Skip to content

Commit

Permalink
Merge pull request #4068 from ab9rf/owned_buildings
Browse files Browse the repository at this point in the history
change `unitst::owned_buildings` to `vector<building_civzonest*>`
  • Loading branch information
myk002 authored Nov 29, 2023
2 parents 45422b9 + ea69038 commit 82cbff4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions library/modules/Buildings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,17 +357,15 @@ bool Buildings::setOwner(df::building_civzonest *bld, df::unit *unit)
if (bld->assigned_unit == unit)
return true;

df::building * pbld = virtual_cast<df::building>(bld);

if (bld->assigned_unit)
{
auto &blist = bld->assigned_unit->owned_buildings;
vector_erase_at(blist, linear_index(blist, pbld));
vector_erase_at(blist, linear_index(blist, bld));

if (auto spouse = df::unit::find(bld->assigned_unit->relationship_ids[df::unit_relationship_type::Spouse]))
{
auto &blist = spouse->owned_buildings;
vector_erase_at(blist, linear_index(blist, pbld));
vector_erase_at(blist, linear_index(blist, bld));
}
}

Expand All @@ -381,7 +379,7 @@ bool Buildings::setOwner(df::building_civzonest *bld, df::unit *unit)
if (auto spouse = df::unit::find(unit->relationship_ids[df::unit_relationship_type::Spouse]))
{
auto &blist = spouse->owned_buildings;
if (bld->canUseSpouseRoom() && linear_index(blist, pbld) < 0)
if (bld->canUseSpouseRoom() && linear_index(blist, bld) < 0)
blist.push_back(bld);
}
}
Expand Down
2 changes: 1 addition & 1 deletion library/xml
Submodule xml updated 1 files
+1 −1 df.units.xml

0 comments on commit 82cbff4

Please sign in to comment.