Added a function to get a partial creature raw list.

develop
Japa 2017-06-23 19:54:22 +05:30
parent a2f6c80298
commit 31dbb792ca
2 changed files with 24 additions and 1 deletions

@ -775,3 +775,9 @@ message VersionInfo
optional string dfhack_version = 2;
optional string remote_fortress_reader_version = 3;
}
message ListRequest
{
optional int32 list_start = 1;
optional int32 list_end = 2;
}

@ -137,6 +137,7 @@ static command_result GetWorldMapCenter(color_ostream &stream, const EmptyMessag
static command_result GetRegionMaps(color_ostream &stream, const EmptyMessage *in, RegionMaps *out);
static command_result GetRegionMapsNew(color_ostream &stream, const EmptyMessage *in, RegionMaps *out);
static command_result GetCreatureRaws(color_ostream &stream, const EmptyMessage *in, CreatureRawList *out);
static command_result GetPartialCreatureRaws(color_ostream &stream, const ListRequest *in, CreatureRawList *out);
static command_result GetPlantRaws(color_ostream &stream, const EmptyMessage *in, PlantRawList *out);
static command_result CopyScreen(color_ostream &stream, const EmptyMessage *in, ScreenCapture *out);
static command_result PassKeyboardEvent(color_ostream &stream, const KeyboardEvent *in);
@ -250,6 +251,7 @@ DFhackCExport RPCService *plugin_rpcconnect(color_ostream &)
svc->addFunction("GetRegionMaps", GetRegionMaps);
svc->addFunction("GetRegionMapsNew", GetRegionMapsNew);
svc->addFunction("GetCreatureRaws", GetCreatureRaws);
svc->addFunction("GetPartialCreatureRaws", GetPartialCreatureRaws);
svc->addFunction("GetWorldMapCenter", GetWorldMapCenter);
svc->addFunction("GetPlantRaws", GetPlantRaws);
svc->addFunction("CopyScreen", CopyScreen);
@ -2259,13 +2261,28 @@ static command_result GetRegionMapsNew(color_ostream &stream, const EmptyMessage
}
static command_result GetCreatureRaws(color_ostream &stream, const EmptyMessage *in, CreatureRawList *out)
{
return GetPartialCreatureRaws(stream, NULL, out);
}
static command_result GetPartialCreatureRaws(color_ostream &stream, const ListRequest *in, CreatureRawList *out)
{
if (!df::global::world)
return CR_FAILURE;
df::world * world = df::global::world;
for (int i = 0; i < world->raws.creatures.all.size(); i++)
int list_start = 0;
int list_end = world->raws.creatures.all.size();
if (in != nullptr)
{
list_start = in->list_start();
if(in->list_end() < list_end)
list_end = in->list_end();
}
for (int i = list_start; i < list_end; i++)
{
df::creature_raw * orig_creature = world->raws.creatures.all[i];