Add debug console command to unblock bay road stops with incorrect occupancy state
This commit is contained in:
@@ -63,6 +63,7 @@
|
||||
#include "tile_cmd.h"
|
||||
#include "object_base.h"
|
||||
#include "newgrf_newsignals.h"
|
||||
#include "roadstop_base.h"
|
||||
#include <time.h>
|
||||
|
||||
#include "3rdparty/cpp-btree/btree_set.h"
|
||||
@@ -2593,6 +2594,30 @@ DEF_CONSOLE_CMD(ConMergeLinkgraphJobsAsap)
|
||||
return true;
|
||||
}
|
||||
|
||||
DEF_CONSOLE_CMD(ConUnblockBayRoadStops)
|
||||
{
|
||||
if (argc == 0) {
|
||||
IConsoleHelp("Unblock bay road stops blocked by a bug, for single-player use only.");
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Station *st : Station::Iterate()) {
|
||||
for (RoadStopType rs_type : { ROADSTOP_BUS, ROADSTOP_TRUCK }) {
|
||||
for (RoadStop *rs = st->GetPrimaryRoadStop(rs_type); rs != nullptr; rs = rs->next) {
|
||||
if (IsBayRoadStopTile(rs->xy)) {
|
||||
rs->DebugClearOccupancy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const RoadVehicle *rv : RoadVehicle::Iterate()) {
|
||||
if (IsInsideMM(rv->state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END)) {
|
||||
RoadStop::GetByTile(rv->tile, GetRoadStopType(rv->tile))->DebugReEnter(rv);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
DEF_CONSOLE_CMD(ConDbgSpecial)
|
||||
{
|
||||
if (argc == 0) {
|
||||
@@ -4113,6 +4138,7 @@ void IConsoleStdLibRegister()
|
||||
/* Bug workarounds */
|
||||
IConsole::CmdRegister("jgrpp_bug_workaround_unblock_heliports", ConResetBlockedHeliports, ConHookNoNetwork, true);
|
||||
IConsole::CmdRegister("merge_linkgraph_jobs_asap", ConMergeLinkgraphJobsAsap, ConHookNoNetwork, true);
|
||||
IConsole::CmdRegister("unblock_bay_road_stops", ConUnblockBayRoadStops, ConHookNoNetwork, true);
|
||||
|
||||
IConsole::CmdRegister("dbgspecial", ConDbgSpecial, ConHookSpecialCmd, true);
|
||||
|
||||
|
@@ -370,6 +370,21 @@ bool RoadStop::Enter(RoadVehicle *rv)
|
||||
}
|
||||
}
|
||||
|
||||
void RoadStop::DebugClearOccupancy()
|
||||
{
|
||||
SetBit(this->status, RSSFB_BAY0_FREE);
|
||||
SetBit(this->status, RSSFB_BAY1_FREE);
|
||||
ClrBit(this->status, RSSFB_ENTRY_BUSY);
|
||||
}
|
||||
|
||||
void RoadStop::DebugReEnter(const RoadVehicle *rv)
|
||||
{
|
||||
if (!IsInsideMM(rv->state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END)) return;
|
||||
|
||||
ClrBit(this->status, HasBit(rv->state, RVS_USING_SECOND_BAY) ? RSSFB_BAY1_FREE : RSSFB_BAY0_FREE);
|
||||
if (!HasBit(rv->state, RVS_ENTERED_STOP)) SetBit(this->status, RSSFB_ENTRY_BUSY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Leave the road stop
|
||||
* @param rv the vehicle that leaves the stop
|
||||
|
@@ -167,6 +167,9 @@ struct RoadStop : RoadStopPool::PoolItem<&_roadstop_pool> {
|
||||
|
||||
static bool IsDriveThroughRoadStopContinuation(TileIndex rs, TileIndex next);
|
||||
|
||||
void DebugClearOccupancy();
|
||||
void DebugReEnter(const RoadVehicle *rv);
|
||||
|
||||
private:
|
||||
Entry *east; ///< The vehicles that entered from the east
|
||||
Entry *west; ///< The vehicles that entered from the west
|
||||
|
Reference in New Issue
Block a user