From d11df5b87fea0c691dc5fad3081f8e621b0ebb42 Mon Sep 17 00:00:00 2001 From: Japa Date: Thu, 11 Dec 2014 20:10:49 +0530 Subject: [PATCH] Added a simple unit listing to remotefortressreader.cpp. Updated stonesense. --- plugins/proto/RemoteFortressReader.proto | 14 ++++++++++++++ plugins/remotefortressreader.cpp | 20 ++++++++++++++++++++ plugins/stonesense | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/plugins/proto/RemoteFortressReader.proto b/plugins/proto/RemoteFortressReader.proto index e65345b3e..7f8435e72 100644 --- a/plugins/proto/RemoteFortressReader.proto +++ b/plugins/proto/RemoteFortressReader.proto @@ -132,6 +132,20 @@ message MaterialList{ repeated MaterialDefinition material_list = 1; } +message UnitDefinition +{ + required int32 id = 1; + optional bool isValid = 2; + optional int32 pos_x = 3; + optional int32 pos_y = 4; + optional int32 pos_z = 5; +} + +message UnitList +{ + repeated UnitDefinition creature_list = 1; +} + message BlockRequest { optional int32 blocks_needed = 1; diff --git a/plugins/remotefortressreader.cpp b/plugins/remotefortressreader.cpp index 3ef673119..46330f143 100644 --- a/plugins/remotefortressreader.cpp +++ b/plugins/remotefortressreader.cpp @@ -38,6 +38,8 @@ #include "df/mental_attribute_type.h" #include +#include "df/unit.h" + //DFhack specific headers #include "modules/Maps.h" #include "modules/MapCache.h" @@ -65,6 +67,8 @@ static command_result GetTiletypeList(color_ostream &stream, const EmptyMessage static command_result GetBlockList(color_ostream &stream, const BlockRequest *in, BlockList *out); static command_result GetPlantList(color_ostream &stream, const BlockRequest *in, PlantList *out); static command_result CheckHashes(color_ostream &stream, const EmptyMessage *in); +static command_result GetUnitList(color_ostream &stream, const EmptyMessage *in, UnitList *out); + void CopyBlock(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC); void FindChangedBlocks(); @@ -109,6 +113,7 @@ DFhackCExport RPCService *plugin_rpcconnect(color_ostream &) svc->addFunction("CheckHashes", CheckHashes); svc->addFunction("GetTiletypeList", GetTiletypeList); svc->addFunction("GetPlantList", GetPlantList); + svc->addFunction("GetUnitList", GetUnitList); return svc; } @@ -650,3 +655,18 @@ static command_result GetPlantList(color_ostream &stream, const BlockRequest *in } return CR_OK; } + +static command_result GetUnitList(color_ostream &stream, const EmptyMessage *in, UnitList *out) +{ + auto world = df::global::world; + for (int i = 0; i < world->units.all.size(); i++) + { + auto unit = world->units.all[i]; + auto send_unit = out->add_creature_list(); + send_unit->set_id(unit->id); + send_unit->set_pos_x(unit->pos.x); + send_unit->set_pos_y(unit->pos.y); + send_unit->set_pos_z(unit->pos.z); + } + return CR_OK; +} \ No newline at end of file diff --git a/plugins/stonesense b/plugins/stonesense index 4e2881415..8270ef289 160000 --- a/plugins/stonesense +++ b/plugins/stonesense @@ -1 +1 @@ -Subproject commit 4e288141586c7da504c3c4f0d5d6b4c289aa3614 +Subproject commit 8270ef2892b640a2e5753844a5e917ba96523fbb