src/cargotype.h
author terom@frrb.lan
Fri, 19 Dec 2008 01:32:07 +0200
changeset 10438 51bff16a04c9
parent 9750 7114408dd1fa
permissions -rw-r--r--
initial mini-map stuff
6091
c8827d9ae04a (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$ */
c8827d9ae04a (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
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8959
diff changeset
     3
/** @file cargotype.h Types/functions related to cargos. */
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6122
diff changeset
     4
6091
c8827d9ae04a (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
c8827d9ae04a (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
c8827d9ae04a (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
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 7287
diff changeset
     8
#include "cargo_type.h"
8123
ce31d2843a95 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8119
diff changeset
     9
#include "gfx_type.h"
8959
636d242edd89 (svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents: 8762
diff changeset
    10
#include "strings_type.h"
9126
5648d696456b (svn r12986) -Codechange: move the landscape and transport related types from openttd.h to their own headers.
rubidium
parents: 9111
diff changeset
    11
#include "landscape_type.h"
6091
c8827d9ae04a (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
c8827d9ae04a (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;
c8827d9ae04a (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
6311
5e4d7deb256b (svn r9236) -Codechange: Add 'town effect' attribute to cargo types. This will be used to specify how the cargo behaves wrt towns, instead of relying on fixed cargo IDs.
peter1138
parents: 6248
diff changeset
    15
enum TownEffect {
5e4d7deb256b (svn r9236) -Codechange: Add 'town effect' attribute to cargo types. This will be used to specify how the cargo behaves wrt towns, instead of relying on fixed cargo IDs.
peter1138
parents: 6248
diff changeset
    16
	TE_NONE,
5e4d7deb256b (svn r9236) -Codechange: Add 'town effect' attribute to cargo types. This will be used to specify how the cargo behaves wrt towns, instead of relying on fixed cargo IDs.
peter1138
parents: 6248
diff changeset
    17
	TE_PASSENGERS,
5e4d7deb256b (svn r9236) -Codechange: Add 'town effect' attribute to cargo types. This will be used to specify how the cargo behaves wrt towns, instead of relying on fixed cargo IDs.
peter1138
parents: 6248
diff changeset
    18
	TE_MAIL,
5e4d7deb256b (svn r9236) -Codechange: Add 'town effect' attribute to cargo types. This will be used to specify how the cargo behaves wrt towns, instead of relying on fixed cargo IDs.
peter1138
parents: 6248
diff changeset
    19
	TE_GOODS,
5e4d7deb256b (svn r9236) -Codechange: Add 'town effect' attribute to cargo types. This will be used to specify how the cargo behaves wrt towns, instead of relying on fixed cargo IDs.
peter1138
parents: 6248
diff changeset
    20
	TE_WATER,
5e4d7deb256b (svn r9236) -Codechange: Add 'town effect' attribute to cargo types. This will be used to specify how the cargo behaves wrt towns, instead of relying on fixed cargo IDs.
peter1138
parents: 6248
diff changeset
    21
	TE_FOOD,
5e4d7deb256b (svn r9236) -Codechange: Add 'town effect' attribute to cargo types. This will be used to specify how the cargo behaves wrt towns, instead of relying on fixed cargo IDs.
peter1138
parents: 6248
diff changeset
    22
};
5e4d7deb256b (svn r9236) -Codechange: Add 'town effect' attribute to cargo types. This will be used to specify how the cargo behaves wrt towns, instead of relying on fixed cargo IDs.
peter1138
parents: 6248
diff changeset
    23
6091
c8827d9ae04a (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
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6148
diff changeset
    25
struct CargoSpec {
6091
c8827d9ae04a (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;
c8827d9ae04a (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;
c8827d9ae04a (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
	uint8 legend_colour;
c8827d9ae04a (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 rating_colour;
c8827d9ae04a (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 weight;
c8827d9ae04a (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
	uint16 initial_payment;
c8827d9ae04a (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
	uint8 transit_days[2];
c8827d9ae04a (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
c8827d9ae04a (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
	bool is_freight;
6311
5e4d7deb256b (svn r9236) -Codechange: Add 'town effect' attribute to cargo types. This will be used to specify how the cargo behaves wrt towns, instead of relying on fixed cargo IDs.
peter1138
parents: 6248
diff changeset
    35
	TownEffect town_effect; ///< The effect this cargo type has on towns
6091
c8827d9ae04a (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
	uint16 multipliertowngrowth;
6359
8527262c4cf8 (svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents: 6335
diff changeset
    37
	uint8 callback_mask;
6091
c8827d9ae04a (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
8959
636d242edd89 (svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents: 8762
diff changeset
    39
	StringID name;
636d242edd89 (svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents: 8762
diff changeset
    40
	StringID name_single;
636d242edd89 (svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents: 8762
diff changeset
    41
	StringID units_volume;
636d242edd89 (svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents: 8762
diff changeset
    42
	StringID quantifier;
636d242edd89 (svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents: 8762
diff changeset
    43
	StringID abbrev;
6091
c8827d9ae04a (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
c8827d9ae04a (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
	SpriteID sprite;
c8827d9ae04a (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
c8827d9ae04a (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
	uint16 classes;
9750
7114408dd1fa (svn r13885) -Fix [FS#2168]: Var 0x7F is not feature-specific.
frosch
parents: 9126
diff changeset
    48
	const struct GRFFile *grffile;   ///< NewGRF where 'group' belongs to
6365
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents: 6359
diff changeset
    49
	const struct SpriteGroup *group;
6122
3359af5a1f54 (svn r8858) -Codechange: Replace magic number test with class method for determining if a cargo is valid/active.
peter1138
parents: 6113
diff changeset
    50
3359af5a1f54 (svn r8858) -Codechange: Replace magic number test with class method for determining if a cargo is valid/active.
peter1138
parents: 6113
diff changeset
    51
	bool IsValid() const;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6148
diff changeset
    52
};
6091
c8827d9ae04a (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
c8827d9ae04a (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
6113
a10ede03ac58 (svn r8849) -Codechange: Replace hardcoded global/climate cargo mapping tables with dynamically generated data. Change associated code to use new functions.
peter1138
parents: 6091
diff changeset
    55
extern uint32 _cargo_mask;
6359
8527262c4cf8 (svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents: 6335
diff changeset
    56
extern CargoSpec _cargo[NUM_CARGO];
6113
a10ede03ac58 (svn r8849) -Codechange: Replace hardcoded global/climate cargo mapping tables with dynamically generated data. Change associated code to use new functions.
peter1138
parents: 6091
diff changeset
    57
a10ede03ac58 (svn r8849) -Codechange: Replace hardcoded global/climate cargo mapping tables with dynamically generated data. Change associated code to use new functions.
peter1138
parents: 6091
diff changeset
    58
6091
c8827d9ae04a (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 */
c8827d9ae04a (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);
c8827d9ae04a (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 */
c8827d9ae04a (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);
8762
bbe195577e21 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents: 8298
diff changeset
    63
/* Get the cargo icon for a given cargo ID */
bbe195577e21 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents: 8298
diff changeset
    64
SpriteID GetCargoSprite(CargoID i);
6143
dbca54e64e01 (svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents: 6123
diff changeset
    65
/* Get the cargo ID with the cargo label */
dbca54e64e01 (svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents: 6123
diff changeset
    66
CargoID GetCargoIDByLabel(CargoLabel cl);
6460
705fbddbf3dc (svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138
parents: 6365
diff changeset
    67
CargoID GetCargoIDByBitnum(uint8 bitnum);
6113
a10ede03ac58 (svn r8849) -Codechange: Replace hardcoded global/climate cargo mapping tables with dynamically generated data. Change associated code to use new functions.
peter1138
parents: 6091
diff changeset
    68
6329
a492d5e61d7b (svn r9301) -Codechange: Use cargo class to determine if a road vehicle can stop in bus or truck stops.
peter1138
parents: 6311
diff changeset
    69
static inline bool IsCargoInClass(CargoID c, uint16 cc)
a492d5e61d7b (svn r9301) -Codechange: Use cargo class to determine if a road vehicle can stop in bus or truck stops.
peter1138
parents: 6311
diff changeset
    70
{
6335
4a4307dcc346 (svn r9327) -Fix (r9301): Fix warning on MSVC
peter1138
parents: 6329
diff changeset
    71
	return (GetCargo(c)->classes & cc) != 0;
6329
a492d5e61d7b (svn r9301) -Codechange: Use cargo class to determine if a road vehicle can stop in bus or truck stops.
peter1138
parents: 6311
diff changeset
    72
}
a492d5e61d7b (svn r9301) -Codechange: Use cargo class to determine if a road vehicle can stop in bus or truck stops.
peter1138
parents: 6311
diff changeset
    73
6091
c8827d9ae04a (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
c8827d9ae04a (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 */