src/rail.h
author rubidium
Wed, 03 Dec 2008 00:19:06 +0000
changeset 10400 03e9c6b00a00
parent 10225 eb61dd8101c1
permissions -rw-r--r--
(svn r14651) -Fix [FS#2437] (r14636): extmidi wasn't compiled/linked anymore.
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2049
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2049
diff changeset
     2
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 9034
diff changeset
     3
/** @file rail.h Rail specific functions. */
2232
2a0d0328ebbe (svn r2752) -Doc: Added some doxygen stuff to rail.h. I'm gonna mess around with this file and wanted to get rid of this first
celestar
parents: 2186
diff changeset
     4
1942
c5d5cf5b0263 (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
     5
#ifndef RAIL_H
c5d5cf5b0263 (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
     6
#define RAIL_H
c5d5cf5b0263 (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
     7
8101
d5357bde8cab (svn r11662) -Codechange: move some rail types/related functions around.
rubidium
parents: 8100
diff changeset
     8
#include "rail_type.h"
d5357bde8cab (svn r11662) -Codechange: move some rail types/related functions around.
rubidium
parents: 8100
diff changeset
     9
#include "track_type.h"
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8116
diff changeset
    10
#include "vehicle_type.h"
8123
ce31d2843a95 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8121
diff changeset
    11
#include "gfx_type.h"
8113
31b7784db761 (svn r11674) -Codechange: refactor some functions out of macros.h into more logical locations.
rubidium
parents: 8108
diff changeset
    12
#include "core/bitmath_func.hpp"
8123
ce31d2843a95 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8121
diff changeset
    13
#include "economy_func.h"
9154
2c042b567165 (svn r13016) -Codechange: unify the detection if rail catenary should be drawn
smatz
parents: 9111
diff changeset
    14
#include "slope_type.h"
1942
c5d5cf5b0263 (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
    15
8860
a30cd0629e2b (svn r12624) -Codechange: Make drawing of catenary an attribute of rail types, instead of deciding by the rail type directly.
peter1138
parents: 8732
diff changeset
    16
enum RailTypeFlag {
a30cd0629e2b (svn r12624) -Codechange: Make drawing of catenary an attribute of rail types, instead of deciding by the rail type directly.
peter1138
parents: 8732
diff changeset
    17
	RTF_CATENARY = 0,  ///< Set if the rail type should have catenary drawn
a30cd0629e2b (svn r12624) -Codechange: Make drawing of catenary an attribute of rail types, instead of deciding by the rail type directly.
peter1138
parents: 8732
diff changeset
    18
};
a30cd0629e2b (svn r12624) -Codechange: Make drawing of catenary an attribute of rail types, instead of deciding by the rail type directly.
peter1138
parents: 8732
diff changeset
    19
a30cd0629e2b (svn r12624) -Codechange: Make drawing of catenary an attribute of rail types, instead of deciding by the rail type directly.
peter1138
parents: 8732
diff changeset
    20
enum RailTypeFlags {
a30cd0629e2b (svn r12624) -Codechange: Make drawing of catenary an attribute of rail types, instead of deciding by the rail type directly.
peter1138
parents: 8732
diff changeset
    21
	RTFB_NONE     = 0,
a30cd0629e2b (svn r12624) -Codechange: Make drawing of catenary an attribute of rail types, instead of deciding by the rail type directly.
peter1138
parents: 8732
diff changeset
    22
	RTFB_CATENARY = 1 << RTF_CATENARY,
a30cd0629e2b (svn r12624) -Codechange: Make drawing of catenary an attribute of rail types, instead of deciding by the rail type directly.
peter1138
parents: 8732
diff changeset
    23
};
a30cd0629e2b (svn r12624) -Codechange: Make drawing of catenary an attribute of rail types, instead of deciding by the rail type directly.
peter1138
parents: 8732
diff changeset
    24
DECLARE_ENUM_AS_BIT_SET(RailTypeFlags);
a30cd0629e2b (svn r12624) -Codechange: Make drawing of catenary an attribute of rail types, instead of deciding by the rail type directly.
peter1138
parents: 8732
diff changeset
    25
2233
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
    26
/** This struct contains all the info that is needed to draw and construct tracks.
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
    27
 */
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6162
diff changeset
    28
struct RailtypeInfo {
2274
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
    29
	/** Struct containing the main sprites. @note not all sprites are listed, but only
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
    30
	 *  the ones used directly in the code */
2233
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
    31
	struct {
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
    32
		SpriteID track_y;      ///< single piece of rail in Y direction, with ground
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
    33
		SpriteID track_ns;     ///< two pieces of rail in North and South corner (East-West direction)
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
    34
		SpriteID ground;       ///< ground sprite for a 3-way switch
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
    35
		SpriteID single_y;     ///< single piece of rail in Y direction, without ground
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
    36
		SpriteID single_x;     ///< single piece of rail in X direction
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
    37
		SpriteID single_n;     ///< single piece of rail in the northern corner
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
    38
		SpriteID single_s;     ///< single piece of rail in the southern corner
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
    39
		SpriteID single_e;     ///< single piece of rail in the eastern corner
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
    40
		SpriteID single_w;     ///< single piece of rail in the western corner
9493
030cfc495f31 (svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents: 9154
diff changeset
    41
		SpriteID single_sloped;///< single piecs of rail for slopes
2511
3eb6cb6b750d (svn r3037) Don't deduce the sprites for tunnels and level crossings from magic numbers, but fetch them from the central rail info array. This is a preparation step for electrified rails
tron
parents: 2472
diff changeset
    42
		SpriteID crossing;     ///< level crossing, rail in X direction
3eb6cb6b750d (svn r3037) Don't deduce the sprites for tunnels and level crossings from magic numbers, but fetch them from the central rail info array. This is a preparation step for electrified rails
tron
parents: 2472
diff changeset
    43
		SpriteID tunnel;       ///< tunnel sprites base
2233
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
    44
	} base_sprites;
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
    45
2274
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
    46
	/** struct containing the sprites for the rail GUI. @note only sprites referred to
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
    47
	 * directly in the code are listed */
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
    48
	struct {
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
    49
		SpriteID build_ns_rail;      ///< button for building single rail in N-S direction
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
    50
		SpriteID build_x_rail;       ///< button for building single rail in X direction
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
    51
		SpriteID build_ew_rail;      ///< button for building single rail in E-W direction
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
    52
		SpriteID build_y_rail;       ///< button for building single rail in Y direction
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
    53
		SpriteID auto_rail;          ///< button for the autorail construction
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
    54
		SpriteID build_depot;        ///< button for building depots
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
    55
		SpriteID build_tunnel;       ///< button for building a tunnel
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
    56
		SpriteID convert_rail;       ///< button for converting rail
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
    57
	} gui_sprites;
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
    58
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
    59
	struct {
7396
6b9f010b31ea (svn r10765) -Documentation [FS#1100]: of rail.h. Based on a patch by Progman.
rubidium
parents: 7335
diff changeset
    60
		CursorID rail_ns;    ///< Cursor for building rail in N-S direction
6b9f010b31ea (svn r10765) -Documentation [FS#1100]: of rail.h. Based on a patch by Progman.
rubidium
parents: 7335
diff changeset
    61
		CursorID rail_swne;  ///< Cursor for building rail in X direction
6b9f010b31ea (svn r10765) -Documentation [FS#1100]: of rail.h. Based on a patch by Progman.
rubidium
parents: 7335
diff changeset
    62
		CursorID rail_ew;    ///< Cursor for building rail in E-W direction
6b9f010b31ea (svn r10765) -Documentation [FS#1100]: of rail.h. Based on a patch by Progman.
rubidium
parents: 7335
diff changeset
    63
		CursorID rail_nwse;  ///< Cursor for building rail in Y direction
6b9f010b31ea (svn r10765) -Documentation [FS#1100]: of rail.h. Based on a patch by Progman.
rubidium
parents: 7335
diff changeset
    64
		CursorID autorail;   ///< Cursor for autorail tool
6b9f010b31ea (svn r10765) -Documentation [FS#1100]: of rail.h. Based on a patch by Progman.
rubidium
parents: 7335
diff changeset
    65
		CursorID depot;      ///< Cursor for building a depot
6b9f010b31ea (svn r10765) -Documentation [FS#1100]: of rail.h. Based on a patch by Progman.
rubidium
parents: 7335
diff changeset
    66
		CursorID tunnel;     ///< Cursor for building a tunnel
6b9f010b31ea (svn r10765) -Documentation [FS#1100]: of rail.h. Based on a patch by Progman.
rubidium
parents: 7335
diff changeset
    67
		CursorID convert;    ///< Cursor for converting track
2514
859692ffa65a (svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents: 2511
diff changeset
    68
	} cursor;
859692ffa65a (svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents: 2511
diff changeset
    69
859692ffa65a (svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents: 2511
diff changeset
    70
	struct {
2274
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
    71
		StringID toolbar_caption;
10000
57463dc267a0 (svn r14157) -Codechange: Add and use string properties for rail types instead of relying on consecutive string IDs.
peter1138
parents: 9775
diff changeset
    72
		StringID menu_text;
57463dc267a0 (svn r14157) -Codechange: Add and use string properties for rail types instead of relying on consecutive string IDs.
peter1138
parents: 9775
diff changeset
    73
		StringID build_caption;
57463dc267a0 (svn r14157) -Codechange: Add and use string properties for rail types instead of relying on consecutive string IDs.
peter1138
parents: 9775
diff changeset
    74
		StringID replace_text;
57463dc267a0 (svn r14157) -Codechange: Add and use string properties for rail types instead of relying on consecutive string IDs.
peter1138
parents: 9775
diff changeset
    75
		StringID new_loco;
2274
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
    76
	} strings;
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
    77
2233
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
    78
	/** sprite number difference between a piece of track on a snowy ground and the corresponding one on normal ground */
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
    79
	SpriteID snow_offset;
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
    80
3355
e414a0b104a6 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
    81
	/** bitmask to the OTHER railtypes on which an engine of THIS railtype generates power */
8236
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
    82
	RailTypes powered_railtypes;
3355
e414a0b104a6 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
    83
e414a0b104a6 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
    84
	/** bitmask to the OTHER railtypes on which an engine of THIS railtype can physically travel */
8236
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
    85
	RailTypes compatible_railtypes;
2254
99de94953104 (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
    86
99de94953104 (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
    87
	/**
99de94953104 (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
    88
	 * Offset between the current railtype and normal rail. This means that:<p>
99de94953104 (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
    89
	 * 1) All the sprites in a railset MUST be in the same order. This order
99de94953104 (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
    90
	 *    is determined by normal rail. Check sprites 1005 and following for this order<p>
99de94953104 (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
    91
	 * 2) The position where the railtype is loaded must always be the same, otherwise
6420
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6248
diff changeset
    92
	 *    the offset will fail.
2254
99de94953104 (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
    93
	 * @note: Something more flexible might be desirable in the future.
99de94953104 (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
    94
	 */
99de94953104 (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
    95
	SpriteID total_offset;
2536
634914d741b4 (svn r3065) -Codechange/Add: Modified the bridge drawing code so that the basic offset is read from the RailTypeInfo struct. This is (hopefully) the last DrawTile change on the way to electrified railways. While being at it, de-mystified the function a bit and added some asserts.
celestar
parents: 2520
diff changeset
    96
634914d741b4 (svn r3065) -Codechange/Add: Modified the bridge drawing code so that the basic offset is read from the RailTypeInfo struct. This is (hopefully) the last DrawTile change on the way to electrified railways. While being at it, de-mystified the function a bit and added some asserts.
celestar
parents: 2520
diff changeset
    97
	/**
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
    98
	 * Bridge offset
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
    99
	 */
2536
634914d741b4 (svn r3065) -Codechange/Add: Modified the bridge drawing code so that the basic offset is read from the RailTypeInfo struct. This is (hopefully) the last DrawTile change on the way to electrified railways. While being at it, de-mystified the function a bit and added some asserts.
celestar
parents: 2520
diff changeset
   100
	SpriteID bridge_offset;
3503
44f50afb0a75 (svn r4354) [Elrail][NewGRF] Codechange: Drawing of custom waypoints with custom ground sprites used the index of the rail type as an offset. With the introduction of elrails this offset is incorrect, so instead there is now a lookup table within the RailTypeInfo struct to explicitly list the offset.
peter1138
parents: 3500
diff changeset
   101
44f50afb0a75 (svn r4354) [Elrail][NewGRF] Codechange: Drawing of custom waypoints with custom ground sprites used the index of the rail type as an offset. With the introduction of elrails this offset is incorrect, so instead there is now a lookup table within the RailTypeInfo struct to explicitly list the offset.
peter1138
parents: 3500
diff changeset
   102
	/**
44f50afb0a75 (svn r4354) [Elrail][NewGRF] Codechange: Drawing of custom waypoints with custom ground sprites used the index of the rail type as an offset. With the introduction of elrails this offset is incorrect, so instead there is now a lookup table within the RailTypeInfo struct to explicitly list the offset.
peter1138
parents: 3500
diff changeset
   103
	 * Offset to add to ground sprite when drawing custom waypoints / stations
44f50afb0a75 (svn r4354) [Elrail][NewGRF] Codechange: Drawing of custom waypoints with custom ground sprites used the index of the rail type as an offset. With the introduction of elrails this offset is incorrect, so instead there is now a lookup table within the RailTypeInfo struct to explicitly list the offset.
peter1138
parents: 3500
diff changeset
   104
	 */
44f50afb0a75 (svn r4354) [Elrail][NewGRF] Codechange: Drawing of custom waypoints with custom ground sprites used the index of the rail type as an offset. With the introduction of elrails this offset is incorrect, so instead there is now a lookup table within the RailTypeInfo struct to explicitly list the offset.
peter1138
parents: 3500
diff changeset
   105
	byte custom_ground_offset;
8169
31d57d9de945 (svn r11732) -Fix (r4150): elrail merge gave elrail, monorail & maglev unintended speed bonuses for curves, as the bonus was based on the railtype index. The bonus is now specified by a property of the railtype.
peter1138
parents: 8138
diff changeset
   106
31d57d9de945 (svn r11732) -Fix (r4150): elrail merge gave elrail, monorail & maglev unintended speed bonuses for curves, as the bonus was based on the railtype index. The bonus is now specified by a property of the railtype.
peter1138
parents: 8138
diff changeset
   107
	/**
31d57d9de945 (svn r11732) -Fix (r4150): elrail merge gave elrail, monorail & maglev unintended speed bonuses for curves, as the bonus was based on the railtype index. The bonus is now specified by a property of the railtype.
peter1138
parents: 8138
diff changeset
   108
	 * Multiplier for curve maximum speed advantage
31d57d9de945 (svn r11732) -Fix (r4150): elrail merge gave elrail, monorail & maglev unintended speed bonuses for curves, as the bonus was based on the railtype index. The bonus is now specified by a property of the railtype.
peter1138
parents: 8138
diff changeset
   109
	 */
31d57d9de945 (svn r11732) -Fix (r4150): elrail merge gave elrail, monorail & maglev unintended speed bonuses for curves, as the bonus was based on the railtype index. The bonus is now specified by a property of the railtype.
peter1138
parents: 8138
diff changeset
   110
	byte curve_speed;
8860
a30cd0629e2b (svn r12624) -Codechange: Make drawing of catenary an attribute of rail types, instead of deciding by the rail type directly.
peter1138
parents: 8732
diff changeset
   111
a30cd0629e2b (svn r12624) -Codechange: Make drawing of catenary an attribute of rail types, instead of deciding by the rail type directly.
peter1138
parents: 8732
diff changeset
   112
	/**
a30cd0629e2b (svn r12624) -Codechange: Make drawing of catenary an attribute of rail types, instead of deciding by the rail type directly.
peter1138
parents: 8732
diff changeset
   113
	 * Bit mask of rail type flags
a30cd0629e2b (svn r12624) -Codechange: Make drawing of catenary an attribute of rail types, instead of deciding by the rail type directly.
peter1138
parents: 8732
diff changeset
   114
	 */
a30cd0629e2b (svn r12624) -Codechange: Make drawing of catenary an attribute of rail types, instead of deciding by the rail type directly.
peter1138
parents: 8732
diff changeset
   115
	RailTypeFlags flags;
10002
87148ad75853 (svn r14160) -Codechange: Move _railtype_cost_multipliers into the rail type information struct.
peter1138
parents: 10001
diff changeset
   116
87148ad75853 (svn r14160) -Codechange: Move _railtype_cost_multipliers into the rail type information struct.
peter1138
parents: 10001
diff changeset
   117
	/**
87148ad75853 (svn r14160) -Codechange: Move _railtype_cost_multipliers into the rail type information struct.
peter1138
parents: 10001
diff changeset
   118
	 * Cost multiplier for building this rail type
87148ad75853 (svn r14160) -Codechange: Move _railtype_cost_multipliers into the rail type information struct.
peter1138
parents: 10001
diff changeset
   119
	 */
87148ad75853 (svn r14160) -Codechange: Move _railtype_cost_multipliers into the rail type information struct.
peter1138
parents: 10001
diff changeset
   120
	uint8 cost_multiplier;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6162
diff changeset
   121
};
2233
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   122
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   123
1967
a01f4d5dd957 (svn r2473) - Add: VehicleMayEnterTile(), which checks if the tile owner of a tile is correct for a vehicle to enter it. Based upon glx's code.
matthijs
parents: 1950
diff changeset
   124
/**
2233
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   125
 * Returns a pointer to the Railtype information for a given railtype
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   126
 * @param railtype the rail type which the information is requested for
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   127
 * @return The pointer to the RailtypeInfo
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   128
 */
2236
34daee5dfc60 (svn r2756) Renamed railtypes into _railtypes
ludde
parents: 2233
diff changeset
   129
static inline const RailtypeInfo *GetRailTypeInfo(RailType railtype)
2233
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   130
{
6162
798086a4c251 (svn r8912) -Codechange: coding style cleanup and moving of two global externs into the functions that use them.
rubidium
parents: 6156
diff changeset
   131
	extern RailtypeInfo _railtypes[RAILTYPE_END];
2233
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   132
	assert(railtype < RAILTYPE_END);
2236
34daee5dfc60 (svn r2756) Renamed railtypes into _railtypes
ludde
parents: 2233
diff changeset
   133
	return &_railtypes[railtype];
2233
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   134
}
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   135
ee31c1e1477c (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   136
/**
2006
9d5d7fd428c2 (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   137
 * Checks if an engine of the given RailType can drive on a tile with a given
9d5d7fd428c2 (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   138
 * RailType. This would normally just be an equality check, but for electric
9d5d7fd428c2 (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   139
 * rails (which also support non-electric engines).
9d5d7fd428c2 (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   140
 * @return Whether the engine can drive on this tile.
9d5d7fd428c2 (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   141
 * @param  enginetype The RailType of the engine we are considering.
9d5d7fd428c2 (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   142
 * @param  tiletype   The RailType of the tile we are considering.
9d5d7fd428c2 (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   143
 */
9d5d7fd428c2 (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   144
static inline bool IsCompatibleRail(RailType enginetype, RailType tiletype)
9d5d7fd428c2 (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   145
{
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7833
diff changeset
   146
	return HasBit(GetRailTypeInfo(enginetype)->compatible_railtypes, tiletype);
2006
9d5d7fd428c2 (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   147
}
9d5d7fd428c2 (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   148
7396
6b9f010b31ea (svn r10765) -Documentation [FS#1100]: of rail.h. Based on a patch by Progman.
rubidium
parents: 7335
diff changeset
   149
/**
6b9f010b31ea (svn r10765) -Documentation [FS#1100]: of rail.h. Based on a patch by Progman.
rubidium
parents: 7335
diff changeset
   150
 * Checks if an engine of the given RailType got power on a tile with a given
6b9f010b31ea (svn r10765) -Documentation [FS#1100]: of rail.h. Based on a patch by Progman.
rubidium
parents: 7335
diff changeset
   151
 * RailType. This would normally just be an equality check, but for electric
6b9f010b31ea (svn r10765) -Documentation [FS#1100]: of rail.h. Based on a patch by Progman.
rubidium
parents: 7335
diff changeset
   152
 * rails (which also support non-electric engines).
6b9f010b31ea (svn r10765) -Documentation [FS#1100]: of rail.h. Based on a patch by Progman.
rubidium
parents: 7335
diff changeset
   153
 * @return Whether the engine got power on this tile.
6b9f010b31ea (svn r10765) -Documentation [FS#1100]: of rail.h. Based on a patch by Progman.
rubidium
parents: 7335
diff changeset
   154
 * @param  enginetype The RailType of the engine we are considering.
6b9f010b31ea (svn r10765) -Documentation [FS#1100]: of rail.h. Based on a patch by Progman.
rubidium
parents: 7335
diff changeset
   155
 * @param  tiletype   The RailType of the tile we are considering.
6b9f010b31ea (svn r10765) -Documentation [FS#1100]: of rail.h. Based on a patch by Progman.
rubidium
parents: 7335
diff changeset
   156
 */
3355
e414a0b104a6 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   157
static inline bool HasPowerOnRail(RailType enginetype, RailType tiletype)
e414a0b104a6 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   158
{
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7833
diff changeset
   159
	return HasBit(GetRailTypeInfo(enginetype)->powered_railtypes, tiletype);
3355
e414a0b104a6 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   160
}
e414a0b104a6 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   161
7730
4293ba29ce21 (svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents: 7703
diff changeset
   162
/**
4293ba29ce21 (svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents: 7703
diff changeset
   163
 * Returns the cost of building the specified railtype.
4293ba29ce21 (svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents: 7703
diff changeset
   164
 * @param railtype The railtype being built.
4293ba29ce21 (svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents: 7703
diff changeset
   165
 * @return The cost multiplier.
4293ba29ce21 (svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents: 7703
diff changeset
   166
 */
4293ba29ce21 (svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents: 7703
diff changeset
   167
static inline Money RailBuildCost(RailType railtype)
4293ba29ce21 (svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents: 7703
diff changeset
   168
{
4293ba29ce21 (svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents: 7703
diff changeset
   169
	assert(railtype < RAILTYPE_END);
10002
87148ad75853 (svn r14160) -Codechange: Move _railtype_cost_multipliers into the rail type information struct.
peter1138
parents: 10001
diff changeset
   170
	return (_price.build_rail * GetRailTypeInfo(railtype)->cost_multiplier) >> 3;
7730
4293ba29ce21 (svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents: 7703
diff changeset
   171
}
4293ba29ce21 (svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents: 7703
diff changeset
   172
8043
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   173
/**
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   174
 * Calculates the cost of rail conversion
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   175
 * @param from The railtype we are converting from
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   176
 * @param to   The railtype we are converting to
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   177
 * @return Cost per TrackBit
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   178
 */
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   179
static inline Money RailConvertCost(RailType from, RailType to)
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   180
{
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   181
	/* rail -> el. rail
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   182
	 * calculate the price as 5 / 4 of (cost build el. rail) - (cost build rail)
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   183
	 * (the price of workers to get to place is that 1/4)
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   184
	 */
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   185
	if (HasPowerOnRail(from, to)) {
10004
e8985b8f9841 (svn r14162) -Fix: Allow rail type conversion if the rail type cost multipliers are the same.
peter1138
parents: 10002
diff changeset
   186
		Money cost = ((RailBuildCost(to) - RailBuildCost(from)) * 5) >> 2;
e8985b8f9841 (svn r14162) -Fix: Allow rail type conversion if the rail type cost multipliers are the same.
peter1138
parents: 10002
diff changeset
   187
		if (cost != 0) return cost;
8043
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   188
	}
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   189
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   190
	/* el. rail -> rail
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   191
	 * calculate the price as 1 / 4 of (cost build el. rail) - (cost build rail)
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   192
	 * (the price of workers is 1 / 4 + price of copper sold to a recycle center)
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   193
	 */
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   194
	if (HasPowerOnRail(to, from)) {
10004
e8985b8f9841 (svn r14162) -Fix: Allow rail type conversion if the rail type cost multipliers are the same.
peter1138
parents: 10002
diff changeset
   195
		Money cost = (RailBuildCost(from) - RailBuildCost(to)) >> 2;
e8985b8f9841 (svn r14162) -Fix: Allow rail type conversion if the rail type cost multipliers are the same.
peter1138
parents: 10002
diff changeset
   196
		if (cost != 0) return cost;
8043
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   197
	}
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   198
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   199
	/* make the price the same as remove + build new type */
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   200
	return RailBuildCost(to) + _price.remove_rail;
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   201
}
08dcb2d81d9d (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
smatz
parents: 7929
diff changeset
   202
9775
22e256c3bf46 (svn r13912) -Codechange: remove some casts by returning the proper type instead of void*.
rubidium
parents: 9493
diff changeset
   203
Vehicle *UpdateTrainPowerProc(Vehicle *v, void *data);
2520
8a52362c4ada (svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents: 2514
diff changeset
   204
void DrawTrainDepotSprite(int x, int y, int image, RailType railtype);
8a52362c4ada (svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents: 2514
diff changeset
   205
void DrawDefaultWaypointSprite(int x, int y, RailType railtype);
9775
22e256c3bf46 (svn r13912) -Codechange: remove some casts by returning the proper type instead of void*.
rubidium
parents: 9493
diff changeset
   206
Vehicle *EnsureNoTrainOnTrackProc(Vehicle *v, void *data);
8712
be50475ea8fc (svn r12386) -Fix [FS#1841](r2428): train could break apart when reversed while partially in a depot
smatz
parents: 8238
diff changeset
   207
int TicksToLeaveDepot(const Vehicle *v);
3355
e414a0b104a6 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   208
7335
141c6b86ec1f (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7155
diff changeset
   209
Foundation GetRailFoundation(Slope tileh, TrackBits bits);
5116
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 4549
diff changeset
   210
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 4549
diff changeset
   211
8236
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
   212
/**
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10004
diff changeset
   213
 * Finds out if a company has a certain railtype available
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10004
diff changeset
   214
 * @param company the company in question
8236
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
   215
 * @param railtype requested RailType
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10004
diff changeset
   216
 * @return true if company has requested RailType available
8236
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
   217
 */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10004
diff changeset
   218
bool HasRailtypeAvail(const CompanyID company, const RailType railtype);
8236
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
   219
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
   220
/**
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
   221
 * Validate functions for rail building.
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
   222
 * @param rail the railtype to check.
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10004
diff changeset
   223
 * @return true if the current company may build the rail.
8236
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
   224
 */
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
   225
bool ValParamRailtype(const RailType rail);
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
   226
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
   227
/**
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10004
diff changeset
   228
 * Returns the "best" railtype a company can build.
8236
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
   229
 * As the AI doesn't know what the BEST one is, we have our own priority list
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
   230
 * here. When adding new railtypes, modify this function
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10004
diff changeset
   231
 * @param company the company "in action"
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10004
diff changeset
   232
 * @return The "best" railtype a company has available
8236
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
   233
 */
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10004
diff changeset
   234
RailType GetBestRailtype(const CompanyID company);
8236
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
   235
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
   236
/**
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10004
diff changeset
   237
 * Get the rail types the given company can build.
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10004
diff changeset
   238
 * @param company the company to get the rail types for.
8236
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
   239
 * @return the rail types.
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
   240
 */
10225
eb61dd8101c1 (svn r14448) -Codechange [FS#2328]: rename a few variables (based on a patch by planetmaker)
smatz
parents: 10207
diff changeset
   241
RailTypes GetCompanyRailtypes(const CompanyID c);
8236
8a5dd0b42e47 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8211
diff changeset
   242
10001
df9284007ed5 (svn r14158) -Codechange: Initialization of rail type data from static source, so data can be changed.
peter1138
parents: 10000
diff changeset
   243
/**
df9284007ed5 (svn r14158) -Codechange: Initialization of rail type data from static source, so data can be changed.
peter1138
parents: 10000
diff changeset
   244
 * Reset all rail type information to its default values.
df9284007ed5 (svn r14158) -Codechange: Initialization of rail type data from static source, so data can be changed.
peter1138
parents: 10000
diff changeset
   245
 */
df9284007ed5 (svn r14158) -Codechange: Initialization of rail type data from static source, so data can be changed.
peter1138
parents: 10000
diff changeset
   246
void ResetRailTypes();
df9284007ed5 (svn r14158) -Codechange: Initialization of rail type data from static source, so data can be changed.
peter1138
parents: 10000
diff changeset
   247
2536
634914d741b4 (svn r3065) -Codechange/Add: Modified the bridge drawing code so that the basic offset is read from the RailTypeInfo struct. This is (hopefully) the last DrawTile change on the way to electrified railways. While being at it, de-mystified the function a bit and added some asserts.
celestar
parents: 2520
diff changeset
   248
#endif /* RAIL_H */