|
|
|
|
@ -389,6 +389,7 @@ int Locomotives::Reset(string name) {
|
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
|
|
|
|
|
if (name.compare(locomotives[i].name) == 0) {
|
|
|
|
|
debug (0, "Locomotives::Reset (Name:%s)", name.c_str());
|
|
|
|
|
locomotives[i].flags &= ~(LOCO_F_AUTO | LOCO_F_AUTOSTOP | LOCO_F_RANDOM);
|
|
|
|
|
locomotives[i].blockassign[0] = 0;
|
|
|
|
|
locomotives[i].blockdest[0] = 0;
|
|
|
|
|
locomotives[i].blockprev[0] = 0;
|
|
|
|
|
@ -398,21 +399,25 @@ int Locomotives::Reset(string name) {
|
|
|
|
|
locomotives[i].auto_onroute = 0;
|
|
|
|
|
locomotives[i].auto_data = 0;
|
|
|
|
|
locomotives[i].auto_timenext = { 0 };
|
|
|
|
|
locomotives[i].sched_step = 0;
|
|
|
|
|
locomotives[i].sched_step = -1;
|
|
|
|
|
|
|
|
|
|
jp.Clear();
|
|
|
|
|
jp.AddObject("locomotive",_GetJSON(i));
|
|
|
|
|
if(network) network->ChangeListPushToAll(jp.ToString());
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
server->railways.ClearLockedby(name);
|
|
|
|
|
server->blocks.ClearLockedby(name);
|
|
|
|
|
jp.AddObject("locomotive",_GetJSON(i));
|
|
|
|
|
if(network) network->ChangeListPushToAll(jp.ToString());
|
|
|
|
|
|
|
|
|
|
UnLock();
|
|
|
|
|
return 1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int Locomotives::SetMan(string name) {
|
|
|
|
|
int Locomotives::SetModeMan(string name) {
|
|
|
|
|
int i;
|
|
|
|
|
JSONParse jp;
|
|
|
|
|
|
|
|
|
|
Lock();
|
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
|
|
|
|
|
@ -422,7 +427,12 @@ int Locomotives::SetMan(string name) {
|
|
|
|
|
locomotives[i].auto_onroute = 0;
|
|
|
|
|
locomotives[i].auto_way[0] = 0;
|
|
|
|
|
locomotives[i].auto_wayold[0] = 0;
|
|
|
|
|
locomotives[i].sched_step = 0;
|
|
|
|
|
locomotives[i].sched_step = -1;
|
|
|
|
|
|
|
|
|
|
jp.Clear();
|
|
|
|
|
jp.AddObject("locomotive",_GetJSON(i));
|
|
|
|
|
if(network) network->ChangeListPushToAll(jp.ToString());
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
UnLock();
|
|
|
|
|
@ -431,8 +441,9 @@ int Locomotives::SetMan(string name) {
|
|
|
|
|
return 1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int Locomotives::SetAutoMan(string name) {
|
|
|
|
|
int Locomotives::SetModeAutoMan(string name) {
|
|
|
|
|
int i;
|
|
|
|
|
JSONParse jp;
|
|
|
|
|
|
|
|
|
|
Lock();
|
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
|
|
|
|
|
@ -440,6 +451,11 @@ int Locomotives::SetAutoMan(string name) {
|
|
|
|
|
debug (0, "Locomotives::SetAutoMan (Name:%s)\n", name.c_str());
|
|
|
|
|
locomotives[i].flags |= LOCO_F_AUTOSTOP;
|
|
|
|
|
locomotives[i].flags &= ~LOCO_F_RANDOM;
|
|
|
|
|
|
|
|
|
|
jp.Clear();
|
|
|
|
|
jp.AddObject("locomotive",_GetJSON(i));
|
|
|
|
|
if(network) network->ChangeListPushToAll(jp.ToString());
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
UnLock();
|
|
|
|
|
@ -447,8 +463,9 @@ int Locomotives::SetAutoMan(string name) {
|
|
|
|
|
return 1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int Locomotives::SetAuto(string name) {
|
|
|
|
|
int Locomotives::SetModeAuto(string name) {
|
|
|
|
|
int i;
|
|
|
|
|
JSONParse jp;
|
|
|
|
|
|
|
|
|
|
Lock();
|
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
|
|
|
|
|
@ -456,6 +473,11 @@ int Locomotives::SetAuto(string name) {
|
|
|
|
|
debug (0, "Locomotives::SetAuto (Name:%s)\n", name.c_str());
|
|
|
|
|
locomotives[i].flags |= LOCO_F_AUTO;
|
|
|
|
|
locomotives[i].flags &= ~LOCO_F_RANDOM;
|
|
|
|
|
|
|
|
|
|
jp.Clear();
|
|
|
|
|
jp.AddObject("locomotive",_GetJSON(i));
|
|
|
|
|
if(network) network->ChangeListPushToAll(jp.ToString());
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
UnLock();
|
|
|
|
|
@ -463,8 +485,9 @@ int Locomotives::SetAuto(string name) {
|
|
|
|
|
return 1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int Locomotives::SetAutoRand(string name) {
|
|
|
|
|
int Locomotives::SetModeAutoRand(string name) {
|
|
|
|
|
int i;
|
|
|
|
|
JSONParse jp;
|
|
|
|
|
|
|
|
|
|
Lock();
|
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
|
|
|
|
|
@ -472,6 +495,11 @@ int Locomotives::SetAutoRand(string name) {
|
|
|
|
|
debug (0, "Locomotives::SetRandom (Name:%s)\n", name.c_str());
|
|
|
|
|
locomotives[i].flags |= LOCO_F_RANDOM;
|
|
|
|
|
locomotives[i].flags &= ~LOCO_F_AUTOSTOP;
|
|
|
|
|
|
|
|
|
|
jp.Clear();
|
|
|
|
|
jp.AddObject("locomotive",_GetJSON(i));
|
|
|
|
|
if(network) network->ChangeListPushToAll(jp.ToString());
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
UnLock();
|
|
|
|
|
@ -699,7 +727,6 @@ void::Locomotives::SendUpdate (Locomotive *loc) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -722,25 +749,26 @@ int Locomotives::Loop() {
|
|
|
|
|
//
|
|
|
|
|
// only in automate do anything alone
|
|
|
|
|
//
|
|
|
|
|
if (loco->blockassign[0] == 0) continue;
|
|
|
|
|
if (loco->blockassign[0] == 0) {
|
|
|
|
|
debug (0, "%s:%d Locomotive not assigned to any block. Set Mode to Man", __FILE__, __LINE__);
|
|
|
|
|
SetModeMan(loco->name);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (loco->auto_onroute == LOCO_OR_NOTHING) {
|
|
|
|
|
timer_start(&loco->auto_timenext);
|
|
|
|
|
loco->auto_onroute = LOCO_OR_SEARCH;
|
|
|
|
|
//
|
|
|
|
|
// check if the loco mode is set to autostop
|
|
|
|
|
if (loco->flags & LOCO_F_AUTOSTOP) {
|
|
|
|
|
SetMan(loco->name);
|
|
|
|
|
SetModeMan(loco->name);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
timer_start(&loco->auto_timenext);
|
|
|
|
|
loco->auto_onroute = LOCO_OR_SEARCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (loco->auto_onroute == LOCO_OR_SEARCH) {
|
|
|
|
|
//
|
|
|
|
|
// check if the loco mode is set to autostop
|
|
|
|
|
if (loco->flags & LOCO_F_AUTOSTOP) {
|
|
|
|
|
SetMan(loco->name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (loco->auto_onroute == LOCO_OR_SEARCH) {
|
|
|
|
|
//
|
|
|
|
|
// try to find and prepare(lock) a new way.
|
|
|
|
|
// nothing found check if we can reverse direction, this will be done only
|
|
|
|
|
|