Send histfig materials over remotefortressreader.cpp, using unique ids.

develop
Japa 2016-08-26 12:23:50 +05:30
parent 5c3260c382
commit 91cb734a25
1 changed files with 84 additions and 57 deletions

@ -15,6 +15,7 @@
#include "df/caste_raw.h"
#include "df/body_part_raw.h"
#include "df/historical_figure.h"
#include "df/world_history.h"
#include "df/job_item.h"
#include "df/job_material_category.h"
@ -972,6 +973,7 @@ static command_result GetMaterialList(color_ostream &stream, const EmptyMessage
df::world_raws *raws = &world->raws;
df::world_history *history = &world->history;
MaterialInfo mat;
for (int i = 0; i < raws->inorganics.size(); i++)
{
@ -1016,7 +1018,7 @@ static command_result GetMaterialList(color_ostream &stream, const EmptyMessage
df::creature_raw * creature = raws->creatures.all[i];
for (int j = 0; j < creature->material.size(); j++)
{
mat.decode(j + 19, i);
mat.decode(j + MaterialInfo::CREATURE_BASE, i);
MaterialDefinition *mat_def = out->add_material_list();
mat_def->mutable_mat_pair()->set_mat_type(j + 19);
mat_def->mutable_mat_pair()->set_mat_index(i);
@ -1031,6 +1033,31 @@ static command_result GetMaterialList(color_ostream &stream, const EmptyMessage
}
}
}
for (int i = 0; i < history->figures.size(); i++)
{
df::historical_figure * figure = history->figures[i];
if (figure->race < 0)
continue;
df::creature_raw * creature = raws->creatures.all[figure->race];
for (int j = 0; j < creature->material.size(); j++)
{
mat.decode(j + MaterialInfo::FIGURE_BASE, i);
MaterialDefinition *mat_def = out->add_material_list();
mat_def->mutable_mat_pair()->set_mat_type(j + MaterialInfo::FIGURE_BASE);
mat_def->mutable_mat_pair()->set_mat_index(i);
stringstream id;
id << "HF" << i << mat.getToken();
mat_def->set_id(id.str());
mat_def->set_name(mat.toString()); //find the name at cave temperature;
if (creature->material[j]->state_color[GetState(creature->material[j])] < raws->language.colors.size())
{
df::descriptor_color *color = raws->language.colors[creature->material[j]->state_color[GetState(creature->material[j])]];
mat_def->mutable_state_color()->set_red(color->red * 255);
mat_def->mutable_state_color()->set_green(color->green * 255);
mat_def->mutable_state_color()->set_blue(color->blue * 255);
}
}
}
for (int i = 0; i < raws->plants.all.size(); i++)
{
df::plant_raw * plant = raws->plants.all[i];