From 65e549848df2ffc174074968e9d6113e6cef6cdb Mon Sep 17 00:00:00 2001 From: Japa Date: Tue, 27 Feb 2018 21:01:38 +0530 Subject: [PATCH] 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);