src/cargotype.h
author truebrain
Thu, 12 Jun 2008 21:18:09 +0000
branchnoai
changeset 10944 588393239ac6
parent 10455 22c441f5adf9
permissions -rw-r--r--
(svn r13498) [NoAI] -Add: added 'pathfinder.road' to the regression
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
10455
22c441f5adf9 (svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents: 10249
diff changeset
     3
/** @file cargotype.h Types/functions related to cargos. */
6449
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
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9686
diff changeset
     8
#include "cargo_type.h"
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9686
diff changeset
     9
#include "gfx_type.h"
10249
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents: 9826
diff changeset
    10
#include "strings_type.h"
10455
22c441f5adf9 (svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents: 10249
diff changeset
    11
#include "landscape_type.h"
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
    12
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
    13
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
    14
9476
1d1ed96f32ad (svn r9323) [NoAI] -Sync with trunk r9206:9322
truelight
parents: 6574
diff changeset
    15
enum TownEffect {
1d1ed96f32ad (svn r9323) [NoAI] -Sync with trunk r9206:9322
truelight
parents: 6574
diff changeset
    16
	TE_NONE,
1d1ed96f32ad (svn r9323) [NoAI] -Sync with trunk r9206:9322
truelight
parents: 6574
diff changeset
    17
	TE_PASSENGERS,
1d1ed96f32ad (svn r9323) [NoAI] -Sync with trunk r9206:9322
truelight
parents: 6574
diff changeset
    18
	TE_MAIL,
1d1ed96f32ad (svn r9323) [NoAI] -Sync with trunk r9206:9322
truelight
parents: 6574
diff changeset
    19
	TE_GOODS,
1d1ed96f32ad (svn r9323) [NoAI] -Sync with trunk r9206:9322
truelight
parents: 6574
diff changeset
    20
	TE_WATER,
1d1ed96f32ad (svn r9323) [NoAI] -Sync with trunk r9206:9322
truelight
parents: 6574
diff changeset
    21
	TE_FOOD,
1d1ed96f32ad (svn r9323) [NoAI] -Sync with trunk r9206:9322
truelight
parents: 6574
diff changeset
    22
};
1d1ed96f32ad (svn r9323) [NoAI] -Sync with trunk r9206:9322
truelight
parents: 6574
diff changeset
    23
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
    24
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6474
diff changeset
    25
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
    26
	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
    27
	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
    28
	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
    29
	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
    30
	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
    31
	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
    32
	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
    33
	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
    34
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
	bool is_freight;
9476
1d1ed96f32ad (svn r9323) [NoAI] -Sync with trunk r9206:9322
truelight
parents: 6574
diff changeset
    36
	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
    37
	uint16 multipliertowngrowth;
9517
be1775555bbd (svn r9431) [NoAI] -Sync with trunk r9394:9430
truelight
parents: 9493
diff changeset
    38
	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
    39
10249
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents: 9826
diff changeset
    40
	StringID name;
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents: 9826
diff changeset
    41
	StringID name_single;
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents: 9826
diff changeset
    42
	StringID units_volume;
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents: 9826
diff changeset
    43
	StringID quantifier;
58810805030e (svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents: 9826
diff changeset
    44
	StringID abbrev;
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
    45
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
    46
	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
    47
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
    48
	uint16 classes;
9517
be1775555bbd (svn r9431) [NoAI] -Sync with trunk r9394:9430
truelight
parents: 9493
diff changeset
    49
	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
    50
a749c78812a7 (svn r8858) -Codechange: Replace magic number test with class method for determining if a cargo is valid/active.
peter1138
parents: 6439
diff changeset
    51
	bool IsValid() const;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6474
diff changeset
    52
};
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
    53
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
    54
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
    55
extern uint32 _cargo_mask;
9517
be1775555bbd (svn r9431) [NoAI] -Sync with trunk r9394:9430
truelight
parents: 9493
diff changeset
    56
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
    57
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
    58
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
    59
/* 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
    60
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
    61
/* 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
    62
const CargoSpec *GetCargo(CargoID c);
9826
9707ad4c9b60 (svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents: 9724
diff changeset
    63
/* Get the cargo icon for a given cargo ID */
9707ad4c9b60 (svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents: 9724
diff changeset
    64
SpriteID GetCargoSprite(CargoID i);
6469
05a2e97144ec (svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents: 6449
diff changeset
    65
/* 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
    66
CargoID GetCargoIDByLabel(CargoLabel cl);
9599
949374e83b78 (svn r9632) [NoAI] -Sync with trunk r9574:9631.
rubidium
parents: 9517
diff changeset
    67
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
    68
9476
1d1ed96f32ad (svn r9323) [NoAI] -Sync with trunk r9206:9322
truelight
parents: 6574
diff changeset
    69
static inline bool IsCargoInClass(CargoID c, uint16 cc)
1d1ed96f32ad (svn r9323) [NoAI] -Sync with trunk r9206:9322
truelight
parents: 6574
diff changeset
    70
{
9493
b38bfff5f3a3 (svn r9363) [NoAI] -Sync with trunk r9322:9362
truelight
parents: 9476
diff changeset
    71
	return (GetCargo(c)->classes & cc) != 0;
9476
1d1ed96f32ad (svn r9323) [NoAI] -Sync with trunk r9206:9322
truelight
parents: 6574
diff changeset
    72
}
1d1ed96f32ad (svn r9323) [NoAI] -Sync with trunk r9206:9322
truelight
parents: 6574
diff changeset
    73
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
    74
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
    75
#endif /* CARGOTYPE_H */