Data Structures | Functions | Variables

# programmable_signals.cpp File Reference

Programmable Signals. More...

`#include "stdafx.h"`
`#include "programmable_signals.h"`
`#include "debug.h"`
`#include "command_func.h"`
`#include "table/strings.h"`
`#include "window_func.h"`
`#include "company_func.h"`
`#include "cmd_helper.h"`
`#include <assert.h>`

Go to the source code of this file.

## Data Structures
struct | SignalVM
## Functions
static SignalProgram * | GetExistingSignalProgram (SignalReference ref)
SignalProgram * | GetSignalProgram (SignalReference ref)
uint16 | GetSignalSpeed (SignalReference ref)
void | FreeSignalProgram (SignalReference ref)
void | FreeSignalSpeed (SignalReference ref)
void | FreeSignalSpeeds ()
void | FreeSignalPrograms ()
SignalState | RunSignalProgram (SignalReference ref, uint num_exits, uint num_green)
void | RemoveProgramDependencies (SignalReference by, SignalReference on)
CommandCost | CmdInsertSignalInstruction (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Insert a signal instruction into the signal program.
CommandCost | CmdModifySignalInstruction (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Modify a singal instruction.
CommandCost | CmdRemoveSignalInstruction (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Remove an instruction from a signal program.
CommandCost | CmdSetSignalSpeedLimit (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Set a speed-signal's value.
## Variables
ProgramList | _signal_programs
SpeedLimits | _speedlimits

## Detailed Description

Programmable Signals.

Definition in file programmable_signals.cpp.

## Function Documentation

CommandCost CmdInsertSignalInstruction | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Insert a signal instruction into the signal program.

Parameters:

  | tile | The Tile on which to perform the operation.
  | p1 | Flags and information. Bits 0-2 Which track the signal sits on. Bits 3-18 ID of instruction to insert before. Bits 19-26 Which opcode to create. Bits 27-31 Reserved.
  | p2 | Depends upon instruction. PSO_SET_SIGNAL: Colour to set the signal to.
  | text | unused.

Definition at line 489 of file programmable_signals.cpp.

References _current_company, AddTrackToSignalBuffer(), CMD_ERROR, GB(), GetTileOwner(), HasTrack(), InvalidateWindowData(), IsPlainRailTile(), IsTileOwner(), IsValidTrack(), SmallVector< T, S >::Length(), PSO_FIRST, PSO_IF, PSO_IF_ELSE, PSO_IF_ENDIF, PSO_LAST, PSO_SET_SIGNAL, return_cmd_error, and UpdateSignalsInBuffer().

CommandCost CmdModifySignalInstruction | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Modify a singal instruction.

Parameters:

  | tile | The Tile on which to perform the operation.
  | p1 | Flags and information. Bits 0-2 Which track the signal sits on. Bits 3-18 ID of instruction to insert before.
  | p2 | Depends upon instruction. PSO_SET_SIGNAL: Colour to set the signal to. PSO_IF: Bit 0 If 0, set the condidion code: Bit 1-8: Conditon code to change to. Otherwise, if SignalVariableCondition: Bits 1-2: Which field to change (ConditionField). Bits 3-31: Value to set field to. Otherwise, if SignalStateCondition: Bits 1-4: Trackdir on which signal is located. Bits 5-31: Tile on which signal is located.
  | text | unused.

Definition at line 569 of file programmable_signals.cpp.

References _current_company, AddTrackToSignalBuffer(), CMD_ERROR, SignalIf::condition, GB(), GetTileOwner(), HasSignalOnTrackdir(), HasTrack(), INVALID_TILE, INVALID_TRACKDIR, InvalidateWindowData(), IsPlainRailTile(), IsTileOwner(), IsValidTile(), IsValidTrack(), IsValidTrackdir(), SmallVector< T, S >::Length(), PSC_ALWAYS, PSC_NEVER, PSC_NUM_GREEN, PSC_NUM_RED, PSC_SIGNAL_STATE, PSO_FIRST, PSO_IF, PSO_IF_ELSE, PSO_IF_ENDIF, PSO_LAST, PSO_SET_SIGNAL, return_cmd_error, SCF_COMPARATOR, SCF_VALUE, SignalIf::SetCondition(), and UpdateSignalsInBuffer().

CommandCost CmdRemoveSignalInstruction | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Remove an instruction from a signal program.

Parameters:

  | tile | The Tile on which to perform the operation.
  | p1 | Flags and information. Bits 0-2 Which track the signal sits on. Bits 3-18 ID of instruction to insert before.
  | p2 | unused.
  | text | unused.

Definition at line 699 of file programmable_signals.cpp.

References _current_company, AddTrackToSignalBuffer(), CMD_ERROR, GB(), GetTileOwner(), HasTrack(), InvalidateWindowData(), IsPlainRailTile(), IsTileOwner(), IsValidTrack(), SmallVector< T, S >::Length(), PSO_FIRST, PSO_IF, PSO_IF_ELSE, PSO_IF_ENDIF, PSO_LAST, PSO_SET_SIGNAL, return_cmd_error, and UpdateSignalsInBuffer().

CommandCost CmdSetSignalSpeedLimit | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Set a speed-signal's value.

Parameters:

  | tile | The Tile on which to perform the operation
  | p1 | Flags and information Bits 0-2 Which track the signal sits on Bits 3-18 unused
  | p2 | the value to set
  | text | unused

Definition at line 755 of file programmable_signals.cpp.

References _current_company, AddTrackToSignalBuffer(), CMD_ERROR, GetTileOwner(), HasTrack(), InvalidateWindowData(), IsPlainRailTile(), IsTileOwner(), IsValidTrack(), return_cmd_error, and UpdateSignalsInBuffer().