Files
@ r13177:b124129e2270
Branch filter:
Location: cpp/openttd-patchpack/source/src/cargotype.h - annotation
r13177:b124129e2270
3.3 KiB
text/x-c
(svn r17694) -Codechange: don't break $ to two lines in squirrel_export.awk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | r6091:2faa7d307565 r6091:2faa7d307565 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r9111:983de9c5a848 r6123:049e9624d068 r6091:2faa7d307565 r6091:2faa7d307565 r6091:2faa7d307565 r12932:8c04eed8b65b r8119:8fdb3a371896 r8123:dde0a9a84019 r8959:484dbfc31293 r9126:35955a7b9d9e r6091:2faa7d307565 r6091:2faa7d307565 r6091:2faa7d307565 r6311:78f38fcd68ca r6311:78f38fcd68ca r6311:78f38fcd68ca r6311:78f38fcd68ca r6311:78f38fcd68ca r6311:78f38fcd68ca r6311:78f38fcd68ca r6311:78f38fcd68ca r6311:78f38fcd68ca r6091:2faa7d307565 r12236:ae676539361d r12236:ae676539361d r6248:b940b09d7ab8 r6091:2faa7d307565 r6091:2faa7d307565 r6091:2faa7d307565 r6091:2faa7d307565 r6091:2faa7d307565 r6091:2faa7d307565 r6091:2faa7d307565 r6091:2faa7d307565 r6091:2faa7d307565 r6311:78f38fcd68ca r6091:2faa7d307565 r13026:0c3f00ec0a74 r6091:2faa7d307565 r8959:484dbfc31293 r8959:484dbfc31293 r8959:484dbfc31293 r8959:484dbfc31293 r8959:484dbfc31293 r6091:2faa7d307565 r6091:2faa7d307565 r6091:2faa7d307565 r6091:2faa7d307565 r9750:1e2535e15958 r6365:410001496130 r6122:508316e17f8e r12932:8c04eed8b65b r12932:8c04eed8b65b r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12236:ae676539361d r12236:ae676539361d r12236:ae676539361d r12405:ba094e765533 r12405:ba094e765533 r12409:5f538763905f r12409:5f538763905f r12405:ba094e765533 r12408:d7d52eed8c09 r12405:ba094e765533 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12405:ba094e765533 r12405:ba094e765533 r12405:ba094e765533 r12409:5f538763905f r12405:ba094e765533 r12405:ba094e765533 r6248:b940b09d7ab8 r6091:2faa7d307565 r6113:c77736e8b915 r6113:c77736e8b915 r6091:2faa7d307565 r6091:2faa7d307565 r8762:2da4ffd55f31 r8762:2da4ffd55f31 r6143:9ed364174dfd r6143:9ed364174dfd r6460:74b53af67ae0 r6113:c77736e8b915 r12405:ba094e765533 r12236:ae676539361d r12405:ba094e765533 r12236:ae676539361d r12236:ae676539361d r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r12408:d7d52eed8c09 r6091:2faa7d307565 | /* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file cargotype.h Types/functions related to cargos. */
#ifndef CARGOTYPE_H
#define CARGOTYPE_H
#include "economy_type.h"
#include "cargo_type.h"
#include "gfx_type.h"
#include "strings_type.h"
#include "landscape_type.h"
typedef uint32 CargoLabel;
enum TownEffect {
TE_NONE,
TE_PASSENGERS,
TE_MAIL,
TE_GOODS,
TE_WATER,
TE_FOOD,
};
static const byte INVALID_CARGO = 0xFF;
struct CargoSpec {
uint8 bitnum;
CargoLabel label;
uint8 legend_colour;
uint8 rating_colour;
uint8 weight;
uint16 initial_payment;
uint8 transit_days[2];
bool is_freight;
TownEffect town_effect; ///< The effect this cargo type has on towns
uint16 multipliertowngrowth;
uint8 callback_mask; ///< Bitmask of cargo callbacks that have to be called
StringID name;
StringID name_single;
StringID units_volume;
StringID quantifier;
StringID abbrev;
SpriteID sprite;
uint16 classes;
const struct GRFFile *grffile; ///< NewGRF where 'group' belongs to
const struct SpriteGroup *group;
Money current_payment;
/**
* Determines index of this cargospec
* @return index (in the CargoSpec::array array)
*/
FORCEINLINE CargoID Index() const
{
return this - CargoSpec::array;
}
/**
* Tests for validity of this cargospec
* @return is this cargospec valid?
* @note assert(cs->IsValid()) can be triggered when GRF config is modified
*/
FORCEINLINE bool IsValid() const
{
return this->bitnum != INVALID_CARGO;
}
/**
* Total number of cargospecs, both valid and invalid
* @return length of CargoSpec::array
*/
static FORCEINLINE size_t GetArraySize()
{
return lengthof(CargoSpec::array);
}
/**
* Retrieve cargo details for the given cargo ID
* @param index ID of cargo
* @pre index is a valid cargo ID
*/
static FORCEINLINE CargoSpec *Get(size_t index)
{
assert(index < lengthof(CargoSpec::array));
return &CargoSpec::array[index];
}
private:
static CargoSpec array[NUM_CARGO]; ///< Array holding all CargoSpecs
friend void SetupCargoForClimate(LandscapeID l);
};
extern uint32 _cargo_mask;
/* Set up the default cargo types for the given landscape type */
void SetupCargoForClimate(LandscapeID l);
/* Get the cargo icon for a given cargo ID */
SpriteID GetCargoSprite(CargoID i);
/* Get the cargo ID with the cargo label */
CargoID GetCargoIDByLabel(CargoLabel cl);
CargoID GetCargoIDByBitnum(uint8 bitnum);
static inline bool IsCargoInClass(CargoID c, uint16 cc)
{
return (CargoSpec::Get(c)->classes & cc) != 0;
}
#define FOR_ALL_CARGOSPECS_FROM(var, start) for (size_t cargospec_index = start; var = NULL, cargospec_index < CargoSpec::GetArraySize(); cargospec_index++) \
if ((var = CargoSpec::Get(cargospec_index))->IsValid())
#define FOR_ALL_CARGOSPECS(var) FOR_ALL_CARGOSPECS_FROM(var, 0)
#endif /* CARGOTYPE_H */
|