MCPcopy Create free account
hub / github.com/DFHack/dfhack / hasValidMapPos

Function hasValidMapPos

plugins/autobutcher.cpp:627–632  ·  view source on GitHub ↗

found a unit with weird position values on one of my maps (negative and in the thousands) it didn't appear in the animal stocks screen, but looked completely fine otherwise (alive, tame, own, etc) maybe a rare bug, but better avoid assigning such units to zones or slaughter etc.

Source from the content-addressed store, hash-verified

625// it didn't appear in the animal stocks screen, but looked completely fine otherwise (alive, tame, own, etc)
626// maybe a rare bug, but better avoid assigning such units to zones or slaughter etc.
627static bool hasValidMapPos(df::unit *unit) {
628 return unit->pos.x >= 0 && unit->pos.y >= 0 && unit->pos.z >= 0
629 && unit->pos.x < world->map.x_count
630 && unit->pos.y < world->map.y_count
631 && unit->pos.z < world->map.z_count;
632}
633
634// built cage in a zone (supposed to detect zoo cages)
635static bool isInBuiltCageRoom(df::unit *unit) {

Callers 1

isInappropriateUnitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected