author | peter1138 |
Sun, 03 Aug 2008 17:35:08 +0000 | |
changeset 9834 | 7474149531c1 |
parent 9642 | 0a700db0611c |
permissions | -rw-r--r-- |
2268 | 1 |
/* $Id$ */ |
2262
252cfd94c54d
(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 |
|
252cfd94c54d
(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 */ |
252cfd94c54d
(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 |
|
252cfd94c54d
(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 |
252cfd94c54d
(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 |
252cfd94c54d
(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 |
|
8123
ce31d2843a95
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents:
8119
diff
changeset
|
8 |
#include "gfx_type.h" |
8222
ce0457729295
(svn r11785) -Codechange: remove some unneeded includes.
rubidium
parents:
8138
diff
changeset
|
9 |
#include "direction_type.h" |
8138
dbfdc08fa6b9
(svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents:
8123
diff
changeset
|
10 |
#include "tile_cmd.h" |
8123
ce31d2843a95
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents:
8119
diff
changeset
|
11 |
|
9642
0a700db0611c
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents:
9578
diff
changeset
|
12 |
/** This enum is related to the definition of bridge pieces, |
0a700db0611c
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents:
9578
diff
changeset
|
13 |
* which is used to determine the proper sprite table to use |
0a700db0611c
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents:
9578
diff
changeset
|
14 |
* while drawing a given bridge part. |
0a700db0611c
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents:
9578
diff
changeset
|
15 |
*/ |
0a700db0611c
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents:
9578
diff
changeset
|
16 |
enum BridgePieces { |
0a700db0611c
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents:
9578
diff
changeset
|
17 |
BRIDGE_PIECE_NORTH = 0, |
0a700db0611c
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents:
9578
diff
changeset
|
18 |
BRIDGE_PIECE_SOUTH, |
0a700db0611c
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents:
9578
diff
changeset
|
19 |
BRIDGE_PIECE_INNER_NORTH, |
0a700db0611c
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents:
9578
diff
changeset
|
20 |
BRIDGE_PIECE_INNER_SOUTH, |
0a700db0611c
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents:
9578
diff
changeset
|
21 |
BRIDGE_PIECE_MIDDLE_ODD, |
0a700db0611c
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents:
9578
diff
changeset
|
22 |
BRIDGE_PIECE_MIDDLE_EVEN, |
0a700db0611c
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents:
9578
diff
changeset
|
23 |
BRIDGE_PIECE_HEAD, |
0a700db0611c
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents:
9578
diff
changeset
|
24 |
BRIDGE_PIECE_INVALID, |
0a700db0611c
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents:
9578
diff
changeset
|
25 |
}; |
0a700db0611c
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents:
9578
diff
changeset
|
26 |
|
0a700db0611c
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents:
9578
diff
changeset
|
27 |
DECLARE_POSTFIX_INCREMENT(BridgePieces); |
0a700db0611c
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas
parents:
9578
diff
changeset
|
28 |
|
3359
633290bf1117
(svn r4154) -Moved MAX_BRIDGES in bridge.h and made it an enum. This makes two drops ...
celestar
parents:
3355
diff
changeset
|
29 |
enum { |
633290bf1117
(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 |
633290bf1117
(svn r4154) -Moved MAX_BRIDGES in bridge.h and made it an enum. This makes two drops ...
celestar
parents:
3355
diff
changeset
|
31 |
}; |
633290bf1117
(svn r4154) -Moved MAX_BRIDGES in bridge.h and made it an enum. This makes two drops ...
celestar
parents:
3355
diff
changeset
|
32 |
|
8532
ebe68d6899b6
(svn r12107) -Codechange: Add and use the typedef BridgeType
belugas
parents:
8491
diff
changeset
|
33 |
typedef uint BridgeType; |
ebe68d6899b6
(svn r12107) -Codechange: Add and use the typedef BridgeType
belugas
parents:
8491
diff
changeset
|
34 |
|
2262
252cfd94c54d
(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 |
252cfd94c54d
(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 |
*/ |
8535
ef36a2eb9345
(svn r12111) -Codechange: Rename Bridge to BridgeSpec, out of consistensy with other Specs in used.
belugas
parents:
8532
diff
changeset
|
37 |
struct BridgeSpec { |
8540
7d2f5260dc4b
(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:
8535
diff
changeset
|
38 |
Year avail_year; ///< the year where it becomes available |
7d2f5260dc4b
(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:
8535
diff
changeset
|
39 |
byte min_length; ///< the minimum length (not counting start and end tile) |
7d2f5260dc4b
(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:
8535
diff
changeset
|
40 |
byte max_length; ///< the maximum length (not counting start and end tile) |
7d2f5260dc4b
(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:
8535
diff
changeset
|
41 |
uint16 price; ///< the price multiplier |
7d2f5260dc4b
(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:
8535
diff
changeset
|
42 |
uint16 speed; ///< maximum travel speed |
7d2f5260dc4b
(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:
8535
diff
changeset
|
43 |
SpriteID sprite; ///< the sprite which is used in the GUI |
7d2f5260dc4b
(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:
8535
diff
changeset
|
44 |
SpriteID pal; ///< the palette which is used in the GUI |
7d2f5260dc4b
(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:
8535
diff
changeset
|
45 |
StringID material; ///< the string that contains the bridge description |
7d2f5260dc4b
(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:
8535
diff
changeset
|
46 |
StringID transport_name[2]; ///< description of the bridge, when built for road or rail |
7d2f5260dc4b
(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:
8535
diff
changeset
|
47 |
PalSpriteID **sprite_table; ///< table of sprites for drawing the bridge |
7d2f5260dc4b
(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:
8535
diff
changeset
|
48 |
byte flags; ///< bit 0 set: disable drawing of far pillars. |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6160
diff
changeset
|
49 |
}; |
2262
252cfd94c54d
(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 |
|
8535
ef36a2eb9345
(svn r12111) -Codechange: Rename Bridge to BridgeSpec, out of consistensy with other Specs in used.
belugas
parents:
8532
diff
changeset
|
51 |
extern BridgeSpec _bridge[MAX_BRIDGES]; |
2262
252cfd94c54d
(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 |
|
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:
7318
diff
changeset
|
53 |
Foundation GetBridgeFoundation(Slope tileh, Axis axis); |
8379
94fcc26a241a
(svn r11946) -Fix: slope detection of bridge ramps.
frosch
parents:
8222
diff
changeset
|
54 |
bool HasBridgeFlatRamp(Slope tileh, Axis axis); |
6141 | 55 |
|
8535
ef36a2eb9345
(svn r12111) -Codechange: Rename Bridge to BridgeSpec, out of consistensy with other Specs in used.
belugas
parents:
8532
diff
changeset
|
56 |
static inline const BridgeSpec *GetBridgeSpec(BridgeType i) |
6141 | 57 |
{ |
58 |
assert(i < lengthof(_bridge)); |
|
59 |
return &_bridge[i]; |
|
60 |
} |
|
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:
2763
diff
changeset
|
61 |
|
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6248
diff
changeset
|
62 |
void DrawBridgeMiddle(const TileInfo *ti); |
6160
fa42299e967e
(svn r8908) -Codechange: declaration of DrawBridgeMiddle does not belong in a map accessors header.
rubidium
parents:
6141
diff
changeset
|
63 |
|
9578
897d5acf2a62
(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:
8540
diff
changeset
|
64 |
bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len, uint32 flags = 0); |
8119
52b48108425a
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
7335
diff
changeset
|
65 |
int CalcBridgeLenCostFactor(int x); |
52b48108425a
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
7335
diff
changeset
|
66 |
|
8489
28bedfca9e27
(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:
8475
diff
changeset
|
67 |
void ResetBridges(); |
28bedfca9e27
(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:
8475
diff
changeset
|
68 |
|
2262
252cfd94c54d
(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 */ |