From 265e229d613cc9b81c27d53d12066880a702d89c Mon Sep 17 00:00:00 2001 From: Japa Date: Tue, 27 Feb 2018 19:58:07 +0530 Subject: [PATCH 01/12] Send all relavent generated instruement information over RFR --- library/xml | 2 +- plugins/proto/ItemdefInstrument.proto | 104 +++++++++++++++++++ plugins/proto/RemoteFortressReader.proto | 3 + plugins/remotefortressreader/CMakeLists.txt | 1 + plugins/remotefortressreader/item_reader.cpp | 79 ++++++++++++++ 5 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 plugins/proto/ItemdefInstrument.proto diff --git a/library/xml b/library/xml index 2794f8a6d..5fea1ef62 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 2794f8a6d7405d4858bac486a0bb17b94740c142 +Subproject commit 5fea1ef62a040d24a9efa31a9a6dfd8eb1eea3f6 diff --git a/plugins/proto/ItemdefInstrument.proto b/plugins/proto/ItemdefInstrument.proto new file mode 100644 index 000000000..977e86f90 --- /dev/null +++ b/plugins/proto/ItemdefInstrument.proto @@ -0,0 +1,104 @@ +package ItemdefInstrument; + +//Attempts to provide a complete framework for reading everything from a fortress needed for vizualization +option optimize_for = LITE_RUNTIME; + +message InstrumentFlags + { + optional bool indefinite_pitch = 1; + optional bool placed_as_building = 2; + optional bool metal_mat = 3; + optional bool stone_mat = 4; + optional bool wood_mat = 5; + optional bool glass_mat = 6; + optional bool ceramic_mat = 7; + optional bool shell_mat = 8; + optional bool bone_mat = 9; +} + +enum PitchChoiceType +{ + MEMBRANE_POSITION = 0; + SUBPART_CHOICE = 1; + KEYBOARD = 2; + STOPPING_FRET = 3; + STOPPING_AGAINST_BODY = 4; + STOPPING_HOLE = 5; + STOPPING_HOLE_KEY = 6; + SLIDE = 7; + HARMONIC_SERIES = 8; + VALVE_ROUTES_AIR = 9; + BP_IN_BELL = 10; + FOOT_PEDALS = 11; +} + +enum SoundProductionType +{ + PLUCKED_BY_BP = 0; + PLUCKED = 1; + BOWED = 2; + STRUCK_BY_BP = 3; + STRUCK = 4; + VIBRATE_BP_AGAINST_OPENING = 5; + BLOW_AGAINST_FIPPLE = 6; + BLOW_OVER_OPENING_SIDE = 7; + BLOW_OVER_OPENING_END = 8; + BLOW_OVER_SINGLE_REED = 9; + BLOW_OVER_DOUBLE_REED = 10; + BLOW_OVER_FREE_REED = 11; + STRUCK_TOGETHER = 12; + SHAKEN = 13; + SCRAPED = 14; + FRICTION = 15; + RESONATOR = 16; + BAG_OVER_REED = 17; + AIR_OVER_REED = 18; + AIR_OVER_FREE_REED = 19; + AIR_AGAINST_FIPPLE = 20; +} + +enum TuningType +{ + PEGS = 0; + ADJUSTABLE_BRIDGES = 1; + CROOKS = 2; + TIGHTENING = 4; + LEVERS = 5; +} + +message InstrumentPiece +{ + optional string type = 1; + optional string id = 2; + optional string name = 3; + optional string name_plural = 4; +} + +message InstrumentRegister +{ + optional int32 pitch_range_min = 1; + optional int32 pitch_range_max = 2; +} + +message InstrumentDef +{ + optional InstrumentFlags flags = 1; + optional int32 size = 2; + optional int32 value = 3; + optional int32 material_size = 4; + repeated InstrumentPiece pieces = 5; + optional int32 pitch_range_min = 6; + optional int32 pitch_range_max = 7; + optional int32 volume_mb_min = 8; + optional int32 volume_mb_max = 9; + repeated SoundProductionType sound_production = 10; + repeated string sound_production_parm1 = 11; + repeated string sound_production_parm2 = 12; + repeated PitchChoiceType pitch_choice = 13; + repeated string pitch_choice_parm1 = 14; + repeated string pitch_choice_parm2 = 15; + repeated TuningType tuning = 16; + repeated string tuning_parm = 17; + repeated InstrumentRegister registers = 18; + optional string description = 19; +} \ No newline at end of file diff --git a/plugins/proto/RemoteFortressReader.proto b/plugins/proto/RemoteFortressReader.proto index 35f5b0abe..b2e5eae4d 100644 --- a/plugins/proto/RemoteFortressReader.proto +++ b/plugins/proto/RemoteFortressReader.proto @@ -3,6 +3,8 @@ package RemoteFortressReader; //Attempts to provide a complete framework for reading everything from a fortress needed for vizualization option optimize_for = LITE_RUNTIME; +import "ItemdefInstrument.proto"; + //We use shapes, etc, because the actual tiletypes may differ between DF versions. enum TiletypeShape { @@ -329,6 +331,7 @@ message MaterialDefinition{ optional string id = 2; optional string name = 3; optional ColorDefinition state_color = 4; //Simplifying colors to assume room temperature. + optional ItemdefInstrument.InstrumentDef instrument = 5; } message BuildingType diff --git a/plugins/remotefortressreader/CMakeLists.txt b/plugins/remotefortressreader/CMakeLists.txt index 10cc21047..ad61c94ce 100644 --- a/plugins/remotefortressreader/CMakeLists.txt +++ b/plugins/remotefortressreader/CMakeLists.txt @@ -17,6 +17,7 @@ SET(PROJECT_HDRS SET(PROJECT_PROTO ../../proto/RemoteFortressReader ../../proto/AdventureControl + ../../proto/ItemdefInstrument ) SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE) diff --git a/plugins/remotefortressreader/item_reader.cpp b/plugins/remotefortressreader/item_reader.cpp index 59b1f36e7..2adcce67f 100644 --- a/plugins/remotefortressreader/item_reader.cpp +++ b/plugins/remotefortressreader/item_reader.cpp @@ -1,6 +1,7 @@ #include "item_reader.h" #include "Core.h" #include "VersionInfo.h" +#include "ItemdefInstrument.pb.h" #include "df/art_image.h" #include "df/art_image_chunk.h" @@ -16,6 +17,8 @@ #include "df/art_image_property_transitive_verbst.h" #include "df/art_image_ref.h" #include "df/descriptor_shape.h" +#include "df/instrument_piece.h" +#include "df/instrument_register.h" #include "df/item_type.h" #include "df/item_constructed.h" #include "df/item_gemst.h" @@ -23,6 +26,7 @@ #include "df/item_statuest.h" #include "df/item_threadst.h" #include "df/item_toolst.h" +#include "df/itemdef_instrumentst.h" #include "df/itemimprovement.h" #include "df/itemimprovement_art_imagest.h" #include "df/itemimprovement_bandsst.h" @@ -46,6 +50,7 @@ using namespace DFHack; using namespace df::enums; using namespace RemoteFortressReader; +using namespace ItemdefInstrument; using namespace std; using namespace df::global; @@ -565,6 +570,80 @@ DFHack::command_result GetItemList(DFHack::color_ostream &stream, const DFHack:: mat_def->mutable_mat_pair()->set_mat_index(i); df::itemdef * item = Items::getSubtypeDef(it, i); mat_def->set_id(ENUM_KEY_STR(item_type, it) + "/" + item->id); + switch (it) + { + case df::enums::item_type::INSTRUMENT: + { + VIRTUAL_CAST_VAR(instrument, df::itemdef_instrumentst, item); + mat_def->set_name(instrument->name); + auto send_instrument = mat_def->mutable_instrument(); + auto flags = send_instrument->mutable_flags(); + flags->set_indefinite_pitch(instrument->flags.is_set(instrument_flags::INDEFINITE_PITCH)); + flags->set_placed_as_building(instrument->flags.is_set(instrument_flags::PLACED_AS_BUILDING)); + flags->set_metal_mat(instrument->flags.is_set(instrument_flags::METAL_MAT)); + flags->set_stone_mat(instrument->flags.is_set(instrument_flags::STONE_MAT)); + flags->set_wood_mat(instrument->flags.is_set(instrument_flags::WOOD_MAT)); + flags->set_glass_mat(instrument->flags.is_set(instrument_flags::GLASS_MAT)); + flags->set_ceramic_mat(instrument->flags.is_set(instrument_flags::CERAMIC_MAT)); + flags->set_shell_mat(instrument->flags.is_set(instrument_flags::SHELL_MAT)); + flags->set_bone_mat(instrument->flags.is_set(instrument_flags::BONE_MAT)); + send_instrument->set_size(instrument->size); + send_instrument->set_value(instrument->value); + send_instrument->set_material_size(instrument->material_size); + for (int j = 0; j < instrument->pieces.size(); j++) + { + auto piece = send_instrument->add_pieces(); + piece->set_type(instrument->pieces[i]->type); + piece->set_id(instrument->pieces[i]->id); + piece->set_name(instrument->pieces[i]->name); + piece->set_name_plural(instrument->pieces[i]->name_plural); + } + send_instrument->set_pitch_range_min(instrument->pitch_range_min); + send_instrument->set_pitch_range_max(instrument->pitch_range_max); + for (int j = 0; j < instrument->sound_production.size(); j++) + { + send_instrument->add_sound_production((SoundProductionType)instrument->sound_production[j]); + } + for (int j = 0; j < instrument->sound_production_parm1.size(); j++) + { + send_instrument->add_sound_production_parm1(*(instrument->sound_production_parm1[j])); + } + for (int j = 0; j < instrument->sound_production_parm2.size(); j++) + { + send_instrument->add_sound_production_parm2(*(instrument->sound_production_parm2[j])); + } + for (int j = 0; j < instrument->pitch_choice.size(); j++) + { + send_instrument->add_pitch_choice((PitchChoiceType)instrument->pitch_choice[j]); + } + for (int j = 0; j < instrument->pitch_choice_parm1.size(); j++) + { + send_instrument->add_pitch_choice_parm1(*(instrument->pitch_choice_parm1[j])); + } + for (int j = 0; j < instrument->pitch_choice_parm2.size(); j++) + { + send_instrument->add_pitch_choice_parm2(*(instrument->pitch_choice_parm2[j])); + } + for (int j = 0; j < instrument->tuning.size(); j++) + { + send_instrument->add_tuning((TuningType)instrument->tuning[j]); + } + for (int j = 0; j < instrument->tuning_parm.size(); j++) + { + send_instrument->add_tuning_parm(*(instrument->tuning_parm[j])); + } + for (int j = 0; j < instrument->registers.size(); j++) + { + auto reg = send_instrument->add_registers(); + reg->set_pitch_range_min(instrument->registers[j]->pitch_range_min); + reg->set_pitch_range_max(instrument->registers[j]->pitch_range_max); + } + send_instrument->set_description(instrument->description); + break; + } + default: + break; + } } } } From d758104f5e5280756af82acba96898cc5728129e Mon Sep 17 00:00:00 2001 From: Japa Date: Tue, 27 Feb 2018 20:24:32 +0530 Subject: [PATCH 02/12] update stonesense for RFR protos --- plugins/stonesense | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/stonesense b/plugins/stonesense index 031bf4caa..da3065a35 160000 --- a/plugins/stonesense +++ b/plugins/stonesense @@ -1 +1 @@ -Subproject commit 031bf4caafec321dd315202a83539d052ed49d84 +Subproject commit da3065a35362a8ae3190234792c8cd14fffac9dd From 65e549848df2ffc174074968e9d6113e6cef6cdb Mon Sep 17 00:00:00 2001 From: Japa Date: Tue, 27 Feb 2018 21:01:38 +0530 Subject: [PATCH 03/12] fix some crashes in the new instrument reader code. --- plugins/proto/ItemdefInstrument.proto | 4 ++-- plugins/remotefortressreader/item_reader.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/proto/ItemdefInstrument.proto b/plugins/proto/ItemdefInstrument.proto index 977e86f90..c92491ace 100644 --- a/plugins/proto/ItemdefInstrument.proto +++ b/plugins/proto/ItemdefInstrument.proto @@ -62,8 +62,8 @@ enum TuningType PEGS = 0; ADJUSTABLE_BRIDGES = 1; CROOKS = 2; - TIGHTENING = 4; - LEVERS = 5; + TIGHTENING = 3; + LEVERS = 4; } message InstrumentPiece diff --git a/plugins/remotefortressreader/item_reader.cpp b/plugins/remotefortressreader/item_reader.cpp index 2adcce67f..70f499598 100644 --- a/plugins/remotefortressreader/item_reader.cpp +++ b/plugins/remotefortressreader/item_reader.cpp @@ -575,7 +575,7 @@ DFHack::command_result GetItemList(DFHack::color_ostream &stream, const DFHack:: case df::enums::item_type::INSTRUMENT: { VIRTUAL_CAST_VAR(instrument, df::itemdef_instrumentst, item); - mat_def->set_name(instrument->name); + mat_def->set_name(DF2UTF(instrument->name)); auto send_instrument = mat_def->mutable_instrument(); auto flags = send_instrument->mutable_flags(); flags->set_indefinite_pitch(instrument->flags.is_set(instrument_flags::INDEFINITE_PITCH)); @@ -593,10 +593,10 @@ DFHack::command_result GetItemList(DFHack::color_ostream &stream, const DFHack:: for (int j = 0; j < instrument->pieces.size(); j++) { auto piece = send_instrument->add_pieces(); - piece->set_type(instrument->pieces[i]->type); - piece->set_id(instrument->pieces[i]->id); - piece->set_name(instrument->pieces[i]->name); - piece->set_name_plural(instrument->pieces[i]->name_plural); + piece->set_type(instrument->pieces[j]->type); + piece->set_id(instrument->pieces[j]->id); + piece->set_name(DF2UTF(instrument->pieces[j]->name)); + piece->set_name_plural(DF2UTF(instrument->pieces[j]->name_plural)); } send_instrument->set_pitch_range_min(instrument->pitch_range_min); send_instrument->set_pitch_range_max(instrument->pitch_range_max); From 490fbd8b266bdf8a562f8d98b33b76d44174721f Mon Sep 17 00:00:00 2001 From: Japa Date: Tue, 27 Feb 2018 21:18:15 +0530 Subject: [PATCH 04/12] send instrument description using UTF8 --- plugins/remotefortressreader/item_reader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/remotefortressreader/item_reader.cpp b/plugins/remotefortressreader/item_reader.cpp index 70f499598..9adfbced2 100644 --- a/plugins/remotefortressreader/item_reader.cpp +++ b/plugins/remotefortressreader/item_reader.cpp @@ -638,7 +638,7 @@ DFHack::command_result GetItemList(DFHack::color_ostream &stream, const DFHack:: reg->set_pitch_range_min(instrument->registers[j]->pitch_range_min); reg->set_pitch_range_max(instrument->registers[j]->pitch_range_max); } - send_instrument->set_description(instrument->description); + send_instrument->set_description(DF2UTF(instrument->description)); break; } default: From 3f26d4fe09636fd2c8cc31e13621e59c8fb98831 Mon Sep 17 00:00:00 2001 From: Japa Mala Illo Date: Sat, 3 Mar 2018 11:41:58 +0530 Subject: [PATCH 05/12] Add flows to RFR --- plugins/proto/RemoteFortressReader.proto | 31 +++++++++++++++++++ .../remotefortressreader.cpp | 24 ++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/plugins/proto/RemoteFortressReader.proto b/plugins/proto/RemoteFortressReader.proto index b2e5eae4d..bf82c164c 100644 --- a/plugins/proto/RemoteFortressReader.proto +++ b/plugins/proto/RemoteFortressReader.proto @@ -313,6 +313,7 @@ message MapBlock repeated bool tile_dig_designation_marker = 27; repeated bool tile_dig_designation_auto = 28; repeated int32 grass_percent = 29; + repeated FlowInfo flows = 30; } message MatPair { @@ -1028,3 +1029,33 @@ enum ArtImageVerb VERB_BEINGMUTILATED = 46; VERB_TRIUMPHANTPOSE = 47; } + +enum FlowType +{ + Miasma = 0; + Steam = 1; + Mist = 2; + MaterialDust = 3; + MagmaMist = 4; + Smoke = 5; + Dragonfire = 6; + Fire = 7; + Web = 8; + MaterialGas = 9; + MaterialVapor = 10; + OceanWave = 11; + SeaFoam = 12; + ItemCloud = 13; +} + +message FlowInfo +{ + optional int32 index = 1; + optional FlowType type = 2; + optional int32 density = 3; + optional Coord pos = 4; + optional Coord dest = 5; + optional bool expanding = 6; + optional bool reuse = 7; + optional int32 guide_id = 8; +} diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index e321bf8d5..5b8cf89d5 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -58,6 +58,7 @@ #include "df/dfhack_material_category.h" #include "df/enabler.h" #include "df/engraving.h" +#include "df/flow_info.h" #include "df/graphic.h" #include "df/historical_figure.h" @@ -1395,6 +1396,29 @@ void CopyItems(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBloc } } +void CopyFlow(df::flow_info * localFlow, RemoteFortressReader::FlowInfo * netFlow, int index) +{ + //There's no consistent ID to use, so we just use the pointer. + netFlow->set_index((int)localFlow); + netFlow->set_type((FlowType)localFlow->type); + netFlow->set_density(localFlow->density); + ConvertDFCoord(localFlow->pos, netFlow->mutable_pos()); + ConvertDFCoord(localFlow->dest, netFlow->mutable_dest()); + netFlow->set_expanding(localFlow->expanding); + netFlow->set_reuse(localFlow->reuse); + netFlow->set_guide_id(localFlow->guide_id); +} + +void CopyFlows(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBlock) +{ + NetBlock->set_map_x(DfBlock->map_pos.x); + NetBlock->set_map_y(DfBlock->map_pos.y); + NetBlock->set_map_z(DfBlock->map_pos.z); + for (int i = 0; i < DfBlock->flows.size(); i++) + { + CopyFlow(DfBlock->flows[i], NetBlock->add_flows(), i); + } +} static command_result GetBlockList(color_ostream &stream, const BlockRequest *in, BlockList *out) { From 894f6c232b406048602b4cbd27ab1f5d66c6bb70 Mon Sep 17 00:00:00 2001 From: Japa Mala Illo Date: Sat, 3 Mar 2018 12:48:09 +0530 Subject: [PATCH 06/12] actually copy flows with the block this time. --- .../remotefortressreader.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index 5b8cf89d5..6876866fc 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -1466,7 +1466,7 @@ static command_result GetBlockList(color_ostream &stream, const BlockRequest *in df::map_block * block = DFHack::Maps::getBlock(pos); if (block != NULL) { - int nonAir = 0; + bool nonAir = false; for (int xxx = 0; xxx < 16; xxx++) for (int yyy = 0; yyy < 16; yyy++) { @@ -1474,16 +1474,23 @@ static command_result GetBlockList(color_ostream &stream, const BlockRequest *in DFHack::tileShapeBasic(DFHack::tileShape(block->tiletype[xxx][yyy])) != df::tiletype_shape_basic::Open) || block->designation[xxx][yyy].bits.flow_size > 0 || block->occupancy[xxx][yyy].bits.building > 0) - nonAir++; + { + nonAir = true; + goto ItsAir; + } } - if (nonAir > 0 || firstBlock) + ItsAir: + if (block->flows.size() > 0) + nonAir = true; + if (nonAir || firstBlock) { bool tileChanged = IsTiletypeChanged(pos); bool desChanged = IsDesignationChanged(pos); bool spatterChanged = IsspatterChanged(pos); bool itemsChanged = block->items.size() > 0; + bool flows = block->flows.size() > 0; RemoteFortressReader::MapBlock *net_block; - if (tileChanged || desChanged || spatterChanged || firstBlock || itemsChanged) + if (tileChanged || desChanged || spatterChanged || firstBlock || itemsChanged || flows) net_block = out->add_map_blocks(); if (tileChanged) { @@ -1502,6 +1509,10 @@ static command_result GetBlockList(color_ostream &stream, const BlockRequest *in Copyspatters(block, net_block, &MC, pos); if (itemsChanged) CopyItems(block, net_block, &MC, pos); + if (flows) + { + CopyFlows(block, net_block); + } } } } From ebf96518966496542ba381239610bd879c3a76b4 Mon Sep 17 00:00:00 2001 From: Japa Mala Illo Date: Sun, 4 Mar 2018 02:41:40 +0530 Subject: [PATCH 07/12] Include Materials in flows. --- plugins/proto/RemoteFortressReader.proto | 1 + plugins/remotefortressreader/remotefortressreader.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/proto/RemoteFortressReader.proto b/plugins/proto/RemoteFortressReader.proto index bf82c164c..1bd05bcc3 100644 --- a/plugins/proto/RemoteFortressReader.proto +++ b/plugins/proto/RemoteFortressReader.proto @@ -1058,4 +1058,5 @@ message FlowInfo optional bool expanding = 6; optional bool reuse = 7; optional int32 guide_id = 8; + optional MatPair material = 9; } diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index 6876866fc..0f7b1e55c 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -1398,8 +1398,6 @@ void CopyItems(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBloc void CopyFlow(df::flow_info * localFlow, RemoteFortressReader::FlowInfo * netFlow, int index) { - //There's no consistent ID to use, so we just use the pointer. - netFlow->set_index((int)localFlow); netFlow->set_type((FlowType)localFlow->type); netFlow->set_density(localFlow->density); ConvertDFCoord(localFlow->pos, netFlow->mutable_pos()); @@ -1407,6 +1405,9 @@ void CopyFlow(df::flow_info * localFlow, RemoteFortressReader::FlowInfo * netFlo netFlow->set_expanding(localFlow->expanding); netFlow->set_reuse(localFlow->reuse); netFlow->set_guide_id(localFlow->guide_id); + auto mat = netFlow->mutable_material(); + mat->set_mat_index(localFlow->mat_index); + mat->set_mat_type(localFlow->mat_type); } void CopyFlows(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBlock) From c765e12254352466e9d53ad87a7c24a058047404 Mon Sep 17 00:00:00 2001 From: Japa Date: Mon, 5 Mar 2018 19:00:18 +0530 Subject: [PATCH 08/12] Store tool names in RFR --- plugins/remotefortressreader/item_reader.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/remotefortressreader/item_reader.cpp b/plugins/remotefortressreader/item_reader.cpp index 9adfbced2..762fc9270 100644 --- a/plugins/remotefortressreader/item_reader.cpp +++ b/plugins/remotefortressreader/item_reader.cpp @@ -27,6 +27,7 @@ #include "df/item_threadst.h" #include "df/item_toolst.h" #include "df/itemdef_instrumentst.h" +#include "df/itemdef_toolst.h" #include "df/itemimprovement.h" #include "df/itemimprovement_art_imagest.h" #include "df/itemimprovement_bandsst.h" @@ -641,6 +642,11 @@ DFHack::command_result GetItemList(DFHack::color_ostream &stream, const DFHack:: send_instrument->set_description(DF2UTF(instrument->description)); break; } + case df::enums::item_type::TOOL: + { + VIRTUAL_CAST_VAR(tool, df::itemdef_toolst, item); + mat_def->set_name(DF2UTF(tool->name)); + } default: break; } From c3f931652d05e859f1df9d5280fb9a0d59944415 Mon Sep 17 00:00:00 2001 From: Japa Date: Tue, 6 Mar 2018 09:44:21 +0530 Subject: [PATCH 09/12] Send item cloud info properly. --- plugins/proto/RemoteFortressReader.proto | 1 + .../remotefortressreader.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/plugins/proto/RemoteFortressReader.proto b/plugins/proto/RemoteFortressReader.proto index 1bd05bcc3..694fb4057 100644 --- a/plugins/proto/RemoteFortressReader.proto +++ b/plugins/proto/RemoteFortressReader.proto @@ -1059,4 +1059,5 @@ message FlowInfo optional bool reuse = 7; optional int32 guide_id = 8; optional MatPair material = 9; + optional MatPair item = 10; } diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index 0f7b1e55c..028a39241 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -59,6 +59,8 @@ #include "df/enabler.h" #include "df/engraving.h" #include "df/flow_info.h" +#include "df/flow_guide.h" +#include "df/flow_guide_item_cloudst.h" #include "df/graphic.h" #include "df/historical_figure.h" @@ -1408,6 +1410,22 @@ void CopyFlow(df::flow_info * localFlow, RemoteFortressReader::FlowInfo * netFlo auto mat = netFlow->mutable_material(); mat->set_mat_index(localFlow->mat_index); mat->set_mat_type(localFlow->mat_type); + if (localFlow->guide_id >= 0 && localFlow->type == flow_type::ItemCloud) + { + auto guide = df::flow_guide::find(localFlow->guide_id); + if (guide) + { + VIRTUAL_CAST_VAR(cloud, df::flow_guide_item_cloudst, guide); + if (cloud) + { + mat->set_mat_index(cloud->mattype); + mat->set_mat_type(cloud->mattype); + auto item = netFlow->mutable_item(); + item->set_mat_index(cloud->item_subtype); + item->set_mat_type(cloud->item_type); + } + } + } } void CopyFlows(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBlock) From 3e7da4d5f2132d5dcbaa5cb88f98679cba1e91da Mon Sep 17 00:00:00 2001 From: Japa Date: Tue, 6 Mar 2018 22:37:26 +0530 Subject: [PATCH 10/12] FIx wrong material being sent with item flows. --- plugins/remotefortressreader/remotefortressreader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index 028a39241..eea2902f0 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -1418,7 +1418,7 @@ void CopyFlow(df::flow_info * localFlow, RemoteFortressReader::FlowInfo * netFlo VIRTUAL_CAST_VAR(cloud, df::flow_guide_item_cloudst, guide); if (cloud) { - mat->set_mat_index(cloud->mattype); + mat->set_mat_index(cloud->matindex); mat->set_mat_type(cloud->mattype); auto item = netFlow->mutable_item(); item->set_mat_index(cloud->item_subtype); From a810960bde87f04a14675a6f61a67b03f5ebebfb Mon Sep 17 00:00:00 2001 From: Japa Date: Sat, 10 Mar 2018 21:02:28 +0530 Subject: [PATCH 11/12] Support spiderwebs and add a fake flow type for campfires. --- plugins/proto/RemoteFortressReader.proto | 1 + plugins/remotefortressreader/item_reader.cpp | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/plugins/proto/RemoteFortressReader.proto b/plugins/proto/RemoteFortressReader.proto index 694fb4057..0b4ce1ac7 100644 --- a/plugins/proto/RemoteFortressReader.proto +++ b/plugins/proto/RemoteFortressReader.proto @@ -1046,6 +1046,7 @@ enum FlowType OceanWave = 11; SeaFoam = 12; ItemCloud = 13; + CampFire = -1; } message FlowInfo diff --git a/plugins/remotefortressreader/item_reader.cpp b/plugins/remotefortressreader/item_reader.cpp index 762fc9270..eb4fb549c 100644 --- a/plugins/remotefortressreader/item_reader.cpp +++ b/plugins/remotefortressreader/item_reader.cpp @@ -332,6 +332,10 @@ void CopyItem(RemoteFortressReader::Item * NetItem, df::item * DfItem) if (info.decode(thread->dye_mat_type, thread->dye_mat_index)) ConvertDFColorDescriptor(info.material->powder_dye, NetItem->mutable_dye()); } + if (DfItem->flags.bits.spider_web) + type->set_mat_index(1); + else + type->set_mat_index(0); break; } case df::enums::item_type::CLOTH: @@ -553,13 +557,24 @@ DFHack::command_result GetItemList(DFHack::color_ostream &stream, const DFHack:: mat_def = out->add_material_list(); mat_def->mutable_mat_pair()->set_mat_type((int)it); mat_def->mutable_mat_pair()->set_mat_index(0); - mat_def->set_id("BOX_CHEST"); + mat_def->set_id("BOX/CHEST"); mat_def = out->add_material_list(); mat_def->mutable_mat_pair()->set_mat_type((int)it); mat_def->mutable_mat_pair()->set_mat_index(1); - mat_def->set_id("BOX_BAG"); + mat_def->set_id("BOX/BAG"); break; } + case df::enums::item_type::THREAD: + { + mat_def = out->add_material_list(); + mat_def->mutable_mat_pair()->set_mat_type((int)it); + mat_def->mutable_mat_pair()->set_mat_index(0); + mat_def->set_id("THREAD/NORMAL"); + mat_def = out->add_material_list(); + mat_def->mutable_mat_pair()->set_mat_type((int)it); + mat_def->mutable_mat_pair()->set_mat_index(1); + mat_def->set_id("THREAD/WEB"); + } } int subtypes = Items::getSubtypeCount(it); if (subtypes >= 0) From 09bc1c3169336f85155aca12454a65edc0d5b52b Mon Sep 17 00:00:00 2001 From: Japa Date: Wed, 14 Mar 2018 16:08:37 +0530 Subject: [PATCH 12/12] add ocean waves to RFR --- plugins/proto/RemoteFortressReader.proto | 7 +++++++ .../remotefortressreader.cpp | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/plugins/proto/RemoteFortressReader.proto b/plugins/proto/RemoteFortressReader.proto index 0b4ce1ac7..3298d42fb 100644 --- a/plugins/proto/RemoteFortressReader.proto +++ b/plugins/proto/RemoteFortressReader.proto @@ -439,6 +439,7 @@ message BlockList optional int32 map_x = 2; optional int32 map_y = 3; repeated Engraving engravings = 4; + repeated Wave ocean_waves = 5; } message PlantDef @@ -1062,3 +1063,9 @@ message FlowInfo optional MatPair material = 9; optional MatPair item = 10; } + +message Wave +{ + optional Coord dest = 1; + optional Coord pos = 2; +} \ No newline at end of file diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index eea2902f0..d30b0a67e 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -72,6 +72,7 @@ #include "df/material_vec_ref.h" #include "df/matter_state.h" #include "df/mental_attribute_type.h" +#include "df/ocean_wave.h" #include "df/physical_attribute_type.h" #include "df/plant.h" #include "df/plant_raw_flags.h" @@ -400,6 +401,14 @@ void ConvertDFCoord(DFCoord in, RemoteFortressReader::Coord * out) out->set_z(in.z); } +void ConvertDFCoord(int x, int y, int z, RemoteFortressReader::Coord * out) +{ + out->set_x(x); + out->set_y(y); + out->set_z(z); +} + + RemoteFortressReader::TiletypeMaterial TranslateMaterial(df::tiletype_material material) { switch (material) @@ -1607,6 +1616,13 @@ static command_result GetBlockList(color_ostream &stream, const BlockRequest *in netEngraving->set_southwest(engraving->flags.bits.southwest); netEngraving->set_southeast(engraving->flags.bits.southeast); } + for (int i = 0; i < world->ocean_waves.size(); i++) + { + auto wave = world->ocean_waves[i]; + auto netWave = out->add_ocean_waves(); + ConvertDFCoord(wave->x1, wave->y1, wave->z, netWave->mutable_dest()); + ConvertDFCoord(wave->x2, wave->y2, wave->z, netWave->mutable_pos()); + } MC.trash(); return CR_OK; }