summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2008-02-05 04:48:56 +0000
committerbelugas <belugas@openttd.org>2008-02-05 04:48:56 +0000
commit3003986e6777c79a992ecb21b7f908f1793cd7de (patch)
tree7460617a02af63ccffb0af9f8e2e9d7968c55f44 /src
parentc261218cf51d9b21133b095b4b056afb452086ee (diff)
downloadopenttd-3003986e6777c79a992ecb21b7f908f1793cd7de.tar.xz
(svn r12064) -Codechange : Give grf bridges their own ResetBridges function, and put bridge spec in table/bridge_land.h, where it should be.
Diffstat (limited to 'src')
-rw-r--r--src/bridge.h2
-rw-r--r--src/newgrf.cpp11
-rw-r--r--src/table/bridge_land.h69
-rw-r--r--src/tunnelbridge_cmd.cpp85
4 files changed, 89 insertions, 78 deletions
diff --git a/src/bridge.h b/src/bridge.h
index 60c1e6185..0fbd7aeee 100644
--- a/src/bridge.h
+++ b/src/bridge.h
@@ -47,4 +47,6 @@ void DrawBridgeMiddle(const TileInfo *ti);
bool CheckBridge_Stuff(byte bridge_type, uint bridge_len);
int CalcBridgeLenCostFactor(int x);
+void ResetBridges();
+
#endif /* BRIDGE_H */
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 8563f7db4..f09f1e27b 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -5091,15 +5091,8 @@ static void ResetNewGRFData()
/* Copy/reset original engine info data */
SetupEngines();
- /* Copy/reset original bridge info data
- * First, free sprite table data */
- for (uint i = 0; i < MAX_BRIDGES; i++) {
- if (_bridge[i].sprite_table != NULL) {
- for (uint j = 0; j < 7; j++) free(_bridge[i].sprite_table[j]);
- free(_bridge[i].sprite_table);
- }
- }
- memcpy(&_bridge, &orig_bridge, sizeof(_bridge));
+ /* Copy/reset original bridge info data */
+ ResetBridges();
/* Reset refit/cargo class data */
memset(&cargo_allowed, 0, sizeof(cargo_allowed));
diff --git a/src/table/bridge_land.h b/src/table/bridge_land.h
index 495b742ae..2eb5b273c 100644
--- a/src/table/bridge_land.h
+++ b/src/table/bridge_land.h
@@ -707,3 +707,72 @@ static const PalSpriteID * const * const _bridge_sprite_table[MAX_BRIDGES] = {
_bridge_sprite_table_11,
_bridge_sprite_table_12
};
+
+/** Describes the data that defines each bridge in the game
+ * @param y year of availablity
+ * @param mnl minimum length
+ * @param mxl maximum length
+ * @param p price
+ * @param mxs maximum speed allowed
+ * @param spr sprite to use in purchase GUI
+ * @param plt palette for the sprite in purchase GUI
+ * @param dsc description of the bridge in purchase GUI
+ * @param nrl description of the rail bridge in query tool
+ * @param nrd description of the road bridge in query tool
+ */
+#define MB(y, mnl, mxl, p, mxs, spr, plt, dsc, nrl, nrd) \
+ {y, mnl, mxl, p, mxs, spr, plt, dsc, nrl, nrd, NULL, 0}
+
+const Bridge _orig_bridge[] = {
+/*
+ year of availablity
+ | minimum length
+ | | maximum length
+ | | | price
+ | | | | maximum speed
+ | | | | | sprite to use in GUI
+ | | | | | | palette in GUI
+ string with description name on rail name on road
+ | | | */
+ MB( 0, 0, 16, 80, 32, 0xA24, PAL_NONE,
+ STR_5012_WOODEN, STR_501F_WOODEN_RAIL_BRIDGE, STR_5025_WOODEN_ROAD_BRIDGE),
+
+ MB( 0, 0, 2, 112, 48, 0xA26, PALETTE_TO_STRUCT_RED,
+ STR_5013_CONCRETE, STR_5020_CONCRETE_RAIL_BRIDGE, STR_5026_CONCRETE_ROAD_BRIDGE),
+
+ MB( 1930, 0, 5, 144, 64, 0xA25, PAL_NONE,
+ STR_500F_GIRDER_STEEL, STR_501C_STEEL_GIRDER_RAIL_BRIDGE, STR_5022_STEEL_GIRDER_ROAD_BRIDGE),
+
+ MB( 0, 2, 10, 168, 80, 0xA22, PALETTE_TO_STRUCT_CONCRETE,
+ STR_5011_SUSPENSION_CONCRETE, STR_501E_REINFORCED_CONCRETE_SUSPENSION, STR_5024_REINFORCED_CONCRETE_SUSPENSION),
+
+ MB( 1930, 3, 16, 185, 96, 0xA22, PAL_NONE,
+ STR_500E_SUSPENSION_STEEL, STR_501B_STEEL_SUSPENSION_RAIL_BRIDGE, STR_5021_STEEL_SUSPENSION_ROAD_BRIDGE),
+
+ MB( 1930, 3, 16, 192, 112, 0xA22, PALETTE_TO_STRUCT_YELLOW,
+ STR_500E_SUSPENSION_STEEL, STR_501B_STEEL_SUSPENSION_RAIL_BRIDGE, STR_5021_STEEL_SUSPENSION_ROAD_BRIDGE),
+
+ MB( 1930, 3, 7, 224, 160, 0xA23, PAL_NONE,
+ STR_5010_CANTILEVER_STEEL, STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE, STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE),
+
+ MB( 1930, 3, 8, 232, 208, 0xA23, PALETTE_TO_STRUCT_BROWN,
+ STR_5010_CANTILEVER_STEEL, STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE, STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE),
+
+ MB( 1930, 3, 9, 248, 240, 0xA23, PALETTE_TO_STRUCT_RED,
+ STR_5010_CANTILEVER_STEEL, STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE, STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE),
+
+ MB( 1930, 0, 2, 240, 256, 0xA27, PAL_NONE,
+ STR_500F_GIRDER_STEEL, STR_501C_STEEL_GIRDER_RAIL_BRIDGE, STR_5022_STEEL_GIRDER_ROAD_BRIDGE),
+
+ MB( 1995, 2, 16, 255, 320, 0xA28, PAL_NONE,
+ STR_5014_TUBULAR_STEEL, STR_5027_TUBULAR_RAIL_BRIDGE, STR_5028_TUBULAR_ROAD_BRIDGE),
+
+ MB( 2005, 2, 32, 380, 512, 0xA28, PALETTE_TO_STRUCT_YELLOW,
+ STR_5014_TUBULAR_STEEL, STR_5027_TUBULAR_RAIL_BRIDGE, STR_5028_TUBULAR_ROAD_BRIDGE),
+
+ MB( 2010, 2, 32, 510, 608, 0xA28, PALETTE_TO_STRUCT_GREY,
+ STR_BRIDGE_TUBULAR_SILICON, STR_5027_TUBULAR_RAIL_BRIDGE, STR_5028_TUBULAR_ROAD_BRIDGE)
+};
+
+#undef MB
+
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index de2bec51d..6b1cdd60a 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -38,77 +38,24 @@
#include "table/strings.h"
#include "table/bridge_land.h"
-
-/** Describes the data that defines each bridge in the game
- * @param y year of availablity
- * @param mnl minimum length
- * @param mxl maximum length
- * @param p price
- * @param mxs maximum speed allowed
- * @param spr sprite to use in purchase GUI
- * @param plt palette for the sprite in purchase GUI
- * @param dsc description of the bridge in purchase GUI
- * @param nrl description of the rail bridge in query tool
- * @param nrd description of the road bridge in query tool
- */
-#define MB(y, mnl, mxl, p, mxs, spr, plt, dsc, nrl, nrd) \
- {y, mnl, mxl, p, mxs, spr, plt, dsc, nrl, nrd, NULL, 0}
-
-const Bridge orig_bridge[] = {
-/*
- year of availablity
- | minimum length
- | | maximum length
- | | | price
- | | | | maximum speed
- | | | | | sprite to use in GUI
- | | | | | | palette in GUI
- string with description name on rail name on road
- | | | */
- MB( 0, 0, 16, 80, 32, 0xA24, PAL_NONE,
- STR_5012_WOODEN, STR_501F_WOODEN_RAIL_BRIDGE, STR_5025_WOODEN_ROAD_BRIDGE),
-
- MB( 0, 0, 2, 112, 48, 0xA26, PALETTE_TO_STRUCT_RED,
- STR_5013_CONCRETE, STR_5020_CONCRETE_RAIL_BRIDGE, STR_5026_CONCRETE_ROAD_BRIDGE),
-
- MB( 1930, 0, 5, 144, 64, 0xA25, PAL_NONE,
- STR_500F_GIRDER_STEEL, STR_501C_STEEL_GIRDER_RAIL_BRIDGE, STR_5022_STEEL_GIRDER_ROAD_BRIDGE),
-
- MB( 0, 2, 10, 168, 80, 0xA22, PALETTE_TO_STRUCT_CONCRETE,
- STR_5011_SUSPENSION_CONCRETE, STR_501E_REINFORCED_CONCRETE_SUSPENSION, STR_5024_REINFORCED_CONCRETE_SUSPENSION),
-
- MB( 1930, 3, 16, 185, 96, 0xA22, PAL_NONE,
- STR_500E_SUSPENSION_STEEL, STR_501B_STEEL_SUSPENSION_RAIL_BRIDGE, STR_5021_STEEL_SUSPENSION_ROAD_BRIDGE),
-
- MB( 1930, 3, 16, 192, 112, 0xA22, PALETTE_TO_STRUCT_YELLOW,
- STR_500E_SUSPENSION_STEEL, STR_501B_STEEL_SUSPENSION_RAIL_BRIDGE, STR_5021_STEEL_SUSPENSION_ROAD_BRIDGE),
-
- MB( 1930, 3, 7, 224, 160, 0xA23, PAL_NONE,
- STR_5010_CANTILEVER_STEEL, STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE, STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE),
-
- MB( 1930, 3, 8, 232, 208, 0xA23, PALETTE_TO_STRUCT_BROWN,
- STR_5010_CANTILEVER_STEEL, STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE, STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE),
-
- MB( 1930, 3, 9, 248, 240, 0xA23, PALETTE_TO_STRUCT_RED,
- STR_5010_CANTILEVER_STEEL, STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE, STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE),
-
- MB( 1930, 0, 2, 240, 256, 0xA27, PAL_NONE,
- STR_500F_GIRDER_STEEL, STR_501C_STEEL_GIRDER_RAIL_BRIDGE, STR_5022_STEEL_GIRDER_ROAD_BRIDGE),
-
- MB( 1995, 2, 16, 255, 320, 0xA28, PAL_NONE,
- STR_5014_TUBULAR_STEEL, STR_5027_TUBULAR_RAIL_BRIDGE, STR_5028_TUBULAR_ROAD_BRIDGE),
-
- MB( 2005, 2, 32, 380, 512, 0xA28, PALETTE_TO_STRUCT_YELLOW,
- STR_5014_TUBULAR_STEEL, STR_5027_TUBULAR_RAIL_BRIDGE, STR_5028_TUBULAR_ROAD_BRIDGE),
-
- MB( 2010, 2, 32, 510, 608, 0xA28, PALETTE_TO_STRUCT_GREY,
- STR_BRIDGE_TUBULAR_SILICON, STR_5027_TUBULAR_RAIL_BRIDGE, STR_5028_TUBULAR_ROAD_BRIDGE)
-};
-
-#undef MB
-
Bridge _bridge[MAX_BRIDGES];
+/** Reset the data been eventually changed by the grf loaded. */
+void ResetBridges()
+{
+ /* First, free sprite table data */
+ for (uint i = 0; i < MAX_BRIDGES; i++) {
+ if (_bridge[i].sprite_table != NULL) {
+ for (uint j = 0; j < 7; j++) free(_bridge[i].sprite_table[j]);
+ free(_bridge[i].sprite_table);
+ }
+ }
+
+ /* Then, wipe out current bidges */
+ memset(&_bridge, 0, sizeof(_bridge));
+ /* And finally, reinstall default data */
+ memcpy(&_bridge, &_orig_bridge, sizeof(_orig_bridge));
+}
/** calculate the price factor for building a long bridge.
* basically the cost delta is 1,1, 1, 2,2, 3,3,3, 4,4,4,4, 5,5,5,5,5, 6,6,6,6,6,6, 7,7,7,7,7,7,7, 8,8,8,8,8,8,8,8,