Maintain a circular buffer of recent commands, add to crashlog.
[openttd-joker.git] / src / tracerestrict.h
blob08d459ef72911ce53ca1b9c65982cc3e9782cf8d
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
8 /** @file tracerestrict.h Header file for Trace Restrict */
10 #ifndef TRACERESTRICT_H
11 #define TRACERESTRICT_H
13 #include "stdafx.h"
14 #include "core/bitmath_func.hpp"
15 #include "core/enum_type.hpp"
16 #include "core/pool_type.hpp"
17 #include "command_func.h"
18 #include "rail_map.h"
19 #include "tile_type.h"
20 #include "group_type.h"
21 #include "3rdparty/cpp-btree/btree_map.h"
22 #include <vector>
24 struct Train;
26 /** Program pool ID type. */
27 typedef uint32 TraceRestrictProgramID;
28 struct TraceRestrictProgram;
30 /** Tile/track mapping type. */
31 typedef uint32 TraceRestrictRefId;
33 /** Type of the pool for trace restrict programs. */
34 typedef Pool<TraceRestrictProgram, TraceRestrictProgramID, 16, 256000> TraceRestrictProgramPool;
35 /** The actual pool for trace restrict nodes. */
36 extern TraceRestrictProgramPool _tracerestrictprogram_pool;
38 extern const uint16 _tracerestrict_pathfinder_penalty_preset_values[];
40 #define FOR_ALL_TRACE_RESTRICT_PROGRAMS_FROM(var, start) FOR_ALL_ITEMS_FROM(TraceRestrictProgram, tr_index, var, start)
41 #define FOR_ALL_TRACE_RESTRICT_PROGRAMS(var) FOR_ALL_TRACE_RESTRICT_PROGRAMS_FROM(var, 0)
43 /** Type used for the TraceRestrictRefId -> TraceRestrictProgramID mapping */
44 struct TraceRestrictMappingItem {
45 TraceRestrictProgramID program_id;
47 TraceRestrictMappingItem() { }
49 TraceRestrictMappingItem(TraceRestrictProgramID program_id_)
50 : program_id(program_id_) { }
53 typedef btree::btree_map<TraceRestrictRefId, TraceRestrictMappingItem> TraceRestrictMapping;
55 /** The actual mapping from TraceRestrictRefId to TraceRestrictProgramID. */
56 extern TraceRestrictMapping _tracerestrictprogram_mapping;
58 void ClearTraceRestrictMapping();
60 /** Type of a single instruction, this is bit-packed as per TraceRestrictItemFlagAllocation */
61 typedef uint32 TraceRestrictItem;
63 /**
64 * Describes the allocation of bits to fields in TraceRestrictItem
65 * Of the fields below, the type seem the most likely
66 * to need future expansion, hence the reserved bits are placed
67 * immediately after them
69 * COUNT values describe the field bit width
70 * OFFSET values describe the field bit offset
72 enum TraceRestrictItemFlagAllocation {
73 TRIFA_TYPE_COUNT = 5,
74 TRIFA_TYPE_OFFSET = 0,
76 /* 3 bits reserved for future use */
78 TRIFA_COND_FLAGS_COUNT = 3,
79 TRIFA_COND_FLAGS_OFFSET = 8,
81 TRIFA_AUX_FIELD_COUNT = 2,
82 TRIFA_AUX_FIELD_OFFSET = 11,
84 TRIFA_COND_OP_COUNT = 3,
85 TRIFA_COND_OP_OFFSET = 13,
87 TRIFA_VALUE_COUNT = 16,
88 TRIFA_VALUE_OFFSET = 16,
91 /**
92 * Enumeration of TraceRestrictItem type field
93 * This is split into two halves:
94 * * non-conditionals < TRIT_COND_BEGIN
95 * * conditionals, >= TRIT_COND_BEGIN
97 enum TraceRestrictItemType {
98 TRIT_NULL = 0, ///< Null-type, not in programs and not valid for execution, mainly used with TraceRestrictNullTypeSpecialValue for start/end
99 TRIT_PF_DENY = 1, ///< Pathfinder deny/allow
100 TRIT_PF_PENALTY = 2, ///< Add to pathfinder penalty
101 TRIT_RESERVE_THROUGH = 3, ///< Reserve through PBS signal
102 TRIT_LONG_RESERVE = 4, ///< Long reserve PBS signal
104 TRIT_COND_BEGIN = 8, ///< Start of conditional item types, note that this has the same value as TRIT_COND_ENDIF
105 TRIT_COND_ENDIF = 8, ///< This is an endif block or an else block
106 TRIT_COND_UNDEFINED = 9, ///< This condition has no type defined (evaluate as false)
107 TRIT_COND_TRAIN_LENGTH = 10, ///< Test train length
108 TRIT_COND_MAX_SPEED = 11, ///< Test train max speed
109 TRIT_COND_CURRENT_ORDER = 12, ///< Test train current order (station, waypoint or depot)
110 TRIT_COND_NEXT_ORDER = 13, ///< Test train next order (station, waypoint or depot)
111 TRIT_COND_LAST_STATION = 14, ///< Test train last visited station
112 TRIT_COND_CARGO = 15, ///< Test if train can carry cargo type
113 TRIT_COND_ENTRY_DIRECTION = 16, ///< Test which side of signal/signal tile is being entered from
114 TRIT_COND_PBS_ENTRY_SIGNAL = 17, ///< Test tile and PBS-state of previous signal
115 TRIT_COND_TRAIN_GROUP = 18, ///< Test train group membership
116 /* space up to 31 */
120 * TraceRestrictItem condition flags field, only valid with conditional types (IsTraceRestrictTypeConditional() is true)
122 enum TraceRestrictCondFlags {
123 TRCF_DEFAULT = 0, ///< indicates end if for type: TRIT_COND_ENDIF, if otherwise
124 TRCF_ELSE = 1 << 0, ///< indicates an else block for type: TRIT_COND_ENDIF, elif otherwise
125 TRCF_OR = 1 << 1, ///< indicates an orif block, not valid with type: TRIT_COND_ENDIF
126 /* 1 bit spare */
128 DECLARE_ENUM_AS_BIT_SET(TraceRestrictCondFlags)
131 * Enumeration of TraceRestrictItemvalue type field when type is TRIT_NULL
133 enum TraceRestrictNullTypeSpecialValue {
134 TRNTSV_NULL = 0, ///< null, what you get when you zero-init a TraceRestrictItemvalue
135 TRNTSV_START = 1, ///< start tag, generated within GUI
136 TRNTSV_END = 2, ///< end tag, generated within GUI
140 * Enumeration of TraceRestrictItemvalue type field when value type is TRVT_DIRECTION
142 enum TraceRestrictDirectionTypeSpecialValue {
143 TRNTSV_NE = 0, ///< DIAGDIR_NE: entering at NE tile edge
144 TRNTSV_SE = 1, ///< DIAGDIR_SE: entering at SE tile edge
145 TRNTSV_SW = 2, ///< DIAGDIR_SW: entering at SW tile edge
146 TRNTSV_NW = 3, ///< DIAGDIR_NW: entering at NW tile edge
147 TRDTSV_FRONT = 4, ///< entering at front face of signal
148 TRDTSV_BACK = 5, ///< entering at rear face of signal
152 * TraceRestrictItem condition operator field, only valid with conditional types (IsTraceRestrictTypeConditional() is true)
154 enum TraceRestrictCondOp {
155 TRCO_IS = 0, ///< equality test, or can carry test for cargo
156 TRCO_ISNOT = 1, ///< inequality test, or can't carry test for cargo
157 TRCO_LT = 2, ///< less than test
158 TRCO_LTE = 3, ///< less than or equal test
159 TRCO_GT = 4, ///< greater than test
160 TRCO_GTE = 5, ///< greater than or equal test
161 /* space up to 7 */
165 * TraceRestrictItem auxiliary type field, for order type conditionals
167 enum TraceRestrictOrderCondAuxField {
168 TROCAF_STATION = 0, ///< value field is a station StationID
169 TROCAF_WAYPOINT = 1, ///< value field is a waypoint StationID
170 TROCAF_DEPOT = 2, ///< value field is a depot DepotID
171 /* space up to 3 */
175 * TraceRestrictItem auxiliary type field, for order type conditionals
177 enum TraceRestrictPathfinderPenaltyAuxField {
178 TRPPAF_VALUE = 0, ///< value field is a the pathfinder penalty to use
179 TRPPAF_PRESET = 1, ///< value field is a pathfinder penalty prefix index: TraceRestrictPathfinderPenaltyPresetIndex
180 /* space up to 3 */
184 * TraceRestrictItem pathfinder penalty preset index
185 * This may not be shortened, only lengthened, as preset indexes are stored in save games
187 enum TraceRestrictPathfinderPenaltyPresetIndex {
188 TRPPPI_SMALL = 0, ///< small preset value
189 TRPPPI_MEDIUM = 1, ///< medium preset value
190 TRPPPI_LARGE = 2, ///< large preset value
191 TRPPPI_END, ///< end value
195 * Enumeration for TraceRestrictProgramResult::flags
197 enum TraceRestrictProgramResultFlags {
198 TRPRF_DENY = 1 << 0, ///< Pathfinder deny is set
199 TRPRF_RESERVE_THROUGH = 1 << 1, ///< Reserve through is set
200 TRPRF_LONG_RESERVE = 1 << 2, ///< Long reserve is set
202 DECLARE_ENUM_AS_BIT_SET(TraceRestrictProgramResultFlags)
205 * Enumeration for TraceRestrictProgram::actions_used_flags
207 enum TraceRestrictProgramActionsUsedFlags {
208 TRPAUF_PF = 1 << 0, ///< Pathfinder deny or penalty are present
209 TRPAUF_RESERVE_THROUGH = 1 << 1, ///< Reserve through action is present
210 TRPAUF_LONG_RESERVE = 1 << 2, ///< Long reserve action is present
212 DECLARE_ENUM_AS_BIT_SET(TraceRestrictProgramActionsUsedFlags)
215 * Execution input of a TraceRestrictProgram
217 struct TraceRestrictProgramInput {
218 typedef TileIndex PreviousSignalProc(const Train *v, const void *ptr);
220 TileIndex tile; ///< Tile of restrict signal, for direction testing
221 Trackdir trackdir; ///< Track direction on tile of restrict signal, for direction testing
222 PreviousSignalProc *previous_signal_callback; ///< Callback to retrieve tile and direction of previous signal, may be NULL
223 const void *previous_signal_ptr; ///< Opaque pointer suitable to be passed to previous_signal_callback
225 TraceRestrictProgramInput(TileIndex tile_, Trackdir trackdir_, PreviousSignalProc *previous_signal_callback_, const void *previous_signal_ptr_)
226 : tile(tile_), trackdir(trackdir_), previous_signal_callback(previous_signal_callback_), previous_signal_ptr(previous_signal_ptr_) { }
230 * Execution result of a TraceRestrictProgram
232 struct TraceRestrictProgramResult {
233 uint32 penalty; ///< Total additional pathfinder penalty
234 TraceRestrictProgramResultFlags flags; ///< Flags of other actions to take
236 TraceRestrictProgramResult()
237 : penalty(0), flags(static_cast<TraceRestrictProgramResultFlags>(0)) { }
241 * Program type, this stores the instruction list
242 * This is refcounted, see info at top of tracerestrict.cpp
244 struct TraceRestrictProgram : TraceRestrictProgramPool::PoolItem<&_tracerestrictprogram_pool> {
245 std::vector<TraceRestrictItem> items;
246 uint32 refcount;
247 TraceRestrictProgramActionsUsedFlags actions_used_flags;
249 TraceRestrictProgram()
250 : refcount(0), actions_used_flags(static_cast<TraceRestrictProgramActionsUsedFlags>(0)) { }
252 void Execute(const Train *v, const TraceRestrictProgramInput &input, TraceRestrictProgramResult &out) const;
255 * Increment ref count, only use when creating a mapping
257 void IncrementRefCount() { refcount++; }
259 void DecrementRefCount();
261 static CommandCost Validate(const std::vector<TraceRestrictItem> &items, TraceRestrictProgramActionsUsedFlags &actions_used_flags);
263 static size_t InstructionOffsetToArrayOffset(const std::vector<TraceRestrictItem> &items, size_t offset);
265 static size_t ArrayOffsetToInstructionOffset(const std::vector<TraceRestrictItem> &items, size_t offset);
267 /** Call InstructionOffsetToArrayOffset on current program instruction list */
268 size_t InstructionOffsetToArrayOffset(size_t offset) const
270 return TraceRestrictProgram::InstructionOffsetToArrayOffset(this->items, offset);
273 /** Call ArrayOffsetToInstructionOffset on current program instruction list */
274 size_t ArrayOffsetToInstructionOffset(size_t offset) const
276 return TraceRestrictProgram::ArrayOffsetToInstructionOffset(this->items, offset);
279 /** Get number of instructions in @p items */
280 static size_t GetInstructionCount(const std::vector<TraceRestrictItem> &items)
282 return ArrayOffsetToInstructionOffset(items, items.size());
285 /** Call GetInstructionCount on current program instruction list */
286 size_t GetInstructionCount() const
288 return TraceRestrictProgram::GetInstructionCount(this->items);
291 /** Get an iterator to the instruction at a given @p instruction_offset in @p items */
292 static std::vector<TraceRestrictItem>::iterator InstructionAt(std::vector<TraceRestrictItem> &items, size_t instruction_offset)
294 return items.begin() + TraceRestrictProgram::InstructionOffsetToArrayOffset(items, instruction_offset);
297 /** Get a const_iterator to the instruction at a given @p instruction_offset in @p items */
298 static std::vector<TraceRestrictItem>::const_iterator InstructionAt(const std::vector<TraceRestrictItem> &items, size_t instruction_offset)
300 return items.begin() + TraceRestrictProgram::InstructionOffsetToArrayOffset(items, instruction_offset);
303 /** Call validation function on current program instruction list and set actions_used_flags */
304 CommandCost Validate()
306 return TraceRestrictProgram::Validate(items, actions_used_flags);
310 /** Get TraceRestrictItem type field */
311 static inline TraceRestrictItemType GetTraceRestrictType(TraceRestrictItem item)
313 return static_cast<TraceRestrictItemType>(GB(item, TRIFA_TYPE_OFFSET, TRIFA_TYPE_COUNT));
316 /** Get TraceRestrictItem condition flags field */
317 static inline TraceRestrictCondFlags GetTraceRestrictCondFlags(TraceRestrictItem item)
319 return static_cast<TraceRestrictCondFlags>(GB(item, TRIFA_COND_FLAGS_OFFSET, TRIFA_COND_FLAGS_COUNT));
322 /** Get TraceRestrictItem condition operator field */
323 static inline TraceRestrictCondOp GetTraceRestrictCondOp(TraceRestrictItem item)
325 return static_cast<TraceRestrictCondOp>(GB(item, TRIFA_COND_OP_OFFSET, TRIFA_COND_OP_COUNT));
328 /** Get TraceRestrictItem auxiliary field */
329 static inline uint8 GetTraceRestrictAuxField(TraceRestrictItem item)
331 return GB(item, TRIFA_AUX_FIELD_OFFSET, TRIFA_AUX_FIELD_COUNT);
334 /** Get TraceRestrictItem value field */
335 static inline uint16 GetTraceRestrictValue(TraceRestrictItem item)
337 return static_cast<uint16>(GB(item, TRIFA_VALUE_OFFSET, TRIFA_VALUE_COUNT));
340 /** Set TraceRestrictItem type field */
341 static inline void SetTraceRestrictType(TraceRestrictItem &item, TraceRestrictItemType type)
343 SB(item, TRIFA_TYPE_OFFSET, TRIFA_TYPE_COUNT, type);
346 /** Set TraceRestrictItem condition operator field */
347 static inline void SetTraceRestrictCondOp(TraceRestrictItem &item, TraceRestrictCondOp condop)
349 SB(item, TRIFA_COND_OP_OFFSET, TRIFA_COND_OP_COUNT, condop);
352 /** Set TraceRestrictItem condition flags field */
353 static inline void SetTraceRestrictCondFlags(TraceRestrictItem &item, TraceRestrictCondFlags condflags)
355 SB(item, TRIFA_COND_FLAGS_OFFSET, TRIFA_COND_FLAGS_COUNT, condflags);
358 /** Set TraceRestrictItem auxiliary field */
359 static inline void SetTraceRestrictAuxField(TraceRestrictItem &item, uint8 data)
361 SB(item, TRIFA_AUX_FIELD_OFFSET, TRIFA_AUX_FIELD_COUNT, data);
364 /** Set TraceRestrictItem value field */
365 static inline void SetTraceRestrictValue(TraceRestrictItem &item, uint16 value)
367 SB(item, TRIFA_VALUE_OFFSET, TRIFA_VALUE_COUNT, value);
370 /** Is TraceRestrictItemType a conditional type? */
371 static inline bool IsTraceRestrictTypeConditional(TraceRestrictItemType type)
373 return type >= TRIT_COND_BEGIN;
376 /** Is TraceRestrictItem type field a conditional type? */
377 static inline bool IsTraceRestrictConditional(TraceRestrictItem item)
379 return IsTraceRestrictTypeConditional(GetTraceRestrictType(item));
382 /** Is TraceRestrictItem a double-item type? */
383 static inline bool IsTraceRestrictDoubleItem(TraceRestrictItem item)
385 return GetTraceRestrictType(item) == TRIT_COND_PBS_ENTRY_SIGNAL;
389 * Categorisation of what is allowed in the TraceRestrictItem condition op field
390 * see TraceRestrictTypePropertySet
392 enum TraceRestrictConditionOpType {
393 TRCOT_NONE = 0, ///< takes no condition op
394 TRCOT_BINARY = 1, ///< takes "is" and "is not" condition ops
395 TRCOT_ALL = 2, ///< takes all condition ops (i.e. all relational ops)
399 * Categorisation of what is in the TraceRestrictItem value field
400 * see TraceRestrictTypePropertySet
402 enum TraceRestrictValueType {
403 TRVT_NONE = 0, ///< value field not used (set to 0)
404 TRVT_SPECIAL = 1, ///< special handling of value field
405 TRVT_INT = 2, ///< takes an unsigned integer value
406 TRVT_DENY = 3, ///< takes a value 0 = deny, 1 = allow (cancel previous deny)
407 TRVT_SPEED = 4, ///< takes an integer speed value
408 TRVT_ORDER = 5, ///< takes an order target ID, as per the auxiliary field as type: TraceRestrictOrderCondAuxField
409 TRVT_CARGO_ID = 6, ///< takes a CargoID
410 TRVT_DIRECTION = 7, ///< takes a TraceRestrictDirectionTypeSpecialValue
411 TRVT_TILE_INDEX = 8, ///< takes a TileIndex in the next item slot
412 TRVT_PF_PENALTY = 9, ///< takes a pathfinder penalty value or preset index, as per the auxiliary field as type: TraceRestrictPathfinderPenaltyAuxField
413 TRVT_RESERVE_THROUGH = 10,///< takes a value 0 = reserve through, 1 = cancel previous reserve through
414 TRVT_LONG_RESERVE = 11,///< takes a value 0 = long reserve, 1 = cancel previous long reserve
415 TRVT_GROUP_INDEX = 12,///< takes a GroupID
419 * Describes formats of TraceRestrictItem condition op and value fields
421 struct TraceRestrictTypePropertySet {
422 TraceRestrictConditionOpType cond_type;
423 TraceRestrictValueType value_type;
426 void SetTraceRestrictValueDefault(TraceRestrictItem &item, TraceRestrictValueType value_type);
427 void SetTraceRestrictTypeAndNormalise(TraceRestrictItem &item, TraceRestrictItemType type);
430 * Get TraceRestrictTypePropertySet for a given instruction, only looks at value field
432 static inline TraceRestrictTypePropertySet GetTraceRestrictTypeProperties(TraceRestrictItem item)
434 TraceRestrictTypePropertySet out;
436 if (GetTraceRestrictType(item) == TRIT_NULL) {
437 out.cond_type = TRCOT_NONE;
438 out.value_type = TRVT_SPECIAL;
439 } else if (GetTraceRestrictType(item) == TRIT_COND_ENDIF ||
440 GetTraceRestrictType(item) == TRIT_COND_UNDEFINED) {
441 out.cond_type = TRCOT_NONE;
442 out.value_type = TRVT_NONE;
443 } else if (IsTraceRestrictConditional(item)) {
444 out.cond_type = TRCOT_ALL;
446 switch (GetTraceRestrictType(item)) {
447 case TRIT_COND_TRAIN_LENGTH:
448 out.value_type = TRVT_INT;
449 break;
451 case TRIT_COND_MAX_SPEED:
452 out.value_type = TRVT_SPEED;
453 break;
455 case TRIT_COND_CURRENT_ORDER:
456 case TRIT_COND_NEXT_ORDER:
457 case TRIT_COND_LAST_STATION:
458 out.value_type = TRVT_ORDER;
459 out.cond_type = TRCOT_BINARY;
460 break;
462 case TRIT_COND_CARGO:
463 out.value_type = TRVT_CARGO_ID;
464 out.cond_type = TRCOT_BINARY;
465 break;
467 case TRIT_COND_ENTRY_DIRECTION:
468 out.value_type = TRVT_DIRECTION;
469 out.cond_type = TRCOT_BINARY;
470 break;
472 case TRIT_COND_PBS_ENTRY_SIGNAL:
473 out.value_type = TRVT_TILE_INDEX;
474 out.cond_type = TRCOT_BINARY;
475 break;
477 case TRIT_COND_TRAIN_GROUP:
478 out.value_type = TRVT_GROUP_INDEX;
479 out.cond_type = TRCOT_BINARY;
480 break;
482 default:
483 NOT_REACHED();
484 break;
486 } else {
487 out.cond_type = TRCOT_NONE;
488 if (GetTraceRestrictType(item) == TRIT_PF_PENALTY) {
489 out.value_type = TRVT_PF_PENALTY;
490 } else if (GetTraceRestrictType(item) == TRIT_PF_DENY) {
491 out.value_type = TRVT_DENY;
492 } else if (GetTraceRestrictType(item) == TRIT_RESERVE_THROUGH) {
493 out.value_type = TRVT_RESERVE_THROUGH;
494 } else if (GetTraceRestrictType(item) == TRIT_LONG_RESERVE) {
495 out.value_type = TRVT_LONG_RESERVE;
496 } else {
497 out.value_type = TRVT_NONE;
501 return out;
504 /** Get mapping ref ID from tile and track */
505 static inline TraceRestrictRefId MakeTraceRestrictRefId(TileIndex t, Track track)
507 return (t << 3) | track;
510 /** Get tile from mapping ref ID */
511 static inline TileIndex GetTraceRestrictRefIdTileIndex(TraceRestrictRefId ref)
513 return static_cast<TileIndex>(ref >> 3);
516 /** Get track from mapping ref ID */
517 static inline Track GetTraceRestrictRefIdTrack(TraceRestrictRefId ref)
519 return static_cast<Track>(ref & 7);
522 void TraceRestrictCreateProgramMapping(TraceRestrictRefId ref, TraceRestrictProgram *prog);
523 bool TraceRestrictRemoveProgramMapping(TraceRestrictRefId ref);
525 TraceRestrictProgram *GetTraceRestrictProgram(TraceRestrictRefId ref, bool create_new);
527 void TraceRestrictNotifySignalRemoval(TileIndex tile, Track track);
530 * Gets the existing signal program for the tile identified by @p t and @p track, or NULL
532 static inline const TraceRestrictProgram *GetExistingTraceRestrictProgram(TileIndex t, Track track)
534 if (IsRestrictedSignal(t)) {
535 return GetTraceRestrictProgram(MakeTraceRestrictRefId(t, track), false);
536 } else {
537 return NULL;
542 * Enumeration for command action type field, indicates what command to do
544 enum TraceRestrictDoCommandType {
545 TRDCT_INSERT_ITEM, ///< insert new instruction before offset field as given value
546 TRDCT_MODIFY_ITEM, ///< modify instruction at offset field to given value
547 TRDCT_MODIFY_DUAL_ITEM, ///< modify second item of dual-part instruction at offset field to given value
548 TRDCT_REMOVE_ITEM, ///< remove instruction at offset field
550 TRDCT_PROG_COPY, ///< copy program operation. Do not re-order this with respect to other values
551 TRDCT_PROG_SHARE, ///< share program operation
552 TRDCT_PROG_UNSHARE, ///< unshare program (copy as a new program)
553 TRDCT_PROG_RESET, ///< reset program state of signal
556 void TraceRestrictDoCommandP(TileIndex tile, Track track, TraceRestrictDoCommandType type, uint32 offset, uint32 value, StringID error_msg);
558 void TraceRestrictProgMgmtWithSourceDoCommandP(TileIndex tile, Track track, TraceRestrictDoCommandType type,
559 TileIndex source_tile, Track source_track, StringID error_msg);
562 * Short-hand to call TraceRestrictProgMgmtWithSourceDoCommandP with 0 for source tile/track
564 inline void TraceRestrictProgMgmtDoCommandP(TileIndex tile, Track track, TraceRestrictDoCommandType type, StringID error_msg)
566 TraceRestrictProgMgmtWithSourceDoCommandP(tile, track, type, static_cast<TileIndex>(0), static_cast<Track>(0), error_msg);
569 CommandCost CmdProgramSignalTraceRestrict(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text);
570 CommandCost CmdProgramSignalTraceRestrictProgMgmt(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text);
572 void ShowTraceRestrictProgramWindow(TileIndex tile, Track track);
574 void TraceRestrictRemoveDestinationID(TraceRestrictOrderCondAuxField type, uint16 index);
575 void TraceRestrictRemoveGroupID(GroupID index);
577 #endif /* TRACERESTRICT_H */