(svn r26482) -Codechange: add an include that allows us to undefine/redefine "unsafe" functions to prevent them from being used, and thus having to care about certain aspects of their return values

pull/155/head
rubidium 10 years ago
parent dd84952d15
commit 2be4215f43

@ -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)

@ -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",

@ -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;

@ -40,11 +40,12 @@
#include "../game/game_info.hpp"
#include "../game/game_instance.hpp"
#include "table/strings.h"
#include <vector>
#include "../safeguards.h"
static ScriptConfig *GetConfig(CompanyID slot)
{
if (slot == OWNER_DEITY) return GameConfig::GetConfig();

@ -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.

@ -82,6 +82,8 @@
#include "../company_base.h"
#include "../company_func.h"
#include "../safeguards.h"
AIInstance::AIInstance() :
ScriptInstance("AI")
{}

@ -18,6 +18,8 @@
#include "ai_info.hpp"
#include "ai_scanner.hpp"
#include "../safeguards.h"
AIScannerInfo::AIScannerInfo() :
ScriptScanner(),

@ -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).

@ -21,6 +21,8 @@
#include "table/strings.h"
#include "safeguards.h"
/**
* Draw the details for the given vehicle at the given position
*

@ -15,6 +15,8 @@
#include "table/airport_movement.h"
#include "table/airporttile_ids.h"
#include "safeguards.h"
/**
* Define a generic airport.

@ -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

@ -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. */

@ -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.
/**

@ -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)

@ -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);

@ -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);

@ -13,6 +13,8 @@
#include "base_consist.h"
#include "vehicle_base.h"
#include "safeguards.h"
BaseConsist::~BaseConsist()
{
free(this->name);

@ -15,6 +15,8 @@
#include "../table/sprites.h"
#include "../safeguards.h"
/** Instantiation of the 32bpp with animation blitter factory. */
static FBlitter_32bppAnim iFBlitter_32bppAnim;

@ -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;

@ -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;

@ -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;

@ -15,6 +15,8 @@
#include "../table/sprites.h"
#include "../safeguards.h"
/** Instantiation of the simple 32bpp blitter factory. */
static FBlitter_32bppSimple iFBlitter_32bppSimple;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -12,6 +12,8 @@
#include "../stdafx.h"
#include "null.hpp"
#include "../safeguards.h"
/** Instantiation of the null blitter factory. */
static FBlitter_Null iFBlitter_Null;

@ -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;

@ -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),

@ -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 */

@ -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

@ -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

@ -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.

@ -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.

@ -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)

@ -20,6 +20,8 @@
#include "table/strings.h"
#include "table/cargo_const.h"
#include "safeguards.h"
CargoSpec CargoSpec::array[NUM_CARGO];
/**

@ -12,6 +12,8 @@
#include "stdafx.h"
#include "cheat_type.h"
#include "safeguards.h"
/** All the cheats. */
Cheats _cheats;

@ -30,6 +30,8 @@
#include "table/sprites.h"
#include "safeguards.h"
/**
* The 'amount' to cheat with.

@ -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[] = {

@ -29,6 +29,8 @@
#include "table/strings.h"
#include "safeguards.h"
CommandProc CmdBuildRailroadTrack;
CommandProc CmdRemoveRailroadTrack;
CommandProc CmdBuildSingleRail;

@ -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.

@ -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.

@ -20,6 +20,8 @@
#include <stdarg.h>
#include "safeguards.h"
static const uint ICON_TOKEN_COUNT = 20; ///< Maximum number of tokens in one command
/* console parser */

@ -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).

@ -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;

@ -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

@ -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,

@ -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.

@ -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.

@ -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.

@ -13,6 +13,8 @@
#include "random_func.hpp"
#include "bitmath_func.hpp"
#include "../safeguards.h"
Randomizer _random, _interactive_random;
/**

@ -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

@ -36,6 +36,8 @@
#include <time.h>
#include "safeguards.h"
/* static */ const char *CrashLog::message = NULL;
/* static */ char *CrashLog::gamelog_buffer = NULL;
/* static */ const char *CrashLog::gamelog_last = NULL;

@ -20,6 +20,8 @@
#include "table/strings.h"
#include "safeguards.h"
/* exchange rate prefix symbol_pos
* | separator | postfix |
* | | Euro year | | | name

@ -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)

@ -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 {

@ -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;

@ -20,6 +20,8 @@ FILE *_log_fd = NULL; ///< File to reroute output of a forked OpenTTD to
#include <unistd.h>
#include "safeguards.h"
#if (defined(SUNOS) && !defined(_LP64) && !defined(_I32LPx)) || defined(__HAIKU__)
/* Solaris has, in certain situation, pid_t defined as long, while in other
* cases it has it defined as int... this handles all cases nicely.

@ -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)

@ -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.

@ -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.

@ -47,6 +47,8 @@
#include "table/strings.h"
#include "safeguards.h"
/** Delay counter for considering the next disaster. */
uint16 _disaster_delay;

@ -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);

@ -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.

@ -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");

@ -19,6 +19,8 @@
#include "effectvehicle_func.h"
#include "effectvehicle_base.h"
#include "safeguards.h"
static void ChimneySmokeInit(EffectVehicle *v)
{

@ -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.

@ -35,6 +35,8 @@
#include "table/strings.h"
#include "table/engines.h"
#include "safeguards.h"
EnginePool _engine_pool("Engine");
INSTANTIATE_POOL_METHODS(Engine)

@ -25,6 +25,8 @@
#include "table/strings.h"
#include "safeguards.h"
/**
* Return the category of an engine.
* @param engine Engine to examine.

@ -29,6 +29,8 @@
#include "table/strings.h"
#include <list>
#include "safeguards.h"
static const NWidgetPart _nested_errmsg_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_RED),

@ -32,6 +32,8 @@
#include "basedir.h"
#endif
#include "safeguards.h"
/** Size of the #Fio data buffer. */
#define FIO_BUFFER_SIZE 512

@ -26,6 +26,8 @@
#include "table/strings.h"
#include "safeguards.h"
/* Variables to display file lists */
SmallVector<FiosItem, 32> _fios_items;
static char *_fios_path;

@ -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.

@ -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.

@ -35,6 +35,8 @@ extern FT_Library _library;
#include <shlobj.h> /* SHGetFolderPath */
#include "os/windows/win32.h"
#include "safeguards.h"
/**
* Get the short DOS 8.3 format for paths.
* FreeType doesn't support Unicode filenames and Windows' fopen (as used
@ -373,6 +375,8 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
#include "os/macosx/macos.h"
#include "safeguards.h"
FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
{
FT_Error err = FT_Err_Cannot_Open_Resource;
@ -542,6 +546,8 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
#include <fontconfig/fontconfig.h>
#include "safeguards.h"
/* ========================================================================================
* FontConfig (unix) support
* ======================================================================================== */

@ -15,6 +15,8 @@
#include "game_config.hpp"
#include "game_info.hpp"
#include "../safeguards.h"
/* static */ GameConfig *GameConfig::GetConfig(ScriptSettingSource source)
{
GameConfig **config;

@ -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;

@ -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.

@ -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")

@ -15,6 +15,8 @@
#include "game_info.hpp"
#include "game_scanner.hpp"
#include "../safeguards.h"
void GameScannerInfo::Initialize()
{

@ -24,6 +24,8 @@
#include <stdarg.h>
#include "../safeguards.h"
void CDECL strgen_warning(const char *s, ...)
{
char buf[1024];

@ -21,6 +21,8 @@
#include <stdarg.h>
#include "safeguards.h"
extern const uint16 SAVEGAME_VERSION; ///< current savegame version
extern SavegameType _savegame_type; ///< type of savegame we are loading

@ -34,6 +34,8 @@
#include "game/game.hpp"
#include "game/game_instance.hpp"
#include "safeguards.h"
void GenerateClearTile();
void GenerateIndustries();

@ -32,6 +32,8 @@
#include "widgets/genworld_widget.h"
#include "safeguards.h"
extern void MakeNewgameSettingsLive();

@ -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;

@ -21,6 +21,8 @@
#include <unicode/ustring.h>
#endif /* WITH_ICU */
#include "safeguards.h"
/** Cache of ParagraphLayout lines. */
Layouter::LineCache *Layouter::linecache;

@ -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];

@ -24,6 +24,8 @@
#include "gui.h"
#include "network/network.h"
#include "safeguards.h"
GoalID _new_goal_id;

@ -28,6 +28,8 @@
#include "table/strings.h"
#include "safeguards.h"
/** Goal list columns. */
enum GoalColumn {
GC_GOAL = 0, ///< Goal text column.

@ -30,6 +30,8 @@
#include "table/sprites.h"
#include <math.h>
#include "safeguards.h"
/* Bitmasks of company and cargo indices that shouldn't be drawn. */
static uint _legend_excluded_companies;
static uint _legend_excluded_cargo;

@ -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.
*/

@ -24,6 +24,8 @@
#include "table/strings.h"
#include "safeguards.h"
GroupID _new_group_id;
GroupPool _group_pool("Group");

@ -30,6 +30,8 @@
#include "table/sprites.h"
#include "safeguards.h"
static const int LEVEL_WIDTH = 10; ///< Indenting width of a sub-group in pixels
typedef GUIList<const Group*> GUIGroupList;

@ -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)

@ -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.

@ -25,6 +25,8 @@
#include "widgets/highscore_widget.h"
#include "safeguards.h"
struct EndGameHighScoreBaseWindow : Window {
uint32 background_img;
int8 rank;

@ -16,6 +16,8 @@
#include "string_func.h"
#include "window_gui.h"
#include "safeguards.h"
char *_hotkeys_file;
/**

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save