diff --git a/server/locomotive.cc b/server/locomotive.cc index 6d9e746..9c7a0f6 100644 --- a/server/locomotive.cc +++ b/server/locomotive.cc @@ -613,9 +613,20 @@ int Locomotives::Loop() { if (loco->auto_onroute == LOCO_OR_NOTHING) { timer_start(&loco->auto_timenext); loco->auto_onroute = LOCO_OR_SEARCH; + // + // check if the loco mode is set to autostop + if (loco->flags & LOCO_F_AUTOSTOP) { + SetMan(loco->name); + } } else if (loco->auto_onroute == LOCO_OR_SEARCH) { + // + // check if the loco mode is set to autostop + if (loco->flags & LOCO_F_AUTOSTOP) { + SetMan(loco->name); + } + // // try to find and prepare(lock) a new way. // nothing found check if we can reverse direction, this will be done only @@ -752,7 +763,7 @@ int Locomotives::Loop() { // try to find new way printf ("%s:%d LOCO_OR_ONTHEWAY try to find new way\n", __FILE__, __LINE__); if (loco->blockdest[0] == 0) { - if ((loco->flags & LOCO_F_RANDOM) && (loco->flags & LOCO_F_CARGO || !(server->blocks.GetFlags(block) & BLOCK_F_STATION))) + if ((loco->flags & LOCO_F_RANDOM) && ((loco->flags & LOCO_F_CARGO) || !(server->blocks.GetFlags(block) & BLOCK_F_STATION))) if (server->railways.FindRandomWay(loco->blockassign, loco->name, &way)) { size_t pos; if ((pos = way.find(",b:", 1)) != string::npos) { diff --git a/webinterface/locomotive.js b/webinterface/locomotive.js index 85f740e..ff72366 100644 --- a/webinterface/locomotive.js +++ b/webinterface/locomotive.js @@ -648,7 +648,7 @@ function lococtrl_show(name) { \ \ \ - \ + \ \ \ \ @@ -693,6 +693,9 @@ function lococtrl_cb_btnreset() { var name = getTextBetween(this.id, "lococtrl_", "_btnreset"); var request = { command: "locomotivereset", locomotive: name }; serverinout (request, serverinout_defaultCallback); + + request = { command: "locomotivesetman", locomotive: name }; + serverinout (request, serverinout_defaultCallback); }; @@ -790,7 +793,11 @@ function lococtrl_setData(data) { var cbauto = document.getElementById("lococtrl_"+data.name+"_cbauto"); var cbrand = document.getElementById("lococtrl_"+data.name+"_cbrand"); var cbmanstop = document.getElementById("lococtrl_"+data.name+"_cbstopman"); - + var btnman = document.getElementById("lococtrl_"+data.name+"_btnman"); + var btnautostop = document.getElementById("lococtrl_"+data.name+"_btnstopman"); + var btnauto = document.getElementById("lococtrl_"+data.name+"_btnauto"); + var btnautorand = document.getElementById("lococtrl_"+data.name+"_btnrand"); + if (range && reverse) { debug ("lococtrl: " + data.name + " speed:" + data.speed + " vmax:" + data.vmax + " flags:" + data.flags); @@ -801,7 +808,26 @@ function lococtrl_setData(data) { cbrand.checked = (data.flags & LOCO_F_RANDOM); cbmanstop.checked = (data.flags & LOCO_F_AUTOSTOP); - range.min = 0; + if (data.flags & LOCO_F_AUTOSTOP) { + btnman.disabled = false; + btnauto.disabled = true; + btnautorand.disabled = true; + btnautostop.disabled = true; + } + else if (data.flags & LOCO_F_AUTO) { + btnman.disabled = true; + btnautorand.disabled = false; + btnautostop.disabled = false; + } + else { + btnman.disabled = true; + btnautorand.disabled = true; + btnautostop.disabled = true; + btnauto.disabled = false; + } + + + range.min = 0; if (data.vmax) range.max = data.vmax; range.value = Math.abs(Number(data.speed)); }