summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/newgrf_airport.cpp15
-rw-r--r--src/newgrf_airporttiles.cpp2
-rw-r--r--src/newgrf_industries.cpp15
-rw-r--r--src/newgrf_industrytiles.cpp15
-rw-r--r--src/newgrf_spritegroup.cpp2
-rw-r--r--src/newgrf_spritegroup.h3
6 files changed, 45 insertions, 7 deletions
diff --git a/src/newgrf_airport.cpp b/src/newgrf_airport.cpp
index 3d65b37c1..6a893180d 100644
--- a/src/newgrf_airport.cpp
+++ b/src/newgrf_airport.cpp
@@ -184,6 +184,19 @@ static void AirportSetTriggers(const ResolverObject *object, int triggers)
{
}
+/**
+ * Store a value into the object's persistent storage.
+ * @param object Object that we want to query.
+ * @param pos Position in the persistent storage to use.
+ * @param value Value to store.
+ */
+void AirportStorePSA(ResolverObject *object, uint pos, int32 value)
+{
+ Station *st = object->u.airport.st;
+ if (object->scope != VSG_SCOPE_SELF || st == NULL) return;
+ st->airport.psa.Store(pos, value);
+}
+
static void NewAirportResolver(ResolverObject *res, TileIndex tile, Station *st, byte airport_id, byte layout)
{
res->GetRandomBits = AirportGetRandomBits;
@@ -191,8 +204,8 @@ static void NewAirportResolver(ResolverObject *res, TileIndex tile, Station *st,
res->SetTriggers = AirportSetTriggers;
res->GetVariable = AirportGetVariable;
res->ResolveReal = AirportResolveReal;
+ res->StorePSA = AirportStorePSA;
- res->psa = st != NULL ? &st->airport.psa : NULL;
res->u.airport.st = st;
res->u.airport.airport_id = airport_id;
res->u.airport.layout = layout;
diff --git a/src/newgrf_airporttiles.cpp b/src/newgrf_airporttiles.cpp
index 0c029d9c4..ae387138a 100644
--- a/src/newgrf_airporttiles.cpp
+++ b/src/newgrf_airporttiles.cpp
@@ -228,9 +228,9 @@ static void AirportTileResolver(ResolverObject *res, const AirportTileSpec *ats,
res->SetTriggers = NULL;
res->GetVariable = AirportTileGetVariable;
res->ResolveReal = AirportTileResolveReal;
+ res->StorePSA = NULL;
assert(st != NULL);
- res->psa = NULL;
res->u.airport.airport_id = st->airport.type;
res->u.airport.st = st;
res->u.airport.tile = tile;
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp
index b17c5a8d2..22c20495f 100644
--- a/src/newgrf_industries.cpp
+++ b/src/newgrf_industries.cpp
@@ -376,6 +376,19 @@ static void IndustrySetTriggers(const ResolverObject *object, int triggers)
ind->random_triggers = triggers;
}
+/**
+ * Store a value into the object's persistent storage.
+ * @param object Object that we want to query.
+ * @param pos Position in the persistent storage to use.
+ * @param value Value to store.
+ */
+void IndustryStorePSA(ResolverObject *object, uint pos, int32 value)
+{
+ Industry *ind = object->u.industry.ind;
+ if (object->scope != VSG_SCOPE_SELF || ind->index == INVALID_INDUSTRY) return;
+ ind->psa.Store(pos, value);
+}
+
static void NewIndustryResolver(ResolverObject *res, TileIndex tile, Industry *indus, IndustryType type)
{
res->GetRandomBits = IndustryGetRandomBits;
@@ -383,8 +396,8 @@ static void NewIndustryResolver(ResolverObject *res, TileIndex tile, Industry *i
res->SetTriggers = IndustrySetTriggers;
res->GetVariable = IndustryGetVariable;
res->ResolveReal = IndustryResolveReal;
+ res->StorePSA = IndustryStorePSA;
- res->psa = &indus->psa;
res->u.industry.tile = tile;
res->u.industry.ind = indus;
res->u.industry.gfx = INVALID_INDUSTRYTILE;
diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp
index da72c41cf..c69c3b8cb 100644
--- a/src/newgrf_industrytiles.cpp
+++ b/src/newgrf_industrytiles.cpp
@@ -148,6 +148,19 @@ static void IndustryTileSetTriggers(const ResolverObject *object, int triggers)
}
}
+/**
+ * Store a value into the persistent storage of the object's parent.
+ * @param object Object that we want to query.
+ * @param pos Position in the persistent storage to use.
+ * @param value Value to store.
+ */
+void IndustryTileStorePSA(ResolverObject *object, uint pos, int32 value)
+{
+ Industry *ind = object->u.industry.ind;
+ if (object->scope != VSG_SCOPE_PARENT || ind->index == INVALID_INDUSTRY) return;
+ ind->psa.Store(pos, value);
+}
+
static void NewIndustryTileResolver(ResolverObject *res, IndustryGfx gfx, TileIndex tile, Industry *indus)
{
res->GetRandomBits = IndustryTileGetRandomBits;
@@ -155,8 +168,8 @@ static void NewIndustryTileResolver(ResolverObject *res, IndustryGfx gfx, TileIn
res->SetTriggers = IndustryTileSetTriggers;
res->GetVariable = IndustryTileGetVariable;
res->ResolveReal = IndustryTileResolveReal;
+ res->StorePSA = IndustryTileStorePSA;
- res->psa = &indus->psa;
res->u.industry.tile = tile;
res->u.industry.ind = indus;
res->u.industry.gfx = gfx;
diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp
index 3b1693b4e..1750dc389 100644
--- a/src/newgrf_spritegroup.cpp
+++ b/src/newgrf_spritegroup.cpp
@@ -113,7 +113,7 @@ static U EvalAdjustT(const DeterministicSpriteGroupAdjust *adjust, ResolverObjec
case DSGA_OP_XOR: return last_value ^ value;
case DSGA_OP_STO: _temp_store.Store((U)value, (S)last_value); return last_value;
case DSGA_OP_RST: return value;
- case DSGA_OP_STOP: if (object->psa != NULL) object->psa->Store((U)value, (S)last_value); return last_value;
+ case DSGA_OP_STOP: if (object->StorePSA != NULL) object->StorePSA(object, (U)value, (S)last_value); return last_value;
case DSGA_OP_ROR: return RotateRight(last_value, value);
case DSGA_OP_SCMP: return ((S)last_value == (S)value) ? 1 : ((S)last_value < (S)value ? 0 : 2);
case DSGA_OP_UCMP: return ((U)last_value == (U)value) ? 1 : ((U)last_value < (U)value ? 0 : 2);
diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h
index 2a1b054f6..528d18bfc 100644
--- a/src/newgrf_spritegroup.h
+++ b/src/newgrf_spritegroup.h
@@ -314,8 +314,6 @@ struct ResolverObject {
VarSpriteGroupScope scope; ///< Scope of currently resolved DeterministicSpriteGroup resp. RandomizedSpriteGroup
byte count; ///< Additional scope for RandomizedSpriteGroup
- BaseStorageArray *psa; ///< The persistent storage array of this resolved object.
-
const GRFFile *grffile; ///< GRFFile the resolved SpriteGroup belongs to
union {
@@ -382,6 +380,7 @@ struct ResolverObject {
void (*SetTriggers)(const struct ResolverObject*, int);
uint32 (*GetVariable)(const struct ResolverObject*, byte, byte, bool*);
const SpriteGroup *(*ResolveReal)(const struct ResolverObject*, const RealSpriteGroup*);
+ void (*StorePSA)(struct ResolverObject*, uint, int32);
};
#endif /* NEWGRF_SPRITEGROUP_H */