Added a simple unit listing to remotefortressreader.cpp. Updated stonesense.

develop
Japa 2014-12-11 20:10:49 +05:30
parent 6297c83418
commit d11df5b87f
3 changed files with 35 additions and 1 deletions

@ -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;

@ -38,6 +38,8 @@
#include "df/mental_attribute_type.h"
#include <df/color_modifier_raw.h>
#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;
}

@ -1 +1 @@
Subproject commit 4e288141586c7da504c3c4f0d5d6b4c289aa3614
Subproject commit 8270ef2892b640a2e5753844a5e917ba96523fbb