summaryrefslogtreecommitdiff
path: root/src/newgrf_animation_base.h
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2011-10-31 22:31:35 +0000
committermichi_cc <michi_cc@openttd.org>2011-10-31 22:31:35 +0000
commitf66cd97776cd73c653fad685c9a74538b4d8a2a8 (patch)
tree1226809074a7d42317fa5523336ad72dd049a4e2 /src/newgrf_animation_base.h
parente7f7a749e80348f22f3927acd1a7c79b924d4b58 (diff)
downloadopenttd-f66cd97776cd73c653fad685c9a74538b4d8a2a8.tar.xz
(svn r23071) -Codechange: [NewGRF] Allow passing custom extra data through the generic NewGRF animation helper class.
Diffstat (limited to 'src/newgrf_animation_base.h')
-rw-r--r--src/newgrf_animation_base.h15
1 files changed, 9 insertions, 6 deletions
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) {