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) {
\
\
\
+