Skip to content
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

Raiding units aren't flagged inactive, update code and docs #4948

Closed
wants to merge 10 commits into from

Conversation

Bumber64
Copy link
Contributor

@Bumber64 Bumber64 commented Sep 20, 2024

Add Units::isInPlay fn to check isActive then scan units.active. Useful when you've got a unit pointer, but you don't know if it's in the active units vector. (DF unsets the inactive flag a few ticks after raiding units leave the map.)

Updated some code and docs using this info. I would've changed the isActive function, but there may be performance concerns. Would be great if Bay12 could just use a flag for this, but we can't count on raiding bugs being fixed this decade.

Made getUnitsInBox rule out inactive units by default, since death and map edge locations aren't where the unit actually is.

* Add docs for units.isInPlay
* Update docs w/r/t item/unit active assumptions
Since we're ruling out inactive non-dead units, prevent raiding unit jank.
* Update changelog.txt
* Update Lua API.rst
* Update LuaApi.cpp
* Update Units.h
* Update Units.cpp
@Bumber64 Bumber64 changed the title Add Units::isInplay; Update code and docs (raiding units aren't flagged inactive) Raiding units aren't flagged inactive, update code and docs Sep 21, 2024
@Bumber64
Copy link
Contributor Author

Couldn't find any places in existing code that would benefit from a Units::isInPlay. linear_index can be used if someone needs to scan world.units.all.

@Bumber64
Copy link
Contributor Author

Bumber64 commented Sep 22, 2024

hf.info.whereabouts.army_id was mentioned as a way to get the army so we could check for raiding. If that's only set when they're off the map, that could work.

hf.info.whereabouts.site_id can be checked to rule out exiled units after arrival at their new site, but it gives the lair for megabeasts currently on the map.

@Bumber64 Bumber64 marked this pull request as draft September 22, 2024 14:39
@Bumber64
Copy link
Contributor Author

Replaced by #4959

@Bumber64 Bumber64 closed this Sep 24, 2024
@Bumber64 Bumber64 deleted the units_inplay branch September 24, 2024 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant