From 58bef276de608cc92823e6d685971edcec035540 Mon Sep 17 00:00:00 2001 From: Japa Date: Fri, 19 Jan 2018 08:25:16 +0530 Subject: [PATCH] send item imrpovements --- plugins/proto/RemoteFortressReader.proto | 4 ++-- plugins/remotefortressreader/item_reader.cpp | 23 ++++++++++++++++++-- plugins/remotefortressreader/item_reader.h | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/plugins/proto/RemoteFortressReader.proto b/plugins/proto/RemoteFortressReader.proto index 463e368fc..ef32b9b81 100644 --- a/plugins/proto/RemoteFortressReader.proto +++ b/plugins/proto/RemoteFortressReader.proto @@ -907,8 +907,8 @@ enum ImprovementType message ItemImprovement { - optional MatPair mat_type = 1; + optional MatPair material = 1; optional ImprovementType type = 2; optional int32 shape = 3; - + optional int32 specific_type= 4; } diff --git a/plugins/remotefortressreader/item_reader.cpp b/plugins/remotefortressreader/item_reader.cpp index 256d78fd9..ed9c5f204 100644 --- a/plugins/remotefortressreader/item_reader.cpp +++ b/plugins/remotefortressreader/item_reader.cpp @@ -8,6 +8,9 @@ #include "df/item_toolst.h" #include "df/item_smallgemst.h" #include "df/itemimprovement.h" +#include "df/itemimprovement_bandsst.h" +#include "df/itemimprovement_coveredst.h" +#include "df/itemimprovement_itemspecificst.h" #include "df/itemimprovement_threadst.h" #include "df/itemdef.h" #include "df/map_block.h" @@ -287,22 +290,38 @@ void CopyItem(RemoteFortressReader::Item * NetItem, df::item * DfItem) improvement_type::improvement_type impType = improvement->getType(); + auto netImp = NetItem->add_improvements(); + + netImp->set_type((ImprovementType)impType); + + auto mat = netImp->mutable_material(); + mat->set_mat_type(improvement->mat_type); + mat->set_mat_index(improvement->mat_index); + switch (impType) { case df::enums::improvement_type::ART_IMAGE: break; case df::enums::improvement_type::COVERED: { + VIRTUAL_CAST_VAR(covered, df::itemimprovement_coveredst, improvement); + netImp->set_shape(covered->shape); break; } case df::enums::improvement_type::RINGS_HANGING: break; case df::enums::improvement_type::BANDS: + { + VIRTUAL_CAST_VAR(bands, df::itemimprovement_bandsst, improvement); + netImp->set_shape(bands->shape); break; - case df::enums::improvement_type::SPIKES: - break; + } case df::enums::improvement_type::ITEMSPECIFIC: + { + VIRTUAL_CAST_VAR(specific, df::itemimprovement_itemspecificst, improvement); + netImp->set_specific_type(specific->type); break; + } case df::enums::improvement_type::THREAD: { VIRTUAL_CAST_VAR(improvement_thread, df::itemimprovement_threadst, improvement); diff --git a/plugins/remotefortressreader/item_reader.h b/plugins/remotefortressreader/item_reader.h index 45f8c1a95..2bd8e7c89 100644 --- a/plugins/remotefortressreader/item_reader.h +++ b/plugins/remotefortressreader/item_reader.h @@ -15,7 +15,7 @@ namespace df namespace MapExtras { - struct MapCache; + class MapCache; } DFHack::command_result GetItemList(DFHack::color_ostream &stream, const DFHack::EmptyMessage *in, RemoteFortressReader::MaterialList *out);