Add profession color and unit flags to remotefortressreader

develop
Japa 2015-09-05 14:54:12 +05:30
parent 44a670db4d
commit 1a78cabd7c
2 changed files with 18 additions and 3 deletions

@ -178,6 +178,11 @@ message UnitDefinition
optional int32 pos_y = 4; optional int32 pos_y = 4;
optional int32 pos_z = 5; optional int32 pos_z = 5;
optional MatPair race = 6; optional MatPair race = 6;
optional ColorDefinition profession_color = 7;
optional uint32 flags1 = 8;
optional uint32 flags2 = 9;
optional uint32 flags3 = 10;
} }
message UnitList message UnitList

@ -57,6 +57,7 @@
#include "modules/Translation.h" #include "modules/Translation.h"
#include "modules/Items.h" #include "modules/Items.h"
#include "modules/Buildings.h" #include "modules/Buildings.h"
#include "modules/Units.h"
#include "TileTypes.h" #include "TileTypes.h"
#include "MiscUtils.h" #include "MiscUtils.h"
@ -179,20 +180,25 @@ uint16_t fletcher16(uint8_t const *data, size_t bytes)
return sum2 << 8 | sum1; return sum2 << 8 | sum1;
} }
void ConvertDfColor(int16_t in[3], RemoteFortressReader::ColorDefinition * out) void ConvertDfColor(int16_t index, RemoteFortressReader::ColorDefinition * out)
{ {
if (!df::global::enabler) if (!df::global::enabler)
return; return;
auto enabler = df::global::enabler; auto enabler = df::global::enabler;
int index = in[0] + 8 * in[1];
out->set_red((int)(enabler->ccolor[index][0] * 255)); out->set_red((int)(enabler->ccolor[index][0] * 255));
out->set_green((int)(enabler->ccolor[index][1] * 255)); out->set_green((int)(enabler->ccolor[index][1] * 255));
out->set_blue((int)(enabler->ccolor[index][2] * 255)); out->set_blue((int)(enabler->ccolor[index][2] * 255));
} }
void ConvertDfColor(int16_t in[3], RemoteFortressReader::ColorDefinition * out)
{
int index = in[0] + 8 * in[1];
ConvertDfColor(index, out);
}
RemoteFortressReader::TiletypeMaterial TranslateMaterial(df::tiletype_material material) RemoteFortressReader::TiletypeMaterial TranslateMaterial(df::tiletype_material material)
{ {
switch (material) switch (material)
@ -955,6 +961,10 @@ static command_result GetUnitList(color_ostream &stream, const EmptyMessage *in,
send_unit->set_pos_z(unit->pos.z); send_unit->set_pos_z(unit->pos.z);
send_unit->mutable_race()->set_mat_type(unit->race); send_unit->mutable_race()->set_mat_type(unit->race);
send_unit->mutable_race()->set_mat_index(unit->caste); send_unit->mutable_race()->set_mat_index(unit->caste);
ConvertDfColor(Units::getProfessionColor(unit), send_unit->mutable_profession_color());
send_unit->set_flags1(unit->flags1.whole);
send_unit->set_flags2(unit->flags2.whole);
send_unit->set_flags3(unit->flags3.whole);
} }
return CR_OK; return CR_OK;
} }