diff --git a/library/RemoteTools.cpp b/library/RemoteTools.cpp index 00344d6a2..7f86134b1 100644 --- a/library/RemoteTools.cpp +++ b/library/RemoteTools.cpp @@ -614,6 +614,20 @@ static command_result ListSquads(color_ostream &stream, return CR_OK; } +static command_result SetUnitLabors(color_ostream &stream, const SetUnitLaborsIn *in) +{ + for (size_t i = 0; i < in->change_size(); i++) + { + auto change = in->change(i); + auto unit = df::unit::find(change.unit_id()); + + if (unit) + unit->status.labors[change.labor()] = change.value(); + } + + return CR_OK; +} + CoreService::CoreService() { suspend_depth = 0; @@ -637,6 +651,8 @@ CoreService::CoreService() { addFunction("ListMaterials", ListMaterials, SF_CALLED_ONCE); addFunction("ListUnits", ListUnits); addFunction("ListSquads", ListSquads); + + addFunction("SetUnitLabors", SetUnitLabors); } CoreService::~CoreService() diff --git a/library/proto/Basic.proto b/library/proto/Basic.proto index 246fba22e..64eaea8eb 100755 --- a/library/proto/Basic.proto +++ b/library/proto/Basic.proto @@ -188,3 +188,9 @@ message BasicSquadInfo { // Member histfig ids: repeated sint32 members = 4; }; + +message UnitLaborState { + required int32 unit_id = 1; + required int32 labor = 2; + required bool value = 3; +}; diff --git a/library/proto/BasicApi.proto b/library/proto/BasicApi.proto index 3072f9cad..a5a07aa1c 100755 --- a/library/proto/BasicApi.proto +++ b/library/proto/BasicApi.proto @@ -99,4 +99,9 @@ message ListUnitsOut { message ListSquadsIn {} message ListSquadsOut { repeated BasicSquadInfo value = 1; -} +}; + +// RPC SetUnitLabors : SetUnitLaborsIn -> EmptyMessage +message SetUnitLaborsIn { + repeated UnitLaborState change = 1; +};