summaryrefslogtreecommitdiff
path: root/src/object_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-08-28 18:51:47 +0000
committerrubidium <rubidium@openttd.org>2010-08-28 18:51:47 +0000
commit60fe27db5060a4079dc58b8b61355f0a57757e36 (patch)
tree1c7944ac5811ebaec6b55363799bf1491ce7b846 /src/object_cmd.cpp
parentee8c37c3d9fb5b62e24b0272fd93cd50acaa80f6 (diff)
downloadopenttd-60fe27db5060a4079dc58b8b61355f0a57757e36.tar.xz
(svn r20662) -Codechange: implement object animation
Diffstat (limited to 'src/object_cmd.cpp')
-rw-r--r--src/object_cmd.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp
index c4f17f576..8978fb9cd 100644
--- a/src/object_cmd.cpp
+++ b/src/object_cmd.cpp
@@ -89,6 +89,7 @@ void BuildObject(ObjectType type, TileIndex tile, CompanyID owner, Town *town)
}
Object::IncTypeCount(type);
+ if (spec->flags & OBJECT_FLAG_ANIMATION) TriggerObjectAnimation(o, OAT_BUILT, spec);
}
/**
@@ -379,6 +380,9 @@ static void GetTileDesc_Object(TileIndex tile, TileDesc *td)
static void TileLoop_Object(TileIndex tile)
{
+ const ObjectSpec *spec = ObjectSpec::GetByTile(tile);
+ if (spec->flags & OBJECT_FLAG_ANIMATION) TriggerObjectTileAnimation(Object::GetByTile(tile), tile, OAT_TILELOOP, spec);
+
if (IsTileOnWater(tile)) TileLoop_Water(tile);
if (!IsCompanyHQ(tile)) return;
@@ -424,6 +428,25 @@ static bool ClickTile_Object(TileIndex tile)
return true;
}
+static void AnimateTile_Object(TileIndex tile)
+{
+ AnimateNewObjectTile(tile);
+}
+
+/** Call the ticks on the objects. */
+void OnTick_Objects()
+{
+ const Object *o;
+ FOR_ALL_OBJECTS(o) {
+ /* Run 250 tick interval trigger for object animation.
+ * Object index is included so that triggers are not all done
+ * at the same time. */
+ if ((_tick_counter + o->index) % 250 == 0) {
+ const ObjectSpec *spec = ObjectSpec::GetByTile(o->location.tile);
+ if (spec->flags & OBJECT_FLAG_ANIMATION) TriggerObjectAnimation(o, OAT_250_TICKS, spec);
+ }
+ }
+}
/* checks, if a radio tower is within a 9x9 tile square around tile */
static bool IsRadioTowerNearby(TileIndex tile)
@@ -564,7 +587,7 @@ extern const TileTypeProcs _tile_type_object_procs = {
GetTileDesc_Object, // get_tile_desc_proc
GetTileTrackStatus_Object, // get_tile_track_status_proc
ClickTile_Object, // click_tile_proc
- NULL, // animate_tile_proc
+ AnimateTile_Object, // animate_tile_proc
TileLoop_Object, // tile_loop_clear
ChangeTileOwner_Object, // change_tile_owner_clear
NULL, // add_produced_cargo_proc