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,6 +48,7 @@ int ComplexLevelStatData::_get_stat_diff(int main_stat, int old_level, int new_l
}
ComplexLevelStatData::ComplexLevelStatData() {
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();
@ -60,6 +61,7 @@ ComplexLevelStatData::ComplexLevelStatData() {
}
}
}
}
ComplexLevelStatData::~ComplexLevelStatData() {
for (int i = 0; i < ESS::get_singleton()->get_max_character_level(); ++i) {

View File

@ -46,7 +46,9 @@ int SimpleLevelStatData::_get_stat_diff(int main_stat, int old_level, int new_le
}
SimpleLevelStatData::SimpleLevelStatData() {
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) {
_stat_per_level.set(i, 0);

View File

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