mark blocks as onlyCARGO or onlyPESSANGER is working

master
Steffen Pohle 4 years ago
parent 0e75d05c14
commit 47ebbf3ada

@ -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

@ -11,7 +11,8 @@
#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];

@ -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());

@ -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;

@ -9,7 +9,8 @@ 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) {
<label><input id=\"blockdet_flagend\" type=\"checkbox\" value=\"\">End</label><br> \
<label><input id=\"blockdet_flagstation\" type=\"checkbox\" value=\"\">Station</label><br> \
<label><input id=\"blockdet_flagspeedlimit\" type=\"checkbox\" value=\"\">Speed Limit</label><br> \
</td><td> \
<label><input id=\"blockdet_flagonlycargo\" type=\"checkbox\" value=\"\">Only Cargo</label><br> \
<label><input id=\"blockdet_flagonlypassenger\" type=\"checkbox\" value=\"\">Only Passenger</label><br> \
<label><input id=\"blockdet_flagunknown\" type=\"hidden\" value=\"\"></label><br> \
</td></tr></table> \
\
</td><td></td></tr></table> \
@ -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;

@ -5,7 +5,7 @@ body {
}
:root {
--top-height: 34px;
--top-height: 35px;
--side-width: 37px;
--bottom-height: 0px;
--menu-bg-color: #333;

Loading…
Cancel
Save