From 6565a3a2ba6589ff190fdfda2cabfecc378bebe0 Mon Sep 17 00:00:00 2001 From: JapaMala Date: Thu, 18 Apr 2019 21:49:18 -0500 Subject: [PATCH] Add wounds to RFR --- plugins/proto/RemoteFortressReader.proto | 14 +++++++++++++ .../remotefortressreader.cpp | 20 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/plugins/proto/RemoteFortressReader.proto b/plugins/proto/RemoteFortressReader.proto index 89d34c365..ed7557a2f 100644 --- a/plugins/proto/RemoteFortressReader.proto +++ b/plugins/proto/RemoteFortressReader.proto @@ -466,6 +466,19 @@ message InventoryItem optional int32 body_part_id = 3; } +message WoundPart +{ + optional int32 global_layer_idx = 1; + optional int32 body_part_id = 2; + optional int32 layer_idx = 3; +} + +message UnitWound +{ + repeated WoundPart parts = 1; + optional bool severed_part = 2; +} + message UnitDefinition { required int32 id = 1; @@ -493,6 +506,7 @@ message UnitDefinition optional float subpos_z = 23; optional Coord facing = 24; optional int32 age = 25; + repeated UnitWound wounds = 26; } message UnitList diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index bd21e6d87..f4bf13e2c 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -1,5 +1,5 @@ #include "df_version_int.h" -#define RFR_VERSION "0.20.0" +#define RFR_VERSION "0.20.1" #include #include @@ -92,6 +92,7 @@ #include "df/ui.h" #include "df/unit.h" #include "df/unit_inventory_item.h" +#include "df/unit_wound.h" #include "df/viewscreen_choose_start_sitest.h" #include "df/viewscreen_loadgamest.h" #include "df/viewscreen_savegamest.h" @@ -1653,6 +1654,19 @@ float lerp(float a, float b, float f) return a + f * (b - a); } +void GetWounds(df::unit_wound * wound, UnitWound * send_wound) +{ + for (size_t i = 0; i < wound->parts.size(); i++) + { + auto part = wound->parts[i]; + auto send_part = send_wound->add_parts(); + send_part->set_global_layer_idx(part->global_layer_idx); + send_part->set_body_part_id(part->body_part_id); + send_part->set_layer_idx(part->layer_idx); + } + send_wound->set_severed_part(wound->flags.bits.severed_part); +} + static command_result GetUnitListInside(color_ostream &stream, const BlockRequest *in, UnitList *out) { auto world = df::global::world; @@ -1826,6 +1840,10 @@ static command_result GetUnitListInside(color_ostream &stream, const BlockReques facing->set_z(unit->path.path.z[0] - unit->pos.z); } } + for (size_t i = 0; i < unit->body.wounds.size(); i++) + { + GetWounds(unit->body.wounds[i], send_unit->add_wounds()); + } } return CR_OK; }