diff options
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | engine.c | 64 | ||||
-rw-r--r-- | engine.h | 40 | ||||
-rw-r--r-- | newgrf_cargo.c | 71 | ||||
-rw-r--r-- | newgrf_cargo.h | 63 | ||||
-rw-r--r-- | newgrf_engine.c | 21 | ||||
-rw-r--r-- | newgrf_engine.h | 9 | ||||
-rw-r--r-- | newgrf_station.h | 1 | ||||
-rw-r--r-- | openttd.dsp | 8 | ||||
-rw-r--r-- | openttd.vcproj | 6 |
10 files changed, 161 insertions, 123 deletions
@@ -635,6 +635,7 @@ SRCS += network_gui.c SRCS += network_server.c SRCS += network_udp.c SRCS += newgrf.c +SRCS += newgrf_cargo.c SRCS += newgrf_engine.c SRCS += newgrf_spritegroup.c SRCS += newgrf_station.c @@ -15,6 +15,7 @@ #include "saveload.h" #include "variables.h" #include "train.h" +#include "newgrf_cargo.h" EngineInfo _engine_info[TOTAL_NUM_ENGINES]; RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES]; @@ -28,56 +29,10 @@ enum { ENGINE_PREVIEWING = 4, }; -/** TRANSLATE FROM LOCAL CARGO TO GLOBAL CARGO ID'S. - * This maps the per-landscape cargo ID's to globally unique cargo ID's usable ie. in - * the custom GRF files. It is basically just a transcribed table from TTDPatch's newgrf.txt. - */ -const CargoID _global_cargo_id[NUM_LANDSCAPE][NUM_CARGO] = { - /* LT_NORMAL */ {GC_PASSENGERS, GC_COAL, GC_MAIL, GC_OIL, GC_LIVESTOCK, GC_GOODS, GC_GRAIN, GC_WOOD, GC_IRON_ORE, GC_STEEL, GC_VALUABLES, GC_PAPER_TEMP}, - /* LT_HILLY */ {GC_PASSENGERS, GC_COAL, GC_MAIL, GC_OIL, GC_LIVESTOCK, GC_GOODS, GC_GRAIN, GC_WOOD, GC_INVALID, GC_PAPER, GC_VALUABLES, GC_FOOD }, - /* LT_DESERT */ {GC_PASSENGERS, GC_RUBBER,GC_MAIL, GC_OIL, GC_FRUIT, GC_GOODS, GC_GRAIN, GC_WOOD, GC_COPPER_ORE, GC_WATER, GC_VALUABLES, GC_FOOD }, - /* LT_CANDY */ {GC_PASSENGERS, GC_SUGAR, GC_MAIL, GC_TOYS,GC_BATTERIES, GC_CANDY, GC_TOFFEE,GC_COLA, GC_COTTON_CANDY,GC_BUBBLES,GC_PLASTIC, GC_FIZZY_DRINKS }, - /** - * - GC_INVALID (255) means that cargo is not available for that climate - * - GC_PAPER_TEMP (27) is paper in temperate climate in TTDPatch - * Following can be renumbered: - * - GC_DEFAULT (29) is the defa ult cargo for the purpose of spritesets - * - GC_PURCHASE (30) is the purchase list image (the equivalent of 0xff) for the purpose of spritesets - */ -}; - -/** BEGIN --- TRANSLATE FROM GLOBAL CARGO TO LOCAL CARGO ID'S **/ -/** Map global cargo ID's to local-cargo ID's */ -const CargoID _local_cargo_id_ctype[NUM_GLOBAL_CID] = { - CT_PASSENGERS,CT_COAL, CT_MAIL, CT_OIL, CT_LIVESTOCK,CT_GOODS, CT_GRAIN, CT_WOOD, /* 0- 7 */ - CT_IRON_ORE, CT_STEEL, CT_VALUABLES, CT_PAPER, CT_FOOD, CT_FRUIT, CT_COPPER_ORE, CT_WATER, /* 8-15 */ - CT_RUBBER, CT_SUGAR, CT_TOYS, CT_BATTERIES,CT_CANDY, CT_TOFFEE, CT_COLA, CT_COTTON_CANDY, /* 16-23 */ - CT_BUBBLES, CT_PLASTIC,CT_FIZZY_DRINKS,CT_PAPER /* unsup. */,CT_HILLY_UNUSED, /* 24-28 */ - CT_INVALID, CT_INVALID /* 29-30 */ -}; - -#define MC(cargo) (1 << cargo) -/** Bitmasked value where the global cargo ID is available in landscape - * 0: LT_NORMAL, 1: LT_HILLY, 2: LT_DESERT, 3: LT_CANDY */ -const uint32 _landscape_global_cargo_mask[NUM_LANDSCAPE] = -{ /* LT_NORMAL: temperate */ - MC(GC_PASSENGERS)|MC(GC_COAL)|MC(GC_MAIL)|MC(GC_OIL)|MC(GC_LIVESTOCK)|MC(GC_GOODS)|MC(GC_GRAIN)|MC(GC_WOOD)| - MC(GC_IRON_ORE)|MC(GC_STEEL)|MC(GC_VALUABLES), - /* LT_HILLY: arctic */ - MC(GC_PASSENGERS)|MC(GC_COAL)|MC(GC_MAIL)|MC(GC_OIL)|MC(GC_LIVESTOCK)|MC(GC_GOODS)| - MC(GC_GRAIN)|MC(GC_WOOD)|MC(GC_VALUABLES)|MC(GC_PAPER)|MC(GC_FOOD), - /* LT_DESERT: rainforest/desert */ - MC(GC_PASSENGERS)|MC(GC_MAIL)|MC(GC_OIL)|MC(GC_GOODS)|MC(GC_GRAIN)|MC(GC_WOOD)| - MC(GC_VALUABLES)|MC(GC_FOOD)|MC(GC_FRUIT)|MC(GC_COPPER_ORE)|MC(GC_WATER)|MC(GC_RUBBER), - /* LT_CANDY: toyland */ - MC(GC_PASSENGERS)|MC(GC_MAIL)|MC(GC_SUGAR)|MC(GC_TOYS)|MC(GC_BATTERIES)|MC(GC_CANDY)| - MC(GC_TOFFEE)|MC(GC_COLA)|MC(GC_COTTON_CANDY)|MC(GC_BUBBLES)|MC(GC_PLASTIC)|MC(GC_FIZZY_DRINKS) -}; -/** END --- TRANSLATE FROM GLOBAL CARGO TO LOCAL CARGO ID'S **/ - /** Bitmasked values of what type of cargo is refittable for the given vehicle-type. * This coupled with the landscape information (_landscape_global_cargo_mask) gives * us exactly what is refittable and what is not */ +#define MC(cargo) (1 << cargo) const uint32 _default_refitmasks[NUM_VEHICLE_TYPES] = { /* Trains */ MC(GC_PASSENGERS)|MC(GC_COAL)|MC(GC_MAIL)|MC(GC_LIVESTOCK)|MC(GC_GOODS)|MC(GC_GRAIN)|MC(GC_WOOD)|MC(GC_IRON_ORE)| @@ -95,21 +50,6 @@ const uint32 _default_refitmasks[NUM_VEHICLE_TYPES] = { /* Special/Disaster */ 0,0 }; - -/** - * Bitmask of classes for cargo types. - */ -const uint32 cargo_classes[16] = { - /* Passengers */ MC(GC_PASSENGERS), - /* Mail */ MC(GC_MAIL), - /* Express */ MC(GC_GOODS)|MC(GC_FOOD)|MC(GC_CANDY), - /* Armoured */ MC(GC_VALUABLES), - /* Bulk */ MC(GC_COAL)|MC(GC_GRAIN)|MC(GC_IRON_ORE)|MC(GC_COPPER_ORE)|MC(GC_FRUIT)|MC(GC_SUGAR)|MC(GC_TOFFEE)|MC(GC_COTTON_CANDY), - /* Piece */ MC(GC_LIVESTOCK)|MC(GC_WOOD)|MC(GC_STEEL)|MC(GC_PAPER)|MC(GC_TOYS)|MC(GC_BATTERIES)|MC(GC_BUBBLES)|MC(GC_FIZZY_DRINKS), - /* Liquids */ MC(GC_OIL)|MC(GC_WATER)|MC(GC_RUBBER)|MC(GC_COLA)|MC(GC_PLASTIC), - /* Chilled */ MC(GC_FOOD)|MC(GC_FRUIT), - /* Undefined */ 0, 0, 0, 0, 0, 0, 0, 0 -}; #undef MC void ShowEnginePreviewWindow(EngineID engine); @@ -124,48 +124,8 @@ enum { void AddTypeToEngines(void); void StartupEngines(void); -enum GlobalCargo { - GC_PASSENGERS = 0, - GC_COAL = 1, - GC_MAIL = 2, - GC_OIL = 3, - GC_LIVESTOCK = 4, - GC_GOODS = 5, - GC_GRAIN = 6, // GC_WHEAT / GC_MAIZE - GC_WOOD = 7, - GC_IRON_ORE = 8, - GC_STEEL = 9, - GC_VALUABLES = 10, // GC_GOLD / GC_DIAMONDS - GC_PAPER = 11, - GC_FOOD = 12, - GC_FRUIT = 13, - GC_COPPER_ORE = 14, - GC_WATER = 15, - GC_RUBBER = 16, - GC_SUGAR = 17, - GC_TOYS = 18, - GC_BATTERIES = 19, - GC_CANDY = 20, - GC_TOFFEE = 21, - GC_COLA = 22, - GC_COTTON_CANDY = 23, - GC_BUBBLES = 24, - GC_PLASTIC = 25, - GC_FIZZY_DRINKS = 26, - GC_PAPER_TEMP = 27, - GC_UNDEFINED = 28, // undefined; unused slot in arctic climate - GC_DEFAULT = 29, - GC_PURCHASE = 30, - GC_DEFAULT_NA = 31, // New stations only - GC_INVALID = 255, - NUM_GLOBAL_CID = 32 -}; VARDEF const uint32 _default_refitmasks[NUM_VEHICLE_TYPES]; -VARDEF const CargoID _global_cargo_id[NUM_LANDSCAPE][NUM_CARGO]; -VARDEF const uint32 _landscape_global_cargo_mask[NUM_LANDSCAPE]; -VARDEF const CargoID _local_cargo_id_ctype[NUM_GLOBAL_CID]; -VARDEF const uint32 cargo_classes[16]; void DrawTrainEngine(int x, int y, EngineID engine, uint32 image_ormod); void DrawRoadVehEngine(int x, int y, EngineID engine, uint32 image_ormod); diff --git a/newgrf_cargo.c b/newgrf_cargo.c new file mode 100644 index 000000000..f60e9839f --- /dev/null +++ b/newgrf_cargo.c @@ -0,0 +1,71 @@ + +#include "stdafx.h" +#include "openttd.h" +#include "newgrf_cargo.h" + +/** TRANSLATE FROM LOCAL CARGO TO GLOBAL CARGO ID'S. + * This maps the per-landscape cargo ID's to globally unique cargo ID's usable ie. in + * the custom GRF files. It is basically just a transcribed table from TTDPatch's newgrf.txt. + */ +const CargoID _global_cargo_id[NUM_LANDSCAPE][NUM_CARGO] = { + /* LT_NORMAL */ {GC_PASSENGERS, GC_COAL, GC_MAIL, GC_OIL, GC_LIVESTOCK, GC_GOODS, GC_GRAIN, GC_WOOD, GC_IRON_ORE, GC_STEEL, GC_VALUABLES, GC_PAPER_TEMP}, + /* LT_HILLY */ {GC_PASSENGERS, GC_COAL, GC_MAIL, GC_OIL, GC_LIVESTOCK, GC_GOODS, GC_GRAIN, GC_WOOD, GC_INVALID, GC_PAPER, GC_VALUABLES, GC_FOOD }, + /* LT_DESERT */ {GC_PASSENGERS, GC_RUBBER,GC_MAIL, GC_OIL, GC_FRUIT, GC_GOODS, GC_GRAIN, GC_WOOD, GC_COPPER_ORE, GC_WATER, GC_VALUABLES, GC_FOOD }, + /* LT_CANDY */ {GC_PASSENGERS, GC_SUGAR, GC_MAIL, GC_TOYS,GC_BATTERIES, GC_CANDY, GC_TOFFEE,GC_COLA, GC_COTTON_CANDY,GC_BUBBLES,GC_PLASTIC, GC_FIZZY_DRINKS }, + /** + * - GC_INVALID (255) means that cargo is not available for that climate + * - GC_PAPER_TEMP (27) is paper in temperate climate in TTDPatch + * Following can be renumbered: + * - GC_DEFAULT (29) is the defa ult cargo for the purpose of spritesets + * - GC_PURCHASE (30) is the purchase list image (the equivalent of 0xff) for the purpose of spritesets + */ +}; + +/** BEGIN --- TRANSLATE FROM GLOBAL CARGO TO LOCAL CARGO ID'S **/ +/** Map global cargo ID's to local-cargo ID's */ +const CargoID _local_cargo_id_ctype[NUM_GLOBAL_CID] = { + CT_PASSENGERS,CT_COAL, CT_MAIL, CT_OIL, CT_LIVESTOCK,CT_GOODS, CT_GRAIN, CT_WOOD, /* 0- 7 */ + CT_IRON_ORE, CT_STEEL, CT_VALUABLES, CT_PAPER, CT_FOOD, CT_FRUIT, CT_COPPER_ORE, CT_WATER, /* 8-15 */ + CT_RUBBER, CT_SUGAR, CT_TOYS, CT_BATTERIES,CT_CANDY, CT_TOFFEE, CT_COLA, CT_COTTON_CANDY, /* 16-23 */ + CT_BUBBLES, CT_PLASTIC,CT_FIZZY_DRINKS,CT_PAPER /* unsup. */,CT_HILLY_UNUSED, /* 24-28 */ + CT_INVALID, CT_INVALID /* 29-30 */ +}; + +/** Bitmasked value where the global cargo ID is available in landscape + * 0: LT_NORMAL, 1: LT_HILLY, 2: LT_DESERT, 3: LT_CANDY */ +#define MC(cargo) (1 << cargo) +const uint32 _landscape_global_cargo_mask[NUM_LANDSCAPE] = +{ /* LT_NORMAL: temperate */ + MC(GC_PASSENGERS)|MC(GC_COAL)|MC(GC_MAIL)|MC(GC_OIL)|MC(GC_LIVESTOCK)|MC(GC_GOODS)|MC(GC_GRAIN)|MC(GC_WOOD)| + MC(GC_IRON_ORE)|MC(GC_STEEL)|MC(GC_VALUABLES), + /* LT_HILLY: arctic */ + MC(GC_PASSENGERS)|MC(GC_COAL)|MC(GC_MAIL)|MC(GC_OIL)|MC(GC_LIVESTOCK)|MC(GC_GOODS)| + MC(GC_GRAIN)|MC(GC_WOOD)|MC(GC_VALUABLES)|MC(GC_PAPER)|MC(GC_FOOD), + /* LT_DESERT: rainforest/desert */ + MC(GC_PASSENGERS)|MC(GC_MAIL)|MC(GC_OIL)|MC(GC_GOODS)|MC(GC_GRAIN)|MC(GC_WOOD)| + MC(GC_VALUABLES)|MC(GC_FOOD)|MC(GC_FRUIT)|MC(GC_COPPER_ORE)|MC(GC_WATER)|MC(GC_RUBBER), + /* LT_CANDY: toyland */ + MC(GC_PASSENGERS)|MC(GC_MAIL)|MC(GC_SUGAR)|MC(GC_TOYS)|MC(GC_BATTERIES)|MC(GC_CANDY)| + MC(GC_TOFFEE)|MC(GC_COLA)|MC(GC_COTTON_CANDY)|MC(GC_BUBBLES)|MC(GC_PLASTIC)|MC(GC_FIZZY_DRINKS) +}; +/** END --- TRANSLATE FROM GLOBAL CARGO TO LOCAL CARGO ID'S **/ + +/** + * Bitmask of classes for cargo types. + */ +const uint32 cargo_classes[16] = { + /* Passengers */ MC(GC_PASSENGERS), + /* Mail */ MC(GC_MAIL), + /* Express */ MC(GC_GOODS)|MC(GC_FOOD)|MC(GC_CANDY), + /* Armoured */ MC(GC_VALUABLES), + /* Bulk */ MC(GC_COAL)|MC(GC_GRAIN)|MC(GC_IRON_ORE)|MC(GC_COPPER_ORE)|MC(GC_FRUIT)|MC(GC_SUGAR)|MC(GC_TOFFEE)|MC(GC_COTTON_CANDY), + /* Piece */ MC(GC_LIVESTOCK)|MC(GC_WOOD)|MC(GC_STEEL)|MC(GC_PAPER)|MC(GC_TOYS)|MC(GC_BATTERIES)|MC(GC_BUBBLES)|MC(GC_FIZZY_DRINKS), + /* Liquids */ MC(GC_OIL)|MC(GC_WATER)|MC(GC_RUBBER)|MC(GC_COLA)|MC(GC_PLASTIC), + /* Chilled */ MC(GC_FOOD)|MC(GC_FRUIT), + /* Undefined */ 0, 0, 0, 0, 0, 0, 0, 0 +}; +#undef MC + +/** + *there are 32 slots available per climate with newcargo.*/ +#define MAXSLOTS 32 diff --git a/newgrf_cargo.h b/newgrf_cargo.h new file mode 100644 index 000000000..a95d17396 --- /dev/null +++ b/newgrf_cargo.h @@ -0,0 +1,63 @@ +/* $Id$ */ + +#ifndef NEWGRF_CARGO_H +#define NEWGRF_CARGO_H + +#include "table/sprites.h" + + +enum { + CC_NOAVAILABLE = 0, + CC_PASSENGERS = 1 << 0, + CC_MAIL = 1 << 1, + CC_EXPRESS = 1 << 2, + CC_ARMOURED = 1 << 3, + CC_BULK = 1 << 4, + CC_PIECE_GOODS = 1 << 5, + CC_LIQUID = 1 << 6, + CC_REFRIGERATED = 1 << 7, +}; + +enum GlobalCargo { + GC_PASSENGERS = 0, + GC_COAL = 1, + GC_MAIL = 2, + GC_OIL = 3, + GC_LIVESTOCK = 4, + GC_GOODS = 5, + GC_GRAIN = 6, // GC_WHEAT / GC_MAIZE + GC_WOOD = 7, + GC_IRON_ORE = 8, + GC_STEEL = 9, + GC_VALUABLES = 10, // GC_GOLD / GC_DIAMONDS + GC_PAPER = 11, + GC_FOOD = 12, + GC_FRUIT = 13, + GC_COPPER_ORE = 14, + GC_WATER = 15, + GC_RUBBER = 16, + GC_SUGAR = 17, + GC_TOYS = 18, + GC_BATTERIES = 19, + GC_CANDY = 20, + GC_TOFFEE = 21, + GC_COLA = 22, + GC_COTTON_CANDY = 23, + GC_BUBBLES = 24, + GC_PLASTIC = 25, + GC_FIZZY_DRINKS = 26, + GC_PAPER_TEMP = 27, + GC_UNDEFINED = 28, // undefined; unused slot in arctic climate + GC_DEFAULT = 29, + GC_PURCHASE = 30, + GC_DEFAULT_NA = 31, // New stations only + GC_INVALID = 255, + NUM_GLOBAL_CID = 32 +}; + +VARDEF const CargoID _global_cargo_id[NUM_LANDSCAPE][NUM_CARGO]; +VARDEF const uint32 _landscape_global_cargo_mask[NUM_LANDSCAPE]; +VARDEF const CargoID _local_cargo_id_ctype[NUM_GLOBAL_CID]; +VARDEF const uint32 cargo_classes[16]; + +#endif /* NEWGRF_CARGO_H */ diff --git a/newgrf_engine.c b/newgrf_engine.c index c89dbd0a7..3a7773130 100644 --- a/newgrf_engine.c +++ b/newgrf_engine.c @@ -14,22 +14,9 @@ #include "newgrf_engine.h" #include "newgrf_station.h" #include "newgrf_spritegroup.h" +#include "newgrf_cargo.h" -/* XXX These tables should be moved / ripped out when newcargos is implemented. */ - -/* Cargo classes */ -enum { - CC_NONE = 0, - CC_PASSENGERS = 1 << 0, - CC_MAIL = 1 << 1, - CC_EXPRESS = 1 << 2, - CC_ARMOURED = 1 << 3, - CC_BULK = 1 << 4, - CC_PIECE_GOODS = 1 << 5, - CC_LIQUID = 1 << 6, - CC_REFRIGERATED = 1 << 7, -}; /* Default cargo classes */ static const uint16 _cargo_classes[NUM_GLOBAL_CID] = { @@ -61,9 +48,9 @@ static const uint16 _cargo_classes[NUM_GLOBAL_CID] = { CC_LIQUID, CC_PIECE_GOODS, CC_PIECE_GOODS, - CC_NONE, - CC_NONE, - CC_NONE, + CC_NOAVAILABLE, + CC_NOAVAILABLE, + CC_NOAVAILABLE, }; int _traininfo_vehicle_pitch = 0; diff --git a/newgrf_engine.h b/newgrf_engine.h index f41aad6c2..0e3d37697 100644 --- a/newgrf_engine.h +++ b/newgrf_engine.h @@ -4,6 +4,7 @@ #define NEWGRF_ENGINE_H #include "direction.h" +#include "newgrf_cargo.h" /** @file newgrf_engine.h */ @@ -12,10 +13,10 @@ extern int _traininfo_vehicle_pitch; extern int _traininfo_vehicle_width; VARDEF const uint32 _default_refitmasks[NUM_VEHICLE_TYPES]; -VARDEF const CargoID _global_cargo_id[NUM_LANDSCAPE][NUM_CARGO]; -VARDEF const uint32 _landscape_global_cargo_mask[NUM_LANDSCAPE]; -VARDEF const CargoID _local_cargo_id_ctype[NUM_GLOBAL_CID]; -VARDEF const uint32 cargo_classes[16]; +extern const CargoID _global_cargo_id[NUM_LANDSCAPE][NUM_CARGO]; +extern const uint32 _landscape_global_cargo_mask[NUM_LANDSCAPE]; +extern const CargoID _local_cargo_id_ctype[NUM_GLOBAL_CID]; +extern const uint32 cargo_classes[16]; void SetWagonOverrideSprites(EngineID engine, const struct SpriteGroup *group, byte *train_id, int trains); void SetCustomEngineSprites(EngineID engine, byte cargo, const struct SpriteGroup *group); diff --git a/newgrf_station.h b/newgrf_station.h index 284b80121..841b492be 100644 --- a/newgrf_station.h +++ b/newgrf_station.h @@ -6,6 +6,7 @@ #define NEWGRF_STATION_H #include "engine.h" +#include "newgrf_cargo.h" typedef enum { STAT_CLASS_DFLT, ///< Default station class. diff --git a/openttd.dsp b/openttd.dsp index 1cf407fc5..cefb68382 100644 --- a/openttd.dsp +++ b/openttd.dsp @@ -271,6 +271,10 @@ SOURCE=.\newgrf.c # End Source File
# Begin Source File
+SOURCE=.\newgrf_cargo.c
+# End Source File
+# Begin Source File
+
SOURCE=.\newgrf_engine.c
# End Source File
# Begin Source File
@@ -672,6 +676,10 @@ SOURCE=.\newgrf_callbacks.h # End Source File
# Begin Source File
+SOURCE=.\newgrf_cargo.h
+# End Source File
+# Begin Source File
+
SOURCE=.\newgrf_engine.h
# End Source File
# Begin Source File
diff --git a/openttd.vcproj b/openttd.vcproj index 4a82db4ee..4e390dd76 100644 --- a/openttd.vcproj +++ b/openttd.vcproj @@ -277,6 +277,9 @@ RelativePath=".\newgrf.c"> </File> <File + RelativePath=".\newgrf_cargo.c"> + </File> + <File RelativePath=".\newgrf_engine.c"> </File> <File @@ -503,6 +506,9 @@ RelativePath=".\newgrf_callbacks.h"> </File> <File + RelativePath=".\newgrf_cargo.h"> + </File> + <File RelativePath=".\newgrf_engine.h"> </File> <File |