summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_airporttiles.cpp4
-rw-r--r--src/newgrf_animation_base.h15
-rw-r--r--src/newgrf_house.cpp4
-rw-r--r--src/newgrf_industrytiles.cpp4
-rw-r--r--src/newgrf_object.cpp5
-rw-r--r--src/newgrf_station.cpp8
6 files changed, 25 insertions, 15 deletions
diff --git a/src/newgrf_airporttiles.cpp b/src/newgrf_airporttiles.cpp
index 71f882302..090ccf676 100644
--- a/src/newgrf_airporttiles.cpp
+++ b/src/newgrf_airporttiles.cpp
@@ -243,7 +243,7 @@ static void AirportTileResolver(ResolverObject *res, const AirportTileSpec *ats,
res->grffile = ats->grf_prop.grffile;
}
-uint16 GetAirportTileCallback(CallbackID callback, uint32 param1, uint32 param2, const AirportTileSpec *ats, Station *st, TileIndex tile)
+uint16 GetAirportTileCallback(CallbackID callback, uint32 param1, uint32 param2, const AirportTileSpec *ats, Station *st, TileIndex tile, int extra_data = 0)
{
ResolverObject object;
const SpriteGroup *group;
@@ -306,7 +306,7 @@ bool DrawNewAirportTile(TileInfo *ti, Station *st, StationGfx gfx, const Airport
}
/** Helper class for animation control. */
-struct AirportTileAnimationBase : public AnimationBase<AirportTileAnimationBase, AirportTileSpec, Station, GetAirportTileCallback> {
+struct AirportTileAnimationBase : public AnimationBase<AirportTileAnimationBase, AirportTileSpec, Station, int, GetAirportTileCallback> {
static const CallbackID cb_animation_speed = CBID_AIRPTILE_ANIMATION_SPEED;
static const CallbackID cb_animation_next_frame = CBID_AIRPTILE_ANIM_NEXT_FRAME;
diff --git a/src/newgrf_animation_base.h b/src/newgrf_animation_base.h
index be0b93c6a..a3463adb2 100644
--- a/src/newgrf_animation_base.h
+++ b/src/newgrf_animation_base.h
@@ -23,9 +23,10 @@
* @tparam Tbase Instantiation of this class.
* @tparam Tspec NewGRF specification related to the animated tile.
* @tparam Tobj Object related to the animated tile.
+ * @tparam Textra Custom extra callback data.
* @tparam GetCallback The callback function pointer.
*/
-template <typename Tbase, typename Tspec, typename Tobj, uint16 (*GetCallback)(CallbackID callback, uint32 param1, uint32 param2, const Tspec *statspec, Tobj *st, TileIndex tile)>
+template <typename Tbase, typename Tspec, typename Tobj, typename Textra, uint16 (*GetCallback)(CallbackID callback, uint32 param1, uint32 param2, const Tspec *statspec, Tobj *st, TileIndex tile, Textra extra_data)>
struct AnimationBase {
/**
* Animate a single tile.
@@ -34,15 +35,16 @@ struct AnimationBase {
* @param obj Object related to the tile.
* @param tile Tile to animate changes for.
* @param random_animation Whether to pass random bits to the "next frame" callback.
+ * @param extra_data Custom extra callback data.
*/
- static void AnimateTile(const Tspec *spec, Tobj *obj, TileIndex tile, bool random_animation)
+ static void AnimateTile(const Tspec *spec, Tobj *obj, TileIndex tile, bool random_animation, Textra extra_data = 0)
{
assert(spec != NULL);
/* Acquire the animation speed from the NewGRF. */
uint8 animation_speed = spec->animation.speed;
if (HasBit(spec->callback_mask, Tbase::cbm_animation_speed)) {
- uint16 callback = GetCallback(Tbase::cb_animation_speed, 0, 0, spec, obj, tile);
+ uint16 callback = GetCallback(Tbase::cb_animation_speed, 0, 0, spec, obj, tile, extra_data);
if (callback != CALLBACK_FAILED) animation_speed = Clamp(callback & 0xFF, 0, 16);
}
@@ -58,7 +60,7 @@ struct AnimationBase {
bool frame_set_by_callback = false;
if (HasBit(spec->callback_mask, Tbase::cbm_animation_next_frame)) {
- uint16 callback = GetCallback(Tbase::cb_animation_next_frame, random_animation ? Random() : 0, 0, spec, obj, tile);
+ uint16 callback = GetCallback(Tbase::cb_animation_next_frame, random_animation ? Random() : 0, 0, spec, obj, tile, extra_data);
if (callback != CALLBACK_FAILED) {
frame_set_by_callback = true;
@@ -109,10 +111,11 @@ struct AnimationBase {
* @param tile Tile to consider animation changes for.
* @param random_bits Random bits for this update. To be passed as parameter to the NewGRF.
* @param trigger What triggered this update? To be passed as parameter to the NewGRF.
+ * @param extra_data Custom extra data for callback processing.
*/
- static void ChangeAnimationFrame(CallbackID cb, const Tspec *spec, Tobj *obj, TileIndex tile, uint32 random_bits, uint32 trigger)
+ static void ChangeAnimationFrame(CallbackID cb, const Tspec *spec, Tobj *obj, TileIndex tile, uint32 random_bits, uint32 trigger, Textra extra_data = 0)
{
- uint16 callback = GetCallback(cb, random_bits, trigger, spec, obj, tile);
+ uint16 callback = GetCallback(cb, random_bits, trigger, spec, obj, tile, extra_data);
if (callback == CALLBACK_FAILED) return;
switch (callback & 0xFF) {
diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp
index e4961c7a4..bea4b9b2d 100644
--- a/src/newgrf_house.cpp
+++ b/src/newgrf_house.cpp
@@ -505,13 +505,13 @@ void DrawNewHouseTile(TileInfo *ti, HouseID house_id)
}
/* Simple wrapper for GetHouseCallback to keep the animation unified. */
-uint16 GetSimpleHouseCallback(CallbackID callback, uint32 param1, uint32 param2, const HouseSpec *spec, Town *town, TileIndex tile)
+uint16 GetSimpleHouseCallback(CallbackID callback, uint32 param1, uint32 param2, const HouseSpec *spec, Town *town, TileIndex tile, uint32 extra_data)
{
return GetHouseCallback(callback, param1, param2, spec - HouseSpec::Get(0), town, tile);
}
/** Helper class for animation control. */
-struct HouseAnimationBase : public AnimationBase<HouseAnimationBase, HouseSpec, Town, GetSimpleHouseCallback> {
+struct HouseAnimationBase : public AnimationBase<HouseAnimationBase, HouseSpec, Town, uint32, GetSimpleHouseCallback> {
static const CallbackID cb_animation_speed = CBID_HOUSE_ANIMATION_SPEED;
static const CallbackID cb_animation_next_frame = CBID_HOUSE_ANIMATION_NEXT_FRAME;
diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp
index 02bab3130..caecde957 100644
--- a/src/newgrf_industrytiles.cpp
+++ b/src/newgrf_industrytiles.cpp
@@ -307,13 +307,13 @@ CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind
}
/* Simple wrapper for GetHouseCallback to keep the animation unified. */
-uint16 GetSimpleIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, const IndustryTileSpec *spec, Industry *ind, TileIndex tile)
+uint16 GetSimpleIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, const IndustryTileSpec *spec, Industry *ind, TileIndex tile, int extra_data)
{
return GetIndustryTileCallback(callback, param1, param2, spec - GetIndustryTileSpec(0), ind, tile);
}
/** Helper class for animation control. */
-struct IndustryAnimationBase : public AnimationBase<IndustryAnimationBase, IndustryTileSpec, Industry, GetSimpleIndustryCallback> {
+struct IndustryAnimationBase : public AnimationBase<IndustryAnimationBase, IndustryTileSpec, Industry, int, GetSimpleIndustryCallback> {
static const CallbackID cb_animation_speed = CBID_INDTILE_ANIMATION_SPEED;
static const CallbackID cb_animation_next_frame = CBID_INDTILE_ANIM_NEXT_FRAME;
diff --git a/src/newgrf_object.cpp b/src/newgrf_object.cpp
index 41735b7fa..a6b0c3edd 100644
--- a/src/newgrf_object.cpp
+++ b/src/newgrf_object.cpp
@@ -521,15 +521,16 @@ void DrawNewObjectTileInGUI(int x, int y, const ObjectSpec *spec, uint8 view)
* @param spec The specification of the object / the entry point.
* @param o The object to call the callback for.
* @param tile The tile the callback is called for.
+ * @param extra_data Ignored.
* @return The result of the callback.
*/
-uint16 StubGetObjectCallback(CallbackID callback, uint32 param1, uint32 param2, const ObjectSpec *spec, Object *o, TileIndex tile)
+uint16 StubGetObjectCallback(CallbackID callback, uint32 param1, uint32 param2, const ObjectSpec *spec, Object *o, TileIndex tile, int extra_data)
{
return GetObjectCallback(callback, param1, param2, spec, o, tile);
}
/** Helper class for animation control. */
-struct ObjectAnimationBase : public AnimationBase<ObjectAnimationBase, ObjectSpec, Object, StubGetObjectCallback> {
+struct ObjectAnimationBase : public AnimationBase<ObjectAnimationBase, ObjectSpec, Object, int, StubGetObjectCallback> {
static const CallbackID cb_animation_speed = CBID_OBJECT_ANIMATION_SPEED;
static const CallbackID cb_animation_next_frame = CBID_OBJECT_ANIMATION_NEXT_FRAME;
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index f5ab8cfb2..b33259d32 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -908,8 +908,14 @@ bool IsStationTileElectrifiable(TileIndex tile)
!HasBit(statspec->wires, GetStationGfx(tile));
}
+/** Wrapper for animation control, see #GetStationCallback. */
+uint16 GetAnimStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile, int extra_data)
+{
+ return GetStationCallback(callback, param1, param2, statspec, st, tile);
+}
+
/** Helper class for animation control. */
-struct StationAnimationBase : public AnimationBase<StationAnimationBase, StationSpec, BaseStation, GetStationCallback> {
+struct StationAnimationBase : public AnimationBase<StationAnimationBase, StationSpec, BaseStation, int, GetAnimStationCallback> {
static const CallbackID cb_animation_speed = CBID_STATION_ANIMATION_SPEED;
static const CallbackID cb_animation_next_frame = CBID_STATION_ANIM_NEXT_FRAME;