newgrf_cargo.c
author bjarni
Wed, 04 Oct 2006 12:01:59 +0000
changeset 4725 40cccaaa042c
parent 4344 7e123fec5b0b
permissions -rw-r--r--
(svn r6637) -Codechange: merged all (vehicle type)EnterDepot into VehicleEnterDepot()
This revealed duplicated code like aircraft lists got invalidated twice
Moved invalidation of the vehicle detail window to VehicleServiceInDepot() as it should always be updated when serviced
3867
fc05c6b14ff0 (svn r4903) CodeChange : forgot the Id tag. Sorry
belugas
parents: 3866
diff changeset
     1
/* $Id$ */
3866
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
     2
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
     3
#include "stdafx.h"
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
     4
#include "openttd.h"
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
     5
#include "newgrf_cargo.h"
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
     6
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
     7
/** TRANSLATE FROM LOCAL CARGO TO GLOBAL CARGO ID'S.
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
     8
 * This maps the per-landscape cargo ID's to globally unique cargo ID's usable ie. in
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
     9
 * the custom GRF  files. It is basically just a transcribed table from TTDPatch's newgrf.txt.
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    10
 */
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    11
const CargoID _global_cargo_id[NUM_LANDSCAPE][NUM_CARGO] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 3867
diff changeset
    12
	/* 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},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 3867
diff changeset
    13
	/* 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 },
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 3867
diff changeset
    14
	/* 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 },
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 3867
diff changeset
    15
	/* 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 },
3866
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    16
	/**
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    17
	 * - GC_INVALID (255) means that  cargo is not available for that climate
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    18
	 * - GC_PAPER_TEMP (27) is paper in  temperate climate in TTDPatch
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    19
	 * Following can  be renumbered:
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    20
	 * - GC_DEFAULT (29) is the defa ult cargo for the purpose of spritesets
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    21
	 * - GC_PURCHASE (30) is the purchase list image (the equivalent of 0xff) for the purpose of spritesets
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    22
	 */
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    23
};
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    24
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    25
/** BEGIN --- TRANSLATE FROM GLOBAL CARGO TO LOCAL CARGO ID'S **/
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    26
/** Map global cargo ID's to local-cargo ID's */
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    27
const CargoID _local_cargo_id_ctype[NUM_GLOBAL_CID] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 3867
diff changeset
    28
	CT_PASSENGERS, CT_COAL,    CT_MAIL,         CT_OIL,       CT_LIVESTOCK, CT_GOODS,  CT_GRAIN,      CT_WOOD,         /*  0- 7 */
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 3867
diff changeset
    29
	CT_IRON_ORE,   CT_STEEL,   CT_VALUABLES,    CT_PAPER,     CT_FOOD,      CT_FRUIT,  CT_COPPER_ORE, CT_WATER,        /*  8-15 */
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 3867
diff changeset
    30
	CT_RUBBER,     CT_SUGAR,   CT_TOYS,         CT_BATTERIES, CT_CANDY,     CT_TOFFEE, CT_COLA,       CT_COTTON_CANDY, /* 16-23 */
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 3867
diff changeset
    31
	CT_BUBBLES,    CT_PLASTIC, CT_FIZZY_DRINKS, CT_PAPER      /* unsup. */, CT_HILLY_UNUSED,                           /* 24-28 */
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 3867
diff changeset
    32
	CT_INVALID,    CT_INVALID                                                                                          /* 29-30 */
3866
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    33
};
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    34
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    35
/** Bitmasked value where the global cargo ID is available in landscape
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    36
 * 0: LT_NORMAL, 1: LT_HILLY, 2: LT_DESERT, 3: LT_CANDY */
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    37
#define MC(cargo) (1 << cargo)
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    38
const uint32 _landscape_global_cargo_mask[NUM_LANDSCAPE] =
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    39
{ /* LT_NORMAL: temperate */
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 3867
diff changeset
    40
	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),
3866
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    41
	/* LT_HILLY: arctic */
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 3867
diff changeset
    42
	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),
3866
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    43
	/* LT_DESERT: rainforest/desert */
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 3867
diff changeset
    44
	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),
3866
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    45
	/* LT_CANDY: toyland */
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 3867
diff changeset
    46
	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)
3866
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    47
};
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    48
/** END   --- TRANSLATE FROM GLOBAL CARGO TO LOCAL CARGO ID'S **/
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    49
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    50
/**
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    51
 * Bitmask of classes for cargo types.
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    52
 */
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    53
const uint32 cargo_classes[16] = {
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    54
	/* Passengers */ MC(GC_PASSENGERS),
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    55
	/* Mail       */ MC(GC_MAIL),
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 3867
diff changeset
    56
	/* Express    */ MC(GC_GOODS)     | MC(GC_FOOD)  | MC(GC_CANDY),
3866
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    57
	/* Armoured   */ MC(GC_VALUABLES),
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 3867
diff changeset
    58
	/* 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),
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 3867
diff changeset
    59
	/* 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),
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 3867
diff changeset
    60
	/* Liquids    */ MC(GC_OIL)       | MC(GC_WATER) | MC(GC_RUBBER)   | MC(GC_COLA)       | MC(GC_PLASTIC),
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 3867
diff changeset
    61
	/* Chilled    */ MC(GC_FOOD)      | MC(GC_FRUIT),
3866
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    62
	/* Undefined  */ 0, 0, 0, 0, 0, 0, 0, 0
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    63
};
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    64
#undef MC
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    65
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    66
/**
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    67
 *there are 32 slots available per climate with newcargo.*/
b13553406a0a (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
diff changeset
    68
#define MAXSLOTS 32