src/bridge.h
author belugas
Wed, 27 Feb 2008 04:26:25 +0000
changeset 8645 fd2d92d9761b
parent 8540 7d2f5260dc4b
child 9578 897d5acf2a62
permissions -rw-r--r--
(svn r12288) -Fix(r12287): forgot to include two sprite renames out of consistency.
And obviously forgot to compile before committing, as the array rename would have been evident.
2268
052f106e6e6a (svn r2788) Fix Id tag
tron
parents: 2263
diff changeset
     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
3359
633290bf1117 (svn r4154) -Moved MAX_BRIDGES in bridge.h and made it an enum. This makes two drops ...
celestar
parents: 3355
diff changeset
    12
enum {
633290bf1117 (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
633290bf1117 (svn r4154) -Moved MAX_BRIDGES in bridge.h and made it an enum. This makes two drops ...
celestar
parents: 3355
diff changeset
    14
};
633290bf1117 (svn r4154) -Moved MAX_BRIDGES in bridge.h and made it an enum. This makes two drops ...
celestar
parents: 3355
diff changeset
    15
8532
ebe68d6899b6 (svn r12107) -Codechange: Add and use the typedef BridgeType
belugas
parents: 8491
diff changeset
    16
typedef uint BridgeType;
ebe68d6899b6 (svn r12107) -Codechange: Add and use the typedef BridgeType
belugas
parents: 8491
diff changeset
    17
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
    18
/** 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
    19
 */
8535
ef36a2eb9345 (svn r12111) -Codechange: Rename Bridge to BridgeSpec, out of consistensy with other Specs in used.
belugas
parents: 8532
diff changeset
    20
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
    21
	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
    22
	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
    23
	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
    24
	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
    25
	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
    26
	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
    27
	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
    28
	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
    29
	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
    30
	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
    31
	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
    32
};
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
    33
8535
ef36a2eb9345 (svn r12111) -Codechange: Rename Bridge to BridgeSpec, out of consistensy with other Specs in used.
belugas
parents: 8532
diff changeset
    34
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
    35
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
    36
Foundation GetBridgeFoundation(Slope tileh, Axis axis);
8379
94fcc26a241a (svn r11946) -Fix: slope detection of bridge ramps.
frosch
parents: 8222
diff changeset
    37
bool HasBridgeFlatRamp(Slope tileh, Axis axis);
6141
bd1637f172b4 (svn r8884) -Fix
tron
parents: 5668
diff changeset
    38
8535
ef36a2eb9345 (svn r12111) -Codechange: Rename Bridge to BridgeSpec, out of consistensy with other Specs in used.
belugas
parents: 8532
diff changeset
    39
static inline const BridgeSpec *GetBridgeSpec(BridgeType i)
6141
bd1637f172b4 (svn r8884) -Fix
tron
parents: 5668
diff changeset
    40
{
bd1637f172b4 (svn r8884) -Fix
tron
parents: 5668
diff changeset
    41
	assert(i < lengthof(_bridge));
bd1637f172b4 (svn r8884) -Fix
tron
parents: 5668
diff changeset
    42
	return &_bridge[i];
bd1637f172b4 (svn r8884) -Fix
tron
parents: 5668
diff changeset
    43
}
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
    44
7318
632cd0497770 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents: 6248
diff changeset
    45
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
    46
8532
ebe68d6899b6 (svn r12107) -Codechange: Add and use the typedef BridgeType
belugas
parents: 8491
diff changeset
    47
bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len);
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 7335
diff changeset
    48
int CalcBridgeLenCostFactor(int x);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 7335
diff changeset
    49
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
    50
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
    51
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
#endif /* BRIDGE_H */