X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrain.cpp;h=889f21e70fa0940a4ddbfb4075660616cc03153a;hb=d0881a98a6240758ac1aeceaa9443d718ab1ad5c;hp=b1fbc6a76ebb1bf4ad02f85d981f465fef1a1759;hpb=ecd7af790bd3ab7c7e768f68968379e1feea56a9;p=r2c2.git diff --git a/source/libr2c2/train.cpp b/source/libr2c2/train.cpp index b1fbc6a..889f21e 100644 --- a/source/libr2c2/train.cpp +++ b/source/libr2c2/train.cpp @@ -327,6 +327,8 @@ void Train::tick(const Time::TimeDelta &dt) Driver &driver = layout.get_driver(); + allocator.tick(); + bool intent_to_move = false; for(list::iterator i=ais.begin(); i!=ais.end(); ++i) { @@ -417,6 +419,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 +599,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 +622,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);