getplants: fix crash when world_object_data is not present for certain blocks

develop
lethosor 2020-09-20 01:24:46 -04:00
parent 9d3a168cc3
commit 0e6e00af5e
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
2 changed files with 4 additions and 0 deletions

@ -34,6 +34,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
# Future # Future
## Fixes ## Fixes
- `getplants`: fixed a crash that could occur on some maps
- `search`: fixed an issue causing item counts on the trade screen to display inconsistently when searching - `search`: fixed an issue causing item counts on the trade screen to display inconsistently when searching
- `stockpiles`: fixed a crash when loading food stockpiles - `stockpiles`: fixed a crash when loading food stockpiles

@ -247,6 +247,9 @@ bool picked(const df::plant *plant, int32_t growth_subtype) {
int32_t pos_y = site->global_min_y + plant->pos.y / 48; int32_t pos_y = site->global_min_y + plant->pos.y / 48;
size_t id = pos_x + pos_y * 16 * world_data->world_width; size_t id = pos_x + pos_y * 16 * world_data->world_width;
df::world_object_data *object_data = df::world_object_data::find(id); df::world_object_data *object_data = df::world_object_data::find(id);
if (!object_data) {
return false;
}
df::map_block_column *column = world->map.map_block_columns[(plant->pos.x / 16) * world->map.x_count_block + (plant->pos.y / 16)]; df::map_block_column *column = world->map.map_block_columns[(plant->pos.x / 16) * world->map.x_count_block + (plant->pos.y / 16)];
for (size_t i = 0; i < object_data->picked_growths.x.size(); i++) { for (size_t i = 0; i < object_data->picked_growths.x.size(); i++) {