Add current order (station, waypoint or depot) condition variable.
Adjust item bit allocations: * Increase cond flags from 2 bits to 3 bits, for future expansion. * Use 2 bits remaining in adjacent gap for an auxiliary type field. This is used for the type (station, waypoint, etc.) of order tests. Perform a linear scan of the program pool when deleting a station, waypoint or depot.
This commit is contained in:
@@ -59,10 +59,11 @@ enum TraceRestrictItemFlagAllocation {
|
||||
|
||||
/* 3 bits reserved for future use */
|
||||
|
||||
TRIFA_COND_FLAGS_COUNT = 2,
|
||||
TRIFA_COND_FLAGS_COUNT = 3,
|
||||
TRIFA_COND_FLAGS_OFFSET = 8,
|
||||
|
||||
/* 3 bits reserved for future use */
|
||||
TRIFA_AUX_FIELD_COUNT = 2,
|
||||
TRIFA_AUX_FIELD_OFFSET = 11,
|
||||
|
||||
TRIFA_COND_OP_COUNT = 3,
|
||||
TRIFA_COND_OP_OFFSET = 13,
|
||||
@@ -81,6 +82,7 @@ enum TraceRestrictItemType {
|
||||
TRIT_COND_UNDEFINED = 9, ///< This condition has no type defined (evaluate as false)
|
||||
TRIT_COND_TRAIN_LENGTH = 10, ///< Test train length
|
||||
TRIT_COND_MAX_SPEED = 11, ///< Test train max speed
|
||||
TRIT_COND_CURRENT_ORDER = 12, ///< Test train current order (station, waypoint or depot)
|
||||
/* space up to 31 */
|
||||
};
|
||||
|
||||
@@ -88,6 +90,7 @@ enum TraceRestrictItemType {
|
||||
enum TraceRestrictCondFlags {
|
||||
TRCF_ELSE = 1 << 0,
|
||||
TRCF_OR = 1 << 1,
|
||||
/* 1 bit spare */
|
||||
};
|
||||
DECLARE_ENUM_AS_BIT_SET(TraceRestrictCondFlags)
|
||||
|
||||
@@ -107,6 +110,13 @@ enum TraceRestrictCondOp {
|
||||
/* space up to 7 */
|
||||
};
|
||||
|
||||
enum TraceRestrictOrderCondAuxField {
|
||||
TROCAF_STATION = 0,
|
||||
TROCAF_WAYPOINT = 1,
|
||||
TROCAF_DEPOT = 2,
|
||||
/* space up to 7 */
|
||||
};
|
||||
|
||||
enum TraceRestrictProgramResultFlags {
|
||||
TRPRF_DENY = 1 << 0,
|
||||
};
|
||||
@@ -155,6 +165,11 @@ static inline TraceRestrictCondOp GetTraceRestrictCondOp(TraceRestrictItem item)
|
||||
return static_cast<TraceRestrictCondOp>(GB(item, TRIFA_COND_OP_OFFSET, TRIFA_COND_OP_COUNT));
|
||||
}
|
||||
|
||||
static inline uint8 GetTraceRestrictAuxField(TraceRestrictItem item)
|
||||
{
|
||||
return GB(item, TRIFA_AUX_FIELD_OFFSET, TRIFA_AUX_FIELD_COUNT);
|
||||
}
|
||||
|
||||
static inline uint16 GetTraceRestrictValue(TraceRestrictItem item)
|
||||
{
|
||||
return static_cast<uint16>(GB(item, TRIFA_VALUE_OFFSET, TRIFA_VALUE_COUNT));
|
||||
@@ -170,6 +185,11 @@ static inline void SetTraceRestrictCondOp(TraceRestrictItem &item, TraceRestrict
|
||||
SB(item, TRIFA_COND_OP_OFFSET, TRIFA_COND_OP_COUNT, condop);
|
||||
}
|
||||
|
||||
static inline void SetTraceRestrictAuxField(TraceRestrictItem &item, uint8 data)
|
||||
{
|
||||
SB(item, TRIFA_AUX_FIELD_OFFSET, TRIFA_AUX_FIELD_COUNT, data);
|
||||
}
|
||||
|
||||
void SetTraceRestrictTypeAndNormalise(TraceRestrictItem &item, TraceRestrictItemType type);
|
||||
|
||||
static inline void SetTraceRestrictValue(TraceRestrictItem &item, uint16 value)
|
||||
@@ -199,6 +219,7 @@ enum TraceRestrictValueType {
|
||||
TRVT_INT = 2, ///< takes an integer value
|
||||
TRVT_DENY = 3, ///< takes a value 0 = deny, 1 = allow (cancel previous deny)
|
||||
TRVT_SPEED = 4, ///< takes an integer speed value
|
||||
TRVT_ORDER = 5, ///< takes an order target ID, as per the auxiliary field as type: TraceRestrictOrderCondAuxField
|
||||
};
|
||||
|
||||
struct TraceRestrictTypePropertySet {
|
||||
@@ -229,6 +250,11 @@ static inline TraceRestrictTypePropertySet GetTraceRestrictTypeProperties(TraceR
|
||||
out.value_type = TRVT_SPEED;
|
||||
break;
|
||||
|
||||
case TRIT_COND_CURRENT_ORDER:
|
||||
out.value_type = TRVT_ORDER;
|
||||
out.cond_type = TRCOT_BINARY;
|
||||
break;
|
||||
|
||||
default:
|
||||
NOT_REACHED();
|
||||
break;
|
||||
@@ -311,4 +337,6 @@ CommandCost CmdProgramSignalTraceRestrictProgMgmt(TileIndex tile, DoCommandFlag
|
||||
|
||||
void ShowTraceRestrictProgramWindow(TileIndex tile, Track track);
|
||||
|
||||
void TraceRestrictRemoveDestinationID(TraceRestrictOrderCondAuxField type, uint16 index);
|
||||
|
||||
#endif /* TRACERESTRICT_H */
|
||||
|
Reference in New Issue
Block a user