|
|
|
@ -503,10 +503,8 @@ string Railways::GetDestBlock(int locoflags, string blockend) {
|
|
|
|
|
blockp = server->blocks.GetSecondBlock(blockn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (blockend[0] == '+') blockend = "+:" + blockn;
|
|
|
|
|
else blockend = "-:" + blockp;
|
|
|
|
|
|
|
|
|
|
block = blockend;
|
|
|
|
|
if (blockend[0] == '+') block = "+:" + blockn;
|
|
|
|
|
else block = "-:" + blockp;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
block = blockend;
|
|
|
|
@ -642,13 +640,13 @@ int Railways::FindWay(string org_blockstart, string org_blockend, string lockedf
|
|
|
|
|
}
|
|
|
|
|
else if (fd_pos.enterfrom >= 0 && fd_end.x == fd_pos.x && fd_pos.y == fd_end.y && fd_pos.enterfrom == fd_end.enterfrom) {
|
|
|
|
|
// destination found
|
|
|
|
|
debug (0, "Railway::FindWay %s:%d found way.", __FILE__, __LINE__);
|
|
|
|
|
found = 1;
|
|
|
|
|
*next = fd_pos.way + ",b:" + blockend;
|
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
|
|
fd_pos.x = -1;
|
|
|
|
|
fd_pos.y = -1;
|
|
|
|
|
fd_pos.way = "";
|
|
|
|
|
debug (0, "Railway::FindWay %s:%d found way. [%s]", __FILE__, __LINE__, next->c_str());
|
|
|
|
|
}
|
|
|
|
|
else if (fd_pos.enterfrom >= 0 && fd_start.x == fd_pos.x && fd_start.y == fd_pos.y && fd_start.enterfrom == fd_pos.enterfrom) {
|
|
|
|
|
// start found
|
|
|
|
@ -890,215 +888,6 @@ int Railways::FindRandomWay(string blockstart, string lockedfor, string *next) {
|
|
|
|
|
|
|
|
|
|
debug (0, "Railway::FindRandomWay - disabled for now - needs to be rewritten");
|
|
|
|
|
return 0;
|
|
|
|
|
/*
|
|
|
|
|
// check blocklen
|
|
|
|
|
if (blockstart.length() <= 3) return 0;
|
|
|
|
|
|
|
|
|
|
// allocate and clear memory for checked data
|
|
|
|
|
fd_data = (struct s_findway_map *) malloc (sizeof(struct s_findway_map) * width * height);
|
|
|
|
|
if (fd_data == NULL) {
|
|
|
|
|
printf ("%s:%d (%s) FATAL ERROR: could not allocate enough memory\n", __FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
memset (fd_data, 0x0, sizeof(struct s_findway_map) * width*height);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// find start and endpoint mark on fd_data, also startpoint to fd_list
|
|
|
|
|
fd_end.x = fd_start.x = -1;
|
|
|
|
|
fd_end.y = fd_start.y = -1;
|
|
|
|
|
fd_end.enterfrom = fd_start.enterfrom = -1;
|
|
|
|
|
|
|
|
|
|
if (FindReference(&fd_start.x, &fd_start.y, blockstart.substr(2, string::npos))) {
|
|
|
|
|
if (Get(fd_start.x, fd_start.y).dir == 1) {
|
|
|
|
|
if (blockstart[0] == '+') fd_start.enterfrom = 0;
|
|
|
|
|
else fd_start.enterfrom = 2;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (blockstart[0] == '+') fd_start.enterfrom = 3;
|
|
|
|
|
else fd_start.enterfrom = 1;
|
|
|
|
|
}
|
|
|
|
|
fd_start.way = "b:" + blockstart;
|
|
|
|
|
fd_data[GetRIdx(fd_start.x, fd_start.y)].e = (1 << fd_start.enterfrom);
|
|
|
|
|
fd_data[GetRIdx(fd_start.x, fd_start.y)].score = 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
debug (0, "Railway::FindRandomWay could not find startblock (%s).", blockstart.c_str());
|
|
|
|
|
free (fd_data);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fd_pos = NextPos(fd_start, Get(fd_start.x, fd_start.y).dir);
|
|
|
|
|
Lock();
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// loop through the map to find all possible ways to the destination
|
|
|
|
|
// this will be done in respect of lockedby blocks and ways.
|
|
|
|
|
//
|
|
|
|
|
while ((fd_list.size() > 0 || fd_pos.enterfrom >= 0) && found == 0) {
|
|
|
|
|
// DebugPrintFindWay(fd_data);
|
|
|
|
|
if (fd_pos.enterfrom < 0) {
|
|
|
|
|
std::list<struct s_findway_data>::iterator iter;
|
|
|
|
|
|
|
|
|
|
iter = fd_list.begin();
|
|
|
|
|
if (iter != fd_list.end()) {
|
|
|
|
|
fd_pos = *iter;
|
|
|
|
|
fd_list.pop_front();
|
|
|
|
|
// printf ("get from stack (%d,%d)\n", fd_pos.x, fd_pos.y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// printf ("%s:%d fd_start (%d,%d) enterfrom:%d\n", __FILE__, __LINE__, fd_start.x, fd_start.y, fd_start.enterfrom);
|
|
|
|
|
// printf ("%s:%d fd_end (%d,%d) enterfrom:%d\n", __FILE__, __LINE__, fd_end.x, fd_end.y, fd_end.enterfrom);
|
|
|
|
|
// printf ("%s:%d fd_pos (%d,%d) enterfrom:%d\n", __FILE__, __LINE__, fd_pos.x, fd_pos.y, fd_pos.enterfrom);
|
|
|
|
|
if (fd_pos.enterfrom < 0 && fd_pos.enterfrom > 3) {
|
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
|
|
fd_pos.x = -1;
|
|
|
|
|
fd_pos.y = -1;
|
|
|
|
|
fd_pos.way = "";
|
|
|
|
|
}
|
|
|
|
|
else if (fd_pos.enterfrom >= 0 && fd_start.x == fd_pos.x && fd_start.y == fd_pos.y && fd_start.enterfrom == fd_pos.enterfrom) {
|
|
|
|
|
// start found
|
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
|
|
fd_pos.x = -1;
|
|
|
|
|
fd_pos.y = -1;
|
|
|
|
|
fd_pos.way = "";
|
|
|
|
|
}
|
|
|
|
|
else if (fd_data[GetRIdx(fd_pos.x, fd_pos.y)].e & (1 << fd_pos.enterfrom)) {
|
|
|
|
|
// old entry found
|
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
|
|
fd_pos.x = -1;
|
|
|
|
|
fd_pos.y = -1;
|
|
|
|
|
fd_pos.way = "";
|
|
|
|
|
}
|
|
|
|
|
else if (fd_pos.enterfrom >= 0) {
|
|
|
|
|
rpos = &railways[GetRIdx(fd_pos.x, fd_pos.y)];
|
|
|
|
|
fd_data[GetRIdx(fd_pos.x, fd_pos.y)].e |= (1 << fd_pos.enterfrom);
|
|
|
|
|
|
|
|
|
|
if (rpos->type == RAILWAY_NORMAL || rpos->type == RAILWAY_SENSOR) {
|
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->dir);
|
|
|
|
|
rnext = &railways[GetRIdx(fd_pos.x, fd_pos.y)];
|
|
|
|
|
if (rnext->lockedby[0] != 0) {
|
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
|
|
fd_pos.x = -1;
|
|
|
|
|
fd_pos.y = -1;
|
|
|
|
|
fd_pos.way = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (rpos->type == RAILWAY_TURNOUT) {
|
|
|
|
|
// random turn or no turn
|
|
|
|
|
if ((rand() & 1) == 1) {
|
|
|
|
|
fd_tmp = NextPos(fd_pos, rpos->altdir);
|
|
|
|
|
fd_tmp.way += (string)",t:" + (string)rpos->name + (string)":1";
|
|
|
|
|
fd_list.push_back(fd_tmp);
|
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->dir);
|
|
|
|
|
fd_pos.way += (string)",t:" + (string)rpos->name + (string)":0";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
fd_tmp = NextPos(fd_pos, rpos->dir);
|
|
|
|
|
fd_tmp.way += (string)",t:" + (string)rpos->name + (string)":0";
|
|
|
|
|
fd_list.push_back(fd_tmp);
|
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->altdir);
|
|
|
|
|
fd_pos.way += (string)",t:" + (string)rpos->name + (string)":1";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (rpos->type == RAILWAY_CONNECTOR) {
|
|
|
|
|
int found = 0;
|
|
|
|
|
|
|
|
|
|
x = -1;
|
|
|
|
|
y = -1;
|
|
|
|
|
while (found == 0 && _FindReference(&x, &y, rpos->name) == 1) {
|
|
|
|
|
if (fd_pos.x != x || fd_pos.y != y) {
|
|
|
|
|
fd_pos.oldx = fd_pos.x;
|
|
|
|
|
fd_pos.oldy = fd_pos.y;
|
|
|
|
|
fd_pos.oldenterfrom = fd_pos.enterfrom;
|
|
|
|
|
fd_pos.x = x;
|
|
|
|
|
fd_pos.y = y;
|
|
|
|
|
rpos = &railways[GetRIdx(fd_pos.x, fd_pos.y)];
|
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->dir);
|
|
|
|
|
found = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (found == 0) {
|
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
|
|
fd_pos.x = -1;
|
|
|
|
|
fd_pos.y = -1;
|
|
|
|
|
fd_pos.way = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
// if block is off ignore it completly
|
|
|
|
|
else if (rpos->type == RAILWAY_BLOCK) {
|
|
|
|
|
int blflags = server->blocks.GetFlags(rpos->name);
|
|
|
|
|
|
|
|
|
|
if ((server->blocks.IsOff(rpos->name) ||
|
|
|
|
|
((blflags & BLOCK_F_ENDSTATION) && !(locoflags & LOCO_F_CANREVERSE)) ||
|
|
|
|
|
((blflags & BLOCK_F_SHORT) && !(locoflags & LOCO_F_SHORTTRAIN)) ||
|
|
|
|
|
((blflags & BLOCK_F_ONLYCARGO) && !(locoflags & LOCO_F_CARGO)) ||
|
|
|
|
|
((blflags & BLOCK_F_ONLYPASSENGER) && (locoflags & LOCO_F_CARGO)))) {
|
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
|
|
fd_pos.x = -1;
|
|
|
|
|
fd_pos.y = -1;
|
|
|
|
|
fd_pos.way = "";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// lockedby = server->blocks.GetLockedby(rpos->name);
|
|
|
|
|
lockedby = server->blocks.GetLockedby(rpos->name);
|
|
|
|
|
if (lockedby.length() == 0 || lockedby.compare(lockedfor) == 0) {
|
|
|
|
|
if (fd_pos.enterfrom == 0 || fd_pos.enterfrom == 3)
|
|
|
|
|
fd_pos.way += (string)",b:+:" + (string)rpos->name;
|
|
|
|
|
else fd_pos.way += (string)",b:-:" + (string)rpos->name;
|
|
|
|
|
|
|
|
|
|
*next = fd_pos.way + ",b:" + (string)rpos->name;
|
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
|
|
fd_pos.x = -1;
|
|
|
|
|
fd_pos.y = -1;
|
|
|
|
|
fd_pos.way = "";
|
|
|
|
|
found = 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
|
|
fd_pos.x = -1;
|
|
|
|
|
fd_pos.y = -1;
|
|
|
|
|
fd_pos.way = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else { // finished nothing more to check
|
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
|
|
fd_pos.x = -1;
|
|
|
|
|
fd_pos.y = -1;
|
|
|
|
|
fd_pos.way = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (found == 0) *next = "";
|
|
|
|
|
else {
|
|
|
|
|
//
|
|
|
|
|
// next = "b:+blockname,t:name:0,t:name:1,b:-blockname"
|
|
|
|
|
debug (0, "* Random Temp Next: %s", next->c_str());
|
|
|
|
|
size_t npos;
|
|
|
|
|
if ((npos = next->find(",b:")) != string::npos) {
|
|
|
|
|
*next = next->substr(0, next->find(",", npos+1));
|
|
|
|
|
debug (0, "* Random next: '%s' found", next->c_str());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// nothing found?
|
|
|
|
|
debug (0, "* Random Nothing Found next: '%s' but no next block?", next->c_str());
|
|
|
|
|
*next = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
UnLock();
|
|
|
|
|
|
|
|
|
|
free (fd_data);
|
|
|
|
|
|
|
|
|
|
return found;
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1114,11 +903,11 @@ int Railways::LockWay (string way, string lockedby, int lockonoff) {
|
|
|
|
|
struct s_findway_data start;
|
|
|
|
|
struct s_findway_data end;
|
|
|
|
|
struct s_findway_data pos;
|
|
|
|
|
string startblock, startblock2, endblock, endblock2;
|
|
|
|
|
string startblock, startblock2, startblockfinal, endblock, endblock2,endblockfinal;
|
|
|
|
|
Railway *r;
|
|
|
|
|
int finished = 0;
|
|
|
|
|
JSONParse jp;
|
|
|
|
|
int locoflags = 0;
|
|
|
|
|
int locoflags = server->locomotives.GetFlags(lockedby);
|
|
|
|
|
int blockendflags = 0;
|
|
|
|
|
int blockstartflags = 0;
|
|
|
|
|
|
|
|
|
@ -1139,7 +928,6 @@ int Railways::LockWay (string way, string lockedby, int lockonoff) {
|
|
|
|
|
//
|
|
|
|
|
// take care of split blocks and long trains.
|
|
|
|
|
// if the second block is not needed endblock2 will remain empty
|
|
|
|
|
locoflags = server->locomotives.GetFlags(lockedby);
|
|
|
|
|
blockendflags = server->blocks.GetFlags(endblock.substr(2, string::npos));
|
|
|
|
|
if (!(locoflags & LOCO_F_SHORTTRAIN) && (blockendflags & BLOCK_F_SPLIT))
|
|
|
|
|
endblock2 = server->blocks.GetSecondBlock(endblock.substr(2, string::npos));
|
|
|
|
@ -1154,7 +942,23 @@ int Railways::LockWay (string way, string lockedby, int lockonoff) {
|
|
|
|
|
//
|
|
|
|
|
// find start position
|
|
|
|
|
//
|
|
|
|
|
if (FindReference(&start.x, &start.y, startblock.substr(2,string::npos))) {
|
|
|
|
|
if (startblock2.length() > 0) {
|
|
|
|
|
if ((startblock[0] == '+' && !(blockstartflags & BLOCK_F_SPLITPOS)) ||
|
|
|
|
|
(startblock[0] == '-' && (blockstartflags & BLOCK_F_SPLITPOS)) ) {
|
|
|
|
|
startblockfinal = startblock2;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
startblockfinal = startblock.substr(2, string::npos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
startblockfinal = startblock.substr(2, string::npos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// retrieve final start position, in case of split blocks
|
|
|
|
|
if (FindReference(&start.x, &start.y, startblockfinal)) {
|
|
|
|
|
if (Get(start.x, start.y).dir == 1) {
|
|
|
|
|
if (startblock[0] == '+') start.enterfrom = 0;
|
|
|
|
|
else start.enterfrom = 2;
|
|
|
|
@ -1170,10 +974,42 @@ int Railways::LockWay (string way, string lockedby, int lockonoff) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// find end position. Long trains and Split blocks is being taken care of in
|
|
|
|
|
// the Findwaypart.
|
|
|
|
|
// when unlocking we are not unlocking the way between these blocks.
|
|
|
|
|
if (FindReference(&end.x, &end.y, endblock.substr(2,string::npos))) {
|
|
|
|
|
// find end position
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// retrieve final end position, in case of split blocks
|
|
|
|
|
if (endblock2.length() > 0) {
|
|
|
|
|
if (lockonoff) {
|
|
|
|
|
if ((endblock[0] == '+' && (blockendflags & BLOCK_F_SPLITPOS)) ||
|
|
|
|
|
(endblock[0] == '-' && !(blockendflags & BLOCK_F_SPLITPOS)) ) {
|
|
|
|
|
endblockfinal = endblock2;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
endblockfinal = endblock.substr(2, string::npos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if ((endblock[0] == '-' && (blockendflags & BLOCK_F_SPLITPOS)) ||
|
|
|
|
|
(endblock[0] == '+' && !(blockendflags & BLOCK_F_SPLITPOS)) ) {
|
|
|
|
|
endblockfinal = endblock2;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
endblockfinal = endblock.substr(2, string::npos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
endblockfinal = endblock.substr(2, string::npos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// get the final end position
|
|
|
|
|
if (!FindReference(&end.x, &end.y, endblockfinal)) {
|
|
|
|
|
debug (0, "Railway::FindWay could not find endblock (%s).", endblockfinal.c_str());
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Get(end.x, end.y).dir == 1) {
|
|
|
|
|
if (endblock[0] == '+') end.enterfrom = 0;
|
|
|
|
|
else end.enterfrom = 2;
|
|
|
|
@ -1182,11 +1018,6 @@ int Railways::LockWay (string way, string lockedby, int lockonoff) {
|
|
|
|
|
if (endblock[0] == '+') end.enterfrom = 3;
|
|
|
|
|
else end.enterfrom = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
debug (0, "Railway::FindWay could not find end (%s).", endblock.c_str());
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf ("%s:%d LockWay Way:'%s' start [%d,%d -> %d] to [%d,%d -> %d] LockOnOff:%d\n", __FILE__, __LINE__, way.c_str(),
|
|
|
|
|
start.x, start.y, start.enterfrom, end.x, end.y, end.enterfrom, lockonoff);
|
|
|
|
@ -1215,24 +1046,27 @@ int Railways::LockWay (string way, string lockedby, int lockonoff) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// lock start and endpoint... unlock only start
|
|
|
|
|
if ((pos.x == end.x && pos.y == end.y) || (r->type == RAILWAY_BLOCK &&
|
|
|
|
|
((endblock.compare(r->name) == 0) ||
|
|
|
|
|
(endblock2.length() > 0 && endblock2.compare(r->name) == 0)))) {
|
|
|
|
|
if (lockonoff == 1) {
|
|
|
|
|
if (r->type == RAILWAY_BLOCK) {
|
|
|
|
|
if ((strcmp(endblock.c_str()+2,r->name) == 0) || (endblock2.length() > 0 && (endblock2.compare(r->name) == 0))) {
|
|
|
|
|
UnLock();
|
|
|
|
|
server->blocks.SetLockedby(r->name, lockedby, 1);
|
|
|
|
|
if (lockonoff) {
|
|
|
|
|
strncpy (r->lockedby, lockedby.c_str(), REFERENCENAME_LEN);
|
|
|
|
|
Lock();
|
|
|
|
|
jp.Clear();
|
|
|
|
|
jp.AddObject("railway",_GetJSONRailway(pos.x, pos.y));
|
|
|
|
|
if(network) network->ChangeListPushToAll(jp.ToString());
|
|
|
|
|
server->blocks.SetLockedby(r->name, lockedby, lockonoff);
|
|
|
|
|
}
|
|
|
|
|
Lock();
|
|
|
|
|
}
|
|
|
|
|
else if (pos.x == start.x && pos.y == start.y && r->type == RAILWAY_BLOCK) {
|
|
|
|
|
else if ((strcmp(startblock.c_str()+2, r->name) == 0) || (startblock2.length() > 0 && (startblock2.compare(r->name) == 0))) {
|
|
|
|
|
UnLock();
|
|
|
|
|
if (lockonoff) server->blocks.SetLockedby(r->name, lockedby, lockonoff);
|
|
|
|
|
server->blocks.SetLockedby(r->name, lockedby, lockonoff);
|
|
|
|
|
if (lockonoff) strncpy (r->lockedby, lockedby.c_str(), REFERENCENAME_LEN);
|
|
|
|
|
else r->lockedby[0] = 0;
|
|
|
|
|
Lock();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
debug (0, "*** ERROR *** RailWay BLOCK not start and end (r->name:%s) startblock:%s [%s] endblock:%s [%s]"
|
|
|
|
|
, r->name, startblock.c_str(), startblock2.c_str(), endblock.c_str(), endblock2.c_str());
|
|
|
|
|
server->PowerOnOff(0);
|
|
|
|
|
}
|
|
|
|
|
jp.Clear();
|
|
|
|
|
jp.AddObject("railway",_GetJSONRailway(pos.x, pos.y));
|
|
|
|
|
if(network) network->ChangeListPushToAll(jp.ToString());
|
|
|
|
@ -1287,12 +1121,14 @@ int Railways::LockWay (string way, string lockedby, int lockonoff) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// in case this turnout is not in the way list. It is might in between the splitblocks
|
|
|
|
|
if (way.substr(curwaypos+2, pos1-curwaypos-2).compare(r->name) != 0) {
|
|
|
|
|
debug (0, "LockWay turnout '%s' not on Way '%s' we should on '%s'", r->name, way.c_str(), way.substr(curwaypos+2, pos1-curwaypos-2).c_str());
|
|
|
|
|
UnLock();
|
|
|
|
|
return 0;
|
|
|
|
|
int d = server->turnouts.Get(r->name);
|
|
|
|
|
debug (0, "LockWay tournout %s in between start or endblock? Active: %d", r->name, d);
|
|
|
|
|
pos = NextPos(pos, d ? r->altdir : r->dir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
if (way[pos1+1] == '0') pos = NextPos(pos, r->dir);
|
|
|
|
|
else pos = NextPos(pos, r->altdir);
|
|
|
|
|
|
|
|
|
@ -1300,6 +1136,7 @@ int Railways::LockWay (string way, string lockedby, int lockonoff) {
|
|
|
|
|
curwaypos = way.find(",t:", curwaypos);
|
|
|
|
|
if (curwaypos != string::npos) curwaypos++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (r->type == RAILWAY_CONNECTOR) {
|
|
|
|
|
int found = 0;
|
|
|
|
|