summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_house.cpp1
-rw-r--r--src/newgrf_station.cpp1
-rw-r--r--src/openttd.cpp1
-rw-r--r--src/rail_cmd.cpp1
-rw-r--r--src/road_cmd.cpp1
-rw-r--r--src/town_cmd.cpp12
-rw-r--r--src/town_map.h21
7 files changed, 29 insertions, 9 deletions
diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp
index 42d9be698..b64537bea 100644
--- a/src/newgrf_house.cpp
+++ b/src/newgrf_house.cpp
@@ -22,6 +22,7 @@
#include "functions.h"
#include "player_func.h"
#include "animated_tile_func.h"
+#include "date_func.h"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index f926aa5a8..aa81743bf 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -23,6 +23,7 @@
#include "date_func.h"
#include "player_func.h"
#include "animated_tile_func.h"
+#include "functions.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 1a46826a5..5a1b3e238 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -59,6 +59,7 @@
#include "vehicle_func.h"
#include "cheat_func.h"
#include "animated_tile_func.h"
+#include "functions.h"
#include "newgrf.h"
#include "newgrf_config.h"
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 2870e4f5a..9caf2132f 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -43,6 +43,7 @@
#include "tunnelbridge.h"
#include "station_map.h"
#include "water_map.h"
+#include "functions.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 0db3392dc..6e6f6fa8f 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -36,6 +36,7 @@
#include "road_func.h"
#include "tunnelbridge.h"
#include "cheat_func.h"
+#include "functions.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 66cc9e945..45de37aeb 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -45,6 +45,9 @@
#include "economy_func.h"
#include "station_func.h"
#include "cheat_func.h"
+#include "functions.h"
+#include "animated_tile_func.h"
+#include "date_func.h"
#include "table/strings.h"
#include "table/sprites.h"
@@ -268,7 +271,10 @@ static void AnimateTile_Town(TileIndex tile)
pos += (pos < dest) ? 1 : -1;
SetLiftPosition(tile, pos);
- if (pos == dest) HaltLift(tile);
+ if (pos == dest) {
+ HaltLift(tile);
+ DeleteAnimatedTile(tile);
+ }
MarkTileDirtyByTile(tile);
}
@@ -385,6 +391,7 @@ static void MakeSingleHouseBigger(TileIndex tile)
/* Now that construction is complete, we can add the population of the
* building to the town. */
ChangePopulation(GetTownByTile(tile), GetHouseSpecs(GetHouseType(tile))->population);
+ SetHouseConstructionYear(tile, _cur_year);
}
MarkTileDirtyByTile(tile);
}
@@ -1644,6 +1651,9 @@ static inline void ClearMakeHouseTile(TileIndex tile, TownID tid, byte counter,
assert(CmdSucceeded(cc));
MakeHouseTile(tile, tid, counter, stage, type, random_bits);
+ if (GetHouseSpecs(type)->building_flags & BUILDING_IS_ANIMATED) AddAnimatedTile(tile);
+
+ MarkTileDirtyByTile(tile);
}
diff --git a/src/town_map.h b/src/town_map.h
index e48e826f5..f8cc4c071 100644
--- a/src/town_map.h
+++ b/src/town_map.h
@@ -6,10 +6,8 @@
#define TOWN_MAP_H
#include "town.h"
-#include "date_func.h"
+#include "date_type.h"
#include "tile_map.h"
-#include "functions.h"
-#include "animated_tile_func.h"
/**
* Get the index of which town this house/street is attached to.
@@ -114,7 +112,6 @@ static inline byte GetLiftDestination(TileIndex t)
static inline void HaltLift(TileIndex t)
{
SB(_me[t].m7, 0, 4, 0);
- DeleteAnimatedTile(t);
}
/**
@@ -207,9 +204,6 @@ static inline void MakeHouseTile(TileIndex t, TownID tid, byte counter, byte sta
_m[t].m5 = IsHouseCompleted(t) ? 0 : (stage << 3 | counter);
SetHouseAnimationFrame(t, 0);
_me[t].m7 = GetHouseSpecs(type)->processing_time;
-
- if (GetHouseSpecs(type)->building_flags & BUILDING_IS_ANIMATED) AddAnimatedTile(t);
- MarkTileDirtyByTile(t);
}
/**
@@ -267,11 +261,22 @@ static inline void IncHouseConstructionTick(TileIndex t)
/* House is now completed.
* Store the year of construction as well, for newgrf house purpose */
SetHouseCompleted(t, true);
- _m[t].m5 = Clamp(_cur_year - ORIGINAL_BASE_YEAR, 0, 0xFF);
}
}
/**
+ * Set the year that this house was constructed (between 1920 and 2175).
+ * @param t the tile of this house
+ * @param year the year to set
+ * @pre IsTileType(t, MP_HOUSE) && IsHouseCompleted(t)
+ */
+static inline void SetHouseConstructionYear(TileIndex t, Year year)
+{
+ assert(IsTileType(t, MP_HOUSE) && IsHouseCompleted(t));
+ _m[t].m5 = Clamp(year - ORIGINAL_BASE_YEAR, 0, 0xFF);
+}
+
+/**
* Get the year that this house was constructed (between 1920 and 2175).
* @param t the tile of this house
* @pre IsTileType(t, MP_HOUSE)