Fixes#3159.
Valid map coordinates from (0, 0, 0) to (world->map.x_count - 1, world->map.y_count - 1, world->map.z_count - 1).
Stockpile coords (x1, y1, z) to (x2, y2, z) may lie outside of this region.
Use min of (0, 0) and max of (world->map.x_count - 1, world->map.y_count - 1) when iterating the block.
Changed the StockpileIterator::operator++ to checks block based on <= 16 rather than <16. Previously it was not returning items at stockpile tiles at the block boundary. Identified as part of combine.lua changes.
this allows callers of Buildings::setSize() to "pre-initialize" the
extents to declare non-rectangular structures. this allows quickfort to
create non-rectangular stockpiles, farm plots, zones, etc. the extents
are still reset as before if the size of the building doesn't match the
caller's expectations.
this commit also fixes a memory leak when setSize() allocates memory for
extents, but the memory is not deallocated if the building is ultimately
invalid for some reason.
The pointer to the building ID was sometimes not dereferenced properly.
Addressed by switching to an ID cast to a pointer type for consistency with
other types of events.
Fixes#1434
Ref #1003 (19695b4ee7)
Broken in #1253 (a7dfacd1c5)
Previously, there was some disagreement over whether event handlers such as
Buildings::updateBuildings() took building pointers or building IDs shoved
into pointers. It turned out to be the latter, which, unfortunately, did not
compile on x64. Passing building IDs isn't possible in all cases, because
building event handlers can be called for recently-deleted buildings too.
Pointers to building IDs do work reliably, though.
Fixes#1003