Changeset - r21383:942c32fb8b0e
[Not reviewed]
master
! ! !
rubidium - 11 years ago 2014-04-23 20:13:33
rubidium@openttd.org
(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
402 files changed with 873 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/3rdparty/md5/md5.cpp
Show inline comments
 
@@ -57,12 +57,14 @@
 
 */
 

	
 
#include "../../stdafx.h"
 
#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)
 
#define T3    0x242070db
 
#define T4 /* 0xc1bdceee */ (T_MASK ^ 0x3e423111)
 
#define T5 /* 0xf57c0faf */ (T_MASK ^ 0x0a83f050)
src/ai/ai_config.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../stdafx.h"
 
#include "../settings_type.h"
 
#include "ai.hpp"
 
#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",
 
	"", // STR_AI_SETTINGS_START_DELAY
 
	AI::START_NEXT_MIN,
 
	AI::START_NEXT_MAX,
src/ai/ai_core.cpp
Show inline comments
 
@@ -19,12 +19,14 @@
 
#include "ai_scanner.hpp"
 
#include "ai_instance.hpp"
 
#include "ai_config.hpp"
 
#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;
 

	
 
/* static */ bool AI::CanStartNew()
 
{
src/ai/ai_gui.cpp
Show inline comments
 
@@ -37,17 +37,18 @@
 
#include "ai_instance.hpp"
 
#include "../game/game.hpp"
 
#include "../game/game_config.hpp"
 
#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();
 
	return AIConfig::GetConfig(slot);
 
}
 

	
src/ai/ai_info.cpp
Show inline comments
 
@@ -14,12 +14,14 @@
 
#include "../script/squirrel_class.hpp"
 
#include "ai_info.hpp"
 
#include "ai_scanner.hpp"
 
#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.
 
 */
 
static bool CheckAPIVersion(const char *api_version)
 
{
src/ai/ai_instance.cpp
Show inline comments
 
@@ -79,12 +79,14 @@
 
#include "../script/api/ai/ai_waypoint.hpp.sq"
 
#include "../script/api/ai/ai_waypointlist.hpp.sq"
 

	
 
#include "../company_base.h"
 
#include "../company_func.h"
 

	
 
#include "../safeguards.h"
 

	
 
AIInstance::AIInstance() :
 
	ScriptInstance("AI")
 
{}
 

	
 
void AIInstance::Initialize(AIInfo *info)
 
{
src/ai/ai_scanner.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 
#include "../core/random_func.hpp"
 

	
 
#include "../script/squirrel_class.hpp"
 
#include "ai_info.hpp"
 
#include "ai_scanner.hpp"
 

	
 
#include "../safeguards.h"
 

	
 

	
 
AIScannerInfo::AIScannerInfo() :
 
	ScriptScanner(),
 
	info_dummy(NULL)
 
{
 
}
src/aircraft_cmd.cpp
Show inline comments
 
@@ -36,12 +36,14 @@
 
#include "core/random_func.hpp"
 
#include "core/backup_type.hpp"
 
#include "zoom_func.h"
 

	
 
#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).
 
static const int HELI_FLIGHT_ALTITUDE   = 184;  ///< Normal flight altitude of helicopters.
 

	
 

	
src/aircraft_gui.cpp
Show inline comments
 
@@ -18,12 +18,14 @@
 
#include "window_gui.h"
 
#include "spritecache.h"
 
#include "zoom_func.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Draw the details for the given vehicle at the given position
 
 *
 
 * @param v     current vehicle
 
 * @param left  The left most coordinate to draw
 
 * @param right The right most coordinate to draw
src/airport.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "stdafx.h"
 
#include "station_base.h"
 
#include "table/strings.h"
 
#include "table/airport_movement.h"
 
#include "table/airporttile_ids.h"
 

	
 
#include "safeguards.h"
 

	
 

	
 
/**
 
 * Define a generic airport.
 
 * @param name Suffix of the names of the airport data.
 
 * @param terminals The terminals.
 
 * @param num_helipads Number of heli pads.
src/airport_gui.cpp
Show inline comments
 
@@ -28,12 +28,14 @@
 
#include "hotkeys.h"
 
#include "vehicle_func.h"
 
#include "gui.h"
 

	
 
#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
 
static byte _selected_airport_layout;          ///< selected airport layout number.
 

	
 
static void ShowBuildAirportPicker(Window *parent);
src/animated_tile.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "stdafx.h"
 
#include "core/alloc_func.hpp"
 
#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. */
 
uint _animated_tile_count = 0;
 
/** The number of slots for animated tiles allocated currently. */
 
uint _animated_tile_allocated = 0;
src/articulated_vehicles.cpp
Show inline comments
 
@@ -16,12 +16,14 @@
 
#include "engine_func.h"
 
#include "company_func.h"
 
#include "newgrf.h"
 

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

	
 
/**
 
 * Determines the next articulated part to attach
 
 * @param index Position in chain
 
 * @param front_type Front engine type
src/autoreplace.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "stdafx.h"
 
#include "command_func.h"
 
#include "group.h"
 
#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)
 

	
 
/**
 
 * Retrieves the EngineRenew that specifies the replacement of the given
src/autoreplace_cmd.cpp
Show inline comments
 
@@ -19,12 +19,14 @@
 
#include "autoreplace_gui.h"
 
#include "articulated_vehicles.h"
 
#include "core/random_func.hpp"
 

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

	
 
/**
 
 * Figure out if two engines got at least one type of cargo in common (refitting if needed)
src/autoreplace_gui.cpp
Show inline comments
 
@@ -25,12 +25,14 @@
 
#include "core/geometry_func.hpp"
 
#include "rail_gui.h"
 
#include "widgets/dropdown_func.h"
 

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

	
 
static int CDECL EngineNumberSorter(const EngineID *a, const EngineID *b)
 
{
src/base_consist.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file base_consist.cpp Properties for front vehicles/consists. */
 

	
 
#include "stdafx.h"
 
#include "base_consist.h"
 
#include "vehicle_base.h"
 

	
 
#include "safeguards.h"
 

	
 
BaseConsist::~BaseConsist()
 
{
 
	free(this->name);
 
}
 

	
 
/**
src/blitter/32bpp_anim.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../stdafx.h"
 
#include "../video/video_driver.hpp"
 
#include "32bpp_anim.hpp"
 

	
 
#include "../table/sprites.h"
 

	
 
#include "../safeguards.h"
 

	
 
/** Instantiation of the 32bpp with animation blitter factory. */
 
static FBlitter_32bppAnim iFBlitter_32bppAnim;
 

	
 
template <BlitterMode mode>
 
inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
 
{
src/blitter/32bpp_anim_sse4.cpp
Show inline comments
 
@@ -14,12 +14,14 @@
 
#include "../stdafx.h"
 
#include "../video/video_driver.hpp"
 
#include "../table/sprites.h"
 
#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;
 

	
 
/**
 
 * Draws a sprite to a (screen) buffer. It is templated to allow faster operation.
 
 *
src/blitter/32bpp_base.cpp
Show inline comments
 
@@ -9,12 +9,14 @@
 

	
 
/** @file 32bpp_base.cpp Implementation of base for 32 bpp blitters. */
 

	
 
#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;
 
}
 

	
 
void Blitter_32bppBase::SetPixel(void *video, int x, int y, uint8 colour)
src/blitter/32bpp_optimized.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../stdafx.h"
 
#include "../zoom_func.h"
 
#include "../settings_type.h"
 
#include "32bpp_optimized.hpp"
 

	
 
#include "../safeguards.h"
 

	
 
/** Instantiation of the optimized 32bpp blitter factory. */
 
static FBlitter_32bppOptimized iFBlitter_32bppOptimized;
 

	
 
/**
 
 * Draws a sprite to a (screen) buffer. It is templated to allow faster operation.
 
 *
src/blitter/32bpp_simple.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../stdafx.h"
 
#include "../zoom_func.h"
 
#include "32bpp_simple.hpp"
 

	
 
#include "../table/sprites.h"
 

	
 
#include "../safeguards.h"
 

	
 
/** Instantiation of the simple 32bpp blitter factory. */
 
static FBlitter_32bppSimple iFBlitter_32bppSimple;
 

	
 
void Blitter_32bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
 
{
 
	const Blitter_32bppSimple::Pixel *src, *src_line;
src/blitter/32bpp_sse2.cpp
Show inline comments
 
@@ -14,12 +14,14 @@
 
#include "../stdafx.h"
 
#include "../zoom_func.h"
 
#include "../settings_type.h"
 
#include "32bpp_sse2.hpp"
 
#include "32bpp_sse_func.hpp"
 

	
 
#include "../safeguards.h"
 

	
 
/** Instantiation of the SSE2 32bpp blitter factory. */
 
static FBlitter_32bppSSE2 iFBlitter_32bppSSE2;
 

	
 
Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
 
{
 
	/* First uint32 of a line = the number of transparent pixels from the left.
src/blitter/32bpp_sse4.cpp
Show inline comments
 
@@ -14,10 +14,12 @@
 
#include "../stdafx.h"
 
#include "../zoom_func.h"
 
#include "../settings_type.h"
 
#include "32bpp_sse4.hpp"
 
#include "32bpp_sse_func.hpp"
 

	
 
#include "../safeguards.h"
 

	
 
/** Instantiation of the SSE4 32bpp blitter factory. */
 
static FBlitter_32bppSSE4 iFBlitter_32bppSSE4;
 

	
 
#endif /* WITH_SSE */
src/blitter/32bpp_ssse3.cpp
Show inline comments
 
@@ -14,10 +14,12 @@
 
#include "../stdafx.h"
 
#include "../zoom_func.h"
 
#include "../settings_type.h"
 
#include "32bpp_ssse3.hpp"
 
#include "32bpp_sse_func.hpp"
 

	
 
#include "../safeguards.h"
 

	
 
/** Instantiation of the SSSE3 32bpp blitter factory. */
 
static FBlitter_32bppSSSE3 iFBlitter_32bppSSSE3;
 

	
 
#endif /* WITH_SSE */
src/blitter/8bpp_base.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file 8bpp_base.cpp Implementation of the base for all 8 bpp blitters. */
 

	
 
#include "../stdafx.h"
 
#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;
 

	
 
	do {
 
		for (int i = 0; i != width; i++) *((uint8 *)dst + i) = ctab[((uint8 *)dst)[i]];
src/blitter/8bpp_optimized.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../stdafx.h"
 
#include "../zoom_func.h"
 
#include "../settings_type.h"
 
#include "../core/math_func.hpp"
 
#include "8bpp_optimized.hpp"
 

	
 
#include "../safeguards.h"
 

	
 
/** Instantiation of the 8bpp optimised blitter factory. */
 
static FBlitter_8bppOptimized iFBlitter_8bppOptimized;
 

	
 
void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
 
{
 
	/* Find the offset of this zoom-level */
src/blitter/8bpp_simple.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file 8bpp_simple.cpp Implementation of the simple 8 bpp blitter. */
 

	
 
#include "../stdafx.h"
 
#include "../zoom_func.h"
 
#include "8bpp_simple.hpp"
 

	
 
#include "../safeguards.h"
 

	
 
/** Instantiation of the simple 8bpp blitter factory. */
 
static FBlitter_8bppSimple iFBlitter_8bppSimple;
 

	
 
void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
 
{
 
	const uint8 *src, *src_line;
src/blitter/base.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file base.cpp Implementation of the base for all blitters. */
 

	
 
#include "../stdafx.h"
 
#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;
 
	int dx;
 
	int stepx;
 
	int stepy;
src/blitter/null.cpp
Show inline comments
 
@@ -9,12 +9,14 @@
 

	
 
/** @file null.cpp A blitter that doesn't blit. */
 

	
 
#include "../stdafx.h"
 
#include "null.hpp"
 

	
 
#include "../safeguards.h"
 

	
 
/** Instantiation of the null blitter factory. */
 
static FBlitter_Null iFBlitter_Null;
 

	
 
Sprite *Blitter_Null::Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
 
{
 
	Sprite *dest_sprite;
src/bmp.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "stdafx.h"
 
#include "bmp.h"
 
#include "core/bitmath_func.hpp"
 
#include "core/alloc_func.hpp"
 
#include "core/mem_func.hpp"
 

	
 
#include "safeguards.h"
 

	
 
void BmpInitializeBuffer(BmpBuffer *buffer, FILE *file)
 
{
 
	buffer->pos      = -1;
 
	buffer->file     = file;
 
	buffer->read     = 0;
 
	buffer->real_pos = ftell(file);
src/bootstrap_gui.cpp
Show inline comments
 
@@ -26,12 +26,14 @@
 
#include "window_func.h"
 

	
 
#include "widgets/bootstrap_widget.h"
 

	
 
#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),
 
};
 

	
 
/**
src/bridge_gui.cpp
Show inline comments
 
@@ -26,12 +26,14 @@
 
#include "road_gui.h"
 

	
 
#include "widgets/bridge_widget.h"
 

	
 
#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 */
 
static BridgeType _last_roadbridge_type = 0;
 

	
 
/**
src/bridge_map.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file bridge_map.cpp Map accessor functions for bridges. */
 

	
 
#include "stdafx.h"
 
#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
 
 * @param tile the bridge tile to find the bridge ramp for
 
 * @param dir  the direction to search in
 
 */
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -34,12 +34,14 @@
 
#include "autoreplace_func.h"
 

	
 
#include "widgets/build_vehicle_widget.h"
 

	
 
#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
 
 * @return the height for the entry
 
 */
 
uint GetEngineListHeight(VehicleType type)
src/cargoaction.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "stdafx.h"
 
#include "economy_base.h"
 
#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.
 
 * @return Either new packet if splitting was necessary or the given one
 
 *         otherwise.
 
 */
src/cargomonitor.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file cargomonitor.cpp Implementation of the cargo transport monitoring. */
 

	
 
#include "stdafx.h"
 
#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.
 

	
 
/**
 
 * Helper method for ClearCargoPickupMonitoring and ClearCargoDeliveryMonitoring.
 
 * Clears all monitors that belong to the specified company or all if INVALID_OWNER
src/cargopacket.cpp
Show inline comments
 
@@ -14,12 +14,14 @@
 
#include "core/pool_func.hpp"
 
#include "core/random_func.hpp"
 
#include "economy_base.h"
 
#include "cargoaction.h"
 
#include "order_type.h"
 

	
 
#include "safeguards.h"
 

	
 
/* Initialize the cargopacket-pool */
 
CargoPacketPool _cargopacket_pool("CargoPacket");
 
INSTANTIATE_POOL_METHODS(CargoPacket)
 

	
 
/**
 
 * Create a new packet for savegame loading.
src/cargotype.cpp
Show inline comments
 
@@ -17,12 +17,14 @@
 
#include "core/sort_func.hpp"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "table/cargo_const.h"
 

	
 
#include "safeguards.h"
 

	
 
CargoSpec CargoSpec::array[NUM_CARGO];
 

	
 
/**
 
 * Bitmask of cargo types available. This includes phony cargoes like regearing cargoes.
 
 * Initialized during a call to #SetupCargoForClimate.
 
 */
src/cheat.cpp
Show inline comments
 
@@ -9,12 +9,14 @@
 

	
 
/** @file cheat.cpp Handling (loading/saving/initializing) of cheats. */
 

	
 
#include "stdafx.h"
 
#include "cheat_type.h"
 

	
 
#include "safeguards.h"
 

	
 
/** All the cheats. */
 
Cheats _cheats;
 

	
 
/** Reinitialise all the cheats. */
 
void InitializeCheats()
 
{
src/cheat_gui.cpp
Show inline comments
 
@@ -27,12 +27,14 @@
 
#include "linkgraph/linkgraphschedule.h"
 

	
 
#include "widgets/cheat_widget.h"
 

	
 
#include "table/sprites.h"
 

	
 
#include "safeguards.h"
 

	
 

	
 
/**
 
 * The 'amount' to cheat with.
 
 * This variable is semantically a constant value, but because the cheat
 
 * code requires to be able to write to the variable it is not constified.
 
 */
src/clear_cmd.cpp
Show inline comments
 
@@ -20,12 +20,14 @@
 
#include "newgrf_generic.h"
 

	
 
#include "table/strings.h"
 
#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[] = {
 
		PR_CLEAR_GRASS,
 
		PR_CLEAR_ROUGH,
 
		PR_CLEAR_ROCKS,
src/command.cpp
Show inline comments
 
@@ -26,12 +26,14 @@
 
#include "signal_func.h"
 
#include "core/backup_type.hpp"
 
#include "object_base.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
CommandProc CmdBuildRailroadTrack;
 
CommandProc CmdRemoveRailroadTrack;
 
CommandProc CmdBuildSingleRail;
 
CommandProc CmdRemoveSingleRail;
 

	
 
CommandProc CmdLandscapeClear;
src/company_cmd.cpp
Show inline comments
 
@@ -36,12 +36,14 @@
 
#include "game/game.hpp"
 
#include "goal_base.h"
 
#include "story_base.h"
 

	
 
#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.
 
CompanyManagerFace _company_manager_face; ///< for company manager face storage in openttd.cfg
 
uint _next_competitor_start;              ///< the number of ticks before the next AI is started
 
uint _cur_company_tick_index;             ///< used to generate a name for one company that doesn't have a name yet per tick
src/company_gui.cpp
Show inline comments
 
@@ -35,12 +35,14 @@
 
#include "road_func.h"
 
#include "water.h"
 
#include "station_func.h"
 

	
 
#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.
 
static const uint EXP_BLOCKSPACE = 10;     ///< Amount of vertical space between two blocks of numbers.
 

	
 
static void DoSelectCompanyManagerFace(Window *parent);
src/console.cpp
Show inline comments
 
@@ -17,12 +17,14 @@
 
#include "debug.h"
 
#include "console_func.h"
 
#include "settings_type.h"
 

	
 
#include <stdarg.h>
 

	
 
#include "safeguards.h"
 

	
 
static const uint ICON_TOKEN_COUNT = 20;     ///< Maximum number of tokens in one command
 

	
 
/* console parser */
 
IConsoleCmd   *_iconsole_cmds;    ///< list of registered commands
 
IConsoleAlias *_iconsole_aliases; ///< list of registered aliases
 

	
src/console_cmds.cpp
Show inline comments
 
@@ -37,12 +37,14 @@
 
#include "newgrf.h"
 
#include "console_func.h"
 
#include "engine_base.h"
 
#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).
 

	
 
/* console command defines */
 
#define DEF_CONSOLE_CMD(function) static bool function(byte argc, char *argv[])
 
#define DEF_CONSOLE_HOOK(function) static ConsoleHookResult function(bool echo)
src/console_gui.cpp
Show inline comments
 
@@ -24,12 +24,14 @@
 
#include "video/video_driver.hpp"
 

	
 
#include "widgets/console_widget.h"
 

	
 
#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;
 
static const uint ICON_BOTTOM_BORDERWIDTH = 12;
 

	
 
/**
src/core/alloc_func.cpp
Show inline comments
 
@@ -8,12 +8,14 @@
 
 */
 

	
 
/** @file alloc_func.cpp Functions to 'handle' memory allocation errors */
 

	
 
#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
 
 */
 
void NORETURN MallocError(size_t size)
 
{
src/core/bitmath_func.cpp
Show inline comments
 
@@ -9,12 +9,14 @@
 

	
 
/** @file bitmath_func.cpp Functions related to bit mathematics. */
 

	
 
#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,
 
	4,  0,  1,  0,  2,  0,  1,  0,
 
	3,  0,  1,  0,  2,  0,  1,  0,
 
	5,  0,  1,  0,  2,  0,  1,  0,
src/core/geometry_func.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file geometry_func.cpp Geometry functions. */
 

	
 
#include "../stdafx.h"
 
#include "geometry_func.hpp"
 
#include "math_func.hpp"
 

	
 
#include "../safeguards.h"
 

	
 
/**
 
 * Compute bounding box of both dimensions.
 
 * @param d1 First dimension.
 
 * @param d2 Second dimension.
 
 * @return The bounding box of both dimensions, the smallest dimension that surrounds both arguments.
 
 */
src/core/math_func.cpp
Show inline comments
 
@@ -9,12 +9,14 @@
 

	
 
/** @file math_func.cpp Math functions. */
 

	
 
#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.
 
 * @param a First number.
 
 * @param b second number.
 
 * @return Least common multiple of values \a a and \a b.
src/core/pool_func.cpp
Show inline comments
 
@@ -9,12 +9,14 @@
 

	
 
/** @file pool_func.cpp Implementation of PoolBase methods. */
 

	
 
#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.
 
 */
 
/* virtual */ PoolBase::~PoolBase()
 
{
src/core/random_func.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file random_func.cpp Implementation of the pseudo random generator. */
 

	
 
#include "../stdafx.h"
 
#include "random_func.hpp"
 
#include "bitmath_func.hpp"
 

	
 
#include "../safeguards.h"
 

	
 
Randomizer _random, _interactive_random;
 

	
 
/**
 
 * Generate the next pseudo random number
 
 * @return the random number
 
 */
src/cpu.cpp
Show inline comments
 
@@ -9,12 +9,14 @@
 

	
 
/** @file cpu.cpp OS/CPU/compiler dependent CPU specific calls. */
 

	
 
#include "stdafx.h"
 
#include "core/bitmath_func.hpp"
 

	
 
#include "safeguards.h"
 

	
 
#undef RDTSC_AVAILABLE
 

	
 
/* rdtsc for MSC_VER, uses simple inline assembly, or _rdtsc
 
 * from external win64.asm because VS2005 does not support inline assembly */
 
#if defined(_MSC_VER) && !defined(RDTSC_AVAILABLE) && !defined(WINCE)
 
#include <intrin.h>
src/crashlog.cpp
Show inline comments
 
@@ -33,12 +33,14 @@
 
#include "game/game_info.hpp"
 
#include "company_base.h"
 
#include "company_func.h"
 

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

	
 
char *CrashLog::LogCompiler(char *buffer, const char *last) const
 
{
src/currency.cpp
Show inline comments
 
@@ -17,12 +17,14 @@
 
#include "settings_type.h"
 
#include "date_func.h"
 
#include "string_type.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
	/*   exchange rate    prefix                         symbol_pos
 
	 *   |  separator        |           postfix             |
 
	 *   |   |   Euro year   |              |                | name
 
	 *   |   |    |          |              |                |  | */
 
/** The original currency specifications. */
 
static const CurrencySpec origin_currency_specs[CURRENCY_END] = {
src/date.cpp
Show inline comments
 
@@ -18,12 +18,14 @@
 
#include "date_func.h"
 
#include "vehicle_base.h"
 
#include "rail_gui.h"
 
#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)
 
DateFract _date_fract; ///< Fractional part of the day.
 
uint16 _tick_counter;  ///< Ever incrementing (and sometimes wrapping) tick counter for setting off various events
 

	
src/date_gui.cpp
Show inline comments
 
@@ -17,12 +17,14 @@
 
#include "date_gui.h"
 
#include "core/geometry_func.hpp"
 

	
 
#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 {
 
	SetDateCallback *callback; ///< Callback to call when a date has been selected
 
	YearMonthDay date; ///< The currently selected date
 
	Year min_year;     ///< The minimum year in the year dropdown
src/debug.cpp
Show inline comments
 
@@ -21,12 +21,14 @@
 

	
 
#if defined(ENABLE_NETWORK)
 
#include "network/network_admin.h"
 
SOCKET _debug_socket = INVALID_SOCKET;
 
#endif /* ENABLE_NETWORK */
 

	
 
#include "safeguards.h"
 

	
 
int _debug_driver_level;
 
int _debug_grf_level;
 
int _debug_map_level;
 
int _debug_misc_level;
 
int _debug_net_level;
 
int _debug_sprite_level;
src/dedicated.cpp
Show inline comments
 
@@ -17,12 +17,14 @@ char *_log_file = NULL; ///< File to rer
 
FILE *_log_fd   = NULL; ///< File to reroute output of a forked OpenTTD to
 

	
 
#if defined(UNIX) && !defined(__MORPHOS__)
 

	
 
#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.
 
 * Haiku has also defined pid_t as a long.
 
 */
 
# define PRINTF_PID_T "%ld"
src/depot.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 
#include "order_func.h"
 
#include "window_func.h"
 
#include "core/pool_func.hpp"
 
#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)
 

	
 
/**
 
 * Clean up a depot
src/depot_cmd.cpp
Show inline comments
 
@@ -18,12 +18,14 @@
 
#include "vehicle_gui.h"
 
#include "vehiclelist.h"
 
#include "window_func.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Check whether the given name is globally unique amongst depots.
 
 * @param name The name to check.
 
 * @return True if there is no depot with the given name.
 
 */
 
static bool IsUniqueDepotName(const char *name)
src/depot_gui.cpp
Show inline comments
 
@@ -30,12 +30,14 @@
 
#include "zoom_func.h"
 

	
 
#include "widgets/depot_widget.h"
 

	
 
#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.
 
 * How long they should be moved and for what window types are controlled in ShowDepotWindow()
 
 */
 

	
src/disaster_cmd.cpp
Show inline comments
 
@@ -44,12 +44,14 @@
 
#include "company_base.h"
 
#include "core/random_func.hpp"
 
#include "core/backup_type.hpp"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/** Delay counter for considering the next disaster. */
 
uint16 _disaster_delay;
 

	
 
enum DisasterSubType {
 
	ST_ZEPPELINER,
 
	ST_ZEPPELINER_SHADOW,
src/dock_gui.cpp
Show inline comments
 
@@ -29,12 +29,14 @@
 

	
 
#include "widgets/dock_widget.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
static void ShowBuildDockStationPicker(Window *parent);
 
static void ShowBuildDocksDepotPicker(Window *parent);
 

	
 
static Axis _ship_depot_direction;
 

	
 
void CcBuildDocks(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
src/driver.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 
#include "debug.h"
 
#include "sound/sound_driver.hpp"
 
#include "music/music_driver.hpp"
 
#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.
 
Dimension _resolutions[32]; ///< List of resolutions.
 
Dimension _cur_resolution;  ///< The current resolution.
 
bool _rightclick_emulate;   ///< Whether right clicking is emulated.
src/economy.cpp
Show inline comments
 
@@ -50,12 +50,14 @@
 
#include "story_base.h"
 
#include "linkgraph/refresh.h"
 

	
 
#include "table/strings.h"
 
#include "table/pricebase.h"
 

	
 
#include "safeguards.h"
 

	
 

	
 
/* Initialize the cargo payment-pool */
 
CargoPaymentPool _cargo_payment_pool("CargoPayment");
 
INSTANTIATE_POOL_METHODS(CargoPayment)
 

	
 
/**
src/effectvehicle.cpp
Show inline comments
 
@@ -16,12 +16,14 @@
 
#include "vehicle_func.h"
 
#include "sound_func.h"
 
#include "animated_tile_func.h"
 
#include "effectvehicle_func.h"
 
#include "effectvehicle_base.h"
 

	
 
#include "safeguards.h"
 

	
 

	
 
static void ChimneySmokeInit(EffectVehicle *v)
 
{
 
	uint32 r = Random();
 
	v->cur_image = SPR_CHIMNEY_SMOKE_0 + GB(r, 0, 3);
 
	v->progress = GB(r, 16, 3);
src/elrail.cpp
Show inline comments
 
@@ -64,12 +64,14 @@
 
#include "elrail_func.h"
 
#include "company_base.h"
 
#include "newgrf_railtype.h"
 

	
 
#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.
 
 * @return The tile location group.
 
 */
 
static inline TLG GetTLG(TileIndex t)
src/engine.cpp
Show inline comments
 
@@ -32,12 +32,14 @@
 
#include "articulated_vehicles.h"
 
#include "error.h"
 

	
 
#include "table/strings.h"
 
#include "table/engines.h"
 

	
 
#include "safeguards.h"
 

	
 
EnginePool _engine_pool("Engine");
 
INSTANTIATE_POOL_METHODS(Engine)
 

	
 
EngineOverrideManager _engine_mngr;
 

	
 
/**
src/engine_gui.cpp
Show inline comments
 
@@ -22,12 +22,14 @@
 
#include "settings_type.h"
 

	
 
#include "widgets/engine_widget.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Return the category of an engine.
 
 * @param engine Engine to examine.
 
 * @return String describing the category ("road veh", "train". "airplane", or "ship") of the engine.
 
 */
 
StringID GetEngineCategoryName(EngineID engine)
src/error_gui.cpp
Show inline comments
 
@@ -26,12 +26,14 @@
 

	
 
#include "widgets/error_widget.h"
 

	
 
#include "table/strings.h"
 
#include <list>
 

	
 
#include "safeguards.h"
 

	
 
static const NWidgetPart _nested_errmsg_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_RED),
 
		NWidget(WWT_CAPTION, COLOUR_RED, WID_EM_CAPTION), SetDataTip(STR_ERROR_MESSAGE_CAPTION, STR_NULL),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_RED),
src/fileio.cpp
Show inline comments
 
@@ -29,12 +29,14 @@
 
#include <algorithm>
 

	
 
#ifdef WITH_XDG_BASEDIR
 
#include "basedir.h"
 
#endif
 

	
 
#include "safeguards.h"
 

	
 
/** Size of the #Fio data buffer. */
 
#define FIO_BUFFER_SIZE 512
 

	
 
/** Structure for keeping several open files with just one data buffer. */
 
struct Fio {
 
	byte *buffer, *buffer_end;             ///< position pointer in local buffer and last valid byte of buffer
src/fios.cpp
Show inline comments
 
@@ -23,12 +23,14 @@
 
#ifndef WIN32
 
# include <unistd.h>
 
#endif /* WIN32 */
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/* Variables to display file lists */
 
SmallVector<FiosItem, 32> _fios_items;
 
static char *_fios_path;
 
SmallFiosItem _file_to_saveload;
 
SortingBits _savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING;
 

	
src/fios_gui.cpp
Show inline comments
 
@@ -31,12 +31,14 @@
 

	
 
#include "widgets/fios_widget.h"
 

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

	
 
static bool _fios_path_changed;
 
static bool _savegame_sort_dirty;
 

	
src/fontcache.cpp
Show inline comments
 
@@ -20,12 +20,14 @@
 
#include "gfx_layout.h"
 

	
 
#include "table/sprites.h"
 
#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.
 

	
 
/** Default heights for the different sizes of fonts. */
 
static const int _default_font_height[FS_END]   = {10, 6, 18, 10};
 
static const int _default_font_ascender[FS_END] = { 8, 5, 15,  8};
src/fontdetection.cpp
Show inline comments
 
@@ -32,12 +32,14 @@ extern FT_Library _library;
 
#include "core/alloc_func.hpp"
 
#include "core/math_func.hpp"
 
#include <windows.h>
 
#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
 
 * by FreeType) doesn't support UTF-8 filenames. So we have to convert the
 
 * filename into something that isn't UTF-8 but represents the Unicode file
 
 * name. This is the short DOS 8.3 format. This does not contain any
 
@@ -370,12 +372,14 @@ bool SetFallbackFont(FreeTypeSettings *s
 
/* ========================================================================================
 
 * OSX support
 
 * ======================================================================================== */
 

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

	
 
	/* Get font reference from name. */
 
	CFStringRef name = CFStringCreateWithCString(kCFAllocatorDefault, font_name, kCFStringEncodingUTF8);
 
@@ -539,12 +543,14 @@ bool SetFallbackFont(FreeTypeSettings *s
 
}
 

	
 
#elif defined(WITH_FONTCONFIG) /* end ifdef __APPLE__ */
 

	
 
#include <fontconfig/fontconfig.h>
 

	
 
#include "safeguards.h"
 

	
 
/* ========================================================================================
 
 * FontConfig (unix) support
 
 * ======================================================================================== */
 
FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
 
{
 
	FT_Error err = FT_Err_Cannot_Open_Resource;
src/game/game_config.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../stdafx.h"
 
#include "../settings_type.h"
 
#include "game.hpp"
 
#include "game_config.hpp"
 
#include "game_info.hpp"
 

	
 
#include "../safeguards.h"
 

	
 
/* static */ GameConfig *GameConfig::GetConfig(ScriptSettingSource source)
 
{
 
	GameConfig **config;
 
	if (source == SSS_FORCE_NEWGAME || (source == SSS_DEFAULT && _game_mode == GM_MENU)) {
 
		config = &_settings_newgame.game_config;
 
	} else {
src/game/game_core.cpp
Show inline comments
 
@@ -18,12 +18,14 @@
 
#include "game.hpp"
 
#include "game_scanner.hpp"
 
#include "game_config.hpp"
 
#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;
 
/* static */ GameScannerInfo *Game::scanner_info = NULL;
 
/* static */ GameScannerLibrary *Game::scanner_library = NULL;
 

	
src/game/game_info.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 

	
 
#include "../script/squirrel_class.hpp"
 
#include "game_info.hpp"
 
#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.
 
 */
 
static bool CheckAPIVersion(const char *api_version)
 
{
src/game/game_instance.cpp
Show inline comments
 
@@ -82,12 +82,14 @@
 
#include "../script/api/game/game_vehiclelist.hpp.sq"
 
#include "../script/api/game/game_viewport.hpp.sq"
 
#include "../script/api/game/game_waypoint.hpp.sq"
 
#include "../script/api/game/game_waypointlist.hpp.sq"
 
#include "../script/api/game/game_window.hpp.sq"
 

	
 
#include "../safeguards.h"
 

	
 

	
 
GameInstance::GameInstance() :
 
	ScriptInstance("GS")
 
{}
 

	
 
void GameInstance::Initialize(GameInfo *info)
src/game/game_scanner.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../stdafx.h"
 

	
 
#include "../script/squirrel_class.hpp"
 
#include "game_info.hpp"
 
#include "game_scanner.hpp"
 

	
 
#include "../safeguards.h"
 

	
 

	
 
void GameScannerInfo::Initialize()
 
{
 
	ScriptScanner::Initialize("GSScanner");
 
}
 

	
src/game/game_text.cpp
Show inline comments
 
@@ -21,12 +21,14 @@
 
#include "game_info.hpp"
 

	
 
#include "table/strings.h"
 

	
 
#include <stdarg.h>
 

	
 
#include "../safeguards.h"
 

	
 
void CDECL strgen_warning(const char *s, ...)
 
{
 
	char buf[1024];
 
	va_list va;
 
	va_start(va, s);
 
	vsnprintf(buf, lengthof(buf), s, va);
src/gamelog.cpp
Show inline comments
 
@@ -18,12 +18,14 @@
 
#include "debug.h"
 
#include "date_func.h"
 
#include "rev.h"
 

	
 
#include <stdarg.h>
 

	
 
#include "safeguards.h"
 

	
 
extern const uint16 SAVEGAME_VERSION;  ///< current savegame version
 

	
 
extern SavegameType _savegame_type; ///< type of savegame we are loading
 

	
 
extern uint32 _ttdp_version;     ///< version of TTDP savegame (if applicable)
 
extern uint16 _sl_version;       ///< the major savegame version identifier
src/genworld.cpp
Show inline comments
 
@@ -31,12 +31,14 @@
 
#include "core/backup_type.hpp"
 
#include "progress.h"
 
#include "error.h"
 
#include "game/game.hpp"
 
#include "game/game_instance.hpp"
 

	
 
#include "safeguards.h"
 

	
 

	
 
void GenerateClearTile();
 
void GenerateIndustries();
 
void GenerateObjects();
 
void GenerateTrees();
 

	
src/genworld_gui.cpp
Show inline comments
 
@@ -29,12 +29,14 @@
 
#include "core/random_func.hpp"
 
#include "progress.h"
 
#include "error.h"
 

	
 
#include "widgets/genworld_widget.h"
 

	
 
#include "safeguards.h"
 

	
 

	
 
extern void MakeNewgameSettingsLive();
 

	
 
/** Enum for the modes we can generate in. */
 
enum GenenerateLandscapeWindowMode {
 
	GLWM_GENERATE,  ///< Generate new game.
src/gfx.cpp
Show inline comments
 
@@ -23,12 +23,14 @@
 
#include "newgrf_debug.h"
 

	
 
#include "table/palettes.h"
 
#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;
 
bool _ctrl_pressed;   ///< Is Ctrl pressed?
 
bool _shift_pressed;  ///< Is Shift pressed?
 
byte _fast_forward;
src/gfx_layout.cpp
Show inline comments
 
@@ -18,12 +18,14 @@
 
#include "table/control_codes.h"
 

	
 
#ifdef WITH_ICU
 
#include <unicode/ustring.h>
 
#endif /* WITH_ICU */
 

	
 
#include "safeguards.h"
 

	
 

	
 
/** Cache of ParagraphLayout lines. */
 
Layouter::LineCache *Layouter::linecache;
 

	
 
/** Cache of Font instances. */
 
Layouter::FontColourMap Layouter::fonts[FS_END];
src/gfxinit.cpp
Show inline comments
 
@@ -22,12 +22,14 @@
 
/* The type of set we're replacing */
 
#define SET_TYPE "graphics"
 
#include "base_media_func.h"
 

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

	
 
#include "table/landscape_sprite.h"
 

	
 
/** Offsets for loading the different "replacement" sprites in the files. */
src/goal.cpp
Show inline comments
 
@@ -21,12 +21,14 @@
 
#include "company_base.h"
 
#include "story_base.h"
 
#include "string_func.h"
 
#include "gui.h"
 
#include "network/network.h"
 

	
 
#include "safeguards.h"
 

	
 

	
 
GoalID _new_goal_id;
 

	
 
GoalPool _goal_pool("Goal");
 
INSTANTIATE_POOL_METHODS(Goal)
 

	
src/goal_gui.cpp
Show inline comments
 
@@ -25,12 +25,14 @@
 
#include "command_func.h"
 

	
 
#include "widgets/goal_widget.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/** Goal list columns. */
 
enum GoalColumn {
 
	GC_GOAL = 0, ///< Goal text column.
 
	GC_PROGRESS, ///< Goal progress column.
 
};
 

	
src/graph_gui.cpp
Show inline comments
 
@@ -27,12 +27,14 @@
 
#include "widgets/graph_widget.h"
 

	
 
#include "table/strings.h"
 
#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;
 

	
 
/* Apparently these don't play well with enums. */
 
static const OverflowSafeInt64 INVALID_DATAPOINT(INT64_MAX); // Value used for a datapoint that shouldn't be drawn.
src/ground_vehicle.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "stdafx.h"
 
#include "train.h"
 
#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.
 
 */
 
template <class T, VehicleType Type>
 
void GroundVehicle<T, Type>::PowerChanged()
 
{
src/group_cmd.cpp
Show inline comments
 
@@ -21,12 +21,14 @@
 
#include "company_func.h"
 
#include "core/pool_func.hpp"
 
#include "order_backup.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
GroupID _new_group_id;
 

	
 
GroupPool _group_pool("Group");
 
INSTANTIATE_POOL_METHODS(Group)
 

	
 
GroupStatistics::GroupStatistics()
src/group_gui.cpp
Show inline comments
 
@@ -27,12 +27,14 @@
 
#include "company_base.h"
 

	
 
#include "widgets/group_widget.h"
 

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

	
 
static const NWidgetPart _nested_group_widgets[] = {
 
	NWidget(NWID_HORIZONTAL), // Window header
src/heightmap.cpp
Show inline comments
 
@@ -19,12 +19,14 @@
 
#include "gfx_func.h"
 
#include "fios.h"
 
#include "fileio_func.h"
 

	
 
#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)
 
 */
 
static inline byte RGBToGrayscale(byte red, byte green, byte blue)
 
{
src/highscore.cpp
Show inline comments
 
@@ -17,12 +17,14 @@
 
#include "string_func.h"
 
#include "strings_func.h"
 
#include "table/strings.h"
 
#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.
 

	
 
static const StringID _endgame_perf_titles[] = {
 
	STR_HIGHSCORE_PERFORMANCE_TITLE_BUSINESSMAN,
 
	STR_HIGHSCORE_PERFORMANCE_TITLE_BUSINESSMAN,
src/highscore_gui.cpp
Show inline comments
 
@@ -22,12 +22,14 @@
 
#include "company_base.h"
 
#include "strings_func.h"
 
#include "hotkeys.h"
 

	
 
#include "widgets/highscore_widget.h"
 

	
 
#include "safeguards.h"
 

	
 
struct EndGameHighScoreBaseWindow : Window {
 
	uint32 background_img;
 
	int8 rank;
 

	
 
	EndGameHighScoreBaseWindow(WindowDesc *desc) : Window(desc)
 
	{
src/hotkeys.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 
#include "openttd.h"
 
#include "hotkeys.h"
 
#include "ini_type.h"
 
#include "string_func.h"
 
#include "window_gui.h"
 

	
 
#include "safeguards.h"
 

	
 
char *_hotkeys_file;
 

	
 
/**
 
 * List of all HotkeyLists.
 
 * This is a pointer to ensure initialisation order with the various static HotkeyList instances.
 
 */
src/industry_cmd.cpp
Show inline comments
 
@@ -42,12 +42,14 @@
 
#include "game/game.hpp"
 

	
 
#include "table/strings.h"
 
#include "table/industry_land.h"
 
#include "table/build_industry.h"
 

	
 
#include "safeguards.h"
 

	
 
IndustryPool _industry_pool("Industry");
 
INSTANTIATE_POOL_METHODS(Industry)
 

	
 
void ShowIndustryViewWindow(int industry);
 
void BuildOilRig(TileIndex tile);
 

	
src/industry_gui.cpp
Show inline comments
 
@@ -38,12 +38,14 @@
 
#include "smallmap_gui.h"
 
#include "widgets/dropdown_type.h"
 
#include "widgets/industry_widget.h"
 

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

	
 
assert_compile(NUM_INDUSTRYTYPES <= 64); // Make sure all industry types fit in _displayed_industries.
 

	
 
/** Cargo suffix type (for which window is it requested) */
src/ini.cpp
Show inline comments
 
@@ -23,12 +23,14 @@
 
#ifdef WIN32
 
# include <windows.h>
 
# include <shellapi.h>
 
# 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
 
 */
 
IniFile::IniFile(const char * const *list_group_names) : IniLoadFile(list_group_names)
 
{
src/ini_load.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "stdafx.h"
 
#include "core/alloc_func.hpp"
 
#include "core/mem_func.hpp"
 
#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
 
 * @param name   the name of the item
 
 * @param len    the length of the name of the item
 
 */
src/intro_gui.cpp
Show inline comments
 
@@ -30,12 +30,14 @@
 

	
 
#include "widgets/intro_widget.h"
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
 

	
 
#include "safeguards.h"
 

	
 
struct SelectGameWindow : public Window {
 

	
 
	SelectGameWindow(WindowDesc *desc) : Window(desc)
 
	{
 
		this->CreateNestedTree();
 
		this->FinishInitNested(0);
src/landscape.cpp
Show inline comments
 
@@ -34,12 +34,14 @@
 
#include <list>
 
#include <set>
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
 

	
 
#include "safeguards.h"
 

	
 
extern const TileTypeProcs
 
	_tile_type_clear_procs,
 
	_tile_type_rail_procs,
 
	_tile_type_road_procs,
 
	_tile_type_town_procs,
 
	_tile_type_trees_procs,
src/linkgraph/demands.cpp
Show inline comments
 
/** @file demands.cpp Definition of demand calculating link graph handler. */
 

	
 
#include "../stdafx.h"
 
#include "demands.h"
 
#include <list>
 

	
 
#include "../safeguards.h"
 

	
 
typedef std::list<NodeID> NodeList;
 

	
 
/**
 
 * Scale various things according to symmetric/asymmetric distribution.
 
 */
 
class Scaler {
src/linkgraph/flowmapper.cpp
Show inline comments
 
@@ -9,12 +9,14 @@
 

	
 
/** @file flowmapper.cpp Definition of flowmapper. */
 

	
 
#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.
 
 */
 
void FlowMapper::Run(LinkGraphJob &job) const
 
{
src/linkgraph/linkgraph.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file linkgraph.cpp Definition of link graph classes used for cargo distribution. */
 

	
 
#include "../stdafx.h"
 
#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)
 

	
 
/**
 
 * Create a node or clear it.
src/linkgraph/linkgraph_gui.cpp
Show inline comments
 
@@ -19,12 +19,14 @@
 
#include "../smallmap_gui.h"
 
#include "../core/geometry_func.hpp"
 
#include "../widgets/link_graph_legend_widget.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "../safeguards.h"
 

	
 
/**
 
 * Colours for the various "load" states of links. Ordered from "unused" to
 
 * "overloaded".
 
 */
 
const uint8 LinkGraphOverlay::LINK_COLOURS[] = {
 
	0x0f, 0xd1, 0xd0, 0x57,
src/linkgraph/linkgraphjob.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../stdafx.h"
 
#include "../core/pool_func.hpp"
 
#include "../window_func.h"
 
#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)
 

	
 
/**
 
 * Create a link graph job from a link graph. The link graph will be copied so
src/linkgraph/linkgraphschedule.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 
#include "linkgraphschedule.h"
 
#include "init.h"
 
#include "demands.h"
 
#include "mcf.h"
 
#include "flowmapper.h"
 

	
 
#include "../safeguards.h"
 

	
 
/**
 
 * Start the next job in the schedule.
 
 */
 
void LinkGraphSchedule::SpawnNext()
 
{
 
	if (this->schedule.empty()) return;
src/linkgraph/mcf.cpp
Show inline comments
 
@@ -2,12 +2,14 @@
 

	
 
#include "../stdafx.h"
 
#include "../core/math_func.hpp"
 
#include "mcf.h"
 
#include <set>
 

	
 
#include "../safeguards.h"
 

	
 
typedef std::map<NodeID, Path *> PathViaMap;
 

	
 
/**
 
 * Distance-based annotation for use in the Dijkstra algorithm. This is close
 
 * to the original meaning of "annotation" in this context. Paths are rated
 
 * according to the sum of distances of their edges.
src/linkgraph/refresh.cpp
Show inline comments
 
@@ -14,12 +14,14 @@
 
#include "../station_func.h"
 
#include "../engine_base.h"
 
#include "../vehicle_func.h"
 
#include "refresh.h"
 
#include "linkgraph.h"
 

	
 
#include "../safeguards.h"
 

	
 
/**
 
 * Refresh all links the given vehicle will visit.
 
 * @param v Vehicle to refresh links for.
 
 * @param allow_merge If the refresher is allowed to merge or extend link graphs.
 
 */
 
/* static */ void LinkRefresher::Run(Vehicle *v, bool allow_merge)
src/main_gui.cpp
Show inline comments
 
@@ -42,12 +42,14 @@
 
#include "network/network_gui.h"
 
#include "network/network_base.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
static int _rename_id = 1;
 
static int _rename_what = -1;
 

	
 
void CcGiveMoney(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
#ifdef ENABLE_NETWORK
src/map.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "stdafx.h"
 
#include "debug.h"
 
#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);
 
#endif
 

	
 
uint _map_log_x;     ///< 2^_map_log_x == _map_size_x
src/misc.cpp
Show inline comments
 
@@ -26,12 +26,14 @@
 
#include "network/network_func.h"
 
#include "window_func.h"
 
#include "core/pool_type.hpp"
 
#include "game/game.hpp"
 
#include "linkgraph/linkgraphschedule.h"
 

	
 
#include "safeguards.h"
 

	
 

	
 
extern TileIndex _cur_tileloop_tile;
 
extern void MakeNewgameSettingsLive();
 

	
 
void InitializeSound();
 
void InitializeMusic();
src/misc/countedobj.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file countedobj.cpp Support for reference counted objects. */
 

	
 
#include "../stdafx.h"
 

	
 
#include "countedptr.hpp"
 

	
 
#include "../safeguards.h"
 

	
 
int32 SimpleCountedObject::AddRef()
 
{
 
	return ++m_ref_cnt;
 
}
 

	
 
int32 SimpleCountedObject::Release()
src/misc/dbg_helpers.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file dbg_helpers.cpp Helpers for outputting debug information. */
 

	
 
#include "../stdafx.h"
 
#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",
 
	"SW", "NW", "UW", "LW", "LN", "RN", "rsw", "rnw",
 
};
 

	
src/misc/getoptdata.cpp
Show inline comments
 
@@ -9,12 +9,14 @@
 

	
 
/** @file getoptdata.cpp Library for parsing command line options. */
 

	
 
#include "../stdafx.h"
 
#include "getoptdata.h"
 

	
 
#include "../safeguards.h"
 

	
 
/**
 
 * Find the next option.
 
 * @return Function returns one
 
 * - An option letter if it found another option.
 
 * - -1 if option processing is finished. Inspect #argv and #numleft to find the command line arguments.
 
 * - -2 if an error was encountered.
src/misc_cmd.cpp
Show inline comments
 
@@ -22,12 +22,14 @@
 
#include "company_gui.h"
 
#include "company_base.h"
 
#include "core/backup_type.hpp"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Increase the loan of your company.
 
 * @param tile unused
 
 * @param flags operation to perform
 
 * @param p1 amount to increase the loan with, multitude of LOAN_INTERVAL. Only used when p2 == 2.
 
 * @param p2 when 0: loans LOAN_INTERVAL
src/misc_gui.cpp
Show inline comments
 
@@ -27,12 +27,14 @@
 
#include "newgrf_debug.h"
 

	
 
#include "widgets/misc_widget.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/** Method to open the OSK. */
 
enum OskActivation {
 
	OSKA_DISABLED,           ///< The OSK shall not be activated at all.
 
	OSKA_DOUBLE_CLICK,       ///< Double click on the edit box opens OSK.
 
	OSKA_SINGLE_CLICK,       ///< Single click after focus click opens OSK.
 
	OSKA_IMMEDIATELY,        ///< Focusing click already opens OSK.
src/mixer.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file mixer.cpp Mixing of sound samples. */
 

	
 
#include "stdafx.h"
 
#include <math.h>
 
#include "core/math_func.hpp"
 

	
 
#include "safeguards.h"
 

	
 
struct MixerChannel {
 
	bool active;
 

	
 
	/* pointer to allocated buffer memory */
 
	int8 *memory;
 

	
src/music.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "stdafx.h"
 

	
 
/** The type of set we're replacing */
 
#define SET_TYPE "music"
 
#include "base_media_func.h"
 

	
 
#include "safeguards.h"
 

	
 
INSTANTIATE_BASE_MEDIA_METHODS(BaseMedia<MusicSet>, MusicSet)
 

	
 
/** Names corresponding to the music set's files */
 
static const char * const _music_file_names[] = {
 
	"theme",
 
	"old_0", "old_1", "old_2", "old_3", "old_4", "old_5", "old_6", "old_7", "old_8", "old_9",
src/music/allegro_m.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 

	
 
#include "../stdafx.h"
 
#include "../debug.h"
 
#include "allegro_m.h"
 
#include <allegro.h>
 

	
 
#include "../safeguards.h"
 

	
 
static FMusicDriver_Allegro iFMusicDriver_Allegro;
 
static MIDI *_midi = NULL;
 

	
 
/**
 
 * There are multiple modules that might be using Allegro and
 
 * Allegro can only be initiated once.
src/music/bemidi.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 
#include "../openttd.h"
 
#include "bemidi.h"
 

	
 
/* BeOS System Includes */
 
#include <MidiSynthFile.h>
 

	
 
#include "../safeguards.h"
 

	
 
/** The file we're playing. */
 
static BMidiSynthFile midiSynthFile;
 

	
 
/** Factory for BeOS' midi player. */
 
static FMusicDriver_BeMidi iFMusicDriver_BeMidi;
 

	
src/music/cocoa_m.cpp
Show inline comments
 
@@ -25,12 +25,14 @@
 
#include <CoreServices/CoreServices.h>
 
#include <AudioUnit/AudioUnit.h>
 
#include <AudioToolbox/AudioToolbox.h>
 
#undef Rect
 
#undef Point
 

	
 
#include "../safeguards.h"
 

	
 
static FMusicDriver_Cocoa iFMusicDriver_Cocoa;
 

	
 

	
 
static MusicPlayer    _player = NULL;
 
static MusicSequence  _sequence = NULL;
 
static MusicTimeStamp _seq_length = 0;
src/music/dmusic.cpp
Show inline comments
 
@@ -24,12 +24,14 @@
 
#include <windows.h>
 
#include <dmksctrl.h>
 
#include <dmusici.h>
 
#include <dmusicc.h>
 
#include <dmusicf.h>
 

	
 
#include "../safeguards.h"
 

	
 
static FMusicDriver_DMusic iFMusicDriver_DMusic;
 

	
 
/** the direct music object manages buffers and ports */
 
static IDirectMusic *music = NULL;
 

	
 
/** the performance object controls manipulation of the segments */
src/music/extmidi.cpp
Show inline comments
 
@@ -22,12 +22,14 @@
 
#include <sys/wait.h>
 
#include <unistd.h>
 
#include <signal.h>
 
#include <sys/stat.h>
 
#include <errno.h>
 

	
 
#include "../safeguards.h"
 

	
 
#ifndef EXTERNAL_PLAYER
 
/** The default external midi player. */
 
#define EXTERNAL_PLAYER "timidity"
 
#endif
 

	
 
/** Factory for the midi player that uses external players. */
src/music/libtimidity.cpp
Show inline comments
 
@@ -23,12 +23,14 @@
 
#include <errno.h>
 
#include <timidity.h>
 
#if defined(PSP)
 
#include <pspaudiolib.h>
 
#endif /* PSP */
 

	
 
#include "../safeguards.h"
 

	
 
/** The state of playing. */
 
enum MidiState {
 
	MIDI_STOPPED = 0,
 
	MIDI_PLAYING = 1,
 
};
 

	
src/music/null_m.cpp
Show inline comments
 
@@ -9,8 +9,10 @@
 

	
 
/** @file null_m.cpp The music playback that is silent. */
 

	
 
#include "../stdafx.h"
 
#include "null_m.h"
 

	
 
#include "../safeguards.h"
 

	
 
/** The factory for the music player that does nothing. */
 
static FMusicDriver_Null iFMusicDriver_Null;
src/music/os2_m.cpp
Show inline comments
 
@@ -18,12 +18,14 @@
 
#define INCL_WIN
 

	
 
#include <stdarg.h>
 
#include <os2.h>
 
#include <os2me.h>
 

	
 
#include "../safeguards.h"
 

	
 
/**********************
 
 * OS/2 MIDI PLAYER
 
 **********************/
 

	
 
/* Interesting how similar the MCI API in OS/2 is to the Win32 MCI API,
 
 * eh? Anyone would think they both came from the same place originally! ;)
src/music/qtmidi.cpp
Show inline comments
 
@@ -35,12 +35,14 @@
 
#define Rect  OTTDRect
 
#define Point OTTDPoint
 
#include <QuickTime/QuickTime.h>
 
#undef Rect
 
#undef Point
 

	
 
#include "../safeguards.h"
 

	
 
static FMusicDriver_QtMidi iFMusicDriver_QtMidi;
 

	
 

	
 
static const uint MIDI_TYPE = 'Midi'; ///< OSType code for MIDI songs.
 

	
 

	
src/music/win32_m.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../stdafx.h"
 
#include "../string_func.h"
 
#include "win32_m.h"
 
#include <windows.h>
 
#include <mmsystem.h>
 

	
 
#include "../safeguards.h"
 

	
 
static struct {
 
	bool stop_song;
 
	bool terminate;
 
	bool playing;
 
	int new_vol;
 
	HANDLE wait_obj;
src/music_gui.cpp
Show inline comments
 
@@ -26,12 +26,14 @@
 

	
 
#include "widgets/music_widget.h"
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Get the name of the song.
 
 * @param index of the song.
 
 * @return the name of the song.
 
 */
 
static const char *GetSongName(int index)
src/network/core/address.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "address.h"
 
#include "../../debug.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/**
 
 * Get the hostname; in case it wasn't given the
 
 * IPv4 dotted representation is given.
 
 * @return the hostname
 
 */
 
const char *NetworkAddress::GetHostname()
src/network/core/core.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 

	
 
#include "../../stdafx.h"
 
#include "../../debug.h"
 
#include "os_abstraction.h"
 
#include "packet.h"
 

	
 
#include "../../safeguards.h"
 

	
 

	
 
#ifdef __MORPHOS__
 
/* the library base is required here */
 
struct Library *SocketBase = NULL;
 
#endif
 

	
src/network/core/host.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#ifdef ENABLE_NETWORK
 

	
 
#include "../../stdafx.h"
 
#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.
 
 * @param broadcast the list of broadcasts to write into.
 
 */
 
static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast);
src/network/core/packet.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 

	
 
#include "../../stdafx.h"
 
#include "../../string_func.h"
 

	
 
#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
 
 */
 
Packet::Packet(NetworkSocketHandler *cs)
 
{
src/network/core/tcp.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 

	
 
#include "../../stdafx.h"
 
#include "../../debug.h"
 

	
 
#include "tcp.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/**
 
 * Construct a socket handler for a TCP connection.
 
 * @param s The just opened TCP connection.
 
 */
 
NetworkTCPSocketHandler::NetworkTCPSocketHandler(SOCKET s) :
 
		NetworkSocketHandler(),
src/network/core/tcp_admin.cpp
Show inline comments
 
@@ -16,12 +16,14 @@
 
#include "../../stdafx.h"
 

	
 
#include "../network_internal.h"
 
#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);
 
assert_compile((int)CRR_BANKRUPT  == (int)ADMIN_CRR_BANKRUPT);
 
assert_compile((int)CRR_END       == (int)ADMIN_CRR_END);
 

	
src/network/core/tcp_connect.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 

	
 
#include "../../stdafx.h"
 
#include "../../thread/thread.h"
 

	
 
#include "tcp.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/** List of connections that are currently being created */
 
static SmallVector<TCPConnecter *,  1> _tcp_connecters;
 

	
 
/**
 
 * Create a new connecter for the given address
 
 * @param address the (un)resolved address to connect to
src/network/core/tcp_content.cpp
Show inline comments
 
@@ -21,12 +21,14 @@
 
#include "../../ai/ai.hpp"
 
#include "../../game/game.hpp"
 
#include "../../fios.h"
 
#endif /* OPENTTD_MSU */
 
#include "tcp_content.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/** Clear everything in the struct */
 
ContentInfo::ContentInfo()
 
{
 
	memset(this, 0, sizeof(*this));
 
}
 

	
src/network/core/tcp_game.cpp
Show inline comments
 
@@ -19,12 +19,14 @@
 
#include "../network_internal.h"
 
#include "../../debug.h"
 
#include "../../error.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/**
 
 * Create a new socket for the game connection.
 
 * @param s The socket to connect with.
 
 */
 
NetworkGameSocketHandler::NetworkGameSocketHandler(SOCKET s) : info(NULL), client_id(INVALID_CLIENT_ID),
 
		last_frame(_frame_counter), last_frame_server(_frame_counter), last_packet(_realtime_tick)
src/network/core/tcp_http.cpp
Show inline comments
 
@@ -17,12 +17,14 @@
 
#include "../../debug.h"
 
#include "../../rev.h"
 
#include "../network_func.h"
 

	
 
#include "tcp_http.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/** List of open HTTP connections. */
 
static SmallVector<NetworkHTTPSocketHandler *, 1> _http_connections;
 

	
 
/**
 
 * Start the querying
 
 * @param s        the socket of this connection
src/network/core/udp.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 

	
 
#include "../../stdafx.h"
 
#include "../../date_func.h"
 
#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.
 
 */
 
NetworkUDPSocketHandler::NetworkUDPSocketHandler(NetworkAddressList *bind)
 
{
src/network/network.cpp
Show inline comments
 
@@ -35,12 +35,14 @@
 
#include "../landscape_type.h"
 
#include "../rev.h"
 
#include "../core/pool_func.hpp"
 
#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! */
 
bool _ddc_fastforward = true;
 
#endif /* DEBUG_DUMP_COMMANDS */
 

	
src/network/network_admin.cpp
Show inline comments
 
@@ -22,12 +22,14 @@
 
#include "../console_func.h"
 
#include "../core/pool_func.hpp"
 
#include "../map_func.h"
 
#include "../rev.h"
 
#include "../game/game.hpp"
 

	
 
#include "../safeguards.h"
 

	
 

	
 
/* This file handles all the admin network commands. */
 

	
 
/** Redirection of the (remote) console to the admin. */
 
AdminIndex _redirect_console_to_admin = INVALID_ADMIN_ID;
 

	
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -27,12 +27,14 @@
 
#include "network_base.h"
 

	
 
#include "../widgets/network_chat_widget.h"
 

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

	
 
/** Spacing between chat lines. */
 
static const uint NETWORK_CHAT_LINE_SPACING = 3;
src/network/network_client.cpp
Show inline comments
 
@@ -31,12 +31,14 @@
 
#include "network_base.h"
 
#include "network_client.h"
 
#include "../core/backup_type.hpp"
 

	
 
#include "table/strings.h"
 

	
 
#include "../safeguards.h"
 

	
 
/* This file handles all the client-commands */
 

	
 

	
 
/** Read some packets, and when do use that data as initial load filter. */
 
struct PacketReader : LoadFilter {
 
	static const size_t CHUNK = 32 * 1024;  ///< 32 KiB chunks of memory.
src/network/network_command.cpp
Show inline comments
 
@@ -16,12 +16,14 @@
 
#include "network_client.h"
 
#include "network_server.h"
 
#include "../command_func.h"
 
#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,
 
	/* 0x01 */ CcBuildPrimaryVehicle,
 
	/* 0x02 */ CcBuildAirport,
 
	/* 0x03 */ CcBuildBridge,
src/network/network_content.cpp
Show inline comments
 
@@ -24,12 +24,14 @@
 
#include "table/strings.h"
 

	
 
#if defined(WITH_ZLIB)
 
#include <zlib.h>
 
#endif
 

	
 
#include "../safeguards.h"
 

	
 
extern bool HasScenario(const ContentInfo *ci, bool md5sum);
 

	
 
/** The client we use to connect to the server. */
 
ClientNetworkContentSocketHandler _network_content_client;
 

	
 
/** Wrapper function for the HasProc */
src/network/network_content_gui.cpp
Show inline comments
 
@@ -26,12 +26,14 @@
 
#include "network_content_gui.h"
 

	
 

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

	
 

	
 
/** Window for displaying the textfile of an item in the content list. */
src/network/network_gamelist.cpp
Show inline comments
 
@@ -19,12 +19,14 @@
 
#include "../window_func.h"
 
#include "../thread/thread.h"
 
#include "network_internal.h"
 
#include "network_udp.h"
 
#include "network_gamelist.h"
 

	
 
#include "../safeguards.h"
 

	
 
NetworkGameList *_network_game_list = NULL;
 

	
 
/** Mutex for handling delayed insertion/querying of servers. */
 
static ThreadMutex *_network_game_list_mutex = ThreadMutex::New();
 
/** The games to insert when the GUI thread has time for us. */
 
static NetworkGameList *_network_game_delayed_insertion_list = NULL;
src/network/network_gui.cpp
Show inline comments
 
@@ -36,12 +36,14 @@
 

	
 
#include "table/strings.h"
 
#include "../table/sprites.h"
 

	
 
#include "../stringfilter_type.h"
 

	
 
#include "../safeguards.h"
 

	
 

	
 
static void ShowNetworkStartServerWindow();
 
static void ShowNetworkLobbyWindow(NetworkGameList *ngl);
 

	
 
/**
 
 * Advertisement options in the start server window
src/network/network_server.cpp
Show inline comments
 
@@ -30,12 +30,14 @@
 
#include "../roadveh.h"
 
#include "../order_backup.h"
 
#include "../core/pool_func.hpp"
 
#include "../core/random_func.hpp"
 
#include "../rev.h"
 

	
 
#include "../safeguards.h"
 

	
 

	
 
/* This file handles all the server-commands */
 

	
 
DECLARE_POSTFIX_INCREMENT(ClientID)
 
/** The identifier counter for new clients (is never decreased) */
 
static ClientID _network_client_id = CLIENT_ID_FIRST;
src/network/network_udp.cpp
Show inline comments
 
@@ -31,12 +31,14 @@
 
#include "../newgrf_text.h"
 
#include "../strings_func.h"
 
#include "table/strings.h"
 

	
 
#include "core/udp.h"
 

	
 
#include "../safeguards.h"
 

	
 
/** Mutex for all out threaded udp resolution and such. */
 
static ThreadMutex *_network_udp_mutex = ThreadMutex::New();
 

	
 
/** Session key to register ourselves to the master server */
 
static uint64 _session_key = 0;
 

	
src/newgrf.cpp
Show inline comments
 
@@ -49,12 +49,14 @@
 
#include "language.h"
 
#include "vehicle_base.h"
 

	
 
#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.
 
 *
 
 * Contains portions of documentation by TTDPatch team.
 
 * Thanks especially to Josef Drexler for the documentation as well as a lot
src/newgrf_airport.cpp
Show inline comments
 
@@ -14,12 +14,14 @@
 
#include "date_func.h"
 
#include "newgrf_spritegroup.h"
 
#include "newgrf_text.h"
 
#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.
 
	byte airport_id;    ///< Type of airport for which the callback is run.
 
	byte layout;        ///< Layout of the airport to build.
 
	TileIndex tile;     ///< Tile for the callback, only valid for airporttile callbacks.
src/newgrf_airporttiles.cpp
Show inline comments
 
@@ -20,12 +20,14 @@
 
#include "company_base.h"
 
#include "town.h"
 
#include "table/strings.h"
 
#include "table/airporttiles.h"
 
#include "newgrf_animation_base.h"
 

	
 
#include "safeguards.h"
 

	
 

	
 
AirportTileSpec AirportTileSpec::tiles[NUM_AIRPORTTILES];
 

	
 
AirportTileOverrideManager _airporttile_mngr(NEW_AIRPORTTILE_OFFSET, NUM_AIRPORTTILES, INVALID_AIRPORTTILE);
 

	
 
/**
src/newgrf_canal.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 
#include "debug.h"
 
#include "newgrf_spritegroup.h"
 
#include "newgrf_canal.h"
 
#include "water.h"
 
#include "water_map.h"
 

	
 
#include "safeguards.h"
 

	
 
/** Table of canal 'feature' sprite groups */
 
WaterFeature _water_feature[CF_END];
 

	
 
/** Scope resolver of a canal tile. */
 
struct CanalScopeResolver : public ScopeResolver {
 
	TileIndex tile; ///< Tile containing the canal.
src/newgrf_cargo.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file newgrf_cargo.cpp Implementation of NewGRF cargoes. */
 

	
 
#include "stdafx.h"
 
#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);
 

	
 
	/* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const;
 
};
src/newgrf_commons.cpp
Show inline comments
 
@@ -29,12 +29,14 @@
 
#include "company_base.h"
 
#include "error.h"
 
#include "strings_func.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Constructor of generic class
 
 * @param offset end of original data for this entity. i.e: houses = 110
 
 * @param maximum of entities this manager can deal with. i.e: houses = 512
 
 * @param invalid is the ID used to identify an invalid entity id
 
 */
src/newgrf_config.cpp
Show inline comments
 
@@ -22,12 +22,14 @@
 
#include "strings_func.h"
 
#include "textfile_gui.h"
 

	
 
#include "fileio_func.h"
 
#include "fios.h"
 

	
 
#include "safeguards.h"
 

	
 
/** Create a new GRFTextWrapper. */
 
GRFTextWrapper::GRFTextWrapper() :
 
	text(NULL)
 
{
 
}
 

	
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -40,12 +40,14 @@
 
#include "newgrf_industrytiles.h"
 

	
 
#include "widgets/newgrf_debug_widget.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/** The sprite picker. */
 
NewGrfDebugSpritePicker _newgrf_debug_sprite_picker = { SPM_NONE, NULL, 0, SmallVector<SpriteID, 256>() };
 

	
 
/**
 
 * Get the feature index related to the window number.
 
 * @param window_number The window to get the feature index from.
src/newgrf_engine.cpp
Show inline comments
 
@@ -22,12 +22,14 @@
 
#include "aircraft.h"
 
#include "station_base.h"
 
#include "company_base.h"
 
#include "newgrf_railtype.h"
 
#include "ship.h"
 

	
 
#include "safeguards.h"
 

	
 
struct WagonOverride {
 
	EngineID *train_id;
 
	uint trains;
 
	CargoID cargo;
 
	const SpriteGroup *group;
 
};
src/newgrf_generic.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 
#include "industrytype.h"
 
#include "core/random_func.hpp"
 
#include "newgrf_sound.h"
 
#include "water_map.h"
 
#include <list>
 

	
 
#include "safeguards.h"
 

	
 
/** Scope resolver for generic objects and properties. */
 
struct GenericScopeResolver : public ScopeResolver {
 
	CargoID cargo_type;
 
	uint8 default_selection;
 
	uint8 src_industry;        ///< Source industry substitute type. 0xFF for "town", 0xFE for "unknown".
 
	uint8 dst_industry;        ///< Destination industry substitute type. 0xFF for "town", 0xFE for "unknown".
src/newgrf_gui.cpp
Show inline comments
 
@@ -33,12 +33,14 @@
 

	
 
#include "widgets/newgrf_widget.h"
 
#include "widgets/misc_widget.h"
 

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

	
 
/**
 
 * Show the first NewGRF error we can find.
src/newgrf_house.cpp
Show inline comments
 
@@ -21,12 +21,14 @@
 
#include "town.h"
 
#include "genworld.h"
 
#include "newgrf_animation_base.h"
 
#include "newgrf_cargo.h"
 
#include "station_base.h"
 

	
 
#include "safeguards.h"
 

	
 
static BuildingCounts<uint32> _building_counts;
 
static HouseClassMapping _class_mapping[HOUSE_CLASS_MAX];
 

	
 
HouseOverrideManager _house_mngr(NEW_HOUSE_OFFSET, NUM_HOUSES, INVALID_HOUSE_ID);
 

	
 
/**
src/newgrf_industries.cpp
Show inline comments
 
@@ -21,12 +21,14 @@
 
#include "error.h"
 
#include "strings_func.h"
 
#include "core/random_func.hpp"
 

	
 
#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. */
 
IndustryOverrideManager _industry_mngr(NEW_INDUSTRYOFFSET, NUM_INDUSTRYTYPES, INVALID_INDUSTRYTYPE);
 
IndustryTileOverrideManager _industile_mngr(NEW_INDUSTRYTILEOFFSET, NUM_INDUSTRYTILES, INVALID_INDUSTRYTILE);
 

	
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -19,12 +19,14 @@
 
#include "command_func.h"
 
#include "water.h"
 
#include "newgrf_animation_base.h"
 

	
 
#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
 
 * @param tile TileIndex from which the callback was initiated
 
 * @param index of the industry been queried for
 
 * @param signed_offsets Are the x and y offset encoded in parameter signed?
src/newgrf_object.cpp
Show inline comments
 
@@ -21,12 +21,14 @@
 
#include "object_map.h"
 
#include "tile_cmd.h"
 
#include "town.h"
 
#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);
 

	
 
extern const ObjectSpec _original_objects[NEW_OBJECT_OFFSET];
 
/** All the object specifications. */
 
ObjectSpec _object_specs[NUM_OBJECTS];
src/newgrf_railtype.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 
#include "debug.h"
 
#include "newgrf_railtype.h"
 
#include "date_func.h"
 
#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);
 
	return GB(tmp, 0, 2);
 
}
 

	
src/newgrf_sound.cpp
Show inline comments
 
@@ -17,12 +17,14 @@
 
#include "vehicle_base.h"
 
#include "sound_func.h"
 
#include "fileio_func.h"
 
#include "debug.h"
 
#include "settings_type.h"
 

	
 
#include "safeguards.h"
 

	
 
static SmallVector<SoundEntry, 8> _sounds;
 

	
 

	
 
/**
 
 * Allocate sound slots.
 
 * @param num Number of slots to allocate.
src/newgrf_spritegroup.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "stdafx.h"
 
#include "debug.h"
 
#include "newgrf_spritegroup.h"
 
#include "core/pool_func.hpp"
 

	
 
#include "safeguards.h"
 

	
 
SpriteGroupPool _spritegroup_pool("SpriteGroup");
 
INSTANTIATE_POOL_METHODS(SpriteGroup)
 

	
 
TemporaryStorageArray<int32, 0x110> _temp_store;
 

	
 

	
src/newgrf_station.cpp
Show inline comments
 
@@ -23,12 +23,14 @@
 
#include "newgrf_town.h"
 
#include "company_func.h"
 
#include "tunnelbridge_map.h"
 
#include "newgrf_animation_base.h"
 
#include "newgrf_class_func.h"
 

	
 
#include "safeguards.h"
 

	
 

	
 
template <typename Tspec, typename Tid, Tid Tmax>
 
/* static */ void NewGRFClass<Tspec, Tid, Tmax>::InsertDefaults()
 
{
 
	/* Set up initial data */
 
	classes[0].global_id = 'DFLT';
src/newgrf_storage.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 
#include "newgrf_storage.h"
 
#include "core/pool_func.hpp"
 
#include "core/endian_func.hpp"
 
#include "debug.h"
 
#include <set>
 

	
 
#include "safeguards.h"
 

	
 
PersistentStoragePool _persistent_storage_pool("PersistentStorage");
 
INSTANTIATE_POOL_METHODS(PersistentStorage)
 

	
 
/** The changed storage arrays */
 
static std::set<BasePersistentStorageArray*> *_changed_storage_arrays = new std::set<BasePersistentStorageArray*>;
 

	
src/newgrf_text.cpp
Show inline comments
 
@@ -30,12 +30,14 @@
 
#include "core/smallmap_type.hpp"
 
#include "language.h"
 

	
 
#include "table/strings.h"
 
#include "table/control_codes.h"
 

	
 
#include "safeguards.h"
 

	
 
#define GRFTAB  28
 
#define TABSIZE 11
 

	
 
/**
 
 * Explains the newgrf shift bit positioning.
 
 * the grf base will not be used in order to find the string, but rather for
src/newgrf_town.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "stdafx.h"
 
#include "debug.h"
 
#include "town.h"
 
#include "newgrf_town.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Resolver of a town scope.
 
 * @param ro Surrounding resolver.
 
 * @param t %Town of the scope.
 
 * @param readonly Scope may change persistent storage of the town.
 
 */
src/newgrf_townname.cpp
Show inline comments
 
@@ -16,12 +16,14 @@
 

	
 
#include "stdafx.h"
 
#include "newgrf_townname.h"
 
#include "core/alloc_func.hpp"
 
#include "string_func.h"
 

	
 
#include "safeguards.h"
 

	
 
static GRFTownName *_grf_townnames = NULL;
 

	
 
GRFTownName *GetGRFTownName(uint32 grfid)
 
{
 
	GRFTownName *t = _grf_townnames;
 
	for (; t != NULL; t = t->next) {
src/news_gui.cpp
Show inline comments
 
@@ -35,12 +35,14 @@
 
#include "settings_internal.h"
 

	
 
#include "widgets/news_widget.h"
 

	
 
#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
 
static uint _total_news = 0;                ///< current number of news items
 
static NewsItem *_oldest_news = NULL;       ///< head of news items queue
 
static NewsItem *_latest_news = NULL;       ///< tail of news items queue
src/object_cmd.cpp
Show inline comments
 
@@ -35,12 +35,14 @@
 
#include "newgrf_debug.h"
 
#include "vehicle_func.h"
 

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

	
 
/**
 
 * Get the object associated with a tile.
src/object_gui.cpp
Show inline comments
 
@@ -20,12 +20,14 @@
 
#include "window_func.h"
 

	
 
#include "widgets/object_widget.h"
 

	
 
#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
 

	
 
/** The window used for building objects. */
 
class BuildObjectWindow : public PickerWindowBase {
src/openttd.cpp
Show inline comments
 
@@ -65,12 +65,14 @@
 
#include "viewport_sprite_sorter.h"
 

	
 
#include "linkgraph/linkgraphschedule.h"
 

	
 
#include <stdarg.h>
 

	
 
#include "safeguards.h"
 

	
 
void CallLandscapeTick();
 
void IncreaseDate();
 
void DoPaletteAnimations();
 
void MusicLoop();
 
void ResetMusic();
 
void CallWindowTickEvent();
src/order_backup.cpp
Show inline comments
 
@@ -16,12 +16,14 @@
 
#include "network/network_func.h"
 
#include "order_backup.h"
 
#include "vehicle_base.h"
 
#include "window_func.h"
 
#include "station_map.h"
 

	
 
#include "safeguards.h"
 

	
 
OrderBackupPool _order_backup_pool("BackupOrder");
 
INSTANTIATE_POOL_METHODS(OrderBackup)
 

	
 
/** Free everything that is allocated. */
 
OrderBackup::~OrderBackup()
 
{
src/order_cmd.cpp
Show inline comments
 
@@ -27,12 +27,14 @@
 
#include "waypoint_base.h"
 
#include "company_base.h"
 
#include "order_backup.h"
 

	
 
#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
 
 */
 
assert_compile(sizeof(DestinationID) >= sizeof(DepotID));
 
assert_compile(sizeof(DestinationID) >= sizeof(StationID));
 

	
src/order_gui.cpp
Show inline comments
 
@@ -29,12 +29,14 @@
 
#include "hotkeys.h"
 
#include "aircraft.h"
 
#include "engine_func.h"
 

	
 
#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] = {
 
	{
 
		/* No refitting. */
 
		{
src/os/macosx/crashlog_osx.cpp
Show inline comments
 
@@ -19,12 +19,14 @@
 
#include <errno.h>
 
#include <signal.h>
 
#include <mach-o/arch.h>
 
#include <dlfcn.h>
 
#include <cxxabi.h>
 

	
 
#include "../../safeguards.h"
 

	
 

	
 
/* Macro testing a stack address for valid alignment. */
 
#if defined(__i386__)
 
#define IS_ALIGNED(addr) (((uintptr_t)(addr) & 0xf) == 8)
 
#else
 
#define IS_ALIGNED(addr) (((uintptr_t)(addr) & 0xf) == 0)
src/os/macosx/splash.cpp
Show inline comments
 
@@ -20,12 +20,14 @@
 
#include "splash.h"
 

	
 
#ifdef WITH_PNG
 

	
 
#include <png.h>
 

	
 
#include "../../safeguards.h"
 

	
 
/**
 
 * Handle pnglib error.
 
 *
 
 * @param png_ptr Pointer to png struct.
 
 * @param message Error message text.
 
 */
src/os/os2/os2.cpp
Show inline comments
 
@@ -27,12 +27,14 @@
 
#include <stdlib.h>
 
#include <time.h>
 
#ifndef __INNOTEK_LIBC__
 
	#include <dos.h>
 
#endif
 

	
 
#include "../../safeguards.h"
 

	
 
#define INCL_WIN
 
#define INCL_WINCLIPBOARD
 

	
 
#include <os2.h>
 
#ifndef __INNOTEK_LIBC__
 
	#include <i86.h>
src/os/unix/crashlog_unix.cpp
Show inline comments
 
@@ -28,12 +28,14 @@
 
#endif
 

	
 
#if defined(__NetBSD__)
 
#include <unistd.h>
 
#endif
 

	
 
#include "../../safeguards.h"
 

	
 
/**
 
 * Unix implementation for the crash logger.
 
 */
 
class CrashLogUnix : public CrashLog {
 
	/** Signal that has been thrown. */
 
	int signum;
src/os/unix/unix.cpp
Show inline comments
 
@@ -60,12 +60,14 @@ ULONG __stack = (1024*1024)*2; // maybe 
 
	#if defined(WITH_SDL)
 
		/* the mac implementation needs this file included in the same file as main() */
 
		#include <SDL.h>
 
	#endif
 
#endif
 

	
 
#include "../../safeguards.h"
 

	
 
bool FiosIsRoot(const char *path)
 
{
 
#if !defined(__MORPHOS__) && !defined(__AMIGAOS__)
 
	return path[1] == '\0';
 
#else
 
	/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */
src/os/windows/crashlog_win.cpp
Show inline comments
 
@@ -21,12 +21,14 @@
 
#include "../../saveload/saveload.h"
 
#include "../../video/video_driver.hpp"
 

	
 
#include <windows.h>
 
#include <signal.h>
 

	
 
#include "../../safeguards.h"
 

	
 
static const uint MAX_SYMBOL_LEN = 512;
 
static const uint MAX_FRAMES     = 64;
 

	
 
/* printf format specification for 32/64-bit addresses. */
 
#ifdef _M_AMD64
 
#define PRINTF_PTR "0x%016IX"
src/os/windows/win32.cpp
Show inline comments
 
@@ -26,12 +26,14 @@
 
#include "../../core/random_func.hpp"
 
#include "../../string_func.h"
 
#include "../../crashlog.h"
 
#include <errno.h>
 
#include <sys/stat.h>
 

	
 
#include "../../safeguards.h"
 

	
 
static bool _has_console;
 
static bool _cursor_disable = true;
 
static bool _cursor_visible = true;
 

	
 
bool MyShowCursor(bool show, bool toggle)
 
{
src/osk_gui.cpp
Show inline comments
 
@@ -20,12 +20,14 @@
 

	
 
#include "widgets/osk_widget.h"
 

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

	
 
enum KeyStateBits {
 
	KEYS_NONE,
 
	KEYS_SHIFT,
src/pathfinder/npf/aystar.cpp
Show inline comments
 
@@ -24,12 +24,14 @@
 
 */
 

	
 
#include "../../stdafx.h"
 
#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.
 
 * @return The #PathNode if it is available, else \c NULL
 
 */
 
PathNode *AyStar::ClosedListIsInList(const AyStarNode *node)
src/pathfinder/npf/npf.cpp
Show inline comments
 
@@ -16,12 +16,14 @@
 
#include "../../roadstop_base.h"
 
#include "../pathfinder_func.h"
 
#include "../pathfinder_type.h"
 
#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;
 
static const uint NPF_HASH_HALFBITS = NPF_HASH_BITS / 2;
 
static const uint NPF_HASH_HALFMASK = (1 << NPF_HASH_HALFBITS) - 1;
 

	
src/pathfinder/npf/queue.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file queue.cpp Implementation of the #BinaryHeap/#Hash. */
 

	
 
#include "../../stdafx.h"
 
#include "../../core/alloc_func.hpp"
 
#include "queue.h"
 

	
 
#include "../../safeguards.h"
 

	
 

	
 
/*
 
 * Binary Heap
 
 * For information, see: http://www.policyalmanac.org/games/binaryHeaps.htm
 
 */
 

	
src/pathfinder/opf/opf_ship.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../../stdafx.h"
 
#include "../../tunnelbridge_map.h"
 
#include "../../tunnelbridge.h"
 
#include "../../ship.h"
 
#include "../../core/random_func.hpp"
 

	
 
#include "../../safeguards.h"
 

	
 
struct RememberData {
 
	uint16 cur_length;
 
	byte depth;
 
	Track last_choosen_track;
 
};
 

	
src/pathfinder/yapf/yapf_rail.cpp
Show inline comments
 
@@ -16,12 +16,14 @@
 
#include "yapf_node_rail.hpp"
 
#include "yapf_costrail.hpp"
 
#include "yapf_destrail.hpp"
 
#include "../../viewport_func.h"
 
#include "../../newgrf_station.h"
 

	
 
#include "../../safeguards.h"
 

	
 
#define DEBUG_YAPF_CACHE 0
 

	
 
#if DEBUG_YAPF_CACHE
 
template <typename Tpf> void DumpState(Tpf &pf1, Tpf &pf2)
 
{
 
	DumpTarget dmp1, dmp2;
src/pathfinder/yapf/yapf_road.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../../stdafx.h"
 
#include "yapf.hpp"
 
#include "yapf_node_road.hpp"
 
#include "../../roadstop_base.h"
 

	
 
#include "../../safeguards.h"
 

	
 

	
 
template <class Types>
 
class CYapfCostRoadT
 
{
 
public:
 
	typedef typename Types::Tpf Tpf; ///< pathfinder (derived from THIS class)
src/pathfinder/yapf/yapf_ship.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../../stdafx.h"
 
#include "../../ship.h"
 

	
 
#include "yapf.hpp"
 
#include "yapf_node_ship.hpp"
 

	
 
#include "../../safeguards.h"
 

	
 
/** Node Follower module of YAPF for ships */
 
template <class Types>
 
class CYapfFollowShipT
 
{
 
public:
 
	typedef typename Types::Tpf Tpf;                     ///< the pathfinder class (derived from THIS class)
src/pbs.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "stdafx.h"
 
#include "viewport_func.h"
 
#include "vehicle_func.h"
 
#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
 
 * @return the reserved trackbits. TRACK_BIT_NONE on nothing reserved or
 
 *     a tile without rail.
 
 */
src/progress.cpp
Show inline comments
 
@@ -9,12 +9,14 @@
 

	
 
/** @file progress.cpp Functions for modal progress windows. */
 

	
 
#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;
 
/** Rights for the performing work. */
 
ThreadMutex *_modal_progress_work_mutex = ThreadMutex::New();
 
/** Rights for the painting. */
src/rail.cpp
Show inline comments
 
@@ -14,12 +14,14 @@
 
#include "tunnelbridge_map.h"
 
#include "date_func.h"
 
#include "company_func.h"
 
#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 */
 
extern const byte _signal_along_trackdir[TRACKDIR_END] = {
 
	0x8, 0x8, 0x8, 0x2, 0x4, 0x1, 0, 0,
 
	0x4, 0x4, 0x4, 0x1, 0x8, 0x2
src/rail_cmd.cpp
Show inline comments
 
@@ -35,12 +35,14 @@
 
#include "object_map.h"
 

	
 
#include "table/strings.h"
 
#include "table/railtypes.h"
 
#include "table/track_land.h"
 

	
 
#include "safeguards.h"
 

	
 
/** Helper type for lists/vectors of trains */
 
typedef SmallVector<Train *, 16> TrainList;
 

	
 
RailtypeInfo _railtypes[RAILTYPE_END];
 

	
 
assert_compile(sizeof(_original_railtypes) <= sizeof(_railtypes));
src/rail_gui.cpp
Show inline comments
 
@@ -37,12 +37,14 @@
 

	
 
#include "station_map.h"
 
#include "tunnelbridge_map.h"
 

	
 
#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
 
static DiagDirection _build_depot_direction; ///< Currently selected depot direction
 
static byte _waypoint_count = 1;             ///< Number of waypoint types
 
static byte _cur_waypoint_type;              ///< Currently selected waypoint type
src/rev.cpp.in
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file rev.cpp Autogenerated file with the revision and such of OpenTTD. */
 

	
 
#include "stdafx.h"
 
#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.
 
 */
 
bool IsReleasedVersion()
 
{
src/road.cpp
Show inline comments
 
@@ -17,12 +17,14 @@
 
#include "company_func.h"
 
#include "company_base.h"
 
#include "engine_base.h"
 
#include "date_func.h"
 
#include "landscape.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Return if the tile is a valid tile for a crossing.
 
 *
 
 * @param tile the current tile
 
 * @param ax the axis of the road over the rail
 
 * @return true if it is a valid tile
src/road_cmd.cpp
Show inline comments
 
@@ -35,12 +35,14 @@
 
#include "date_func.h"
 
#include "genworld.h"
 
#include "company_gui.h"
 

	
 
#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
 
 */
 
bool RoadVehiclesAreBuilt()
 
{
src/road_gui.cpp
Show inline comments
 
@@ -30,12 +30,14 @@
 
#include "road_gui.h"
 

	
 
#include "widgets/road_widget.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
static void ShowRVStationPicker(Window *parent, RoadStopType rs);
 
static void ShowRoadDepotPicker(Window *parent);
 

	
 
static bool _remove_button_clicked;
 
static bool _one_way_button_clicked;
 

	
src/road_map.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file road_map.cpp Complex road accessors. */
 

	
 
#include "stdafx.h"
 
#include "station_map.h"
 
#include "tunnelbridge_map.h"
 

	
 
#include "safeguards.h"
 

	
 

	
 
/**
 
 * Returns the RoadBits on an arbitrary tile
 
 * Special behaviour:
 
 * - road depots: entrance is treated as road piece
 
 * - road tunnels: entrance is treated as road piece
src/roadstop.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 
#include "roadveh.h"
 
#include "core/pool_func.hpp"
 
#include "roadstop_base.h"
 
#include "station_base.h"
 
#include "vehicle_func.h"
 

	
 
#include "safeguards.h"
 

	
 
/** The pool of roadstops. */
 
RoadStopPool _roadstop_pool("RoadStop");
 
INSTANTIATE_POOL_METHODS(RoadStop)
 

	
 
/**
 
 * De-Initializes RoadStops.
src/roadveh_cmd.cpp
Show inline comments
 
@@ -35,12 +35,14 @@
 
#include "core/backup_type.hpp"
 
#include "newgrf.h"
 
#include "zoom_func.h"
 

	
 
#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,
 
	0xD7C, 0xC14, 0xC1C, 0xC24, 0xC2C, 0xC34, 0xC3C, 0xC4C,
 
	0xC54, 0xC64, 0xC5C, 0xC6C, 0xC44, 0xC5C, 0xC64, 0xCAC,
 
	0xCB4, 0xCBC, 0xD94, 0xD9C, 0xDA4, 0xDAC, 0xDB4, 0xDBC,
src/roadveh_gui.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 
#include "strings_func.h"
 
#include "vehicle_func.h"
 
#include "string_func.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Draw the details for the given vehicle at the given position
 
 *
 
 * @param v     current vehicle
 
 * @param left  The left most coordinate to draw
 
 * @param right The right most coordinate to draw
src/safeguards.h
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
/*
 
 * This file is part of OpenTTD.
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/**
 
 * @file safeguards.h A number of safeguards to prevent using unsafe methods.
 
 *
 
 * Unsafe methods are, for example, strndup and strncpy because they may leave the
 
 * string without a null termination, but also strdup and strndup because they can
 
 * return NULL and then all strdups would need to be guarded against that instead
 
 * of using the current MallocT/ReallocT/CallocT technique of just giving the user
 
 * an error that too much memory was used instead of spreading that code though
 
 * the whole code base.
 
 */
 

	
 
#ifndef SAFEGUARDS_H
 
#define SAFEGUARDS_H
 

	
 
/* Use MallocT instead. */
 
#define malloc    SAFEGUARD_DO_NOT_USE_THIS_METHOD
 

	
 
/* Use MallocT instead. */
 
#define calloc    SAFEGUARD_DO_NOT_USE_THIS_METHOD
 

	
 
/* Use ReallocT instead. */
 
#define realloc   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 

	
 
/* Use stredup instead. */
 
//#define strdup    SAFEGUARD_DO_NOT_USE_THIS_METHOD
 

	
 
/* Use stredup instead. */
 
//#define strndup   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 

	
 
/* Use strecpy instead. */
 
//#define strcpy    SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
//#define strncpy   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 

	
 
/* Use strecat instead. */
 
//#define strcat    SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
//#define strncat   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 

	
 
/* Use seprintf instead. */
 
//#define sprintf   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
//#define snprintf  SAFEGUARD_DO_NOT_USE_THIS_METHOD
 

	
 
/* Use vseprintf instead. */
 
//#define vsprintf  SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
//#define vsnprintf SAFEGUARD_DO_NOT_USE_THIS_METHOD
 

	
 
/* Use fgets instead. */
 
#define gets      SAFEGUARD_DO_NOT_USE_THIS_METHOD
 

	
 
/* No clear replacement. */
 
//#define strtok    SAFEGUARD_DO_NOT_USE_THIS_METHOD
 

	
 
/*
 
 * Possible future methods to mark unsafe, though needs more thought:
 
 *  - memcpy; when memory area overlaps it messes up, use memmove.
 
 *  - strlen: when the data is 'garbage', this could read beyond bounds.
 
 */
 

	
 
#endif /* SAFEGUARDS_H */
src/saveload/afterload.cpp
Show inline comments
 
@@ -55,12 +55,14 @@
 

	
 

	
 
#include "saveload_internal.h"
 

	
 
#include <signal.h>
 

	
 
#include "../safeguards.h"
 

	
 
extern Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY);
 

	
 
/**
 
 * Makes a tile canal or water depending on the surroundings.
 
 *
 
 * Must only be used for converting old savegames. Use WaterClass now.
src/saveload/ai_sl.cpp
Show inline comments
 
@@ -17,12 +17,14 @@
 

	
 
#include "../ai/ai.hpp"
 
#include "../ai/ai_config.hpp"
 
#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];
 
static bool _ai_saveload_is_random;
 

	
 
static const SaveLoad _ai_company[] = {
src/saveload/airport_sl.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../stdafx.h"
 

	
 
#include "saveload.h"
 
#include "newgrf_sl.h"
 

	
 
#include "../safeguards.h"
 

	
 
static void Save_APID()
 
{
 
	Save_NewGRFMapping(_airport_mngr);
 
}
 

	
 
static void Load_APID()
src/saveload/animated_tile_sl.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../stdafx.h"
 
#include "../tile_type.h"
 
#include "../core/alloc_func.hpp"
 

	
 
#include "saveload.h"
 

	
 
#include "../safeguards.h"
 

	
 
extern TileIndex *_animated_tile_list;
 
extern uint _animated_tile_count;
 
extern uint _animated_tile_allocated;
 

	
 
/**
 
 * Save the ANIT chunk.
src/saveload/autoreplace_sl.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../stdafx.h"
 
#include "../autoreplace_base.h"
 

	
 
#include "saveload.h"
 

	
 
#include "../safeguards.h"
 

	
 
static const SaveLoad _engine_renew_desc[] = {
 
	    SLE_VAR(EngineRenew, from,     SLE_UINT16),
 
	    SLE_VAR(EngineRenew, to,       SLE_UINT16),
 

	
 
	    SLE_REF(EngineRenew, next,     REF_ENGINE_RENEWS),
 
	SLE_CONDVAR(EngineRenew, group_id, SLE_UINT16, 60, SL_MAX_VERSION),
src/saveload/cargomonitor_sl.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../stdafx.h"
 
#include "../cargomonitor.h"
 

	
 
#include "saveload.h"
 

	
 
#include "../safeguards.h"
 

	
 
/** Temporary storage of cargo monitoring data for loading or saving it. */
 
struct TempStorage {
 
	CargoMonitorID number;
 
	uint32 amount;
 
};
 

	
src/saveload/cargopacket_sl.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../stdafx.h"
 
#include "../vehicle_base.h"
 
#include "../station_base.h"
 

	
 
#include "saveload.h"
 

	
 
#include "../safeguards.h"
 

	
 
/**
 
 * Savegame conversion for cargopackets.
 
 */
 
/* static */ void CargoPacket::AfterLoad()
 
{
 
	if (IsSavegameVersionBefore(44)) {
src/saveload/cheat_sl.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../stdafx.h"
 
#include "../cheat_type.h"
 

	
 
#include "saveload.h"
 

	
 
#include "../safeguards.h"
 

	
 
/**
 
 * Save the cheat values.
 
 */
 
static void Save_CHTS()
 
{
 
	/* Cannot use lengthof because _cheats is of type Cheats, not Cheat */
src/saveload/company_sl.cpp
Show inline comments
 
@@ -18,12 +18,14 @@
 
#include "../station_base.h"
 

	
 
#include "saveload.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "../safeguards.h"
 

	
 
/**
 
 * Converts an old company manager's face format to the new company manager's face format
 
 *
 
 * Meaning of the bits in the old face (some bits are used in several times):
 
 * - 4 and 5: chin
 
 * - 6 to 9: eyebrows
src/saveload/depot_sl.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../stdafx.h"
 
#include "../depot_base.h"
 
#include "../town.h"
 

	
 
#include "saveload.h"
 

	
 
#include "../safeguards.h"
 

	
 
static TownID _town_index;
 

	
 
static const SaveLoad _depot_desc[] = {
 
	 SLE_CONDVAR(Depot, xy,         SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
 
	 SLE_CONDVAR(Depot, xy,         SLE_UINT32,                 6, SL_MAX_VERSION),
 
	SLEG_CONDVAR(_town_index,       SLE_UINT16,                 0, 140),
src/saveload/economy_sl.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../stdafx.h"
 
#include "../economy_func.h"
 
#include "../economy_base.h"
 

	
 
#include "saveload.h"
 

	
 
#include "../safeguards.h"
 

	
 
/** Prices in pre 126 savegames */
 
static void Load_PRIC()
 
{
 
	/* Old games store 49 base prices, very old games store them as int32 */
 
	int vt = IsSavegameVersionBefore(65) ? SLE_FILE_I32 : SLE_FILE_I64;
 
	SlArray(NULL, 49, vt | SLE_VAR_NULL);
src/saveload/engine_sl.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../stdafx.h"
 
#include "saveload_internal.h"
 
#include "../engine_base.h"
 
#include <map>
 

	
 
#include "../safeguards.h"
 

	
 
static const SaveLoad _engine_desc[] = {
 
	 SLE_CONDVAR(Engine, intro_date,          SLE_FILE_U16 | SLE_VAR_I32,  0,  30),
 
	 SLE_CONDVAR(Engine, intro_date,          SLE_INT32,                  31, SL_MAX_VERSION),
 
	 SLE_CONDVAR(Engine, age,                 SLE_FILE_U16 | SLE_VAR_I32,  0,  30),
 
	 SLE_CONDVAR(Engine, age,                 SLE_INT32,                  31, SL_MAX_VERSION),
 
	     SLE_VAR(Engine, reliability,         SLE_UINT16),
src/saveload/game_sl.cpp
Show inline comments
 
@@ -17,12 +17,14 @@
 
#include "../game/game.hpp"
 
#include "../game/game_config.hpp"
 
#include "../network/network.h"
 
#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];
 
static bool _game_saveload_is_random;
 

	
 
static const SaveLoad _game_script[] = {
src/saveload/gamelog_sl.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../stdafx.h"
 
#include "../gamelog_internal.h"
 
#include "../fios.h"
 

	
 
#include "saveload.h"
 

	
 
#include "../safeguards.h"
 

	
 
static const SaveLoad _glog_action_desc[] = {
 
	SLE_VAR(LoggedAction, tick,              SLE_UINT16),
 
	SLE_END()
 
};
 

	
 
static const SaveLoad _glog_mode_desc[] = {
src/saveload/goal_sl.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../stdafx.h"
 
#include "../goal_base.h"
 

	
 
#include "saveload.h"
 

	
 
#include "../safeguards.h"
 

	
 
static const SaveLoad _goals_desc[] = {
 
	    SLE_VAR(Goal, company,   SLE_UINT16),
 
	    SLE_VAR(Goal, type,      SLE_UINT16),
 
	    SLE_VAR(Goal, dst,       SLE_UINT32),
 
	    SLE_STR(Goal, text,      SLE_STR | SLF_ALLOW_CONTROL, 0),
 
	SLE_CONDSTR(Goal, progress,  SLE_STR | SLF_ALLOW_CONTROL, 0, 182, SL_MAX_VERSION),
src/saveload/group_sl.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../stdafx.h"
 
#include "../group.h"
 

	
 
#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),
 
	SLE_CONDNULL(2,                                                         0,  163), // num_vehicle
 
	     SLE_VAR(Group, owner,              SLE_UINT8),
 
	     SLE_VAR(Group, vehicle_type,       SLE_UINT8),
src/saveload/industry_sl.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../stdafx.h"
 
#include "../industry.h"
 

	
 
#include "saveload.h"
 
#include "newgrf_sl.h"
 

	
 
#include "../safeguards.h"
 

	
 
static OldPersistentStorage _old_ind_persistent_storage;
 

	
 
static const SaveLoad _industry_desc[] = {
 
	SLE_CONDVAR(Industry, location.tile,              SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
	SLE_CONDVAR(Industry, location.tile,              SLE_UINT32,                  6, SL_MAX_VERSION),
 
	    SLE_VAR(Industry, location.w,                 SLE_FILE_U8 | SLE_VAR_U16),
src/saveload/labelmaps_sl.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../stdafx.h"
 
#include "../station_map.h"
 
#include "../tunnelbridge_map.h"
 

	
 
#include "saveload.h"
 

	
 
#include "../safeguards.h"
 

	
 
static SmallVector<RailTypeLabel, RAILTYPE_END> _railtype_list;
 

	
 
/**
 
 * Test if any saved rail type labels are different to the currently loaded
 
 * rail types, which therefore requires conversion.
 
 * @return true if (and only if) conversion due to rail type changes is needed.
src/saveload/linkgraph_sl.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 
#include "../linkgraph/linkgraph.h"
 
#include "../linkgraph/linkgraphjob.h"
 
#include "../linkgraph/linkgraphschedule.h"
 
#include "../settings_internal.h"
 
#include "saveload.h"
 

	
 
#include "../safeguards.h"
 

	
 
typedef LinkGraph::BaseNode Node;
 
typedef LinkGraph::BaseEdge Edge;
 

	
 
const SettingDesc *GetSettingDescription(uint index);
 

	
 
static uint _num_nodes;
src/saveload/map_sl.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 
#include "../map_func.h"
 
#include "../core/bitmath_func.hpp"
 
#include "../fios.h"
 

	
 
#include "saveload.h"
 

	
 
#include "../safeguards.h"
 

	
 
static uint32 _map_dim_x;
 
static uint32 _map_dim_y;
 

	
 
static const SaveLoadGlobVarList _map_dimensions[] = {
 
	SLEG_CONDVAR(_map_dim_x, SLE_UINT32, 6, SL_MAX_VERSION),
 
	SLEG_CONDVAR(_map_dim_y, SLE_UINT32, 6, SL_MAX_VERSION),
src/saveload/misc_sl.cpp
Show inline comments
 
@@ -18,12 +18,14 @@
 
#include "../gfx_func.h"
 
#include "../core/random_func.hpp"
 
#include "../fios.h"
 

	
 
#include "saveload.h"
 

	
 
#include "../safeguards.h"
 

	
 
extern TileIndex _cur_tileloop_tile;
 
extern uint16 _disaster_delay;
 
extern byte _trees_tick_ctr;
 

	
 
/* Keep track of current game position */
 
int _saved_scrollpos_x;
src/saveload/newgrf_sl.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../stdafx.h"
 
#include "../fios.h"
 

	
 
#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),
 
	SLE_VAR(EntityIDMapping, entity_id,     SLE_UINT8),
 
	SLE_VAR(EntityIDMapping, substitute_id, SLE_UINT8),
 
	SLE_END()
src/saveload/object_sl.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 
#include "../object_base.h"
 
#include "../object_map.h"
 

	
 
#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),
 
	    SLE_VAR(Object, location.h,                 SLE_FILE_U8 | SLE_VAR_U16),
 
	    SLE_REF(Object, town,                       REF_TOWN),
 
	    SLE_VAR(Object, build_date,                 SLE_UINT32),
src/saveload/oldloader.cpp
Show inline comments
 
@@ -20,12 +20,14 @@
 

	
 
#include "saveload_internal.h"
 
#include "oldloader.h"
 

	
 
#include <exception>
 

	
 
#include "../safeguards.h"
 

	
 
static const int TTO_HEADER_SIZE = 41;
 
static const int TTD_HEADER_SIZE = 49;
 

	
 
uint32 _bump_assert_value;
 

	
 
static inline OldChunkType GetOldChunkType(OldChunkType type)     {return (OldChunkType)GB(type, 0, 4);}
src/saveload/oldloader_sl.cpp
Show inline comments
 
@@ -31,12 +31,14 @@
 
#include "oldloader.h"
 

	
 
#include "table/strings.h"
 
#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
 

	
 
static uint8 *_old_map3;
 

	
src/saveload/order_sl.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 
#include "../order_backup.h"
 
#include "../settings_type.h"
 
#include "../network/network.h"
 

	
 
#include "saveload_internal.h"
 

	
 
#include "../safeguards.h"
 

	
 
/**
 
 * Converts this order from an old savegame's version;
 
 * it moves all bits to the new location.
 
 */
 
void Order::ConvertFromOldSavegame()
 
{
src/saveload/saveload.cpp
Show inline comments
 
@@ -46,12 +46,14 @@
 

	
 
#include "table/strings.h"
 

	
 
#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
 
 * savegame version.
 
 * Up to savegame version 18 there is a minor version as well.
 
 *
src/saveload/signs_sl.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../stdafx.h"
 
#include "../signs_base.h"
 
#include "../fios.h"
 

	
 
#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),
 
	SLE_CONDSTR(Sign, name,  SLE_STR | SLF_ALLOW_CONTROL, 0, 84, SL_MAX_VERSION),
 
	SLE_CONDVAR(Sign, x,     SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
 
	SLE_CONDVAR(Sign, y,     SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
src/saveload/station_sl.cpp
Show inline comments
 
@@ -16,12 +16,14 @@
 
#include "../vehicle_base.h"
 
#include "../newgrf_station.h"
 

	
 
#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.
 
 */
 
static void UpdateWaypointOrder(Order *o)
 
{
src/saveload/storage_sl.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file storage_sl.cpp Code handling saving and loading of persistent storages. */
 

	
 
#include "../stdafx.h"
 
#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),
 
	 SLE_CONDARR(PersistentStorage, storage,  SLE_UINT32, 16,            161, SL_MAX_VERSION),
 
	 SLE_END()
 
};
src/saveload/story_sl.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../stdafx.h"
 
#include "../story_base.h"
 

	
 
#include "saveload.h"
 

	
 
#include "../safeguards.h"
 

	
 
/** Called after load to trash broken pages. */
 
void AfterLoadStoryBook()
 
{
 
	if (IsSavegameVersionBefore(185)) {
 
		/* Trash all story pages and page elements because
 
		 * they were saved with wrong data types.
src/saveload/strings_sl.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../stdafx.h"
 
#include "../string_func.h"
 
#include "saveload_internal.h"
 

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

	
 
/**
 
 * Remap a string ID from the old format to the new format
src/saveload/subsidy_sl.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../stdafx.h"
 
#include "../subsidy_base.h"
 

	
 
#include "saveload.h"
 

	
 
#include "../safeguards.h"
 

	
 
static const SaveLoad _subsidies_desc[] = {
 
	    SLE_VAR(Subsidy, cargo_type, SLE_UINT8),
 
	    SLE_VAR(Subsidy, remaining,  SLE_UINT8),
 
	SLE_CONDVAR(Subsidy, awarded,    SLE_UINT8,                 125, SL_MAX_VERSION),
 
	SLE_CONDVAR(Subsidy, src_type,   SLE_UINT8,                 125, SL_MAX_VERSION),
 
	SLE_CONDVAR(Subsidy, dst_type,   SLE_UINT8,                 125, SL_MAX_VERSION),
src/saveload/town_sl.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 
#include "../landscape.h"
 
#include "../subsidy_func.h"
 

	
 
#include "saveload.h"
 
#include "newgrf_sl.h"
 

	
 
#include "../safeguards.h"
 

	
 
/**
 
 * Rebuild all the cached variables of towns.
 
 */
 
void RebuildTownCaches()
 
{
 
	Town *town;
src/saveload/vehicle_sl.cpp
Show inline comments
 
@@ -21,12 +21,14 @@
 
#include "../company_func.h"
 

	
 
#include "saveload.h"
 

	
 
#include <map>
 

	
 
#include "../safeguards.h"
 

	
 
/**
 
 * Link front and rear multiheaded engines to each other
 
 * This is done when loading a savegame
 
 */
 
void ConnectMultiheadedTrains()
 
{
src/saveload/waypoint_sl.cpp
Show inline comments
 
@@ -17,12 +17,14 @@
 
#include "../newgrf.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "saveload_internal.h"
 

	
 
#include "../safeguards.h"
 

	
 
/** Helper structure to convert from the old waypoint system. */
 
struct OldWaypoint {
 
	size_t index;
 
	TileIndex xy;
 
	TownID town_index;
 
	Town *town;
src/screenshot.cpp
Show inline comments
 
@@ -25,12 +25,14 @@
 
#include "window_func.h"
 
#include "tile_map.h"
 
#include "landscape.h"
 

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

	
 
char _screenshot_format_name[8];      ///< Extension of the current screenshot format (corresponds with #_cur_screenshot_format).
 
uint _num_screenshot_formats;         ///< Number of available screenshot formats.
 
uint _cur_screenshot_format;          ///< Index of the currently selected screenshot format in #_screenshot_formats.
src/script/api/script_accounting.cpp
Show inline comments
 
@@ -9,12 +9,14 @@
 

	
 
/** @file script_accounting.cpp Implementation of ScriptAccounting. */
 

	
 
#include "../../stdafx.h"
 
#include "script_accounting.hpp"
 

	
 
#include "../../safeguards.h"
 

	
 
Money ScriptAccounting::GetCosts()
 
{
 
	return this->GetDoCommandCosts();
 
}
 

	
 
void ScriptAccounting::ResetCosts()
src/script/api/script_admin.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../../stdafx.h"
 
#include "script_admin.hpp"
 
#include "script_log.hpp"
 
#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) {
 
		ScriptLog::Error("Send parameters can only be nested to 25 deep. No data sent."); // SQUIRREL_MAX_DEPTH = 25
 
		return false;
 
	}
src/script/api/script_airport.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../../stdafx.h"
 
#include "script_airport.hpp"
 
#include "script_station.hpp"
 
#include "../../station_base.h"
 
#include "../../town.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ bool ScriptAirport::IsValidAirportType(AirportType type)
 
{
 
	return IsAirportInformationAvailable(type) && ::AirportSpec::Get(type)->IsAvailable();
 
}
 

	
 
/* static */ bool ScriptAirport::IsAirportInformationAvailable(AirportType type)
src/script/api/script_base.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../../stdafx.h"
 
#include "script_base.hpp"
 
#include "script_error.hpp"
 
#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)
 
	 *   but we pick InteractiveRandomRange if we are a network_server or network-client. */
 
	if (_networking) return ::InteractiveRandom();
 
	return ::Random();
src/script/api/script_basestation.cpp
Show inline comments
 
@@ -14,12 +14,14 @@
 
#include "script_error.hpp"
 
#include "../../station_base.h"
 
#include "../../string_func.h"
 
#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);
 
	return st != NULL && (st->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY || st->owner == OWNER_NONE);
 
}
 

	
src/script/api/script_bridge.cpp
Show inline comments
 
@@ -14,12 +14,14 @@
 
#include "script_rail.hpp"
 
#include "../script_instance.hpp"
 
#include "../../bridge_map.h"
 
#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;
 
}
 

	
 
/* static */ bool ScriptBridge::IsBridgeTile(TileIndex tile)
src/script/api/script_bridgelist.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../../stdafx.h"
 
#include "script_bridgelist.hpp"
 
#include "script_bridge.hpp"
 
#include "../../bridge.h"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptBridgeList::ScriptBridgeList()
 
{
 
	for (byte j = 0; j < MAX_BRIDGES; j++) {
 
		if (ScriptBridge::IsValidBridge(j)) this->AddItem(j);
 
	}
 
}
src/script/api/script_cargo.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../../stdafx.h"
 
#include "script_cargo.hpp"
 
#include "../../economy_func.h"
 
#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());
 
}
 

	
 
/* static */ bool ScriptCargo::IsValidTownEffect(TownEffect towneffect_type)
src/script/api/script_cargolist.cpp
Show inline comments
 
@@ -14,12 +14,14 @@
 
#include "script_industry.hpp"
 
#include "script_station.hpp"
 
#include "../../cargotype.h"
 
#include "../../industry.h"
 
#include "../../station_base.h"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptCargoList::ScriptCargoList()
 
{
 
	const CargoSpec *cs;
 
	FOR_ALL_CARGOSPECS(cs) {
 
		this->AddItem(cs->Index());
 
	}
src/script/api/script_cargomonitor.cpp
Show inline comments
 
@@ -9,12 +9,14 @@
 

	
 
/** @file script_cargomonitor.cpp Code to monitor cargo pickup and deliveries by companies. */
 

	
 
#include "../../stdafx.h"
 
#include "script_cargomonitor.hpp"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ uint32 ScriptCargoMonitor::GetTownDeliveryAmount(ScriptCompany::CompanyID company, CargoID cargo, TownID town_id, bool keep_monitoring)
 
{
 
	CargoMonitorID monitor = EncodeCargoTownMonitor(static_cast<CompanyID>(company), cargo, town_id);
 
	return GetDeliveryAmount(monitor, keep_monitoring);
 
}
 

	
src/script/api/script_company.cpp
Show inline comments
 
@@ -21,12 +21,14 @@
 
#include "../../strings_func.h"
 
#include "../../tile_map.h"
 
#include "../../string_func.h"
 
#include "../../settings_func.h"
 
#include "table/strings.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ ScriptCompany::CompanyID ScriptCompany::ResolveCompanyID(ScriptCompany::CompanyID company)
 
{
 
	if (company == COMPANY_SELF) {
 
		if (!::Company::IsValidID((::CompanyID)_current_company)) return COMPANY_INVALID;
 
		return (CompanyID)((byte)_current_company);
 
	}
src/script/api/script_companymode.cpp
Show inline comments
 
@@ -9,12 +9,14 @@
 

	
 
/** @file script_companymode.cpp Implementation of ScriptCompanyMode. */
 

	
 
#include "../../stdafx.h"
 
#include "script_companymode.hpp"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptCompanyMode::ScriptCompanyMode(int company)
 
{
 
	if (company < OWNER_BEGIN || company >= MAX_COMPANIES) company = INVALID_COMPANY;
 

	
 
	this->last_company = ScriptObject::GetCompany();
 
	ScriptObject::SetCompany((CompanyID)company);
src/script/api/script_controller.cpp
Show inline comments
 
@@ -21,12 +21,14 @@
 
#include "../script_instance.hpp"
 
#include "script_log.hpp"
 
#include "../../ai/ai_gui.hpp"
 
#include "../../settings_type.h"
 
#include "../../network/network.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ void ScriptController::SetCommandDelay(int ticks)
 
{
 
	if (ticks <= 0) return;
 
	ScriptObject::SetDoCommandDelay(ticks);
 
}
 

	
src/script/api/script_date.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include <time.h>
 
#include "../../stdafx.h"
 
#include "script_date.hpp"
 
#include "../../date_func.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ bool ScriptDate::IsValidDate(Date date)
 
{
 
	return date >= 0;
 
}
 

	
 
/* static */ ScriptDate::Date ScriptDate::GetCurrentDate()
src/script/api/script_depotlist.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../../stdafx.h"
 
#include "script_depotlist.hpp"
 
#include "../../depot_base.h"
 
#include "../../station_base.h"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptDepotList::ScriptDepotList(ScriptTile::TransportType transport_type)
 
{
 
	::TileType tile_type;
 
	switch (transport_type) {
 
		default: return;
 

	
src/script/api/script_engine.cpp
Show inline comments
 
@@ -17,12 +17,14 @@
 
#include "../../rail.h"
 
#include "../../engine_base.h"
 
#include "../../engine_func.h"
 
#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);
 
	if (e == NULL || !e->IsEnabled()) return false;
 

	
 
	/* AIs have only access to engines they can purchase or still have in use.
src/script/api/script_enginelist.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file script_enginelist.cpp Implementation of ScriptEngineList and friends. */
 

	
 
#include "../../stdafx.h"
 
#include "script_enginelist.hpp"
 
#include "../../engine_base.h"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptEngineList::ScriptEngineList(ScriptVehicle::VehicleType vehicle_type)
 
{
 
	Engine *e;
 
	FOR_ALL_ENGINES_OF_TYPE(e, (::VehicleType)vehicle_type) {
 
		if (ScriptObject::GetCompany() == OWNER_DEITY || HasBit(e->company_avail, ScriptObject::GetCompany())) this->AddItem(e->index);
 
	}
src/script/api/script_error.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file script_error.cpp Implementation of ScriptError. */
 

	
 
#include "../../stdafx.h"
 
#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();
 

	
 
/* static */ ScriptErrorType ScriptError::GetLastError()
 
{
 
	return ScriptObject::GetLastError();
src/script/api/script_event.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../../stdafx.h"
 
#include "script_event_types.hpp"
 

	
 
#include <queue>
 

	
 
#include "../../safeguards.h"
 

	
 
/** The queue of events for a script. */
 
struct ScriptEventData {
 
	std::queue<ScriptEvent *> stack; ///< The actual queue.
 
};
 

	
 
/* static */ void ScriptEventController::CreateEventPointer()
src/script/api/script_event_types.cpp
Show inline comments
 
@@ -16,12 +16,14 @@
 
#include "../../strings_func.h"
 
#include "../../settings_type.h"
 
#include "../../engine_base.h"
 
#include "../../articulated_vehicles.h"
 
#include "table/strings.h"
 

	
 
#include "../../safeguards.h"
 

	
 
bool ScriptEventEnginePreview::IsEngineValid() const
 
{
 
	const Engine *e = ::Engine::GetIfValid(this->engine);
 
	return e != NULL && e->IsEnabled();
 
}
 

	
src/script/api/script_execmode.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../../stdafx.h"
 
#include "script_execmode.hpp"
 
#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
 
	 *  should continue with the real execution of the command. */
 
	return true;
 
}
src/script/api/script_game.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../../stdafx.h"
 
#include "script_game.hpp"
 
#include "../../command_type.h"
 
#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);
 
}
 

	
 
/* static */ bool ScriptGame::Unpause()
src/script/api/script_gamesettings.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../../stdafx.h"
 
#include "script_gamesettings.hpp"
 
#include "../../settings_internal.h"
 
#include "../../settings_type.h"
 
#include "../../command_type.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ bool ScriptGameSettings::IsValid(const char *setting)
 
{
 
	uint i;
 
	const SettingDesc *sd = GetSettingFromName(setting, &i);
 
	return sd != NULL && sd->desc.cmd != SDT_STRING;
 
}
src/script/api/script_goal.cpp
Show inline comments
 
@@ -17,12 +17,14 @@
 
#include "script_town.hpp"
 
#include "script_story_page.hpp"
 
#include "../script_instance.hpp"
 
#include "../../goal_base.h"
 
#include "../../string_func.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ bool ScriptGoal::IsValidGoal(GoalID goal_id)
 
{
 
	return ::Goal::IsValidID(goal_id);
 
}
 

	
 
/* static */ ScriptGoal::GoalID ScriptGoal::New(ScriptCompany::CompanyID company, Text *goal, GoalType type, uint32 destination)
src/script/api/script_group.cpp
Show inline comments
 
@@ -16,12 +16,14 @@
 
#include "../../string_func.h"
 
#include "../../strings_func.h"
 
#include "../../autoreplace_func.h"
 
#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);
 
	return g != NULL && g->owner == ScriptObject::GetCompany();
 
}
 

	
src/script/api/script_grouplist.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file script_grouplist.cpp Implementation of ScriptGroupList and friends. */
 

	
 
#include "../../stdafx.h"
 
#include "script_grouplist.hpp"
 
#include "../../group.h"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptGroupList::ScriptGroupList()
 
{
 
	Group *g;
 
	FOR_ALL_GROUPS(g) {
 
		if (g->owner == ScriptObject::GetCompany()) this->AddItem(g->index);
 
	}
src/script/api/script_industry.cpp
Show inline comments
 
@@ -16,12 +16,14 @@
 
#include "../../industry.h"
 
#include "../../strings_func.h"
 
#include "../../station_base.h"
 
#include "../../newgrf_industries.h"
 
#include "table/strings.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ int32 ScriptIndustry::GetIndustryCount()
 
{
 
	return (int32)::Industry::GetNumItems();
 
}
 

	
 
/* static */ bool ScriptIndustry::IsValidIndustry(IndustryID industry_id)
src/script/api/script_industrylist.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file script_industrylist.cpp Implementation of ScriptIndustryList and friends. */
 

	
 
#include "../../stdafx.h"
 
#include "script_industrylist.hpp"
 
#include "../../industry.h"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptIndustryList::ScriptIndustryList()
 
{
 
	Industry *i;
 
	FOR_ALL_INDUSTRIES(i) {
 
		this->AddItem(i->index);
 
	}
src/script/api/script_industrytype.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 
#include "script_error.hpp"
 
#include "../../strings_func.h"
 
#include "../../industry.h"
 
#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;
 

	
 
	return ::GetIndustrySpec(industry_type)->enabled;
 
}
src/script/api/script_industrytypelist.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file script_industrytypelist.cpp Implementation of ScriptIndustryTypeList. */
 

	
 
#include "../../stdafx.h"
 
#include "script_industrytypelist.hpp"
 
#include "../../industry.h"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptIndustryTypeList::ScriptIndustryTypeList()
 
{
 
	for (int i = 0; i < NUM_INDUSTRYTYPES; i++) {
 
		if (ScriptIndustryType::IsValidIndustryType(i)) this->AddItem(i);
 
	}
 
}
src/script/api/script_infrastructure.cpp
Show inline comments
 
@@ -14,12 +14,14 @@
 
#include "../../company_base.h"
 
#include "../../rail.h"
 
#include "../../road_func.h"
 
#include "../../water.h"
 
#include "../../station_func.h"
 

	
 
#include "../../safeguards.h"
 

	
 

	
 
/* static */ uint32 ScriptInfrastructure::GetRailPieceCount(ScriptCompany::CompanyID company, ScriptRail::RailType railtype)
 
{
 
	company = ScriptCompany::ResolveCompanyID(company);
 
	if (company == ScriptCompany::COMPANY_INVALID || (::RailType)railtype >= RAILTYPE_END) return 0;
 

	
src/script/api/script_list.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../../stdafx.h"
 
#include "script_list.hpp"
 
#include "../../debug.h"
 
#include "../../script/squirrel.hpp"
 

	
 
#include "../../safeguards.h"
 

	
 
/**
 
 * Base class for any ScriptList sorter.
 
 */
 
class ScriptListSorter {
 
protected:
 
	ScriptList *list;           ///< The list that's being sorted.
src/script/api/script_log.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../../stdafx.h"
 
#include "script_log.hpp"
 
#include "../../core/alloc_func.hpp"
 
#include "../../debug.h"
 
#include "../../window_func.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ void ScriptLog::Info(const char *message)
 
{
 
	ScriptLog::Log(LOG_INFO, message);
 
}
 

	
 
/* static */ void ScriptLog::Warning(const char *message)
src/script/api/script_map.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file script_map.cpp Implementation of ScriptMap. */
 

	
 
#include "../../stdafx.h"
 
#include "script_map.hpp"
 
#include "../../tile_map.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ bool ScriptMap::IsValidTile(TileIndex t)
 
{
 
	return ::IsValidTile(t);
 
}
 

	
 
/* static */ TileIndex ScriptMap::GetMapSize()
src/script/api/script_marine.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../../stdafx.h"
 
#include "script_marine.hpp"
 
#include "script_station.hpp"
 
#include "../../station_base.h"
 
#include "../../tile_cmd.h"
 

	
 
#include "../../safeguards.h"
 

	
 

	
 
/* static */ bool ScriptMarine::IsWaterDepotTile(TileIndex tile)
 
{
 
	if (!::IsValidTile(tile)) return false;
 

	
 
	return ::IsTileType(tile, MP_WATER) && ::GetWaterTileType(tile) == WATER_TILE_DEPOT;
src/script/api/script_news.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../../stdafx.h"
 
#include "script_news.hpp"
 
#include "script_error.hpp"
 
#include "../../command_type.h"
 
#include "../../string_func.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ bool ScriptNews::Create(NewsType type, Text *text, ScriptCompany::CompanyID company)
 
{
 
	CCountedPtr<Text> counter(text);
 

	
 
	EnforcePrecondition(false, text != NULL);
 
	const char *encoded = text->GetEncodedText();
src/script/api/script_object.cpp
Show inline comments
 
@@ -21,12 +21,14 @@
 

	
 
#include "../script_storage.hpp"
 
#include "../script_instance.hpp"
 
#include "../script_fatalerror.hpp"
 
#include "script_error.hpp"
 

	
 
#include "../../safeguards.h"
 

	
 
/**
 
 * Get the storage associated with the current ScriptInstance.
 
 * @return The storage.
 
 */
 
static ScriptStorage *GetStorage()
 
{
src/script/api/script_order.cpp
Show inline comments
 
@@ -18,12 +18,14 @@
 
#include "../../vehicle_base.h"
 
#include "../../roadstop_base.h"
 
#include "../../depot_base.h"
 
#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
 
 * @return the order type, or OT_END when there is no order
 
 */
 
static OrderType GetOrderTypeByTile(TileIndex t)
src/script/api/script_rail.cpp
Show inline comments
 
@@ -18,12 +18,14 @@
 
#include "../../debug.h"
 
#include "../../station_base.h"
 
#include "../../newgrf_generic.h"
 
#include "../../newgrf_station.h"
 
#include "../../strings_func.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ char *ScriptRail::GetName(RailType rail_type)
 
{
 
	if (!IsRailTypeAvailable(rail_type)) return NULL;
 

	
 
	return GetString(GetRailTypeInfo((::RailType)rail_type)->strings.menu_text);
 
}
src/script/api/script_railtypelist.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file script_railtypelist.cpp Implementation of ScriptRailTypeList and friends. */
 

	
 
#include "../../stdafx.h"
 
#include "script_railtypelist.hpp"
 
#include "../../rail.h"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptRailTypeList::ScriptRailTypeList()
 
{
 
	for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
 
		if (ScriptObject::GetCompany() == OWNER_DEITY || ::HasRailtypeAvail(ScriptObject::GetCompany(), rt)) this->AddItem(rt);
 
	}
 
}
src/script/api/script_road.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 
#include "script_map.hpp"
 
#include "script_station.hpp"
 
#include "script_cargo.hpp"
 
#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;
 
}
 

	
 
/* static */ bool ScriptRoad::IsRoadTile(TileIndex tile)
src/script/api/script_sign.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 
#include "../script_instance.hpp"
 
#include "../../signs_base.h"
 
#include "../../string_func.h"
 
#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);
 
	return si != NULL && (si->owner == ScriptObject::GetCompany() || si->owner == OWNER_DEITY);
 
}
 

	
src/script/api/script_signlist.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../../stdafx.h"
 
#include "script_signlist.hpp"
 
#include "script_sign.hpp"
 
#include "../../signs_base.h"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptSignList::ScriptSignList()
 
{
 
	Sign *s;
 
	FOR_ALL_SIGNS(s) {
 
		if (ScriptSign::IsValidSign(s->index)) this->AddItem(s->index);
 
	}
src/script/api/script_station.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 
#include "script_town.hpp"
 
#include "script_cargo.hpp"
 
#include "../../station_base.h"
 
#include "../../roadstop_base.h"
 
#include "../../town.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ bool ScriptStation::IsValidStation(StationID station_id)
 
{
 
	const Station *st = ::Station::GetIfValid(station_id);
 
	return st != NULL && (st->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY || st->owner == OWNER_NONE);
 
}
 

	
src/script/api/script_stationlist.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../../stdafx.h"
 
#include "script_stationlist.hpp"
 
#include "script_vehicle.hpp"
 
#include "../../station_base.h"
 
#include "../../vehicle_base.h"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptStationList::ScriptStationList(ScriptStation::StationType station_type)
 
{
 
	Station *st;
 
	FOR_ALL_STATIONS(st) {
 
		if ((st->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY) && (st->facilities & station_type) != 0) this->AddItem(st->index);
 
	}
src/script/api/script_story_page.cpp
Show inline comments
 
@@ -19,12 +19,14 @@
 
#include "../script_instance.hpp"
 
#include "../../story_base.h"
 
#include "../../goal_base.h"
 
#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);
 
}
 

	
 
/* static */ bool ScriptStoryPage::IsValidStoryPageElement(StoryPageElementID story_page_element_id)
src/script/api/script_storypageelementlist.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file script_storypageelementlist.cpp Implementation of ScriptStoryPageElementList and friends. */
 

	
 
#include "../../stdafx.h"
 
#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;
 

	
 
	StoryPageElement *pe;
 
	FOR_ALL_STORY_PAGE_ELEMENTS(pe) {
src/script/api/script_storypagelist.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../../stdafx.h"
 
#include "script_storypagelist.hpp"
 
#include "script_story_page.hpp"
 
#include "../../story_base.h"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptStoryPageList::ScriptStoryPageList(ScriptCompany::CompanyID company)
 
{
 
	uint8 c = company;
 
	if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY;
 

	
 
	StoryPage *p;
src/script/api/script_subsidy.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 
#include "script_industry.hpp"
 
#include "script_town.hpp"
 
#include "script_error.hpp"
 
#include "../../subsidy_base.h"
 
#include "../../station_base.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ bool ScriptSubsidy::IsValidSubsidy(SubsidyID subsidy_id)
 
{
 
	return ::Subsidy::IsValidID(subsidy_id);
 
}
 

	
 
/* static */ bool ScriptSubsidy::IsAwarded(SubsidyID subsidy_id)
src/script/api/script_subsidylist.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file script_subsidylist.cpp Implementation of ScriptSubsidyList. */
 

	
 
#include "../../stdafx.h"
 
#include "script_subsidylist.hpp"
 
#include "../../subsidy_base.h"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptSubsidyList::ScriptSubsidyList()
 
{
 
	const Subsidy *s;
 
	FOR_ALL_SUBSIDIES(s) {
 
		this->AddItem(s->index);
 
	}
src/script/api/script_testmode.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../../stdafx.h"
 
#include "script_testmode.hpp"
 
#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
 
	 *  should stop after testing the command and return with that result. */
 
	return false;
 
}
src/script/api/script_text.cpp
Show inline comments
 
@@ -14,12 +14,14 @@
 
#include "../../strings_func.h"
 
#include "script_text.hpp"
 
#include "../../table/control_codes.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptText::ScriptText(HSQUIRRELVM vm) :
 
	ZeroedMemoryAllocator()
 
{
 
	int nparam = sq_gettop(vm) - 1;
 
	if (nparam < 1) {
 
		throw sq_throwerror(vm, _SC("You need to pass at least a StringID to the constructor"));
src/script/api/script_tile.cpp
Show inline comments
 
@@ -17,12 +17,14 @@
 
#include "../../water_map.h"
 
#include "../../clear_map.h"
 
#include "../../tree_map.h"
 
#include "../../town.h"
 
#include "../../landscape.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ bool ScriptTile::IsBuildable(TileIndex tile)
 
{
 
	if (!::IsValidTile(tile)) return false;
 

	
 
	switch (::GetTileType(tile)) {
 
		default: return false;
src/script/api/script_tilelist.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../../stdafx.h"
 
#include "script_tilelist.hpp"
 
#include "script_industry.hpp"
 
#include "../../industry.h"
 
#include "../../station_base.h"
 

	
 
#include "../../safeguards.h"
 

	
 
void ScriptTileList::AddRectangle(TileIndex t1, TileIndex t2)
 
{
 
	if (!::IsValidTile(t1)) return;
 
	if (!::IsValidTile(t2)) return;
 

	
 
	TileArea ta(t1, t2);
src/script/api/script_town.cpp
Show inline comments
 
@@ -18,12 +18,14 @@
 
#include "../../string_func.h"
 
#include "../../strings_func.h"
 
#include "../../station_base.h"
 
#include "../../landscape.h"
 
#include "table/strings.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ int32 ScriptTown::GetTownCount()
 
{
 
	return (int32)::Town::GetNumItems();
 
}
 

	
 
/* static */ bool ScriptTown::IsValidTown(TownID town_id)
src/script/api/script_townlist.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file script_townlist.cpp Implementation of ScriptTownList and friends. */
 

	
 
#include "../../stdafx.h"
 
#include "script_townlist.hpp"
 
#include "../../town.h"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptTownList::ScriptTownList()
 
{
 
	Town *t;
 
	FOR_ALL_TOWNS(t) {
 
		this->AddItem(t->index);
 
	}
src/script/api/script_tunnel.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../../stdafx.h"
 
#include "script_tunnel.hpp"
 
#include "script_rail.hpp"
 
#include "../script_instance.hpp"
 
#include "../../tunnel_map.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ bool ScriptTunnel::IsTunnelTile(TileIndex tile)
 
{
 
	if (!::IsValidTile(tile)) return false;
 
	return ::IsTunnelTile(tile);
 
}
 

	
src/script/api/script_vehicle.cpp
Show inline comments
 
@@ -21,12 +21,14 @@
 
#include "../../roadveh.h"
 
#include "../../train.h"
 
#include "../../vehicle_func.h"
 
#include "../../aircraft.h"
 
#include "table/strings.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ bool ScriptVehicle::IsValidVehicle(VehicleID vehicle_id)
 
{
 
	const Vehicle *v = ::Vehicle::GetIfValid(vehicle_id);
 
	return v != NULL && (v->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY) && (v->IsPrimaryVehicle() || (v->type == VEH_TRAIN && ::Train::From(v)->IsFreeWagon()));
 
}
 

	
src/script/api/script_vehiclelist.cpp
Show inline comments
 
@@ -14,12 +14,14 @@
 
#include "script_group.hpp"
 
#include "script_map.hpp"
 
#include "script_station.hpp"
 
#include "../../depot_map.h"
 
#include "../../vehicle_base.h"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptVehicleList::ScriptVehicleList()
 
{
 
	const Vehicle *v;
 
	FOR_ALL_VEHICLES(v) {
 
		if ((v->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY) && v->IsPrimaryVehicle()) this->AddItem(v->index);
 
	}
src/script/api/script_viewport.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../../stdafx.h"
 
#include "script_viewport.hpp"
 
#include "script_game.hpp"
 
#include "script_map.hpp"
 
#include "../../viewport_func.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ void ScriptViewport::ScrollTo(TileIndex tile)
 
{
 
	if (ScriptGame::IsMultiplayer()) return;
 
	if (!ScriptMap::IsValidTile(tile)) return;
 

	
 
	ScrollMainWindowToTile(tile);
src/script/api/script_waypoint.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../../stdafx.h"
 
#include "script_waypoint.hpp"
 
#include "script_rail.hpp"
 
#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);
 
	return wp != NULL && (wp->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY || wp->owner == OWNER_NONE);
 
}
 

	
src/script/api/script_waypointlist.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../../stdafx.h"
 
#include "script_waypointlist.hpp"
 
#include "script_vehicle.hpp"
 
#include "../../vehicle_base.h"
 
#include "../../waypoint_base.h"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptWaypointList::ScriptWaypointList(ScriptWaypoint::WaypointType waypoint_type)
 
{
 
	const Waypoint *wp;
 
	FOR_ALL_WAYPOINTS(wp) {
 
		if ((wp->facilities & waypoint_type) &&
 
				(wp->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY || wp->owner == OWNER_NONE)) this->AddItem(wp->index);
src/script/api/script_window.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../../stdafx.h"
 
#include "script_window.hpp"
 
#include "script_game.hpp"
 
#include "../../window_func.h"
 
#include "../../window_gui.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/* static */ void ScriptWindow::Close(WindowClass window, uint32 number)
 
{
 
	if (ScriptGame::IsMultiplayer()) return;
 

	
 
	if (number == NUMBER_ALL) {
 
		DeleteWindowByClass((::WindowClass)window);
src/script/script_config.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "../stdafx.h"
 
#include "../settings_type.h"
 
#include "../core/random_func.hpp"
 
#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);
 
	this->name = (name == NULL) ? NULL : strdup(name);
 
	this->info = (name == NULL) ? NULL : this->FindInfo(this->name, version, force_exact_match);
 
	this->version = (info == NULL) ? -1 : info->GetVersion();
src/script/script_info.cpp
Show inline comments
 
@@ -14,12 +14,14 @@
 

	
 
#include "squirrel_helper.hpp"
 

	
 
#include "script_info.hpp"
 
#include "script_scanner.hpp"
 

	
 
#include "../safeguards.h"
 

	
 
ScriptInfo::~ScriptInfo()
 
{
 
	/* Free all allocated strings */
 
	for (ScriptConfigItemList::iterator it = this->config_list.begin(); it != this->config_list.end(); it++) {
 
		free((*it).name);
 
		free((*it).description);
src/script/script_info_dummy.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include <squirrel.h>
 
#include "../stdafx.h"
 

	
 
#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
 
 *  available, no matter what the situation is. By defining it in C++, there
 
 *  is simply no way a user can delete it, and therefore safe to use. It has
 
 *  to be noted that this Script is complete invisible for the user, and impossible
src/script/script_instance.cpp
Show inline comments
 
@@ -26,12 +26,14 @@
 
#include "api/script_log.hpp"
 

	
 
#include "../company_base.h"
 
#include "../company_func.h"
 
#include "../fileio_func.h"
 

	
 
#include "../safeguards.h"
 

	
 
ScriptStorage::~ScriptStorage()
 
{
 
	/* Free our pointers */
 
	if (event_data != NULL) ScriptEventController::FreeEventPointer();
 
	if (log_data != NULL) ScriptLog::FreeLogPointer();
 
}
src/script/script_scanner.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 
#include "../settings_type.h"
 

	
 
#include "../script/squirrel.hpp"
 
#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);
 
	this->main_script = strdup(filename);
 
	if (this->main_script == NULL) return false;
 

	
src/script/squirrel.cpp
Show inline comments
 
@@ -16,12 +16,14 @@
 
#include "../fileio_func.h"
 
#include "../string_func.h"
 
#include <sqstdaux.h>
 
#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];
 

	
 
#ifdef _SQ64
 
	scsnprintf(buf, lengthof(buf), _SC("Error %s:%ld/%ld: %s"), source, line, column, desc);
src/script/squirrel_std.cpp
Show inline comments
 
@@ -14,12 +14,14 @@
 
#include "../stdafx.h"
 
#include "../debug.h"
 
#include "squirrel_std.hpp"
 
#include "../core/alloc_func.hpp"
 
#include "../core/math_func.hpp"
 

	
 
#include "../safeguards.h"
 

	
 

	
 
SQInteger SquirrelStd::min(HSQUIRRELVM vm)
 
{
 
	SQInteger tmp1, tmp2;
 

	
 
	sq_getinteger(vm, 2, &tmp1);
src/sdl.cpp
Show inline comments
 
@@ -76,12 +76,14 @@ static const char *LoadSdlDLL()
 
	}
 
	return NULL;
 
}
 

	
 
#endif /* DYNAMICALLY_LOADED_SDL */
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Open the SDL library.
 
 * @param x The subsystem to load.
 
 */
 
const char *SdlOpen(uint32 x)
 
{
src/settings.cpp
Show inline comments
 
@@ -68,12 +68,14 @@
 
#include "void_map.h"
 
#include "station_base.h"
 

	
 
#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).
 
VehicleDefaultSettings _old_vds; ///< Used for loading default vehicles settings from old savegames
 
char *_config_file; ///< Configuration file of OpenTTD
 

	
src/settings_gui.cpp
Show inline comments
 
@@ -35,12 +35,14 @@
 
#include "blitter/factory.hpp"
 
#include "language.h"
 
#include "textfile_gui.h"
 
#include "stringfilter_type.h"
 
#include "querystring_gui.h"
 

	
 
#include "safeguards.h"
 

	
 

	
 
static const StringID _driveside_dropdown[] = {
 
	STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_LEFT,
 
	STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_RIGHT,
 
	INVALID_STRING_ID
 
};
src/settingsgen/settingsgen.cpp
Show inline comments
 
@@ -27,12 +27,14 @@
 
#ifdef stderr
 
#undef stderr
 
#endif
 
#define stderr stdout
 
#endif /* __MORPHOS__ */
 

	
 
#include "../safeguards.h"
 

	
 
/**
 
 * Report a fatal error.
 
 * @param s Format string.
 
 * @note Function does not return.
 
 */
 
void NORETURN CDECL error(const char *s, ...)
src/ship_cmd.cpp
Show inline comments
 
@@ -33,12 +33,14 @@
 
#include "company_base.h"
 
#include "tunnelbridge_map.h"
 
#include "zoom_func.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Determine the effective #WaterClass for a ship travelling on a tile.
 
 * @param tile Tile of interest
 
 * @return the waterclass to be used by the ship.
 
 */
 
WaterClass GetEffectiveWaterClass(TileIndex tile)
src/ship_gui.cpp
Show inline comments
 
@@ -18,12 +18,14 @@
 
#include "vehicle_func.h"
 
#include "spritecache.h"
 
#include "zoom_func.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Draws an image of a ship
 
 * @param v         Front vehicle
 
 * @param left      The minimum horizontal position
 
 * @param right     The maximum horizontal position
 
 * @param y         Vertical position to draw at
src/signal.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 
#include "tunnelbridge_map.h"
 
#include "vehicle_func.h"
 
#include "viewport_func.h"
 
#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
 
static const uint SIG_TBD_SIZE    = 256; ///< number of intersections - open nodes in current block
 
static const uint SIG_GLOB_SIZE   = 128; ///< number of open blocks (block can be opened more times until detected)
 
static const uint SIG_GLOB_UPDATE =  64; ///< how many items need to be in _globset to force update
src/signs.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 
#include "signs_func.h"
 
#include "strings_func.h"
 
#include "core/pool_func.hpp"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/** Initialize the sign-pool */
 
SignPool _sign_pool("Sign");
 
INSTANTIATE_POOL_METHODS(Sign)
 

	
 
/**
 
 * Creates a new sign
src/signs_cmd.cpp
Show inline comments
 
@@ -18,12 +18,14 @@
 
#include "tilehighlight_func.h"
 
#include "window_func.h"
 
#include "string_func.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/** The last built sign. */
 
SignID _new_sign_id;
 

	
 
/**
 
 * Place a sign at the given coordinates. Ownership of sign has
 
 * no effect whatsoever except for the colour the sign gets for easy recognition,
src/signs_gui.cpp
Show inline comments
 
@@ -30,12 +30,14 @@
 

	
 
#include "widgets/sign_widget.h"
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
 

	
 
#include "safeguards.h"
 

	
 
struct SignList {
 
	/**
 
	 * A GUIList contains signs and uses a StringFilter for filtering.
 
	 */
 
	typedef GUIList<const Sign *, StringFilter &> GUISignList;
 

	
src/smallmap_gui.cpp
Show inline comments
 
@@ -25,12 +25,14 @@
 
#include "company_base.h"
 

	
 
#include "smallmap_gui.h"
 

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

	
 
/** Link stat colours shown in legenda. */
 
static uint8 _linkstat_colours_in_legenda[] = {0, 1, 3, 5, 7, 9, 11};
src/sound.cpp
Show inline comments
 
@@ -18,12 +18,14 @@
 
#include "vehicle_base.h"
 

	
 
/* The type of set we're replacing */
 
#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)
 
{
 
	memset(_original_sounds, 0, sizeof(_original_sounds));
 

	
src/sound/allegro_s.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 

	
 
#include "../mixer.h"
 
#include "../debug.h"
 
#include "allegro_s.h"
 
#include <allegro.h>
 

	
 
#include "../safeguards.h"
 

	
 
static FSoundDriver_Allegro iFSoundDriver_Allegro;
 
/** The stream we are writing too */
 
static AUDIOSTREAM *_stream = NULL;
 
/** The number of samples in the buffer */
 
static int _buffer_size;
 

	
src/sound/cocoa_s.cpp
Show inline comments
 
@@ -27,12 +27,14 @@
 
#define Rect        OTTDRect
 
#define Point       OTTDPoint
 
#include <AudioUnit/AudioUnit.h>
 
#undef Rect
 
#undef Point
 

	
 
#include "../safeguards.h"
 

	
 
static FSoundDriver_Cocoa iFSoundDriver_Cocoa;
 

	
 
static AudioUnit _outputAudioUnit;
 

	
 
/* The CoreAudio callback */
 
static OSStatus audioCallback(void *inRefCon, AudioUnitRenderActionFlags *inActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList * ioData)
src/sound/null_s.cpp
Show inline comments
 
@@ -9,8 +9,10 @@
 

	
 
/** @file null_s.cpp The sound driver that doesn't produce sound. */
 

	
 
#include "../stdafx.h"
 
#include "null_s.h"
 

	
 
#include "../safeguards.h"
 

	
 
/** The factory for the null sound driver. */
 
static FSoundDriver_Null iFSoundDriver_Null;
src/sound/sdl_s.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 

	
 
#include "../mixer.h"
 
#include "../sdl.h"
 
#include "sdl_s.h"
 
#include <SDL.h>
 

	
 
#include "../safeguards.h"
 

	
 
/** Factory for the SDL sound driver. */
 
static FSoundDriver_SDL iFSoundDriver_SDL;
 

	
 
/**
 
 * Callback that fills the sound buffer.
 
 * @param userdata Ignored.
src/sound/win32_s.cpp
Show inline comments
 
@@ -17,12 +17,14 @@
 
#include "../core/bitmath_func.hpp"
 
#include "../core/math_func.hpp"
 
#include "win32_s.h"
 
#include <windows.h>
 
#include <mmsystem.h>
 

	
 
#include "../safeguards.h"
 

	
 
static FSoundDriver_Win32 iFSoundDriver_Win32;
 

	
 
static HWAVEOUT _waveout;
 
static WAVEHDR _wave_hdr[2];
 
static int _bufsize;
 
static HANDLE _thread;
src/sprite.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 
#include "sprite.h"
 
#include "viewport_func.h"
 
#include "landscape.h"
 
#include "spritecache.h"
 
#include "zoom_func.h"
 

	
 
#include "safeguards.h"
 

	
 

	
 
/**
 
 * Draws a tile sprite sequence.
 
 * @param ti The tile to draw on
 
 * @param dts Sprite and subsprites to draw
 
 * @param to The transparency bit that toggles drawing of these sprites
src/spritecache.cpp
Show inline comments
 
@@ -21,12 +21,14 @@
 
#include "core/mem_func.hpp"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "table/palette_convert.h"
 

	
 
#include "safeguards.h"
 

	
 
/* Default of 4MB spritecache */
 
uint _sprite_cache_size = 4;
 

	
 
typedef SimpleTinyEnumT<SpriteType, byte> SpriteTypeByte;
 

	
 
struct SpriteCache {
src/spriteloader/grf.cpp
Show inline comments
 
@@ -18,12 +18,14 @@
 
#include "../error.h"
 
#include "../core/math_func.hpp"
 
#include "../core/alloc_type.hpp"
 
#include "../core/bitmath_func.hpp"
 
#include "grf.hpp"
 

	
 
#include "../safeguards.h"
 

	
 
extern const byte _palmap_w2d[];
 

	
 
/** The different colour components a sprite can have. */
 
enum SpriteColourComponent {
 
	SCC_RGB   = 1 << 0, ///< Sprite has RGB.
 
	SCC_ALPHA = 1 << 1, ///< Sprite has alpha.
src/station.cpp
Show inline comments
 
@@ -26,12 +26,14 @@
 
#include "core/random_func.hpp"
 
#include "linkgraph/linkgraph.h"
 
#include "linkgraph/linkgraphschedule.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/** The pool of stations. */
 
StationPool _station_pool("Station");
 
INSTANTIATE_POOL_METHODS(Station)
 

	
 
typedef StationIDStack::SmallStackPool StationIDStackPool;
 
template<> StationIDStackPool StationIDStack::_pool = StationIDStackPool();
src/station_cmd.cpp
Show inline comments
 
@@ -53,12 +53,14 @@
 
#include "linkgraph/linkgraph_base.h"
 
#include "linkgraph/refresh.h"
 
#include "widgets/station_widget.h"
 

	
 
#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.
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return true if and only if the tile is a hangar.
 
 */
src/station_gui.cpp
Show inline comments
 
@@ -36,12 +36,14 @@
 

	
 
#include "table/strings.h"
 

	
 
#include <set>
 
#include <vector>
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Calculates and draws the accepted or supplied cargo around the selected tile(s)
 
 * @param left x position where the string is to be drawn
 
 * @param right the right most position to draw on
 
 * @param top y position where the string is to be drawn
 
 * @param sct which type of cargo is to be displayed (passengers/non-passengers)
src/statusbar_gui.cpp
Show inline comments
 
@@ -28,12 +28,14 @@
 

	
 
#include "widgets/statusbar_widget.h"
 

	
 
#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));
 
	StringID str = ni->string_id;
 

	
 
	char buf[512];
src/story.cpp
Show inline comments
 
@@ -21,12 +21,14 @@
 
#include "tile_map.h"
 
#include "goal_type.h"
 
#include "goal_base.h"
 
#include "window_func.h"
 
#include "gui.h"
 

	
 
#include "safeguards.h"
 

	
 

	
 
StoryPageElementID _new_story_page_element_id;
 
StoryPageID _new_story_page_id;
 
uint32 _story_page_element_next_sort_value;
 
uint32 _story_page_next_sort_value;
 

	
src/story_gui.cpp
Show inline comments
 
@@ -28,12 +28,14 @@
 

	
 
#include "widgets/story_widget.h"
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
 

	
 
#include "safeguards.h"
 

	
 
typedef GUIList<const StoryPage*> GUIStoryPageList;
 
typedef GUIList<const StoryPageElement*> GUIStoryPageElementList;
 

	
 
struct StoryBookWindow : Window {
 
protected:
 
	Scrollbar *vscroll;                ///< Scrollbar of the page text.
src/strgen/strgen.cpp
Show inline comments
 
@@ -36,12 +36,14 @@
 
#endif
 
#define stderr stdout
 
#endif /* __MORPHOS__ */
 

	
 
#include "../table/strgen_tables.h"
 

	
 
#include "../safeguards.h"
 

	
 

	
 
#ifdef _MSC_VER
 
# define LINE_NUM_FMT(s) "%s (%d): warning: %s (" s ")\n"
 
#else
 
# define LINE_NUM_FMT(s) "%s:%d: " s ": %s\n"
 
#endif
src/strgen/strgen_base.cpp
Show inline comments
 
@@ -16,12 +16,14 @@
 

	
 
#include "strgen.h"
 

	
 

	
 
#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
 
static bool _translation;             ///< Is the current file actually a translation or not
 
const char *_file = "(unknown file)"; ///< The filename of the input, so we can refer to it in errors/warnings
 
int _cur_line;                        ///< The current line we're parsing in the input file
src/string.cpp
Show inline comments
 
@@ -29,12 +29,14 @@
 
/* Required by strnatcmp. */
 
#include <unicode/ustring.h>
 
#include "language.h"
 
#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.
 
 * - return gives the amount of characters added, not what it would add.
 
 * @param str    buffer to write to up to last
 
 * @param last   last character we may write to
src/stringfilter.cpp
Show inline comments
 
@@ -12,12 +12,14 @@
 
#include "stdafx.h"
 
#include "string_func.h"
 
#include "strings_func.h"
 
#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 = '\'';
 
static const WChar STATE_QUOTE2 = '"';
 

	
 
/**
src/strings.cpp
Show inline comments
 
@@ -38,12 +38,14 @@
 
#include "game/game_text.hpp"
 
#include <stack>
 

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

	
 
TextDirection _current_text_dir; ///< Text direction of the currently selected language.
 

	
src/subsidy.cpp
Show inline comments
 
@@ -24,12 +24,14 @@
 
#include "core/random_func.hpp"
 
#include "game/game.hpp"
 
#include "command_func.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
SubsidyPool _subsidy_pool("Subsidy"); ///< Pool for the subsidies.
 
INSTANTIATE_POOL_METHODS(Subsidy)
 

	
 
/**
 
 * Marks subsidy as awarded, creates news and AI event
 
 * @param company awarded company
src/subsidy_gui.cpp
Show inline comments
 
@@ -22,12 +22,14 @@
 
#include "core/geometry_func.hpp"
 

	
 
#include "widgets/subsidy_widget.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
struct SubsidyListWindow : Window {
 
	Scrollbar *vscroll;
 

	
 
	SubsidyListWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
 
	{
 
		this->CreateNestedTree();
src/terraform_cmd.cpp
Show inline comments
 
@@ -18,12 +18,14 @@
 
#include "object_base.h"
 
#include "company_base.h"
 
#include "company_func.h"
 

	
 
#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.
 
 * This affects all corners with a manhatten distance smaller than MAX_TILE_HEIGHT to one of the initial 4 corners.
 
 * Their maximal amount is computed to 4 * \sum_{i=1}^{h_max} i  =  2 * h_max * (h_max + 1).
 
 */
src/terraform_gui.cpp
Show inline comments
 
@@ -34,12 +34,14 @@
 
#include "terraform_gui.h"
 

	
 
#include "widgets/terraform_widget.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
void CcTerraform(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (result.Succeeded()) {
 
		if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT_OTHER, tile);
 
	} else {
 
		extern TileIndex _terraform_err_tile;
src/textbuf.cpp
Show inline comments
 
@@ -17,12 +17,14 @@
 
#include "strings_func.h"
 
#include "gfx_type.h"
 
#include "gfx_func.h"
 
#include "window_func.h"
 
#include "core/alloc_func.hpp"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Try to retrieve the current clipboard contents.
 
 *
 
 * @note OS-specific function.
 
 * @return True if some text could be retrieved.
 
 */
src/texteff.cpp
Show inline comments
 
@@ -14,12 +14,14 @@
 
#include "transparency.h"
 
#include "strings_func.h"
 
#include "core/smallvec_type.hpp"
 
#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
 
	uint64 params_2;     ///< second DParam parameter
 
	StringID string_id;  ///< String to draw for the text effect, if INVALID_STRING_ID then it's not valid
 
	uint8 duration;      ///< How long the text effect should stay, in ticks (applies only when mode == TE_RISING)
src/textfile_gui.cpp
Show inline comments
 
@@ -18,12 +18,14 @@
 
#include "textfile_gui.h"
 

	
 
#include "widgets/misc_widget.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/** Widgets for the textfile window. */
 
static const NWidgetPart _nested_textfile_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_MAUVE),
 
		NWidget(WWT_CAPTION, COLOUR_MAUVE, WID_TF_CAPTION), SetDataTip(STR_NULL, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_TEXTBTN, COLOUR_MAUVE, WID_TF_WRAPTEXT), SetDataTip(STR_TEXTFILE_WRAP_TEXT, STR_TEXTFILE_WRAP_TEXT_TOOLTIP),
src/tgp.cpp
Show inline comments
 
@@ -14,12 +14,14 @@
 
#include "clear_map.h"
 
#include "void_map.h"
 
#include "genworld.h"
 
#include "core/random_func.hpp"
 
#include "landscape_type.h"
 

	
 
#include "safeguards.h"
 

	
 
/*
 
 *
 
 * Quickie guide to Perlin Noise
 
 * Perlin noise is a predictable pseudo random number sequence. By generating
 
 * it in 2 dimensions, it becomes a useful random map that, for a given seed
 
 * and starting X & Y, is entirely predictable. On the face of it, that may not
src/thread/thread_morphos.cpp
Show inline comments
 
@@ -20,12 +20,14 @@
 
#include <exec/rawfmt.h>
 
#include <dos/dostags.h>
 

	
 
#include <proto/dos.h>
 
#include <proto/exec.h>
 

	
 
#include "../safeguards.h"
 

	
 
/**
 
 *  avoid name clashes with MorphOS API functions
 
 */
 
#undef Exit
 
#undef Wait
 

	
src/thread/thread_none.cpp
Show inline comments
 
@@ -9,12 +9,14 @@
 

	
 
/** @file thread_none.cpp No-Threads-Available implementation of Threads */
 

	
 
#include "../stdafx.h"
 
#include "thread.h"
 

	
 
#include "../safeguards.h"
 

	
 
/* static */ bool ThreadObject::New(OTTDThreadFunc proc, void *param, ThreadObject **thread)
 
{
 
	if (thread != NULL) *thread = NULL;
 
	return false;
 
}
 

	
src/thread/thread_os2.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 
#include "thread.h"
 

	
 
#define INCL_DOS
 
#include <os2.h>
 
#include <process.h>
 

	
 
#include "../safeguards.h"
 

	
 
/**
 
 * OS/2 version for ThreadObject.
 
 */
 
class ThreadObject_OS2 : public ThreadObject {
 
private:
 
	TID thread;          ///< System thread identifier.
src/thread/thread_pthread.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../stdafx.h"
 
#include "thread.h"
 
#include <pthread.h>
 
#include <errno.h>
 

	
 
#include "../safeguards.h"
 

	
 
/**
 
 * POSIX pthread version for ThreadObject.
 
 */
 
class ThreadObject_pthread : public ThreadObject {
 
private:
 
	pthread_t thread;    ///< System thread identifier.
src/thread/thread_win32.cpp
Show inline comments
 
@@ -14,12 +14,14 @@
 
#include "../debug.h"
 
#include "../core/alloc_func.hpp"
 
#include <stdlib.h>
 
#include <windows.h>
 
#include <process.h>
 

	
 
#include "../safeguards.h"
 

	
 
/**
 
 * Win32 thread version for ThreadObject.
 
 */
 
class ThreadObject_Win32 : public ThreadObject {
 
private:
 
	HANDLE thread;       ///< System thread identifier.
src/tile_map.cpp
Show inline comments
 
@@ -9,12 +9,14 @@
 

	
 
/** @file tile_map.cpp Global tile accessors. */
 

	
 
#include "stdafx.h"
 
#include "tile_map.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Return the slope of a given tile
 
 * @param tile Tile to compute slope of
 
 * @param h    If not \c NULL, pointer to storage of z height
 
 * @return Slope of the tile, except for the HALFTILE part
 
 */
src/tilearea.cpp
Show inline comments
 
@@ -10,12 +10,14 @@
 
/** @file tilearea.cpp Handling of tile areas. */
 

	
 
#include "stdafx.h"
 

	
 
#include "tilearea_type.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Construct this tile area based on two points.
 
 * @param start the start of the area
 
 * @param end   the end of the area
 
 */
 
OrthogonalTileArea::OrthogonalTileArea(TileIndex start, TileIndex end)
src/timetable_cmd.cpp
Show inline comments
 
@@ -17,12 +17,14 @@
 
#include "vehicle_base.h"
 
#include "cmd_helper.h"
 
#include "core/sort_func.hpp"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Change/update a particular timetable entry.
 
 * @param v            The vehicle to change the timetable of.
 
 * @param order_number The index of the timetable in the order list.
 
 * @param val          The new data of the timetable entry.
 
 * @param mtf          Which part of the timetable entry to change.
src/timetable_gui.cpp
Show inline comments
 
@@ -27,12 +27,14 @@
 

	
 
#include "widgets/timetable_widget.h"
 

	
 
#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
 
	Ticks departure; ///< The departure time
 
};
 

	
src/toolbar_gui.cpp
Show inline comments
 
@@ -50,12 +50,14 @@
 
#include "widgets/toolbar_widget.h"
 

	
 
#include "network/network.h"
 
#include "network/network_gui.h"
 
#include "network/network_func.h"
 

	
 
#include "safeguards.h"
 

	
 

	
 
RailType _last_built_railtype;
 
RoadType _last_built_roadtype;
 

	
 
static ScreenshotType _confirmed_screenshot_type; ///< Screenshot type the current query is about to confirm.
 

	
src/town_cmd.cpp
Show inline comments
 
@@ -47,12 +47,14 @@
 
#include "ai/ai.hpp"
 
#include "game/game.hpp"
 

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

	
 
/* Initialize the town-pool */
 
TownPool _town_pool("Town");
 
INSTANTIATE_POOL_METHODS(Town)
src/town_gui.cpp
Show inline comments
 
@@ -34,12 +34,14 @@
 
#include "widgets/dropdown_func.h"
 

	
 
#include "widgets/town_widget.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
typedef GUIList<const Town*> GUITownList;
 

	
 
static const NWidgetPart _nested_town_authority_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
 
		NWidget(WWT_CAPTION, COLOUR_BROWN, WID_TA_CAPTION), SetDataTip(STR_LOCAL_AUTHORITY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
src/townname.cpp
Show inline comments
 
@@ -17,12 +17,14 @@
 
#include "core/random_func.hpp"
 
#include "genworld.h"
 
#include "gfx_layout.h"
 

	
 
#include "table/townname.h"
 

	
 
#include "safeguards.h"
 

	
 

	
 
/**
 
 * Initializes this struct from town data
 
 * @param t town for which we will be printing name later
 
 */
 
TownNameParams::TownNameParams(const Town *t) :
src/train_cmd.cpp
Show inline comments
 
@@ -36,12 +36,14 @@
 
#include "zoom_func.h"
 
#include "newgrf_debug.h"
 

	
 
#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.
 
static TileIndex TrainApproachingCrossingTile(const Train *v);
 
static void CheckIfTrainNeedsService(Train *v);
 
static void CheckNextTrainTile(Train *v);
src/train_gui.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 
#include "train.h"
 
#include "strings_func.h"
 
#include "vehicle_func.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Callback for building wagons.
 
 * @param result The result of the command.
 
 * @param tile   The tile the command was executed on.
 
 * @param p1 Additional data for the command (for the #CommandProc)
 
 * @param p2 Additional data for the command (for the #CommandProc)
src/transparency_gui.cpp
Show inline comments
 
@@ -17,12 +17,14 @@
 

	
 
#include "widgets/transparency_widget.h"
 

	
 
#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.
 
byte _display_opt; ///< What do we want to draw/do?
 

	
 
class TransparenciesWindow : public Window
src/tree_cmd.cpp
Show inline comments
 
@@ -26,12 +26,14 @@
 
#include "newgrf_generic.h"
 

	
 
#include "table/strings.h"
 
#include "table/tree_land.h"
 
#include "table/clear_land.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * List of tree placer algorithm.
 
 *
 
 * This enumeration defines all possible tree placer algorithm in the game.
 
 */
 
enum TreePlacer {
src/tree_gui.cpp
Show inline comments
 
@@ -22,12 +22,14 @@
 
#include "widgets/tree_widget.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "table/tree_land.h"
 

	
 
#include "safeguards.h"
 

	
 
void PlaceTreesRandomly();
 

	
 
/** Tree Sprites with their palettes */
 
const PalSpriteID tree_sprites[] = {
 
	{ 1621, PAL_NONE }, { 1587, PAL_NONE }, { 1656, PAL_NONE }, { 1579, PAL_NONE },
 
	{ 1607, PAL_NONE }, { 1593, PAL_NONE }, { 1614, PAL_NONE }, { 1586, PAL_NONE },
src/tunnel_map.cpp
Show inline comments
 
@@ -9,12 +9,14 @@
 

	
 
/** @file tunnel_map.cpp Map accessors for tunnels. */
 

	
 
#include "stdafx.h"
 
#include "tunnelbridge_map.h"
 

	
 
#include "safeguards.h"
 

	
 

	
 
/**
 
 * Gets the other end of the tunnel. Where a vehicle would reappear when it
 
 * enters at the given tile.
 
 * @param tile the tile to search from.
 
 * @return the tile of the other end of the tunnel.
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -41,12 +41,14 @@
 
#include "water.h"
 
#include "company_gui.h"
 

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

	
 
/** Z position of the bridge sprites relative to bridge height (downwards) */
 
static const int BRIDGE_Z_START = 3;
 

	
src/vehicle.cpp
Show inline comments
 
@@ -52,12 +52,14 @@
 
#include "gamelog.h"
 
#include "linkgraph/linkgraph.h"
 
#include "linkgraph/refresh.h"
 

	
 
#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;
 
uint16 _returned_refit_capacity;      ///< Stores the capacity after a refit operation.
 
uint16 _returned_mail_refit_capacity; ///< Stores the mail capacity after a refit operation (Aircraft only).
 

	
src/vehicle_cmd.cpp
Show inline comments
 
@@ -31,12 +31,14 @@
 
#include "ship.h"
 
#include "newgrf.h"
 
#include "company_base.h"
 

	
 
#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),
 
	CMD_BUILD_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_ROAD_VEHICLE),
 
	CMD_BUILD_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_SHIP),
 
	CMD_BUILD_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_AIRCRAFT),
src/vehicle_gui.cpp
Show inline comments
 
@@ -36,12 +36,14 @@
 
#include "company_base.h"
 
#include "engine_func.h"
 
#include "station_base.h"
 
#include "tilehighlight_func.h"
 
#include "zoom_func.h"
 

	
 
#include "safeguards.h"
 

	
 

	
 
Sorting _sorting;
 

	
 
static GUIVehicleList::SortFunction VehicleNumberSorter;
 
static GUIVehicleList::SortFunction VehicleNameSorter;
 
static GUIVehicleList::SortFunction VehicleAgeSorter;
src/vehiclelist.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "stdafx.h"
 
#include "train.h"
 
#include "vehiclelist.h"
 
#include "group.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Pack a VehicleListIdentifier in a single uint32.
 
 * @return The packed identifier.
 
 */
 
uint32 VehicleListIdentifier::Pack()
 
{
src/video/allegro_v.cpp
Show inline comments
 
@@ -24,12 +24,14 @@
 
#include "../network/network.h"
 
#include "../core/random_func.hpp"
 
#include "../core/math_func.hpp"
 
#include "allegro_v.h"
 
#include <allegro.h>
 

	
 
#include "../safeguards.h"
 

	
 
#ifdef _DEBUG
 
/* Allegro replaces SEGV/ABRT signals meaning that the debugger will never
 
 * be triggered, so rereplace the signals and make the debugger useful. */
 
#include <signal.h>
 
#endif
 

	
src/video/dedicated_v.cpp
Show inline comments
 
@@ -128,12 +128,14 @@ static void CloseWindowsConsoleThread()
 
	CloseHandle(_hWaitForInputHandling);
 
	DEBUG(driver, 2, "Windows console thread shut down");
 
}
 

	
 
#endif
 

	
 
#include "../safeguards.h"
 

	
 

	
 
static void *_dedicated_video_mem;
 

	
 
/* Whether a fork has been done. */
 
bool _dedicated_forks;
 

	
src/video/null_v.cpp
Show inline comments
 
@@ -11,12 +11,14 @@
 

	
 
#include "../stdafx.h"
 
#include "../gfx_func.h"
 
#include "../blitter/factory.hpp"
 
#include "null_v.h"
 

	
 
#include "../safeguards.h"
 

	
 
/** Factory for the null video driver. */
 
static FVideoDriver_Null iFVideoDriver_Null;
 

	
 
const char *VideoDriver_Null::Start(const char * const *parm)
 
{
 
#ifdef _MSC_VER
src/video/sdl_v.cpp
Show inline comments
 
@@ -23,12 +23,14 @@
 
#include "../core/random_func.hpp"
 
#include "../core/math_func.hpp"
 
#include "../fileio_func.h"
 
#include "sdl_v.h"
 
#include <SDL.h>
 

	
 
#include "../safeguards.h"
 

	
 
static FVideoDriver_SDL iFVideoDriver_SDL;
 

	
 
static SDL_Surface *_sdl_screen;
 
static SDL_Surface *_sdl_realscreen;
 
static bool _all_modes;
 

	
src/video/win32_v.cpp
Show inline comments
 
@@ -24,12 +24,14 @@
 
#include "../window_gui.h"
 
#include "../window_func.h"
 
#include "win32_v.h"
 
#include <windows.h>
 
#include <imm.h>
 

	
 
#include "../safeguards.h"
 

	
 
/* Missing define in MinGW headers. */
 
#ifndef MAPVK_VK_TO_CHAR
 
#define MAPVK_VK_TO_CHAR    (2)
 
#endif
 

	
 
static struct {
src/viewport.cpp
Show inline comments
 
@@ -48,12 +48,14 @@
 
#include "linkgraph/linkgraph_gui.h"
 
#include "viewport_sprite_sorter.h"
 

	
 
#include "table/strings.h"
 
#include "table/palettes.h"
 

	
 
#include "safeguards.h"
 

	
 
Point _tile_fract_coords;
 

	
 
struct StringSpriteToDraw {
 
	StringID string;
 
	Colours colour;
 
	int32 x;
src/viewport_gui.cpp
Show inline comments
 
@@ -19,12 +19,14 @@
 

	
 
#include "widgets/viewport_widget.h"
 

	
 
#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),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY, WID_EV_CAPTION), SetDataTip(STR_EXTRA_VIEW_PORT_TITLE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_SHADEBOX, COLOUR_GREY),
src/viewport_sprite_sorter_sse4.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 

	
 
#include "stdafx.h"
 
#include "cpu.h"
 
#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
 
#else
 
	#define LOAD_128 _mm_loadu_si128
 
#endif
src/void_cmd.cpp
Show inline comments
 
@@ -14,12 +14,14 @@
 
#include "command_func.h"
 
#include "viewport_func.h"
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
 

	
 
#include "safeguards.h"
 

	
 
static void DrawTile_Void(TileInfo *ti)
 
{
 
	DrawGroundSprite(SPR_SHADOW_CELL, PAL_NONE);
 
}
 

	
 

	
src/water_cmd.cpp
Show inline comments
 
@@ -39,12 +39,14 @@
 
#include "company_base.h"
 
#include "company_gui.h"
 
#include "newgrf_generic.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Describes from which directions a specific slope can be flooded (if the tile is floodable at all).
 
 */
 
static const uint8 _flood_from_dirs[] = {
 
	(1 << DIR_NW) | (1 << DIR_SW) | (1 << DIR_SE) | (1 << DIR_NE), // SLOPE_FLAT
 
	(1 << DIR_NE) | (1 << DIR_SE),                                 // SLOPE_W
src/waypoint.cpp
Show inline comments
 
@@ -13,12 +13,14 @@
 

	
 
#include "order_func.h"
 
#include "window_func.h"
 
#include "newgrf_station.h"
 
#include "waypoint_base.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Draw a waypoint
 
 * @param x coordinate
 
 * @param y coordinate
 
 * @param stat_id station id
 
 * @param railtype RailType to use for
src/waypoint_cmd.cpp
Show inline comments
 
@@ -29,12 +29,14 @@
 
#include "company_base.h"
 
#include "water.h"
 
#include "company_gui.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Update the virtual coords needed to draw the waypoint sign.
 
 */
 
void Waypoint::UpdateVirtCoord()
 
{
 
	Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE);
src/waypoint_gui.cpp
Show inline comments
 
@@ -24,12 +24,14 @@
 
#include "waypoint_base.h"
 

	
 
#include "widgets/waypoint_widget.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/** GUI for accessing waypoints and buoys. */
 
struct WaypointWindow : Window {
 
private:
 
	VehicleType vt; ///< Vehicle type using the waypoint.
 
	Waypoint *wp;   ///< Waypoint displayed by the window.
 

	
src/widget.cpp
Show inline comments
 
@@ -21,12 +21,14 @@
 
#include "querystring_gui.h"
 

	
 
#include "table/sprites.h"
 
#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.
 

	
 
/**
 
 * Compute the vertical position of the draggable part of scrollbar
 
 * @param sb     Scrollbar list data
src/widgets/dropdown.cpp
Show inline comments
 
@@ -15,12 +15,14 @@
 
#include "../strings_func.h"
 
#include "../window_func.h"
 
#include "dropdown_type.h"
 

	
 
#include "dropdown_widget.h"
 

	
 
#include "../safeguards.h"
 

	
 

	
 
void DropDownListItem::Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const
 
{
 
	int c1 = _colour_gradient[bg_colour][3];
 
	int c2 = _colour_gradient[bg_colour][7];
 

	
src/window.cpp
Show inline comments
 
@@ -34,12 +34,14 @@
 
#include "toolbar_gui.h"
 
#include "statusbar_gui.h"
 
#include "error.h"
 
#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.
 
	VA_MAIN_VIEWPORT_FULLSCREEN,  //!< Scroll main viewport at edge when using fullscreen.
 
	VA_MAIN_VIEWPORT,             //!< Scroll main viewport at edge.
 
	VA_EVERY_VIEWPORT,            //!< Scroll all viewports at their edges.
0 comments (0 inline, 0 general)