src/bridge.h
author Tero Marttila <terom@fixme.fi>
Fri, 18 Jul 2008 22:41:08 +0300
changeset 11177 6d9a43c48924
parent 11147 d009bad829a6
permissions -rw-r--r--
set the GRFConfig's next ptr to NULL
2268
a28a946df64f (svn r2788) Fix Id tag
tron
parents: 2263
diff changeset
     1
/* $Id$ */
2262
bd59b2d8d75f (svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
diff changeset
     2
bd59b2d8d75f (svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
diff changeset
     3
/** @file bridge.h Header file for bridges */
bd59b2d8d75f (svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
diff changeset
     4
bd59b2d8d75f (svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
diff changeset
     5
#ifndef BRIDGE_H
bd59b2d8d75f (svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
diff changeset
     6
#define BRIDGE_H
bd59b2d8d75f (svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
diff changeset
     7
8619
c2434269c3eb (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8615
diff changeset
     8
#include "gfx_type.h"
8718
1f536d980531 (svn r11785) -Codechange: remove some unneeded includes.
rubidium
parents: 8634
diff changeset
     9
#include "direction_type.h"
8634
5ffca02f9115 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8619
diff changeset
    10
#include "tile_cmd.h"
8619
c2434269c3eb (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8615
diff changeset
    11
11147
d009bad829a6 (svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents: 11054
diff changeset
    12
/** This enum is related to the definition of bridge pieces,
d009bad829a6 (svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents: 11054
diff changeset
    13
 * which is used to determine the proper sprite table to use
d009bad829a6 (svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents: 11054
diff changeset
    14
 * while drawing a given bridge part.
d009bad829a6 (svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents: 11054
diff changeset
    15
 */
d009bad829a6 (svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents: 11054
diff changeset
    16
enum BridgePieces {
d009bad829a6 (svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents: 11054
diff changeset
    17
	BRIDGE_PIECE_NORTH = 0,
d009bad829a6 (svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents: 11054
diff changeset
    18
	BRIDGE_PIECE_SOUTH,
d009bad829a6 (svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents: 11054
diff changeset
    19
	BRIDGE_PIECE_INNER_NORTH,
d009bad829a6 (svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents: 11054
diff changeset
    20
	BRIDGE_PIECE_INNER_SOUTH,
d009bad829a6 (svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents: 11054
diff changeset
    21
	BRIDGE_PIECE_MIDDLE_ODD,
d009bad829a6 (svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents: 11054
diff changeset
    22
	BRIDGE_PIECE_MIDDLE_EVEN,
d009bad829a6 (svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents: 11054
diff changeset
    23
	BRIDGE_PIECE_HEAD,
d009bad829a6 (svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents: 11054
diff changeset
    24
	BRIDGE_PIECE_INVALID,
d009bad829a6 (svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents: 11054
diff changeset
    25
};
d009bad829a6 (svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents: 11054
diff changeset
    26
d009bad829a6 (svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents: 11054
diff changeset
    27
DECLARE_POSTFIX_INCREMENT(BridgePieces);
d009bad829a6 (svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents: 11054
diff changeset
    28
3359
d4316b1af327 (svn r4154) -Moved MAX_BRIDGES in bridge.h and made it an enum. This makes two drops ...
celestar
parents: 3355
diff changeset
    29
enum {
d4316b1af327 (svn r4154) -Moved MAX_BRIDGES in bridge.h and made it an enum. This makes two drops ...
celestar
parents: 3355
diff changeset
    30
	MAX_BRIDGES = 13
d4316b1af327 (svn r4154) -Moved MAX_BRIDGES in bridge.h and made it an enum. This makes two drops ...
celestar
parents: 3355
diff changeset
    31
};
d4316b1af327 (svn r4154) -Moved MAX_BRIDGES in bridge.h and made it an enum. This makes two drops ...
celestar
parents: 3355
diff changeset
    32
9028
501b3b351df7 (svn r12107) -Codechange: Add and use the typedef BridgeType
belugas
parents: 8987
diff changeset
    33
typedef uint BridgeType;
501b3b351df7 (svn r12107) -Codechange: Add and use the typedef BridgeType
belugas
parents: 8987
diff changeset
    34
2262
bd59b2d8d75f (svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
diff changeset
    35
/** Struct containing information about a single bridge type
bd59b2d8d75f (svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
diff changeset
    36
 */
9031
e260304797e6 (svn r12111) -Codechange: Rename Bridge to BridgeSpec, out of consistensy with other Specs in used.
belugas
parents: 9028
diff changeset
    37
struct BridgeSpec {
9036
d3b132a4b97a (svn r12118) -Codechange: Put the two descriptions of bridges in an array instead of two single variables, following the transport type it represents
belugas
parents: 9031
diff changeset
    38
	Year avail_year;             ///< the year where it becomes available
d3b132a4b97a (svn r12118) -Codechange: Put the two descriptions of bridges in an array instead of two single variables, following the transport type it represents
belugas
parents: 9031
diff changeset
    39
	byte min_length;             ///< the minimum length (not counting start and end tile)
d3b132a4b97a (svn r12118) -Codechange: Put the two descriptions of bridges in an array instead of two single variables, following the transport type it represents
belugas
parents: 9031
diff changeset
    40
	byte max_length;             ///< the maximum length (not counting start and end tile)
d3b132a4b97a (svn r12118) -Codechange: Put the two descriptions of bridges in an array instead of two single variables, following the transport type it represents
belugas
parents: 9031
diff changeset
    41
	uint16 price;                ///< the price multiplier
d3b132a4b97a (svn r12118) -Codechange: Put the two descriptions of bridges in an array instead of two single variables, following the transport type it represents
belugas
parents: 9031
diff changeset
    42
	uint16 speed;                ///< maximum travel speed
d3b132a4b97a (svn r12118) -Codechange: Put the two descriptions of bridges in an array instead of two single variables, following the transport type it represents
belugas
parents: 9031
diff changeset
    43
	SpriteID sprite;             ///< the sprite which is used in the GUI
d3b132a4b97a (svn r12118) -Codechange: Put the two descriptions of bridges in an array instead of two single variables, following the transport type it represents
belugas
parents: 9031
diff changeset
    44
	SpriteID pal;                ///< the palette which is used in the GUI
d3b132a4b97a (svn r12118) -Codechange: Put the two descriptions of bridges in an array instead of two single variables, following the transport type it represents
belugas
parents: 9031
diff changeset
    45
	StringID material;           ///< the string that contains the bridge description
d3b132a4b97a (svn r12118) -Codechange: Put the two descriptions of bridges in an array instead of two single variables, following the transport type it represents
belugas
parents: 9031
diff changeset
    46
	StringID transport_name[2];  ///< description of the bridge, when built for road or rail
d3b132a4b97a (svn r12118) -Codechange: Put the two descriptions of bridges in an array instead of two single variables, following the transport type it represents
belugas
parents: 9031
diff changeset
    47
	PalSpriteID **sprite_table;  ///< table of sprites for drawing the bridge
d3b132a4b97a (svn r12118) -Codechange: Put the two descriptions of bridges in an array instead of two single variables, following the transport type it represents
belugas
parents: 9031
diff changeset
    48
	byte flags;                  ///< bit 0 set: disable drawing of far pillars.
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6486
diff changeset
    49
};
2262
bd59b2d8d75f (svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
diff changeset
    50
9031
e260304797e6 (svn r12111) -Codechange: Rename Bridge to BridgeSpec, out of consistensy with other Specs in used.
belugas
parents: 9028
diff changeset
    51
extern BridgeSpec _bridge[MAX_BRIDGES];
2262
bd59b2d8d75f (svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
diff changeset
    52
7831
5dded9b03500 (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: 7814
diff changeset
    53
Foundation GetBridgeFoundation(Slope tileh, Axis axis);
8875
ffcab947226b (svn r11946) -Fix: slope detection of bridge ramps.
frosch
parents: 8718
diff changeset
    54
bool HasBridgeFlatRamp(Slope tileh, Axis axis);
6467
6228b576422d (svn r8884) -Fix
tron
parents: 5919
diff changeset
    55
9031
e260304797e6 (svn r12111) -Codechange: Rename Bridge to BridgeSpec, out of consistensy with other Specs in used.
belugas
parents: 9028
diff changeset
    56
static inline const BridgeSpec *GetBridgeSpec(BridgeType i)
6467
6228b576422d (svn r8884) -Fix
tron
parents: 5919
diff changeset
    57
{
6228b576422d (svn r8884) -Fix
tron
parents: 5919
diff changeset
    58
	assert(i < lengthof(_bridge));
6228b576422d (svn r8884) -Fix
tron
parents: 5919
diff changeset
    59
	return &_bridge[i];
6228b576422d (svn r8884) -Fix
tron
parents: 5919
diff changeset
    60
}
3355
a653b8e47f27 (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: 2763
diff changeset
    61
7814
fe643468ad64 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents: 6574
diff changeset
    62
void DrawBridgeMiddle(const TileInfo *ti);
6486
4f8af35b11eb (svn r8908) -Codechange: declaration of DrawBridgeMiddle does not belong in a map accessors header.
rubidium
parents: 6467
diff changeset
    63
11054
88373b819bbc (svn r13611) -Fix [FS#2100]: if the first bridge can't be build for a given length, then none of the other bridges can. Effectively meaning that if someone replaces the first bridge with a bridge that can be only 3 tiles longs then only other bridges that can be 3 tiles long will be buildable, but only if they are 3 tiles long.
rubidium
parents: 9036
diff changeset
    64
bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len, uint32 flags = 0);
8615
6b91ca653bad (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 7831
diff changeset
    65
int CalcBridgeLenCostFactor(int x);
6b91ca653bad (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 7831
diff changeset
    66
8985
2f7b495d5807 (svn r12064) -Codechange : Give grf bridges their own ResetBridges function, and put bridge spec in table/bridge_land.h, where it should be.
belugas
parents: 8971
diff changeset
    67
void ResetBridges();
2f7b495d5807 (svn r12064) -Codechange : Give grf bridges their own ResetBridges function, and put bridge spec in table/bridge_land.h, where it should be.
belugas
parents: 8971
diff changeset
    68
2262
bd59b2d8d75f (svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
diff changeset
    69
#endif /* BRIDGE_H */