diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d067e60..b1b0c4ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - Fix the selection outline sticking in single-tile mode on the Prefab tab. - Fix heal location data being cleared if certain spaces aren't used in the table. - Fix bad URL color contrast on dark themes. +- Fix some issues when too few/many pokémon are specified for a wild encounter group. ## [5.1.1] - 2023-02-20 ### Added diff --git a/src/project.cpp b/src/project.cpp index 422c09c5..fd7d7dcc 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -1670,6 +1670,11 @@ bool Project::readWildMonData() { newMon.species = monObj["species"].string_value(); header.wildMons[field].wildPokemon.append(newMon); } + // If the user supplied too few pokémon for this group then we fill in the rest. + for (int i = header.wildMons[field].wildPokemon.length(); i < monField.encounterRates.length(); i++) { + WildPokemon newMon; // Keep default values + header.wildMons[field].wildPokemon.append(newMon); + } } } wildMonData[mapConstant].insert({encounterObj["base_label"].string_value(), header}); diff --git a/src/ui/encountertablemodel.cpp b/src/ui/encountertablemodel.cpp index b38529af..fd870e40 100644 --- a/src/ui/encountertablemodel.cpp +++ b/src/ui/encountertablemodel.cpp @@ -10,11 +10,10 @@ EncounterTableModel::EncounterTableModel(WildMonInfo info, EncounterFields field this->resize(this->monInfo.wildPokemon.size(), ColumnType::Count); - this->slotRatios = fields[fieldIndex].encounterRates; - for (int r = 0; r < this->numRows; r++) { this->groupNames.append(QString()); this->slotPercentages.append(0.0); + this->slotRatios.append(fields[fieldIndex].encounterRates.value(r, 0)); } if (!this->encounterFields[this->fieldIndex].groups.empty()) {