Skip to content

Conversation

UnknowableCoder
Copy link

After doing some research on the ways to properly get access to site IDs in Adventure Mode, I realized the SC_MAP_LOADED state change only triggers on transitioning from no map to having a map loaded. The logic can easily be expanded to also consider the cases when there is a map and the map changes. For this, I propose a new state change, which I have tentatively called SC_NEW_MAP_AVAILABLE.

In the same vein, while World::GetCurrentSiteId should correctly return the current site ID (or -1 if no site), some practical use cases may benefit from being able to get all sites in a caller-provided range around the adventurer. For this reason, I propose the introduction of World::GetCurrentSiteIdsWithExtraRange, which extends the logic of the former function to take an std::vector as an in-parameter and return all applicable sites, optionally with extra range in x and y and a maximum number of sites to be return (which would be ordered by ID and not distance...).

DFHACK_EXPORT df::unit * getAdventurer();

DFHACK_EXPORT int32_t GetCurrentSiteId();
DFHACK_EXPORT void GetCurrentSiteIdsWithExtraRange(std::vector<int32_t>& ids, const int32_t x_range = 0, const int32_t y_range = 0, const uint32_t max = UINT_MAX);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be documented in docs/dev/Lua API.rst

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.

2 participants