diff --git a/src/3rdparty/md5/md5.cpp b/src/3rdparty/md5/md5.cpp index d2d6fbab77..2111a8eb81 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 3b3c09a429..65365f4d4e 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 3f4381b0c5..d4ff233116 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 8bcc41455d..885c9bee88 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 +#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 375248d7d2..9c9f3b47eb 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 f109a09260..1c304c8569 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 64b877c6c8..7c2bff7785 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 ee89fbf0df..2f49158eb9 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 6db75d3af8..2c58b68c89 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 c3c67effc5..a50c049c23 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 4ad4789ff6..761466f1a5 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 8995275e90..78dda8b3b6 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 501af719de..859d9a750a 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 0788fccb36..3b7f739726 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 2e13caffba..e69ac66eb2 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 dc1f5ed738..c53df993f3 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 005c886723..805e1d58f1 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 80ec54da43..71c3e0a34e 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 d456da22da..f25683a10b 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 3ea03327f6..26dd2f037e 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 5d2332883c..9b7d7115c9 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 30443c50bb..0ad7418db0 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 5b7316ccea..ae2b3ccc52 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 dab0d8f3e9..723264f03f 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 33d49648e7..ab6c9eba5d 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 f2ba704054..eab6eaa0db 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 31661c360d..bcd8dc2824 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 d98cff1c92..d24d8caac5 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 d30f4054b7..e83df2e714 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 1c2b379d1b..e968abe13f 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 2cb3dbf787..1033d89f11 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 c2b76f0b1c..98c3175d63 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 61c477aeac..95c9d7137c 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 6ebf80424e..d1e0d6024a 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 0719f29ec6..57e306e882 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 48c49e99f1..96ddc3708e 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 5120967854..7d31e6e237 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 67d00554b6..34f8c4243b 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 6d601e2558..863c585616 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 f8dae235fa..8b300c9668 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 9eb405d2ab..b2006053a7 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 0035de54cb..ad73ed143d 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 34d5ab61ec..3700eae1bc 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 0357e337ea..35b87459c6 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 bbbf0950b5..0f34d3540b 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 1b5ff24224..29bab2f740 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -20,6 +20,8 @@ #include +#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 1a4ea9239c..4d4223f142 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 c3dcdaa122..d7ed1f6905 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 d2b3a4b6c5..b78023f4d6 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 af0200bcb8..7763227315 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 1a15887380..86f317a372 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 8c136c0bb6..d927702083 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 fa410850f1..f8ff93cecc 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 8cf21b54f5..5c1d079403 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 1a878c1826..c48b8cbd4d 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 986736bb3e..9159836c80 100644 --- a/src/crashlog.cpp +++ b/src/crashlog.cpp @@ -36,6 +36,8 @@ #include +#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 52060e21c8..56111022cf 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 800e4faeaf..9c25af40ee 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 a0c4bc38c0..520b3e7f92 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 dceae7ec49..b5d6b97b57 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 6342bc2476..ce383ee4a5 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 +#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 9663f042e3..821399fd2b 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 5fb2b2de2f..77f76bd204 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 c677d039d9..6b44428afb 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 a027dd0484..1be0f217a2 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 059aef6b5f..94b7355731 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 dd03e5e7b6..818251e31a 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 5db7061bf9..fd089f82b5 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 a196c52d64..48f3e6cdf0 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 a431837920..8116bff2c6 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 700475c1b4..03072869c3 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 6ee47692d4..3ac261d15a 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 5e8f52432d..34a49c74d1 100644 --- a/src/error_gui.cpp +++ b/src/error_gui.cpp @@ -29,6 +29,8 @@ #include "table/strings.h" #include +#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 f88d8deeaf..2cbf13ae81 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 ff7153af3f..ced425967a 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 _fios_items; static char *_fios_path; diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index 9fce85ae96..579eedf894 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 4d369ad51f..0f949c544f 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 82c4f354f6..bf97daabf2 100644 --- a/src/fontdetection.cpp +++ b/src/fontdetection.cpp @@ -35,6 +35,8 @@ extern FT_Library _library; #include /* 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 +#include "safeguards.h" + /* ======================================================================================== * FontConfig (unix) support * ======================================================================================== */ diff --git a/src/game/game_config.cpp b/src/game/game_config.cpp index a85c2f467e..50cd5da4e0 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 9fd47a4c8b..2f95e26224 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 ab49fea12a..e6ec3657bf 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 f4afc69b9a..9d030f296b 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 f8c2b4f22e..4dceaa7336 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 cd9721b8ab..502869249d 100644 --- a/src/game/game_text.cpp +++ b/src/game/game_text.cpp @@ -24,6 +24,8 @@ #include +#include "../safeguards.h" + void CDECL strgen_warning(const char *s, ...) { char buf[1024]; diff --git a/src/gamelog.cpp b/src/gamelog.cpp index b4b9fd7a62..e0853584dd 100644 --- a/src/gamelog.cpp +++ b/src/gamelog.cpp @@ -21,6 +21,8 @@ #include +#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 822fe141fa..d90c9ad4de 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 f1b561ef18..9a2fe62b57 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 adc644d205..0218634518 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 0c4c1f23fd..2dba6a2046 100644 --- a/src/gfx_layout.cpp +++ b/src/gfx_layout.cpp @@ -21,6 +21,8 @@ #include #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 109db2e08a..30ff37998b 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 e2436745ce..d472fc2c56 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 b2e591ffdd..cb38d7f6e6 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 10779502da..c12c6ace4d 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -30,6 +30,8 @@ #include "table/sprites.h" #include +#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 5712b28f96..f3134608ac 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 be1bfce5d9..1c5d05ae1e 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 0b6c860dd6..c332c934d6 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 GUIGroupList; diff --git a/src/heightmap.cpp b/src/heightmap.cpp index 50cfd6e22a..93cfa0a62c 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 b2dcf8e5f6..86e4f5ae88 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 d79afe4ebd..35ada7266c 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 c5a8109ade..0579792e76 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 9930057a39..9deb043632 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 cc305509f2..bcda8bd5c9 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 11f79ed16e..2e4e9097fc 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 75a8254531..a64ca454ca 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 5d13058944..9de9274083 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 a19c98db95..c4116eaafd 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 80a0f56772..84c73f7333 100644 --- a/src/linkgraph/demands.cpp +++ b/src/linkgraph/demands.cpp @@ -4,6 +4,8 @@ #include "demands.h" #include +#include "../safeguards.h" + typedef std::list NodeList; /** diff --git a/src/linkgraph/flowmapper.cpp b/src/linkgraph/flowmapper.cpp index 3daab44142..4b974a809e 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 d41c3494d1..461b3b47e6 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 f75f602ab5..579bf9c469 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 61e3136167..30d68e4d89 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 4e6f332662..30ad20d4d5 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 af9f6ce5fb..3163ec9e39 100644 --- a/src/linkgraph/mcf.cpp +++ b/src/linkgraph/mcf.cpp @@ -5,6 +5,8 @@ #include "mcf.h" #include +#include "../safeguards.h" + typedef std::map PathViaMap; /** diff --git a/src/linkgraph/refresh.cpp b/src/linkgraph/refresh.cpp index 921f5d7b8d..8c45cad8b6 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 9d13deef66..cdef1e6a6e 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 1ee0ba247c..bd035bed3d 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 11607a5f1d..d9d506993f 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 228b35e82a..28f614afab 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 f87070fa0d..a80230de1c 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 6ca9a1bfc6..7859594dd9 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 c35ccc8f82..e7da13c7aa 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 55bef30e34..61e38b2374 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 401a9c0ba2..5945bd235a 100644 --- a/src/mixer.cpp +++ b/src/mixer.cpp @@ -13,6 +13,8 @@ #include #include "core/math_func.hpp" +#include "safeguards.h" + struct MixerChannel { bool active; diff --git a/src/music.cpp b/src/music.cpp index 55599a947b..4001e621e1 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) /** Names corresponding to the music set's files */ diff --git a/src/music/allegro_m.cpp b/src/music/allegro_m.cpp index 9551825905..77b488186a 100644 --- a/src/music/allegro_m.cpp +++ b/src/music/allegro_m.cpp @@ -16,6 +16,8 @@ #include "allegro_m.h" #include +#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 5ee62dfe51..2bc2074763 100644 --- a/src/music/bemidi.cpp +++ b/src/music/bemidi.cpp @@ -16,6 +16,8 @@ /* BeOS System Includes */ #include +#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 e7c7d6b752..a201984ae1 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 185d66a769..40ce69d1a0 100644 --- a/src/music/dmusic.cpp +++ b/src/music/dmusic.cpp @@ -27,6 +27,8 @@ #include #include +#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 93492aa996..6bfc990e5d 100644 --- a/src/music/extmidi.cpp +++ b/src/music/extmidi.cpp @@ -25,6 +25,8 @@ #include #include +#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 92f17212c3..1cb2adc0f9 100644 --- a/src/music/libtimidity.cpp +++ b/src/music/libtimidity.cpp @@ -26,6 +26,8 @@ #include #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 cb42a906a5..90d08d04a1 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 ec1fca2645..d7fb97d2d3 100644 --- a/src/music/os2_m.cpp +++ b/src/music/os2_m.cpp @@ -21,6 +21,8 @@ #include #include +#include "../safeguards.h" + /********************** * OS/2 MIDI PLAYER **********************/ diff --git a/src/music/qtmidi.cpp b/src/music/qtmidi.cpp index 0cfe318e7b..dfd6f16eb3 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 65ffbbc6b3..d3a7019a0f 100644 --- a/src/music/win32_m.cpp +++ b/src/music/win32_m.cpp @@ -15,6 +15,8 @@ #include #include +#include "../safeguards.h" + static struct { bool stop_song; bool terminate; diff --git a/src/music_gui.cpp b/src/music_gui.cpp index 896624cb7d..01406849fe 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 d8c990e240..d25ade4a3a 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 867bb4bb98..7a2ad92a29 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 0af0f7992c..cf98239f86 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 4d9345e824..7548132e0b 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 e68c354fc6..790941fc01 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 636696e2cb..284ceda9b1 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 ed2885b0ed..ccbf93f3c3 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 _tcp_connecters; diff --git a/src/network/core/tcp_content.cpp b/src/network/core/tcp_content.cpp index 8a4604feb0..fc22c4491f 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 d263b28e4a..9b3f7b5ef3 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 a9829d5604..a8bb64080a 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 _http_connections; diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp index f7abc7e35a..ce5f06b1f2 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 a3c8fd4a93..c22615a953 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 0327bf3666..c1ca3d3bb2 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 8b965feff2..2a06082dd6 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 44c13fbc8b..10e3695b7a 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 7ba26041cc..6e5458fd86 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 8677a81042..215ed5dfdd 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -27,6 +27,8 @@ #include #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 808c3ea232..332cf1a532 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 9496362137..e5d80630e1 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 615710465d..09c2623e78 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 fcaad19ab0..ebc7ee37ef 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 cde2994f70..46d8fddefe 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 b567fc4c9b..90fd24bf14 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 4201fc6221..6db12f7373 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 323fb6cc16..5eb24f670f 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 8f81fd0d8a..cba19cbdba 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 0166985233..7d830c5730 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 ef75be5d8c..4caf3a5d47 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 337b3edd11..9250ce748b 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 cead62750e..d3b5ddd164 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() }; diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index b5fe5d711e..cdd62b7aef 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 55eee6d23e..9bd77239aa 100644 --- a/src/newgrf_generic.cpp +++ b/src/newgrf_generic.cpp @@ -18,6 +18,8 @@ #include "water_map.h" #include +#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 47cca029a9..b923dfd17c 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 c660fe3ab7..7fe5fadf48 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 _building_counts; static HouseClassMapping _class_mapping[HOUSE_CLASS_MAX]; diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 725373d105..a7ae4c01fb 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 f22514a03f..90a17550d0 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 6f7e3f0ff8..3f48a819f5 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 f43689698e..872a3a7f66 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 c7739558fd..60ee609165 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 _sounds; diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp index d6d3c172c8..624b4d5474 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 f99121df2d..e70a8653bf 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 /* static */ void NewGRFClass::InsertDefaults() diff --git a/src/newgrf_storage.cpp b/src/newgrf_storage.cpp index 7e8b9d8d07..e91e1f90c8 100644 --- a/src/newgrf_storage.cpp +++ b/src/newgrf_storage.cpp @@ -16,6 +16,8 @@ #include "debug.h" #include +#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 439a8d57fd..cb6b57fa6a 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 c807e77a84..2f48eb757d 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 29ca068172..42aae3f147 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 5639001b71..77fc5828d2 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 05efae0a21..4038288d09 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 29a9d0d5ef..f0dbd0dc25 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 c901272c57..f3c62ba8ef 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -68,6 +68,8 @@ #include +#include "safeguards.h" + void CallLandscapeTick(); void IncreaseDate(); void DoPaletteAnimations(); diff --git a/src/order_backup.cpp b/src/order_backup.cpp index 100348f8ab..597ad13bba 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 70ab702a58..e73f4f35fa 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 e62cf595f9..ac248f878b 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 109b3e5fe2..05816c67e9 100644 --- a/src/os/macosx/crashlog_osx.cpp +++ b/src/os/macosx/crashlog_osx.cpp @@ -22,6 +22,8 @@ #include #include +#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 bc1cd2dbf3..eadb785101 100644 --- a/src/os/macosx/splash.cpp +++ b/src/os/macosx/splash.cpp @@ -23,6 +23,8 @@ #include +#include "../../safeguards.h" + /** * Handle pnglib error. * diff --git a/src/os/os2/os2.cpp b/src/os/os2/os2.cpp index 82ba19924f..283104d080 100644 --- a/src/os/os2/os2.cpp +++ b/src/os/os2/os2.cpp @@ -30,6 +30,8 @@ #include #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 0960720d1a..47de057f7e 100644 --- a/src/os/unix/crashlog_unix.cpp +++ b/src/os/unix/crashlog_unix.cpp @@ -31,6 +31,8 @@ #include #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 09bf6c6e70..accfffc061 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 41f83b60ba..9704403c8e 100644 --- a/src/os/windows/crashlog_win.cpp +++ b/src/os/windows/crashlog_win.cpp @@ -24,6 +24,8 @@ #include #include +#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 d7ea4ab356..30d964df76 100644 --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -29,6 +29,8 @@ #include #include +#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 2516c4dbf6..446f88db60 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 153ffa8c15..9ef2bca479 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 5c4ccb3ccb..bb705e5f4a 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 45540c1b61..2afb413918 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 850577de14..023c6a4a09 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 f66140046a..dea4e28c1b 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 82493241f5..711889b569 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 CYapfCostRoadT diff --git a/src/pathfinder/yapf/yapf_ship.cpp b/src/pathfinder/yapf/yapf_ship.cpp index 5e1cd27e75..a01444a9ec 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 CYapfFollowShipT diff --git a/src/pbs.cpp b/src/pbs.cpp index 55569c0596..76cb3b9d63 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 343893ceee..b498be109b 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 dd34cb6530..79598ec4a1 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 4dd4659bb6..c4b2b9f432 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 TrainList; diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 6fb08e7ca7..d07bb5520c 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 506e641d73..c208382050 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 c005d56c1b..57c5da5d41 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 7931fa965b..d20bdcfb46 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 181c920019..c0594e1f80 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 2c24582ee7..4984117bab 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 193e915d21..ca049979ca 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 ae15a88a5d..88a31de73a 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 bf837bbad3..7f3e7bbbca 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 0000000000..e4c8949f11 --- /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 . + */ + +/** + * @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 87754d6b52..d56dbe1718 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -58,6 +58,8 @@ #include +#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 51d0a50b8c..b86c5541e6 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 00a4b2b012..1172d2593e 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 2ccd42cb53..3fc5f61753 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 0cb9cca8d1..99e945503d 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 2188470a22..98ad95f090 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 fbc38cc852..dc8d4145e3 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 aa5648a888..4616b7e852 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 5878f31ead..03e9cdcb39 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 0d62d74cdf..861a541730 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 86605bdfb7..dabf120fca 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 d02264cd6b..80ab5debd1 100644 --- a/src/saveload/engine_sl.cpp +++ b/src/saveload/engine_sl.cpp @@ -14,6 +14,8 @@ #include "../engine_base.h" #include +#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 b2b263b131..629bc271a2 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 f25a8d1ebd..f818eca137 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 1c260503e8..c415d8ba4f 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 891d6ea6f1..93734f80f6 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 469548f231..658cfd2bdd 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 5cc77af0ce..3b898a3b87 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 _railtype_list; /** diff --git a/src/saveload/linkgraph_sl.cpp b/src/saveload/linkgraph_sl.cpp index f0dcb1dd45..d9b2b9093c 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 7088a4406c..007af7bc60 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 72c56db540..c7bd31e81e 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 d3915340cf..cdfd0f317a 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 4e8539793b..dfb1d2cbf5 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 83fc58ebfa..13ee0e5b06 100644 --- a/src/saveload/oldloader.cpp +++ b/src/saveload/oldloader.cpp @@ -23,6 +23,8 @@ #include +#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 f9215cf1d0..e260acd454 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 8234165793..40f83f832b 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 ab3e4a2904..34b396ddc0 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 d5ea26d65d..d5bacd509c 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 71e3b31ec7..23c306c38a 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 d35fa7cc94..110df63a7c 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 310f96fcb8..87e3720a62 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 b1cc50d460..c6b63bc1a0 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 bfdd25339f..f6d650468c 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 de52604f5f..7db6a7aa6f 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 ad8ef08315..059015be29 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -24,6 +24,8 @@ #include +#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 6ea72ea6f2..0f93969853 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 6e72dd520c..799be36d29 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 dfe05df3b0..e6fddf9e8c 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 3625fb4585..9027b29a2f 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 438a18ae98..edb912609e 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 7fd5b2df90..5b2d550b8c 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 5134243a96..229abf8657 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 25f9fc4542..45bec466c8 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 9687663e9e..0969342ecb 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 b2459af4eb..a2643f897f 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 08f705d60d..39b22a792a 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 e19821bba8..4b5b85ed61 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(company), cargo, town_id); diff --git a/src/script/api/script_company.cpp b/src/script/api/script_company.cpp index 851ca7888d..53f58c9147 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 bf6da493c0..1931a5db78 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 7ca0c7d464..d8489da491 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 6ff92debac..2f5b399633 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 7adbe8a286..05bb4ccd04 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 138628547b..1fe16321b5 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 b6143a20ec..99ab9537be 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 46d287f77c..9dd6ece190 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 d7d19863ff..0e711ca416 100644 --- a/src/script/api/script_event.cpp +++ b/src/script/api/script_event.cpp @@ -14,6 +14,8 @@ #include +#include "../../safeguards.h" + /** The queue of events for a script. */ struct ScriptEventData { std::queue stack; ///< The actual queue. diff --git a/src/script/api/script_event_types.cpp b/src/script/api/script_event_types.cpp index f22bb2f619..8c1395c11b 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 fe2ac3d7c1..4fb0cc7e29 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 f0aeb191fc..c24757a3cc 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 ed284ae595..1f8ded877e 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 535450973d..5153e0ef0e 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 89cbf2c711..1e8d6d774d 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 39dd310024..d1071c36c6 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 5e30f13770..c536ec5590 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 b9824b9acb..d2d298fa3f 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 bbfca99a4d..1ac59975dc 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 c72fabcaa5..b60361578b 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 1ce051bba0..d7da2747e1 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 68df5bf956..7add90c741 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 fc6a0b193a..6e725617cb 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 3f224b3d15..6334089fdb 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 abc8666f1f..434ec11acc 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 e80b884913..8d808ff3c8 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 counter(text); diff --git a/src/script/api/script_object.cpp b/src/script/api/script_object.cpp index 679efd1a7c..47de2b1a73 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 3098b452fd..676262dc77 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 26317a72c0..af68a3edc8 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 9373ce85c8..016145b764 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 445446695e..3a9a8ca3fd 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 3373800b54..236e1df7ef 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 5f6c6075bb..61ab9665aa 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 2774ac28ea..db0865261a 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 a7269bd249..9d88fd8fc1 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 17b7b82736..11820ec3f6 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 5b6b2cd533..3f1fa4ebbe 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 795ff02018..fc32e80a37 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 146ba690d4..640f7ab0a0 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 68644846f0..fd7d947799 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 46cc15e054..37f296de0c 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 f87b2e8b28..9fb297990c 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 c84e8411a6..db9220acd6 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 d4fe9f9773..933a92c4cb 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 725c7d0a6a..d81704ae38 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 33a3fc0703..a2e12febe1 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 97085688f8..7b891f28d0 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 23003ca26e..ca841f7557 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 3017266fab..625f0f8c4f 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 139edb0297..737e7e68da 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 a10b3376be..91733a38e8 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 b32b3e8b37..dd641a6848 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 086e59f639..1252f0fc7e 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 a46f5f3923..7842a3a9d7 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 8b84966f23..f3ea1747b5 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 b846303325..b70032f44b 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 7e4766fdbf..1aa5f1978b 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 2197a55058..b90f63cd83 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 ce73f9a640..2c50b964aa 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 9de119e1e1..a6f19a5dd5 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 91d52d917a..79e9ed2927 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 970c169b4a..b5fcbc670d 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 908ddadbf6..ea8c93feb8 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 d975822477..9f8cc10501 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 f1d09d40c7..210af20279 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 10cf78922b..cd04efbef5 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 e8a6690fcb..8e870b53db 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 53465fc8a1..2a23a43c9c 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 3109d1ef03..9a21c4e350 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 aeac02eb96..2358e9492c 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 b4137038fc..a8da3284e1 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 9bad9d6bd2..79dd988bfa 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 76a1e1e91d..88a723ff85 100644 --- a/src/sound/allegro_s.cpp +++ b/src/sound/allegro_s.cpp @@ -18,6 +18,8 @@ #include "allegro_s.h" #include +#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 1dc2a25d4a..8cf4a632bc 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 953bf5764a..3dc95c46ff 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 7e1c3e9936..e3fb99eaa7 100644 --- a/src/sound/sdl_s.cpp +++ b/src/sound/sdl_s.cpp @@ -18,6 +18,8 @@ #include "sdl_s.h" #include +#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 d241f45c81..0cd632714c 100644 --- a/src/sound/win32_s.cpp +++ b/src/sound/win32_s.cpp @@ -20,6 +20,8 @@ #include #include +#include "../safeguards.h" + static FSoundDriver_Win32 iFSoundDriver_Win32; static HWAVEOUT _waveout; diff --git a/src/sprite.cpp b/src/sprite.cpp index 513ca014fa..6db6966d80 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 49f2d7ff4b..c41b8f51cb 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 678ebb79a6..a45bd0fa8e 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 49554aaeff..c035aafce4 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 cf449df94a..9c2ddc1817 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 e658c1f20e..b773a1af44 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -39,6 +39,8 @@ #include #include +#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 62799e18bf..151fa5c373 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 da44c27437..46a1936317 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 872ed0a9a2..8199e7fcc4 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 GUIStoryPageList; typedef GUIList GUIStoryPageElementList; diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp index 5d04538413..61c36cd61d 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 be825fac06..27c76631c6 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 983f79edff..5b60979db4 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 98392bed66..6045c19ef4 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 dcaa6ae292..64692ef008 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 0cccd92d54..974aa50a8f 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 298a8bb571..04e5ae262b 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 7321a6d837..98ac1d365d 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 399b0a073b..d2e7d39e1f 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 766396fc66..80e4f90d74 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 fd20017161..03b5645998 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 95f2b0d773..ad6215af50 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 1fb3485ec5..77cf282daa 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 abf2cf0ccc..cc6b2f9d3d 100644 --- a/src/thread/thread_morphos.cpp +++ b/src/thread/thread_morphos.cpp @@ -23,6 +23,8 @@ #include #include +#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 415a62d59d..afa799b239 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 d93fc0c710..93f04cac19 100644 --- a/src/thread/thread_os2.cpp +++ b/src/thread/thread_os2.cpp @@ -16,6 +16,8 @@ #include #include +#include "../safeguards.h" + /** * OS/2 version for ThreadObject. */ diff --git a/src/thread/thread_pthread.cpp b/src/thread/thread_pthread.cpp index 9d54a4d20b..ce407fd941 100644 --- a/src/thread/thread_pthread.cpp +++ b/src/thread/thread_pthread.cpp @@ -14,6 +14,8 @@ #include #include +#include "../safeguards.h" + /** * POSIX pthread version for ThreadObject. */ diff --git a/src/thread/thread_win32.cpp b/src/thread/thread_win32.cpp index 484cc55137..c37baf7c36 100644 --- a/src/thread/thread_win32.cpp +++ b/src/thread/thread_win32.cpp @@ -17,6 +17,8 @@ #include #include +#include "../safeguards.h" + /** * Win32 thread version for ThreadObject. */ diff --git a/src/tile_map.cpp b/src/tile_map.cpp index 1e30ba0d96..9855484dff 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 046e222214..ec3b9aafbb 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 5b7a69d8ea..2e21506421 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 0a846915fa..b05c072118 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 57bc4d4124..c3f2a6e7b5 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 d3c480af11..78d453ed3a 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 b1fdace35e..a2ac0bafe7 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -37,6 +37,8 @@ #include "table/strings.h" +#include "safeguards.h" + typedef GUIList GUITownList; static const NWidgetPart _nested_town_authority_widgets[] = { diff --git a/src/townname.cpp b/src/townname.cpp index ad9b26fee6..99dd998217 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 0198ac58cb..57d6ab30bd 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 24cecd5f1c..a89ade3cf7 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 9e00552b68..4bad2b0561 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 c30609e782..4fcda82d81 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 784f4546da..f21eeaef2e 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 7639fa9491..4e6d5a7e13 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 2739fd7c49..9bb96538d6 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 ceb345f469..415b8e56a3 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 78c62d20a2..c42eb338fb 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 b1cd7ce2be..16813cea5d 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 fca9c5e466..93dec488d7 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 f844c6d0d0..e7c7b828b2 100644 --- a/src/video/allegro_v.cpp +++ b/src/video/allegro_v.cpp @@ -27,6 +27,8 @@ #include "allegro_v.h" #include +#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 9be1b2d3ce..1d8992bb79 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 f2f7fc5ed5..5037814e5b 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 cad21955d0..ff0fffd9cd 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -26,6 +26,8 @@ #include "sdl_v.h" #include +#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 c0da6db54e..989a2f1a26 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -27,6 +27,8 @@ #include #include +#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 c3ccea8735..d1eb8f449c 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 ab8125fa1f..90b0e1468f 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 7cd48e7d9b..05a7f8aa1c 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 cd8d9caa69..ea918b96a7 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 15c57afd56..7b5272a411 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 9500aba82b..857f8ba874 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 1a3d6e6e94..b2656987db 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 d02a96057e..3400a7df47 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 31c5ea8532..77d163c81b 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 6b0f60e37d..d919eff7cc 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 8f97693f60..3ea69ca3ca 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.