-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't include raiding units in Units::isActive; make getPosition return invalid coords #4959
base: develop
Are you sure you want to change the base?
Changes from all commits
e2f1598
6f51b36
b0da75d
556a8bd
8d1ddb7
6f196e2
2750fcf
e9158d4
2995ab9
84e9a09
7664545
2cd932a
fdf8217
a53ed8b
342afcc
b618d45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -446,7 +446,7 @@ static void handle_missing_assignments(color_ostream &out, | |
if (!hf || hf->died_year > -1 || was_expelled(hf)) | ||
continue; | ||
if (auto unit = df::unit::find(hf->unit_id)) { | ||
if (Units::isActive(unit) && !Units::isDead(unit) && active_unit_ids.contains(unit->id)) { | ||
if (!Units::isDead(unit) && Units::isActive(unit) && active_unit_ids.contains(unit->id)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved Or maybe switch to directly testing the |
||
// unit is still alive on the map; assume the unassigment was intentional/expected | ||
continue; | ||
} | ||
|
@@ -458,7 +458,7 @@ static void handle_missing_assignments(color_ostream &out, | |
auto spouse_hf = df::historical_figure::find(spouse_hfid); | ||
auto spouse = spouse_hf ? df::unit::find(spouse_hf->unit_id) : nullptr; | ||
if (spouse_hf && share_with_spouse) { | ||
if (spouse && Units::isActive(spouse) && !Units::isDead(spouse) && active_unit_ids.contains(spouse->id)) | ||
if (spouse && !Units::isDead(spouse) && Units::isActive(spouse) && active_unit_ids.contains(spouse->id)) | ||
{ | ||
DEBUG(cycle,out).print("assigning zone %d (%s) to spouse %s\n", | ||
zone_id, ENUM_KEY_STR(civzone_type, zone->type).c_str(), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Units::isActive
is used in many many places. I'm worried that adding an O(N) search for every call will be a performance killer. I'm also concerned that changing the behavior of this function will break existing callers, both Lua and C++. I'd like to see some research done on those two points before merging this PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a check on my fort, and all of my units in
units.active
had at least one ofinactive
,move_state
, orcan_swap
set. There was aninactive
unit without the other two flags set that had itspos
directly above my well. It's possible the combination could represent a ghost or climbing unit? Probably not going to be a performance consideration given how infrequently those occur. Then there's the actual raiding units, which you won't hit while iteratingunits.active
, and for which the check is mandatory when iteratingunits.all
.I went through all the uses of
isActive
,getPosition
,getUnitsInBox
, andisUnitInBox
I could find, as well as theinactive
flag. There's no change in behavior to anything iterating theunits.active
vector (or indirectly throughforCitizens
/getCitizens
).isDead
is used instead ofisActive
for the case of actual dead units. Anything iteratingunits.all
wasn't properly considering raiding units, which was justRemoteTools.cpp
/spectate
.I don't fully understand
plugins/preserve-rooms.cpp
but it didn't look like the changes break anything. You'd know better than me.