src/bridge.h
author convert-repo
Mon, 07 Apr 2008 16:21:55 +0000
changeset 10076 dfd70e42c4ae
parent 9036 d3b132a4b97a
child 11054 88373b819bbc
permissions -rw-r--r--
update tags
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
3359
d4316b1af327 (svn r4154) -Moved MAX_BRIDGES in bridge.h and made it an enum. This makes two drops ...
celestar
parents: 3355
diff changeset
    12
enum {
d4316b1af327 (svn r4154) -Moved MAX_BRIDGES in bridge.h and made it an enum. This makes two drops ...
celestar
parents: 3355
diff changeset
    13
	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
    14
};
d4316b1af327 (svn r4154) -Moved MAX_BRIDGES in bridge.h and made it an enum. This makes two drops ...
celestar
parents: 3355
diff changeset
    15
9028
501b3b351df7 (svn r12107) -Codechange: Add and use the typedef BridgeType
belugas
parents: 8987
diff changeset
    16
typedef uint BridgeType;
501b3b351df7 (svn r12107) -Codechange: Add and use the typedef BridgeType
belugas
parents: 8987
diff changeset
    17
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
    18
/** 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
    19
 */
9031
e260304797e6 (svn r12111) -Codechange: Rename Bridge to BridgeSpec, out of consistensy with other Specs in used.
belugas
parents: 9028
diff changeset
    20
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
    21
	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
    22
	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
    23
	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
    24
	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
    25
	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
    26
	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
    27
	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
    28
	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
    29
	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
    30
	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
    31
	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
    32
};
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
    33
9031
e260304797e6 (svn r12111) -Codechange: Rename Bridge to BridgeSpec, out of consistensy with other Specs in used.
belugas
parents: 9028
diff changeset
    34
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
    35
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
    36
Foundation GetBridgeFoundation(Slope tileh, Axis axis);
8875
ffcab947226b (svn r11946) -Fix: slope detection of bridge ramps.
frosch
parents: 8718
diff changeset
    37
bool HasBridgeFlatRamp(Slope tileh, Axis axis);
6467
6228b576422d (svn r8884) -Fix
tron
parents: 5919
diff changeset
    38
9031
e260304797e6 (svn r12111) -Codechange: Rename Bridge to BridgeSpec, out of consistensy with other Specs in used.
belugas
parents: 9028
diff changeset
    39
static inline const BridgeSpec *GetBridgeSpec(BridgeType i)
6467
6228b576422d (svn r8884) -Fix
tron
parents: 5919
diff changeset
    40
{
6228b576422d (svn r8884) -Fix
tron
parents: 5919
diff changeset
    41
	assert(i < lengthof(_bridge));
6228b576422d (svn r8884) -Fix
tron
parents: 5919
diff changeset
    42
	return &_bridge[i];
6228b576422d (svn r8884) -Fix
tron
parents: 5919
diff changeset
    43
}
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
    44
7814
fe643468ad64 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents: 6574
diff changeset
    45
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
    46
9028
501b3b351df7 (svn r12107) -Codechange: Add and use the typedef BridgeType
belugas
parents: 8987
diff changeset
    47
bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len);
8615
6b91ca653bad (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 7831
diff changeset
    48
int CalcBridgeLenCostFactor(int x);
6b91ca653bad (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 7831
diff changeset
    49
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
    50
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
    51
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
#endif /* BRIDGE_H */