From 069d6b67d69e723a58a2f4083e99aa22c06ec281 Mon Sep 17 00:00:00 2001 From: Japa Date: Tue, 21 Jun 2016 22:42:47 +0530 Subject: [PATCH] Send all size modifiers through remotefortressreader. --- plugins/proto/RemoteFortressReader.proto | 37 ++++++++++++++++++++-- plugins/remotefortressreader.cpp | 40 ++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/plugins/proto/RemoteFortressReader.proto b/plugins/proto/RemoteFortressReader.proto index 327398c4a..8f8d1b923 100644 --- a/plugins/proto/RemoteFortressReader.proto +++ b/plugins/proto/RemoteFortressReader.proto @@ -258,7 +258,7 @@ message UnitAppearance repeated int32 body_modifiers = 1; repeated int32 bp_modifiers = 2; optional int32 size_modifier = 3; - + repeated int32 colors = 4; } message UnitDefinition @@ -278,7 +278,7 @@ message UnitDefinition optional string name = 13; optional int32 blood_max = 14; optional int32 blood_count = 15; - + optional UnitAppearance appearance = 16; } message UnitList @@ -440,6 +440,33 @@ message RegionMaps repeated RegionMap region_maps = 2; } +enum PatternType +{ + MONOTONE = 0; + STRIPES = 1; + IRIS_EYE = 2; + SPOTS = 3; + PUPIL_EYE = 4; + MOTTLED = 5; +} + +message PatternDescriptor +{ + optional string id = 1; + repeated ColorDefinition colors = 2; + optional PatternType pattern = 3; +} + +message ColorModifierRaw +{ + repeated PatternDescriptor patterns = 1; + repeated int32 body_part_id = 2; + repeated int32 tissue_layer_id = 3; + optional int32 start_date = 4; + optional int32 end_date = 5; + optional string part = 6; +} + message BodyPartLayerRaw { optional string layer_name = 1; @@ -461,6 +488,8 @@ message BodyPartRaw message BpAppearanceModifier { optional string type = 1; + optional int32 mod_min = 2; + optional int32 mod_max = 3; } message CasteRaw @@ -477,6 +506,8 @@ message CasteRaw repeated int32 modifier_idx = 10; repeated int32 part_idx = 11; repeated int32 layer_idx = 12; + repeated BpAppearanceModifier body_appearance_modifiers = 13; + repeated ColorModifierRaw color_modifiers = 14; } message CreatureRaw @@ -580,4 +611,4 @@ message KeyboardEvent optional uint32 sym = 5; optional uint32 mod = 6; optional uint32 unicode = 7; -} \ No newline at end of file +} diff --git a/plugins/remotefortressreader.cpp b/plugins/remotefortressreader.cpp index 8c7747921..af39fbe76 100644 --- a/plugins/remotefortressreader.cpp +++ b/plugins/remotefortressreader.cpp @@ -68,6 +68,7 @@ #include "df/bp_appearance_modifier.h" #include "df/body_part_layer_raw.h" +#include "df/body_appearance_modifier.h" //DFhack specific headers #include "modules/Maps.h" @@ -1512,6 +1513,15 @@ static command_result GetUnitList(color_ostream &stream, const EmptyMessage *in, { send_unit->set_name(DF2UTF(Translation::TranslateName(Units::getVisibleName(unit)))); } + + auto appearance = send_unit->mutable_appearance(); + for (int j = 0; j < unit->appearance.body_modifiers.size(); j++) + appearance->add_body_modifiers(unit->appearance.body_modifiers[j]); + for (int j = 0; j < unit->appearance.bp_modifiers.size(); j++) + appearance->add_bp_modifiers(unit->appearance.bp_modifiers[j]); + for (int j = 0; j < unit->appearance.colors.size(); j++) + appearance->add_colors(unit->appearance.colors[j]); + appearance->set_size_modifier(unit->appearance.size_modifier); } return CR_OK; } @@ -2324,6 +2334,18 @@ static command_result GetCreatureRaws(color_ostream &stream, const EmptyMessage auto send_mod = send_caste->add_modifiers(); auto orig_mod = orig_caste->bp_appearance.modifiers[k]; send_mod->set_type(ENUM_KEY_STR(appearance_modifier_type, orig_mod->type)); + + if (orig_mod->growth_rate > 0) + { + send_mod->set_mod_min(orig_mod->growth_min); + send_mod->set_mod_max(orig_mod->growth_max); + } + else + { + send_mod->set_mod_min(orig_mod->ranges[0]); + send_mod->set_mod_max(orig_mod->ranges[6]); + } + } for (int k = 0; k < orig_caste->bp_appearance.modifier_idx.size(); k++) { @@ -2331,6 +2353,24 @@ static command_result GetCreatureRaws(color_ostream &stream, const EmptyMessage send_caste->add_part_idx(orig_caste->bp_appearance.part_idx[k]); send_caste->add_layer_idx(orig_caste->bp_appearance.layer_idx[k]); } + for (int k = 0; k < orig_caste->body_appearance_modifiers.size(); k++) + { + auto send_mod = send_caste->add_body_appearance_modifiers(); + auto orig_mod = orig_caste->body_appearance_modifiers[k]; + + send_mod->set_type(ENUM_KEY_STR(appearance_modifier_type, orig_mod->type)); + + if (orig_mod->growth_rate > 0) + { + send_mod->set_mod_min(orig_mod->growth_min); + send_mod->set_mod_max(orig_mod->growth_max); + } + else + { + send_mod->set_mod_min(orig_mod->ranges[0]); + send_mod->set_mod_max(orig_mod->ranges[6]); + } + } } }