(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

This commit is contained in:
rubidium
2014-04-23 20:13:33 +00:00
parent dd84952d15
commit 2be4215f43
402 changed files with 873 additions and 1 deletions

View File

@@ -12,6 +12,8 @@
#include "../../stdafx.h"
#include "script_accounting.hpp"
#include "../../safeguards.h"
Money ScriptAccounting::GetCosts()
{
return this->GetDoCommandCosts();

View File

@@ -15,6 +15,8 @@
#include "../../network/network_admin.h"
#include "../script_instance.hpp"
#include "../../safeguards.h"
/* static */ bool ScriptAdmin::MakeJSON(HSQUIRRELVM vm, SQInteger index, int max_depth, std::string &data)
{
if (max_depth == 0) {

View File

@@ -15,6 +15,8 @@
#include "../../station_base.h"
#include "../../town.h"
#include "../../safeguards.h"
/* static */ bool ScriptAirport::IsValidAirportType(AirportType type)
{
return IsAirportInformationAvailable(type) && ::AirportSpec::Get(type)->IsAvailable();

View File

@@ -15,6 +15,8 @@
#include "../../network/network.h"
#include "../../core/random_func.hpp"
#include "../../safeguards.h"
/* static */ uint32 ScriptBase::Rand()
{
/* We pick RandomRange if we are in SP (so when saved, we do the same over and over)

View File

@@ -17,6 +17,8 @@
#include "../../strings_func.h"
#include "table/strings.h"
#include "../../safeguards.h"
/* static */ bool ScriptBaseStation::IsValidBaseStation(StationID station_id)
{
const BaseStation *st = ::BaseStation::GetIfValid(station_id);

View File

@@ -17,6 +17,8 @@
#include "../../strings_func.h"
#include "../../date_func.h"
#include "../../safeguards.h"
/* static */ bool ScriptBridge::IsValidBridge(BridgeID bridge_id)
{
return bridge_id < MAX_BRIDGES && ::GetBridgeSpec(bridge_id)->avail_year <= _cur_year;

View File

@@ -14,6 +14,8 @@
#include "script_bridge.hpp"
#include "../../bridge.h"
#include "../../safeguards.h"
ScriptBridgeList::ScriptBridgeList()
{
for (byte j = 0; j < MAX_BRIDGES; j++) {

View File

@@ -15,6 +15,8 @@
#include "../../core/bitmath_func.hpp"
#include "../../settings_type.h"
#include "../../safeguards.h"
/* static */ bool ScriptCargo::IsValidCargo(CargoID cargo_type)
{
return (cargo_type < NUM_CARGO && ::CargoSpec::Get(cargo_type)->IsValid());

View File

@@ -17,6 +17,8 @@
#include "../../industry.h"
#include "../../station_base.h"
#include "../../safeguards.h"
ScriptCargoList::ScriptCargoList()
{
const CargoSpec *cs;

View File

@@ -12,6 +12,8 @@
#include "../../stdafx.h"
#include "script_cargomonitor.hpp"
#include "../../safeguards.h"
/* static */ uint32 ScriptCargoMonitor::GetTownDeliveryAmount(ScriptCompany::CompanyID company, CargoID cargo, TownID town_id, bool keep_monitoring)
{
CargoMonitorID monitor = EncodeCargoTownMonitor(static_cast<CompanyID>(company), cargo, town_id);

View File

@@ -24,6 +24,8 @@
#include "../../settings_func.h"
#include "table/strings.h"
#include "../../safeguards.h"
/* static */ ScriptCompany::CompanyID ScriptCompany::ResolveCompanyID(ScriptCompany::CompanyID company)
{
if (company == COMPANY_SELF) {

View File

@@ -12,6 +12,8 @@
#include "../../stdafx.h"
#include "script_companymode.hpp"
#include "../../safeguards.h"
ScriptCompanyMode::ScriptCompanyMode(int company)
{
if (company < OWNER_BEGIN || company >= MAX_COMPANIES) company = INVALID_COMPANY;

View File

@@ -24,6 +24,8 @@
#include "../../settings_type.h"
#include "../../network/network.h"
#include "../../safeguards.h"
/* static */ void ScriptController::SetCommandDelay(int ticks)
{
if (ticks <= 0) return;

View File

@@ -14,6 +14,8 @@
#include "script_date.hpp"
#include "../../date_func.h"
#include "../../safeguards.h"
/* static */ bool ScriptDate::IsValidDate(Date date)
{
return date >= 0;

View File

@@ -14,6 +14,8 @@
#include "../../depot_base.h"
#include "../../station_base.h"
#include "../../safeguards.h"
ScriptDepotList::ScriptDepotList(ScriptTile::TransportType transport_type)
{
::TileType tile_type;

View File

@@ -20,6 +20,8 @@
#include "../../articulated_vehicles.h"
#include "table/strings.h"
#include "../../safeguards.h"
/* static */ bool ScriptEngine::IsValidEngine(EngineID engine_id)
{
const Engine *e = ::Engine::GetIfValid(engine_id);

View File

@@ -13,6 +13,8 @@
#include "script_enginelist.hpp"
#include "../../engine_base.h"
#include "../../safeguards.h"
ScriptEngineList::ScriptEngineList(ScriptVehicle::VehicleType vehicle_type)
{
Engine *e;

View File

@@ -13,6 +13,8 @@
#include "script_error.hpp"
#include "../../core/bitmath_func.hpp"
#include "../../safeguards.h"
ScriptError::ScriptErrorMap ScriptError::error_map = ScriptError::ScriptErrorMap();
ScriptError::ScriptErrorMapString ScriptError::error_map_string = ScriptError::ScriptErrorMapString();

View File

@@ -14,6 +14,8 @@
#include <queue>
#include "../../safeguards.h"
/** The queue of events for a script. */
struct ScriptEventData {
std::queue<ScriptEvent *> stack; ///< The actual queue.

View File

@@ -19,6 +19,8 @@
#include "../../articulated_vehicles.h"
#include "table/strings.h"
#include "../../safeguards.h"
bool ScriptEventEnginePreview::IsEngineValid() const
{
const Engine *e = ::Engine::GetIfValid(this->engine);

View File

@@ -14,6 +14,8 @@
#include "../script_instance.hpp"
#include "../script_fatalerror.hpp"
#include "../../safeguards.h"
bool ScriptExecMode::ModeProc()
{
/* In execution mode we only return 'true', telling the DoCommand it

View File

@@ -15,6 +15,8 @@
#include "../../settings_type.h"
#include "../../network/network.h"
#include "../../safeguards.h"
/* static */ bool ScriptGame::Pause()
{
return ScriptObject::DoCommand(0, PM_PAUSED_GAME_SCRIPT, 1, CMD_PAUSE);

View File

@@ -15,6 +15,8 @@
#include "../../settings_type.h"
#include "../../command_type.h"
#include "../../safeguards.h"
/* static */ bool ScriptGameSettings::IsValid(const char *setting)
{
uint i;

View File

@@ -20,6 +20,8 @@
#include "../../goal_base.h"
#include "../../string_func.h"
#include "../../safeguards.h"
/* static */ bool ScriptGoal::IsValidGoal(GoalID goal_id)
{
return ::Goal::IsValidID(goal_id);

View File

@@ -19,6 +19,8 @@
#include "../../settings_func.h"
#include "table/strings.h"
#include "../../safeguards.h"
/* static */ bool ScriptGroup::IsValidGroup(GroupID group_id)
{
const Group *g = ::Group::GetIfValid(group_id);

View File

@@ -13,6 +13,8 @@
#include "script_grouplist.hpp"
#include "../../group.h"
#include "../../safeguards.h"
ScriptGroupList::ScriptGroupList()
{
Group *g;

View File

@@ -19,6 +19,8 @@
#include "../../newgrf_industries.h"
#include "table/strings.h"
#include "../../safeguards.h"
/* static */ int32 ScriptIndustry::GetIndustryCount()
{
return (int32)::Industry::GetNumItems();

View File

@@ -13,6 +13,8 @@
#include "script_industrylist.hpp"
#include "../../industry.h"
#include "../../safeguards.h"
ScriptIndustryList::ScriptIndustryList()
{
Industry *i;

View File

@@ -18,6 +18,8 @@
#include "../../newgrf_industries.h"
#include "../../core/random_func.hpp"
#include "../../safeguards.h"
/* static */ bool ScriptIndustryType::IsValidIndustryType(IndustryType industry_type)
{
if (industry_type >= NUM_INDUSTRYTYPES) return false;

View File

@@ -13,6 +13,8 @@
#include "script_industrytypelist.hpp"
#include "../../industry.h"
#include "../../safeguards.h"
ScriptIndustryTypeList::ScriptIndustryTypeList()
{
for (int i = 0; i < NUM_INDUSTRYTYPES; i++) {

View File

@@ -17,6 +17,8 @@
#include "../../water.h"
#include "../../station_func.h"
#include "../../safeguards.h"
/* static */ uint32 ScriptInfrastructure::GetRailPieceCount(ScriptCompany::CompanyID company, ScriptRail::RailType railtype)
{

View File

@@ -14,6 +14,8 @@
#include "../../debug.h"
#include "../../script/squirrel.hpp"
#include "../../safeguards.h"
/**
* Base class for any ScriptList sorter.
*/

View File

@@ -15,6 +15,8 @@
#include "../../debug.h"
#include "../../window_func.h"
#include "../../safeguards.h"
/* static */ void ScriptLog::Info(const char *message)
{
ScriptLog::Log(LOG_INFO, message);

View File

@@ -13,6 +13,8 @@
#include "script_map.hpp"
#include "../../tile_map.h"
#include "../../safeguards.h"
/* static */ bool ScriptMap::IsValidTile(TileIndex t)
{
return ::IsValidTile(t);

View File

@@ -15,6 +15,8 @@
#include "../../station_base.h"
#include "../../tile_cmd.h"
#include "../../safeguards.h"
/* static */ bool ScriptMarine::IsWaterDepotTile(TileIndex tile)
{

View File

@@ -15,6 +15,8 @@
#include "../../command_type.h"
#include "../../string_func.h"
#include "../../safeguards.h"
/* static */ bool ScriptNews::Create(NewsType type, Text *text, ScriptCompany::CompanyID company)
{
CCountedPtr<Text> counter(text);

View File

@@ -24,6 +24,8 @@
#include "../script_fatalerror.hpp"
#include "script_error.hpp"
#include "../../safeguards.h"
/**
* Get the storage associated with the current ScriptInstance.
* @return The storage.

View File

@@ -21,6 +21,8 @@
#include "../../station_base.h"
#include "../../waypoint_base.h"
#include "../../safeguards.h"
/**
* Gets the order type given a tile
* @param t the tile to get the order from

View File

@@ -21,6 +21,8 @@
#include "../../newgrf_station.h"
#include "../../strings_func.h"
#include "../../safeguards.h"
/* static */ char *ScriptRail::GetName(RailType rail_type)
{
if (!IsRailTypeAvailable(rail_type)) return NULL;

View File

@@ -13,6 +13,8 @@
#include "script_railtypelist.hpp"
#include "../../rail.h"
#include "../../safeguards.h"
ScriptRailTypeList::ScriptRailTypeList()
{
for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {

View File

@@ -16,6 +16,8 @@
#include "../../station_base.h"
#include "../../script/squirrel_helper_type.hpp"
#include "../../safeguards.h"
/* static */ ScriptRoad::RoadVehicleType ScriptRoad::GetRoadVehicleTypeForCargo(CargoID cargo_type)
{
return ScriptCargo::HasCargoClass(cargo_type, ScriptCargo::CC_PASSENGERS) ? ROADVEHTYPE_BUS : ROADVEHTYPE_TRUCK;

View File

@@ -18,6 +18,8 @@
#include "../../strings_func.h"
#include "../../tile_map.h"
#include "../../safeguards.h"
/* static */ bool ScriptSign::IsValidSign(SignID sign_id)
{
const Sign *si = ::Sign::GetIfValid(sign_id);

View File

@@ -14,6 +14,8 @@
#include "script_sign.hpp"
#include "../../signs_base.h"
#include "../../safeguards.h"
ScriptSignList::ScriptSignList()
{
Sign *s;

View File

@@ -18,6 +18,8 @@
#include "../../roadstop_base.h"
#include "../../town.h"
#include "../../safeguards.h"
/* static */ bool ScriptStation::IsValidStation(StationID station_id)
{
const Station *st = ::Station::GetIfValid(station_id);

View File

@@ -15,6 +15,8 @@
#include "../../station_base.h"
#include "../../vehicle_base.h"
#include "../../safeguards.h"
ScriptStationList::ScriptStationList(ScriptStation::StationType station_type)
{
Station *st;

View File

@@ -22,6 +22,8 @@
#include "../../string_func.h"
#include "../../tile_map.h"
#include "../../safeguards.h"
/* static */ bool ScriptStoryPage::IsValidStoryPage(StoryPageID story_page_id)
{
return ::StoryPage::IsValidID(story_page_id);

View File

@@ -13,6 +13,8 @@
#include "script_storypageelementlist.hpp"
#include "../../story_base.h"
#include "../../safeguards.h"
ScriptStoryPageElementList::ScriptStoryPageElementList(ScriptStoryPage::StoryPageID story_page_id)
{
if (!ScriptStoryPage::IsValidStoryPage(story_page_id)) return;

View File

@@ -14,6 +14,8 @@
#include "script_story_page.hpp"
#include "../../story_base.h"
#include "../../safeguards.h"
ScriptStoryPageList::ScriptStoryPageList(ScriptCompany::CompanyID company)
{
uint8 c = company;

View File

@@ -18,6 +18,8 @@
#include "../../subsidy_base.h"
#include "../../station_base.h"
#include "../../safeguards.h"
/* static */ bool ScriptSubsidy::IsValidSubsidy(SubsidyID subsidy_id)
{
return ::Subsidy::IsValidID(subsidy_id);

View File

@@ -13,6 +13,8 @@
#include "script_subsidylist.hpp"
#include "../../subsidy_base.h"
#include "../../safeguards.h"
ScriptSubsidyList::ScriptSubsidyList()
{
const Subsidy *s;

View File

@@ -14,6 +14,8 @@
#include "../script_instance.hpp"
#include "../script_fatalerror.hpp"
#include "../../safeguards.h"
bool ScriptTestMode::ModeProc()
{
/* In test mode we only return 'false', telling the DoCommand it

View File

@@ -17,6 +17,8 @@
#include "table/strings.h"
#include "../../safeguards.h"
ScriptText::ScriptText(HSQUIRRELVM vm) :
ZeroedMemoryAllocator()
{

View File

@@ -20,6 +20,8 @@
#include "../../town.h"
#include "../../landscape.h"
#include "../../safeguards.h"
/* static */ bool ScriptTile::IsBuildable(TileIndex tile)
{
if (!::IsValidTile(tile)) return false;

View File

@@ -15,6 +15,8 @@
#include "../../industry.h"
#include "../../station_base.h"
#include "../../safeguards.h"
void ScriptTileList::AddRectangle(TileIndex t1, TileIndex t2)
{
if (!::IsValidTile(t1)) return;

View File

@@ -21,6 +21,8 @@
#include "../../landscape.h"
#include "table/strings.h"
#include "../../safeguards.h"
/* static */ int32 ScriptTown::GetTownCount()
{
return (int32)::Town::GetNumItems();

View File

@@ -13,6 +13,8 @@
#include "script_townlist.hpp"
#include "../../town.h"
#include "../../safeguards.h"
ScriptTownList::ScriptTownList()
{
Town *t;

View File

@@ -15,6 +15,8 @@
#include "../script_instance.hpp"
#include "../../tunnel_map.h"
#include "../../safeguards.h"
/* static */ bool ScriptTunnel::IsTunnelTile(TileIndex tile)
{
if (!::IsValidTile(tile)) return false;

View File

@@ -24,6 +24,8 @@
#include "../../aircraft.h"
#include "table/strings.h"
#include "../../safeguards.h"
/* static */ bool ScriptVehicle::IsValidVehicle(VehicleID vehicle_id)
{
const Vehicle *v = ::Vehicle::GetIfValid(vehicle_id);

View File

@@ -17,6 +17,8 @@
#include "../../depot_map.h"
#include "../../vehicle_base.h"
#include "../../safeguards.h"
ScriptVehicleList::ScriptVehicleList()
{
const Vehicle *v;

View File

@@ -15,6 +15,8 @@
#include "script_map.hpp"
#include "../../viewport_func.h"
#include "../../safeguards.h"
/* static */ void ScriptViewport::ScrollTo(TileIndex tile)
{
if (ScriptGame::IsMultiplayer()) return;

View File

@@ -15,6 +15,8 @@
#include "script_marine.hpp"
#include "../../waypoint_base.h"
#include "../../safeguards.h"
/* static */ bool ScriptWaypoint::IsValidWaypoint(StationID waypoint_id)
{
const Waypoint *wp = ::Waypoint::GetIfValid(waypoint_id);

View File

@@ -15,6 +15,8 @@
#include "../../vehicle_base.h"
#include "../../waypoint_base.h"
#include "../../safeguards.h"
ScriptWaypointList::ScriptWaypointList(ScriptWaypoint::WaypointType waypoint_type)
{
const Waypoint *wp;

View File

@@ -15,6 +15,8 @@
#include "../../window_func.h"
#include "../../window_gui.h"
#include "../../safeguards.h"
/* static */ void ScriptWindow::Close(WindowClass window, uint32 number)
{
if (ScriptGame::IsMultiplayer()) return;