Data Structures | Functions | Variables

script_rail.cpp File Reference

Implementation of ScriptRail. More...

#include "../../stdafx.h"
#include "script_rail.hpp"
#include "script_map.hpp"
#include "script_station.hpp"
#include "script_industrytype.hpp"
#include "script_cargo.hpp"
#include "../../debug.h"
#include "../../station_base.h"
#include "../../company_func.h"
#include "../../newgrf.h"
#include "../../newgrf_generic.h"
#include "../../newgrf_station.h"
#include "../../strings_func.h"

Go to the source code of this file.

Data Structures

struct  ScriptRailSignalData
 Contains information about the trackdir that belongs to a track when entering from a specific direction. More...

Functions

static uint32 SimulateDrag (TileIndex from, TileIndex tile, TileIndex *to)
 Prepare the second parameter for CmdBuildRailroadTrack and CmdRemoveRailroadTrack.
static bool IsValidSignalType (int signal_type)
 Check if signal_type is a valid SignalType.

Variables

static const int NUM_TRACK_DIRECTIONS = 3
 The number of directions you can go when entering a tile.
static const ScriptRailSignalData _possible_trackdirs [5][NUM_TRACK_DIRECTIONS]
 List information about the trackdir and number of needed cycles for building signals when entering a track from a specific direction.

Detailed Description

Implementation of ScriptRail.

Definition in file script_rail.cpp.


Function Documentation

static uint32 SimulateDrag ( TileIndex  from,
TileIndex  tile,
TileIndex to 
) [static]

Prepare the second parameter for CmdBuildRailroadTrack and CmdRemoveRailroadTrack.

The direction depends on all three tiles. Sometimes the third tile needs to be adjusted.

Definition at line 280 of file script_rail.cpp.

References abs(), Clamp(), ScriptRail::GetCurrentRailType(), MapSizeX(), TileX(), TileY(), TRACK_LEFT, TRACK_LOWER, TRACK_RIGHT, TRACK_UPPER, TRACK_X, and TRACK_Y.

Referenced by ScriptRail::BuildRail(), and ScriptRail::RemoveRail().


Variable Documentation

Initial value:
 {
  {{TRACK_UPPER,   TRACKDIR_UPPER_E, 0}, {TRACK_Y,       TRACKDIR_Y_SE,    0}, {TRACK_LEFT,    TRACKDIR_LEFT_S,  1}},
  {{TRACK_RIGHT,   TRACKDIR_RIGHT_S, 1}, {TRACK_X,       TRACKDIR_X_SW,    1}, {TRACK_UPPER,   TRACKDIR_UPPER_W, 1}},
  {{INVALID_TRACK, INVALID_TRACKDIR, 0}, {INVALID_TRACK, INVALID_TRACKDIR, 0}, {INVALID_TRACK, INVALID_TRACKDIR, 0}},
  {{TRACK_LOWER,   TRACKDIR_LOWER_E, 0}, {TRACK_X,       TRACKDIR_X_NE,    0}, {TRACK_LEFT,    TRACKDIR_LEFT_N,  0}},
  {{TRACK_RIGHT,   TRACKDIR_RIGHT_N, 0}, {TRACK_Y,       TRACKDIR_Y_NW,    1}, {TRACK_LOWER,   TRACKDIR_LOWER_W, 1}}
}

List information about the trackdir and number of needed cycles for building signals when entering a track from a specific direction.

The first index is the difference between the TileIndex of the previous and current tile, where (-)MapSizeX is replaced with -2 / 2 and 2 it added.

Definition at line 390 of file script_rail.cpp.