diff --git a/ChangeLog b/ChangeLog index 3d24bdd..100b367 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ 2021-12-02: +- mark blocks as onlyCARGO or onlyPESSANGER, random-automode looks nice now. - webinterface: debug messages will be print to the console. - webinterface: contextmenu will be displayed inside the visible area diff --git a/server/block.h b/server/block.h index ebcdb2e..48133a1 100644 --- a/server/block.h +++ b/server/block.h @@ -5,13 +5,14 @@ #include "modelbahn.h" #include "server.h" -#define BLOCK_F_OFF 0x0001 -#define BLOCK_F_SHORT 0x0010 -#define BLOCK_F_LONG 0x0020 -#define BLOCK_F_ENDSTATION 0x0040 -#define BLOCK_F_STATION 0x0080 -#define BLOCK_F_SPEEDLIMIT 0x0100 - +#define BLOCK_F_OFF 0x0001 +#define BLOCK_F_SHORT 0x0010 +#define BLOCK_F_LONG 0x0020 +#define BLOCK_F_ENDSTATION 0x0040 +#define BLOCK_F_STATION 0x0080 +#define BLOCK_F_SPEEDLIMIT 0x0100 +#define BLOCK_F_ONLYCARGO 0x0200 +#define BLOCK_F_ONLYPASSENGER 0x0400 struct s_Block { char name[REFERENCENAME_LEN]; diff --git a/server/locomotive.cc b/server/locomotive.cc index ea2bdfa..6d9e746 100644 --- a/server/locomotive.cc +++ b/server/locomotive.cc @@ -297,6 +297,8 @@ int Locomotives::SetDestination (string name, string block, int direction) { blflags = server->blocks.GetFlags(block); if ((blflags & BLOCK_F_SHORT) && !(locomotives[i].flags & LOCO_F_SHORTTRAIN)) break; if ((blflags & BLOCK_F_ENDSTATION) && !(locomotives[i].flags & LOCO_F_CANREVERSE)) break; + if ((blflags & BLOCK_F_ONLYCARGO) && !(locomotives[i].flags & LOCO_F_CARGO)) break; + if ((blflags & BLOCK_F_ONLYPASSENGER) && (locomotives[i].flags & LOCO_F_CARGO)) break; if (direction) snprintf (locomotives[i].blockdest, REFERENCENAME_LEN, "-:%s", block.c_str()); else snprintf (locomotives[i].blockdest, REFERENCENAME_LEN, "+:%s", block.c_str()); diff --git a/server/railway.cc b/server/railway.cc index d73e97c..d33aa37 100644 --- a/server/railway.cc +++ b/server/railway.cc @@ -483,12 +483,12 @@ void Railways::DebugPrintFindWay(struct s_findway_map *fw) { } -///////////////////////////////////////////////////////////////////// -// -// FindWay: will be in two phases to decide where to go and how -// 1. check all possible ways in respect of (out of service blocks) -// 2. -// return 0 if no way found +/**************************************************************************** + * FindWay: will be in two phases to decide where to go and how + * - check all possible ways in respect of (out of service blocks) + * and the ONLYCARGO/PASSENGER flags + * return 0 if no way found + */ int Railways::FindWay(string blockstart, string blockend, string lockedfor, string *next) { // direction 0 ... RIGHT and DOWN // direction 1 ... LEFT and UP @@ -683,8 +683,9 @@ int Railways::FindWay(string blockstart, string blockend, string lockedfor, stri if ((server->blocks.IsOff(rpos->name) || ((blflags & BLOCK_F_ENDSTATION) && !(locoflags & LOCO_F_CANREVERSE)) || - ((blflags & BLOCK_F_SHORT) && !(locoflags & LOCO_F_SHORTTRAIN)))) { - printf ("%s:%d block is off\n", __FILE__, __LINE__); + ((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; @@ -918,7 +919,9 @@ int Railways::FindRandomWay(string blockstart, string lockedfor, string *next) { 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_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; diff --git a/webinterface/block.js b/webinterface/block.js index 9ebd3e7..679b67f 100644 --- a/webinterface/block.js +++ b/webinterface/block.js @@ -3,13 +3,14 @@ // var blocks = []; -const BLOCK_F_OFF = 0x0001; -const BLOCK_F_SHORT = 0x0010; -const BLOCK_F_LONG = 0x0020; -const BLOCK_F_ENDSTATION = 0x0040; -const BLOCK_F_STATION = 0x0080; -const BLOCK_F_SPEEDLIMIT = 0x0100; - +const BLOCK_F_OFF = 0x0001; +const BLOCK_F_SHORT = 0x0010; +const BLOCK_F_LONG = 0x0020; +const BLOCK_F_ENDSTATION = 0x0040; +const BLOCK_F_STATION = 0x0080; +const BLOCK_F_SPEEDLIMIT = 0x0100; +const BLOCK_F_ONLYCARGO = 0x0200; +const BLOCK_F_ONLYPASSENGER = 0x0400; // @@ -206,6 +207,10 @@ function blockdetail_show(name, create) {
\
\
\ + \ +
\ +
\ +
\ \ \ \ @@ -357,6 +362,8 @@ function blockdetail_setData(elm) { var flagshort = document.getElementById("blockdet_flagshort"); var flaglong = document.getElementById("blockdet_flaglong"); var flagend = document.getElementById("blockdet_flagend"); + var flagonlycargo = document.getElementById("blockdet_flagonlycargo"); + var flagonlypassenger = document.getElementById("blockdet_flagonlypassenger"); var flagstation = document.getElementById("blockdet_flagstation"); var flagspeedlimit = document.getElementById("blockdet_flagspeedlimit"); var sensorLU = document.getElementById("blockdet_sensorLU"); @@ -370,6 +377,8 @@ function blockdetail_setData(elm) { if (flagshort) flagshort.checked = Number(elm.flags) & BLOCK_F_SHORT; if (flaglong) flaglong.checked = Number(elm.flags) & BLOCK_F_LONG; if (flagend) flagend.checked = Number(elm.flags) & BLOCK_F_ENDSTATION; + if (flagonlycargo) flagonlycargo.checked = Number(elm.flags) & BLOCK_F_ONLYCARGO; + if (flagonlypassenger) flagonlypassenger.checked = Number(elm.flags) & BLOCK_F_ONLYPASSENGER; if (flagstation) flagstation.checked = Number(elm.flags) & BLOCK_F_STATION; if (flagspeedlimit) flagspeedlimit.checked = Number(elm.flags) & BLOCK_F_SPEEDLIMIT; if (sensorLU) sensorLU.value = elm.sensor_pos_1; @@ -391,6 +400,8 @@ function blockdetail_getData() { var flagshort = document.getElementById("blockdet_flagshort"); var flaglong = document.getElementById("blockdet_flaglong"); var flagend = document.getElementById("blockdet_flagend"); + var flagonlycargo = document.getElementById("blockdet_flagonlycargo"); + var flagonlypassenger = document.getElementById("blockdet_flagonlypassenger"); var flagstation = document.getElementById("blockdet_flagstation"); var flagspeedlimit = document.getElementById("blockdet_flagspeedlimit"); var sensorLU = document.getElementById("blockdet_sensorLU"); @@ -398,18 +409,31 @@ function blockdetail_getData() { var sensorRD = document.getElementById("blockdet_sensorRD"); if (name) res.name = name.value; + if (flagoff.checked) res.flags |= BLOCK_F_OFF; else res.flags &= ~BLOCK_F_OFF; + if (flagshort.checked) res.flags |= BLOCK_F_SHORT; else res.flags &= ~BLOCK_F_SHORT; + if (flaglong.checked) res.flags |= BLOCK_F_LONG; else res.flags &= ~BLOCK_F_LONG; + if (flagend.checked) res.flags |= BLOCK_F_ENDSTATION; else res.flags &= ~BLOCK_F_ENDSTATION; + + if (flagonlycargo.checked) res.flags |= BLOCK_F_ONLYCARGO; + else res.flags &= ~BLOCK_F_ONLYCARGO; + + if (flagonlypassenger.checked) res.flags |= BLOCK_F_ONLYPASSENGER; + else res.flags &= ~BLOCK_F_ONLYPASSENGER; + if (flagstation.checked) res.flags |= BLOCK_F_STATION; else res.flags &= ~BLOCK_F_STATION; + if (flagspeedlimit.checked) res.flags |= BLOCK_F_SPEEDLIMIT; else res.flags &= ~BLOCK_F_SPEEDLIMIT; + if (sensorLU) res.sensor_pos_1 = sensorLU.value; if (sensorC) res.sensor_center = sensorC.value; if (sensorRD) res.sensor_neg_1 = sensorRD.value; diff --git a/webinterface/layout.css b/webinterface/layout.css index 1fd1473..c7da369 100644 --- a/webinterface/layout.css +++ b/webinterface/layout.css @@ -5,7 +5,7 @@ body { } :root { - --top-height: 34px; + --top-height: 35px; --side-width: 37px; --bottom-height: 0px; --menu-bg-color: #333;