Fix EventManager building ID type

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)
develop
lethosor 2019-10-05 20:26:31 -04:00
parent 8675ff660c
commit 08aeb6faeb
2 changed files with 4 additions and 4 deletions

@ -1199,7 +1199,7 @@ void Buildings::clearBuildings(color_ostream& out) {
void Buildings::updateBuildings(color_ostream& out, void* ptr)
{
int32_t id = *((int32_t*)ptr);
int32_t id = (int32_t)(intptr_t)ptr;
auto building = df::building::find(id);
if (building)

@ -273,7 +273,7 @@ void DFHack::EventManager::onStateChange(color_ostream& out, state_change_event
}
for ( size_t a = 0; a < df::global::world->buildings.all.size(); a++ ) {
df::building* b = df::global::world->buildings.all[a];
Buildings::updateBuildings(out, (void*)&(b->id));
Buildings::updateBuildings(out, (void*)intptr_t(b->id));
buildings.insert(b->id);
}
lastSyndromeTime = -1;
@ -609,7 +609,7 @@ static void manageBuildingEvent(color_ostream& out) {
buildings.insert(a);
for ( auto b = copy.begin(); b != copy.end(); b++ ) {
EventHandler bob = (*b).second;
bob.eventHandler(out, (void*)&a);
bob.eventHandler(out, (void*)intptr_t(a));
}
}
nextBuilding = *df::global::building_next_id;
@ -625,7 +625,7 @@ static void manageBuildingEvent(color_ostream& out) {
for ( auto b = copy.begin(); b != copy.end(); b++ ) {
EventHandler bob = (*b).second;
bob.eventHandler(out, (void*)&id);
bob.eventHandler(out, (void*)intptr_t(id));
}
a = buildings.erase(a);
}