From: Mikko Rasa Date: Sat, 4 Apr 2015 16:12:35 +0000 (+0300) Subject: Remember the states of locomotive functions X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=e8b19bb2711913226580b93ba127b0628839c10d;p=r2c2.git Remember the states of locomotive functions --- diff --git a/source/libr2c2/train.cpp b/source/libr2c2/train.cpp index b1fbc6a..4372377 100644 --- a/source/libr2c2/train.cpp +++ b/source/libr2c2/train.cpp @@ -417,6 +417,10 @@ void Train::save(list &st) const st.push_back(ss); } + const VehicleType::FunctionMap &func_map = loco_type.get_functions(); + for(VehicleType::FunctionMap::const_iterator i=func_map.begin(); i!=func_map.end(); ++i) + st.push_back((DataFile::Statement("function"), i->first, static_cast(functions&(1<first)))); + // XXX Need more generic way of saving AI state for(list::const_iterator i=ais.begin(); i!=ais.end(); ++i) { @@ -593,6 +597,7 @@ Train::Loader::Loader(Train &t): blocks_valid(true) { add("blocks", &Loader::blocks); + add("function", &Loader::function); add("name", &Loader::name); add("quantized_speed", &Loader::quantized_speed); add("router", &Loader::router); @@ -615,6 +620,11 @@ void Train::Loader::blocks() load_sub(obj.allocator); } +void Train::Loader::function(unsigned f, bool s) +{ + obj.set_function(f, s); +} + void Train::Loader::name(const string &n) { obj.set_name(n); diff --git a/source/libr2c2/train.h b/source/libr2c2/train.h index dff9aae..9b228c0 100644 --- a/source/libr2c2/train.h +++ b/source/libr2c2/train.h @@ -32,6 +32,7 @@ public: private: virtual void finish(); void blocks(); + void function(unsigned, bool); void name(const std::string &); void quantized_speed(); void router();