summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2010-11-06 12:39:18 +0000
committerterkhen <terkhen@openttd.org>2010-11-06 12:39:18 +0000
commitd699c4a345503df0147de80c7462376f7ff130da (patch)
treee6a3d30744d8b08389bc7826ad77f25e78a4f547 /src
parent8eb3d653da176d4bd4b966065965001d18e37e90 (diff)
downloadopenttd-d699c4a345503df0147de80c7462376f7ff130da.tar.xz
(svn r21091) -Codechange: Add bit constants for checking NewGRFCache validity.
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_engine.cpp16
-rw-r--r--src/vehicle_base.h8
2 files changed, 16 insertions, 8 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 453856ab2..33479cabd 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -512,21 +512,21 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
return GetEngineGRFID(v->engine_type);
case 0x40: // Get length of consist
- if (!HasBit(v->grf_cache.cache_valid, 0)) {
+ if (!HasBit(v->grf_cache.cache_valid, NCVV_POSITION_CONSIST_LENGTH)) {
v->grf_cache.position_consist_length = PositionHelper(v, false);
- SetBit(v->grf_cache.cache_valid, 0);
+ SetBit(v->grf_cache.cache_valid, NCVV_POSITION_CONSIST_LENGTH);
}
return v->grf_cache.position_consist_length;
case 0x41: // Get length of same consecutive wagons
- if (!HasBit(v->grf_cache.cache_valid, 1)) {
+ if (!HasBit(v->grf_cache.cache_valid, NCVV_POSITION_SAME_ID_LENGTH)) {
v->grf_cache.position_same_id_length = PositionHelper(v, true);
- SetBit(v->grf_cache.cache_valid, 1);
+ SetBit(v->grf_cache.cache_valid, NCVV_POSITION_SAME_ID_LENGTH);
}
return v->grf_cache.position_same_id_length;
case 0x42: // Consist cargo information
- if (!HasBit(v->grf_cache.cache_valid, 2)) {
+ if (!HasBit(v->grf_cache.cache_valid, NCVV_CONSIST_CARGO_INFORMATION)) {
const Vehicle *u;
byte cargo_classes = 0;
uint8 common_cargos[NUM_CARGO];
@@ -577,14 +577,14 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
uint8 common_bitnum = (common_cargo_type == CT_INVALID ? 0xFF : CargoSpec::Get(common_cargo_type)->bitnum);
v->grf_cache.consist_cargo_information = cargo_classes | (common_bitnum << 8) | (common_subtype << 16) | (user_def_data << 24);
- SetBit(v->grf_cache.cache_valid, 2);
+ SetBit(v->grf_cache.cache_valid, NCVV_CONSIST_CARGO_INFORMATION);
}
return v->grf_cache.consist_cargo_information;
case 0x43: // Company information
- if (!HasBit(v->grf_cache.cache_valid, 3)) {
+ if (!HasBit(v->grf_cache.cache_valid, NCVV_COMPANY_INFORMATION)) {
v->grf_cache.company_information = v->owner | (Company::IsHumanID(v->owner) ? 0 : 0x10000) | (LiveryHelper(v->engine_type, v) << 24);
- SetBit(v->grf_cache.cache_valid, 3);
+ SetBit(v->grf_cache.cache_valid, NCVV_COMPANY_INFORMATION);
}
return v->grf_cache.company_information;
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index 1c794cb09..13f71c1c7 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -46,6 +46,14 @@ enum VehicleFlags {
VF_STOP_LOADING, ///< Don't load anymore during the next load cycle.
};
+/** Bit numbers used to indicate which of the #NewGRFCache values are valid. */
+enum NewGRFCacheValidValues {
+ NCVV_POSITION_CONSIST_LENGTH = 0, ///< This bit will be set if the NewGRF var 40 currently stored is valid.
+ NCVV_POSITION_SAME_ID_LENGTH = 1, ///< This bit will be set if the NewGRF var 41 currently stored is valid.
+ NCVV_CONSIST_CARGO_INFORMATION = 2, ///< This bit will be set if the NewGRF var 42 currently stored is valid.
+ NCVV_COMPANY_INFORMATION = 3, ///< This bit will be set if the NewGRF var 43 currently stored is valid.
+};
+
/** Cached often queried (NewGRF) values */
struct NewGRFCache {
/* Values calculated when they are requested for the first time after invalidating the NewGRF cache. */