changeset 8140:fb8a05d579da draft

(svn r11702) -Codechange: move all date related stuff to date*.
author rubidium <rubidium@openttd.org>
date Wed, 26 Dec 2007 13:50:40 +0000
parents db99ba38abc0
children 4f0b388bfe1b
files src/ai/default/default.cpp src/ai/trolly/trolly.cpp src/aircraft_cmd.cpp src/airport.cpp src/build_vehicle_gui.cpp src/console_cmds.cpp src/currency.cpp src/currency.h src/date.cpp src/date.h src/date_func.h src/date_type.h src/disaster_cmd.cpp src/economy.cpp src/engine.cpp src/engine.h src/genworld.cpp src/genworld_gui.cpp src/graph_gui.cpp src/group_gui.cpp src/industry.h src/industry_cmd.cpp src/industry_gui.cpp src/landscape.cpp src/main_gui.cpp src/misc.cpp src/misc_gui.cpp src/network/core/game.h src/network/core/udp.cpp src/network/network.cpp src/network/network_client.cpp src/network/network_gui.cpp src/network/network_server.cpp src/network/network_udp.cpp src/newgrf.cpp src/newgrf_engine.cpp src/newgrf_house.cpp src/newgrf_industries.cpp src/newgrf_spritegroup.cpp src/newgrf_station.cpp src/newgrf_text.cpp src/news.h src/news_gui.cpp src/oldloader.cpp src/openttd.cpp src/openttd.h src/player.h src/player_gui.cpp src/players.cpp src/rail_gui.cpp src/roadveh_cmd.cpp src/screenshot.cpp src/settings.cpp src/settings_gui.cpp src/ship_cmd.cpp src/station.cpp src/station_cmd.cpp src/station_gui.cpp src/strings.cpp src/subsidy_gui.cpp src/texteff.cpp src/tile_cmd.h src/timetable_cmd.cpp src/timetable_gui.cpp src/town.h src/town_cmd.cpp src/town_map.h src/train_cmd.cpp src/tunnelbridge_cmd.cpp src/variables.h src/vehicle.cpp src/vehicle.h src/vehicle_gui.cpp src/waypoint.cpp src/yapf/yapf.hpp src/yapf/yapf_costcache.hpp
diffstat 76 files changed, 134 insertions(+), 133 deletions(-) [+]
line wrap: on
line diff
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -23,7 +23,7 @@
 #include "../../depot.h"
 #include "../../variables.h"
 #include "../../bridge.h"
-#include "../../date.h"
+#include "../../date_func.h"
 #include "../../tunnelbridge_map.h"
 #include "../../window_func.h"
 #include "../../functions.h"
--- a/src/ai/trolly/trolly.cpp
+++ b/src/ai/trolly/trolly.cpp
@@ -32,7 +32,7 @@
 #include "../../gui.h"
 #include "../../depot.h"
 #include "../../vehicle.h"
-#include "../../date.h"
+#include "../../date_func.h"
 #include "../ai.h"
 #include "../../order.h"
 
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -26,12 +26,12 @@
 #include "newgrf_callbacks.h"
 #include "newgrf_text.h"
 #include "newgrf_sound.h"
-#include "date.h"
 #include "spritecache.h"
 #include "cargotype.h"
 #include "strings_func.h"
 #include "command_func.h"
 #include "window_func.h"
+#include "date_func.h"
 #include "functions.h"
 
 void Aircraft::UpdateDeltaXY(Direction direction)
--- a/src/airport.cpp
+++ b/src/airport.cpp
@@ -8,9 +8,9 @@
 #include "airport.h"
 #include "variables.h"
 #include "airport_movement.h"
-#include "date.h"
 #include "core/bitmath_func.hpp"
 #include "core/alloc_func.hpp"
+#include "date_func.h"
 
 /* Uncomment this to print out a full report of the airport-structure
  * You should either use
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -23,12 +23,12 @@
 #include "airport.h"
 #include "vehicle_gui.h"
 #include "newgrf_engine.h"
-#include "date.h"
 #include "cargotype.h"
 #include "group.h"
 #include "road_map.h"
 #include "strings_func.h"
 #include "window_func.h"
+#include "date_func.h"
 
 
 enum BuildVehicleWidgets {
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -23,13 +23,13 @@
 #include "station.h"
 #include "screenshot.h"
 #include "genworld.h"
-#include "date.h"
 #include "network/network.h"
 #include "strings_func.h"
 #include "viewport.h"
 #include "window_func.h"
 #include "functions.h"
 #include "map_func.h"
+#include "date_func.h"
 
 // ** scriptfile handling ** //
 static FILE *_script_file;
--- a/src/currency.cpp
+++ b/src/currency.cpp
@@ -8,7 +8,7 @@
 #include "news.h"
 #include "variables.h"
 #include "table/strings.h"
-#include "date.h"
+#include "date_func.h"
 
 	//   exchange rate    prefix             symbol_pos
 	//   |  separator        |     postfix   |
--- a/src/currency.h
+++ b/src/currency.h
@@ -5,6 +5,8 @@
 #ifndef CURRENCY_H
 #define CURRENCY_H
 
+#include "date_type.h"
+
 enum {
 	CF_NOEURO = 0,
 	CF_ISEURO = 1,
--- a/src/date.cpp
+++ b/src/date.cpp
@@ -4,7 +4,6 @@
 
 #include "stdafx.h"
 #include "openttd.h"
-#include "date.h"
 #include "variables.h"
 #include "vehicle.h"
 #include "network/network.h"
@@ -13,6 +12,7 @@
 #include "currency.h"
 #include "window_func.h"
 #include "functions.h"
+#include "date_func.h"
 #ifdef DEBUG_DUMP_COMMANDS
 #include "saveload.h"
 #endif
deleted file mode 100644
--- a/src/date.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* $Id$ */
-
-/** @file date.h */
-
-#ifndef DATE_H
-#define DATE_H
-
-#include "openttd.h"
-
-/**
- * 1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885. On
- *                    an overflow the new day begun and 65535 / 885 = 74.
- * 1 tick is approximately 30 ms.
- * 1 day is thus about 2 seconds (74 * 30 = 2220) on a machine that can run OpenTTD normally
- */
-#define DAY_TICKS 74
-
-/*
- * ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR and DAYS_TILL_ORIGINAL_BASE_YEAR are
- * primarily used for loading newgrf and savegame data and returning some
- * newgrf (callback) functions that were in the original (TTD) inherited
- * format, where '_date == 0' meant that it was 1920-01-01.
- */
-
-/** The minimum starting year/base year of the original TTD */
-#define ORIGINAL_BASE_YEAR 1920
-/** The maximum year of the original TTD */
-#define ORIGINAL_MAX_YEAR 2090
-
-/**
- * The offset in days from the '_date == 0' till
- * 'ConvertYMDToDate(ORIGINAL_BASE_YEAR, 0, 1)'
- */
-#define DAYS_TILL_ORIGINAL_BASE_YEAR (365 * ORIGINAL_BASE_YEAR + ORIGINAL_BASE_YEAR / 4 - ORIGINAL_BASE_YEAR / 100 + ORIGINAL_BASE_YEAR / 400)
-
-/* The absolute minimum & maximum years in OTTD */
-#define MIN_YEAR 0
-/* MAX_YEAR, nicely rounded value of the number of years that can
- * be encoded in a single 32 bits date, about 2^31 / 366 years. */
-#define MAX_YEAR 5000000
-
-/* Year and Date are defined elsewhere */
-typedef uint8  Month;
-typedef uint8  Day;
-typedef uint16 DateFract;
-
-struct YearMonthDay {
-	Year  year;
-	Month month;
-	Day   day;
-};
-
-extern Year      _cur_year;
-extern Month     _cur_month;
-extern Date      _date;
-extern DateFract _date_fract;
-
-
-void SetDate(Date date);
-void ConvertDateToYMD(Date date, YearMonthDay *ymd);
-Date ConvertYMDToDate(Year year, Month month, Day day);
-
-#endif /* DATE_H */
new file mode 100644
--- /dev/null
+++ b/src/date_func.h
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+/** @file date_func.h Functions related to dates. */
+
+#ifndef DATE_FUNC_H
+#define DATE_FUNC_H
+
+#include "date_type.h"
+
+extern Year      _cur_year;
+extern Month     _cur_month;
+extern Date      _date;
+extern DateFract _date_fract;
+
+void SetDate(Date date);
+void ConvertDateToYMD(Date date, YearMonthDay *ymd);
+Date ConvertYMDToDate(Year year, Month month, Day day);
+
+#endif /* DATE_FUNC_H */
new file mode 100644
--- /dev/null
+++ b/src/date_type.h
@@ -0,0 +1,56 @@
+/* $Id$ */
+
+/** @file date_type.h Types related to the dates in OpenTTD. */
+
+#ifndef DATE_TYPE_H
+#define DATE_TYPE_H
+
+/**
+ * 1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885. On
+ *                    an overflow the new day begun and 65535 / 885 = 74.
+ * 1 tick is approximately 30 ms.
+ * 1 day is thus about 2 seconds (74 * 30 = 2220) on a machine that can run OpenTTD normally
+ */
+#define DAY_TICKS 74
+
+/*
+ * ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR and DAYS_TILL_ORIGINAL_BASE_YEAR are
+ * primarily used for loading newgrf and savegame data and returning some
+ * newgrf (callback) functions that were in the original (TTD) inherited
+ * format, where '_date == 0' meant that it was 1920-01-01.
+ */
+
+/** The minimum starting year/base year of the original TTD */
+#define ORIGINAL_BASE_YEAR 1920
+/** The maximum year of the original TTD */
+#define ORIGINAL_MAX_YEAR 2090
+
+/**
+ * The offset in days from the '_date == 0' till
+ * 'ConvertYMDToDate(ORIGINAL_BASE_YEAR, 0, 1)'
+ */
+#define DAYS_TILL_ORIGINAL_BASE_YEAR (365 * ORIGINAL_BASE_YEAR + ORIGINAL_BASE_YEAR / 4 - ORIGINAL_BASE_YEAR / 100 + ORIGINAL_BASE_YEAR / 400)
+
+/* The absolute minimum & maximum years in OTTD */
+#define MIN_YEAR 0
+/* MAX_YEAR, nicely rounded value of the number of years that can
+ * be encoded in a single 32 bits date, about 2^31 / 366 years. */
+#define MAX_YEAR 5000000
+
+typedef int32  Date;
+typedef uint16 DateFract;
+
+typedef int32  Year;
+typedef uint8  Month;
+typedef uint8  Day;
+
+struct YearMonthDay {
+	Year  year;
+	Month month;
+	Day   day;
+};
+
+static const Year INVALID_YEAR = -1;
+static const Date INVALID_DATE = -1;
+
+#endif /* DATE_TYPE_H */
--- a/src/disaster_cmd.cpp
+++ b/src/disaster_cmd.cpp
@@ -36,8 +36,8 @@
 #include "sound.h"
 #include "variables.h"
 #include "table/sprites.h"
-#include "date.h"
 #include "strings_func.h"
+#include "date_func.h"
 #include "functions.h"
 
 enum DisasterSubType {
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -32,7 +32,6 @@
 #include "newgrf_industries.h"
 #include "newgrf_industrytiles.h"
 #include "unmovable.h"
-#include "date.h"
 #include "cargotype.h"
 #include "player_face.h"
 #include "group.h"
@@ -40,6 +39,7 @@
 #include "tile_cmd.h"
 #include "functions.h"
 #include "window_func.h"
+#include "date_func.h"
 
 /**
  * Multiply two integer values and shift the results to right.
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -16,7 +16,6 @@
 #include "train.h"
 #include "aircraft.h"
 #include "newgrf_cargo.h"
-#include "date.h"
 #include "table/engines.h"
 #include "group.h"
 #include "string.h"
@@ -25,6 +24,7 @@
 #include "viewport.h"
 #include "functions.h"
 #include "window_func.h"
+#include "date_func.h"
 
 EngineInfo _engine_info[TOTAL_NUM_ENGINES];
 RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES];
--- a/src/engine.h
+++ b/src/engine.h
@@ -11,6 +11,7 @@
 #include "vehicle_type.h"
 #include "command_type.h"
 #include "gfx_type.h"
+#include "date_type.h"
 #include "sound.h"
 
 enum RailVehicleTypes {
--- a/src/genworld.cpp
+++ b/src/genworld.cpp
@@ -17,9 +17,9 @@
 #include "debug.h"
 #include "settings.h"
 #include "heightmap.h"
-#include "date.h"
 #include "viewport.h"
 #include "map_func.h"
+#include "date_func.h"
 
 void GenerateClearTile();
 void GenerateIndustries();
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -21,10 +21,10 @@
 #include "genworld.h"
 #include "network/network.h"
 #include "thread.h"
-#include "date.h"
 #include "newgrf_config.h"
 #include "strings_func.h"
 #include "window_func.h"
+#include "date_func.h"
 
 /**
  * In what 'mode' the GenerateLandscapeWindowProc is.
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -11,11 +11,11 @@
 #include "player.h"
 #include "economy_func.h"
 #include "variables.h"
-#include "date.h"
 #include "cargotype.h"
 #include "strings_func.h"
 #include "core/alloc_func.hpp"
 #include "window_func.h"
+#include "date_func.h"
 
 /* Bitmasks of player and cargo indices that shouldn't be drawn. */
 static uint _legend_excluded_players;
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -15,7 +15,6 @@
 #include "vehicle_gui.h"
 #include "depot.h"
 #include "train.h"
-#include "date.h"
 #include "group.h"
 #include "viewport.h"
 #include "debug.h"
--- a/src/industry.h
+++ b/src/industry.h
@@ -12,6 +12,7 @@
 #include "economy_type.h"
 #include "map_type.h"
 #include "slope_type.h"
+#include "date_type.h"
 
 typedef uint16 IndustryGfx;
 typedef uint8 IndustryType;
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -23,7 +23,6 @@
 #include "table/industry_land.h"
 #include "table/build_industry.h"
 #include "genworld.h"
-#include "date.h"
 #include "water_map.h"
 #include "tree_map.h"
 #include "cargotype.h"
@@ -40,6 +39,7 @@
 #include "tile_cmd.h"
 #include "functions.h"
 #include "window_func.h"
+#include "date_func.h"
 
 void ShowIndustryViewWindow(int industry);
 void BuildOilRig(TileIndex tile);
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -20,7 +20,6 @@
 #include "newgrf_callbacks.h"
 #include "newgrf_industries.h"
 #include "newgrf_text.h"
-#include "date.h"
 #include "strings_func.h"
 #include "map_func.h"
 
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -5,7 +5,6 @@
 #include "bridge_map.h"
 #include "heightmap.h"
 #include "clear_map.h"
-#include "date.h"
 #include "player.h"
 #include "spritecache.h"
 #include "table/sprites.h"
@@ -24,6 +23,7 @@
 #include "functions.h"
 #include "window_func.h"
 #include "functions.h"
+#include "date_func.h"
 
 extern const TileTypeProcs
 	_tile_type_clear_procs,
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -34,12 +34,12 @@
 #include "screenshot.h"
 #include "genworld.h"
 #include "settings.h"
-#include "date.h"
 #include "vehicle_gui.h"
 #include "transparency_gui.h"
 #include "newgrf_config.h"
 #include "rail_gui.h"
 #include "road_gui.h"
+#include "date_func.h"
 #include "functions.h"
 
 #include "network/network_data.h"
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -18,7 +18,6 @@
 #include "variables.h"
 #include "ai/ai.h"
 #include "newgrf_house.h"
-#include "date.h"
 #include "cargotype.h"
 #include "group.h"
 #include "viewport.h"
@@ -26,6 +25,7 @@
 #include "zoom_func.h"
 #include "functions.h"
 #include "map_func.h"
+#include "date_func.h"
 
 char _name_array[512][32];
 
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -31,7 +31,6 @@
 #include "train.h"
 #include "tgp.h"
 #include "settings.h"
-#include "date.h"
 #include "cargotype.h"
 #include "player_face.h"
 #include "strings_func.h"
@@ -41,6 +40,7 @@
 #include "zoom_func.h"
 #include "functions.h"
 #include "window_func.h"
+#include "date_func.h"
 
 /* Variables to display file lists */
 FiosItem *_fios_list;
--- a/src/network/core/game.h
+++ b/src/network/core/game.h
@@ -11,8 +11,8 @@
 #ifdef ENABLE_NETWORK
 
 #include "config.h"
-#include "../../date.h"
 #include "../../newgrf_config.h"
+#include "../../date_type.h"
 
 /**
  * This is the struct used by both client and server
--- a/src/network/core/udp.cpp
+++ b/src/network/core/udp.cpp
@@ -11,6 +11,7 @@
 #include "../../core/bitmath_func.hpp"
 #include "../../core/math_func.hpp"
 #include "../../core/alloc_func.hpp"
+#include "../../date_func.h"
 #include "packet.h"
 #include "udp.h"
 
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -14,7 +14,7 @@
 #include "../map_func.h"
 #include "../command_func.h"
 #include "../variables.h"
-#include "../date.h"
+#include "../date_func.h"
 #include "../newgrf_config.h"
 #include "table/strings.h"
 #include "network_client.h"
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -8,7 +8,6 @@
 #include "../openttd.h"
 #include "network_data.h"
 #include "core/tcp.h"
-#include "../date.h"
 #include "table/strings.h"
 #include "network_client.h"
 #include "network_gamelist.h"
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -7,7 +7,7 @@
 #include "../strings_func.h"
 #include "../table/sprites.h"
 #include "network.h"
-#include "../date.h"
+#include "../date_func.h"
 
 #include "../fios.h"
 #include "table/strings.h"
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -11,7 +11,7 @@
 #include "core/tcp.h"
 #include "../train.h"
 #include "../aircraft.h"
-#include "../date.h"
+#include "../date_func.h"
 #include "table/strings.h"
 #include "network_server.h"
 #include "network_udp.h"
--- a/src/network/network_udp.cpp
+++ b/src/network/network_udp.cpp
@@ -13,7 +13,7 @@
 #include "../debug.h"
 #include "../string.h"
 #include "network_data.h"
-#include "../date.h"
+#include "../date_func.h"
 #include "../map_func.h"
 #include "network_gamelist.h"
 #include "network_udp.h"
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -24,7 +24,6 @@
 #include "newgrf_text.h"
 #include "table/sprites.h"
 #include "fontcache.h"
-#include "date.h"
 #include "currency.h"
 #include "landscape.h"
 #include "sound.h"
@@ -46,6 +45,7 @@
 #include "rail.h"
 #include "strings_func.h"
 #include "gfx_func.h"
+#include "date_func.h"
 
 /* TTDPatch extended GRF format codec
  * (c) Petr Baudis 2004 (GPL'd)
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -17,8 +17,8 @@
 #include "newgrf_station.h"
 #include "newgrf_spritegroup.h"
 #include "newgrf_cargo.h"
-#include "date.h"
 #include "cargotype.h"
+#include "date_func.h"
 
 
 int _traininfo_vehicle_pitch = 0;
--- a/src/newgrf_house.cpp
+++ b/src/newgrf_house.cpp
@@ -8,7 +8,6 @@
 #include "debug.h"
 #include "viewport.h"
 #include "landscape.h"
-#include "date.h"
 #include "town.h"
 #include "town_map.h"
 #include "sound.h"
--- a/src/newgrf_industries.cpp
+++ b/src/newgrf_industries.cpp
@@ -18,7 +18,6 @@
 #include "newgrf_commons.h"
 #include "newgrf_text.h"
 #include "newgrf_town.h"
-#include "date.h"
 #include "window_func.h"
 
 /* Since the industry IDs defined by the GRF file don't necessarily correlate
--- a/src/newgrf_spritegroup.cpp
+++ b/src/newgrf_spritegroup.cpp
@@ -9,8 +9,8 @@
 #include "oldpool.h"
 #include "newgrf_callbacks.h"
 #include "newgrf_spritegroup.h"
-#include "date.h"
 #include "sprite.h"
+#include "date_func.h"
 
 static void SpriteGroupPoolCleanBlock(uint start_item, uint end_item);
 
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -18,11 +18,11 @@
 #include "newgrf_commons.h"
 #include "newgrf_station.h"
 #include "newgrf_spritegroup.h"
-#include "date.h"
 #include "cargotype.h"
 #include "town_map.h"
 #include "newgrf_town.h"
 #include "gfx_func.h"
+#include "date_func.h"
 
 static StationClass station_classes[STAT_CLASS_MAX];
 
--- a/src/newgrf_text.cpp
+++ b/src/newgrf_text.cpp
@@ -18,7 +18,6 @@
 #include "newgrf.h"
 #include "newgrf_text.h"
 #include "table/control_codes.h"
-#include "date.h"
 #include "strings_func.h"
 
 #define GRFTAB  28
--- a/src/news.h
+++ b/src/news.h
@@ -8,6 +8,7 @@
 #include "window_type.h"
 #include "vehicle_type.h"
 #include "tile_type.h"
+#include "date_type.h"
 
 struct NewsItem {
 	StringID string_id; ///< Message text (sometimes also used for storing other info)
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -12,11 +12,11 @@
 #include "vehicle.h"
 #include "sound.h"
 #include "variables.h"
-#include "date.h"
 #include "string.h"
 #include "transparency.h"
 #include "strings_func.h"
 #include "window_func.h"
+#include "date_func.h"
 
 /** @file news_gui.cpp
  *
--- a/src/oldloader.cpp
+++ b/src/oldloader.cpp
@@ -21,9 +21,9 @@
 #include "depot.h"
 #include "newgrf_config.h"
 #include "ai/ai.h"
-#include "date.h"
 #include "zoom_func.h"
 #include "functions.h"
+#include "date_func.h"
 
 enum {
 	HEADER_SIZE = 49,
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -46,7 +46,6 @@
 #include "yapf/yapf.h"
 #include "settings.h"
 #include "genworld.h"
-#include "date.h"
 #include "clear_map.h"
 #include "fontcache.h"
 #include "newgrf.h"
@@ -62,6 +61,7 @@
 #include "video/video_driver.hpp"
 #include "strings_func.h"
 #include "zoom_func.h"
+#include "date_func.h"
 
 #include "bridge_map.h"
 #include "clear_map.h"
--- a/src/openttd.h
+++ b/src/openttd.h
@@ -49,15 +49,6 @@
 assert_compile(sizeof(DestinationID) == sizeof(WaypointID));
 assert_compile(sizeof(DestinationID) == sizeof(StationID));
 
-
-enum {
-	INVALID_YEAR = -1,
-	INVALID_DATE = -1,
-};
-
-typedef int32 Year;
-typedef int32 Date;
-
 typedef uint32 PlayerFace; ///< player face bits, info see in player_face.h
 
 enum GameModes {
--- a/src/player.h
+++ b/src/player.h
@@ -11,6 +11,7 @@
 #include "road_func.h"
 #include "cargo_type.h"
 #include "command_type.h"
+#include "date_type.h"
 #include "engine.h"
 #include "livery.h"
 #include "genworld.h"
--- a/src/player_gui.cpp
+++ b/src/player_gui.cpp
@@ -18,7 +18,6 @@
 #include "roadveh.h"
 #include "train.h"
 #include "aircraft.h"
-#include "date.h"
 #include "newgrf.h"
 #include "network/network_data.h"
 #include "network/network_client.h"
@@ -27,6 +26,7 @@
 #include "strings_func.h"
 #include "functions.h"
 #include "window_func.h"
+#include "date_func.h"
 
 static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied);
 static void DoSelectPlayerFace(PlayerID player, bool show_big);
--- a/src/players.cpp
+++ b/src/players.cpp
@@ -20,7 +20,6 @@
 #include "variables.h"
 #include "engine.h"
 #include "ai/ai.h"
-#include "date.h"
 #include "player_face.h"
 #include "group.h"
 #include "settings.h"
@@ -29,6 +28,7 @@
 #include "strings_func.h"
 #include "gfx_func.h"
 #include "functions.h"
+#include "date_func.h"
 
 /**
  * Sets the local player and updates the patch settings that are set on a
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -8,7 +8,6 @@
 #include "table/strings.h"
 #include "tile_cmd.h"
 #include "landscape.h"
-#include "date.h"
 #include "gui.h"
 #include "window_gui.h"
 #include "station_gui.h"
@@ -26,6 +25,7 @@
 #include "strings_func.h"
 #include "functions.h"
 #include "window_func.h"
+#include "date_func.h"
 
 #include "bridge_map.h"
 #include "rail_map.h"
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -32,12 +32,12 @@
 #include "newgrf_text.h"
 #include "newgrf_sound.h"
 #include "yapf/yapf.h"
-#include "date.h"
 #include "cargotype.h"
 #include "strings_func.h"
 #include "tunnelbridge_map.h"
 #include "functions.h"
 #include "window_func.h"
+#include "date_func.h"
 
 
 static const uint16 _roadveh_images[63] = {
--- a/src/screenshot.cpp
+++ b/src/screenshot.cpp
@@ -9,7 +9,6 @@
 #include "player.h"
 #include "screenshot.h"
 #include "variables.h"
-#include "date.h"
 #include "string.h"
 #include "blitter/factory.hpp"
 #include "fileio.h"
@@ -18,6 +17,7 @@
 #include "core/alloc_func.hpp"
 #include "core/endian_func.hpp"
 #include "map_func.h"
+#include "date_func.h"
 
 char _screenshot_format_name[8];
 uint _num_screenshot_formats;
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -36,7 +36,6 @@
 #include "newgrf.h"
 #include "newgrf_config.h"
 #include "genworld.h"
-#include "date.h"
 #include "rail.h"
 #include "train.h"
 #include "news.h"
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -20,7 +20,6 @@
 #include "variables.h"
 #include "settings.h"
 #include "vehicle.h"
-#include "date.h"
 #include "newgrf_townname.h"
 #include "strings_func.h"
 #include "functions.h"
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -28,12 +28,12 @@
 #include "newgrf_callbacks.h"
 #include "newgrf_text.h"
 #include "newgrf_sound.h"
-#include "date.h"
 #include "spritecache.h"
 #include "misc/autoptr.hpp"
 #include "strings_func.h"
 #include "functions.h"
 #include "window_func.h"
+#include "date_func.h"
 
 static const uint16 _ship_sprites[] = {0x0E5D, 0x0E55, 0x0E65, 0x0E6D};
 
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -25,13 +25,13 @@
 #include "newgrf_callbacks.h"
 #include "newgrf_station.h"
 #include "yapf/yapf.h"
-#include "date.h"
 #include "cargotype.h"
 #include "roadveh.h"
 #include "station_gui.h"
 #include "zoom_func.h"
 #include "functions.h"
 #include "window_func.h"
+#include "date_func.h"
 
 Station::Station(TileIndex tile)
 {
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -32,7 +32,6 @@
 #include "newgrf_callbacks.h"
 #include "newgrf_station.h"
 #include "yapf/yapf.h"
-#include "date.h"
 #include "misc/autoptr.hpp"
 #include "road_type.h"
 #include "road_internal.h" /* For drawing catenary/checking road removal */
@@ -44,6 +43,7 @@
 #include "strings_func.h"
 #include "functions.h"
 #include "window_func.h"
+#include "date_func.h"
 
 DEFINE_OLD_POOL_GENERIC(Station, Station)
 DEFINE_OLD_POOL_GENERIC(RoadStop, RoadStop)
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -16,7 +16,6 @@
 #include "command_func.h"
 #include "variables.h"
 #include "vehicle_gui.h"
-#include "date.h"
 #include "vehicle.h"
 #include "table/sprites.h"
 #include "cargotype.h"
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -19,7 +19,6 @@
 #include "newgrf_text.h"
 #include "table/control_codes.h"
 #include "music.h"
-#include "date.h"
 #include "industry.h"
 #include "fileio.h"
 #include "cargotype.h"
@@ -35,6 +34,7 @@
 #include "strings_func.h"
 #include "functions.h"
 #include "core/endian_func.hpp"
+#include "date_func.h"
 
 /* for opendir/readdir/closedir */
 # include "fios.h"
--- a/src/subsidy_gui.cpp
+++ b/src/subsidy_gui.cpp
@@ -11,10 +11,10 @@
 #include "player.h"
 #include "economy_func.h"
 #include "variables.h"
-#include "date.h"
 #include "cargotype.h"
 #include "window_gui.h"
 #include "strings_func.h"
+#include "date_func.h"
 
 static void HandleSubsidyClick(int y)
 {
--- a/src/texteff.cpp
+++ b/src/texteff.cpp
@@ -14,12 +14,12 @@
 #include "table/sprites.h"
 #include "blitter/factory.hpp"
 #include <stdarg.h> /* va_list */
-#include "date.h"
 #include "texteff.hpp"
 #include "video/video_driver.hpp"
 #include "transparency.h"
 #include "strings_func.h"
 #include "core/alloc_func.hpp"
+#include "date_func.h"
 #include "functions.h"
 
 enum {
--- a/src/tile_cmd.h
+++ b/src/tile_cmd.h
@@ -11,6 +11,7 @@
 #include "vehicle_type.h"
 #include "cargo_type.h"
 #include "strings_type.h"
+#include "date_type.h"
 
 /** The returned bits of VehicleEnterTile. */
 enum VehicleEnterTileStatus {
--- a/src/timetable_cmd.cpp
+++ b/src/timetable_cmd.cpp
@@ -7,7 +7,6 @@
 #include "variables.h"
 #include "table/strings.h"
 #include "command_func.h"
-#include "date.h"
 #include "player.h"
 #include "vehicle.h"
 #include "functions.h"
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -7,7 +7,6 @@
 #include "variables.h"
 #include "table/strings.h"
 #include "command_func.h"
-#include "date.h"
 #include "engine.h"
 #include "gui.h"
 #include "window_gui.h"
--- a/src/town.h
+++ b/src/town.h
@@ -9,6 +9,7 @@
 #include "core/random_func.hpp"
 #include "cargo_type.h"
 #include "tile_type.h"
+#include "date_type.h"
 
 enum {
 	HOUSE_NO_CLASS   = 0,
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -28,7 +28,6 @@
 #include "variables.h"
 #include "bridge.h"
 #include "bridge_map.h"
-#include "date.h"
 #include "table/town_land.h"
 #include "genworld.h"
 #include "newgrf.h"
--- a/src/town_map.h
+++ b/src/town_map.h
@@ -6,7 +6,7 @@
 #define TOWN_MAP_H
 
 #include "town.h"
-#include "date.h"
+#include "date_func.h"
 #include "tile_map.h"
 #include "functions.h"
 
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -35,7 +35,6 @@
 #include "newgrf_text.h"
 #include "direction_func.h"
 #include "yapf/yapf.h"
-#include "date.h"
 #include "cargotype.h"
 #include "group.h"
 #include "table/sprites.h"
@@ -43,6 +42,7 @@
 #include "strings_func.h"
 #include "functions.h"
 #include "window_func.h"
+#include "date_func.h"
 
 
 static bool TrainCheckIfLineEnds(Vehicle *v);
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -27,13 +27,13 @@
 #include "train.h"
 #include "water_map.h"
 #include "yapf/yapf.h"
-#include "date.h"
 #include "newgrf_sound.h"
 #include "autoslope.h"
 #include "transparency.h"
 #include "tunnelbridge_map.h"
 #include "table/bridge_land.h"
 #include "strings_func.h"
+#include "date_func.h"
 #include "functions.h"
 
 
--- a/src/variables.h
+++ b/src/variables.h
@@ -9,6 +9,7 @@
 #include "openttd.h"
 #include "tile_type.h"
 #include "strings_type.h"
+#include "date_type.h"
 
 /* ********* START OF SAVE REGION */
 
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -33,7 +33,6 @@
 #include "water_map.h"
 #include "network/network.h"
 #include "yapf/yapf.h"
-#include "date.h"
 #include "newgrf_callbacks.h"
 #include "newgrf_engine.h"
 #include "newgrf_sound.h"
@@ -42,6 +41,7 @@
 #include "strings_func.h"
 #include "zoom_func.h"
 #include "functions.h"
+#include "date_func.h"
 #include "window_func.h"
 
 #define INVALID_COORD (0x7fffffff)
--- a/src/vehicle.h
+++ b/src/vehicle.h
@@ -14,6 +14,7 @@
 #include "window_type.h"
 #include "gfx_type.h"
 #include "command_type.h"
+#include "date_type.h"
 #include "oldpool.h"
 #include "order.h"
 #include "cargopacket.h"
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -22,7 +22,6 @@
 #include "newgrf_callbacks.h"
 #include "newgrf_engine.h"
 #include "newgrf_text.h"
-#include "date.h"
 #include "ship.h"
 #include "aircraft.h"
 #include "roadveh.h"
--- a/src/waypoint.cpp
+++ b/src/waypoint.cpp
@@ -19,7 +19,6 @@
 #include "table/strings.h"
 #include "vehicle.h"
 #include "yapf/yapf.h"
-#include "date.h"
 #include "newgrf.h"
 #include "string.h"
 #include "misc/autoptr.hpp"
@@ -28,6 +27,7 @@
 #include "functions.h"
 #include "window_func.h"
 #include "economy_func.h"
+#include "date_func.h"
 
 enum {
 	MAX_WAYPOINTS_PER_TOWN = 64,
--- a/src/yapf/yapf.hpp
+++ b/src/yapf/yapf.hpp
@@ -16,7 +16,6 @@
 #include "../bridge.h"
 #include "../station.h"
 #include "../station_map.h"
-#include "../date.h"
 #include "../tile_cmd.h"
 #include "../landscape.h"
 #include "yapf.h"
--- a/src/yapf/yapf_costcache.hpp
+++ b/src/yapf/yapf_costcache.hpp
@@ -5,6 +5,7 @@
 #ifndef  YAPF_COSTCACHE_HPP
 #define  YAPF_COSTCACHE_HPP
 
+#include "../date_func.h"
 
 /** CYapfSegmentCostCacheNoneT - the formal only yapf cost cache provider that implements
  * PfNodeCacheFetch() and PfNodeCacheFlush() callbacks. Used when nodes don't have CachedData