send growth info through remotefortressreader.cpp

develop
Japa 2016-01-28 00:06:10 +05:30
parent 32e39b8b13
commit 7f3191352c
2 changed files with 53 additions and 2 deletions

@ -444,11 +444,11 @@ message PlantRaw
{
optional int32 index = 1;
optional string id = 2;
repeated string name = 3;
optional string name = 3;
repeated TreeGrowth growths = 4;
}
message PlanRawList
message PlantRawList
{
repeated PlantRaw plant_raws = 1;
}

@ -112,6 +112,7 @@ static command_result GetWorldMap(color_ostream &stream, const EmptyMessage *in,
static command_result GetWorldMapCenter(color_ostream &stream, const EmptyMessage *in, WorldMap *out);
static command_result GetRegionMaps(color_ostream &stream, const EmptyMessage *in, RegionMaps *out);
static command_result GetCreatureRaws(color_ostream &stream, const EmptyMessage *in, CreatureRawList *out);
static command_result GetPlantRaws(color_ostream &stream, const EmptyMessage *in, PlantRawList *out);
void CopyBlock(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC, DFCoord pos);
@ -164,6 +165,7 @@ DFhackCExport RPCService *plugin_rpcconnect(color_ostream &)
svc->addFunction("GetRegionMaps", GetRegionMaps);
svc->addFunction("GetCreatureRaws", GetCreatureRaws);
svc->addFunction("GetWorldMapCenter", GetWorldMapCenter);
svc->addFunction("GetPlantRaws", GetPlantRaws);
return svc;
}
@ -1943,3 +1945,52 @@ static command_result GetCreatureRaws(color_ostream &stream, const EmptyMessage
return CR_OK;
}
static command_result GetPlantRaws(color_ostream &stream, const EmptyMessage *in, PlantRawList *out)
{
if (!df::global::world)
return CR_FAILURE;
df::world * world = df::global::world;
for (int i = 0; i < world->raws.plants.all.size(); i++)
{
df::plant_raw* plant_local = world->raws.plants.all[i];
PlantRaw* plant_remote = out->add_plant_raws();
plant_remote->set_index(i);
plant_remote->set_id(plant_local->id);
plant_remote->set_name(plant_local->name);
for (int j = 0; j < plant_local->growths.size(); j++)
{
df::plant_growth* growth_local = plant_local->growths[j];
TreeGrowth * growth_remote = plant_remote->add_growths();
growth_remote->set_index(j);
growth_remote->set_id(growth_local->id);
growth_remote->set_name(growth_local->name);
for (int k = 0; k < growth_local->prints.size(); k++)
{
df::plant_growth_print* print_local = growth_local->prints[k];
GrowthPrint* print_remote = growth_remote->add_prints();
print_remote->set_priority(print_local->priority);
print_remote->set_color(print_local->color[0] + (print_local->color[1] * 8));
print_remote->set_timing_start(print_local->timing_start);
print_remote->set_timing_end(print_local->timing_end);
}
growth_remote->set_timing_start(growth_local->timing_1);
growth_remote->set_timing_end(growth_local->timing_2);
growth_remote->set_twigs(growth_local->locations.bits.twigs);
growth_remote->set_light_branches(growth_local->locations.bits.light_branches);
growth_remote->set_heavy_branches(growth_local->locations.bits.heavy_branches);
growth_remote->set_trunk(growth_local->locations.bits.trunk);
growth_remote->set_roots(growth_local->locations.bits.roots);
growth_remote->set_cap(growth_local->locations.bits.cap);
growth_remote->set_sapling(growth_local->locations.bits.sapling);
growth_remote->set_timing_start(growth_local->timing_1);
growth_remote->set_timing_end(growth_local->timing_2);
growth_remote->set_trunk_height_start(growth_local->trunk_height_perc_1);
growth_remote->set_trunk_height_end(growth_local->trunk_height_perc_2);
}
}
return CR_OK;
}