Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues when user supplies incorrect number of encounters #554

Merged
merged 1 commit into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading