Merge branch 'tracerestrict-sx' into jgrpp
# Conflicts: # src/pbs.cpp # src/saveload/extended_ver_sl.cpp
This commit is contained in:
@@ -22,11 +22,11 @@
|
||||
#include "string_func.h"
|
||||
#include "pathfinder/yapf/yapf_cache.h"
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
/** @file
|
||||
*
|
||||
* Trace Restrict Data Storage Model Notes:
|
||||
@@ -479,10 +479,26 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp
|
||||
break;
|
||||
|
||||
case TRIT_WAIT_AT_PBS:
|
||||
if (GetTraceRestrictValue(item)) {
|
||||
out.flags &= ~TRPRF_WAIT_AT_PBS;
|
||||
} else {
|
||||
out.flags |= TRPRF_WAIT_AT_PBS;
|
||||
switch (static_cast<TraceRestrictWaitAtPbsValueField>(GetTraceRestrictValue(item))) {
|
||||
case TRWAPVF_WAIT_AT_PBS:
|
||||
out.flags |= TRPRF_WAIT_AT_PBS;
|
||||
break;
|
||||
|
||||
case TRWAPVF_CANCEL_WAIT_AT_PBS:
|
||||
out.flags &= ~TRPRF_WAIT_AT_PBS;
|
||||
break;
|
||||
|
||||
case TRWAPVF_PBS_RES_END_WAIT:
|
||||
out.flags |= TRPRF_PBS_RES_END_WAIT;
|
||||
break;
|
||||
|
||||
case TRWAPVF_CANCEL_PBS_RES_END_WAIT:
|
||||
out.flags &= ~TRPRF_PBS_RES_END_WAIT;
|
||||
break;
|
||||
|
||||
default:
|
||||
NOT_REACHED();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -509,6 +525,22 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp
|
||||
if (input.permitted_slot_operations & TRPISP_RELEASE_FRONT) slot->Vacate(v->index);
|
||||
break;
|
||||
|
||||
case TRSCOF_PBS_RES_END_ACQ_WAIT:
|
||||
if (input.permitted_slot_operations & TRPISP_PBS_RES_END_ACQUIRE) {
|
||||
if (!slot->Occupy(v->index)) out.flags |= TRPRF_PBS_RES_END_WAIT;
|
||||
} else if (input.permitted_slot_operations & TRPISP_PBS_RES_END_ACQ_DRY) {
|
||||
if (!slot->OccupyDryRun(v->index)) out.flags |= TRPRF_PBS_RES_END_WAIT;
|
||||
}
|
||||
break;
|
||||
|
||||
case TRSCOF_PBS_RES_END_ACQ_TRY:
|
||||
if (input.permitted_slot_operations & TRPISP_PBS_RES_END_ACQUIRE) slot->Occupy(v->index);
|
||||
break;
|
||||
|
||||
case TRSCOF_PBS_RES_END_RELEASE:
|
||||
if (input.permitted_slot_operations & TRPISP_PBS_RES_END_RELEASE) slot->Vacate(v->index);
|
||||
break;
|
||||
|
||||
default:
|
||||
NOT_REACHED();
|
||||
break;
|
||||
@@ -629,7 +661,21 @@ CommandCost TraceRestrictProgram::Validate(const std::vector<TraceRestrictItem>
|
||||
break;
|
||||
|
||||
case TRIT_WAIT_AT_PBS:
|
||||
actions_used_flags |= TRPAUF_WAIT_AT_PBS;
|
||||
switch (static_cast<TraceRestrictWaitAtPbsValueField>(GetTraceRestrictValue(item))) {
|
||||
case TRWAPVF_WAIT_AT_PBS:
|
||||
case TRWAPVF_CANCEL_WAIT_AT_PBS:
|
||||
actions_used_flags |= TRPAUF_WAIT_AT_PBS;
|
||||
break;
|
||||
|
||||
case TRWAPVF_PBS_RES_END_WAIT:
|
||||
case TRWAPVF_CANCEL_PBS_RES_END_WAIT:
|
||||
actions_used_flags |= TRPAUF_PBS_RES_END_WAIT;
|
||||
break;
|
||||
|
||||
default:
|
||||
NOT_REACHED();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case TRIT_SLOT:
|
||||
@@ -650,6 +696,15 @@ CommandCost TraceRestrictProgram::Validate(const std::vector<TraceRestrictItem>
|
||||
actions_used_flags |= TRPAUF_SLOT_RELEASE_FRONT;
|
||||
break;
|
||||
|
||||
case TRSCOF_PBS_RES_END_ACQ_WAIT:
|
||||
actions_used_flags |= TRPAUF_PBS_RES_END_SLOT | TRPAUF_PBS_RES_END_WAIT;
|
||||
break;
|
||||
|
||||
case TRSCOF_PBS_RES_END_ACQ_TRY:
|
||||
case TRSCOF_PBS_RES_END_RELEASE:
|
||||
actions_used_flags |= TRPAUF_PBS_RES_END_SLOT;
|
||||
break;
|
||||
|
||||
default:
|
||||
NOT_REACHED();
|
||||
break;
|
||||
@@ -1473,6 +1528,18 @@ bool TraceRestrictSlot::Occupy(VehicleID id, bool force)
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dry-run adding vehicle ID to occupants if possible and not already an occupant
|
||||
* @param id Vehicle ID
|
||||
* @return whether vehicle IDwould be an occupant
|
||||
*/
|
||||
bool TraceRestrictSlot::OccupyDryRun(VehicleID id)
|
||||
{
|
||||
if (this->IsOccupant(id)) return true;
|
||||
if (this->occupants.size() >= this->max_occupancy) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove vehicle ID from occupants
|
||||
* @param id Vehicle ID
|
||||
|
Reference in New Issue
Block a user