changeset 8213:87c85bb42d6f draft

(svn r11776) -Codechange: more header splittings to reduce the dependencies.
author rubidium <rubidium@openttd.org>
date Mon, 07 Jan 2008 14:02:26 +0000 (2008-01-07)
parents 11263ebe590a
children 6385dffc0b37
files src/clear_map.h src/economy_func.h src/gfxinit.cpp src/industry.h src/industry_type.h src/network/network_gui.cpp src/newgrf.h src/newgrf_config.cpp src/newgrf_engine.cpp src/newgrf_gui.cpp src/newgrf_house.h src/newgrf_industries.cpp src/newgrf_industries.h src/newgrf_industrytiles.cpp src/newgrf_spritegroup.h src/newgrf_text.cpp src/openttd.h src/road_map.h src/settings.cpp src/settings_gui.cpp src/settings_type.h src/station.h src/town.h src/town_type.h src/vehicle_gui.cpp
diffstat 25 files changed, 127 insertions(+), 85 deletions(-) [+]
line wrap: on
line diff
--- a/src/clear_map.h
+++ b/src/clear_map.h
@@ -6,6 +6,7 @@
 #define CLEAR_MAP_H
 
 #include "bridge_map.h"
+#include "industry_type.h"
 
 /**
  * Ground types. Valid densities in comments after the enum.
--- a/src/economy_func.h
+++ b/src/economy_func.h
@@ -10,6 +10,8 @@
 #include "cargo_type.h"
 #include "vehicle_type.h"
 #include "tile_type.h"
+#include "town_type.h"
+#include "industry_type.h"
 
 struct Player;
 
--- a/src/gfxinit.cpp
+++ b/src/gfxinit.cpp
@@ -16,6 +16,7 @@
 #include "variables.h"
 #include "fontcache.h"
 #include "gfx_func.h"
+#include "core/alloc_func.hpp"
 #include <string.h>
 
 struct MD5File {
--- a/src/industry.h
+++ b/src/industry.h
@@ -13,9 +13,8 @@
 #include "map_type.h"
 #include "slope_type.h"
 #include "date_type.h"
-
-typedef uint16 IndustryGfx;
-typedef uint8 IndustryType;
+#include "town_type.h"
+#include "industry_type.h"
 
 enum {
 	INVALID_INDUSTRY       = 0xFFFF,
@@ -64,13 +63,6 @@
 	ICT_SCENARIO_EDITOR   ///< while scenarion edition
 };
 
-/** From where is callback CBID_INDUSTRY_AVAILABLE been called */
-enum IndustryAvailabilityCallType {
-	IACT_MAPGENERATION,   ///< during random map generation
-	IACT_RANDOMCREATION,  ///< during creation of random ingame industry
-	IACT_USERCREATION,    ///< from the Fund/build window
-};
-
 enum IndustryBehaviour {
 	INDUSTRYBEH_NONE                  =      0,
 	INDUSTRYBEH_PLANT_FIELDS          = 1 << 0,  ///< periodically plants fileds around itself (temp and artic farms)
@@ -97,7 +89,6 @@
 
 DECLARE_ENUM_AS_BIT_SET(IndustryBehaviour);
 
-struct Industry;
 DECLARE_OLD_POOL(Industry, Industry, 3, 8000)
 
 /**
new file mode 100644
--- /dev/null
+++ b/src/industry_type.h
@@ -0,0 +1,16 @@
+/* $Id$ */
+
+/** @file industry_type.h Types related to the industry. */
+
+#ifndef INDUSTRY_TYPE_H
+#define INDUSTRY_TYPE_H
+
+typedef uint16 IndustryID;
+typedef uint16 IndustryGfx;
+typedef uint8 IndustryType;
+struct Industry;
+
+struct IndustrySpec;
+struct IndustryTileSpec;
+
+#endif /* INDUSTRY_TYPE_H */
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -26,6 +26,7 @@
 #include "../newgrf.h"
 #include "../functions.h"
 #include "../window_func.h"
+#include "../core/alloc_func.hpp"
 
 #define BGC 5
 #define BTC 15
--- a/src/newgrf.h
+++ b/src/newgrf.h
@@ -6,10 +6,10 @@
 #define NEWGRF_H
 
 #include "station.h"
-#include "town.h"
+#include "town_type.h"
 #include "newgrf_config.h"
 #include "cargotype.h"
-#include "industry.h"
+#include "industry_type.h"
 
 enum GrfLoadingStage {
 	GLS_FILESCAN,
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -12,6 +12,7 @@
 #include "network/network_data.h"
 #include "newgrf.h"
 #include "newgrf_config.h"
+#include "core/alloc_func.hpp"
 
 #include "fileio.h"
 #include "fios.h"
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -20,6 +20,7 @@
 #include "cargotype.h"
 #include "date_func.h"
 #include "vehicle_func.h"
+#include "core/random_func.hpp"
 
 
 int _traininfo_vehicle_pitch = 0;
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -14,6 +14,7 @@
 #include "newgrf_config.h"
 #include "strings_func.h"
 #include "window_func.h"
+#include "core/alloc_func.hpp"
 
 /** Parse an integerlist string and set each found value
  * @param p the string to be parsed. Each element in the list is seperated by a
--- a/src/newgrf_house.h
+++ b/src/newgrf_house.h
@@ -5,7 +5,7 @@
 #ifndef NEWGRF_HOUSE_H
 #define NEWGRF_HOUSE_H
 
-#include "town.h"
+#include "town_type.h"
 #include "newgrf_callbacks.h"
 
 /**
--- a/src/newgrf_industries.cpp
+++ b/src/newgrf_industries.cpp
@@ -19,6 +19,7 @@
 #include "newgrf_text.h"
 #include "newgrf_town.h"
 #include "window_func.h"
+#include "town.h"
 
 /* Since the industry IDs defined by the GRF file don't necessarily correlate
  * to those used by the game, the IDs used for overriding old industries must be
--- a/src/newgrf_industries.h
+++ b/src/newgrf_industries.h
@@ -5,7 +5,7 @@
 #ifndef NEWGRF_INDUSTRIES_H
 #define NEWGRF_INDUSTRIES_H
 
-#include "industry.h"
+#include "industry_type.h"
 #include "newgrf_spritegroup.h"
 
 /** When should the industry(tile) be triggered for random bits? */
@@ -18,6 +18,13 @@
 	INDUSTRY_TRIGGER_CARGO_DELIVERY   = 4,
 };
 
+/** From where is callback CBID_INDUSTRY_AVAILABLE been called */
+enum IndustryAvailabilityCallType {
+	IACT_MAPGENERATION,   ///< during random map generation
+	IACT_RANDOMCREATION,  ///< during creation of random ingame industry
+	IACT_USERCREATION,    ///< from the Fund/build window
+};
+
 /* in newgrf_industry.cpp */
 uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available);
 uint16 GetIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile);
--- a/src/newgrf_industrytiles.cpp
+++ b/src/newgrf_industrytiles.cpp
@@ -23,6 +23,7 @@
 #include "sprite.h"
 #include "transparency.h"
 #include "functions.h"
+#include "town.h"
 
 static uint32 GetGRFParameter(IndustryGfx indtile_id, byte parameter)
 {
--- a/src/newgrf_spritegroup.h
+++ b/src/newgrf_spritegroup.h
@@ -5,8 +5,8 @@
 #ifndef NEWGRF_SPRITEGROUP_H
 #define NEWGRF_SPRITEGROUP_H
 
-#include "town.h"
-#include "industry.h"
+#include "town_type.h"
+#include "industry_type.h"
 #include "newgrf_storage.h"
 #include "core/bitmath_func.hpp"
 #include "gfx_type.h"
--- a/src/newgrf_text.cpp
+++ b/src/newgrf_text.cpp
@@ -19,6 +19,8 @@
 #include "newgrf_text.h"
 #include "table/control_codes.h"
 #include "strings_func.h"
+#include "core/alloc_func.hpp"
+#include "newgrf_storage.h"
 
 #define GRFTAB  28
 #define TABSIZE 11
--- a/src/openttd.h
+++ b/src/openttd.h
@@ -16,9 +16,7 @@
 struct Waypoint;
 struct Station;
 struct ViewPort;
-struct Town;
 struct NewsItem;
-struct Industry;
 struct DrawPixelInfo;
 struct Group;
 typedef byte VehicleOrderID;  ///< The index of an order within its current vehicle (not pool related)
@@ -32,8 +30,6 @@
 typedef uint16 StationID;
 static const StationID INVALID_STATION = 0xFFFF;
 typedef uint16 RoadStopID;
-typedef uint16 TownID;
-typedef uint16 IndustryID;
 typedef uint16 DepotID;
 typedef uint16 WaypointID;
 typedef uint16 OrderID;
@@ -153,24 +149,6 @@
 	NUM_LANDSCAPE = 4,
 };
 
-/**
- * Town Layouts
- */
-enum TownLayout {
-	TL_NO_ROADS     = 0, ///< Build no more roads, but still build houses
-	TL_ORIGINAL,         ///< Original algorithm (min. 1 distance between roads)
-	TL_BETTER_ROADS,     ///< Extended original algorithm (min. 2 distance between roads)
-	TL_2X2_GRID,         ///< Geometric 2x2 grid algorithm
-	TL_3X3_GRID,         ///< Geometric 3x3 grid algorithm
-
-	NUM_TLS,             ///< Number of town layouts
-};
-
-/* It needs to be 8bits, because we save and load it as such */
-/** Define basic enum properties */
-template <> struct EnumPropsT<TownLayout> : MakeEnumPropsT<TownLayout, byte, TL_NO_ROADS, NUM_TLS, NUM_TLS> {};
-typedef TinyEnumT<TownLayout> TownLayoutByte; //typedefing-enumification of TownLayout
-
 #define GAME_DIFFICULTY_NUM 18
 
 /** Specific type for Game Difficulty to ease changing the type */
--- a/src/road_map.h
+++ b/src/road_map.h
@@ -7,6 +7,7 @@
 
 #include "track_func.h"
 #include "rail_type.h"
+#include "town_type.h"
 #include "road_func.h"
 #include "tile_map.h"
 
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -42,6 +42,7 @@
 #include "strings_func.h"
 #include "vehicle_func.h"
 #include "sound_func.h"
+#include "core/alloc_func.hpp"
 #ifdef WITH_FREETYPE
 #include "fontcache.h"
 #endif
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -24,6 +24,7 @@
 #include "functions.h"
 #include "window_func.h"
 #include "vehicle_base.h"
+#include "core/alloc_func.hpp"
 
 static uint32 _difficulty_click_a;
 static uint32 _difficulty_click_b;
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -7,6 +7,7 @@
 
 #include "yapf/yapf_settings.h"
 #include "date_type.h"
+#include "town_type.h"
 
 struct GameOptions {
 	GameDifficulty diff;
--- a/src/station.h
+++ b/src/station.h
@@ -13,6 +13,7 @@
 #include "newgrf_station.h"
 #include "cargopacket.h"
 #include "cargo_type.h"
+#include "town_type.h"
 #include "core/geometry_type.hpp"
 #include <list>
 #include <set>
--- a/src/town.h
+++ b/src/town.h
@@ -10,6 +10,7 @@
 #include "cargo_type.h"
 #include "tile_type.h"
 #include "date_type.h"
+#include "town_type.h"
 
 enum {
 	HOUSE_NO_CLASS   = 0,
@@ -68,15 +69,11 @@
 
 DECLARE_ENUM_AS_BIT_SET(HouseExtraFlags)
 
-typedef uint16 HouseID;
-typedef uint16 HouseClassID;
-
 struct BuildingCounts {
 	uint8 id_count[HOUSE_MAX];
 	uint8 class_count[HOUSE_CLASS_MAX];
 };
 
-struct Town;
 DECLARE_OLD_POOL(Town, Town, 3, 8000)
 
 struct Town : PoolItem<Town, TownID, &_Town_pool> {
@@ -197,12 +194,6 @@
 	const struct GRFFile *grffile;     ///< grf file that introduced this house
 };
 
-enum TownSizeMode {
-	TSM_RANDOM,
-	TSM_FIXED,
-	TSM_CITY
-};
-
 VARDEF HouseSpec _house_specs[HOUSE_MAX];
 
 uint32 GetWorldPopulation();
@@ -221,42 +212,6 @@
 	INDUSTRY_REMOVE = 2
 };
 
-enum {
-	/* These refer to the maximums, so Appalling is -1000 to -400
-	 * MAXIMUM RATINGS BOUNDARIES */
-	RATING_MINIMUM     = -1000,
-	RATING_APPALLING   =  -400,
-	RATING_VERYPOOR    =  -200,
-	RATING_POOR        =     0,
-	RATING_MEDIOCRE    =   200,
-	RATING_GOOD        =   400,
-	RATING_VERYGOOD    =   600,
-	RATING_EXCELLENT   =   800,
-	RATING_OUTSTANDING =  1000,         ///< OUTSTANDING
-
-	RATING_MAXIMUM = RATING_OUTSTANDING,
-
-	/* RATINGS AFFECTING NUMBERS */
-	RATING_TREE_DOWN_STEP = -35,
-	RATING_TREE_MINIMUM   = RATING_MINIMUM,
-	RATING_TREE_UP_STEP   = 7,
-	RATING_TREE_MAXIMUM   = 220,
-
-	RATING_TUNNEL_BRIDGE_DOWN_STEP = -250,
-	RATING_TUNNEL_BRIDGE_MINIMUM   = 0,
-
-	RATING_INDUSTRY_DOWN_STEP = -1500,
-	RATING_INDUSTRY_MINIMUM   = RATING_MINIMUM,
-
-	RATING_ROAD_DOWN_STEP = -50,
-	RATING_ROAD_MINIMUM   = -100,
-	RATING_HOUSE_MINIMUM  = RATING_MINIMUM,
-
-	RATING_BRIBE_UP_STEP = 200,
-	RATING_BRIBE_MAXIMUM = 800,
-	RATING_BRIBE_DOWN_TO = -50        // XXX SHOULD BE SOMETHING LOWER?
-};
-
 /** This is the number of ticks between towns being processed for building new
  * houses or roads. This value originally came from the size of the town array
  * in TTD. */
new file mode 100644
--- /dev/null
+++ b/src/town_type.h
@@ -0,0 +1,77 @@
+/* $Id$ */
+
+/** @file town_type.h Types related to towns. */
+
+#ifndef TOWN_TYPE_H
+#define TOWN_TYPE_H
+
+#include "core/enum_type.hpp"
+
+typedef uint16 TownID;
+typedef uint16 HouseID;
+typedef uint16 HouseClassID;
+
+struct Town;
+struct HouseSpec;
+
+enum TownSizeMode {
+	TSM_RANDOM,
+	TSM_FIXED,
+	TSM_CITY
+};
+
+enum {
+	/* These refer to the maximums, so Appalling is -1000 to -400
+	 * MAXIMUM RATINGS BOUNDARIES */
+	RATING_MINIMUM     = -1000,
+	RATING_APPALLING   =  -400,
+	RATING_VERYPOOR    =  -200,
+	RATING_POOR        =     0,
+	RATING_MEDIOCRE    =   200,
+	RATING_GOOD        =   400,
+	RATING_VERYGOOD    =   600,
+	RATING_EXCELLENT   =   800,
+	RATING_OUTSTANDING =  1000,         ///< OUTSTANDING
+
+	RATING_MAXIMUM = RATING_OUTSTANDING,
+
+	/* RATINGS AFFECTING NUMBERS */
+	RATING_TREE_DOWN_STEP = -35,
+	RATING_TREE_MINIMUM   = RATING_MINIMUM,
+	RATING_TREE_UP_STEP   = 7,
+	RATING_TREE_MAXIMUM   = 220,
+
+	RATING_TUNNEL_BRIDGE_DOWN_STEP = -250,
+	RATING_TUNNEL_BRIDGE_MINIMUM   = 0,
+
+	RATING_INDUSTRY_DOWN_STEP = -1500,
+	RATING_INDUSTRY_MINIMUM   = RATING_MINIMUM,
+
+	RATING_ROAD_DOWN_STEP = -50,
+	RATING_ROAD_MINIMUM   = -100,
+	RATING_HOUSE_MINIMUM  = RATING_MINIMUM,
+
+	RATING_BRIBE_UP_STEP = 200,
+	RATING_BRIBE_MAXIMUM = 800,
+	RATING_BRIBE_DOWN_TO = -50        // XXX SHOULD BE SOMETHING LOWER?
+};
+
+/**
+ * Town Layouts
+ */
+enum TownLayout {
+	TL_NO_ROADS     = 0, ///< Build no more roads, but still build houses
+	TL_ORIGINAL,         ///< Original algorithm (min. 1 distance between roads)
+	TL_BETTER_ROADS,     ///< Extended original algorithm (min. 2 distance between roads)
+	TL_2X2_GRID,         ///< Geometric 2x2 grid algorithm
+	TL_3X3_GRID,         ///< Geometric 3x3 grid algorithm
+
+	NUM_TLS,             ///< Number of town layouts
+};
+
+/* It needs to be 8bits, because we save and load it as such */
+/** Define basic enum properties */
+template <> struct EnumPropsT<TownLayout> : MakeEnumPropsT<TownLayout, byte, TL_NO_ROADS, NUM_TLS, NUM_TLS> {};
+typedef TinyEnumT<TownLayout> TownLayoutByte; //typedefing-enumification of TownLayout
+
+#endif /* TOWN_TYPE_H */
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -33,6 +33,7 @@
 #include "window_func.h"
 #include "vehicle_func.h"
 #include "autoreplace_gui.h"
+#include "core/alloc_func.hpp"
 
 struct Sorting {
 	Listing aircraft;