Skip to content
Open
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 docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Template for new versions:
- `preserve-rooms`: don't warn when a room is assigned to a non-existent unit. this is now common behavior for DF when it keeps a room for an unloaded unit
- fixed an overly restrictive type constraint that resulted in some object types being glossed as a boolean when passed as an argument from C++ to Lua
- `plants`: will no longer generate a traceback when a filter is used
- ``Maps::getTileBlock``: added a check in getTileBlock to ensure it does not access unallocated blocks.

## Misc Improvements
- All places where units are listed in DFHack tools now show the translated English name in addition to the native name. In particular, this makes units searchable by English name in `gui/sitemap`.
Expand Down
15 changes: 14 additions & 1 deletion library/modules/Maps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,20 @@ df::map_block *Maps::getTileBlock (int32_t x, int32_t y, int32_t z)
{
if (!isValidTilePos(x,y,z))
return NULL;
return world->map.block_index[x >> 4][y >> 4][z];

auto &block_index = world->map.block_index;

int32_t bx = x >> 4;
int32_t by = y >> 4;

if (block_index == NULL ||
block_index[bx] == NULL ||
block_index[bx][by] == NULL ||
block_index[bx][by][z] == NULL) {
return NULL;
}

return world->map.block_index[bx][by][z];
}

df::map_block *Maps::ensureTileBlock (int32_t x, int32_t y, int32_t z)
Expand Down