use insert_into_vector, tweak docs again

develop
20k 2023-02-27 02:15:26 +00:00
parent c0bd452c86
commit c38a288eee
2 changed files with 5 additions and 6 deletions

@ -1594,9 +1594,9 @@ Military module
* ``dfhack.military.makeSquad(assignment_id)``
Creates a new squad associated with the assignment (ie df::entity_position_assignment, via `id``) and returns it.
Creates a new squad associated with the assignment (ie ``df::entity_position_assignment``, via ``id``) and returns it.
Fails if a squad already exists that is associated with that assignment, or if the assignment is not a fort mode player controlled squad.
Note: This function does not name the squad: consider setting a nickname (under result.name.nickname), and/or filling out the language_name object at result.name.
Note: This function does not name the squad: consider setting a nickname (under ``squad.name.nickname``), and/or filling out the ``language_name`` object at ``squad.name``.
The returned squad is otherwise complete and requires no more setup to work correctly.
* ``dfhack.military.updateRoomAssignments(squad_id, assignment_id, squad_use_flags)``

@ -1,6 +1,7 @@
#include <string>
#include <vector>
#include <array>
#include "MiscUtils.h"
#include "modules/Military.h"
#include "modules/Translation.h"
#include "df/building.h"
@ -258,18 +259,16 @@ void Military::updateRoomAssignments(int32_t squad_id, int32_t civzone_id, df::s
{
room_from_squad = new df::squad::T_rooms();
room_from_squad->building_id = civzone_id;
squad->rooms.push_back(room_from_squad);
std::sort(squad->rooms.begin(), squad->rooms.end(), [](df::squad::T_rooms* a, df::squad::T_rooms* b){return a->building_id < b->building_id;});
insert_into_vector(squad->rooms, &df::squad::T_rooms::building_id, room_from_squad);
}
if (room_from_building == nullptr)
{
room_from_building = new df::building_civzonest::T_squad_room_info();
room_from_building->squad_id = squad_id;
zone->squad_room_info.push_back(room_from_building);
std::sort(zone->squad_room_info.begin(), zone->squad_room_info.end(), [](df::building_civzonest::T_squad_room_info* a, df::building_civzonest::T_squad_room_info* b){return a->squad_id < b->squad_id;});
insert_into_vector(zone->squad_room_info, &df::building_civzonest::T_squad_room_info::squad_id, room_from_building);
}
if (room_from_squad)