diff --git a/docs/changelog.txt b/docs/changelog.txt index dd109a218..2da870ca7 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -171,6 +171,12 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - ``Screen::Pen``: now accepts ``top_of_text`` and ``bottom_of_text`` properties to support offset text in graphics mode - `overlay`: overlay widgets can now specify a default enabled state if they are not already set in the player's overlay config file - ``Lua::Push``: now supports ``std::unordered_map`` +- `Military`: New module for military functionality +- `Military`: new ``makeSquad`` to create a squad +- `Military`: changed ``getSquadName`` to take a squad identifier +- `Military`: new ``updateRoomAssignments`` for assigning a squad to a barracks and archery range +- ``Maps::GetBiomeType`` renamed to ``Maps::getBiomeType`` for consistency +- ``Maps::GetBiomeTypeRef`` renamed to ``Maps::getBiomeTypeRef`` for consistency ## Lua - `helpdb`: new function: ``helpdb.refresh()`` to force a refresh of the database. Call if you are a developer adding new scripts, loading new plugins, or changing help text during play @@ -181,6 +187,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: -@ ``gui.ZScreen``: new attribute: ``defocusable`` for controlling whether a window loses keyboard focus when the map is clicked - ``widgets.Label``: token ``tile`` properties can now be either pens or numeric texture ids - `tiletypes`: now has a Lua API! ``tiletypes_setTile`` +- ``maps.getBiomeType``: exposed preexisting function to Lua ## Removed - `autohauler`: no plans to port to v50, as it just doesn't make sense with the new work detail system diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index 9125ca902..304ce6651 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -1594,16 +1594,16 @@ Military Module API * ``dfhack.military.makeSquad(assignment_id)`` - Creates a new squad associated with the assignment. Fails if one already exists - Note: This function does not name the squad, but they are otherwise complete + Creates a new squad associated with the assignment. Fails if one already exists. + Note: This function does not name the squad, but they are otherwise complete. * ``dfhack.military.updateRoomAssignments(squad_id, assignment_id, squad_use_flags)`` - Sets the sleep, train, indiv_eq, and squad_eq flags when training at a barracks + Sets the sleep, train, indiv_eq, and squad_eq flags when training at a barracks. -* ``dfhack.military.getSquadName(squad)`` +* ``dfhack.military.getSquadName(squad_id)`` - Returns the name of a squad + Returns the name of a squad/ Action Timer API ~~~~~~~~~~~~~~~~ diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index 13ea1a7fe..c9bdc3021 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -1940,7 +1940,7 @@ static const luaL_Reg dfhack_units_funcs[] = { /***** Military Module *****/ static const LuaWrapper::FunctionReg dfhack_military_module[] = { - WRAPM(Military, makeSquad), + WRAPM(Military, makeSquad), WRAPM(Military, updateRoomAssignments), WRAPM(Military, getSquadName), { NULL, NULL } diff --git a/library/include/modules/Military.h b/library/include/modules/Military.h index 19ed47ee2..3a9710687 100644 --- a/library/include/modules/Military.h +++ b/library/include/modules/Military.h @@ -10,10 +10,10 @@ namespace DFHack { namespace Military { - -DFHACK_EXPORT std::string getSquadName(df::unit *unit); + +DFHACK_EXPORT std::string getSquadName(int32_t squad_id); DFHACK_EXPORT df::squad* makeSquad(int32_t assignment_id); DFHACK_EXPORT void updateRoomAssignments(int32_t squad_id, int32_t civzone_id, df::squad_use_flags flags); } -} \ No newline at end of file +} diff --git a/library/modules/Military.cpp b/library/modules/Military.cpp index b67b3a129..1dd71f11d 100644 --- a/library/modules/Military.cpp +++ b/library/modules/Military.cpp @@ -22,12 +22,9 @@ using namespace df::enums; using df::global::world; using df::global::plotinfo; -std::string Military::getSquadName(df::unit *unit) +std::string Military::getSquadName(int32_t squad_id) { - CHECK_NULL_POINTER(unit); - if (unit->military.squad_id == -1) - return ""; - df::squad *squad = df::squad::find(unit->military.squad_id); + df::squad *squad = df::squad::find(squad_id); if (!squad) return ""; if (squad->alias.size() > 0) @@ -304,4 +301,4 @@ void Military::updateRoomAssignments(int32_t squad_id, int32_t civzone_id, df::s } } } -} \ No newline at end of file +} diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index 6731aa513..b8f6ce706 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -1305,7 +1306,7 @@ void viewscreen_unitlaborsst::refreshNames() cur->job_mode = UnitInfo::JOB; } if (unit->military.squad_id > -1) { - cur->squad_effective_name = Units::getSquadName(unit); + cur->squad_effective_name = Military::getSquadName(unit->military.squad_id); cur->squad_info = stl_sprintf("%i", unit->military.squad_position + 1) + "." + cur->squad_effective_name; } else { cur->squad_effective_name = "";