changeset 8268:ab53b3bf7100 draft

(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
author rubidium <rubidium@openttd.org>
date Sun, 13 Jan 2008 13:36:01 +0000
parents e377a682e7a4
children d804368dc2db
files src/ai/ai.cpp src/ai/ai.h src/console.cpp src/console.h src/engine.cpp src/engine.h src/gui.h src/news.h src/news_gui.cpp src/openttd.cpp src/openttd.h src/order.h src/order_cmd.cpp src/settings_type.h src/signs.cpp src/signs.h src/station_gui.cpp src/station_gui.h src/town.h src/town_cmd.cpp src/window.cpp src/window_gui.h
diffstat 22 files changed, 111 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/src/ai/ai.cpp
+++ b/src/ai/ai.cpp
@@ -11,6 +11,9 @@
 #include "ai.h"
 #include "default/default.h"
 
+AIStruct _ai;
+AIPlayer _ai_player[MAX_PLAYERS];
+
 /**
  * Dequeues commands put in the queue via AI_PutCommandInQueue.
  */
--- a/src/ai/ai.h
+++ b/src/ai/ai.h
@@ -36,8 +36,8 @@
 	uint tick;              ///< The current tick (something like _frame_counter, only for AIs)
 };
 
-VARDEF AIStruct _ai;
-VARDEF AIPlayer _ai_player[MAX_PLAYERS];
+extern AIStruct _ai;
+extern AIPlayer _ai_player[MAX_PLAYERS];
 
 // ai.c
 void AI_StartNewAI(PlayerID player);
--- a/src/console.cpp
+++ b/src/console.cpp
@@ -29,6 +29,19 @@
 #define ICON_MAX_ALIAS_LINES 40
 #define ICON_TOKEN_COUNT 20
 
+/* console parser */
+IConsoleCmd   *_iconsole_cmds;    ///< list of registred commands
+IConsoleVar   *_iconsole_vars;    ///< list of registred vars
+IConsoleAlias *_iconsole_aliases; ///< list of registred aliases
+
+/* console colors/modes */
+byte _icolour_def;
+byte _icolour_err;
+byte _icolour_warn;
+byte _icolour_dbg;
+byte _icolour_cmd;
+IConsoleModes _iconsole_mode;
+
 /* ** main console ** */
 static char *_iconsole_buffer[ICON_BUFFER + 1];
 static uint16 _iconsole_cbuffer[ICON_BUFFER + 1];
--- a/src/console.h
+++ b/src/console.h
@@ -103,17 +103,17 @@
 };
 
 /* console parser */
-VARDEF IConsoleCmd   *_iconsole_cmds;    ///< list of registred commands
-VARDEF IConsoleVar   *_iconsole_vars;    ///< list of registred vars
-VARDEF IConsoleAlias *_iconsole_aliases; ///< list of registred aliases
+extern IConsoleCmd   *_iconsole_cmds;    ///< list of registred commands
+extern IConsoleVar   *_iconsole_vars;    ///< list of registred vars
+extern IConsoleAlias *_iconsole_aliases; ///< list of registred aliases
 
 /* console colors/modes */
-VARDEF byte _icolour_def;
-VARDEF byte _icolour_err;
-VARDEF byte _icolour_warn;
-VARDEF byte _icolour_dbg;
-VARDEF byte _icolour_cmd;
-VARDEF IConsoleModes _iconsole_mode;
+extern byte _icolour_def;
+extern byte _icolour_err;
+extern byte _icolour_warn;
+extern byte _icolour_dbg;
+extern byte _icolour_cmd;
+extern IConsoleModes _iconsole_mode;
 
 /* console functions */
 void IConsoleInit();
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -29,6 +29,7 @@
 #include "table/strings.h"
 #include "table/engines.h"
 
+Engine _engines[TOTAL_NUM_ENGINES];
 EngineInfo _engine_info[TOTAL_NUM_ENGINES];
 RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES];
 ShipVehicleInfo _ship_vehicle_info[NUM_SHIP_ENGINES];
--- a/src/engine.h
+++ b/src/engine.h
@@ -202,7 +202,7 @@
 	return end[type];
 }
 
-VARDEF Engine _engines[TOTAL_NUM_ENGINES];
+extern Engine _engines[TOTAL_NUM_ENGINES];
 #define FOR_ALL_ENGINES(e) for (e = _engines; e != endof(_engines); e++)
 #define FOR_ALL_ENGINEIDS_OF_TYPE(e, type) for (e = GetFirstEngineOfType(type); e != GetLastEngineOfType(type); e++)
 
--- a/src/gui.h
+++ b/src/gui.h
@@ -112,7 +112,6 @@
 
 /* main_gui.cpp */
 void HandleOnEditText(const char *str);
-VARDEF bool _station_show_coverage;
 
 void InitializeGUI();
 
--- a/src/news.h
+++ b/src/news.h
@@ -49,7 +49,7 @@
 void DrawNewsBorder(const Window *w);
 void InitNewsItemStructs();
 
-VARDEF NewsItem _statusbar_news_item;
+extern NewsItem _statusbar_news_item;
 
 /** Type of news. */
 enum NewsType {
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -51,6 +51,7 @@
 typedef byte NewsID;
 #define INVALID_NEWS 255
 
+NewsItem _statusbar_news_item;
 static NewsItem _news_items[MAX_NEWS];      ///< The news FIFO queue
 static NewsID _current_news = INVALID_NEWS; ///< points to news item that should be shown next
 static NewsID _oldest_news = 0;             ///< points to first item in fifo queue
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -319,6 +319,8 @@
 	if (_music_driver->IsSongPlaying()) ResetMusic();
 }
 
+byte _no_scroll;
+byte _savegame_sort_order;
 #if defined(UNIX) && !defined(__MORPHOS__)
 extern void DedicatedFork();
 #endif
--- a/src/openttd.h
+++ b/src/openttd.h
@@ -112,31 +112,6 @@
 	NUM_LANDSCAPE = 4,
 };
 
-#define GAME_DIFFICULTY_NUM 18
-
-/** Specific type for Game Difficulty to ease changing the type */
-typedef uint16 GDType;
-struct GameDifficulty {
-	GDType max_no_competitors;
-	GDType competitor_start_time;
-	GDType number_towns;
-	GDType number_industries;
-	GDType max_loan;
-	GDType initial_interest;
-	GDType vehicle_costs;
-	GDType competitor_speed;
-	GDType competitor_intelligence; // no longer in use
-	GDType vehicle_breakdowns;
-	GDType subsidy_multiplier;
-	GDType construction_cost;
-	GDType terrain_type;
-	GDType quantity_sea_lakes;
-	GDType economy;
-	GDType line_reverse_mode;
-	GDType disasters;
-	GDType town_council_tolerance; // minimum required town ratings to be allowed to demolish stuff
-};
-
 struct ViewportSign {
 	int32 left;
 	int32 top;
@@ -150,7 +125,7 @@
 	SORT_BY_NAME    = 2
 };
 
-VARDEF byte _savegame_sort_order;
+extern byte _savegame_sort_order;
 
 enum {
 	MAX_SCREEN_WIDTH  = 2048,
@@ -166,7 +141,7 @@
 	SCROLL_SAVE = 2,
 	SCROLL_CHAT = 4,
 };
-VARDEF byte _no_scroll;
+extern byte _no_scroll;
 
 /** To have a concurrently running thread interface with the main program, use
  * the OTTD_SendThreadMessage() function. Actions to perform upon the message are handled
--- a/src/order.h
+++ b/src/order.h
@@ -130,8 +130,8 @@
 	char *name;
 };
 
-VARDEF TileIndex _backup_orders_tile;
-VARDEF BackuppedOrders _backup_orders_data;
+extern TileIndex _backup_orders_tile;
+extern BackuppedOrders _backup_orders_data;
 
 static inline VehicleOrderID GetMaxOrderIndex()
 {
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -25,6 +25,9 @@
 
 #include "table/strings.h"
 
+TileIndex _backup_orders_tile;
+BackuppedOrders _backup_orders_data;
+
 DEFINE_OLD_POOL_GENERIC(Order, Order)
 
 /**
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -9,6 +9,31 @@
 #include "date_type.h"
 #include "town_type.h"
 
+#define GAME_DIFFICULTY_NUM 18
+
+/** Specific type for Game Difficulty to ease changing the type */
+typedef uint16 GDType;
+struct GameDifficulty {
+	GDType max_no_competitors;
+	GDType competitor_start_time;
+	GDType number_towns;
+	GDType number_industries;
+	GDType max_loan;
+	GDType initial_interest;
+	GDType vehicle_costs;
+	GDType competitor_speed;
+	GDType competitor_intelligence; // no longer in use
+	GDType vehicle_breakdowns;
+	GDType subsidy_multiplier;
+	GDType construction_cost;
+	GDType terrain_type;
+	GDType quantity_sea_lakes;
+	GDType economy;
+	GDType line_reverse_mode;
+	GDType disasters;
+	GDType town_council_tolerance; // minimum required town ratings to be allowed to demolish stuff
+};
+
 struct GameOptions {
 	GameDifficulty diff;
 	byte diff_level;
--- a/src/signs.cpp
+++ b/src/signs.cpp
@@ -23,6 +23,7 @@
 
 SignID _new_sign_id;
 uint _total_signs;
+bool _sign_sort_dirty;
 
 /* Initialize the sign-pool */
 DEFINE_OLD_POOL_GENERIC(Sign, Sign)
--- a/src/signs.h
+++ b/src/signs.h
@@ -60,7 +60,7 @@
 #define FOR_ALL_SIGNS_FROM(ss, start) for (ss = GetSign(start); ss != NULL; ss = (ss->index + 1U < GetSignPoolSize()) ? GetSign(ss->index + 1U) : NULL) if (ss->IsValid())
 #define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0)
 
-VARDEF bool _sign_sort_dirty;
+extern bool _sign_sort_dirty;
 
 void UpdateAllSignVirtCoords();
 void PlaceProc_Sign(TileIndex tile);
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -34,6 +34,8 @@
 static StationSortListingTypeFunction StationWaitingSorter;
 static StationSortListingTypeFunction StationRatingMaxSorter;
 
+bool _station_show_coverage;
+
 /**
  * Draw small boxes of cargo amount and ratings data at the given
  * coordinates. If amount exceeds 576 units, it is shown 'full', same
--- a/src/station_gui.h
+++ b/src/station_gui.h
@@ -61,4 +61,6 @@
 void DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad);
 void CheckRedrawStationCoverage(const Window *w);
 
+extern bool _station_show_coverage;
+
 #endif /* STATION_GUI_H */
--- a/src/town.h
+++ b/src/town.h
@@ -198,7 +198,7 @@
 	const struct GRFFile *grffile;     ///< grf file that introduced this house
 };
 
-VARDEF HouseSpec _house_specs[HOUSE_MAX];
+extern HouseSpec _house_specs[HOUSE_MAX];
 
 uint32 GetWorldPopulation();
 
@@ -239,8 +239,6 @@
 
 bool CheckforTownRating(uint32 flags, Town *t, byte type);
 
-VARDEF const Town** _town_sort;
-
 static inline HouseSpec *GetHouseSpecs(HouseID house_id)
 {
 	assert(house_id < HOUSE_MAX);
@@ -257,8 +255,6 @@
 	return index < GetTownPoolSize() && GetTown(index)->IsValid();
 }
 
-VARDEF uint _total_towns;
-
 static inline TownID GetMaxTownIndex()
 {
 	/* TODO - This isn't the real content of the function, but
@@ -271,6 +267,8 @@
 
 static inline uint GetNumTowns()
 {
+	extern uint _total_towns;
+
 	return _total_towns;
 }
 
@@ -296,16 +294,17 @@
 	return GetTown(index);
 }
 
-Town* CalcClosestTownFromTile(TileIndex tile, uint threshold);
+Town *CalcClosestTownFromTile(TileIndex tile, uint threshold);
 
 #define FOR_ALL_TOWNS_FROM(t, start) for (t = GetTown(start); t != NULL; t = (t->index + 1U < GetTownPoolSize()) ? GetTown(t->index + 1U) : NULL) if (t->IsValid())
 #define FOR_ALL_TOWNS(t) FOR_ALL_TOWNS_FROM(t, 0)
 
-VARDEF bool _town_sort_dirty;
-VARDEF byte _town_sort_order;
+extern bool _town_sort_dirty;
+extern byte _town_sort_order;
+extern const Town **_town_sort;
 
-VARDEF Town *_cleared_town;
-VARDEF int _cleared_town_rating;
+extern Town *_cleared_town;
+extern int _cleared_town_rating;
 
 uint OriginalTileRandomiser(uint x, uint y);
 void ResetHouses();
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -44,6 +44,16 @@
 #include "table/sprites.h"
 #include "table/town_land.h"
 
+uint _total_towns;
+HouseSpec _house_specs[HOUSE_MAX];
+
+bool _town_sort_dirty;
+byte _town_sort_order;
+const Town **_town_sort;
+
+Town *_cleared_town;
+int _cleared_town_rating;
+
 /* Initialize the town-pool */
 DEFINE_OLD_POOL_GENERIC(Town, Town)
 
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -28,6 +28,19 @@
 Window *_z_windows[lengthof(_windows)];
 Window **_last_z_window; ///< always points to the next free space in the z-array
 
+Point _cursorpos_drag_start;
+
+int _scrollbar_start_pos;
+int _scrollbar_size;
+byte _scroller_click_timeout;
+
+bool _scrolling_scrollbar;
+bool _scrolling_viewport;
+bool _popup_menu_active;
+
+byte _special_mouse_mode;
+
+
 void CDECL Window::SetWidgetsDisabledState(bool disab_stat, int widgets, ...)
 {
 	va_list wdg_list;
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -607,17 +607,17 @@
 extern Window **_last_z_window;
 #define FOR_ALL_WINDOWS(wz) for (wz = _z_windows; wz != _last_z_window; wz++)
 
-VARDEF Point _cursorpos_drag_start;
+extern Point _cursorpos_drag_start;
 
-VARDEF int _scrollbar_start_pos;
-VARDEF int _scrollbar_size;
-VARDEF byte _scroller_click_timeout;
+extern int _scrollbar_start_pos;
+extern int _scrollbar_size;
+extern byte _scroller_click_timeout;
 
-VARDEF bool _scrolling_scrollbar;
-VARDEF bool _scrolling_viewport;
-VARDEF bool _popup_menu_active;
+extern bool _scrolling_scrollbar;
+extern bool _scrolling_viewport;
+extern bool _popup_menu_active;
 
-VARDEF byte _special_mouse_mode;
+extern byte _special_mouse_mode;
 enum SpecialMouseMode {
 	WSM_NONE     = 0,
 	WSM_DRAGDROP = 1,