(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:
@@ -12,6 +12,8 @@
|
||||
#include "../../stdafx.h"
|
||||
#include "script_accounting.hpp"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
Money ScriptAccounting::GetCosts()
|
||||
{
|
||||
return this->GetDoCommandCosts();
|
||||
|
@@ -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) {
|
||||
|
@@ -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();
|
||||
|
@@ -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)
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -14,6 +14,8 @@
|
||||
#include "script_bridge.hpp"
|
||||
#include "../../bridge.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
ScriptBridgeList::ScriptBridgeList()
|
||||
{
|
||||
for (byte j = 0; j < MAX_BRIDGES; j++) {
|
||||
|
@@ -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());
|
||||
|
@@ -17,6 +17,8 @@
|
||||
#include "../../industry.h"
|
||||
#include "../../station_base.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
ScriptCargoList::ScriptCargoList()
|
||||
{
|
||||
const CargoSpec *cs;
|
||||
|
@@ -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);
|
||||
|
@@ -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) {
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -14,6 +14,8 @@
|
||||
#include "script_date.hpp"
|
||||
#include "../../date_func.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
/* static */ bool ScriptDate::IsValidDate(Date date)
|
||||
{
|
||||
return date >= 0;
|
||||
|
@@ -14,6 +14,8 @@
|
||||
#include "../../depot_base.h"
|
||||
#include "../../station_base.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
ScriptDepotList::ScriptDepotList(ScriptTile::TransportType transport_type)
|
||||
{
|
||||
::TileType tile_type;
|
||||
|
@@ -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);
|
||||
|
@@ -13,6 +13,8 @@
|
||||
#include "script_enginelist.hpp"
|
||||
#include "../../engine_base.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
ScriptEngineList::ScriptEngineList(ScriptVehicle::VehicleType vehicle_type)
|
||||
{
|
||||
Engine *e;
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -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.
|
||||
|
@@ -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);
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
|
@@ -15,6 +15,8 @@
|
||||
#include "../../settings_type.h"
|
||||
#include "../../command_type.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
/* static */ bool ScriptGameSettings::IsValid(const char *setting)
|
||||
{
|
||||
uint i;
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -13,6 +13,8 @@
|
||||
#include "script_grouplist.hpp"
|
||||
#include "../../group.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
ScriptGroupList::ScriptGroupList()
|
||||
{
|
||||
Group *g;
|
||||
|
@@ -19,6 +19,8 @@
|
||||
#include "../../newgrf_industries.h"
|
||||
#include "table/strings.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
/* static */ int32 ScriptIndustry::GetIndustryCount()
|
||||
{
|
||||
return (int32)::Industry::GetNumItems();
|
||||
|
@@ -13,6 +13,8 @@
|
||||
#include "script_industrylist.hpp"
|
||||
#include "../../industry.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
ScriptIndustryList::ScriptIndustryList()
|
||||
{
|
||||
Industry *i;
|
||||
|
@@ -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;
|
||||
|
@@ -13,6 +13,8 @@
|
||||
#include "script_industrytypelist.hpp"
|
||||
#include "../../industry.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
ScriptIndustryTypeList::ScriptIndustryTypeList()
|
||||
{
|
||||
for (int i = 0; i < NUM_INDUSTRYTYPES; i++) {
|
||||
|
@@ -17,6 +17,8 @@
|
||||
#include "../../water.h"
|
||||
#include "../../station_func.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
|
||||
/* static */ uint32 ScriptInfrastructure::GetRailPieceCount(ScriptCompany::CompanyID company, ScriptRail::RailType railtype)
|
||||
{
|
||||
|
@@ -14,6 +14,8 @@
|
||||
#include "../../debug.h"
|
||||
#include "../../script/squirrel.hpp"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
/**
|
||||
* Base class for any ScriptList sorter.
|
||||
*/
|
||||
|
@@ -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);
|
||||
|
@@ -13,6 +13,8 @@
|
||||
#include "script_map.hpp"
|
||||
#include "../../tile_map.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
/* static */ bool ScriptMap::IsValidTile(TileIndex t)
|
||||
{
|
||||
return ::IsValidTile(t);
|
||||
|
@@ -15,6 +15,8 @@
|
||||
#include "../../station_base.h"
|
||||
#include "../../tile_cmd.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
|
||||
/* static */ bool ScriptMarine::IsWaterDepotTile(TileIndex tile)
|
||||
{
|
||||
|
@@ -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);
|
||||
|
@@ -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.
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
@@ -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++) {
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -14,6 +14,8 @@
|
||||
#include "script_sign.hpp"
|
||||
#include "../../signs_base.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
ScriptSignList::ScriptSignList()
|
||||
{
|
||||
Sign *s;
|
||||
|
@@ -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);
|
||||
|
@@ -15,6 +15,8 @@
|
||||
#include "../../station_base.h"
|
||||
#include "../../vehicle_base.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
ScriptStationList::ScriptStationList(ScriptStation::StationType station_type)
|
||||
{
|
||||
Station *st;
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -14,6 +14,8 @@
|
||||
#include "script_story_page.hpp"
|
||||
#include "../../story_base.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
ScriptStoryPageList::ScriptStoryPageList(ScriptCompany::CompanyID company)
|
||||
{
|
||||
uint8 c = company;
|
||||
|
@@ -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);
|
||||
|
@@ -13,6 +13,8 @@
|
||||
#include "script_subsidylist.hpp"
|
||||
#include "../../subsidy_base.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
ScriptSubsidyList::ScriptSubsidyList()
|
||||
{
|
||||
const Subsidy *s;
|
||||
|
@@ -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
|
||||
|
@@ -17,6 +17,8 @@
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
ScriptText::ScriptText(HSQUIRRELVM vm) :
|
||||
ZeroedMemoryAllocator()
|
||||
{
|
||||
|
@@ -20,6 +20,8 @@
|
||||
#include "../../town.h"
|
||||
#include "../../landscape.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
/* static */ bool ScriptTile::IsBuildable(TileIndex tile)
|
||||
{
|
||||
if (!::IsValidTile(tile)) return false;
|
||||
|
@@ -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;
|
||||
|
@@ -21,6 +21,8 @@
|
||||
#include "../../landscape.h"
|
||||
#include "table/strings.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
/* static */ int32 ScriptTown::GetTownCount()
|
||||
{
|
||||
return (int32)::Town::GetNumItems();
|
||||
|
@@ -13,6 +13,8 @@
|
||||
#include "script_townlist.hpp"
|
||||
#include "../../town.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
ScriptTownList::ScriptTownList()
|
||||
{
|
||||
Town *t;
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -17,6 +17,8 @@
|
||||
#include "../../depot_map.h"
|
||||
#include "../../vehicle_base.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
ScriptVehicleList::ScriptVehicleList()
|
||||
{
|
||||
const Vehicle *v;
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -15,6 +15,8 @@
|
||||
#include "../../vehicle_base.h"
|
||||
#include "../../waypoint_base.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
ScriptWaypointList::ScriptWaypointList(ScriptWaypoint::WaypointType waypoint_type)
|
||||
{
|
||||
const Waypoint *wp;
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user