src/cargotype.h
author celestar
Tue, 12 Jun 2007 11:56:35 +0000
branchgamebalance
changeset 9908 0fa543611bbe
parent 9906 6f41b8713b65
permissions -rw-r--r--
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
6417
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
     1
/* $Id$ */
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
     2
6449
e520244dc71e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6448
diff changeset
     3
/** @file cargotype.h */
e520244dc71e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6448
diff changeset
     4
6417
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
     5
#ifndef CARGOTYPE_H
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
     6
#define CARGOTYPE_H
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
     7
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
     8
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
     9
typedef uint32 CargoLabel;
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    10
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6474
diff changeset
    11
enum TownEffect {
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6474
diff changeset
    12
	TE_NONE,
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6474
diff changeset
    13
	TE_PASSENGERS,
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6474
diff changeset
    14
	TE_MAIL,
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6474
diff changeset
    15
	TE_GOODS,
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6474
diff changeset
    16
	TE_WATER,
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6474
diff changeset
    17
	TE_FOOD,
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6474
diff changeset
    18
};
6417
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    19
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6474
diff changeset
    20
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6474
diff changeset
    21
struct CargoSpec {
6417
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    22
	uint8 bitnum;
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    23
	CargoLabel label;
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    24
	uint32 grfid;
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    25
	uint8 legend_colour;
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    26
	uint8 rating_colour;
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    27
	uint8 weight;
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    28
	uint16 initial_payment;
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    29
	uint8 transit_days[2];
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    30
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    31
	bool is_freight;
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6474
diff changeset
    32
	TownEffect town_effect; ///< The effect this cargo type has on towns
6417
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    33
	uint16 multipliertowngrowth;
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9898
diff changeset
    34
	uint8 callback_mask;
6417
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    35
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    36
	StringID name;
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    37
	StringID name_plural;
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    38
	StringID units_volume;
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    39
	StringID quantifier;
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    40
	StringID abbrev;
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    41
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    42
	SpriteID sprite;
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    43
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    44
	uint16 classes;
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9898
diff changeset
    45
	const struct SpriteGroup *group;
6448
a749c78812a7 (svn r8858) -Codechange: Replace magic number test with class method for determining if a cargo is valid/active.
peter1138
parents: 6439
diff changeset
    46
a749c78812a7 (svn r8858) -Codechange: Replace magic number test with class method for determining if a cargo is valid/active.
peter1138
parents: 6439
diff changeset
    47
	bool IsValid() const;
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6474
diff changeset
    48
};
6417
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    49
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    50
6439
99a5807852b1 (svn r8849) -Codechange: Replace hardcoded global/climate cargo mapping tables with dynamically generated data. Change associated code to use new functions.
peter1138
parents: 6417
diff changeset
    51
extern uint32 _cargo_mask;
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9898
diff changeset
    52
extern CargoSpec _cargo[NUM_CARGO];
6439
99a5807852b1 (svn r8849) -Codechange: Replace hardcoded global/climate cargo mapping tables with dynamically generated data. Change associated code to use new functions.
peter1138
parents: 6417
diff changeset
    53
99a5807852b1 (svn r8849) -Codechange: Replace hardcoded global/climate cargo mapping tables with dynamically generated data. Change associated code to use new functions.
peter1138
parents: 6417
diff changeset
    54
6417
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    55
/* Set up the default cargo types for the given landscape type */
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    56
void SetupCargoForClimate(LandscapeID l);
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    57
/* Retrieve cargo details for the given cargo ID */
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    58
const CargoSpec *GetCargo(CargoID c);
6469
05a2e97144ec (svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents: 6449
diff changeset
    59
/* Get the cargo ID with the cargo label */
05a2e97144ec (svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents: 6449
diff changeset
    60
CargoID GetCargoIDByLabel(CargoLabel cl);
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
    61
CargoID GetCargoIDByBitnum(uint8 bitnum);
6439
99a5807852b1 (svn r8849) -Codechange: Replace hardcoded global/climate cargo mapping tables with dynamically generated data. Change associated code to use new functions.
peter1138
parents: 6417
diff changeset
    62
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6474
diff changeset
    63
static inline bool IsCargoInClass(CargoID c, uint16 cc)
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6474
diff changeset
    64
{
9898
324dad59eb35 (svn r9346) [gamebalance] -Fix: some MSVC fatal warnings (unary minus on unsigned, forcing int to bool), and errors (missing CDECL, missing file in MSVC projects)
KUDr
parents: 9895
diff changeset
    65
	return (GetCargo(c)->classes & cc) != 0;
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6474
diff changeset
    66
}
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6474
diff changeset
    67
6417
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    68
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
diff changeset
    69
#endif /* CARGOTYPE_H */