#include <algorithm>
#include <cmath>
#include <msp/core/maputils.h>
+#include <msp/core/raii.h>
#include <msp/strings/format.h>
#include <msp/time/units.h>
#include <msp/time/utils.h>
using namespace std;
using namespace Msp;
-namespace {
-
-struct SetFlag
-{
- bool &flag;
-
- SetFlag(bool &f): flag(f) { flag = true; }
- ~SetFlag() { flag = false; }
-};
-
-}
-
-
namespace R2C2 {
Train::Train(Layout &l, const VehicleType &t, unsigned a, const string &p):
ais.erase(i);
}
-TrainAI *Train::get_tagged_ai(const string &tag) const
-{
- for(list<TrainAI *>::const_iterator i=ais.begin(); i!=ais.end(); ++i)
- if((*i)->get_tag()==tag)
- return *i;
-
- return 0;
-}
-
void Train::ai_message(const TrainAI::Message &msg)
{
for(list<TrainAI *>::iterator i=ais.begin(); i!=ais.end(); ++i)
void Train::stop_at(Block *block)
{
stop_at_block = block;
+ if(active && !stop_at_block)
+ reserve_more();
}
bool Train::free_block(Block &block)