Check it the ESS singleton is null in LevelStatData's constructor.

This commit is contained in:
Relintai 2022-03-17 11:16:56 +01:00
parent d34ba0a7f4
commit 31e29ebd71
3 changed files with 14 additions and 8 deletions

View File

@ -48,15 +48,17 @@ int ComplexLevelStatData::_get_stat_diff(int main_stat, int old_level, int new_l
} }
ComplexLevelStatData::ComplexLevelStatData() { ComplexLevelStatData::ComplexLevelStatData() {
_stat_per_level.resize(ESS::get_singleton()->get_max_character_level()); if (ESS::get_singleton()->get_max_character_level()) {
_stat_per_level.resize(ESS::get_singleton()->get_max_character_level());
int msc = ESS::get_singleton()->stat_get_main_stat_count(); int msc = ESS::get_singleton()->stat_get_main_stat_count();
for (int i = 0; i < ESS::get_singleton()->get_max_character_level(); ++i) { for (int i = 0; i < ESS::get_singleton()->get_max_character_level(); ++i) {
_stat_per_level.write[i].resize(msc); _stat_per_level.write[i].resize(msc);
for (int j = 0; j < msc; ++j) { for (int j = 0; j < msc; ++j) {
_stat_per_level.write[i].set(j, 0); _stat_per_level.write[i].set(j, 0);
}
} }
} }
} }

View File

@ -46,7 +46,9 @@ int SimpleLevelStatData::_get_stat_diff(int main_stat, int old_level, int new_le
} }
SimpleLevelStatData::SimpleLevelStatData() { SimpleLevelStatData::SimpleLevelStatData() {
_stat_per_level.resize(ESS::get_singleton()->stat_get_main_stat_count()); if (ESS::get_singleton()) {
_stat_per_level.resize(ESS::get_singleton()->stat_get_main_stat_count());
}
for (int i = 0; i < _stat_per_level.size(); ++i) { for (int i = 0; i < _stat_per_level.size(); ++i) {
_stat_per_level.set(i, 0); _stat_per_level.set(i, 0);

View File

@ -90,7 +90,9 @@ void StatData::set_mod_stat_multiplier(int index, float value) {
StatData::StatData() { StatData::StatData() {
//TODO remove? let properties handle this? //TODO remove? let properties handle this?
_entries.resize(ESS::get_singleton()->stat_get_count()); if (ESS::get_singleton()) {
_entries.resize(ESS::get_singleton()->stat_get_count());
}
for (int i = 0; i < _entries.size(); ++i) { for (int i = 0; i < _entries.size(); ++i) {
_entries.set(i, 0); _entries.set(i, 0);