Skip to content

Commit 84791f1

Browse files
authored
Merge pull request #5425 from ab9rf/getplants-crash
resolve `getplants` crash
2 parents bbb5ec4 + a2cda9b commit 84791f1

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Template for new versions:
5656
## New Features
5757

5858
## Fixes
59+
- `getplants`: will no longer crash when faced with plants with growths that do not drop seeds when processed
5960

6061
## Misc Improvements
6162

plugins/getplants.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ selectability selectablePlant(color_ostream& out, const df::plant_raw* plant, bo
154154
bool seedSource = plant->growths[i]->item_type == df::item_type::SEEDS;
155155

156156
if (plant->growths[i]->item_type == df::item_type::PLANT_GROWTH) {
157-
for (size_t k = 0; growth_mat.material->reaction_product.material.mat_type.size(); k++) {
158-
if (growth_mat.material->reaction_product.material.mat_type[k] == plant->material_defs.type[plant_material_def::seed] &&
159-
growth_mat.material->reaction_product.material.mat_index[k] == plant->material_defs.idx[plant_material_def::seed]) {
157+
auto& mat = growth_mat.material->reaction_product.material;
158+
for (size_t k = 0; k < mat.mat_type.size(); k++) {
159+
if (mat.mat_type[k] == plant->material_defs.type[plant_material_def::seed] &&
160+
mat.mat_index[k] == plant->material_defs.idx[plant_material_def::seed]) {
160161
seedSource = true;
161162
break;
162163
}

0 commit comments

Comments
 (0)