Fix Buildings::setOwner() persistence

Needed to set bld->owner_id for changes to persist across save/load

Fixes #983, thanks to Quietust
develop
lethosor 2016-08-21 20:58:40 -04:00
parent 9171149afb
commit 70ac99cbfa
2 changed files with 9 additions and 0 deletions

@ -41,6 +41,10 @@ New Scripts
----------- -----------
- `load-save`: loads a save non-interactively - `load-save`: loads a save non-interactively
Fixes
-----
- Buildings::setOwner() changes now persist properly when saved
DFHack 0.43.03-r1 DFHack 0.43.03-r1
================= =================

@ -239,6 +239,7 @@ bool Buildings::setOwner(df::building *bld, df::unit *unit)
if (unit) if (unit)
{ {
bld->owner_id = unit->id;
unit->owned_buildings.push_back(bld); unit->owned_buildings.push_back(bld);
if (auto spouse = df::unit::find(unit->relationship_ids[df::unit_relationship_type::Spouse])) if (auto spouse = df::unit::find(unit->relationship_ids[df::unit_relationship_type::Spouse]))
@ -248,6 +249,10 @@ bool Buildings::setOwner(df::building *bld, df::unit *unit)
blist.push_back(bld); blist.push_back(bld);
} }
} }
else
{
bld->owner_id = -1;
}
return true; return true;
} }