|
|
@ -41,7 +41,7 @@ int Railways::UnLock() {
|
|
|
|
// data must be mutex looked before use
|
|
|
|
// data must be mutex looked before use
|
|
|
|
struct s_findway_data Railways::NextPos(struct s_findway_data pos, int dirtype) {
|
|
|
|
struct s_findway_data Railways::NextPos(struct s_findway_data pos, int dirtype) {
|
|
|
|
struct s_findway_data np = { x: -1, y: -1, enterfrom: -1, oldx: pos.x, oldy:pos.y,
|
|
|
|
struct s_findway_data np = { x: -1, y: -1, enterfrom: -1, oldx: pos.x, oldy:pos.y,
|
|
|
|
oldenterfrom: pos.enterfrom, parma: pos.parma,
|
|
|
|
oldenterfrom: pos.enterfrom,
|
|
|
|
way: pos.way }; // newpos
|
|
|
|
way: pos.way }; // newpos
|
|
|
|
|
|
|
|
|
|
|
|
if (dirtype == 1) {
|
|
|
|
if (dirtype == 1) {
|
|
|
@ -501,6 +501,8 @@ int Railways::FindWay(string blockstart, string blockend, string lockedfor, stri
|
|
|
|
int found = 0;
|
|
|
|
int found = 0;
|
|
|
|
int locoflags = server->locomotives.GetFlags(lockedfor);
|
|
|
|
int locoflags = server->locomotives.GetFlags(lockedfor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
debug (0, "Railway::FindWay blockstart:%s blockend:%s lockedfor:%s", blockstart.c_str(), blockend.c_str(), lockedfor.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
// check blocklen
|
|
|
|
// check blocklen
|
|
|
|
if (blockstart.length() <= 3 || blockend.length() <= 3) return 0;
|
|
|
|
if (blockstart.length() <= 3 || blockend.length() <= 3) return 0;
|
|
|
|
|
|
|
|
|
|
|
@ -517,7 +519,6 @@ int Railways::FindWay(string blockstart, string blockend, string lockedfor, stri
|
|
|
|
fd_end.x = fd_start.x = -1;
|
|
|
|
fd_end.x = fd_start.x = -1;
|
|
|
|
fd_end.y = fd_start.y = -1;
|
|
|
|
fd_end.y = fd_start.y = -1;
|
|
|
|
fd_end.enterfrom = fd_start.enterfrom = -1;
|
|
|
|
fd_end.enterfrom = fd_start.enterfrom = -1;
|
|
|
|
fd_end.parma = fd_start.parma = -1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (FindReference(&fd_start.x, &fd_start.y, blockstart.substr(2, string::npos))) {
|
|
|
|
if (FindReference(&fd_start.x, &fd_start.y, blockstart.substr(2, string::npos))) {
|
|
|
|
if (Get(fd_start.x, fd_start.y).dir == 1) {
|
|
|
|
if (Get(fd_start.x, fd_start.y).dir == 1) {
|
|
|
@ -531,7 +532,6 @@ int Railways::FindWay(string blockstart, string blockend, string lockedfor, stri
|
|
|
|
fd_start.way = "b:" + blockstart;
|
|
|
|
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)].e = (1 << fd_start.enterfrom);
|
|
|
|
fd_data[GetRIdx(fd_start.x, fd_start.y)].score = 1;
|
|
|
|
fd_data[GetRIdx(fd_start.x, fd_start.y)].score = 1;
|
|
|
|
fd_start.parma = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
debug (0, "Railway::FindWay could not find startblock (%s).", blockstart.c_str());
|
|
|
|
debug (0, "Railway::FindWay could not find startblock (%s).", blockstart.c_str());
|
|
|
@ -617,9 +617,8 @@ int Railways::FindWay(string blockstart, string blockend, string lockedfor, stri
|
|
|
|
|
|
|
|
|
|
|
|
if (rpos->type == RAILWAY_NORMAL || rpos->type == RAILWAY_SENSOR) {
|
|
|
|
if (rpos->type == RAILWAY_NORMAL || rpos->type == RAILWAY_SENSOR) {
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->dir);
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->dir);
|
|
|
|
fd_pos.parma++;
|
|
|
|
|
|
|
|
rnext = &railways[GetRIdx(fd_pos.x, fd_pos.y)];
|
|
|
|
rnext = &railways[GetRIdx(fd_pos.x, fd_pos.y)];
|
|
|
|
if (rnext->lockedby[0] != 0) {
|
|
|
|
if (rnext->lockedby[0] != 0 || !_NextPosIsValid(lockedfor, locoflags, &fd_pos)) {
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
|
fd_pos.x = -1;
|
|
|
|
fd_pos.x = -1;
|
|
|
|
fd_pos.y = -1;
|
|
|
|
fd_pos.y = -1;
|
|
|
@ -630,19 +629,23 @@ int Railways::FindWay(string blockstart, string blockend, string lockedfor, stri
|
|
|
|
else if (rpos->type == RAILWAY_TURNOUT) {
|
|
|
|
else if (rpos->type == RAILWAY_TURNOUT) {
|
|
|
|
fd_tmp = NextPos(fd_pos, rpos->altdir);
|
|
|
|
fd_tmp = NextPos(fd_pos, rpos->altdir);
|
|
|
|
fd_tmp.way += (string)",t:" + (string)rpos->name + (string)":1";
|
|
|
|
fd_tmp.way += (string)",t:" + (string)rpos->name + (string)":1";
|
|
|
|
fd_tmp.parma += 10; // 10 bad point for using the turnout
|
|
|
|
|
|
|
|
fd_list.push_back(fd_tmp);
|
|
|
|
fd_list.push_back(fd_tmp);
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->dir);
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->dir);
|
|
|
|
fd_pos.way += (string)",t:" + (string)rpos->name + (string)":0";
|
|
|
|
if (!_NextPosIsValid(lockedfor, locoflags, &fd_pos)) {
|
|
|
|
fd_pos.parma++;
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
|
|
|
|
|
fd_pos.x = -1;
|
|
|
|
|
|
|
|
fd_pos.y = -1;
|
|
|
|
|
|
|
|
fd_pos.way = "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else fd_pos.way += (string)",t:" + (string)rpos->name + (string)":0";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
else if (rpos->type == RAILWAY_CONNECTOR) {
|
|
|
|
else if (rpos->type == RAILWAY_CONNECTOR) {
|
|
|
|
int found = 0;
|
|
|
|
int conector_found = 0;
|
|
|
|
|
|
|
|
|
|
|
|
x = -1;
|
|
|
|
x = -1;
|
|
|
|
y = -1;
|
|
|
|
y = -1;
|
|
|
|
while (found == 0 && _FindReference(&x, &y, rpos->name) == 1) {
|
|
|
|
while (conector_found == 0 && _FindReference(&x, &y, rpos->name) == 1) {
|
|
|
|
if (fd_pos.x != x || fd_pos.y != y) {
|
|
|
|
if (fd_pos.x != x || fd_pos.y != y) {
|
|
|
|
fd_pos.oldx = fd_pos.x;
|
|
|
|
fd_pos.oldx = fd_pos.x;
|
|
|
|
fd_pos.oldy = fd_pos.y;
|
|
|
|
fd_pos.oldy = fd_pos.y;
|
|
|
@ -651,13 +654,13 @@ int Railways::FindWay(string blockstart, string blockend, string lockedfor, stri
|
|
|
|
fd_pos.y = y;
|
|
|
|
fd_pos.y = y;
|
|
|
|
rpos = &railways[GetRIdx(fd_pos.x, fd_pos.y)];
|
|
|
|
rpos = &railways[GetRIdx(fd_pos.x, fd_pos.y)];
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->dir);
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->dir);
|
|
|
|
fd_pos.parma++;
|
|
|
|
|
|
|
|
found = 1;
|
|
|
|
conector_found = 1;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (found == 0) {
|
|
|
|
if (found == 0 || !_NextPosIsValid(lockedfor, locoflags, &fd_pos)) {
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
|
fd_pos.x = -1;
|
|
|
|
fd_pos.x = -1;
|
|
|
|
fd_pos.y = -1;
|
|
|
|
fd_pos.y = -1;
|
|
|
@ -671,7 +674,8 @@ int Railways::FindWay(string blockstart, string blockend, string lockedfor, stri
|
|
|
|
|
|
|
|
|
|
|
|
if ((server->blocks.IsOff(rpos->name) ||
|
|
|
|
if ((server->blocks.IsOff(rpos->name) ||
|
|
|
|
((blflags & BLOCK_F_ENDSTATION) && !(locoflags & LOCO_F_CANREVERSE)) ||
|
|
|
|
((blflags & BLOCK_F_ENDSTATION) && !(locoflags & LOCO_F_CANREVERSE)) ||
|
|
|
|
((blflags & BLOCK_F_SHORT) && !(locoflags & LOCO_F_SHORTTRAIN)) ||
|
|
|
|
((blflags & BLOCK_F_SHORT) && !(locoflags & LOCO_F_SHORTTRAIN) &&
|
|
|
|
|
|
|
|
!_SplitBlockIsFreeAndAllowed(lockedfor, locoflags, rpos->name)) ||
|
|
|
|
((blflags & BLOCK_F_ONLYCARGO) && !(locoflags & LOCO_F_CARGO)) ||
|
|
|
|
((blflags & BLOCK_F_ONLYCARGO) && !(locoflags & LOCO_F_CARGO)) ||
|
|
|
|
((blflags & BLOCK_F_ONLYPASSENGER) && (locoflags & LOCO_F_CARGO)))) {
|
|
|
|
((blflags & BLOCK_F_ONLYPASSENGER) && (locoflags & LOCO_F_CARGO)))) {
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
@ -688,7 +692,12 @@ int Railways::FindWay(string blockstart, string blockend, string lockedfor, stri
|
|
|
|
else fd_pos.way += (string)",b:-:" + (string)rpos->name;
|
|
|
|
else fd_pos.way += (string)",b:-:" + (string)rpos->name;
|
|
|
|
|
|
|
|
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->dir);
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->dir);
|
|
|
|
fd_pos.parma++;
|
|
|
|
if (!_NextPosIsValid(lockedfor, locoflags, &fd_pos)) {
|
|
|
|
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
|
|
|
|
|
fd_pos.x = -1;
|
|
|
|
|
|
|
|
fd_pos.y = -1;
|
|
|
|
|
|
|
|
fd_pos.way = "";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
@ -727,6 +736,85 @@ int Railways::FindWay(string blockstart, string blockend, string lockedfor, stri
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* check if the position in fwd.x|y is valid for the loco. The check will only done on
|
|
|
|
|
|
|
|
* RAILWAY_BLOCK types. It will also check if the block is free.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
int Railways::_NextPosIsValid(string loconame, int locoflags, struct s_findway_data *fwd) {
|
|
|
|
|
|
|
|
int bflags = -1;
|
|
|
|
|
|
|
|
Railway *rpos = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rpos = &railways[GetRIdx(fwd->x, fwd->y)];
|
|
|
|
|
|
|
|
bflags = server->blocks.GetFlags(rpos->name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rpos->type != RAILWAY_BLOCK) return 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (server->blocks.IsOff(rpos->name)) return 0;
|
|
|
|
|
|
|
|
if ((bflags & BLOCK_F_ENDSTATION) && !(locoflags & LOCO_F_CANREVERSE)) return 0;
|
|
|
|
|
|
|
|
if ((bflags & BLOCK_F_SHORT) && !(locoflags & LOCO_F_SHORTTRAIN) &&
|
|
|
|
|
|
|
|
!_SplitBlockIsFreeAndAllowed(loconame, locoflags, rpos->name)) return 0;
|
|
|
|
|
|
|
|
if ((bflags & BLOCK_F_ONLYCARGO) && !(locoflags & LOCO_F_CARGO)) return 0;
|
|
|
|
|
|
|
|
if ((bflags & BLOCK_F_ONLYPASSENGER) && (locoflags & LOCO_F_CARGO)) return 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* check if this is a split block, and if it can be entered
|
|
|
|
|
|
|
|
* all needed elements must be unlocked to return 1.
|
|
|
|
|
|
|
|
* if the loco is a short train return 0
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
int Railways::_SplitBlockIsFreeAndAllowed(string loconame, int locoflags, string block) {
|
|
|
|
|
|
|
|
string pblock;
|
|
|
|
|
|
|
|
string nblock;
|
|
|
|
|
|
|
|
int bflags = server->blocks.GetFlags(block);
|
|
|
|
|
|
|
|
int nblockflags = 0;
|
|
|
|
|
|
|
|
int pblockflags = 0;
|
|
|
|
|
|
|
|
int x1, y1, x2, y2, dx = 0, dy = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
debug (0, "Railway::_SplitBlockIsFreeAndAllowed loconame:%s flags:%d block:%s", loconame.c_str(), locoflags, block.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (locoflags & LOCO_F_SHORTTRAIN) return 0;
|
|
|
|
|
|
|
|
if ((locoflags & !LOCO_F_SHORTTRAIN) && (bflags & !BLOCK_F_SPLIT)) return 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// read negative the positive block flags
|
|
|
|
|
|
|
|
if (bflags & BLOCK_F_SPLITPOS) {
|
|
|
|
|
|
|
|
pblockflags = bflags;
|
|
|
|
|
|
|
|
pblock = block;
|
|
|
|
|
|
|
|
nblock = server->blocks.GetSecondBlock(block);
|
|
|
|
|
|
|
|
if (nblock.length() == 0) return 0;
|
|
|
|
|
|
|
|
nblockflags = server->blocks.GetFlags(nblock);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
nblockflags = bflags;
|
|
|
|
|
|
|
|
nblock = block;
|
|
|
|
|
|
|
|
pblock = server->blocks.GetSecondBlock(block);
|
|
|
|
|
|
|
|
if (pblock.length() == 0) return 0;
|
|
|
|
|
|
|
|
pblockflags = server->blocks.GetFlags(pblock);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// check if blockflags are setup right and the blocks are free
|
|
|
|
|
|
|
|
if (!(nblockflags & BLOCK_F_SPLIT) && (nblockflags & BLOCK_F_SPLITPOS)) return 0;
|
|
|
|
|
|
|
|
if (!(pblockflags & BLOCK_F_SPLIT) && !(pblockflags & BLOCK_F_SPLITPOS)) return 0;
|
|
|
|
|
|
|
|
if (server->blocks.GetLockedby(nblock).length() != 0) return 0;
|
|
|
|
|
|
|
|
if (server->blocks.GetLockedby(pblock).length() != 0) return 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check the way between the blocks
|
|
|
|
|
|
|
|
if (_FindReference(&x1, &y1, pblock) == 0) return 0;
|
|
|
|
|
|
|
|
if (_FindReference(&x2, &y2, nblock) == 0) return 0;
|
|
|
|
|
|
|
|
debug (0, "Railway::_SplitBlockIsFreeAndAllowed p pos(%d,%d) n pos(%d,%d)", x1, y1, x2, y2);
|
|
|
|
|
|
|
|
// if (x1 == x2 )
|
|
|
|
|
|
|
|
// do {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// } while
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Railways::FindRandomWay(string blockstart, string lockedfor, string *next) {
|
|
|
|
int Railways::FindRandomWay(string blockstart, string lockedfor, string *next) {
|
|
|
|
// direction 0 ... RIGHT and DOWN
|
|
|
|
// direction 0 ... RIGHT and DOWN
|
|
|
|
// direction 1 ... LEFT and UP
|
|
|
|
// direction 1 ... LEFT and UP
|
|
|
@ -742,7 +830,8 @@ int Railways::FindRandomWay(string blockstart, string lockedfor, string *next) {
|
|
|
|
int found = 0;
|
|
|
|
int found = 0;
|
|
|
|
int locoflags = server->locomotives.GetFlags(lockedfor);
|
|
|
|
int locoflags = server->locomotives.GetFlags(lockedfor);
|
|
|
|
|
|
|
|
|
|
|
|
debug (0, "Railway::FindRandomWay");
|
|
|
|
debug (0, "Railway::FindRandomWay - disabled for now - needs to be rewritten");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
// check blocklen
|
|
|
|
// check blocklen
|
|
|
|
if (blockstart.length() <= 3) return 0;
|
|
|
|
if (blockstart.length() <= 3) return 0;
|
|
|
@ -760,7 +849,6 @@ int Railways::FindRandomWay(string blockstart, string lockedfor, string *next) {
|
|
|
|
fd_end.x = fd_start.x = -1;
|
|
|
|
fd_end.x = fd_start.x = -1;
|
|
|
|
fd_end.y = fd_start.y = -1;
|
|
|
|
fd_end.y = fd_start.y = -1;
|
|
|
|
fd_end.enterfrom = fd_start.enterfrom = -1;
|
|
|
|
fd_end.enterfrom = fd_start.enterfrom = -1;
|
|
|
|
fd_end.parma = fd_start.parma = -1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (FindReference(&fd_start.x, &fd_start.y, blockstart.substr(2, string::npos))) {
|
|
|
|
if (FindReference(&fd_start.x, &fd_start.y, blockstart.substr(2, string::npos))) {
|
|
|
|
if (Get(fd_start.x, fd_start.y).dir == 1) {
|
|
|
|
if (Get(fd_start.x, fd_start.y).dir == 1) {
|
|
|
@ -774,7 +862,6 @@ int Railways::FindRandomWay(string blockstart, string lockedfor, string *next) {
|
|
|
|
fd_start.way = "b:" + blockstart;
|
|
|
|
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)].e = (1 << fd_start.enterfrom);
|
|
|
|
fd_data[GetRIdx(fd_start.x, fd_start.y)].score = 1;
|
|
|
|
fd_data[GetRIdx(fd_start.x, fd_start.y)].score = 1;
|
|
|
|
fd_start.parma = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
debug (0, "Railway::FindRandomWay could not find startblock (%s).", blockstart.c_str());
|
|
|
|
debug (0, "Railway::FindRandomWay could not find startblock (%s).", blockstart.c_str());
|
|
|
@ -831,7 +918,6 @@ int Railways::FindRandomWay(string blockstart, string lockedfor, string *next) {
|
|
|
|
|
|
|
|
|
|
|
|
if (rpos->type == RAILWAY_NORMAL || rpos->type == RAILWAY_SENSOR) {
|
|
|
|
if (rpos->type == RAILWAY_NORMAL || rpos->type == RAILWAY_SENSOR) {
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->dir);
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->dir);
|
|
|
|
fd_pos.parma++;
|
|
|
|
|
|
|
|
rnext = &railways[GetRIdx(fd_pos.x, fd_pos.y)];
|
|
|
|
rnext = &railways[GetRIdx(fd_pos.x, fd_pos.y)];
|
|
|
|
if (rnext->lockedby[0] != 0) {
|
|
|
|
if (rnext->lockedby[0] != 0) {
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
|
fd_pos.enterfrom = -1;
|
|
|
@ -846,20 +932,16 @@ int Railways::FindRandomWay(string blockstart, string lockedfor, string *next) {
|
|
|
|
if ((rand() & 1) == 1) {
|
|
|
|
if ((rand() & 1) == 1) {
|
|
|
|
fd_tmp = NextPos(fd_pos, rpos->altdir);
|
|
|
|
fd_tmp = NextPos(fd_pos, rpos->altdir);
|
|
|
|
fd_tmp.way += (string)",t:" + (string)rpos->name + (string)":1";
|
|
|
|
fd_tmp.way += (string)",t:" + (string)rpos->name + (string)":1";
|
|
|
|
fd_tmp.parma += 10; // 10 bad point for using the turnout
|
|
|
|
|
|
|
|
fd_list.push_back(fd_tmp);
|
|
|
|
fd_list.push_back(fd_tmp);
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->dir);
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->dir);
|
|
|
|
fd_pos.way += (string)",t:" + (string)rpos->name + (string)":0";
|
|
|
|
fd_pos.way += (string)",t:" + (string)rpos->name + (string)":0";
|
|
|
|
fd_pos.parma++;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
fd_tmp = NextPos(fd_pos, rpos->dir);
|
|
|
|
fd_tmp = NextPos(fd_pos, rpos->dir);
|
|
|
|
fd_tmp.way += (string)",t:" + (string)rpos->name + (string)":0";
|
|
|
|
fd_tmp.way += (string)",t:" + (string)rpos->name + (string)":0";
|
|
|
|
fd_tmp.parma += 10; // 10 bad point for using the turnout
|
|
|
|
|
|
|
|
fd_list.push_back(fd_tmp);
|
|
|
|
fd_list.push_back(fd_tmp);
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->altdir);
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->altdir);
|
|
|
|
fd_pos.way += (string)",t:" + (string)rpos->name + (string)":1";
|
|
|
|
fd_pos.way += (string)",t:" + (string)rpos->name + (string)":1";
|
|
|
|
fd_pos.parma++;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -877,7 +959,6 @@ int Railways::FindRandomWay(string blockstart, string lockedfor, string *next) {
|
|
|
|
fd_pos.y = y;
|
|
|
|
fd_pos.y = y;
|
|
|
|
rpos = &railways[GetRIdx(fd_pos.x, fd_pos.y)];
|
|
|
|
rpos = &railways[GetRIdx(fd_pos.x, fd_pos.y)];
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->dir);
|
|
|
|
fd_pos = NextPos(fd_pos, rpos->dir);
|
|
|
|
fd_pos.parma++;
|
|
|
|
|
|
|
|
found = 1;
|
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -980,7 +1061,6 @@ int Railways::LockWay (string way, string lockedby, int lockonoff) {
|
|
|
|
end.x = start.x = -1;
|
|
|
|
end.x = start.x = -1;
|
|
|
|
end.y = start.y = -1;
|
|
|
|
end.y = start.y = -1;
|
|
|
|
end.enterfrom = start.enterfrom = -1;
|
|
|
|
end.enterfrom = start.enterfrom = -1;
|
|
|
|
end.parma = start.parma = -1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((pos1 = way.find("b:", 0)) == string::npos) return 0;
|
|
|
|
if ((pos1 = way.find("b:", 0)) == string::npos) return 0;
|
|
|
|
if ((pos2 = way.find(",", pos1+1)) == string::npos) return 0;
|
|
|
|
if ((pos2 = way.find(",", pos1+1)) == string::npos) return 0;
|
|
|
@ -1128,7 +1208,6 @@ int Railways::LockWay (string way, string lockedby, int lockonoff) {
|
|
|
|
pos.y = y;
|
|
|
|
pos.y = y;
|
|
|
|
r = &railways[GetRIdx(pos.x, pos.y)];
|
|
|
|
r = &railways[GetRIdx(pos.x, pos.y)];
|
|
|
|
pos = NextPos(pos, r->dir);
|
|
|
|
pos = NextPos(pos, r->dir);
|
|
|
|
pos.parma++;
|
|
|
|
|
|
|
|
found = 1;
|
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|