diff options
author | rubidium <rubidium@openttd.org> | 2014-04-23 20:13:33 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2014-04-23 20:13:33 +0000 |
commit | 0463dbdc9e5b39399765015c394e29dedaf7d041 (patch) | |
tree | 0d115f2027997f6c452d59d63919f9a6d05cb8be /src | |
parent | 287ecd158249628a9b12aa5567e0e188499084f5 (diff) | |
download | openttd-0463dbdc9e5b39399765015c394e29dedaf7d041.tar.xz |
(svn r26482) -Codechange: add an include that allows us to undefine/redefine "unsafe" functions to prevent them from being used, and thus having to care about certain aspects of their return values
Diffstat (limited to 'src')
402 files changed, 873 insertions, 1 deletions
diff --git a/src/3rdparty/md5/md5.cpp b/src/3rdparty/md5/md5.cpp index d2d6fbab7..2111a8eb8 100644 --- a/src/3rdparty/md5/md5.cpp +++ b/src/3rdparty/md5/md5.cpp @@ -60,6 +60,8 @@ #include "../../core/endian_func.hpp" #include "md5.h" +#include "../../safeguards.h" + #define T_MASK ((uint32)~0) #define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87) #define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9) diff --git a/src/ai/ai_config.cpp b/src/ai/ai_config.cpp index 3b3c09a42..65365f4d4 100644 --- a/src/ai/ai_config.cpp +++ b/src/ai/ai_config.cpp @@ -15,6 +15,8 @@ #include "ai_config.hpp" #include "ai_info.hpp" +#include "../safeguards.h" + /** Configuration for AI start date, every AI has this setting. */ ScriptConfigItem _start_date_config = { "start_date", diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp index 3f4381b0c..d4ff23311 100644 --- a/src/ai/ai_core.cpp +++ b/src/ai/ai_core.cpp @@ -22,6 +22,8 @@ #include "ai_info.hpp" #include "ai.hpp" +#include "../safeguards.h" + /* static */ uint AI::frame_counter = 0; /* static */ AIScannerInfo *AI::scanner_info = NULL; /* static */ AIScannerLibrary *AI::scanner_library = NULL; diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 8bcc41455..885c9bee8 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -40,11 +40,12 @@ #include "../game/game_info.hpp" #include "../game/game_instance.hpp" - #include "table/strings.h" #include <vector> +#include "../safeguards.h" + static ScriptConfig *GetConfig(CompanyID slot) { if (slot == OWNER_DEITY) return GameConfig::GetConfig(); diff --git a/src/ai/ai_info.cpp b/src/ai/ai_info.cpp index 375248d7d..9c9f3b47e 100644 --- a/src/ai/ai_info.cpp +++ b/src/ai/ai_info.cpp @@ -17,6 +17,8 @@ #include "../debug.h" #include "../rev.h" +#include "../safeguards.h" + /** * Check if the API version provided by the AI is supported. * @param api_version The API version as provided by the AI. diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp index f109a0926..1c304c856 100644 --- a/src/ai/ai_instance.cpp +++ b/src/ai/ai_instance.cpp @@ -82,6 +82,8 @@ #include "../company_base.h" #include "../company_func.h" +#include "../safeguards.h" + AIInstance::AIInstance() : ScriptInstance("AI") {} diff --git a/src/ai/ai_scanner.cpp b/src/ai/ai_scanner.cpp index 64b877c6c..7c2bff778 100644 --- a/src/ai/ai_scanner.cpp +++ b/src/ai/ai_scanner.cpp @@ -18,6 +18,8 @@ #include "ai_info.hpp" #include "ai_scanner.hpp" +#include "../safeguards.h" + AIScannerInfo::AIScannerInfo() : ScriptScanner(), diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index ee89fbf0d..2f49158eb 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -39,6 +39,8 @@ #include "table/strings.h" +#include "safeguards.h" + static const int ROTOR_Z_OFFSET = 5; ///< Z Offset between helicopter- and rotorsprite. static const int PLANE_HOLDING_ALTITUDE = 150; ///< Altitude of planes in holding pattern (= lowest flight altitude). diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp index 6db75d3af..2c58b68c8 100644 --- a/src/aircraft_gui.cpp +++ b/src/aircraft_gui.cpp @@ -21,6 +21,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** * Draw the details for the given vehicle at the given position * diff --git a/src/airport.cpp b/src/airport.cpp index c3c67effc..a50c049c2 100644 --- a/src/airport.cpp +++ b/src/airport.cpp @@ -15,6 +15,8 @@ #include "table/airport_movement.h" #include "table/airporttile_ids.h" +#include "safeguards.h" + /** * Define a generic airport. diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 4ad4789ff..761466f1a 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -31,6 +31,8 @@ #include "widgets/airport_widget.h" +#include "safeguards.h" + static AirportClassID _selected_airport_class; ///< the currently visible airport class static int _selected_airport_index; ///< the index of the selected airport in the current class or -1 diff --git a/src/animated_tile.cpp b/src/animated_tile.cpp index 8995275e9..78dda8b3b 100644 --- a/src/animated_tile.cpp +++ b/src/animated_tile.cpp @@ -14,6 +14,8 @@ #include "tile_cmd.h" #include "viewport_func.h" +#include "safeguards.h" + /** The table/list with animated tiles. */ TileIndex *_animated_tile_list = NULL; /** The number of animated tiles in the current state. */ diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp index 501af719d..859d9a750 100644 --- a/src/articulated_vehicles.cpp +++ b/src/articulated_vehicles.cpp @@ -19,6 +19,8 @@ #include "table/strings.h" +#include "safeguards.h" + static const uint MAX_ARTICULATED_PARTS = 100; ///< Maximum of articulated parts per vehicle, i.e. when to abort calling the articulated vehicle callback. /** diff --git a/src/autoreplace.cpp b/src/autoreplace.cpp index 0788fccb3..3b7f73972 100644 --- a/src/autoreplace.cpp +++ b/src/autoreplace.cpp @@ -15,6 +15,8 @@ #include "autoreplace_base.h" #include "core/pool_func.hpp" +#include "safeguards.h" + /** The pool of autoreplace "orders". */ EngineRenewPool _enginerenew_pool("EngineRenew"); INSTANTIATE_POOL_METHODS(EngineRenew) diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index 2e13caffb..e69ac66eb 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -22,6 +22,8 @@ #include "table/strings.h" +#include "safeguards.h" + extern void ChangeVehicleViewports(VehicleID from_index, VehicleID to_index); extern void ChangeVehicleNews(VehicleID from_index, VehicleID to_index); extern void ChangeVehicleViewWindow(VehicleID from_index, VehicleID to_index); diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index dc1f5ed73..c53df993f 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -28,6 +28,8 @@ #include "widgets/autoreplace_widget.h" +#include "safeguards.h" + uint GetEngineListHeight(VehicleType type); void DrawEngineList(VehicleType type, int x, int r, int y, const GUIEngineList *eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count, GroupID selected_group); diff --git a/src/base_consist.cpp b/src/base_consist.cpp index 005c88672..805e1d58f 100644 --- a/src/base_consist.cpp +++ b/src/base_consist.cpp @@ -13,6 +13,8 @@ #include "base_consist.h" #include "vehicle_base.h" +#include "safeguards.h" + BaseConsist::~BaseConsist() { free(this->name); diff --git a/src/blitter/32bpp_anim.cpp b/src/blitter/32bpp_anim.cpp index 80ec54da4..71c3e0a34 100644 --- a/src/blitter/32bpp_anim.cpp +++ b/src/blitter/32bpp_anim.cpp @@ -15,6 +15,8 @@ #include "../table/sprites.h" +#include "../safeguards.h" + /** Instantiation of the 32bpp with animation blitter factory. */ static FBlitter_32bppAnim iFBlitter_32bppAnim; diff --git a/src/blitter/32bpp_anim_sse4.cpp b/src/blitter/32bpp_anim_sse4.cpp index d456da22d..f25683a10 100644 --- a/src/blitter/32bpp_anim_sse4.cpp +++ b/src/blitter/32bpp_anim_sse4.cpp @@ -17,6 +17,8 @@ #include "32bpp_anim_sse4.hpp" #include "32bpp_sse_func.hpp" +#include "../safeguards.h" + /** Instantiation of the SSE4 32bpp blitter factory. */ static FBlitter_32bppSSE4_Anim iFBlitter_32bppSSE4_Anim; diff --git a/src/blitter/32bpp_base.cpp b/src/blitter/32bpp_base.cpp index 3ea03327f..26dd2f037 100644 --- a/src/blitter/32bpp_base.cpp +++ b/src/blitter/32bpp_base.cpp @@ -12,6 +12,8 @@ #include "../stdafx.h" #include "32bpp_base.hpp" +#include "../safeguards.h" + void *Blitter_32bppBase::MoveTo(void *video, int x, int y) { return (uint32 *)video + x + y * _screen.pitch; diff --git a/src/blitter/32bpp_optimized.cpp b/src/blitter/32bpp_optimized.cpp index 5d2332883..9b7d7115c 100644 --- a/src/blitter/32bpp_optimized.cpp +++ b/src/blitter/32bpp_optimized.cpp @@ -14,6 +14,8 @@ #include "../settings_type.h" #include "32bpp_optimized.hpp" +#include "../safeguards.h" + /** Instantiation of the optimized 32bpp blitter factory. */ static FBlitter_32bppOptimized iFBlitter_32bppOptimized; diff --git a/src/blitter/32bpp_simple.cpp b/src/blitter/32bpp_simple.cpp index 30443c50b..0ad7418db 100644 --- a/src/blitter/32bpp_simple.cpp +++ b/src/blitter/32bpp_simple.cpp @@ -15,6 +15,8 @@ #include "../table/sprites.h" +#include "../safeguards.h" + /** Instantiation of the simple 32bpp blitter factory. */ static FBlitter_32bppSimple iFBlitter_32bppSimple; diff --git a/src/blitter/32bpp_sse2.cpp b/src/blitter/32bpp_sse2.cpp index 5b7316cce..ae2b3ccc5 100644 --- a/src/blitter/32bpp_sse2.cpp +++ b/src/blitter/32bpp_sse2.cpp @@ -17,6 +17,8 @@ #include "32bpp_sse2.hpp" #include "32bpp_sse_func.hpp" +#include "../safeguards.h" + /** Instantiation of the SSE2 32bpp blitter factory. */ static FBlitter_32bppSSE2 iFBlitter_32bppSSE2; diff --git a/src/blitter/32bpp_sse4.cpp b/src/blitter/32bpp_sse4.cpp index dab0d8f3e..723264f03 100644 --- a/src/blitter/32bpp_sse4.cpp +++ b/src/blitter/32bpp_sse4.cpp @@ -17,6 +17,8 @@ #include "32bpp_sse4.hpp" #include "32bpp_sse_func.hpp" +#include "../safeguards.h" + /** Instantiation of the SSE4 32bpp blitter factory. */ static FBlitter_32bppSSE4 iFBlitter_32bppSSE4; diff --git a/src/blitter/32bpp_ssse3.cpp b/src/blitter/32bpp_ssse3.cpp index 33d49648e..ab6c9eba5 100644 --- a/src/blitter/32bpp_ssse3.cpp +++ b/src/blitter/32bpp_ssse3.cpp @@ -17,6 +17,8 @@ #include "32bpp_ssse3.hpp" #include "32bpp_sse_func.hpp" +#include "../safeguards.h" + /** Instantiation of the SSSE3 32bpp blitter factory. */ static FBlitter_32bppSSSE3 iFBlitter_32bppSSSE3; diff --git a/src/blitter/8bpp_base.cpp b/src/blitter/8bpp_base.cpp index f2ba70405..eab6eaa0d 100644 --- a/src/blitter/8bpp_base.cpp +++ b/src/blitter/8bpp_base.cpp @@ -13,6 +13,8 @@ #include "../gfx_func.h" #include "8bpp_base.hpp" +#include "../safeguards.h" + void Blitter_8bppBase::DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) { const uint8 *ctab = GetNonSprite(pal, ST_RECOLOUR) + 1; diff --git a/src/blitter/8bpp_optimized.cpp b/src/blitter/8bpp_optimized.cpp index 31661c360..bcd8dc282 100644 --- a/src/blitter/8bpp_optimized.cpp +++ b/src/blitter/8bpp_optimized.cpp @@ -15,6 +15,8 @@ #include "../core/math_func.hpp" #include "8bpp_optimized.hpp" +#include "../safeguards.h" + /** Instantiation of the 8bpp optimised blitter factory. */ static FBlitter_8bppOptimized iFBlitter_8bppOptimized; diff --git a/src/blitter/8bpp_simple.cpp b/src/blitter/8bpp_simple.cpp index d98cff1c9..d24d8caac 100644 --- a/src/blitter/8bpp_simple.cpp +++ b/src/blitter/8bpp_simple.cpp @@ -13,6 +13,8 @@ #include "../zoom_func.h" #include "8bpp_simple.hpp" +#include "../safeguards.h" + /** Instantiation of the simple 8bpp blitter factory. */ static FBlitter_8bppSimple iFBlitter_8bppSimple; diff --git a/src/blitter/base.cpp b/src/blitter/base.cpp index d30f4054b..e83df2e71 100644 --- a/src/blitter/base.cpp +++ b/src/blitter/base.cpp @@ -13,6 +13,8 @@ #include "base.hpp" #include "../core/math_func.hpp" +#include "../safeguards.h" + void Blitter::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) { int dy; diff --git a/src/blitter/null.cpp b/src/blitter/null.cpp index 1c2b379d1..e968abe13 100644 --- a/src/blitter/null.cpp +++ b/src/blitter/null.cpp @@ -12,6 +12,8 @@ #include "../stdafx.h" #include "null.hpp" +#include "../safeguards.h" + /** Instantiation of the null blitter factory. */ static FBlitter_Null iFBlitter_Null; diff --git a/src/bmp.cpp b/src/bmp.cpp index 2cb3dbf78..1033d89f1 100644 --- a/src/bmp.cpp +++ b/src/bmp.cpp @@ -15,6 +15,8 @@ #include "core/alloc_func.hpp" #include "core/mem_func.hpp" +#include "safeguards.h" + void BmpInitializeBuffer(BmpBuffer *buffer, FILE *file) { buffer->pos = -1; diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp index c2b76f0b1..98c3175d6 100644 --- a/src/bootstrap_gui.cpp +++ b/src/bootstrap_gui.cpp @@ -29,6 +29,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** Widgets for the background window to prevent smearing. */ static const struct NWidgetPart _background_widgets[] = { NWidget(WWT_PANEL, COLOUR_DARK_BLUE, WID_BB_BACKGROUND), SetResize(1, 1), diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index 61c477aea..95c9d7137 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -29,6 +29,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** The type of the last built rail bridge */ static BridgeType _last_railbridge_type = 0; /** The type of the last built road bridge */ diff --git a/src/bridge_map.cpp b/src/bridge_map.cpp index 6ebf80424..d1e0d6024 100644 --- a/src/bridge_map.cpp +++ b/src/bridge_map.cpp @@ -13,6 +13,8 @@ #include "landscape.h" #include "tunnelbridge_map.h" +#include "safeguards.h" + /** * Finds the end of a bridge in the specified direction starting at a middle tile diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 0719f29ec..57e306e88 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -37,6 +37,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** * Get the height of a single 'entry' in the engine lists. * @param type the vehicle type to get the height of diff --git a/src/cargoaction.cpp b/src/cargoaction.cpp index 48c49e99f..96ddc3708 100644 --- a/src/cargoaction.cpp +++ b/src/cargoaction.cpp @@ -14,6 +14,8 @@ #include "cargoaction.h" #include "station_base.h" +#include "safeguards.h" + /** * Decides if a packet needs to be split. * @param cp Packet to be either split or moved in one piece. diff --git a/src/cargomonitor.cpp b/src/cargomonitor.cpp index 512096785..7d31e6e23 100644 --- a/src/cargomonitor.cpp +++ b/src/cargomonitor.cpp @@ -13,6 +13,8 @@ #include "cargomonitor.h" #include "station_base.h" +#include "safeguards.h" + CargoMonitorMap _cargo_pickups; ///< Map of monitored pick-ups to the amount since last query/activation. CargoMonitorMap _cargo_deliveries; ///< Map of monitored deliveries to the amount since last query/activation. diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp index 67d00554b..34f8c4243 100644 --- a/src/cargopacket.cpp +++ b/src/cargopacket.cpp @@ -17,6 +17,8 @@ #include "cargoaction.h" #include "order_type.h" +#include "safeguards.h" + /* Initialize the cargopacket-pool */ CargoPacketPool _cargopacket_pool("CargoPacket"); INSTANTIATE_POOL_METHODS(CargoPacket) diff --git a/src/cargotype.cpp b/src/cargotype.cpp index 6d601e255..863c58561 100644 --- a/src/cargotype.cpp +++ b/src/cargotype.cpp @@ -20,6 +20,8 @@ #include "table/strings.h" #include "table/cargo_const.h" +#include "safeguards.h" + CargoSpec CargoSpec::array[NUM_CARGO]; /** diff --git a/src/cheat.cpp b/src/cheat.cpp index f8dae235f..8b300c966 100644 --- a/src/cheat.cpp +++ b/src/cheat.cpp @@ -12,6 +12,8 @@ #include "stdafx.h" #include "cheat_type.h" +#include "safeguards.h" + /** All the cheats. */ Cheats _cheats; diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index 9eb405d2a..b2006053a 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -30,6 +30,8 @@ #include "table/sprites.h" +#include "safeguards.h" + /** * The 'amount' to cheat with. diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp index 0035de54c..ad73ed143 100644 --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -23,6 +23,8 @@ #include "table/sprites.h" #include "table/clear_land.h" +#include "safeguards.h" + static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlag flags) { static const Price clear_price_table[] = { diff --git a/src/command.cpp b/src/command.cpp index 34d5ab61e..3700eae1b 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -29,6 +29,8 @@ #include "table/strings.h" +#include "safeguards.h" + CommandProc CmdBuildRailroadTrack; CommandProc CmdRemoveRailroadTrack; CommandProc CmdBuildSingleRail; diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index 0357e337e..35b87459c 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -39,6 +39,8 @@ #include "table/strings.h" +#include "safeguards.h" + CompanyByte _local_company; ///< Company controlled by the human player at this client. Can also be #COMPANY_SPECTATOR. CompanyByte _current_company; ///< Company currently doing an action. Colours _company_colours[MAX_COMPANIES]; ///< NOSAVE: can be determined from company structs. diff --git a/src/company_gui.cpp b/src/company_gui.cpp index bbbf0950b..0f34d3540 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -38,6 +38,8 @@ #include "widgets/company_widget.h" +#include "safeguards.h" + /** Company GUI constants. */ static const uint EXP_LINESPACE = 2; ///< Amount of vertical space for a horizontal (sub-)total line. diff --git a/src/console.cpp b/src/console.cpp index 1b5ff2422..29bab2f74 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -20,6 +20,8 @@ #include <stdarg.h> +#include "safeguards.h" + static const uint ICON_TOKEN_COUNT = 20; ///< Maximum number of tokens in one command /* console parser */ diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 1a4ea9239..4d4223f14 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -40,6 +40,8 @@ #include "game/game.hpp" #include "table/strings.h" +#include "safeguards.h" + /* scriptfile handling */ static bool _script_running; ///< Script is running (used to abort execution when #ConReturn is encountered). diff --git a/src/console_gui.cpp b/src/console_gui.cpp index c3dcdaa12..d7ed1f690 100644 --- a/src/console_gui.cpp +++ b/src/console_gui.cpp @@ -27,6 +27,8 @@ #include "table/strings.h" +#include "safeguards.h" + static const uint ICON_HISTORY_SIZE = 20; static const uint ICON_LINE_SPACING = 2; static const uint ICON_RIGHT_BORDERWIDTH = 10; diff --git a/src/core/alloc_func.cpp b/src/core/alloc_func.cpp index d2b3a4b6c..b78023f4d 100644 --- a/src/core/alloc_func.cpp +++ b/src/core/alloc_func.cpp @@ -11,6 +11,8 @@ #include "../stdafx.h" +#include "../safeguards.h" + /** * Function to exit with an error message after malloc() or calloc() have failed * @param size number of bytes we tried to allocate diff --git a/src/core/bitmath_func.cpp b/src/core/bitmath_func.cpp index af0200bcb..776322731 100644 --- a/src/core/bitmath_func.cpp +++ b/src/core/bitmath_func.cpp @@ -12,6 +12,8 @@ #include "../stdafx.h" #include "bitmath_func.hpp" +#include "../safeguards.h" + const uint8 _ffb_64[64] = { 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, diff --git a/src/core/geometry_func.cpp b/src/core/geometry_func.cpp index 1a1588738..86f317a37 100644 --- a/src/core/geometry_func.cpp +++ b/src/core/geometry_func.cpp @@ -13,6 +13,8 @@ #include "geometry_func.hpp" #include "math_func.hpp" +#include "../safeguards.h" + /** * Compute bounding box of both dimensions. * @param d1 First dimension. diff --git a/src/core/math_func.cpp b/src/core/math_func.cpp index 8c136c0bb..d92770208 100644 --- a/src/core/math_func.cpp +++ b/src/core/math_func.cpp @@ -12,6 +12,8 @@ #include "../stdafx.h" #include "math_func.hpp" +#include "../safeguards.h" + /** * Compute least common multiple (lcm) of arguments \a a and \a b, the smallest * integer value that is a multiple of both \a a and \a b. diff --git a/src/core/pool_func.cpp b/src/core/pool_func.cpp index fa410850f..f8ff93cec 100644 --- a/src/core/pool_func.cpp +++ b/src/core/pool_func.cpp @@ -12,6 +12,8 @@ #include "../stdafx.h" #include "pool_type.hpp" +#include "../safeguards.h" + /** * Destructor removes this object from the pool vector and * deletes the vector itself if this was the last item removed. diff --git a/src/core/random_func.cpp b/src/core/random_func.cpp index 8cf21b54f..5c1d07940 100644 --- a/src/core/random_func.cpp +++ b/src/core/random_func.cpp @@ -13,6 +13,8 @@ #include "random_func.hpp" #include "bitmath_func.hpp" +#include "../safeguards.h" + Randomizer _random, _interactive_random; /** diff --git a/src/cpu.cpp b/src/cpu.cpp index 1a878c182..c48b8cbd4 100644 --- a/src/cpu.cpp +++ b/src/cpu.cpp @@ -12,6 +12,8 @@ #include "stdafx.h" #include "core/bitmath_func.hpp" +#include "safeguards.h" + #undef RDTSC_AVAILABLE /* rdtsc for MSC_VER, uses simple inline assembly, or _rdtsc diff --git a/src/crashlog.cpp b/src/crashlog.cpp index 986736bb3..9159836c8 100644 --- a/src/crashlog.cpp +++ b/src/crashlog.cpp @@ -36,6 +36,8 @@ #include <time.h> +#include "safeguards.h" + /* static */ const char *CrashLog::message = NULL; /* static */ char *CrashLog::gamelog_buffer = NULL; /* static */ const char *CrashLog::gamelog_last = NULL; diff --git a/src/currency.cpp b/src/currency.cpp index 52060e21c..56111022c 100644 --- a/src/currency.cpp +++ b/src/currency.cpp @@ -20,6 +20,8 @@ #include "table/strings.h" +#include "safeguards.h" + /* exchange rate prefix symbol_pos * | separator | postfix | * | | Euro year | | | name diff --git a/src/date.cpp b/src/date.cpp index 800e4faea..9c25af40e 100644 --- a/src/date.cpp +++ b/src/date.cpp @@ -21,6 +21,8 @@ #include "linkgraph/linkgraph.h" #include "saveload/saveload.h" +#include "safeguards.h" + Year _cur_year; ///< Current year, starting at 0 Month _cur_month; ///< Current month (0..11) Date _date; ///< Current date in days (day counter) diff --git a/src/date_gui.cpp b/src/date_gui.cpp index a0c4bc38c..520b3e7f9 100644 --- a/src/date_gui.cpp +++ b/src/date_gui.cpp @@ -20,6 +20,8 @@ #include "widgets/dropdown_type.h" #include "widgets/date_widget.h" +#include "safeguards.h" + /** Window to select a date graphically by using dropdowns */ struct SetDateWindow : Window { diff --git a/src/debug.cpp b/src/debug.cpp index dceae7ec4..b5d6b97b5 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -24,6 +24,8 @@ SOCKET _debug_socket = INVALID_SOCKET; #endif /* ENABLE_NETWORK */ +#include "safeguards.h" + int _debug_driver_level; int _debug_grf_level; int _debug_map_level; diff --git a/src/dedicated.cpp b/src/dedicated.cpp index 6342bc247..ce383ee4a 100644 --- a/src/dedicated.cpp +++ b/src/dedicated.cpp @@ -20,6 +20,8 @@ FILE *_log_fd = NULL; ///< File to reroute output of a forked OpenTTD to #include <unistd.h> +#include "safeguards.h" + #if (defined(SUNOS) && !defined(_LP64) && !defined(_I32LPx)) || defined(__HAIKU__) /* Solaris has, in certain situation, pid_t defined as long, while in other * cases it has it defined as int... this handles all cases nicely. diff --git a/src/depot.cpp b/src/depot.cpp index 9663f042e..821399fd2 100644 --- a/src/depot.cpp +++ b/src/depot.cpp @@ -18,6 +18,8 @@ #include "vehicle_gui.h" #include "vehiclelist.h" +#include "safeguards.h" + /** All our depots tucked away in a pool. */ DepotPool _depot_pool("Depot"); INSTANTIATE_POOL_METHODS(Depot) diff --git a/src/depot_cmd.cpp b/src/depot_cmd.cpp index 5fb2b2de2..77f76bd20 100644 --- a/src/depot_cmd.cpp +++ b/src/depot_cmd.cpp @@ -21,6 +21,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** * Check whether the given name is globally unique amongst depots. * @param name The name to check. diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index c677d039d..6b44428af 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -33,6 +33,8 @@ #include "table/strings.h" +#include "safeguards.h" + /* * Since all depot window sizes aren't the same, we need to modify sizes a little. * It's done with the following arrays of widget indexes. Each of them tells if a widget side should be moved and in what direction. diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp index a027dd048..1be0f217a 100644 --- a/src/disaster_cmd.cpp +++ b/src/disaster_cmd.cpp @@ -47,6 +47,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** Delay counter for considering the next disaster. */ uint16 _disaster_delay; diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 059aef6b5..94b735573 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -32,6 +32,8 @@ #include "table/sprites.h" #include "table/strings.h" +#include "safeguards.h" + static void ShowBuildDockStationPicker(Window *parent); static void ShowBuildDocksDepotPicker(Window *parent); diff --git a/src/driver.cpp b/src/driver.cpp index dd03e5e7b..818251e31 100644 --- a/src/driver.cpp +++ b/src/driver.cpp @@ -16,6 +16,8 @@ #include "video/video_driver.hpp" #include "string_func.h" +#include "safeguards.h" + VideoDriver *_video_driver; ///< The currently active video driver. char *_ini_videodriver; ///< The video driver a stored in the configuration file. int _num_resolutions; ///< The number of resolutions. diff --git a/src/economy.cpp b/src/economy.cpp index 5db7061bf..fd089f82b 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -53,6 +53,8 @@ #include "table/strings.h" #include "table/pricebase.h" +#include "safeguards.h" + /* Initialize the cargo payment-pool */ CargoPaymentPool _cargo_payment_pool("CargoPayment"); diff --git a/src/effectvehicle.cpp b/src/effectvehicle.cpp index a196c52d6..48f3e6cdf 100644 --- a/src/effectvehicle.cpp +++ b/src/effectvehicle.cpp @@ -19,6 +19,8 @@ #include "effectvehicle_func.h" #include "effectvehicle_base.h" +#include "safeguards.h" + static void ChimneySmokeInit(EffectVehicle *v) { diff --git a/src/elrail.cpp b/src/elrail.cpp index a43183792..8116bff2c 100644 --- a/src/elrail.cpp +++ b/src/elrail.cpp @@ -67,6 +67,8 @@ #include "table/elrail_data.h" +#include "safeguards.h" + /** * Get the tile location group of a tile. * @param t The tile to get the tile location group of. diff --git a/src/engine.cpp b/src/engine.cpp index 700475c1b..03072869c 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -35,6 +35,8 @@ #include "table/strings.h" #include "table/engines.h" +#include "safeguards.h" + EnginePool _engine_pool("Engine"); INSTANTIATE_POOL_METHODS(Engine) diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index 6ee47692d..3ac261d15 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -25,6 +25,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** * Return the category of an engine. * @param engine Engine to examine. diff --git a/src/error_gui.cpp b/src/error_gui.cpp index 5e8f52432..34a49c74d 100644 --- a/src/error_gui.cpp +++ b/src/error_gui.cpp @@ -29,6 +29,8 @@ #include "table/strings.h" #include <list> +#include "safeguards.h" + static const NWidgetPart _nested_errmsg_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_RED), diff --git a/src/fileio.cpp b/src/fileio.cpp index f88d8deea..2cbf13ae8 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -32,6 +32,8 @@ #include "basedir.h" #endif +#include "safeguards.h" + /** Size of the #Fio data buffer. */ #define FIO_BUFFER_SIZE 512 diff --git a/src/fios.cpp b/src/fios.cpp index ff7153af3..ced425967 100644 --- a/src/fios.cpp +++ b/src/fios.cpp @@ -26,6 +26,8 @@ #include "table/strings.h" +#include "safeguards.h" + /* Variables to display file lists */ SmallVector<FiosItem, 32> _fios_items; static char *_fios_path; diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index 9fce85ae9..579eedf89 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -34,6 +34,8 @@ #include "table/sprites.h" #include "table/strings.h" +#include "safeguards.h" + SaveLoadDialogMode _saveload_mode; LoadCheckData _load_check_data; ///< Data loaded from save during SL_LOAD_CHECK. diff --git a/src/fontcache.cpp b/src/fontcache.cpp index 4d369ad51..0f949c544 100644 --- a/src/fontcache.cpp +++ b/src/fontcache.cpp @@ -23,6 +23,8 @@ #include "table/control_codes.h" #include "table/unicode.h" +#include "safeguards.h" + static const int ASCII_LETTERSTART = 32; ///< First printable ASCII letter. static const int MAX_FONT_SIZE = 72; ///< Maximum font size. diff --git a/src/fontdetection.cpp b/src/fontdetection.cpp index 82c4f354f..bf97daabf 100644 --- a/src/fontdetection.cpp +++ b/src/fontdetection.cpp @@ -35,6 +35,8 @@ extern FT_Library _library; #include <shlobj.h> /* SHGetFolderPath */ #include "os/windows/win32.h" +#include "safeguards.h" + /** * Get the short DOS 8.3 format for paths. * FreeType doesn't support Unicode filenames and Windows' fopen (as used @@ -373,6 +375,8 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i #include "os/macosx/macos.h" +#include "safeguards.h" + FT_Error GetFontByFaceName(const char *font_name, FT_Face *face) { FT_Error err = FT_Err_Cannot_Open_Resource; @@ -542,6 +546,8 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i #include <fontconfig/fontconfig.h> +#include "safeguards.h" + /* ======================================================================================== * FontConfig (unix) support * ======================================================================================== */ diff --git a/src/game/game_config.cpp b/src/game/game_config.cpp index a85c2f467..50cd5da4e 100644 --- a/src/game/game_config.cpp +++ b/src/game/game_config.cpp @@ -15,6 +15,8 @@ #include "game_config.hpp" #include "game_info.hpp" +#include "../safeguards.h" + /* static */ GameConfig *GameConfig::GetConfig(ScriptSettingSource source) { GameConfig **config; diff --git a/src/game/game_core.cpp b/src/game/game_core.cpp index 9fd47a4c8..2f95e2622 100644 --- a/src/game/game_core.cpp +++ b/src/game/game_core.cpp @@ -21,6 +21,8 @@ #include "game_instance.hpp" #include "game_info.hpp" +#include "../safeguards.h" + /* static */ uint Game::frame_counter = 0; /* static */ GameInfo *Game::info = NULL; /* static */ GameInstance *Game::instance = NULL; diff --git a/src/game/game_info.cpp b/src/game/game_info.cpp index ab49fea12..e6ec3657b 100644 --- a/src/game/game_info.cpp +++ b/src/game/game_info.cpp @@ -16,6 +16,8 @@ #include "game_scanner.hpp" #include "../debug.h" +#include "../safeguards.h" + /** * Check if the API version provided by the Game is supported. * @param api_version The API version as provided by the Game. diff --git a/src/game/game_instance.cpp b/src/game/game_instance.cpp index f4afc69b9..9d030f296 100644 --- a/src/game/game_instance.cpp +++ b/src/game/game_instance.cpp @@ -85,6 +85,8 @@ #include "../script/api/game/game_waypointlist.hpp.sq" #include "../script/api/game/game_window.hpp.sq" +#include "../safeguards.h" + GameInstance::GameInstance() : ScriptInstance("GS") diff --git a/src/game/game_scanner.cpp b/src/game/game_scanner.cpp index f8c2b4f22..4dceaa733 100644 --- a/src/game/game_scanner.cpp +++ b/src/game/game_scanner.cpp @@ -15,6 +15,8 @@ #include "game_info.hpp" #include "game_scanner.hpp" +#include "../safeguards.h" + void GameScannerInfo::Initialize() { diff --git a/src/game/game_text.cpp b/src/game/game_text.cpp index cd9721b8a..502869249 100644 --- a/src/game/game_text.cpp +++ b/src/game/game_text.cpp @@ -24,6 +24,8 @@ #include <stdarg.h> +#include "../safeguards.h" + void CDECL strgen_warning(const char *s, ...) { char buf[1024]; diff --git a/src/gamelog.cpp b/src/gamelog.cpp index b4b9fd7a6..e0853584d 100644 --- a/src/gamelog.cpp +++ b/src/gamelog.cpp @@ -21,6 +21,8 @@ #include <stdarg.h> +#include "safeguards.h" + extern const uint16 SAVEGAME_VERSION; ///< current savegame version extern SavegameType _savegame_type; ///< type of savegame we are loading diff --git a/src/genworld.cpp b/src/genworld.cpp index 822fe141f..d90c9ad4d 100644 --- a/src/genworld.cpp +++ b/src/genworld.cpp @@ -34,6 +34,8 @@ #include "game/game.hpp" #include "game/game_instance.hpp" +#include "safeguards.h" + void GenerateClearTile(); void GenerateIndustries(); diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index f1b561ef1..9a2fe62b5 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -32,6 +32,8 @@ #include "widgets/genworld_widget.h" +#include "safeguards.h" + extern void MakeNewgameSettingsLive(); diff --git a/src/gfx.cpp b/src/gfx.cpp index adc644d20..021863451 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -26,6 +26,8 @@ #include "table/sprites.h" #include "table/control_codes.h" +#include "safeguards.h" + byte _dirkeys; ///< 1 = left, 2 = up, 4 = right, 8 = down bool _fullscreen; CursorVars _cursor; diff --git a/src/gfx_layout.cpp b/src/gfx_layout.cpp index 0c4c1f23f..2dba6a204 100644 --- a/src/gfx_layout.cpp +++ b/src/gfx_layout.cpp @@ -21,6 +21,8 @@ #include <unicode/ustring.h> #endif /* WITH_ICU */ +#include "safeguards.h" + /** Cache of ParagraphLayout lines. */ Layouter::LineCache *Layouter::linecache; diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp index 109db2e08..30ff37998 100644 --- a/src/gfxinit.cpp +++ b/src/gfxinit.cpp @@ -25,6 +25,8 @@ #include "table/sprites.h" +#include "safeguards.h" + /** Whether the given NewGRFs must get a palette remap from windows to DOS or not. */ bool _palette_remap_grf[MAX_FILE_SLOTS]; diff --git a/src/goal.cpp b/src/goal.cpp index e2436745c..d472fc2c5 100644 --- a/src/goal.cpp +++ b/src/goal.cpp @@ -24,6 +24,8 @@ #include "gui.h" #include "network/network.h" +#include "safeguards.h" + GoalID _new_goal_id; diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp index b2e591ffd..cb38d7f6e 100644 --- a/src/goal_gui.cpp +++ b/src/goal_gui.cpp @@ -28,6 +28,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** Goal list columns. */ enum GoalColumn { GC_GOAL = 0, ///< Goal text column. diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 10779502d..c12c6ace4 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -30,6 +30,8 @@ #include "table/sprites.h" #include <math.h> +#include "safeguards.h" + /* Bitmasks of company and cargo indices that shouldn't be drawn. */ static uint _legend_excluded_companies; static uint _legend_excluded_cargo; diff --git a/src/ground_vehicle.cpp b/src/ground_vehicle.cpp index 5712b28f9..f3134608a 100644 --- a/src/ground_vehicle.cpp +++ b/src/ground_vehicle.cpp @@ -14,6 +14,8 @@ #include "roadveh.h" #include "depot_map.h" +#include "safeguards.h" + /** * Recalculates the cached total power of a vehicle. Should be called when the consist is changed. */ diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp index be1bfce5d..1c5d05ae1 100644 --- a/src/group_cmd.cpp +++ b/src/group_cmd.cpp @@ -24,6 +24,8 @@ #include "table/strings.h" +#include "safeguards.h" + GroupID _new_group_id; GroupPool _group_pool("Group"); diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 0b6c860dd..c332c934d 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -30,6 +30,8 @@ #include "table/sprites.h" +#include "safeguards.h" + static const int LEVEL_WIDTH = 10; ///< Indenting width of a sub-group in pixels typedef GUIList<const Group*> GUIGroupList; diff --git a/src/heightmap.cpp b/src/heightmap.cpp index 50cfd6e22..93cfa0a62 100644 --- a/src/heightmap.cpp +++ b/src/heightmap.cpp @@ -22,6 +22,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** * Convert RGB colours to Grayscale using 29.9% Red, 58.7% Green, 11.4% Blue * (average luminosity formula, NTSC Colour Space) diff --git a/src/highscore.cpp b/src/highscore.cpp index b2dcf8e5f..86e4f5ae8 100644 --- a/src/highscore.cpp +++ b/src/highscore.cpp @@ -20,6 +20,8 @@ #include "core/sort_func.hpp" #include "debug.h" +#include "safeguards.h" + HighScore _highscore_table[SP_HIGHSCORE_END][5]; ///< various difficulty-settings; top 5 char *_highscore_file; ///< The file to store the highscore data in. diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp index d79afe4eb..35ada7266 100644 --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -25,6 +25,8 @@ #include "widgets/highscore_widget.h" +#include "safeguards.h" + struct EndGameHighScoreBaseWindow : Window { uint32 background_img; int8 rank; diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp index c5a8109ad..0579792e7 100644 --- a/src/hotkeys.cpp +++ b/src/hotkeys.cpp @@ -16,6 +16,8 @@ #include "string_func.h" #include "window_gui.h" +#include "safeguards.h" + char *_hotkeys_file; /** diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 9930057a3..9deb04363 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -45,6 +45,8 @@ #include "table/industry_land.h" #include "table/build_industry.h" +#include "safeguards.h" + IndustryPool _industry_pool("Industry"); INSTANTIATE_POOL_METHODS(Industry) diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index cc305509f..bcda8bd5c 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -41,6 +41,8 @@ #include "table/strings.h" +#include "safeguards.h" + bool _ignore_restrictions; uint64 _displayed_industries; ///< Communication from the industry chain window to the smallmap window about what industries to display. diff --git a/src/ini.cpp b/src/ini.cpp index 11f79ed16..2e4e9097f 100644 --- a/src/ini.cpp +++ b/src/ini.cpp @@ -26,6 +26,8 @@ # include "core/mem_func.hpp" #endif +#include "safeguards.h" + /** * Create a new ini file with given group names. * @param list_group_names A \c NULL terminated list with group names that should be loaded as lists instead of variables. @see IGT_LIST diff --git a/src/ini_load.cpp b/src/ini_load.cpp index 75a825453..a64ca454c 100644 --- a/src/ini_load.cpp +++ b/src/ini_load.cpp @@ -15,6 +15,8 @@ #include "ini_type.h" #include "string_func.h" +#include "safeguards.h" + /** * Construct a new in-memory item of an Ini file. * @param parent the group we belong to diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index 5d1305894..9de927408 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -33,6 +33,8 @@ #include "table/strings.h" #include "table/sprites.h" +#include "safeguards.h" + struct SelectGameWindow : public Window { SelectGameWindow(WindowDesc *desc) : Window(desc) diff --git a/src/landscape.cpp b/src/landscape.cpp index a19c98db9..c4116eaaf 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -37,6 +37,8 @@ #include "table/strings.h" #include "table/sprites.h" +#include "safeguards.h" + extern const TileTypeProcs _tile_type_clear_procs, _tile_type_rail_procs, diff --git a/src/linkgraph/demands.cpp b/src/linkgraph/demands.cpp index 80a0f5677..84c73f733 100644 --- a/src/linkgraph/demands.cpp +++ b/src/linkgraph/demands.cpp @@ -4,6 +4,8 @@ #include "demands.h" #include <list> +#include "../safeguards.h" + typedef std::list<NodeID> NodeList; /** diff --git a/src/linkgraph/flowmapper.cpp b/src/linkgraph/flowmapper.cpp index 3daab4414..4b974a809 100644 --- a/src/linkgraph/flowmapper.cpp +++ b/src/linkgraph/flowmapper.cpp @@ -12,6 +12,8 @@ #include "../stdafx.h" #include "flowmapper.h" +#include "../safeguards.h" + /** * Map the paths generated by the MCF solver into flows associated with nodes. * @param component the link graph component to be used. diff --git a/src/linkgraph/linkgraph.cpp b/src/linkgraph/linkgraph.cpp index d41c3494d..461b3b47e 100644 --- a/src/linkgraph/linkgraph.cpp +++ b/src/linkgraph/linkgraph.cpp @@ -13,6 +13,8 @@ #include "../core/pool_func.hpp" #include "linkgraph.h" +#include "../safeguards.h" + /* Initialize the link-graph-pool */ LinkGraphPool _link_graph_pool("LinkGraph"); INSTANTIATE_POOL_METHODS(LinkGraph) diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index f75f602ab..579bf9c46 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -22,6 +22,8 @@ #include "table/strings.h" +#include "../safeguards.h" + /** * Colours for the various "load" states of links. Ordered from "unused" to * "overloaded". diff --git a/src/linkgraph/linkgraphjob.cpp b/src/linkgraph/linkgraphjob.cpp index 61e313616..30d68e4d8 100644 --- a/src/linkgraph/linkgraphjob.cpp +++ b/src/linkgraph/linkgraphjob.cpp @@ -15,6 +15,8 @@ #include "linkgraphjob.h" #include "linkgraphschedule.h" +#include "../safeguards.h" + /* Initialize the link-graph-job-pool */ LinkGraphJobPool _link_graph_job_pool("LinkGraphJob"); INSTANTIATE_POOL_METHODS(LinkGraphJob) diff --git a/src/linkgraph/linkgraphschedule.cpp b/src/linkgraph/linkgraphschedule.cpp index 4e6f33266..30ad20d4d 100644 --- a/src/linkgraph/linkgraphschedule.cpp +++ b/src/linkgraph/linkgraphschedule.cpp @@ -16,6 +16,8 @@ #include "mcf.h" #include "flowmapper.h" +#include "../safeguards.h" + /** * Start the next job in the schedule. */ diff --git a/src/linkgraph/mcf.cpp b/src/linkgraph/mcf.cpp index af9f6ce5f..3163ec9e3 100644 --- a/src/linkgraph/mcf.cpp +++ b/src/linkgraph/mcf.cpp @@ -5,6 +5,8 @@ #include "mcf.h" #include <set> +#include "../safeguards.h" + typedef std::map<NodeID, Path *> PathViaMap; /** diff --git a/src/linkgraph/refresh.cpp b/src/linkgraph/refresh.cpp index 921f5d7b8..8c45cad8b 100644 --- a/src/linkgraph/refresh.cpp +++ b/src/linkgraph/refresh.cpp @@ -17,6 +17,8 @@ #include "refresh.h" #include "linkgraph.h" +#include "../safeguards.h" + /** * Refresh all links the given vehicle will visit. * @param v Vehicle to refresh links for. diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 9d13deef6..cdef1e6a6 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -45,6 +45,8 @@ #include "table/sprites.h" #include "table/strings.h" +#include "safeguards.h" + static int _rename_id = 1; static int _rename_what = -1; diff --git a/src/map.cpp b/src/map.cpp index 1ee0ba247..bd035bed3 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -14,6 +14,8 @@ #include "core/alloc_func.hpp" #include "water_map.h" +#include "safeguards.h" + #if defined(_MSC_VER) /* Why the hell is that not in all MSVC headers?? */ extern "C" _CRTIMP void __cdecl _assert(void *, void *, unsigned); diff --git a/src/misc.cpp b/src/misc.cpp index 11607a5f1..d9d506993 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -29,6 +29,8 @@ #include "game/game.hpp" #include "linkgraph/linkgraphschedule.h" +#include "safeguards.h" + extern TileIndex _cur_tileloop_tile; extern void MakeNewgameSettingsLive(); diff --git a/src/misc/countedobj.cpp b/src/misc/countedobj.cpp index 228b35e82..28f614afa 100644 --- a/src/misc/countedobj.cpp +++ b/src/misc/countedobj.cpp @@ -13,6 +13,8 @@ #include "countedptr.hpp" +#include "../safeguards.h" + int32 SimpleCountedObject::AddRef() { return ++m_ref_cnt; diff --git a/src/misc/dbg_helpers.cpp b/src/misc/dbg_helpers.cpp index f87070fa0..a80230de1 100644 --- a/src/misc/dbg_helpers.cpp +++ b/src/misc/dbg_helpers.cpp @@ -13,6 +13,8 @@ #include "../rail_map.h" #include "dbg_helpers.h" +#include "../safeguards.h" + /** Trackdir & TrackdirBits short names. */ static const char * const trackdir_names[] = { "NE", "SE", "UE", "LE", "LS", "RS", "rne", "rse", diff --git a/src/misc/getoptdata.cpp b/src/misc/getoptdata.cpp index 6ca9a1bfc..7859594dd 100644 --- a/src/misc/getoptdata.cpp +++ b/src/misc/getoptdata.cpp @@ -12,6 +12,8 @@ #include "../stdafx.h" #include "getoptdata.h" +#include "../safeguards.h" + /** * Find the next option. * @return Function returns one diff --git a/src/misc_cmd.cpp b/src/misc_cmd.cpp index c35ccc8f8..e7da13c7a 100644 --- a/src/misc_cmd.cpp +++ b/src/misc_cmd.cpp @@ -25,6 +25,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** * Increase the loan of your company. * @param tile unused diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 55bef30e3..61e38b237 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -30,6 +30,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** Method to open the OSK. */ enum OskActivation { OSKA_DISABLED, ///< The OSK shall not be activated at all. diff --git a/src/mixer.cpp b/src/mixer.cpp index 401a9c0ba..5945bd235 100644 --- a/src/mixer.cpp +++ b/src/mixer.cpp @@ -13,6 +13,8 @@ #include <math.h> #include "core/math_func.hpp" +#include "safeguards.h" + struct MixerChannel { bool active; diff --git a/src/music.cpp b/src/music.cpp index 55599a947..4001e621e 100644 --- a/src/music.cpp +++ b/src/music.cpp @@ -15,6 +15,8 @@ #define SET_TYPE "music" #include "base_media_func.h" +#include "safeguards.h" + INSTANTIATE_BASE_MEDIA_METHODS(BaseMedia<MusicSet>, MusicSet) /** Names corresponding to the music set's files */ diff --git a/src/music/allegro_m.cpp b/src/music/allegro_m.cpp index 955182590..77b488186 100644 --- a/src/music/allegro_m.cpp +++ b/src/music/allegro_m.cpp @@ -16,6 +16,8 @@ #include "allegro_m.h" #include <allegro.h> +#include "../safeguards.h" + static FMusicDriver_Allegro iFMusicDriver_Allegro; static MIDI *_midi = NULL; diff --git a/src/music/bemidi.cpp b/src/music/bemidi.cpp index 5ee62dfe5..2bc207476 100644 --- a/src/music/bemidi.cpp +++ b/src/music/bemidi.cpp @@ -16,6 +16,8 @@ /* BeOS System Includes */ #include <MidiSynthFile.h> +#include "../safeguards.h" + /** The file we're playing. */ static BMidiSynthFile midiSynthFile; diff --git a/src/music/cocoa_m.cpp b/src/music/cocoa_m.cpp index e7c7d6b75..a201984ae 100644 --- a/src/music/cocoa_m.cpp +++ b/src/music/cocoa_m.cpp @@ -28,6 +28,8 @@ #undef Rect #undef Point +#include "../safeguards.h" + static FMusicDriver_Cocoa iFMusicDriver_Cocoa; diff --git a/src/music/dmusic.cpp b/src/music/dmusic.cpp index 185d66a76..40ce69d1a 100644 --- a/src/music/dmusic.cpp +++ b/src/music/dmusic.cpp @@ -27,6 +27,8 @@ #include <dmusicc.h> #include <dmusicf.h> +#include "../safeguards.h" + static FMusicDriver_DMusic iFMusicDriver_DMusic; /** the direct music object manages buffers and ports */ diff --git a/src/music/extmidi.cpp b/src/music/extmidi.cpp index 93492aa99..6bfc990e5 100644 --- a/src/music/extmidi.cpp +++ b/src/music/extmidi.cpp @@ -25,6 +25,8 @@ #include <sys/stat.h> #include <errno.h> +#include "../safeguards.h" + #ifndef EXTERNAL_PLAYER /** The default external midi player. */ #define EXTERNAL_PLAYER "timidity" diff --git a/src/music/libtimidity.cpp b/src/music/libtimidity.cpp index 92f17212c..1cb2adc0f 100644 --- a/src/music/libtimidity.cpp +++ b/src/music/libtimidity.cpp @@ -26,6 +26,8 @@ #include <pspaudiolib.h> #endif /* PSP */ +#include "../safeguards.h" + /** The state of playing. */ enum MidiState { MIDI_STOPPED = 0, diff --git a/src/music/null_m.cpp b/src/music/null_m.cpp index cb42a906a..90d08d04a 100644 --- a/src/music/null_m.cpp +++ b/src/music/null_m.cpp @@ -12,5 +12,7 @@ #include "../stdafx.h" #include "null_m.h" +#include "../safeguards.h" + /** The factory for the music player that does nothing. */ static FMusicDriver_Null iFMusicDriver_Null; diff --git a/src/music/os2_m.cpp b/src/music/os2_m.cpp index ec1fca264..d7fb97d2d 100644 --- a/src/music/os2_m.cpp +++ b/src/music/os2_m.cpp @@ -21,6 +21,8 @@ #include <os2.h> #include <os2me.h> +#include "../safeguards.h" + /********************** * OS/2 MIDI PLAYER **********************/ diff --git a/src/music/qtmidi.cpp b/src/music/qtmidi.cpp index 0cfe318e7..dfd6f16eb 100644 --- a/src/music/qtmidi.cpp +++ b/src/music/qtmidi.cpp @@ -38,6 +38,8 @@ #undef Rect #undef Point +#include "../safeguards.h" + static FMusicDriver_QtMidi iFMusicDriver_QtMidi; diff --git a/src/music/win32_m.cpp b/src/music/win32_m.cpp index 65ffbbc6b..d3a7019a0 100644 --- a/src/music/win32_m.cpp +++ b/src/music/win32_m.cpp @@ -15,6 +15,8 @@ #include <windows.h> #include <mmsystem.h> +#include "../safeguards.h" + static struct { bool stop_song; bool terminate; diff --git a/src/music_gui.cpp b/src/music_gui.cpp index 896624cb7..01406849f 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -29,6 +29,8 @@ #include "table/strings.h" #include "table/sprites.h" +#include "safeguards.h" + /** * Get the name of the song. * @param index of the song. diff --git a/src/network/core/address.cpp b/src/network/core/address.cpp index d8c990e24..d25ade4a3 100644 --- a/src/network/core/address.cpp +++ b/src/network/core/address.cpp @@ -16,6 +16,8 @@ #include "address.h" #include "../../debug.h" +#include "../../safeguards.h" + /** * Get the hostname; in case it wasn't given the * IPv4 dotted representation is given. diff --git a/src/network/core/core.cpp b/src/network/core/core.cpp index 867bb4bb9..7a2ad92a2 100644 --- a/src/network/core/core.cpp +++ b/src/network/core/core.cpp @@ -18,6 +18,8 @@ #include "os_abstraction.h" #include "packet.h" +#include "../../safeguards.h" + #ifdef __MORPHOS__ /* the library base is required here */ diff --git a/src/network/core/host.cpp b/src/network/core/host.cpp index 0af0f7992..cf98239f8 100644 --- a/src/network/core/host.cpp +++ b/src/network/core/host.cpp @@ -15,6 +15,8 @@ #include "../../debug.h" #include "address.h" +#include "../../safeguards.h" + /** * Internal implementation for finding the broadcast IPs. * This function is implemented multiple times for multiple targets. diff --git a/src/network/core/packet.cpp b/src/network/core/packet.cpp index 4d9345e82..7548132e0 100644 --- a/src/network/core/packet.cpp +++ b/src/network/core/packet.cpp @@ -18,6 +18,8 @@ #include "packet.h" +#include "../../safeguards.h" + /** * Create a packet that is used to read from a network socket * @param cs the socket handler associated with the socket we are reading from diff --git a/src/network/core/tcp.cpp b/src/network/core/tcp.cpp index e68c354fc..790941fc0 100644 --- a/src/network/core/tcp.cpp +++ b/src/network/core/tcp.cpp @@ -18,6 +18,8 @@ #include "tcp.h" +#include "../../safeguards.h" + /** * Construct a socket handler for a TCP connection. * @param s The just opened TCP connection. diff --git a/src/network/core/tcp_admin.cpp b/src/network/core/tcp_admin.cpp index 636696e2c..284ceda9b 100644 --- a/src/network/core/tcp_admin.cpp +++ b/src/network/core/tcp_admin.cpp @@ -19,6 +19,8 @@ #include "tcp_admin.h" #include "../../debug.h" +#include "../../safeguards.h" + /* Make sure that these enums match. */ assert_compile((int)CRR_MANUAL == (int)ADMIN_CRR_MANUAL); assert_compile((int)CRR_AUTOCLEAN == (int)ADMIN_CRR_AUTOCLEAN); diff --git a/src/network/core/tcp_connect.cpp b/src/network/core/tcp_connect.cpp index ed2885b0e..ccbf93f3c 100644 --- a/src/network/core/tcp_connect.cpp +++ b/src/network/core/tcp_connect.cpp @@ -18,6 +18,8 @@ #include "tcp.h" +#include "../../safeguards.h" + /** List of connections that are currently being created */ static SmallVector<TCPConnecter *, 1> _tcp_connecters; diff --git a/src/network/core/tcp_content.cpp b/src/network/core/tcp_content.cpp index 8a4604feb..fc22c4491 100644 --- a/src/network/core/tcp_content.cpp +++ b/src/network/core/tcp_content.cpp @@ -24,6 +24,8 @@ #endif /* OPENTTD_MSU */ #include "tcp_content.h" +#include "../../safeguards.h" + /** Clear everything in the struct */ ContentInfo::ContentInfo() { diff --git a/src/network/core/tcp_game.cpp b/src/network/core/tcp_game.cpp index d263b28e4..9b3f7b5ef 100644 --- a/src/network/core/tcp_game.cpp +++ b/src/network/core/tcp_game.cpp @@ -22,6 +22,8 @@ #include "table/strings.h" +#include "../../safeguards.h" + /** * Create a new socket for the game connection. * @param s The socket to connect with. diff --git a/src/network/core/tcp_http.cpp b/src/network/core/tcp_http.cpp index a9829d560..a8bb64080 100644 --- a/src/network/core/tcp_http.cpp +++ b/src/network/core/tcp_http.cpp @@ -20,6 +20,8 @@ #include "tcp_http.h" +#include "../../safeguards.h" + /** List of open HTTP connections. */ static SmallVector<NetworkHTTPSocketHandler *, 1> _http_connections; diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp index f7abc7e35..ce5f06b1f 100644 --- a/src/network/core/udp.cpp +++ b/src/network/core/udp.cpp @@ -18,6 +18,8 @@ #include "../../debug.h" #include "udp.h" +#include "../../safeguards.h" + /** * Create an UDP socket but don't listen yet. * @param bind the addresses to bind to. diff --git a/src/network/network.cpp b/src/network/network.cpp index a3c8fd4a9..c22615a95 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -38,6 +38,8 @@ #include "../gfx_func.h" #include "../error.h" +#include "../safeguards.h" + #ifdef DEBUG_DUMP_COMMANDS #include "../fileio_func.h" /** When running the server till the wait point, run as fast as we can! */ diff --git a/src/network/network_admin.cpp b/src/network/network_admin.cpp index 0327bf366..c1ca3d3bb 100644 --- a/src/network/network_admin.cpp +++ b/src/network/network_admin.cpp @@ -25,6 +25,8 @@ #include "../rev.h" #include "../game/game.hpp" +#include "../safeguards.h" + /* This file handles all the admin network commands. */ diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index 8b965feff..2a06082dd 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -30,6 +30,8 @@ #include "table/strings.h" +#include "../safeguards.h" + /** The draw buffer must be able to contain the chat message, client name and the "[All]" message, * some spaces and possible translations of [All] to other languages. */ assert_compile((int)DRAW_STRING_BUFFER >= (int)NETWORK_CHAT_LENGTH + NETWORK_NAME_LENGTH + 40); diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index 44c13fbc8..10e3695b7 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -34,6 +34,8 @@ #include "table/strings.h" +#include "../safeguards.h" + /* This file handles all the client-commands */ diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp index 7ba26041c..6e5458fd8 100644 --- a/src/network/network_command.cpp +++ b/src/network/network_command.cpp @@ -19,6 +19,8 @@ #include "../company_func.h" #include "../settings_type.h" +#include "../safeguards.h" + /** Table with all the callbacks we'll use for conversion*/ static CommandCallback * const _callback_table[] = { /* 0x00 */ NULL, diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index 8677a8104..215ed5dfd 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -27,6 +27,8 @@ #include <zlib.h> #endif +#include "../safeguards.h" + extern bool HasScenario(const ContentInfo *ci, bool md5sum); /** The client we use to connect to the server. */ diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index 808c3ea23..332cf1a53 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -29,6 +29,8 @@ #include "table/strings.h" #include "../table/sprites.h" +#include "../safeguards.h" + /** Whether the user accepted to enter external websites during this session. */ static bool _accepted_external_search = false; diff --git a/src/network/network_gamelist.cpp b/src/network/network_gamelist.cpp index 949636213..e5d80630e 100644 --- a/src/network/network_gamelist.cpp +++ b/src/network/network_gamelist.cpp @@ -22,6 +22,8 @@ #include "network_udp.h" #include "network_gamelist.h" +#include "../safeguards.h" + NetworkGameList *_network_game_list = NULL; /** Mutex for handling delayed insertion/querying of servers. */ diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 615710465..09c2623e7 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -39,6 +39,8 @@ #include "../stringfilter_type.h" +#include "../safeguards.h" + static void ShowNetworkStartServerWindow(); static void ShowNetworkLobbyWindow(NetworkGameList *ngl); diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index fcaad19ab..ebc7ee37e 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -33,6 +33,8 @@ #include "../core/random_func.hpp" #include "../rev.h" +#include "../safeguards.h" + /* This file handles all the server-commands */ diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp index cde2994f7..46d8fddef 100644 --- a/src/network/network_udp.cpp +++ b/src/network/network_udp.cpp @@ -34,6 +34,8 @@ #include "core/udp.h" +#include "../safeguards.h" + /** Mutex for all out threaded udp resolution and such. */ static ThreadMutex *_network_udp_mutex = ThreadMutex::New(); diff --git a/src/newgrf.cpp b/src/newgrf.cpp index b567fc4c9..90fd24bf1 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -52,6 +52,8 @@ #include "table/strings.h" #include "table/build_industry.h" +#include "safeguards.h" + /* TTDPatch extended GRF format codec * (c) Petr Baudis 2004 (GPL'd) * Changes by Florian octo Forster are (c) by the OpenTTD development team. diff --git a/src/newgrf_airport.cpp b/src/newgrf_airport.cpp index 4201fc622..6db12f737 100644 --- a/src/newgrf_airport.cpp +++ b/src/newgrf_airport.cpp @@ -17,6 +17,8 @@ #include "station_base.h" #include "newgrf_class_func.h" +#include "safeguards.h" + /** Resolver for the airport scope. */ struct AirportScopeResolver : public ScopeResolver { struct Station *st; ///< Station of the airport for which the callback is run, or \c NULL for build gui. diff --git a/src/newgrf_airporttiles.cpp b/src/newgrf_airporttiles.cpp index 323fb6cc1..5eb24f670 100644 --- a/src/newgrf_airporttiles.cpp +++ b/src/newgrf_airporttiles.cpp @@ -23,6 +23,8 @@ #include "table/airporttiles.h" #include "newgrf_animation_base.h" +#include "safeguards.h" + AirportTileSpec AirportTileSpec::tiles[NUM_AIRPORTTILES]; diff --git a/src/newgrf_canal.cpp b/src/newgrf_canal.cpp index 8f81fd0d8..cba19cbdb 100644 --- a/src/newgrf_canal.cpp +++ b/src/newgrf_canal.cpp @@ -16,6 +16,8 @@ #include "water.h" #include "water_map.h" +#include "safeguards.h" + /** Table of canal 'feature' sprite groups */ WaterFeature _water_feature[CF_END]; diff --git a/src/newgrf_cargo.cpp b/src/newgrf_cargo.cpp index 016698523..7d830c573 100644 --- a/src/newgrf_cargo.cpp +++ b/src/newgrf_cargo.cpp @@ -13,6 +13,8 @@ #include "debug.h" #include "newgrf_spritegroup.h" +#include "safeguards.h" + /** Resolver of cargo. */ struct CargoResolverObject : public ResolverObject { CargoResolverObject(const CargoSpec *cs, CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0); diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp index ef75be5d8..4caf3a5d4 100644 --- a/src/newgrf_commons.cpp +++ b/src/newgrf_commons.cpp @@ -32,6 +32,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** * Constructor of generic class * @param offset end of original data for this entity. i.e: houses = 110 diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index 337b3edd1..9250ce748 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -25,6 +25,8 @@ #include "fileio_func.h" #include "fios.h" +#include "safeguards.h" + /** Create a new GRFTextWrapper. */ GRFTextWrapper::GRFTextWrapper() : text(NULL) diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index cead62750..d3b5ddd16 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -43,6 +43,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** The sprite picker. */ NewGrfDebugSpritePicker _newgrf_debug_sprite_picker = { SPM_NONE, NULL, 0, SmallVector<SpriteID, 256>() }; diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index b5fe5d711..cdd62b7ae 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -25,6 +25,8 @@ #include "newgrf_railtype.h" #include "ship.h" +#include "safeguards.h" + struct WagonOverride { EngineID *train_id; uint trains; diff --git a/src/newgrf_generic.cpp b/src/newgrf_generic.cpp index 55eee6d23..9bd77239a 100644 --- a/src/newgrf_generic.cpp +++ b/src/newgrf_generic.cpp @@ -18,6 +18,8 @@ #include "water_map.h" #include <list> +#include "safeguards.h" + /** Scope resolver for generic objects and properties. */ struct GenericScopeResolver : public ScopeResolver { CargoID cargo_type; diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 47cca029a..b923dfd17 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -36,6 +36,8 @@ #include "table/sprites.h" +#include "safeguards.h" + /* Maximum number of NewGRFs that may be loaded. Six reserved slots are: * 0 - config, 1 - sound, 2 - base, 3 - logos, 4 - climate, 5 - extra */ static const int MAX_NEWGRFS = MAX_FILE_SLOTS - 6; diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp index c660fe3ab..7fe5fadf4 100644 --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -24,6 +24,8 @@ #include "newgrf_cargo.h" #include "station_base.h" +#include "safeguards.h" + static BuildingCounts<uint32> _building_counts; static HouseClassMapping _class_mapping[HOUSE_CLASS_MAX]; diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 725373d10..a7ae4c01f 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -24,6 +24,8 @@ #include "table/strings.h" +#include "safeguards.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 * translated when the idustry spec is set. */ diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp index f22514a03..90a17550d 100644 --- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -22,6 +22,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** * Based on newhouses equivalent, but adapted for newindustries * @param parameter from callback. It's in fact a pair of coordinates diff --git a/src/newgrf_object.cpp b/src/newgrf_object.cpp index 6f7e3f0ff..3f48a819f 100644 --- a/src/newgrf_object.cpp +++ b/src/newgrf_object.cpp @@ -24,6 +24,8 @@ #include "water.h" #include "newgrf_animation_base.h" +#include "safeguards.h" + /** The override manager for our objects. */ ObjectOverrideManager _object_mngr(NEW_OBJECT_OFFSET, NUM_OBJECTS, INVALID_OBJECT_TYPE); diff --git a/src/newgrf_railtype.cpp b/src/newgrf_railtype.cpp index f43689698..872a3a7f6 100644 --- a/src/newgrf_railtype.cpp +++ b/src/newgrf_railtype.cpp @@ -16,6 +16,8 @@ #include "depot_base.h" #include "town.h" +#include "safeguards.h" + /* virtual */ uint32 RailTypeScopeResolver::GetRandomBits() const { uint tmp = CountBits(this->tile + (TileX(this->tile) + TileY(this->tile)) * TILE_SIZE); diff --git a/src/newgrf_sound.cpp b/src/newgrf_sound.cpp index c7739558f..60ee60916 100644 --- a/src/newgrf_sound.cpp +++ b/src/newgrf_sound.cpp @@ -20,6 +20,8 @@ #include "debug.h" #include "settings_type.h" +#include "safeguards.h" + static SmallVector<SoundEntry, 8> _sounds; diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp index d6d3c172c..624b4d547 100644 --- a/src/newgrf_spritegroup.cpp +++ b/src/newgrf_spritegroup.cpp @@ -14,6 +14,8 @@ #include "newgrf_spritegroup.h" #include "core/pool_func.hpp" +#include "safeguards.h" + SpriteGroupPool _spritegroup_pool("SpriteGroup"); INSTANTIATE_POOL_METHODS(SpriteGroup) diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index f99121df2..e70a8653b 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -26,6 +26,8 @@ #include "newgrf_animation_base.h" #include "newgrf_class_func.h" +#include "safeguards.h" + template <typename Tspec, typename Tid, Tid Tmax> /* static */ void NewGRFClass<Tspec, Tid, Tmax>::InsertDefaults() diff --git a/src/newgrf_storage.cpp b/src/newgrf_storage.cpp index 7e8b9d8d0..e91e1f90c 100644 --- a/src/newgrf_storage.cpp +++ b/src/newgrf_storage.cpp @@ -16,6 +16,8 @@ #include "debug.h" #include <set> +#include "safeguards.h" + PersistentStoragePool _persistent_storage_pool("PersistentStorage"); INSTANTIATE_POOL_METHODS(PersistentStorage) diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp index 439a8d57f..cb6b57fa6 100644 --- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -33,6 +33,8 @@ #include "table/strings.h" #include "table/control_codes.h" +#include "safeguards.h" + #define GRFTAB 28 #define TABSIZE 11 diff --git a/src/newgrf_town.cpp b/src/newgrf_town.cpp index c807e77a8..2f48eb757 100644 --- a/src/newgrf_town.cpp +++ b/src/newgrf_town.cpp @@ -14,6 +14,8 @@ #include "town.h" #include "newgrf_town.h" +#include "safeguards.h" + /** * Resolver of a town scope. * @param ro Surrounding resolver. diff --git a/src/newgrf_townname.cpp b/src/newgrf_townname.cpp index 29ca06817..42aae3f14 100644 --- a/src/newgrf_townname.cpp +++ b/src/newgrf_townname.cpp @@ -19,6 +19,8 @@ #include "core/alloc_func.hpp" #include "string_func.h" +#include "safeguards.h" + static GRFTownName *_grf_townnames = NULL; GRFTownName *GetGRFTownName(uint32 grfid) diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 5639001b7..77fc5828d 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -38,6 +38,8 @@ #include "table/strings.h" +#include "safeguards.h" + const NewsItem *_statusbar_news_item = NULL; static uint MIN_NEWS_AMOUNT = 30; ///< preferred minimum amount of news messages diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp index 05efae0a2..4038288d0 100644 --- a/src/object_cmd.cpp +++ b/src/object_cmd.cpp @@ -38,6 +38,8 @@ #include "table/strings.h" #include "table/object_land.h" +#include "safeguards.h" + ObjectPool _object_pool("Object"); INSTANTIATE_POOL_METHODS(Object) uint16 Object::counts[NUM_OBJECTS]; diff --git a/src/object_gui.cpp b/src/object_gui.cpp index 29a9d0d5e..f0dbd0dc2 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -23,6 +23,8 @@ #include "table/strings.h" +#include "safeguards.h" + static ObjectClassID _selected_object_class; ///< the currently visible object class static int _selected_object_index; ///< the index of the selected object in the current class or -1 static uint8 _selected_object_view; ///< the view of the selected object diff --git a/src/openttd.cpp b/src/openttd.cpp index c901272c5..f3c62ba8e 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -68,6 +68,8 @@ #include <stdarg.h> +#include "safeguards.h" + void CallLandscapeTick(); void IncreaseDate(); void DoPaletteAnimations(); diff --git a/src/order_backup.cpp b/src/order_backup.cpp index 100348f8a..597ad13bb 100644 --- a/src/order_backup.cpp +++ b/src/order_backup.cpp @@ -19,6 +19,8 @@ #include "window_func.h" #include "station_map.h" +#include "safeguards.h" + OrderBackupPool _order_backup_pool("BackupOrder"); INSTANTIATE_POOL_METHODS(OrderBackup) diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 70ab702a5..e73f4f35f 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -30,6 +30,8 @@ #include "table/strings.h" +#include "safeguards.h" + /* DestinationID must be at least as large as every these below, because it can * be any of them */ diff --git a/src/order_gui.cpp b/src/order_gui.cpp index e62cf595f..ac248f878 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -32,6 +32,8 @@ #include "widgets/order_widget.h" +#include "safeguards.h" + /** Order load types that could be given to station orders. */ static const StringID _station_load_types[][5][5] = { diff --git a/src/os/macosx/crashlog_osx.cpp b/src/os/macosx/crashlog_osx.cpp index 109b3e5fe..05816c67e 100644 --- a/src/os/macosx/crashlog_osx.cpp +++ b/src/os/macosx/crashlog_osx.cpp @@ -22,6 +22,8 @@ #include <dlfcn.h> #include <cxxabi.h> +#include "../../safeguards.h" + /* Macro testing a stack address for valid alignment. */ #if defined(__i386__) diff --git a/src/os/macosx/splash.cpp b/src/os/macosx/splash.cpp index bc1cd2dbf..eadb78510 100644 --- a/src/os/macosx/splash.cpp +++ b/src/os/macosx/splash.cpp @@ -23,6 +23,8 @@ #include <png.h> +#include "../../safeguards.h" + /** * Handle pnglib error. * diff --git a/src/os/os2/os2.cpp b/src/os/os2/os2.cpp index 82ba19924..283104d08 100644 --- a/src/os/os2/os2.cpp +++ b/src/os/os2/os2.cpp @@ -30,6 +30,8 @@ #include <dos.h> #endif +#include "../../safeguards.h" + #define INCL_WIN #define INCL_WINCLIPBOARD diff --git a/src/os/unix/crashlog_unix.cpp b/src/os/unix/crashlog_unix.cpp index 0960720d1..47de057f7 100644 --- a/src/os/unix/crashlog_unix.cpp +++ b/src/os/unix/crashlog_unix.cpp @@ -31,6 +31,8 @@ #include <unistd.h> #endif +#include "../../safeguards.h" + /** * Unix implementation for the crash logger. */ diff --git a/src/os/unix/unix.cpp b/src/os/unix/unix.cpp index 09bf6c6e7..accfffc06 100644 --- a/src/os/unix/unix.cpp +++ b/src/os/unix/unix.cpp @@ -63,6 +63,8 @@ ULONG __stack = (1024*1024)*2; // maybe not that much is needed actually ;) #endif #endif +#include "../../safeguards.h" + bool FiosIsRoot(const char *path) { #if !defined(__MORPHOS__) && !defined(__AMIGAOS__) diff --git a/src/os/windows/crashlog_win.cpp b/src/os/windows/crashlog_win.cpp index 41f83b60b..9704403c8 100644 --- a/src/os/windows/crashlog_win.cpp +++ b/src/os/windows/crashlog_win.cpp @@ -24,6 +24,8 @@ #include <windows.h> #include <signal.h> +#include "../../safeguards.h" + static const uint MAX_SYMBOL_LEN = 512; static const uint MAX_FRAMES = 64; diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp index d7ea4ab35..30d964df7 100644 --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -29,6 +29,8 @@ #include <errno.h> #include <sys/stat.h> +#include "../../safeguards.h" + static bool _has_console; static bool _cursor_disable = true; static bool _cursor_visible = true; diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp index 2516c4dbf..446f88db6 100644 --- a/src/osk_gui.cpp +++ b/src/osk_gui.cpp @@ -23,6 +23,8 @@ #include "table/sprites.h" #include "table/strings.h" +#include "safeguards.h" + char _keyboard_opt[2][OSK_KEYBOARD_ENTRIES * 4 + 1]; static WChar _keyboard[2][OSK_KEYBOARD_ENTRIES]; diff --git a/src/pathfinder/npf/aystar.cpp b/src/pathfinder/npf/aystar.cpp index 153ffa8c1..9ef2bca47 100644 --- a/src/pathfinder/npf/aystar.cpp +++ b/src/pathfinder/npf/aystar.cpp @@ -27,6 +27,8 @@ #include "../../core/alloc_func.hpp" #include "aystar.h" +#include "../../safeguards.h" + /** * This looks in the hash whether a node exists in the closed list. * @param node Node to search. diff --git a/src/pathfinder/npf/npf.cpp b/src/pathfinder/npf/npf.cpp index 5c4ccb3cc..bb705e5f4 100644 --- a/src/pathfinder/npf/npf.cpp +++ b/src/pathfinder/npf/npf.cpp @@ -19,6 +19,8 @@ #include "../follow_track.hpp" #include "aystar.h" +#include "../../safeguards.h" + static const uint NPF_HASH_BITS = 12; ///< The size of the hash used in pathfinding. Just changing this value should be sufficient to change the hash size. Should be an even value. /* Do no change below values */ static const uint NPF_HASH_SIZE = 1 << NPF_HASH_BITS; diff --git a/src/pathfinder/npf/queue.cpp b/src/pathfinder/npf/queue.cpp index 45540c1b6..2afb41391 100644 --- a/src/pathfinder/npf/queue.cpp +++ b/src/pathfinder/npf/queue.cpp @@ -13,6 +13,8 @@ #include "../../core/alloc_func.hpp" #include "queue.h" +#include "../../safeguards.h" + /* * Binary Heap diff --git a/src/pathfinder/opf/opf_ship.cpp b/src/pathfinder/opf/opf_ship.cpp index 850577de1..023c6a4a0 100644 --- a/src/pathfinder/opf/opf_ship.cpp +++ b/src/pathfinder/opf/opf_ship.cpp @@ -15,6 +15,8 @@ #include "../../ship.h" #include "../../core/random_func.hpp" +#include "../../safeguards.h" + struct RememberData { uint16 cur_length; byte depth; diff --git a/src/pathfinder/yapf/yapf_rail.cpp b/src/pathfinder/yapf/yapf_rail.cpp index f66140046..dea4e28c1 100644 --- a/src/pathfinder/yapf/yapf_rail.cpp +++ b/src/pathfinder/yapf/yapf_rail.cpp @@ -19,6 +19,8 @@ #include "../../viewport_func.h" #include "../../newgrf_station.h" +#include "../../safeguards.h" + #define DEBUG_YAPF_CACHE 0 #if DEBUG_YAPF_CACHE diff --git a/src/pathfinder/yapf/yapf_road.cpp b/src/pathfinder/yapf/yapf_road.cpp index 82493241f..711889b56 100644 --- a/src/pathfinder/yapf/yapf_road.cpp +++ b/src/pathfinder/yapf/yapf_road.cpp @@ -14,6 +14,8 @@ #include "yapf_node_road.hpp" #include "../../roadstop_base.h" +#include "../../safeguards.h" + template <class Types> class CYapfCostRoadT diff --git a/src/pathfinder/yapf/yapf_ship.cpp b/src/pathfinder/yapf/yapf_ship.cpp index 5e1cd27e7..a01444a9e 100644 --- a/src/pathfinder/yapf/yapf_ship.cpp +++ b/src/pathfinder/yapf/yapf_ship.cpp @@ -15,6 +15,8 @@ #include "yapf.hpp" #include "yapf_node_ship.hpp" +#include "../../safeguards.h" + /** Node Follower module of YAPF for ships */ template <class Types> class CYapfFollowShipT diff --git a/src/pbs.cpp b/src/pbs.cpp index 55569c059..76cb3b9d6 100644 --- a/src/pbs.cpp +++ b/src/pbs.cpp @@ -15,6 +15,8 @@ #include "newgrf_station.h" #include "pathfinder/follow_track.hpp" +#include "safeguards.h" + /** * Get the reserved trackbits for any tile, regardless of type. * @param t the tile diff --git a/src/progress.cpp b/src/progress.cpp index 343893cee..b498be109 100644 --- a/src/progress.cpp +++ b/src/progress.cpp @@ -12,6 +12,8 @@ #include "stdafx.h" #include "thread/thread.h" +#include "safeguards.h" + /** Are we in a modal progress or not? */ bool _in_modal_progress = false; bool _first_in_modal_loop = false; diff --git a/src/rail.cpp b/src/rail.cpp index dd34cb653..79598ec4a 100644 --- a/src/rail.cpp +++ b/src/rail.cpp @@ -17,6 +17,8 @@ #include "company_base.h" #include "engine_base.h" +#include "safeguards.h" + /* XXX: Below 3 tables store duplicate data. Maybe remove some? */ /* Maps a trackdir to the bit that stores its status in the map arrays, in the * direction along with the trackdir */ diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 4dd4659bb..c4b2b9f43 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -38,6 +38,8 @@ #include "table/railtypes.h" #include "table/track_land.h" +#include "safeguards.h" + /** Helper type for lists/vectors of trains */ typedef SmallVector<Train *, 16> TrainList; diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 6fb08e7ca..d07bb5520 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -40,6 +40,8 @@ #include "widgets/rail_widget.h" +#include "safeguards.h" + static RailType _cur_railtype; ///< Rail type of the current build-rail toolbar. static bool _remove_button_clicked; ///< Flag whether 'remove' toggle-button is currently enabled diff --git a/src/rev.cpp.in b/src/rev.cpp.in index 506e641d7..c20838205 100644 --- a/src/rev.cpp.in +++ b/src/rev.cpp.in @@ -13,6 +13,8 @@ #include "core/bitmath_func.hpp" #include "rev.h" +#include "safeguards.h" + /** * Is this version of OpenTTD a release version? * @return True if it is a release version. diff --git a/src/road.cpp b/src/road.cpp index c005d56c1..57c5da5d4 100644 --- a/src/road.cpp +++ b/src/road.cpp @@ -20,6 +20,8 @@ #include "date_func.h" #include "landscape.h" +#include "safeguards.h" + /** * Return if the tile is a valid tile for a crossing. * diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 7931fa965..d20bdcfb4 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -38,6 +38,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** * Verify whether a road vehicle is available. * @return \c true if at least one road vehicle is available, \c false if not diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 181c92001..c0594e1f8 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -33,6 +33,8 @@ #include "table/strings.h" +#include "safeguards.h" + static void ShowRVStationPicker(Window *parent, RoadStopType rs); static void ShowRoadDepotPicker(Window *parent); diff --git a/src/road_map.cpp b/src/road_map.cpp index 2c24582ee..4984117ba 100644 --- a/src/road_map.cpp +++ b/src/road_map.cpp @@ -13,6 +13,8 @@ #include "station_map.h" #include "tunnelbridge_map.h" +#include "safeguards.h" + /** * Returns the RoadBits on an arbitrary tile diff --git a/src/roadstop.cpp b/src/roadstop.cpp index 193e915d2..ca049979c 100644 --- a/src/roadstop.cpp +++ b/src/roadstop.cpp @@ -16,6 +16,8 @@ #include "station_base.h" #include "vehicle_func.h" +#include "safeguards.h" + /** The pool of roadstops. */ RoadStopPool _roadstop_pool("RoadStop"); INSTANTIATE_POOL_METHODS(RoadStop) diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index ae15a88a5..88a31de73 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -38,6 +38,8 @@ #include "table/strings.h" +#include "safeguards.h" + static const uint16 _roadveh_images[] = { 0xCD4, 0xCDC, 0xCE4, 0xCEC, 0xCF4, 0xCFC, 0xD0C, 0xD14, 0xD24, 0xD1C, 0xD2C, 0xD04, 0xD1C, 0xD24, 0xD6C, 0xD74, diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp index bf837bbad..7f3e7bbbc 100644 --- a/src/roadveh_gui.cpp +++ b/src/roadveh_gui.cpp @@ -18,6 +18,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** * Draw the details for the given vehicle at the given position * diff --git a/src/safeguards.h b/src/safeguards.h new file mode 100644 index 000000000..e4c8949f1 --- /dev/null +++ b/src/safeguards.h @@ -0,0 +1,67 @@ +/* $Id$ */ + +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * @file safeguards.h A number of safeguards to prevent using unsafe methods. + * + * Unsafe methods are, for example, strndup and strncpy because they may leave the + * string without a null termination, but also strdup and strndup because they can + * return NULL and then all strdups would need to be guarded against that instead + * of using the current MallocT/ReallocT/CallocT technique of just giving the user + * an error that too much memory was used instead of spreading that code though + * the whole code base. + */ + +#ifndef SAFEGUARDS_H +#define SAFEGUARDS_H + +/* Use MallocT instead. */ +#define malloc SAFEGUARD_DO_NOT_USE_THIS_METHOD + +/* Use MallocT instead. */ +#define calloc SAFEGUARD_DO_NOT_USE_THIS_METHOD + +/* Use ReallocT instead. */ +#define realloc SAFEGUARD_DO_NOT_USE_THIS_METHOD + +/* Use stredup instead. */ +//#define strdup SAFEGUARD_DO_NOT_USE_THIS_METHOD + +/* Use stredup instead. */ +//#define strndup SAFEGUARD_DO_NOT_USE_THIS_METHOD + +/* Use strecpy instead. */ +//#define strcpy SAFEGUARD_DO_NOT_USE_THIS_METHOD +//#define strncpy SAFEGUARD_DO_NOT_USE_THIS_METHOD + +/* Use strecat instead. */ +//#define strcat SAFEGUARD_DO_NOT_USE_THIS_METHOD +//#define strncat SAFEGUARD_DO_NOT_USE_THIS_METHOD + +/* Use seprintf instead. */ +//#define sprintf SAFEGUARD_DO_NOT_USE_THIS_METHOD +//#define snprintf SAFEGUARD_DO_NOT_USE_THIS_METHOD + +/* Use vseprintf instead. */ +//#define vsprintf SAFEGUARD_DO_NOT_USE_THIS_METHOD +//#define vsnprintf SAFEGUARD_DO_NOT_USE_THIS_METHOD + +/* Use fgets instead. */ +#define gets SAFEGUARD_DO_NOT_USE_THIS_METHOD + +/* No clear replacement. */ +//#define strtok SAFEGUARD_DO_NOT_USE_THIS_METHOD + +/* + * Possible future methods to mark unsafe, though needs more thought: + * - memcpy; when memory area overlaps it messes up, use memmove. + * - strlen: when the data is 'garbage', this could read beyond bounds. + */ + +#endif /* SAFEGUARDS_H */ diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 87754d6b5..d56dbe171 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -58,6 +58,8 @@ #include <signal.h> +#include "../safeguards.h" + extern Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY); /** diff --git a/src/saveload/ai_sl.cpp b/src/saveload/ai_sl.cpp index 51d0a50b8..b86c5541e 100644 --- a/src/saveload/ai_sl.cpp +++ b/src/saveload/ai_sl.cpp @@ -20,6 +20,8 @@ #include "../network/network.h" #include "../ai/ai_instance.hpp" +#include "../safeguards.h" + static char _ai_saveload_name[64]; static int _ai_saveload_version; static char _ai_saveload_settings[1024]; diff --git a/src/saveload/airport_sl.cpp b/src/saveload/airport_sl.cpp index 00a4b2b01..1172d2593 100644 --- a/src/saveload/airport_sl.cpp +++ b/src/saveload/airport_sl.cpp @@ -14,6 +14,8 @@ #include "saveload.h" #include "newgrf_sl.h" +#include "../safeguards.h" + static void Save_APID() { Save_NewGRFMapping(_airport_mngr); diff --git a/src/saveload/animated_tile_sl.cpp b/src/saveload/animated_tile_sl.cpp index 2ccd42cb5..3fc5f6175 100644 --- a/src/saveload/animated_tile_sl.cpp +++ b/src/saveload/animated_tile_sl.cpp @@ -15,6 +15,8 @@ #include "saveload.h" +#include "../safeguards.h" + extern TileIndex *_animated_tile_list; extern uint _animated_tile_count; extern uint _animated_tile_allocated; diff --git a/src/saveload/autoreplace_sl.cpp b/src/saveload/autoreplace_sl.cpp index 0cb9cca8d..99e945503 100644 --- a/src/saveload/autoreplace_sl.cpp +++ b/src/saveload/autoreplace_sl.cpp @@ -14,6 +14,8 @@ #include "saveload.h" +#include "../safeguards.h" + static const SaveLoad _engine_renew_desc[] = { SLE_VAR(EngineRenew, from, SLE_UINT16), SLE_VAR(EngineRenew, to, SLE_UINT16), diff --git a/src/saveload/cargomonitor_sl.cpp b/src/saveload/cargomonitor_sl.cpp index 2188470a2..98ad95f09 100644 --- a/src/saveload/cargomonitor_sl.cpp +++ b/src/saveload/cargomonitor_sl.cpp @@ -14,6 +14,8 @@ #include "saveload.h" +#include "../safeguards.h" + /** Temporary storage of cargo monitoring data for loading or saving it. */ struct TempStorage { CargoMonitorID number; diff --git a/src/saveload/cargopacket_sl.cpp b/src/saveload/cargopacket_sl.cpp index fbc38cc85..dc8d4145e 100644 --- a/src/saveload/cargopacket_sl.cpp +++ b/src/saveload/cargopacket_sl.cpp @@ -15,6 +15,8 @@ #include "saveload.h" +#include "../safeguards.h" + /** * Savegame conversion for cargopackets. */ diff --git a/src/saveload/cheat_sl.cpp b/src/saveload/cheat_sl.cpp index aa5648a88..4616b7e85 100644 --- a/src/saveload/cheat_sl.cpp +++ b/src/saveload/cheat_sl.cpp @@ -14,6 +14,8 @@ #include "saveload.h" +#include "../safeguards.h" + /** * Save the cheat values. */ diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp index 5878f31ea..03e9cdcb3 100644 --- a/src/saveload/company_sl.cpp +++ b/src/saveload/company_sl.cpp @@ -21,6 +21,8 @@ #include "table/strings.h" +#include "../safeguards.h" + /** * Converts an old company manager's face format to the new company manager's face format * diff --git a/src/saveload/depot_sl.cpp b/src/saveload/depot_sl.cpp index 0d62d74cd..861a54173 100644 --- a/src/saveload/depot_sl.cpp +++ b/src/saveload/depot_sl.cpp @@ -15,6 +15,8 @@ #include "saveload.h" +#include "../safeguards.h" + static TownID _town_index; static const SaveLoad _depot_desc[] = { diff --git a/src/saveload/economy_sl.cpp b/src/saveload/economy_sl.cpp index 86605bdfb..dabf120fc 100644 --- a/src/saveload/economy_sl.cpp +++ b/src/saveload/economy_sl.cpp @@ -15,6 +15,8 @@ #include "saveload.h" +#include "../safeguards.h" + /** Prices in pre 126 savegames */ static void Load_PRIC() { diff --git a/src/saveload/engine_sl.cpp b/src/saveload/engine_sl.cpp index d02264cd6..80ab5debd 100644 --- a/src/saveload/engine_sl.cpp +++ b/src/saveload/engine_sl.cpp @@ -14,6 +14,8 @@ #include "../engine_base.h" #include <map> +#include "../safeguards.h" + static const SaveLoad _engine_desc[] = { SLE_CONDVAR(Engine, intro_date, SLE_FILE_U16 | SLE_VAR_I32, 0, 30), SLE_CONDVAR(Engine, intro_date, SLE_INT32, 31, SL_MAX_VERSION), diff --git a/src/saveload/game_sl.cpp b/src/saveload/game_sl.cpp index b2b263b13..629bc271a 100644 --- a/src/saveload/game_sl.cpp +++ b/src/saveload/game_sl.cpp @@ -20,6 +20,8 @@ #include "../game/game_instance.hpp" #include "../game/game_text.hpp" +#include "../safeguards.h" + static char _game_saveload_name[64]; static int _game_saveload_version; static char _game_saveload_settings[1024]; diff --git a/src/saveload/gamelog_sl.cpp b/src/saveload/gamelog_sl.cpp index f25a8d1eb..f818eca13 100644 --- a/src/saveload/gamelog_sl.cpp +++ b/src/saveload/gamelog_sl.cpp @@ -15,6 +15,8 @@ #include "saveload.h" +#include "../safeguards.h" + static const SaveLoad _glog_action_desc[] = { SLE_VAR(LoggedAction, tick, SLE_UINT16), SLE_END() diff --git a/src/saveload/goal_sl.cpp b/src/saveload/goal_sl.cpp index 1c260503e..c415d8ba4 100644 --- a/src/saveload/goal_sl.cpp +++ b/src/saveload/goal_sl.cpp @@ -14,6 +14,8 @@ #include "saveload.h" +#include "../safeguards.h" + static const SaveLoad _goals_desc[] = { SLE_VAR(Goal, company, SLE_UINT16), SLE_VAR(Goal, type, SLE_UINT16), diff --git a/src/saveload/group_sl.cpp b/src/saveload/group_sl.cpp index 891d6ea6f..93734f80f 100644 --- a/src/saveload/group_sl.cpp +++ b/src/saveload/group_sl.cpp @@ -14,6 +14,8 @@ #include "saveload.h" +#include "../safeguards.h" + static const SaveLoad _group_desc[] = { SLE_CONDVAR(Group, name, SLE_NAME, 0, 83), SLE_CONDSTR(Group, name, SLE_STR | SLF_ALLOW_CONTROL, 0, 84, SL_MAX_VERSION), diff --git a/src/saveload/industry_sl.cpp b/src/saveload/industry_sl.cpp index 469548f23..658cfd2bd 100644 --- a/src/saveload/industry_sl.cpp +++ b/src/saveload/industry_sl.cpp @@ -15,6 +15,8 @@ #include "saveload.h" #include "newgrf_sl.h" +#include "../safeguards.h" + static OldPersistentStorage _old_ind_persistent_storage; static const SaveLoad _industry_desc[] = { diff --git a/src/saveload/labelmaps_sl.cpp b/src/saveload/labelmaps_sl.cpp index 5cc77af0c..3b898a3b8 100644 --- a/src/saveload/labelmaps_sl.cpp +++ b/src/saveload/labelmaps_sl.cpp @@ -15,6 +15,8 @@ #include "saveload.h" +#include "../safeguards.h" + static SmallVector<RailTypeLabel, RAILTYPE_END> _railtype_list; /** diff --git a/src/saveload/linkgraph_sl.cpp b/src/saveload/linkgraph_sl.cpp index f0dcb1dd4..d9b2b9093 100644 --- a/src/saveload/linkgraph_sl.cpp +++ b/src/saveload/linkgraph_sl.cpp @@ -16,6 +16,8 @@ #include "../settings_internal.h" #include "saveload.h" +#include "../safeguards.h" + typedef LinkGraph::BaseNode Node; typedef LinkGraph::BaseEdge Edge; diff --git a/src/saveload/map_sl.cpp b/src/saveload/map_sl.cpp index 7088a4406..007af7bc6 100644 --- a/src/saveload/map_sl.cpp +++ b/src/saveload/map_sl.cpp @@ -16,6 +16,8 @@ #include "saveload.h" +#include "../safeguards.h" + static uint32 _map_dim_x; static uint32 _map_dim_y; diff --git a/src/saveload/misc_sl.cpp b/src/saveload/misc_sl.cpp index 72c56db54..c7bd31e81 100644 --- a/src/saveload/misc_sl.cpp +++ b/src/saveload/misc_sl.cpp @@ -21,6 +21,8 @@ #include "saveload.h" +#include "../safeguards.h" + extern TileIndex _cur_tileloop_tile; extern uint16 _disaster_delay; extern byte _trees_tick_ctr; diff --git a/src/saveload/newgrf_sl.cpp b/src/saveload/newgrf_sl.cpp index d3915340c..cdfd0f317 100644 --- a/src/saveload/newgrf_sl.cpp +++ b/src/saveload/newgrf_sl.cpp @@ -15,6 +15,8 @@ #include "saveload.h" #include "newgrf_sl.h" +#include "../safeguards.h" + /** Save and load the mapping between a spec and the NewGRF it came from. */ static const SaveLoad _newgrf_mapping_desc[] = { SLE_VAR(EntityIDMapping, grfid, SLE_UINT32), diff --git a/src/saveload/object_sl.cpp b/src/saveload/object_sl.cpp index 4e8539793..dfb1d2cbf 100644 --- a/src/saveload/object_sl.cpp +++ b/src/saveload/object_sl.cpp @@ -16,6 +16,8 @@ #include "saveload.h" #include "newgrf_sl.h" +#include "../safeguards.h" + static const SaveLoad _object_desc[] = { SLE_VAR(Object, location.tile, SLE_UINT32), SLE_VAR(Object, location.w, SLE_FILE_U8 | SLE_VAR_U16), diff --git a/src/saveload/oldloader.cpp b/src/saveload/oldloader.cpp index 83fc58ebf..13ee0e5b0 100644 --- a/src/saveload/oldloader.cpp +++ b/src/saveload/oldloader.cpp @@ -23,6 +23,8 @@ #include <exception> +#include "../safeguards.h" + static const int TTO_HEADER_SIZE = 41; static const int TTD_HEADER_SIZE = 49; diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp index f9215cf1d..e260acd45 100644 --- a/src/saveload/oldloader_sl.cpp +++ b/src/saveload/oldloader_sl.cpp @@ -34,6 +34,8 @@ #include "../table/engines.h" #include "../table/townname.h" +#include "../safeguards.h" + static bool _read_ttdpatch_flags; ///< Have we (tried to) read TTDPatch extra flags? static uint16 _old_extra_chunk_nums; ///< Number of extra TTDPatch chunks static byte _old_vehicle_multiplier; ///< TTDPatch vehicle multiplier diff --git a/src/saveload/order_sl.cpp b/src/saveload/order_sl.cpp index 823416579..40f83f832 100644 --- a/src/saveload/order_sl.cpp +++ b/src/saveload/order_sl.cpp @@ -16,6 +16,8 @@ #include "saveload_internal.h" +#include "../safeguards.h" + /** * Converts this order from an old savegame's version; * it moves all bits to the new location. diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index ab3e4a290..34b396ddc 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -49,6 +49,8 @@ #include "saveload_internal.h" #include "saveload_filter.h" +#include "../safeguards.h" + /* * Previous savegame versions, the trunk revision where they were * introduced and the released version that had that particular diff --git a/src/saveload/signs_sl.cpp b/src/saveload/signs_sl.cpp index d5ea26d65..d5bacd509 100644 --- a/src/saveload/signs_sl.cpp +++ b/src/saveload/signs_sl.cpp @@ -15,6 +15,8 @@ #include "saveload.h" +#include "../safeguards.h" + /** Description of a sign within the savegame. */ static const SaveLoad _sign_desc[] = { SLE_CONDVAR(Sign, name, SLE_NAME, 0, 83), diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp index 71e3b31ec..23c306c38 100644 --- a/src/saveload/station_sl.cpp +++ b/src/saveload/station_sl.cpp @@ -19,6 +19,8 @@ #include "saveload.h" #include "table/strings.h" +#include "../safeguards.h" + /** * Update the buoy orders to be waypoint orders. * @param o the order 'list' to check. diff --git a/src/saveload/storage_sl.cpp b/src/saveload/storage_sl.cpp index d35fa7cc9..110df63a7 100644 --- a/src/saveload/storage_sl.cpp +++ b/src/saveload/storage_sl.cpp @@ -13,6 +13,8 @@ #include "../newgrf_storage.h" #include "saveload.h" +#include "../safeguards.h" + /** Description of the data to save and load in #PersistentStorage. */ static const SaveLoad _storage_desc[] = { SLE_CONDVAR(PersistentStorage, grfid, SLE_UINT32, 6, SL_MAX_VERSION), diff --git a/src/saveload/story_sl.cpp b/src/saveload/story_sl.cpp index 310f96fcb..87e3720a6 100644 --- a/src/saveload/story_sl.cpp +++ b/src/saveload/story_sl.cpp @@ -14,6 +14,8 @@ #include "saveload.h" +#include "../safeguards.h" + /** Called after load to trash broken pages. */ void AfterLoadStoryBook() { diff --git a/src/saveload/strings_sl.cpp b/src/saveload/strings_sl.cpp index b1cc50d46..c6b63bc1a 100644 --- a/src/saveload/strings_sl.cpp +++ b/src/saveload/strings_sl.cpp @@ -15,6 +15,8 @@ #include "table/strings.h" +#include "../safeguards.h" + static const int NUM_OLD_STRINGS = 512; ///< The number of custom strings stored in old savegames. static const int LEN_OLD_STRINGS = 32; ///< The number of characters per string. static const int LEN_OLD_STRINGS_TTO = 24; ///< The number of characters per string in TTO savegames. diff --git a/src/saveload/subsidy_sl.cpp b/src/saveload/subsidy_sl.cpp index bfdd25339..f6d650468 100644 --- a/src/saveload/subsidy_sl.cpp +++ b/src/saveload/subsidy_sl.cpp @@ -14,6 +14,8 @@ #include "saveload.h" +#include "../safeguards.h" + static const SaveLoad _subsidies_desc[] = { SLE_VAR(Subsidy, cargo_type, SLE_UINT8), SLE_VAR(Subsidy, remaining, SLE_UINT8), diff --git a/src/saveload/town_sl.cpp b/src/saveload/town_sl.cpp index de52604f5..7db6a7aa6 100644 --- a/src/saveload/town_sl.cpp +++ b/src/saveload/town_sl.cpp @@ -18,6 +18,8 @@ #include "saveload.h" #include "newgrf_sl.h" +#include "../safeguards.h" + /** * Rebuild all the cached variables of towns. */ diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index ad8ef0831..059015be2 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -24,6 +24,8 @@ #include <map> +#include "../safeguards.h" + /** * Link front and rear multiheaded engines to each other * This is done when loading a savegame diff --git a/src/saveload/waypoint_sl.cpp b/src/saveload/waypoint_sl.cpp index 6ea72ea6f..0f9396985 100644 --- a/src/saveload/waypoint_sl.cpp +++ b/src/saveload/waypoint_sl.cpp @@ -20,6 +20,8 @@ #include "saveload_internal.h" +#include "../safeguards.h" + /** Helper structure to convert from the old waypoint system. */ struct OldWaypoint { size_t index; diff --git a/src/screenshot.cpp b/src/screenshot.cpp index 6e72dd520..799be36d2 100644 --- a/src/screenshot.cpp +++ b/src/screenshot.cpp @@ -28,6 +28,8 @@ #include "table/strings.h" +#include "safeguards.h" + static const char * const SCREENSHOT_NAME = "screenshot"; ///< Default filename of a saved screenshot. static const char * const HEIGHTMAP_NAME = "heightmap"; ///< Default filename of a saved heightmap. diff --git a/src/script/api/script_accounting.cpp b/src/script/api/script_accounting.cpp index dfe05df3b..e6fddf9e8 100644 --- a/src/script/api/script_accounting.cpp +++ b/src/script/api/script_accounting.cpp @@ -12,6 +12,8 @@ #include "../../stdafx.h" #include "script_accounting.hpp" +#include "../../safeguards.h" + Money ScriptAccounting::GetCosts() { return this->GetDoCommandCosts(); diff --git a/src/script/api/script_admin.cpp b/src/script/api/script_admin.cpp index 3625fb458..9027b29a2 100644 --- a/src/script/api/script_admin.cpp +++ b/src/script/api/script_admin.cpp @@ -15,6 +15,8 @@ #include "../../network/network_admin.h" #include "../script_instance.hpp" +#include "../../safeguards.h" + /* static */ bool ScriptAdmin::MakeJSON(HSQUIRRELVM vm, SQInteger index, int max_depth, std::string &data) { if (max_depth == 0) { diff --git a/src/script/api/script_airport.cpp b/src/script/api/script_airport.cpp index 438a18ae9..edb912609 100644 --- a/src/script/api/script_airport.cpp +++ b/src/script/api/script_airport.cpp @@ -15,6 +15,8 @@ #include "../../station_base.h" #include "../../town.h" +#include "../../safeguards.h" + /* static */ bool ScriptAirport::IsValidAirportType(AirportType type) { return IsAirportInformationAvailable(type) && ::AirportSpec::Get(type)->IsAvailable(); diff --git a/src/script/api/script_base.cpp b/src/script/api/script_base.cpp index 7fd5b2df9..5b2d550b8 100644 --- a/src/script/api/script_base.cpp +++ b/src/script/api/script_base.cpp @@ -15,6 +15,8 @@ #include "../../network/network.h" #include "../../core/random_func.hpp" +#include "../../safeguards.h" + /* static */ uint32 ScriptBase::Rand() { /* We pick RandomRange if we are in SP (so when saved, we do the same over and over) diff --git a/src/script/api/script_basestation.cpp b/src/script/api/script_basestation.cpp index 5134243a9..229abf865 100644 --- a/src/script/api/script_basestation.cpp +++ b/src/script/api/script_basestation.cpp @@ -17,6 +17,8 @@ #include "../../strings_func.h" #include "table/strings.h" +#include "../../safeguards.h" + /* static */ bool ScriptBaseStation::IsValidBaseStation(StationID station_id) { const BaseStation *st = ::BaseStation::GetIfValid(station_id); diff --git a/src/script/api/script_bridge.cpp b/src/script/api/script_bridge.cpp index 25f9fc454..45bec466c 100644 --- a/src/script/api/script_bridge.cpp +++ b/src/script/api/script_bridge.cpp @@ -17,6 +17,8 @@ #include "../../strings_func.h" #include "../../date_func.h" +#include "../../safeguards.h" + /* static */ bool ScriptBridge::IsValidBridge(BridgeID bridge_id) { return bridge_id < MAX_BRIDGES && ::GetBridgeSpec(bridge_id)->avail_year <= _cur_year; diff --git a/src/script/api/script_bridgelist.cpp b/src/script/api/script_bridgelist.cpp index 9687663e9..0969342ec 100644 --- a/src/script/api/script_bridgelist.cpp +++ b/src/script/api/script_bridgelist.cpp @@ -14,6 +14,8 @@ #include "script_bridge.hpp" #include "../../bridge.h" +#include "../../safeguards.h" + ScriptBridgeList::ScriptBridgeList() { for (byte j = 0; j < MAX_BRIDGES; j++) { diff --git a/src/script/api/script_cargo.cpp b/src/script/api/script_cargo.cpp index b2459af4e..a2643f897 100644 --- a/src/script/api/script_cargo.cpp +++ b/src/script/api/script_cargo.cpp @@ -15,6 +15,8 @@ #include "../../core/bitmath_func.hpp" #include "../../settings_type.h" +#include "../../safeguards.h" + /* static */ bool ScriptCargo::IsValidCargo(CargoID cargo_type) { return (cargo_type < NUM_CARGO && ::CargoSpec::Get(cargo_type)->IsValid()); diff --git a/src/script/api/script_cargolist.cpp b/src/script/api/script_cargolist.cpp index 08f705d60..39b22a792 100644 --- a/src/script/api/script_cargolist.cpp +++ b/src/script/api/script_cargolist.cpp @@ -17,6 +17,8 @@ #include "../../industry.h" #include "../../station_base.h" +#include "../../safeguards.h" + ScriptCargoList::ScriptCargoList() { const CargoSpec *cs; diff --git a/src/script/api/script_cargomonitor.cpp b/src/script/api/script_cargomonitor.cpp index e19821bba..4b5b85ed6 100644 --- a/src/script/api/script_cargomonitor.cpp +++ b/src/script/api/script_cargomonitor.cpp @@ -12,6 +12,8 @@ #include "../../stdafx.h" #include "script_cargomonitor.hpp" +#include "../../safeguards.h" + /* static */ uint32 ScriptCargoMonitor::GetTownDeliveryAmount(ScriptCompany::CompanyID company, CargoID cargo, TownID town_id, bool keep_monitoring) { CargoMonitorID monitor = EncodeCargoTownMonitor(static_cast<CompanyID>(company), cargo, town_id); diff --git a/src/script/api/script_company.cpp b/src/script/api/script_company.cpp index 851ca7888..53f58c914 100644 --- a/src/script/api/script_company.cpp +++ b/src/script/api/script_company.cpp @@ -24,6 +24,8 @@ #include "../../settings_func.h" #include "table/strings.h" +#include "../../safeguards.h" + /* static */ ScriptCompany::CompanyID ScriptCompany::ResolveCompanyID(ScriptCompany::CompanyID company) { if (company == COMPANY_SELF) { diff --git a/src/script/api/script_companymode.cpp b/src/script/api/script_companymode.cpp index bf6da493c..1931a5db7 100644 --- a/src/script/api/script_companymode.cpp +++ b/src/script/api/script_companymode.cpp @@ -12,6 +12,8 @@ #include "../../stdafx.h" #include "script_companymode.hpp" +#include "../../safeguards.h" + ScriptCompanyMode::ScriptCompanyMode(int company) { if (company < OWNER_BEGIN || company >= MAX_COMPANIES) company = INVALID_COMPANY; diff --git a/src/script/api/script_controller.cpp b/src/script/api/script_controller.cpp index 7ca0c7d46..d8489da49 100644 --- a/src/script/api/script_controller.cpp +++ b/src/script/api/script_controller.cpp @@ -24,6 +24,8 @@ #include "../../settings_type.h" #include "../../network/network.h" +#include "../../safeguards.h" + /* static */ void ScriptController::SetCommandDelay(int ticks) { if (ticks <= 0) return; diff --git a/src/script/api/script_date.cpp b/src/script/api/script_date.cpp index 6ff92deba..2f5b39963 100644 --- a/src/script/api/script_date.cpp +++ b/src/script/api/script_date.cpp @@ -14,6 +14,8 @@ #include "script_date.hpp" #include "../../date_func.h" +#include "../../safeguards.h" + /* static */ bool ScriptDate::IsValidDate(Date date) { return date >= 0; diff --git a/src/script/api/script_depotlist.cpp b/src/script/api/script_depotlist.cpp index 7adbe8a28..05bb4ccd0 100644 --- a/src/script/api/script_depotlist.cpp +++ b/src/script/api/script_depotlist.cpp @@ -14,6 +14,8 @@ #include "../../depot_base.h" #include "../../station_base.h" +#include "../../safeguards.h" + ScriptDepotList::ScriptDepotList(ScriptTile::TransportType transport_type) { ::TileType tile_type; diff --git a/src/script/api/script_engine.cpp b/src/script/api/script_engine.cpp index 138628547..1fe16321b 100644 --- a/src/script/api/script_engine.cpp +++ b/src/script/api/script_engine.cpp @@ -20,6 +20,8 @@ #include "../../articulated_vehicles.h" #include "table/strings.h" +#include "../../safeguards.h" + /* static */ bool ScriptEngine::IsValidEngine(EngineID engine_id) { const Engine *e = ::Engine::GetIfValid(engine_id); diff --git a/src/script/api/script_enginelist.cpp b/src/script/api/script_enginelist.cpp index b6143a20e..99ab9537b 100644 --- a/src/script/api/script_enginelist.cpp +++ b/src/script/api/script_enginelist.cpp @@ -13,6 +13,8 @@ #include "script_enginelist.hpp" #include "../../engine_base.h" +#include "../../safeguards.h" + ScriptEngineList::ScriptEngineList(ScriptVehicle::VehicleType vehicle_type) { Engine *e; diff --git a/src/script/api/script_error.cpp b/src/script/api/script_error.cpp index 46d287f77..9dd6ece19 100644 --- a/src/script/api/script_error.cpp +++ b/src/script/api/script_error.cpp @@ -13,6 +13,8 @@ #include "script_error.hpp" #include "../../core/bitmath_func.hpp" +#include "../../safeguards.h" + ScriptError::ScriptErrorMap ScriptError::error_map = ScriptError::ScriptErrorMap(); ScriptError::ScriptErrorMapString ScriptError::error_map_string = ScriptError::ScriptErrorMapString(); diff --git a/src/script/api/script_event.cpp b/src/script/api/script_event.cpp index d7d19863f..0e711ca41 100644 --- a/src/script/api/script_event.cpp +++ b/src/script/api/script_event.cpp @@ -14,6 +14,8 @@ #include <queue> +#include "../../safeguards.h" + /** The queue of events for a script. */ struct ScriptEventData { std::queue<ScriptEvent *> stack; ///< The actual queue. diff --git a/src/script/api/script_event_types.cpp b/src/script/api/script_event_types.cpp index f22bb2f61..8c1395c11 100644 --- a/src/script/api/script_event_types.cpp +++ b/src/script/api/script_event_types.cpp @@ -19,6 +19,8 @@ #include "../../articulated_vehicles.h" #include "table/strings.h" +#include "../../safeguards.h" + bool ScriptEventEnginePreview::IsEngineValid() const { const Engine *e = ::Engine::GetIfValid(this->engine); diff --git a/src/script/api/script_execmode.cpp b/src/script/api/script_execmode.cpp index fe2ac3d7c..4fb0cc7e2 100644 --- a/src/script/api/script_execmode.cpp +++ b/src/script/api/script_execmode.cpp @@ -14,6 +14,8 @@ #include "../script_instance.hpp" #include "../script_fatalerror.hpp" +#include "../../safeguards.h" + bool ScriptExecMode::ModeProc() { /* In execution mode we only return 'true', telling the DoCommand it diff --git a/src/script/api/script_game.cpp b/src/script/api/script_game.cpp index f0aeb191f..c24757a3c 100644 --- a/src/script/api/script_game.cpp +++ b/src/script/api/script_game.cpp @@ -15,6 +15,8 @@ #include "../../settings_type.h" #include "../../network/network.h" +#include "../../safeguards.h" + /* static */ bool ScriptGame::Pause() { return ScriptObject::DoCommand(0, PM_PAUSED_GAME_SCRIPT, 1, CMD_PAUSE); diff --git a/src/script/api/script_gamesettings.cpp b/src/script/api/script_gamesettings.cpp index ed284ae59..1f8ded877 100644 --- a/src/script/api/script_gamesettings.cpp +++ b/src/script/api/script_gamesettings.cpp @@ -15,6 +15,8 @@ #include "../../settings_type.h" #include "../../command_type.h" +#include "../../safeguards.h" + /* static */ bool ScriptGameSettings::IsValid(const char *setting) { uint i; diff --git a/src/script/api/script_goal.cpp b/src/script/api/script_goal.cpp index 535450973..5153e0ef0 100644 --- a/src/script/api/script_goal.cpp +++ b/src/script/api/script_goal.cpp @@ -20,6 +20,8 @@ #include "../../goal_base.h" #include "../../string_func.h" +#include "../../safeguards.h" + /* static */ bool ScriptGoal::IsValidGoal(GoalID goal_id) { return ::Goal::IsValidID(goal_id); diff --git a/src/script/api/script_group.cpp b/src/script/api/script_group.cpp index 89cbf2c71..1e8d6d774 100644 --- a/src/script/api/script_group.cpp +++ b/src/script/api/script_group.cpp @@ -19,6 +19,8 @@ #include "../../settings_func.h" #include "table/strings.h" +#include "../../safeguards.h" + /* static */ bool ScriptGroup::IsValidGroup(GroupID group_id) { const Group *g = ::Group::GetIfValid(group_id); diff --git a/src/script/api/script_grouplist.cpp b/src/script/api/script_grouplist.cpp index 39dd31002..d1071c36c 100644 --- a/src/script/api/script_grouplist.cpp +++ b/src/script/api/script_grouplist.cpp @@ -13,6 +13,8 @@ #include "script_grouplist.hpp" #include "../../group.h" +#include "../../safeguards.h" + ScriptGroupList::ScriptGroupList() { Group *g; diff --git a/src/script/api/script_industry.cpp b/src/script/api/script_industry.cpp index 5e30f1377..c536ec559 100644 --- a/src/script/api/script_industry.cpp +++ b/src/script/api/script_industry.cpp @@ -19,6 +19,8 @@ #include "../../newgrf_industries.h" #include "table/strings.h" +#include "../../safeguards.h" + /* static */ int32 ScriptIndustry::GetIndustryCount() { return (int32)::Industry::GetNumItems(); diff --git a/src/script/api/script_industrylist.cpp b/src/script/api/script_industrylist.cpp index b9824b9ac..d2d298fa3 100644 --- a/src/script/api/script_industrylist.cpp +++ b/src/script/api/script_industrylist.cpp @@ -13,6 +13,8 @@ #include "script_industrylist.hpp" #include "../../industry.h" +#include "../../safeguards.h" + ScriptIndustryList::ScriptIndustryList() { Industry *i; diff --git a/src/script/api/script_industrytype.cpp b/src/script/api/script_industrytype.cpp index bbfca99a4..1ac59975d 100644 --- a/src/script/api/script_industrytype.cpp +++ b/src/script/api/script_industrytype.cpp @@ -18,6 +18,8 @@ #include "../../newgrf_industries.h" #include "../../core/random_func.hpp" +#include "../../safeguards.h" + /* static */ bool ScriptIndustryType::IsValidIndustryType(IndustryType industry_type) { if (industry_type >= NUM_INDUSTRYTYPES) return false; diff --git a/src/script/api/script_industrytypelist.cpp b/src/script/api/script_industrytypelist.cpp index c72fabcaa..b60361578 100644 --- a/src/script/api/script_industrytypelist.cpp +++ b/src/script/api/script_industrytypelist.cpp @@ -13,6 +13,8 @@ #include "script_industrytypelist.hpp" #include "../../industry.h" +#include "../../safeguards.h" + ScriptIndustryTypeList::ScriptIndustryTypeList() { for (int i = 0; i < NUM_INDUSTRYTYPES; i++) { diff --git a/src/script/api/script_infrastructure.cpp b/src/script/api/script_infrastructure.cpp index 1ce051bba..d7da2747e 100644 --- a/src/script/api/script_infrastructure.cpp +++ b/src/script/api/script_infrastructure.cpp @@ -17,6 +17,8 @@ #include "../../water.h" #include "../../station_func.h" +#include "../../safeguards.h" + /* static */ uint32 ScriptInfrastructure::GetRailPieceCount(ScriptCompany::CompanyID company, ScriptRail::RailType railtype) { diff --git a/src/script/api/script_list.cpp b/src/script/api/script_list.cpp index 68df5bf95..7add90c74 100644 --- a/src/script/api/script_list.cpp +++ b/src/script/api/script_list.cpp @@ -14,6 +14,8 @@ #include "../../debug.h" #include "../../script/squirrel.hpp" +#include "../../safeguards.h" + /** * Base class for any ScriptList sorter. */ diff --git a/src/script/api/script_log.cpp b/src/script/api/script_log.cpp index fc6a0b193..6e725617c 100644 --- a/src/script/api/script_log.cpp +++ b/src/script/api/script_log.cpp @@ -15,6 +15,8 @@ #include "../../debug.h" #include "../../window_func.h" +#include "../../safeguards.h" + /* static */ void ScriptLog::Info(const char *message) { ScriptLog::Log(LOG_INFO, message); diff --git a/src/script/api/script_map.cpp b/src/script/api/script_map.cpp index 3f224b3d1..6334089fd 100644 --- a/src/script/api/script_map.cpp +++ b/src/script/api/script_map.cpp @@ -13,6 +13,8 @@ #include "script_map.hpp" #include "../../tile_map.h" +#include "../../safeguards.h" + /* static */ bool ScriptMap::IsValidTile(TileIndex t) { return ::IsValidTile(t); diff --git a/src/script/api/script_marine.cpp b/src/script/api/script_marine.cpp index abc8666f1..434ec11ac 100644 --- a/src/script/api/script_marine.cpp +++ b/src/script/api/script_marine.cpp @@ -15,6 +15,8 @@ #include "../../station_base.h" #include "../../tile_cmd.h" +#include "../../safeguards.h" + /* static */ bool ScriptMarine::IsWaterDepotTile(TileIndex tile) { diff --git a/src/script/api/script_news.cpp b/src/script/api/script_news.cpp index e80b88491..8d808ff3c 100644 --- a/src/script/api/script_news.cpp +++ b/src/script/api/script_news.cpp @@ -15,6 +15,8 @@ #include "../../command_type.h" #include "../../string_func.h" +#include "../../safeguards.h" + /* static */ bool ScriptNews::Create(NewsType type, Text *text, ScriptCompany::CompanyID company) { CCountedPtr<Text> counter(text); diff --git a/src/script/api/script_object.cpp b/src/script/api/script_object.cpp index 679efd1a7..47de2b1a7 100644 --- a/src/script/api/script_object.cpp +++ b/src/script/api/script_object.cpp @@ -24,6 +24,8 @@ #include "../script_fatalerror.hpp" #include "script_error.hpp" +#include "../../safeguards.h" + /** * Get the storage associated with the current ScriptInstance. * @return The storage. diff --git a/src/script/api/script_order.cpp b/src/script/api/script_order.cpp index 3098b452f..676262dc7 100644 --- a/src/script/api/script_order.cpp +++ b/src/script/api/script_order.cpp @@ -21,6 +21,8 @@ #include "../../station_base.h" #include "../../waypoint_base.h" +#include "../../safeguards.h" + /** * Gets the order type given a tile * @param t the tile to get the order from diff --git a/src/script/api/script_rail.cpp b/src/script/api/script_rail.cpp index 26317a72c..af68a3edc 100644 --- a/src/script/api/script_rail.cpp +++ b/src/script/api/script_rail.cpp @@ -21,6 +21,8 @@ #include "../../newgrf_station.h" #include "../../strings_func.h" +#include "../../safeguards.h" + /* static */ char *ScriptRail::GetName(RailType rail_type) { if (!IsRailTypeAvailable(rail_type)) return NULL; diff --git a/src/script/api/script_railtypelist.cpp b/src/script/api/script_railtypelist.cpp index 9373ce85c..016145b76 100644 --- a/src/script/api/script_railtypelist.cpp +++ b/src/script/api/script_railtypelist.cpp @@ -13,6 +13,8 @@ #include "script_railtypelist.hpp" #include "../../rail.h" +#include "../../safeguards.h" + ScriptRailTypeList::ScriptRailTypeList() { for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) { diff --git a/src/script/api/script_road.cpp b/src/script/api/script_road.cpp index 445446695..3a9a8ca3f 100644 --- a/src/script/api/script_road.cpp +++ b/src/script/api/script_road.cpp @@ -16,6 +16,8 @@ #include "../../station_base.h" #include "../../script/squirrel_helper_type.hpp" +#include "../../safeguards.h" + /* static */ ScriptRoad::RoadVehicleType ScriptRoad::GetRoadVehicleTypeForCargo(CargoID cargo_type) { return ScriptCargo::HasCargoClass(cargo_type, ScriptCargo::CC_PASSENGERS) ? ROADVEHTYPE_BUS : ROADVEHTYPE_TRUCK; diff --git a/src/script/api/script_sign.cpp b/src/script/api/script_sign.cpp index 3373800b5..236e1df7e 100644 --- a/src/script/api/script_sign.cpp +++ b/src/script/api/script_sign.cpp @@ -18,6 +18,8 @@ #include "../../strings_func.h" #include "../../tile_map.h" +#include "../../safeguards.h" + /* static */ bool ScriptSign::IsValidSign(SignID sign_id) { const Sign *si = ::Sign::GetIfValid(sign_id); diff --git a/src/script/api/script_signlist.cpp b/src/script/api/script_signlist.cpp index 5f6c6075b..61ab9665a 100644 --- a/src/script/api/script_signlist.cpp +++ b/src/script/api/script_signlist.cpp @@ -14,6 +14,8 @@ #include "script_sign.hpp" #include "../../signs_base.h" +#include "../../safeguards.h" + ScriptSignList::ScriptSignList() { Sign *s; diff --git a/src/script/api/script_station.cpp b/src/script/api/script_station.cpp index 2774ac28e..db0865261 100644 --- a/src/script/api/script_station.cpp +++ b/src/script/api/script_station.cpp @@ -18,6 +18,8 @@ #include "../../roadstop_base.h" #include "../../town.h" +#include "../../safeguards.h" + /* static */ bool ScriptStation::IsValidStation(StationID station_id) { const Station *st = ::Station::GetIfValid(station_id); diff --git a/src/script/api/script_stationlist.cpp b/src/script/api/script_stationlist.cpp index a7269bd24..9d88fd8fc 100644 --- a/src/script/api/script_stationlist.cpp +++ b/src/script/api/script_stationlist.cpp @@ -15,6 +15,8 @@ #include "../../station_base.h" #include "../../vehicle_base.h" +#include "../../safeguards.h" + ScriptStationList::ScriptStationList(ScriptStation::StationType station_type) { Station *st; diff --git a/src/script/api/script_story_page.cpp b/src/script/api/script_story_page.cpp index 17b7b8273..11820ec3f 100644 --- a/src/script/api/script_story_page.cpp +++ b/src/script/api/script_story_page.cpp @@ -22,6 +22,8 @@ #include "../../string_func.h" #include "../../tile_map.h" +#include "../../safeguards.h" + /* static */ bool ScriptStoryPage::IsValidStoryPage(StoryPageID story_page_id) { return ::StoryPage::IsValidID(story_page_id); diff --git a/src/script/api/script_storypageelementlist.cpp b/src/script/api/script_storypageelementlist.cpp index 5b6b2cd53..3f1fa4ebb 100644 --- a/src/script/api/script_storypageelementlist.cpp +++ b/src/script/api/script_storypageelementlist.cpp @@ -13,6 +13,8 @@ #include "script_storypageelementlist.hpp" #include "../../story_base.h" +#include "../../safeguards.h" + ScriptStoryPageElementList::ScriptStoryPageElementList(ScriptStoryPage::StoryPageID story_page_id) { if (!ScriptStoryPage::IsValidStoryPage(story_page_id)) return; diff --git a/src/script/api/script_storypagelist.cpp b/src/script/api/script_storypagelist.cpp index 795ff0201..fc32e80a3 100644 --- a/src/script/api/script_storypagelist.cpp +++ b/src/script/api/script_storypagelist.cpp @@ -14,6 +14,8 @@ #include "script_story_page.hpp" #include "../../story_base.h" +#include "../../safeguards.h" + ScriptStoryPageList::ScriptStoryPageList(ScriptCompany::CompanyID company) { uint8 c = company; diff --git a/src/script/api/script_subsidy.cpp b/src/script/api/script_subsidy.cpp index 146ba690d..640f7ab0a 100644 --- a/src/script/api/script_subsidy.cpp +++ b/src/script/api/script_subsidy.cpp @@ -18,6 +18,8 @@ #include "../../subsidy_base.h" #include "../../station_base.h" +#include "../../safeguards.h" + /* static */ bool ScriptSubsidy::IsValidSubsidy(SubsidyID subsidy_id) { return ::Subsidy::IsValidID(subsidy_id); diff --git a/src/script/api/script_subsidylist.cpp b/src/script/api/script_subsidylist.cpp index 68644846f..fd7d94779 100644 --- a/src/script/api/script_subsidylist.cpp +++ b/src/script/api/script_subsidylist.cpp @@ -13,6 +13,8 @@ #include "script_subsidylist.hpp" #include "../../subsidy_base.h" +#include "../../safeguards.h" + ScriptSubsidyList::ScriptSubsidyList() { const Subsidy *s; diff --git a/src/script/api/script_testmode.cpp b/src/script/api/script_testmode.cpp index 46cc15e05..37f296de0 100644 --- a/src/script/api/script_testmode.cpp +++ b/src/script/api/script_testmode.cpp @@ -14,6 +14,8 @@ #include "../script_instance.hpp" #include "../script_fatalerror.hpp" +#include "../../safeguards.h" + bool ScriptTestMode::ModeProc() { /* In test mode we only return 'false', telling the DoCommand it diff --git a/src/script/api/script_text.cpp b/src/script/api/script_text.cpp index f87b2e8b2..9fb297990 100644 --- a/src/script/api/script_text.cpp +++ b/src/script/api/script_text.cpp @@ -17,6 +17,8 @@ #include "table/strings.h" +#include "../../safeguards.h" + ScriptText::ScriptText(HSQUIRRELVM vm) : ZeroedMemoryAllocator() { diff --git a/src/script/api/script_tile.cpp b/src/script/api/script_tile.cpp index c84e8411a..db9220acd 100644 --- a/src/script/api/script_tile.cpp +++ b/src/script/api/script_tile.cpp @@ -20,6 +20,8 @@ #include "../../town.h" #include "../../landscape.h" +#include "../../safeguards.h" + /* static */ bool ScriptTile::IsBuildable(TileIndex tile) { if (!::IsValidTile(tile)) return false; diff --git a/src/script/api/script_tilelist.cpp b/src/script/api/script_tilelist.cpp index d4fe9f977..933a92c4c 100644 --- a/src/script/api/script_tilelist.cpp +++ b/src/script/api/script_tilelist.cpp @@ -15,6 +15,8 @@ #include "../../industry.h" #include "../../station_base.h" +#include "../../safeguards.h" + void ScriptTileList::AddRectangle(TileIndex t1, TileIndex t2) { if (!::IsValidTile(t1)) return; diff --git a/src/script/api/script_town.cpp b/src/script/api/script_town.cpp index 725c7d0a6..d81704ae3 100644 --- a/src/script/api/script_town.cpp +++ b/src/script/api/script_town.cpp @@ -21,6 +21,8 @@ #include "../../landscape.h" #include "table/strings.h" +#include "../../safeguards.h" + /* static */ int32 ScriptTown::GetTownCount() { return (int32)::Town::GetNumItems(); diff --git a/src/script/api/script_townlist.cpp b/src/script/api/script_townlist.cpp index 33a3fc070..a2e12febe 100644 --- a/src/script/api/script_townlist.cpp +++ b/src/script/api/script_townlist.cpp @@ -13,6 +13,8 @@ #include "script_townlist.hpp" #include "../../town.h" +#include "../../safeguards.h" + ScriptTownList::ScriptTownList() { Town *t; diff --git a/src/script/api/script_tunnel.cpp b/src/script/api/script_tunnel.cpp index 97085688f..7b891f28d 100644 --- a/src/script/api/script_tunnel.cpp +++ b/src/script/api/script_tunnel.cpp @@ -15,6 +15,8 @@ #include "../script_instance.hpp" #include "../../tunnel_map.h" +#include "../../safeguards.h" + /* static */ bool ScriptTunnel::IsTunnelTile(TileIndex tile) { if (!::IsValidTile(tile)) return false; diff --git a/src/script/api/script_vehicle.cpp b/src/script/api/script_vehicle.cpp index 23003ca26..ca841f755 100644 --- a/src/script/api/script_vehicle.cpp +++ b/src/script/api/script_vehicle.cpp @@ -24,6 +24,8 @@ #include "../../aircraft.h" #include "table/strings.h" +#include "../../safeguards.h" + /* static */ bool ScriptVehicle::IsValidVehicle(VehicleID vehicle_id) { const Vehicle *v = ::Vehicle::GetIfValid(vehicle_id); diff --git a/src/script/api/script_vehiclelist.cpp b/src/script/api/script_vehiclelist.cpp index 3017266fa..625f0f8c4 100644 --- a/src/script/api/script_vehiclelist.cpp +++ b/src/script/api/script_vehiclelist.cpp @@ -17,6 +17,8 @@ #include "../../depot_map.h" #include "../../vehicle_base.h" +#include "../../safeguards.h" + ScriptVehicleList::ScriptVehicleList() { const Vehicle *v; diff --git a/src/script/api/script_viewport.cpp b/src/script/api/script_viewport.cpp index 139edb029..737e7e68d 100644 --- a/src/script/api/script_viewport.cpp +++ b/src/script/api/script_viewport.cpp @@ -15,6 +15,8 @@ #include "script_map.hpp" #include "../../viewport_func.h" +#include "../../safeguards.h" + /* static */ void ScriptViewport::ScrollTo(TileIndex tile) { if (ScriptGame::IsMultiplayer()) return; diff --git a/src/script/api/script_waypoint.cpp b/src/script/api/script_waypoint.cpp index a10b3376b..91733a38e 100644 --- a/src/script/api/script_waypoint.cpp +++ b/src/script/api/script_waypoint.cpp @@ -15,6 +15,8 @@ #include "script_marine.hpp" #include "../../waypoint_base.h" +#include "../../safeguards.h" + /* static */ bool ScriptWaypoint::IsValidWaypoint(StationID waypoint_id) { const Waypoint *wp = ::Waypoint::GetIfValid(waypoint_id); diff --git a/src/script/api/script_waypointlist.cpp b/src/script/api/script_waypointlist.cpp index b32b3e8b3..dd641a684 100644 --- a/src/script/api/script_waypointlist.cpp +++ b/src/script/api/script_waypointlist.cpp @@ -15,6 +15,8 @@ #include "../../vehicle_base.h" #include "../../waypoint_base.h" +#include "../../safeguards.h" + ScriptWaypointList::ScriptWaypointList(ScriptWaypoint::WaypointType waypoint_type) { const Waypoint *wp; diff --git a/src/script/api/script_window.cpp b/src/script/api/script_window.cpp index 086e59f63..1252f0fc7 100644 --- a/src/script/api/script_window.cpp +++ b/src/script/api/script_window.cpp @@ -15,6 +15,8 @@ #include "../../window_func.h" #include "../../window_gui.h" +#include "../../safeguards.h" + /* static */ void ScriptWindow::Close(WindowClass window, uint32 number) { if (ScriptGame::IsMultiplayer()) return; diff --git a/src/script/script_config.cpp b/src/script/script_config.cpp index a46f5f392..7842a3a9d 100644 --- a/src/script/script_config.cpp +++ b/src/script/script_config.cpp @@ -15,6 +15,8 @@ #include "script_info.hpp" #include "../textfile_gui.h" +#include "../safeguards.h" + void ScriptConfig::Change(const char *name, int version, bool force_exact_match, bool is_random) { free(this->name); diff --git a/src/script/script_info.cpp b/src/script/script_info.cpp index 8b84966f2..f3ea1747b 100644 --- a/src/script/script_info.cpp +++ b/src/script/script_info.cpp @@ -17,6 +17,8 @@ #include "script_info.hpp" #include "script_scanner.hpp" +#include "../safeguards.h" + ScriptInfo::~ScriptInfo() { /* Free all allocated strings */ diff --git a/src/script/script_info_dummy.cpp b/src/script/script_info_dummy.cpp index b84630332..b70032f44 100644 --- a/src/script/script_info_dummy.cpp +++ b/src/script/script_info_dummy.cpp @@ -15,6 +15,8 @@ #include "../string_func.h" #include "../strings_func.h" +#include "../safeguards.h" + /* The reason this exists in C++, is that a user can trash his ai/ or game/ dir, * leaving no Scripts available. The complexity to solve this is insane, and * therefore the alternative is used, and make sure there is always a Script diff --git a/src/script/script_instance.cpp b/src/script/script_instance.cpp index 7e4766fdb..1aa5f1978 100644 --- a/src/script/script_instance.cpp +++ b/src/script/script_instance.cpp @@ -29,6 +29,8 @@ #include "../company_func.h" #include "../fileio_func.h" +#include "../safeguards.h" + ScriptStorage::~ScriptStorage() { /* Free our pointers */ diff --git a/src/script/script_scanner.cpp b/src/script/script_scanner.cpp index 2197a5505..b90f63cd8 100644 --- a/src/script/script_scanner.cpp +++ b/src/script/script_scanner.cpp @@ -18,6 +18,8 @@ #include "script_scanner.hpp" #include "script_info.hpp" +#include "../safeguards.h" + bool ScriptScanner::AddFile(const char *filename, size_t basepath_length, const char *tar_filename) { free(this->main_script); diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp index ce73f9a64..2c50b964a 100644 --- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -19,6 +19,8 @@ #include <../squirrel/sqpcheader.h> #include <../squirrel/sqvm.h> +#include "../safeguards.h" + void Squirrel::CompileError(HSQUIRRELVM vm, const SQChar *desc, const SQChar *source, SQInteger line, SQInteger column) { SQChar buf[1024]; diff --git a/src/script/squirrel_std.cpp b/src/script/squirrel_std.cpp index 9de119e1e..a6f19a5dd 100644 --- a/src/script/squirrel_std.cpp +++ b/src/script/squirrel_std.cpp @@ -17,6 +17,8 @@ #include "../core/alloc_func.hpp" #include "../core/math_func.hpp" +#include "../safeguards.h" + SQInteger SquirrelStd::min(HSQUIRRELVM vm) { diff --git a/src/sdl.cpp b/src/sdl.cpp index 91d52d917..79e9ed292 100644 --- a/src/sdl.cpp +++ b/src/sdl.cpp @@ -79,6 +79,8 @@ static const char *LoadSdlDLL() #endif /* DYNAMICALLY_LOADED_SDL */ +#include "safeguards.h" + /** * Open the SDL library. * @param x The subsystem to load. diff --git a/src/settings.cpp b/src/settings.cpp index 970c169b4..b5fcbc670 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -71,6 +71,8 @@ #include "table/strings.h" #include "table/settings.h" +#include "safeguards.h" + ClientSettings _settings_client; GameSettings _settings_game; ///< Game settings of a running game or the scenario editor. GameSettings _settings_newgame; ///< Game settings for new games (updated from the intro screen). diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 908ddadbf..ea8c93feb 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -38,6 +38,8 @@ #include "stringfilter_type.h" #include "querystring_gui.h" +#include "safeguards.h" + static const StringID _driveside_dropdown[] = { STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_LEFT, diff --git a/src/settingsgen/settingsgen.cpp b/src/settingsgen/settingsgen.cpp index d97582247..9f8cc1050 100644 --- a/src/settingsgen/settingsgen.cpp +++ b/src/settingsgen/settingsgen.cpp @@ -30,6 +30,8 @@ #define stderr stdout #endif /* __MORPHOS__ */ +#include "../safeguards.h" + /** * Report a fatal error. * @param s Format string. diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index f1d09d40c..210af2027 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -36,6 +36,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** * Determine the effective #WaterClass for a ship travelling on a tile. * @param tile Tile of interest diff --git a/src/ship_gui.cpp b/src/ship_gui.cpp index 10cf78922..cd04efbef 100644 --- a/src/ship_gui.cpp +++ b/src/ship_gui.cpp @@ -21,6 +21,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** * Draws an image of a ship * @param v Front vehicle diff --git a/src/signal.cpp b/src/signal.cpp index e8a6690fc..8e870b53d 100644 --- a/src/signal.cpp +++ b/src/signal.cpp @@ -18,6 +18,8 @@ #include "train.h" #include "company_base.h" +#include "safeguards.h" + /** these are the maximums used for updating signal blocks */ static const uint SIG_TBU_SIZE = 64; ///< number of signals entering to block diff --git a/src/signs.cpp b/src/signs.cpp index 53465fc8a..2a23a43c9 100644 --- a/src/signs.cpp +++ b/src/signs.cpp @@ -18,6 +18,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** Initialize the sign-pool */ SignPool _sign_pool("Sign"); INSTANTIATE_POOL_METHODS(Sign) diff --git a/src/signs_cmd.cpp b/src/signs_cmd.cpp index 3109d1ef0..9a21c4e35 100644 --- a/src/signs_cmd.cpp +++ b/src/signs_cmd.cpp @@ -21,6 +21,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** The last built sign. */ SignID _new_sign_id; diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index aeac02eb9..2358e9492 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -33,6 +33,8 @@ #include "table/strings.h" #include "table/sprites.h" +#include "safeguards.h" + struct SignList { /** * A GUIList contains signs and uses a StringFilter for filtering. diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index b4137038f..a8da3284e 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -28,6 +28,8 @@ #include "table/strings.h" +#include "safeguards.h" + static int _smallmap_industry_count; ///< Number of used industries static int _smallmap_company_count; ///< Number of entries in the owner legend. static int _smallmap_cargo_count; ///< Number of cargos in the link stats legend. diff --git a/src/sound.cpp b/src/sound.cpp index 9bad9d6bd..79dd988bf 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -21,6 +21,8 @@ #define SET_TYPE "sounds" #include "base_media_func.h" +#include "safeguards.h" + static SoundEntry _original_sounds[ORIGINAL_SAMPLE_COUNT]; static void OpenBankFile(const char *filename) diff --git a/src/sound/allegro_s.cpp b/src/sound/allegro_s.cpp index 76a1e1e91..88a723ff8 100644 --- a/src/sound/allegro_s.cpp +++ b/src/sound/allegro_s.cpp @@ -18,6 +18,8 @@ #include "allegro_s.h" #include <allegro.h> +#include "../safeguards.h" + static FSoundDriver_Allegro iFSoundDriver_Allegro; /** The stream we are writing too */ static AUDIOSTREAM *_stream = NULL; diff --git a/src/sound/cocoa_s.cpp b/src/sound/cocoa_s.cpp index 1dc2a25d4..8cf4a632b 100644 --- a/src/sound/cocoa_s.cpp +++ b/src/sound/cocoa_s.cpp @@ -30,6 +30,8 @@ #undef Rect #undef Point +#include "../safeguards.h" + static FSoundDriver_Cocoa iFSoundDriver_Cocoa; static AudioUnit _outputAudioUnit; diff --git a/src/sound/null_s.cpp b/src/sound/null_s.cpp index 953bf5764..3dc95c46f 100644 --- a/src/sound/null_s.cpp +++ b/src/sound/null_s.cpp @@ -12,5 +12,7 @@ #include "../stdafx.h" #include "null_s.h" +#include "../safeguards.h" + /** The factory for the null sound driver. */ static FSoundDriver_Null iFSoundDriver_Null; diff --git a/src/sound/sdl_s.cpp b/src/sound/sdl_s.cpp index 7e1c3e993..e3fb99eaa 100644 --- a/src/sound/sdl_s.cpp +++ b/src/sound/sdl_s.cpp @@ -18,6 +18,8 @@ #include "sdl_s.h" #include <SDL.h> +#include "../safeguards.h" + /** Factory for the SDL sound driver. */ static FSoundDriver_SDL iFSoundDriver_SDL; diff --git a/src/sound/win32_s.cpp b/src/sound/win32_s.cpp index d241f45c8..0cd632714 100644 --- a/src/sound/win32_s.cpp +++ b/src/sound/win32_s.cpp @@ -20,6 +20,8 @@ #include <windows.h> #include <mmsystem.h> +#include "../safeguards.h" + static FSoundDriver_Win32 iFSoundDriver_Win32; static HWAVEOUT _waveout; diff --git a/src/sprite.cpp b/src/sprite.cpp index 513ca014f..6db6966d8 100644 --- a/src/sprite.cpp +++ b/src/sprite.cpp @@ -16,6 +16,8 @@ #include "spritecache.h" #include "zoom_func.h" +#include "safeguards.h" + /** * Draws a tile sprite sequence. diff --git a/src/spritecache.cpp b/src/spritecache.cpp index 49f2d7ff4..c41b8f51c 100644 --- a/src/spritecache.cpp +++ b/src/spritecache.cpp @@ -24,6 +24,8 @@ #include "table/strings.h" #include "table/palette_convert.h" +#include "safeguards.h" + /* Default of 4MB spritecache */ uint _sprite_cache_size = 4; diff --git a/src/spriteloader/grf.cpp b/src/spriteloader/grf.cpp index 678ebb79a..a45bd0fa8 100644 --- a/src/spriteloader/grf.cpp +++ b/src/spriteloader/grf.cpp @@ -21,6 +21,8 @@ #include "../core/bitmath_func.hpp" #include "grf.hpp" +#include "../safeguards.h" + extern const byte _palmap_w2d[]; /** The different colour components a sprite can have. */ diff --git a/src/station.cpp b/src/station.cpp index 49554aaef..c035aafce 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -29,6 +29,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** The pool of stations. */ StationPool _station_pool("Station"); INSTANTIATE_POOL_METHODS(Station) diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index cf449df94..9c2ddc181 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -56,6 +56,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** * Check whether the given tile is a hangar. * @param t the tile to of whether it is a hangar. diff --git a/src/station_gui.cpp b/src/station_gui.cpp index e658c1f20..b773a1af4 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -39,6 +39,8 @@ #include <set> #include <vector> +#include "safeguards.h" + /** * Calculates and draws the accepted or supplied cargo around the selected tile(s) * @param left x position where the string is to be drawn diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index 62799e18b..151fa5c37 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -31,6 +31,8 @@ #include "table/strings.h" #include "table/sprites.h" +#include "safeguards.h" + static bool DrawScrollingStatusText(const NewsItem *ni, int scroll_pos, int left, int right, int top, int bottom) { CopyInDParam(0, ni->params, lengthof(ni->params)); diff --git a/src/story.cpp b/src/story.cpp index da44c2743..46a193631 100644 --- a/src/story.cpp +++ b/src/story.cpp @@ -24,6 +24,8 @@ #include "window_func.h" #include "gui.h" +#include "safeguards.h" + StoryPageElementID _new_story_page_element_id; StoryPageID _new_story_page_id; diff --git a/src/story_gui.cpp b/src/story_gui.cpp index 872ed0a9a..8199e7fcc 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -31,6 +31,8 @@ #include "table/strings.h" #include "table/sprites.h" +#include "safeguards.h" + typedef GUIList<const StoryPage*> GUIStoryPageList; typedef GUIList<const StoryPageElement*> GUIStoryPageElementList; diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp index 5d0453841..61c36cd61 100644 --- a/src/strgen/strgen.cpp +++ b/src/strgen/strgen.cpp @@ -39,6 +39,8 @@ #include "../table/strgen_tables.h" +#include "../safeguards.h" + #ifdef _MSC_VER # define LINE_NUM_FMT(s) "%s (%d): warning: %s (" s ")\n" diff --git a/src/strgen/strgen_base.cpp b/src/strgen/strgen_base.cpp index be825fac0..27c76631c 100644 --- a/src/strgen/strgen_base.cpp +++ b/src/strgen/strgen_base.cpp @@ -19,6 +19,8 @@ #include "../table/strgen_tables.h" +#include "../safeguards.h" + /* Compiles a list of strings into a compiled string list */ static bool _translated; ///< Whether the current language is not the master language diff --git a/src/string.cpp b/src/string.cpp index 983f79edf..5b60979db 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -32,6 +32,8 @@ #include "gfx_func.h" #endif /* WITH_ICU */ +#include "safeguards.h" + /** * Safer implementation of vsnprintf; same as vsnprintf except: * - last instead of size, i.e. replace sizeof with lastof. diff --git a/src/stringfilter.cpp b/src/stringfilter.cpp index 98392bed6..6045c19ef 100644 --- a/src/stringfilter.cpp +++ b/src/stringfilter.cpp @@ -15,6 +15,8 @@ #include "stringfilter_type.h" #include "gfx_func.h" +#include "safeguards.h" + static const WChar STATE_WHITESPACE = ' '; static const WChar STATE_WORD = 'w'; static const WChar STATE_QUOTE1 = '\''; diff --git a/src/strings.cpp b/src/strings.cpp index dcaa6ae29..64692ef00 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -41,6 +41,8 @@ #include "table/strings.h" #include "table/control_codes.h" +#include "safeguards.h" + char _config_language_file[MAX_PATH]; ///< The file (name) stored in the configuration. LanguageList _languages; ///< The actual list of language meta data. const LanguageMetadata *_current_language = NULL; ///< The currently loaded language. diff --git a/src/subsidy.cpp b/src/subsidy.cpp index 0cccd92d5..974aa50a8 100644 --- a/src/subsidy.cpp +++ b/src/subsidy.cpp @@ -27,6 +27,8 @@ #include "table/strings.h" +#include "safeguards.h" + SubsidyPool _subsidy_pool("Subsidy"); ///< Pool for the subsidies. INSTANTIATE_POOL_METHODS(Subsidy) diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index 298a8bb57..04e5ae262 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -25,6 +25,8 @@ #include "table/strings.h" +#include "safeguards.h" + struct SubsidyListWindow : Window { Scrollbar *vscroll; diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp index 7321a6d83..98ac1d365 100644 --- a/src/terraform_cmd.cpp +++ b/src/terraform_cmd.cpp @@ -21,6 +21,8 @@ #include "table/strings.h" +#include "safeguards.h" + /* * In one terraforming command all four corners of a initial tile can be raised/lowered (though this is not available to the player). * The maximal amount of height modifications is achieved when raising a complete flat land from sea level to MAX_TILE_HEIGHT or vice versa. diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 399b0a073..d2e7d39e1 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -37,6 +37,8 @@ #include "table/strings.h" +#include "safeguards.h" + void CcTerraform(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) { if (result.Succeeded()) { diff --git a/src/textbuf.cpp b/src/textbuf.cpp index 766396fc6..80e4f90d7 100644 --- a/src/textbuf.cpp +++ b/src/textbuf.cpp @@ -20,6 +20,8 @@ #include "window_func.h" #include "core/alloc_func.hpp" +#include "safeguards.h" + /** * Try to retrieve the current clipboard contents. * diff --git a/src/texteff.cpp b/src/texteff.cpp index fd2001716..03b564599 100644 --- a/src/texteff.cpp +++ b/src/texteff.cpp @@ -17,6 +17,8 @@ #include "viewport_func.h" #include "settings_type.h" +#include "safeguards.h" + /** Container for all information about a text effect */ struct TextEffect : public ViewportSign { uint64 params_1; ///< DParam parameter diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp index 95f2b0d77..ad6215af5 100644 --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -21,6 +21,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** Widgets for the textfile window. */ static const NWidgetPart _nested_textfile_widgets[] = { NWidget(NWID_HORIZONTAL), diff --git a/src/tgp.cpp b/src/tgp.cpp index 1fb3485ec..77cf282da 100644 --- a/src/tgp.cpp +++ b/src/tgp.cpp @@ -17,6 +17,8 @@ #include "core/random_func.hpp" #include "landscape_type.h" +#include "safeguards.h" + /* * * Quickie guide to Perlin Noise diff --git a/src/thread/thread_morphos.cpp b/src/thread/thread_morphos.cpp index abf2cf0cc..cc6b2f9d3 100644 --- a/src/thread/thread_morphos.cpp +++ b/src/thread/thread_morphos.cpp @@ -23,6 +23,8 @@ #include <proto/dos.h> #include <proto/exec.h> +#include "../safeguards.h" + /** * avoid name clashes with MorphOS API functions */ diff --git a/src/thread/thread_none.cpp b/src/thread/thread_none.cpp index 415a62d59..afa799b23 100644 --- a/src/thread/thread_none.cpp +++ b/src/thread/thread_none.cpp @@ -12,6 +12,8 @@ #include "../stdafx.h" #include "thread.h" +#include "../safeguards.h" + /* static */ bool ThreadObject::New(OTTDThreadFunc proc, void *param, ThreadObject **thread) { if (thread != NULL) *thread = NULL; diff --git a/src/thread/thread_os2.cpp b/src/thread/thread_os2.cpp index d93fc0c71..93f04cac1 100644 --- a/src/thread/thread_os2.cpp +++ b/src/thread/thread_os2.cpp @@ -16,6 +16,8 @@ #include <os2.h> #include <process.h> +#include "../safeguards.h" + /** * OS/2 version for ThreadObject. */ diff --git a/src/thread/thread_pthread.cpp b/src/thread/thread_pthread.cpp index 9d54a4d20..ce407fd94 100644 --- a/src/thread/thread_pthread.cpp +++ b/src/thread/thread_pthread.cpp @@ -14,6 +14,8 @@ #include <pthread.h> #include <errno.h> +#include "../safeguards.h" + /** * POSIX pthread version for ThreadObject. */ diff --git a/src/thread/thread_win32.cpp b/src/thread/thread_win32.cpp index 484cc5513..c37baf7c3 100644 --- a/src/thread/thread_win32.cpp +++ b/src/thread/thread_win32.cpp @@ -17,6 +17,8 @@ #include <windows.h> #include <process.h> +#include "../safeguards.h" + /** * Win32 thread version for ThreadObject. */ diff --git a/src/tile_map.cpp b/src/tile_map.cpp index 1e30ba0d9..9855484df 100644 --- a/src/tile_map.cpp +++ b/src/tile_map.cpp @@ -12,6 +12,8 @@ #include "stdafx.h" #include "tile_map.h" +#include "safeguards.h" + /** * Return the slope of a given tile * @param tile Tile to compute slope of diff --git a/src/tilearea.cpp b/src/tilearea.cpp index 046e22221..ec3b9aafb 100644 --- a/src/tilearea.cpp +++ b/src/tilearea.cpp @@ -13,6 +13,8 @@ #include "tilearea_type.h" +#include "safeguards.h" + /** * Construct this tile area based on two points. * @param start the start of the area diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp index 5b7a69d8e..2e2150642 100644 --- a/src/timetable_cmd.cpp +++ b/src/timetable_cmd.cpp @@ -20,6 +20,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** * Change/update a particular timetable entry. * @param v The vehicle to change the timetable of. diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 0a846915f..b05c07211 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -30,6 +30,8 @@ #include "table/sprites.h" #include "table/strings.h" +#include "safeguards.h" + /** Container for the arrival/departure dates of a vehicle */ struct TimetableArrivalDeparture { Ticks arrival; ///< The arrival time diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 57bc4d412..c3f2a6e7b 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -53,6 +53,8 @@ #include "network/network_gui.h" #include "network/network_func.h" +#include "safeguards.h" + RailType _last_built_railtype; RoadType _last_built_roadtype; diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index d3c480af1..78d453ed3 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -50,6 +50,8 @@ #include "table/strings.h" #include "table/town_land.h" +#include "safeguards.h" + TownID _new_town_id; uint32 _town_cargoes_accepted; ///< Bitmap of all cargoes accepted by houses. diff --git a/src/town_gui.cpp b/src/town_gui.cpp index b1fdace35..a2ac0bafe 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -37,6 +37,8 @@ #include "table/strings.h" +#include "safeguards.h" + typedef GUIList<const Town*> GUITownList; static const NWidgetPart _nested_town_authority_widgets[] = { diff --git a/src/townname.cpp b/src/townname.cpp index ad9b26fee..99dd99821 100644 --- a/src/townname.cpp +++ b/src/townname.cpp @@ -20,6 +20,8 @@ #include "table/townname.h" +#include "safeguards.h" + /** * Initializes this struct from town data diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 0198ac58c..57d6ab30b 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -39,6 +39,8 @@ #include "table/strings.h" #include "table/train_cmd.h" +#include "safeguards.h" + static Track ChooseTrainTrack(Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool force_res, bool *got_reservation, bool mark_stuck); static bool TrainCheckIfLineEnds(Train *v, bool reverse = true); bool TrainController(Train *v, Vehicle *nomove, bool reverse = true); // Also used in vehicle_sl.cpp. diff --git a/src/train_gui.cpp b/src/train_gui.cpp index 24cecd5f1..a89ade3cf 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -18,6 +18,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** * Callback for building wagons. * @param result The result of the command. diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp index 9e00552b6..4bad2b056 100644 --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -20,6 +20,8 @@ #include "table/sprites.h" #include "table/strings.h" +#include "safeguards.h" + TransparencyOptionBits _transparency_opt; ///< The bits that should be transparent. TransparencyOptionBits _transparency_lock; ///< Prevent these bits from flipping with X. TransparencyOptionBits _invisibility_opt; ///< The bits that should be invisible. diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index c30609e78..4fcda82d8 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -29,6 +29,8 @@ #include "table/tree_land.h" #include "table/clear_land.h" +#include "safeguards.h" + /** * List of tree placer algorithm. * diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index 784f4546d..f21eeaef2 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -25,6 +25,8 @@ #include "table/strings.h" #include "table/tree_land.h" +#include "safeguards.h" + void PlaceTreesRandomly(); /** Tree Sprites with their palettes */ diff --git a/src/tunnel_map.cpp b/src/tunnel_map.cpp index 7639fa949..4e6d5a7e1 100644 --- a/src/tunnel_map.cpp +++ b/src/tunnel_map.cpp @@ -12,6 +12,8 @@ #include "stdafx.h" #include "tunnelbridge_map.h" +#include "safeguards.h" + /** * Gets the other end of the tunnel. Where a vehicle would reappear when it diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 2739fd7c4..9bb96538d 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -44,6 +44,8 @@ #include "table/strings.h" #include "table/bridge_land.h" +#include "safeguards.h" + BridgeSpec _bridge[MAX_BRIDGES]; ///< The specification of all bridges. TileIndex _build_tunnel_endtile; ///< The end of a tunnel; as hidden return from the tunnel build command for GUI purposes. diff --git a/src/vehicle.cpp b/src/vehicle.cpp index ceb345f46..415b8e56a 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -55,6 +55,8 @@ #include "table/strings.h" +#include "safeguards.h" + #define GEN_HASH(x, y) ((GB((y), 6 + ZOOM_LVL_SHIFT, 6) << 6) + GB((x), 7 + ZOOM_LVL_SHIFT, 6)) VehicleID _new_vehicle_id; diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index 78c62d20a..c42eb338f 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -34,6 +34,8 @@ #include "table/strings.h" +#include "safeguards.h" + /* Tables used in vehicle.h to find the right command for a certain vehicle type */ const uint32 _veh_build_proc_table[] = { CMD_BUILD_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN), diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index b1cd7ce2b..16813cea5 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -39,6 +39,8 @@ #include "tilehighlight_func.h" #include "zoom_func.h" +#include "safeguards.h" + Sorting _sorting; diff --git a/src/vehiclelist.cpp b/src/vehiclelist.cpp index fca9c5e46..93dec488d 100644 --- a/src/vehiclelist.cpp +++ b/src/vehiclelist.cpp @@ -14,6 +14,8 @@ #include "vehiclelist.h" #include "group.h" +#include "safeguards.h" + /** * Pack a VehicleListIdentifier in a single uint32. * @return The packed identifier. diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp index f844c6d0d..e7c7b828b 100644 --- a/src/video/allegro_v.cpp +++ b/src/video/allegro_v.cpp @@ -27,6 +27,8 @@ #include "allegro_v.h" #include <allegro.h> +#include "../safeguards.h" + #ifdef _DEBUG /* Allegro replaces SEGV/ABRT signals meaning that the debugger will never * be triggered, so rereplace the signals and make the debugger useful. */ diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp index 9be1b2d3c..1d8992bb7 100644 --- a/src/video/dedicated_v.cpp +++ b/src/video/dedicated_v.cpp @@ -131,6 +131,8 @@ static void CloseWindowsConsoleThread() #endif +#include "../safeguards.h" + static void *_dedicated_video_mem; diff --git a/src/video/null_v.cpp b/src/video/null_v.cpp index f2f7fc5ed..5037814e5 100644 --- a/src/video/null_v.cpp +++ b/src/video/null_v.cpp @@ -14,6 +14,8 @@ #include "../blitter/factory.hpp" #include "null_v.h" +#include "../safeguards.h" + /** Factory for the null video driver. */ static FVideoDriver_Null iFVideoDriver_Null; diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index cad21955d..ff0fffd9c 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -26,6 +26,8 @@ #include "sdl_v.h" #include <SDL.h> +#include "../safeguards.h" + static FVideoDriver_SDL iFVideoDriver_SDL; static SDL_Surface *_sdl_screen; diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index c0da6db54..989a2f1a2 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -27,6 +27,8 @@ #include <windows.h> #include <imm.h> +#include "../safeguards.h" + /* Missing define in MinGW headers. */ #ifndef MAPVK_VK_TO_CHAR #define MAPVK_VK_TO_CHAR (2) diff --git a/src/viewport.cpp b/src/viewport.cpp index c3ccea873..d1eb8f449 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -51,6 +51,8 @@ #include "table/strings.h" #include "table/palettes.h" +#include "safeguards.h" + Point _tile_fract_coords; struct StringSpriteToDraw { diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp index ab8125fa1..90b0e1468 100644 --- a/src/viewport_gui.cpp +++ b/src/viewport_gui.cpp @@ -22,6 +22,8 @@ #include "table/strings.h" #include "table/sprites.h" +#include "safeguards.h" + /* Extra ViewPort Window Stuff */ static const NWidgetPart _nested_extra_view_port_widgets[] = { NWidget(NWID_HORIZONTAL), diff --git a/src/viewport_sprite_sorter_sse4.cpp b/src/viewport_sprite_sorter_sse4.cpp index 7cd48e7d9..05a7f8aa1 100644 --- a/src/viewport_sprite_sorter_sse4.cpp +++ b/src/viewport_sprite_sorter_sse4.cpp @@ -16,6 +16,8 @@ #include "smmintrin.h" #include "viewport_sprite_sorter.h" +#include "safeguards.h" + #ifdef _SQ64 assert_compile((sizeof(ParentSpriteToDraw) % 16) == 0); #define LOAD_128 _mm_load_si128 diff --git a/src/void_cmd.cpp b/src/void_cmd.cpp index cd8d9caa6..ea918b96a 100644 --- a/src/void_cmd.cpp +++ b/src/void_cmd.cpp @@ -17,6 +17,8 @@ #include "table/strings.h" #include "table/sprites.h" +#include "safeguards.h" + static void DrawTile_Void(TileInfo *ti) { DrawGroundSprite(SPR_SHADOW_CELL, PAL_NONE); diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 15c57afd5..7b5272a41 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -42,6 +42,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** * Describes from which directions a specific slope can be flooded (if the tile is floodable at all). */ diff --git a/src/waypoint.cpp b/src/waypoint.cpp index 9500aba82..857f8ba87 100644 --- a/src/waypoint.cpp +++ b/src/waypoint.cpp @@ -16,6 +16,8 @@ #include "newgrf_station.h" #include "waypoint_base.h" +#include "safeguards.h" + /** * Draw a waypoint * @param x coordinate diff --git a/src/waypoint_cmd.cpp b/src/waypoint_cmd.cpp index 1a3d6e6e9..b2656987d 100644 --- a/src/waypoint_cmd.cpp +++ b/src/waypoint_cmd.cpp @@ -32,6 +32,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** * Update the virtual coords needed to draw the waypoint sign. */ diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp index d02a96057..3400a7df4 100644 --- a/src/waypoint_gui.cpp +++ b/src/waypoint_gui.cpp @@ -27,6 +27,8 @@ #include "table/strings.h" +#include "safeguards.h" + /** GUI for accessing waypoints and buoys. */ struct WaypointWindow : Window { private: diff --git a/src/widget.cpp b/src/widget.cpp index 31c5ea853..77d163c81 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -24,6 +24,8 @@ #include "table/strings.h" #include "table/palettes.h" +#include "safeguards.h" + static const char *UPARROW = "\xEE\x8A\xA0"; ///< String containing an upwards pointing arrow. static const char *DOWNARROW = "\xEE\x8A\xAA"; ///< String containing a downwards pointing arrow. diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index 6b0f60e37..d919eff7c 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -18,6 +18,8 @@ #include "dropdown_widget.h" +#include "../safeguards.h" + void DropDownListItem::Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const { diff --git a/src/window.cpp b/src/window.cpp index 8f97693f6..3ea69ca3c 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -37,6 +37,8 @@ #include "game/game.hpp" #include "video/video_driver.hpp" +#include "safeguards.h" + /** Values for _settings_client.gui.auto_scrolling */ enum ViewportAutoscrolling { VA_DISABLED, //!< Do not autoscroll when mouse is at edge of viewport. |