implement `Buildings::completebuild` function export from DF

to be used by `build-now`
develop
Kelly Kinkade 2023-10-16 14:05:33 -05:00
parent 4fb7694e6e
commit f1ed469ca3
4 changed files with 20 additions and 1 deletions

@ -130,11 +130,12 @@ Template for new versions:
- unavailable tools are no longer listed in the tag indices in the online docs
## API
- added ``Buildings::completebuild``, used to link a newly created building into the world
- added ``Items::getCapacity``, returns the capacity of an item as a container (reverse-engineered), needed for `combine`
## Lua
- added ``GRAY`` color aliases for ``GREY`` colors
- added ``dfhack.items.getCapacity`` to expose the new module API
- added ``dfhack.items.completebuild`` and ``dfhack.items.getCapacity`` to expose new module APIs
- ``utils.search_text``: text search routine (generalized from internal ``widgets.FilteredList`` logic)
## Removed

@ -2440,6 +2440,7 @@ static const LuaWrapper::FunctionReg dfhack_buildings_module[] = {
WRAPM(Buildings, isPenPasture),
WRAPM(Buildings, isPitPond),
WRAPM(Buildings, isActive),
WRAPM(Buildings, completebuild),
{ NULL, NULL }
};

@ -289,5 +289,10 @@ DFHACK_EXPORT df::building* findPenPitAt(df::coord coord);
* Returns the units currently in the given cage
*/
DFHACK_EXPORT bool getCageOccupants(df::building_cagest *cage, std::vector<df::unit*> &units);
/**
* Finalizes a new building into the world
*/
DFHACK_EXPORT void completebuild(df::building* bld, char in_play);
}
}

@ -1707,3 +1707,15 @@ bool Buildings::getCageOccupants(df::building_cagest *cage, vector<df::unit*> &u
return true;
}
void Buildings::completebuild(df::building* bld, char in_play)
{
CHECK_NULL_POINTER(bld);
auto fp = df::global::buildingst_completebuild;
CHECK_NULL_POINTER(fp);
typedef std::function<void(df::building* bld, char)> FT;
auto f = reinterpret_cast<FT*>(fp);
(*f)(bld, in_play);
}