summaryrefslogtreecommitdiff
path: root/src/cargotype.h
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-07-16 19:00:13 +0000
committersmatz <smatz@openttd.org>2009-07-16 19:00:13 +0000
commit1f29e38b8372484d51d852b89fc957eb53635ecb (patch)
treeda4a251ac74e87e72a2857233069790f991914f6 /src/cargotype.h
parentb6889daf8d11b083358a26eea3f633942e2e50e4 (diff)
downloadopenttd-1f29e38b8372484d51d852b89fc957eb53635ecb.tar.xz
(svn r16849) -Codechange: replace GetCargo() by CargoSpec::Get()
Diffstat (limited to 'src/cargotype.h')
-rw-r--r--src/cargotype.h31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/cargotype.h b/src/cargotype.h
index da17c1ada..d7e1b507c 100644
--- a/src/cargotype.h
+++ b/src/cargotype.h
@@ -54,11 +54,27 @@ struct CargoSpec {
{
return this->bitnum != INVALID_CARGO;
}
+
+ /**
+ * Retrieve cargo details for the given cargo ID
+ * @param c ID of cargo
+ * @pre c is a valid cargo ID
+ */
+ static CargoSpec *Get(CargoID c)
+ {
+ assert(c < lengthof(CargoSpec::cargo));
+ return &CargoSpec::cargo[c];
+ }
+
+private:
+ static CargoSpec cargo[NUM_CARGO];
+
+ friend void SetupCargoForClimate(LandscapeID l);
+ friend CargoID GetCargoIDByLabel(CargoLabel cl);
+ friend CargoID GetCargoIDByBitnum(uint8 bitnum);
};
extern uint32 _cargo_mask;
-extern CargoSpec _cargo[NUM_CARGO];
-
/* Set up the default cargo types for the given landscape type */
void SetupCargoForClimate(LandscapeID l);
@@ -68,18 +84,9 @@ SpriteID GetCargoSprite(CargoID i);
CargoID GetCargoIDByLabel(CargoLabel cl);
CargoID GetCargoIDByBitnum(uint8 bitnum);
-/* Retrieve cargo details for the given cargo ID */
-static inline const CargoSpec *GetCargo(CargoID c)
-{
- assert(c < lengthof(_cargo));
- return &_cargo[c];
-}
-
-
static inline bool IsCargoInClass(CargoID c, uint16 cc)
{
- return (GetCargo(c)->classes & cc) != 0;
+ return (CargoSpec::Get(c)->classes & cc) != 0;
}
-
#endif /* CARGOTYPE_H */