Skip to content

Commit

Permalink
Fix issues when user supplies incorrect number of encounters
Browse files Browse the repository at this point in the history
  • Loading branch information
GriffinRichards committed Nov 7, 2023
1 parent 6ee76f8 commit 49cb69f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down
3 changes: 1 addition & 2 deletions src/ui/encountertablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit 49cb69f

Please sign in to comment.