@@ -185,26 +185,26 @@ bool StockpileSettingsSerializer::serialize_to_file(const string& file, uint32_t
185185 return serialize_to_ostream (&output, includedElements);
186186}
187187
188- bool StockpileSettingsSerializer::parse_from_istream (std::istream* input, DeserializeMode mode, const vector<string>& filters) {
188+ bool StockpileSettingsSerializer::parse_from_istream (color_ostream &out, std::istream* input, DeserializeMode mode, const vector<string>& filters) {
189189 if (input->fail ())
190190 return false ;
191191 mBuffer .Clear ();
192192 io::IstreamInputStream zero_copy_input (input);
193193 const bool res = mBuffer .ParseFromZeroCopyStream (&zero_copy_input)
194194 && input->eof ();
195195 if (res)
196- read (mode, filters);
196+ read (out, mode, filters);
197197 return res;
198198}
199199
200- bool StockpileSettingsSerializer::unserialize_from_file (const string& file, DeserializeMode mode, const vector<string>& filters) {
200+ bool StockpileSettingsSerializer::unserialize_from_file (color_ostream &out, const string& file, DeserializeMode mode, const vector<string>& filters) {
201201 std::fstream input (file, std::ios::in | std::ios::binary);
202202 if (input.fail ()) {
203203 WARN (log).print (" failed to open file for reading: '%s'\n " ,
204204 file.c_str ());
205205 return false ;
206206 }
207- return parse_from_istream (&input, mode, filters);
207+ return parse_from_istream (out, &input, mode, filters);
208208}
209209
210210/* *
@@ -768,13 +768,15 @@ void StockpileSettingsSerializer::write(uint32_t includedElements) {
768768}
769769
770770void StockpileSerializer::write (uint32_t includedElements) {
771+ if (includedElements & INCLUDED_ELEMENTS_FEATURES )
772+ write_features ();
771773 if (includedElements & INCLUDED_ELEMENTS_CONTAINERS )
772774 write_containers ();
773775
774776 StockpileSettingsSerializer::write (includedElements);
775777}
776778
777- void StockpileSettingsSerializer::read (DeserializeMode mode, const vector<string>& filters) {
779+ void StockpileSettingsSerializer::read (color_ostream &out, DeserializeMode mode, const vector<string>& filters) {
778780 DEBUG (log).print (" ==READ==\n " );
779781 read_general (mode);
780782 read_ammo (mode, filters);
@@ -803,7 +805,8 @@ void StockpileSettingsSerializer::read(DeserializeMode mode, const vector<string
803805 read_wood (mode, filters);
804806}
805807
806- void StockpileSerializer::read (DeserializeMode mode, const vector<string>& filters) {
808+ void StockpileSerializer::read (color_ostream &out, DeserializeMode mode, const vector<string>& filters) {
809+ read_features (out, mode);
807810 read_containers (mode);
808811 StockpileSettingsSerializer::read (mode, filters);
809812}
@@ -913,19 +916,25 @@ void StockpileSerializer::write_features() {
913916 mBuffer .set_dump (mPile ->settings .allow_organic );
914917}
915918
916- void StockpileSerializer::read_features (DeserializeMode mode) {
917- read_elem<int32_t , bool >(" use_links_only" , mode,
918- std::bind (&StockpileSettings::has_use_links_only, mBuffer ),
919- std::bind (&StockpileSettings::use_links_only, mBuffer ),
920- mPile ->use_links_only );
921- read_elem<bool , bool >(" allow_inorganic" , mode,
922- std::bind (&StockpileSettings::has_allow_inorganic, mBuffer ),
923- std::bind (&StockpileSettings::allow_inorganic, mBuffer ),
924- mPile ->settings .allow_inorganic );
925- read_elem<bool , bool >(" allow_organic" , mode,
926- std::bind (&StockpileSettings::has_allow_organic, mBuffer ),
927- std::bind (&StockpileSettings::allow_organic, mBuffer ),
928- mPile ->settings .allow_organic );
919+ void StockpileSerializer::read_features (color_ostream &out, DeserializeMode mode) {
920+ int32_t melt = -1 , trade = -1 , dump = -1 ;
921+ read_elem<int32_t , bool >(" melt" , mode,
922+ std::bind (&StockpileSettings::has_melt, mBuffer ),
923+ std::bind (&StockpileSettings::melt, mBuffer ),
924+ melt);
925+ read_elem<int32_t , bool >(" trade" , mode,
926+ std::bind (&StockpileSettings::has_trade, mBuffer ),
927+ std::bind (&StockpileSettings::trade, mBuffer ),
928+ trade);
929+ read_elem<int32_t , bool >(" dump" , mode,
930+ std::bind (&StockpileSettings::has_dump, mBuffer ),
931+ std::bind (&StockpileSettings::dump, mBuffer ),
932+ dump);
933+
934+ if (melt != -1 || trade != -1 || dump != -1 ) {
935+ auto &core = Core::getInstance ();
936+ core.runCommand (out, " logistics clear -s " + int_to_string (mPile ->stockpile_number ));
937+ }
929938}
930939
931940static bool ammo_mat_is_allowed (const MaterialInfo& mi) {
0 commit comments