Update to 1.10.0-beta1
This commit is contained in:
@@ -41,6 +41,8 @@ void SQAIEngine_Register(Squirrel *engine)
|
||||
SQAIEngine.DefSQStaticMethod(engine, &ScriptEngine::IsWagon, "IsWagon", 2, ".i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &ScriptEngine::CanRunOnRail, "CanRunOnRail", 3, ".ii");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &ScriptEngine::HasPowerOnRail, "HasPowerOnRail", 3, ".ii");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &ScriptEngine::CanRunOnRoad, "CanRunOnRoad", 3, ".ii");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &ScriptEngine::HasPowerOnRoad, "HasPowerOnRoad", 3, ".ii");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &ScriptEngine::GetRoadType, "GetRoadType", 2, ".i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &ScriptEngine::GetRailType, "GetRailType", 2, ".i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &ScriptEngine::IsArticulated, "IsArticulated", 2, ".i");
|
||||
|
||||
@@ -50,6 +50,7 @@ void SQAIEvent_Register(Squirrel *engine)
|
||||
SQAIEvent.DefSQConst(engine, ScriptEvent::ET_GOAL_QUESTION_ANSWER, "ET_GOAL_QUESTION_ANSWER");
|
||||
SQAIEvent.DefSQConst(engine, ScriptEvent::ET_EXCLUSIVE_TRANSPORT_RIGHTS, "ET_EXCLUSIVE_TRANSPORT_RIGHTS");
|
||||
SQAIEvent.DefSQConst(engine, ScriptEvent::ET_ROAD_RECONSTRUCTION, "ET_ROAD_RECONSTRUCTION");
|
||||
SQAIEvent.DefSQConst(engine, ScriptEvent::ET_VEHICLE_AUTOREPLACED, "ET_VEHICLE_AUTOREPLACED");
|
||||
|
||||
SQAIEvent.DefSQMethod(engine, &ScriptEvent::GetEventType, "GetEventType", 1, "x");
|
||||
|
||||
|
||||
@@ -405,3 +405,19 @@ void SQAIEventRoadReconstruction_Register(Squirrel *engine)
|
||||
|
||||
SQAIEventRoadReconstruction.PostRegister(engine);
|
||||
}
|
||||
|
||||
|
||||
template <> const char *GetClassName<ScriptEventVehicleAutoReplaced, ST_AI>() { return "AIEventVehicleAutoReplaced"; }
|
||||
|
||||
void SQAIEventVehicleAutoReplaced_Register(Squirrel *engine)
|
||||
{
|
||||
DefSQClass<ScriptEventVehicleAutoReplaced, ST_AI> SQAIEventVehicleAutoReplaced("AIEventVehicleAutoReplaced");
|
||||
SQAIEventVehicleAutoReplaced.PreRegister(engine, "AIEvent");
|
||||
|
||||
SQAIEventVehicleAutoReplaced.DefSQStaticMethod(engine, &ScriptEventVehicleAutoReplaced::Convert, "Convert", 2, ".x");
|
||||
|
||||
SQAIEventVehicleAutoReplaced.DefSQMethod(engine, &ScriptEventVehicleAutoReplaced::GetOldVehicleID, "GetOldVehicleID", 1, "x");
|
||||
SQAIEventVehicleAutoReplaced.DefSQMethod(engine, &ScriptEventVehicleAutoReplaced::GetNewVehicleID, "GetNewVehicleID", 1, "x");
|
||||
|
||||
SQAIEventVehicleAutoReplaced.PostRegister(engine);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,10 @@ void SQAIGroup_Register(Squirrel *engine)
|
||||
SQAIGroup.DefSQStaticMethod(engine, &ScriptGroup::GetProfitThisYear, "GetProfitThisYear", 2, ".i");
|
||||
SQAIGroup.DefSQStaticMethod(engine, &ScriptGroup::GetProfitLastYear, "GetProfitLastYear", 2, ".i");
|
||||
SQAIGroup.DefSQStaticMethod(engine, &ScriptGroup::GetCurrentUsage, "GetCurrentUsage", 2, ".i");
|
||||
SQAIGroup.DefSQStaticMethod(engine, &ScriptGroup::SetPrimaryColour, "SetPrimaryColour", 3, ".ii");
|
||||
SQAIGroup.DefSQStaticMethod(engine, &ScriptGroup::SetSecondaryColour, "SetSecondaryColour", 3, ".ii");
|
||||
SQAIGroup.DefSQStaticMethod(engine, &ScriptGroup::GetPrimaryColour, "GetPrimaryColour", 2, ".i");
|
||||
SQAIGroup.DefSQStaticMethod(engine, &ScriptGroup::GetSecondaryColour, "GetSecondaryColour", 2, ".i");
|
||||
|
||||
SQAIGroup.PostRegister(engine);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ void SQAIRail_Register(Squirrel *engine)
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK, ScriptRail::ERR_UNSUITABLE_TRACK);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_THERE_ARE_NO_SIGNALS, ScriptRail::ERR_UNSUITABLE_TRACK);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_THERE_IS_NO_STATION, ScriptRail::ERR_UNSUITABLE_TRACK);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_CROSSING_DISALLOWED, ScriptRail::ERR_RAILTYPE_DISALLOWS_CROSSING);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_CROSSING_DISALLOWED_RAIL, ScriptRail::ERR_RAILTYPE_DISALLOWS_CROSSING);
|
||||
|
||||
ScriptError::RegisterErrorMapString(ScriptRail::ERR_CROSSING_ON_ONEWAY_ROAD, "ERR_CROSSING_ON_ONEWAY_ROAD");
|
||||
ScriptError::RegisterErrorMapString(ScriptRail::ERR_UNSUITABLE_TRACK, "ERR_UNSUITABLE_TRACK");
|
||||
|
||||
@@ -26,9 +26,13 @@ void SQAIRoad_Register(Squirrel *engine)
|
||||
SQAIRoad.DefSQConst(engine, ScriptRoad::ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION, "ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION");
|
||||
SQAIRoad.DefSQConst(engine, ScriptRoad::ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD, "ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD");
|
||||
SQAIRoad.DefSQConst(engine, ScriptRoad::ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS, "ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS");
|
||||
SQAIRoad.DefSQConst(engine, ScriptRoad::ERR_ROADTYPE_DISALLOWS_CROSSING, "ERR_ROADTYPE_DISALLOWS_CROSSING");
|
||||
SQAIRoad.DefSQConst(engine, ScriptRoad::ERR_UNSUITABLE_ROAD, "ERR_UNSUITABLE_ROAD");
|
||||
SQAIRoad.DefSQConst(engine, ScriptRoad::ROADTYPE_ROAD, "ROADTYPE_ROAD");
|
||||
SQAIRoad.DefSQConst(engine, ScriptRoad::ROADTYPE_TRAM, "ROADTYPE_TRAM");
|
||||
SQAIRoad.DefSQConst(engine, ScriptRoad::ROADTYPE_INVALID, "ROADTYPE_INVALID");
|
||||
SQAIRoad.DefSQConst(engine, ScriptRoad::ROADTRAMTYPES_ROAD, "ROADTRAMTYPES_ROAD");
|
||||
SQAIRoad.DefSQConst(engine, ScriptRoad::ROADTRAMTYPES_TRAM, "ROADTRAMTYPES_TRAM");
|
||||
SQAIRoad.DefSQConst(engine, ScriptRoad::ROADVEHTYPE_BUS, "ROADVEHTYPE_BUS");
|
||||
SQAIRoad.DefSQConst(engine, ScriptRoad::ROADVEHTYPE_TRUCK, "ROADVEHTYPE_TRUCK");
|
||||
SQAIRoad.DefSQConst(engine, ScriptRoad::BT_ROAD, "BT_ROAD");
|
||||
@@ -40,12 +44,19 @@ void SQAIRoad_Register(Squirrel *engine)
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_DRIVE_THROUGH_DIRECTION, ScriptRoad::ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_DRIVE_THROUGH_ON_TOWN_ROAD, ScriptRoad::ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION, ScriptRoad::ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_CROSSING_DISALLOWED_ROAD, ScriptRoad::ERR_ROADTYPE_DISALLOWS_CROSSING);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_NO_SUITABLE_ROAD, ScriptRoad::ERR_UNSUITABLE_ROAD);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_NO_SUITABLE_TRAMWAY, ScriptRoad::ERR_UNSUITABLE_ROAD);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_INCOMPATIBLE_ROAD, ScriptRoad::ERR_UNSUITABLE_ROAD);
|
||||
|
||||
ScriptError::RegisterErrorMapString(ScriptRoad::ERR_ROAD_WORKS_IN_PROGRESS, "ERR_ROAD_WORKS_IN_PROGRESS");
|
||||
ScriptError::RegisterErrorMapString(ScriptRoad::ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION, "ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION");
|
||||
ScriptError::RegisterErrorMapString(ScriptRoad::ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD, "ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD");
|
||||
ScriptError::RegisterErrorMapString(ScriptRoad::ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS, "ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS");
|
||||
ScriptError::RegisterErrorMapString(ScriptRoad::ERR_ROADTYPE_DISALLOWS_CROSSING, "ERR_ROADTYPE_DISALLOWS_CROSSING");
|
||||
ScriptError::RegisterErrorMapString(ScriptRoad::ERR_UNSUITABLE_ROAD, "ERR_UNSUITABLE_ROAD");
|
||||
|
||||
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::GetName, "GetName", 2, ".i");
|
||||
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::GetRoadVehicleTypeForCargo, "GetRoadVehicleTypeForCargo", 2, ".i");
|
||||
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::IsRoadTile, "IsRoadTile", 2, ".i");
|
||||
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::IsRoadDepotTile, "IsRoadDepotTile", 2, ".i");
|
||||
@@ -54,6 +65,9 @@ void SQAIRoad_Register(Squirrel *engine)
|
||||
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::IsRoadTypeAvailable, "IsRoadTypeAvailable", 2, ".i");
|
||||
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::GetCurrentRoadType, "GetCurrentRoadType", 1, ".");
|
||||
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::SetCurrentRoadType, "SetCurrentRoadType", 2, ".i");
|
||||
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::RoadVehCanRunOnRoad, "RoadVehCanRunOnRoad", 3, ".ii");
|
||||
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::RoadVehHasPowerOnRoad, "RoadVehHasPowerOnRoad", 3, ".ii");
|
||||
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::ConvertRoadType, "ConvertRoadType", 4, ".iii");
|
||||
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::HasRoadType, "HasRoadType", 3, ".ii");
|
||||
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::AreRoadTilesConnected, "AreRoadTilesConnected", 3, ".ii");
|
||||
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::CanBuildConnectedRoadParts, "CanBuildConnectedRoadParts", 5, ".iaii");
|
||||
@@ -74,6 +88,8 @@ void SQAIRoad_Register(Squirrel *engine)
|
||||
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::RemoveRoadDepot, "RemoveRoadDepot", 2, ".i");
|
||||
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::RemoveRoadStation, "RemoveRoadStation", 2, ".i");
|
||||
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::GetBuildCost, "GetBuildCost", 3, ".ii");
|
||||
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::GetRoadTramType, "GetRoadTramType", 2, ".i");
|
||||
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::GetMaxSpeed, "GetMaxSpeed", 2, ".i");
|
||||
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::GetMaintenanceCostFactor, "GetMaintenanceCostFactor", 2, ".i");
|
||||
|
||||
SQAIRoad.PostRegister(engine);
|
||||
|
||||
25
src/script/api/ai/ai_roadtypelist.hpp.sq
Normal file
25
src/script/api/ai/ai_roadtypelist.hpp.sq
Normal file
@@ -0,0 +1,25 @@
|
||||
/* $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/>.
|
||||
*/
|
||||
|
||||
/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */
|
||||
|
||||
#include "../script_roadtypelist.hpp"
|
||||
#include "../template/template_roadtypelist.hpp.sq"
|
||||
|
||||
|
||||
template <> const char *GetClassName<ScriptRoadTypeList, ST_AI>() { return "AIRoadTypeList"; }
|
||||
|
||||
void SQAIRoadTypeList_Register(Squirrel *engine)
|
||||
{
|
||||
DefSQClass<ScriptRoadTypeList, ST_AI> SQAIRoadTypeList("AIRoadTypeList");
|
||||
SQAIRoadTypeList.PreRegister(engine, "AIList");
|
||||
SQAIRoadTypeList.AddConstructor<void (ScriptRoadTypeList::*)(ScriptRoad::RoadTramTypes rtts), 2>(engine, "xi");
|
||||
|
||||
SQAIRoadTypeList.PostRegister(engine);
|
||||
}
|
||||
@@ -122,6 +122,8 @@ void SQAIVehicle_Register(Squirrel *engine)
|
||||
SQAIVehicle.DefSQStaticMethod(engine, &ScriptVehicle::IsInDepot, "IsInDepot", 2, ".i");
|
||||
SQAIVehicle.DefSQStaticMethod(engine, &ScriptVehicle::IsStoppedInDepot, "IsStoppedInDepot", 2, ".i");
|
||||
SQAIVehicle.DefSQStaticMethod(engine, &ScriptVehicle::BuildVehicle, "BuildVehicle", 3, ".ii");
|
||||
SQAIVehicle.DefSQStaticMethod(engine, &ScriptVehicle::BuildVehicleWithRefit, "BuildVehicleWithRefit", 4, ".iii");
|
||||
SQAIVehicle.DefSQStaticMethod(engine, &ScriptVehicle::GetBuildWithRefitCapacity, "GetBuildWithRefitCapacity", 4, ".iii");
|
||||
SQAIVehicle.DefSQStaticMethod(engine, &ScriptVehicle::CloneVehicle, "CloneVehicle", 4, ".iib");
|
||||
SQAIVehicle.DefSQStaticMethod(engine, &ScriptVehicle::MoveWagon, "MoveWagon", 5, ".iiii");
|
||||
SQAIVehicle.DefSQStaticMethod(engine, &ScriptVehicle::MoveWagonChain, "MoveWagonChain", 5, ".iiii");
|
||||
|
||||
@@ -15,6 +15,30 @@
|
||||
* functions may still be available if you return an older API version
|
||||
* in GetAPIVersion() in info.nut.
|
||||
*
|
||||
* \b 1.10.0
|
||||
*
|
||||
* This version is not yet released. The following changes are not set in stone yet.
|
||||
*
|
||||
* API additions:
|
||||
* \li AIGroup::SetPrimaryColour
|
||||
* \li AIGroup::SetSecondaryColour
|
||||
* \li AIGroup::GetPrimaryColour
|
||||
* \li AIGroup::GetSecondaryColour
|
||||
* \li AIVehicle::BuildVehicleWithRefit
|
||||
* \li AIVehicle::GetBuildWithRefitCapacity
|
||||
* \li AIRoad::GetName
|
||||
* \li AIRoad::RoadVehCanRunOnRoad
|
||||
* \li AIRoad::RoadVehHasPowerOnRoad
|
||||
* \li AIRoad::ConvertRoadType
|
||||
* \li AIRoad::GetMaxSpeed
|
||||
* \li AIEngine::CanRunOnRoad
|
||||
* \li AIEngine::HasPowerOnRoad
|
||||
* \li AIRoadTypeList::RoadTypeList
|
||||
* \li AIEventVehicleAutoReplaced
|
||||
*
|
||||
* Other changes:
|
||||
* \li AITile::DemolishTile works without a selected company
|
||||
*
|
||||
* \b 1.9.0
|
||||
*
|
||||
* API additions:
|
||||
@@ -34,6 +58,9 @@
|
||||
*
|
||||
* No changes
|
||||
*
|
||||
* API additions:
|
||||
* \li AIRoad::ERR_ROADTYPE_DISALLOWS_CROSSING
|
||||
*
|
||||
* \b 1.7.0 - 1.7.2
|
||||
*
|
||||
* No changes
|
||||
@@ -287,7 +314,7 @@
|
||||
* destination it its catchment area. One industry tile or one town house
|
||||
* is enough as long as station accepts the cargo. Awarded subsidies are no
|
||||
* longer bound to stations used for first delivery, any station can be
|
||||
* used for loading and unloading as long as cargo is transfered from
|
||||
* used for loading and unloading as long as cargo is transferred from
|
||||
* source to destination.
|
||||
* \li Make AIEngine:CanRefitCargo() not report refittability to mail by
|
||||
* default for aircraft. It is not necessarily true. This means that even
|
||||
|
||||
@@ -41,6 +41,8 @@ void SQGSEngine_Register(Squirrel *engine)
|
||||
SQGSEngine.DefSQStaticMethod(engine, &ScriptEngine::IsWagon, "IsWagon", 2, ".i");
|
||||
SQGSEngine.DefSQStaticMethod(engine, &ScriptEngine::CanRunOnRail, "CanRunOnRail", 3, ".ii");
|
||||
SQGSEngine.DefSQStaticMethod(engine, &ScriptEngine::HasPowerOnRail, "HasPowerOnRail", 3, ".ii");
|
||||
SQGSEngine.DefSQStaticMethod(engine, &ScriptEngine::CanRunOnRoad, "CanRunOnRoad", 3, ".ii");
|
||||
SQGSEngine.DefSQStaticMethod(engine, &ScriptEngine::HasPowerOnRoad, "HasPowerOnRoad", 3, ".ii");
|
||||
SQGSEngine.DefSQStaticMethod(engine, &ScriptEngine::GetRoadType, "GetRoadType", 2, ".i");
|
||||
SQGSEngine.DefSQStaticMethod(engine, &ScriptEngine::GetRailType, "GetRailType", 2, ".i");
|
||||
SQGSEngine.DefSQStaticMethod(engine, &ScriptEngine::IsArticulated, "IsArticulated", 2, ".i");
|
||||
|
||||
@@ -50,6 +50,7 @@ void SQGSEvent_Register(Squirrel *engine)
|
||||
SQGSEvent.DefSQConst(engine, ScriptEvent::ET_GOAL_QUESTION_ANSWER, "ET_GOAL_QUESTION_ANSWER");
|
||||
SQGSEvent.DefSQConst(engine, ScriptEvent::ET_EXCLUSIVE_TRANSPORT_RIGHTS, "ET_EXCLUSIVE_TRANSPORT_RIGHTS");
|
||||
SQGSEvent.DefSQConst(engine, ScriptEvent::ET_ROAD_RECONSTRUCTION, "ET_ROAD_RECONSTRUCTION");
|
||||
SQGSEvent.DefSQConst(engine, ScriptEvent::ET_VEHICLE_AUTOREPLACED, "ET_VEHICLE_AUTOREPLACED");
|
||||
|
||||
SQGSEvent.DefSQMethod(engine, &ScriptEvent::GetEventType, "GetEventType", 1, "x");
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ void SQGSRail_Register(Squirrel *engine)
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK, ScriptRail::ERR_UNSUITABLE_TRACK);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_THERE_ARE_NO_SIGNALS, ScriptRail::ERR_UNSUITABLE_TRACK);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_THERE_IS_NO_STATION, ScriptRail::ERR_UNSUITABLE_TRACK);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_CROSSING_DISALLOWED, ScriptRail::ERR_RAILTYPE_DISALLOWS_CROSSING);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_CROSSING_DISALLOWED_RAIL, ScriptRail::ERR_RAILTYPE_DISALLOWS_CROSSING);
|
||||
|
||||
ScriptError::RegisterErrorMapString(ScriptRail::ERR_CROSSING_ON_ONEWAY_ROAD, "ERR_CROSSING_ON_ONEWAY_ROAD");
|
||||
ScriptError::RegisterErrorMapString(ScriptRail::ERR_UNSUITABLE_TRACK, "ERR_UNSUITABLE_TRACK");
|
||||
|
||||
@@ -26,9 +26,13 @@ void SQGSRoad_Register(Squirrel *engine)
|
||||
SQGSRoad.DefSQConst(engine, ScriptRoad::ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION, "ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION");
|
||||
SQGSRoad.DefSQConst(engine, ScriptRoad::ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD, "ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD");
|
||||
SQGSRoad.DefSQConst(engine, ScriptRoad::ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS, "ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS");
|
||||
SQGSRoad.DefSQConst(engine, ScriptRoad::ERR_ROADTYPE_DISALLOWS_CROSSING, "ERR_ROADTYPE_DISALLOWS_CROSSING");
|
||||
SQGSRoad.DefSQConst(engine, ScriptRoad::ERR_UNSUITABLE_ROAD, "ERR_UNSUITABLE_ROAD");
|
||||
SQGSRoad.DefSQConst(engine, ScriptRoad::ROADTYPE_ROAD, "ROADTYPE_ROAD");
|
||||
SQGSRoad.DefSQConst(engine, ScriptRoad::ROADTYPE_TRAM, "ROADTYPE_TRAM");
|
||||
SQGSRoad.DefSQConst(engine, ScriptRoad::ROADTYPE_INVALID, "ROADTYPE_INVALID");
|
||||
SQGSRoad.DefSQConst(engine, ScriptRoad::ROADTRAMTYPES_ROAD, "ROADTRAMTYPES_ROAD");
|
||||
SQGSRoad.DefSQConst(engine, ScriptRoad::ROADTRAMTYPES_TRAM, "ROADTRAMTYPES_TRAM");
|
||||
SQGSRoad.DefSQConst(engine, ScriptRoad::ROADVEHTYPE_BUS, "ROADVEHTYPE_BUS");
|
||||
SQGSRoad.DefSQConst(engine, ScriptRoad::ROADVEHTYPE_TRUCK, "ROADVEHTYPE_TRUCK");
|
||||
SQGSRoad.DefSQConst(engine, ScriptRoad::BT_ROAD, "BT_ROAD");
|
||||
@@ -40,12 +44,19 @@ void SQGSRoad_Register(Squirrel *engine)
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_DRIVE_THROUGH_DIRECTION, ScriptRoad::ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_DRIVE_THROUGH_ON_TOWN_ROAD, ScriptRoad::ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION, ScriptRoad::ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_CROSSING_DISALLOWED_ROAD, ScriptRoad::ERR_ROADTYPE_DISALLOWS_CROSSING);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_NO_SUITABLE_ROAD, ScriptRoad::ERR_UNSUITABLE_ROAD);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_NO_SUITABLE_TRAMWAY, ScriptRoad::ERR_UNSUITABLE_ROAD);
|
||||
ScriptError::RegisterErrorMap(STR_ERROR_INCOMPATIBLE_ROAD, ScriptRoad::ERR_UNSUITABLE_ROAD);
|
||||
|
||||
ScriptError::RegisterErrorMapString(ScriptRoad::ERR_ROAD_WORKS_IN_PROGRESS, "ERR_ROAD_WORKS_IN_PROGRESS");
|
||||
ScriptError::RegisterErrorMapString(ScriptRoad::ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION, "ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION");
|
||||
ScriptError::RegisterErrorMapString(ScriptRoad::ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD, "ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD");
|
||||
ScriptError::RegisterErrorMapString(ScriptRoad::ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS, "ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS");
|
||||
ScriptError::RegisterErrorMapString(ScriptRoad::ERR_ROADTYPE_DISALLOWS_CROSSING, "ERR_ROADTYPE_DISALLOWS_CROSSING");
|
||||
ScriptError::RegisterErrorMapString(ScriptRoad::ERR_UNSUITABLE_ROAD, "ERR_UNSUITABLE_ROAD");
|
||||
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::GetName, "GetName", 2, ".i");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::GetRoadVehicleTypeForCargo, "GetRoadVehicleTypeForCargo", 2, ".i");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::IsRoadTile, "IsRoadTile", 2, ".i");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::IsRoadDepotTile, "IsRoadDepotTile", 2, ".i");
|
||||
@@ -54,6 +65,9 @@ void SQGSRoad_Register(Squirrel *engine)
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::IsRoadTypeAvailable, "IsRoadTypeAvailable", 2, ".i");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::GetCurrentRoadType, "GetCurrentRoadType", 1, ".");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::SetCurrentRoadType, "SetCurrentRoadType", 2, ".i");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::RoadVehCanRunOnRoad, "RoadVehCanRunOnRoad", 3, ".ii");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::RoadVehHasPowerOnRoad, "RoadVehHasPowerOnRoad", 3, ".ii");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::ConvertRoadType, "ConvertRoadType", 4, ".iii");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::HasRoadType, "HasRoadType", 3, ".ii");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::AreRoadTilesConnected, "AreRoadTilesConnected", 3, ".ii");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::CanBuildConnectedRoadParts, "CanBuildConnectedRoadParts", 5, ".iaii");
|
||||
@@ -74,6 +88,8 @@ void SQGSRoad_Register(Squirrel *engine)
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::RemoveRoadDepot, "RemoveRoadDepot", 2, ".i");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::RemoveRoadStation, "RemoveRoadStation", 2, ".i");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::GetBuildCost, "GetBuildCost", 3, ".ii");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::GetRoadTramType, "GetRoadTramType", 2, ".i");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::GetMaxSpeed, "GetMaxSpeed", 2, ".i");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::GetMaintenanceCostFactor, "GetMaintenanceCostFactor", 2, ".i");
|
||||
|
||||
SQGSRoad.PostRegister(engine);
|
||||
|
||||
25
src/script/api/game/game_roadtypelist.hpp.sq
Normal file
25
src/script/api/game/game_roadtypelist.hpp.sq
Normal file
@@ -0,0 +1,25 @@
|
||||
/* $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/>.
|
||||
*/
|
||||
|
||||
/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */
|
||||
|
||||
#include "../script_roadtypelist.hpp"
|
||||
#include "../template/template_roadtypelist.hpp.sq"
|
||||
|
||||
|
||||
template <> const char *GetClassName<ScriptRoadTypeList, ST_GS>() { return "GSRoadTypeList"; }
|
||||
|
||||
void SQGSRoadTypeList_Register(Squirrel *engine)
|
||||
{
|
||||
DefSQClass<ScriptRoadTypeList, ST_GS> SQGSRoadTypeList("GSRoadTypeList");
|
||||
SQGSRoadTypeList.PreRegister(engine, "GSList");
|
||||
SQGSRoadTypeList.AddConstructor<void (ScriptRoadTypeList::*)(ScriptRoad::RoadTramTypes rtts), 2>(engine, "xi");
|
||||
|
||||
SQGSRoadTypeList.PostRegister(engine);
|
||||
}
|
||||
@@ -123,6 +123,8 @@ void SQGSVehicle_Register(Squirrel *engine)
|
||||
SQGSVehicle.DefSQStaticMethod(engine, &ScriptVehicle::IsInDepot, "IsInDepot", 2, ".i");
|
||||
SQGSVehicle.DefSQStaticMethod(engine, &ScriptVehicle::IsStoppedInDepot, "IsStoppedInDepot", 2, ".i");
|
||||
SQGSVehicle.DefSQStaticMethod(engine, &ScriptVehicle::BuildVehicle, "BuildVehicle", 3, ".ii");
|
||||
SQGSVehicle.DefSQStaticMethod(engine, &ScriptVehicle::BuildVehicleWithRefit, "BuildVehicleWithRefit", 4, ".iii");
|
||||
SQGSVehicle.DefSQStaticMethod(engine, &ScriptVehicle::GetBuildWithRefitCapacity, "GetBuildWithRefitCapacity", 4, ".iii");
|
||||
SQGSVehicle.DefSQStaticMethod(engine, &ScriptVehicle::CloneVehicle, "CloneVehicle", 4, ".iib");
|
||||
SQGSVehicle.DefSQStaticMethod(engine, &ScriptVehicle::MoveWagon, "MoveWagon", 5, ".iiii");
|
||||
SQGSVehicle.DefSQStaticMethod(engine, &ScriptVehicle::MoveWagonChain, "MoveWagonChain", 5, ".iiii");
|
||||
|
||||
@@ -227,8 +227,8 @@ void SQGSWindow_Register(Squirrel *engine)
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_START_REPLACE, "WID_RV_START_REPLACE");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_INFO_TAB, "WID_RV_INFO_TAB");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_STOP_REPLACE, "WID_RV_STOP_REPLACE");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_RAIL_ROAD_TYPE_DROPDOWN, "WID_RV_RAIL_ROAD_TYPE_DROPDOWN");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_TRAIN_ENGINEWAGON_DROPDOWN, "WID_RV_TRAIN_ENGINEWAGON_DROPDOWN");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_TRAIN_RAILTYPE_DROPDOWN, "WID_RV_TRAIN_RAILTYPE_DROPDOWN");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_TRAIN_WAGONREMOVE_TOGGLE, "WID_RV_TRAIN_WAGONREMOVE_TOGGLE");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_BB_BACKGROUND, "WID_BB_BACKGROUND");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_BAFD_QUESTION, "WID_BAFD_QUESTION");
|
||||
@@ -385,6 +385,8 @@ void SQGSWindow_Register(Squirrel *engine)
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_CI_RAIL_COUNT, "WID_CI_RAIL_COUNT");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_CI_ROAD_DESC, "WID_CI_ROAD_DESC");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_CI_ROAD_COUNT, "WID_CI_ROAD_COUNT");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_CI_TRAM_DESC, "WID_CI_TRAM_DESC");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_CI_TRAM_COUNT, "WID_CI_TRAM_COUNT");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_CI_WATER_DESC, "WID_CI_WATER_DESC");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_CI_WATER_COUNT, "WID_CI_WATER_COUNT");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_CI_STATION_DESC, "WID_CI_STATION_DESC");
|
||||
@@ -466,6 +468,8 @@ void SQGSWindow_Register(Squirrel *engine)
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_FRW_TIMES_NAMES, "WID_FRW_TIMES_NAMES");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_FRW_TIMES_CURRENT, "WID_FRW_TIMES_CURRENT");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_FRW_TIMES_AVERAGE, "WID_FRW_TIMES_AVERAGE");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_FRW_ALLOCSIZE, "WID_FRW_ALLOCSIZE");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_FRW_SEL_MEMORY, "WID_FRW_SEL_MEMORY");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_FRW_SCROLLBAR, "WID_FRW_SCROLLBAR");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_FGW_CAPTION, "WID_FGW_CAPTION");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_FGW_GRAPH, "WID_FGW_GRAPH");
|
||||
@@ -636,6 +640,7 @@ void SQGSWindow_Register(Squirrel *engine)
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_A_WEBSITE, "WID_A_WEBSITE");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_CAPTION, "WID_QS_CAPTION");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_TEXT, "WID_QS_TEXT");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_WARNING, "WID_QS_WARNING");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_DEFAULT, "WID_QS_DEFAULT");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_CANCEL, "WID_QS_CANCEL");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_OK, "WID_QS_OK");
|
||||
@@ -780,6 +785,7 @@ void SQGSWindow_Register(Squirrel *engine)
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_LABEL, "WID_NCP_LABEL");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_PASSWORD, "WID_NCP_PASSWORD");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_SAVE_AS_DEFAULT_PASSWORD, "WID_NCP_SAVE_AS_DEFAULT_PASSWORD");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_WARNING, "WID_NCP_WARNING");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_CANCEL, "WID_NCP_CANCEL");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_OK, "WID_NCP_OK");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NGRFI_CAPTION, "WID_NGRFI_CAPTION");
|
||||
@@ -994,6 +1000,7 @@ void SQGSWindow_Register(Squirrel *engine)
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_BRW_WAYPOINT_MATRIX, "WID_BRW_WAYPOINT_MATRIX");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_BRW_WAYPOINT, "WID_BRW_WAYPOINT");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_BRW_SCROLL, "WID_BRW_SCROLL");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_ROT_CAPTION, "WID_ROT_CAPTION");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_ROT_ROAD_X, "WID_ROT_ROAD_X");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_ROT_ROAD_Y, "WID_ROT_ROAD_Y");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_ROT_AUTOROAD, "WID_ROT_AUTOROAD");
|
||||
@@ -1005,6 +1012,7 @@ void SQGSWindow_Register(Squirrel *engine)
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_ROT_BUILD_BRIDGE, "WID_ROT_BUILD_BRIDGE");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_ROT_BUILD_TUNNEL, "WID_ROT_BUILD_TUNNEL");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_ROT_REMOVE, "WID_ROT_REMOVE");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_ROT_CONVERT_ROAD, "WID_ROT_CONVERT_ROAD");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_BROD_CAPTION, "WID_BROD_CAPTION");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_BROD_DEPOT_NE, "WID_BROD_DEPOT_NE");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_BROD_DEPOT_SE, "WID_BROD_DEPOT_SE");
|
||||
@@ -1115,6 +1123,7 @@ void SQGSWindow_Register(Squirrel *engine)
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SV_ROADVEHS, "WID_SV_ROADVEHS");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SV_SHIPS, "WID_SV_SHIPS");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SV_PLANES, "WID_SV_PLANES");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SV_CATCHMENT, "WID_SV_CATCHMENT");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_STL_CAPTION, "WID_STL_CAPTION");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_STL_LIST, "WID_STL_LIST");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_STL_SCROLLBAR, "WID_STL_SCROLLBAR");
|
||||
@@ -1211,6 +1220,7 @@ void SQGSWindow_Register(Squirrel *engine)
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TN_BUILDING_TOOLS_START, "WID_TN_BUILDING_TOOLS_START");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TN_RAILS, "WID_TN_RAILS");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TN_ROADS, "WID_TN_ROADS");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TN_TRAMS, "WID_TN_TRAMS");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TN_WATER, "WID_TN_WATER");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TN_AIR, "WID_TN_AIR");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TN_LANDSCAPE, "WID_TN_LANDSCAPE");
|
||||
@@ -1234,6 +1244,7 @@ void SQGSWindow_Register(Squirrel *engine)
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TE_TOWN_GENERATE, "WID_TE_TOWN_GENERATE");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TE_INDUSTRY, "WID_TE_INDUSTRY");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TE_ROADS, "WID_TE_ROADS");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TE_TRAMS, "WID_TE_TRAMS");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TE_WATER, "WID_TE_WATER");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TE_TREES, "WID_TE_TREES");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TE_SIGNS, "WID_TE_SIGNS");
|
||||
@@ -1243,10 +1254,12 @@ void SQGSWindow_Register(Squirrel *engine)
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TE_SWITCH_BAR, "WID_TE_SWITCH_BAR");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TD_SORT_ORDER, "WID_TD_SORT_ORDER");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TD_SORT_CRITERIA, "WID_TD_SORT_CRITERIA");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TD_FILTER, "WID_TD_FILTER");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TD_LIST, "WID_TD_LIST");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TD_SCROLLBAR, "WID_TD_SCROLLBAR");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TD_WORLD_POPULATION, "WID_TD_WORLD_POPULATION");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TA_CAPTION, "WID_TA_CAPTION");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TA_ZONE_BUTTON, "WID_TA_ZONE_BUTTON");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TA_RATING_INFO, "WID_TA_RATING_INFO");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TA_COMMAND_LIST, "WID_TA_COMMAND_LIST");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TA_SCROLLBAR, "WID_TA_SCROLLBAR");
|
||||
@@ -1258,6 +1271,7 @@ void SQGSWindow_Register(Squirrel *engine)
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TV_CENTER_VIEW, "WID_TV_CENTER_VIEW");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TV_SHOW_AUTHORITY, "WID_TV_SHOW_AUTHORITY");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TV_CHANGE_NAME, "WID_TV_CHANGE_NAME");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TV_CATCHMENT, "WID_TV_CATCHMENT");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TV_EXPAND, "WID_TV_EXPAND");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TV_DELETE, "WID_TV_DELETE");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TF_NEW_TOWN, "WID_TF_NEW_TOWN");
|
||||
|
||||
@@ -15,6 +15,19 @@
|
||||
* functions may still be available if you return an older API version
|
||||
* in GetAPIVersion() in info.nut.
|
||||
*
|
||||
* \b 1.10.0
|
||||
*
|
||||
* This version is not yet released. The following changes are not set in stone yet.
|
||||
*
|
||||
* API additions:
|
||||
* \li GSVehicle::BuildVehicleWithRefit
|
||||
* \li GSVehicle::GetBuildWithRefitCapacity
|
||||
* \li GSRoad::GetName
|
||||
* \li GSRoad::RoadVehCanRunOnRoad
|
||||
* \li GSRoad::RoadVehHasPowerOnRoad
|
||||
* \li GSRoad::ConvertRoadType
|
||||
* \li GSRoad::GetMaxSpeed
|
||||
*
|
||||
* \b 1.9.0
|
||||
*
|
||||
* API additions:
|
||||
@@ -34,6 +47,9 @@
|
||||
*
|
||||
* No changes
|
||||
*
|
||||
* API additions:
|
||||
* \li GSRoad::ERR_ROADTYPE_DISALLOWS_CROSSING
|
||||
*
|
||||
* \b 1.7.0 - 1.7.2
|
||||
*
|
||||
* No changes
|
||||
|
||||
@@ -135,7 +135,6 @@
|
||||
std::string json;
|
||||
ScriptAdmin::MakeJSON(vm, -1, SQUIRREL_MAX_DEPTH, json);
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (json.length() > NETWORK_GAMESCRIPT_JSON_LENGTH) {
|
||||
ScriptLog::Error("You are trying to send a table that is too large to the AdminPort. No data sent.");
|
||||
sq_pushinteger(vm, 0);
|
||||
@@ -143,7 +142,6 @@
|
||||
}
|
||||
|
||||
NetworkAdminGameScript(json.c_str());
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
sq_pushinteger(vm, 1);
|
||||
return 1;
|
||||
|
||||
@@ -130,17 +130,20 @@
|
||||
|
||||
/* static */ int ScriptAirport::GetNoiseLevelIncrease(TileIndex tile, AirportType type)
|
||||
{
|
||||
extern Town *AirportGetNearestTown(const AirportSpec *as, const TileIterator &it);
|
||||
extern uint8 GetAirportNoiseLevelForTown(const AirportSpec *as, TileIterator &it, TileIndex town_tile);
|
||||
extern Town *AirportGetNearestTown(const AirportSpec *as, const TileIterator &it, uint &mindist);
|
||||
extern uint8 GetAirportNoiseLevelForDistance(const AirportSpec *as, uint distance);
|
||||
|
||||
if (!::IsValidTile(tile)) return -1;
|
||||
if (!IsAirportInformationAvailable(type)) return -1;
|
||||
|
||||
const AirportSpec *as = ::AirportSpec::Get(type);
|
||||
if (!as->IsWithinMapBounds(0, tile)) return -1;
|
||||
|
||||
if (_settings_game.economy.station_noise_level) {
|
||||
const AirportSpec *as = ::AirportSpec::Get(type);
|
||||
AirportTileTableIterator it(as->table[0], tile);
|
||||
const Town *t = AirportGetNearestTown(as, it);
|
||||
return GetAirportNoiseLevelForTown(as, it, t->xy);
|
||||
uint dist;
|
||||
AirportGetNearestTown(as, it, dist);
|
||||
return GetAirportNoiseLevelForDistance(as, dist);
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -148,13 +151,16 @@
|
||||
|
||||
/* static */ TownID ScriptAirport::GetNearestTown(TileIndex tile, AirportType type)
|
||||
{
|
||||
extern Town *AirportGetNearestTown(const AirportSpec *as, const TileIterator &it);
|
||||
extern Town *AirportGetNearestTown(const AirportSpec *as, const TileIterator &it, uint &mindist);
|
||||
|
||||
if (!::IsValidTile(tile)) return INVALID_TOWN;
|
||||
if (!IsAirportInformationAvailable(type)) return INVALID_TOWN;
|
||||
|
||||
const AirportSpec *as = AirportSpec::Get(type);
|
||||
return AirportGetNearestTown(as, AirportTileTableIterator(as->table[0], tile))->index;
|
||||
if (!as->IsWithinMapBounds(0, tile)) return INVALID_TOWN;
|
||||
|
||||
uint dist;
|
||||
return AirportGetNearestTown(as, AirportTileTableIterator(as->table[0], tile), dist)->index;
|
||||
}
|
||||
|
||||
/* static */ uint16 ScriptAirport::GetMaintenanceCostFactor(AirportType type)
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
/* 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);
|
||||
return st != nullptr && (st->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY || st->owner == OWNER_NONE);
|
||||
}
|
||||
|
||||
/* static */ char *ScriptBaseStation::GetName(StationID station_id)
|
||||
{
|
||||
if (!IsValidBaseStation(station_id)) return NULL;
|
||||
if (!IsValidBaseStation(station_id)) return nullptr;
|
||||
|
||||
::SetDParam(0, station_id);
|
||||
return GetString(::Station::IsValidID(station_id) ? STR_STATION_NAME : STR_WAYPOINT_NAME);
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
|
||||
EnforcePrecondition(false, IsValidBaseStation(station_id));
|
||||
EnforcePrecondition(false, name != NULL);
|
||||
EnforcePrecondition(false, name != nullptr);
|
||||
const char *text = name->GetDecodedText();
|
||||
EnforcePreconditionEncodedText(false, text);
|
||||
EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_STATION_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
* @param station_id The basestation to set the name of.
|
||||
* @param name The new name of the station (can be either a raw string, or a ScriptText object).
|
||||
* @pre IsValidBaseStation(station_id).
|
||||
* @pre name != NULL && len(name) != 0.
|
||||
* @pre name != nullptr && len(name) != 0.
|
||||
* @game @pre Valid ScriptCompanyMode active in scope.
|
||||
* @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE
|
||||
* @return True if the name was changed.
|
||||
|
||||
@@ -83,7 +83,7 @@ static void _DoCommandReturnBuildBridge1(class ScriptInstance *instance)
|
||||
switch (vehicle_type) {
|
||||
case ScriptVehicle::VT_ROAD:
|
||||
type |= (TRANSPORT_ROAD << 15);
|
||||
type |= (::RoadTypeToRoadTypes((::RoadType)ScriptObject::GetRoadType()) << 8);
|
||||
type |= (ScriptRoad::GetCurrentRoadType() << 8);
|
||||
break;
|
||||
case ScriptVehicle::VT_RAIL:
|
||||
type |= (TRANSPORT_RAIL << 15);
|
||||
@@ -102,7 +102,7 @@ static void _DoCommandReturnBuildBridge1(class ScriptInstance *instance)
|
||||
|
||||
ScriptObject::SetCallbackVariable(0, start);
|
||||
ScriptObject::SetCallbackVariable(1, end);
|
||||
return ScriptObject::DoCommand(end, start, type | bridge_id, CMD_BUILD_BRIDGE, NULL, &::_DoCommandReturnBuildBridge1);
|
||||
return ScriptObject::DoCommand(end, start, type | bridge_id, CMD_BUILD_BRIDGE, nullptr, &::_DoCommandReturnBuildBridge1);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptBridge::_BuildBridgeRoad1()
|
||||
@@ -114,7 +114,7 @@ static void _DoCommandReturnBuildBridge1(class ScriptInstance *instance)
|
||||
DiagDirection dir_1 = ::DiagdirBetweenTiles(end, start);
|
||||
DiagDirection dir_2 = ::ReverseDiagDir(dir_1);
|
||||
|
||||
return ScriptObject::DoCommand(start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2) | (ScriptObject::GetRoadType() << 4), 0, CMD_BUILD_ROAD, NULL, &::_DoCommandReturnBuildBridge2);
|
||||
return ScriptObject::DoCommand(start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2) | (ScriptRoad::GetCurrentRoadType() << 4), 0, CMD_BUILD_ROAD, nullptr, &::_DoCommandReturnBuildBridge2);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptBridge::_BuildBridgeRoad2()
|
||||
@@ -126,7 +126,7 @@ static void _DoCommandReturnBuildBridge1(class ScriptInstance *instance)
|
||||
DiagDirection dir_1 = ::DiagdirBetweenTiles(end, start);
|
||||
DiagDirection dir_2 = ::ReverseDiagDir(dir_1);
|
||||
|
||||
return ScriptObject::DoCommand(end + ::TileOffsByDiagDir(dir_2), ::DiagDirToRoadBits(dir_1) | (ScriptObject::GetRoadType() << 4), 0, CMD_BUILD_ROAD);
|
||||
return ScriptObject::DoCommand(end + ::TileOffsByDiagDir(dir_2), ::DiagDirToRoadBits(dir_1) | (ScriptRoad::GetCurrentRoadType() << 4), 0, CMD_BUILD_ROAD);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptBridge::RemoveBridge(TileIndex tile)
|
||||
@@ -138,8 +138,8 @@ static void _DoCommandReturnBuildBridge1(class ScriptInstance *instance)
|
||||
|
||||
/* static */ char *ScriptBridge::GetName(BridgeID bridge_id, ScriptVehicle::VehicleType vehicle_type)
|
||||
{
|
||||
EnforcePrecondition(NULL, vehicle_type == ScriptVehicle::VT_ROAD || vehicle_type == ScriptVehicle::VT_RAIL || vehicle_type == ScriptVehicle::VT_WATER);
|
||||
if (!IsValidBridge(bridge_id)) return NULL;
|
||||
EnforcePrecondition(nullptr, vehicle_type == ScriptVehicle::VT_ROAD || vehicle_type == ScriptVehicle::VT_RAIL || vehicle_type == ScriptVehicle::VT_WATER);
|
||||
if (!IsValidBridge(bridge_id)) return nullptr;
|
||||
|
||||
return GetString(vehicle_type == ScriptVehicle::VT_WATER ? STR_LAI_BRIDGE_DESCRIPTION_AQUEDUCT : ::GetBridgeSpec(bridge_id)->transport_name[vehicle_type]);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
/* static */ char *ScriptCargo::GetCargoLabel(CargoID cargo_type)
|
||||
{
|
||||
if (!IsValidCargo(cargo_type)) return NULL;
|
||||
if (!IsValidCargo(cargo_type)) return nullptr;
|
||||
const CargoSpec *cargo = ::CargoSpec::Get(cargo_type);
|
||||
|
||||
/* cargo->label is a uint32 packing a 4 character non-terminated string,
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
CC_LIQUID = ::CC_LIQUID, ///< Liquids (Oil, Water, Rubber)
|
||||
CC_REFRIGERATED = ::CC_REFRIGERATED, ///< Refrigerated cargo (Food, Fruit)
|
||||
CC_HAZARDOUS = ::CC_HAZARDOUS, ///< Hazardous cargo (Nuclear Fuel, Explosives, etc.)
|
||||
CC_COVERED = ::CC_COVERED, ///< Covered/Sheltered Freight (Transporation in Box Vans, Silo Wagons, etc.)
|
||||
CC_COVERED = ::CC_COVERED, ///< Covered/Sheltered Freight (Transportation in Box Vans, Silo Wagons, etc.)
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
/* static */ int32 ScriptCargoMonitor::GetTownDeliveryAmount(ScriptCompany::CompanyID company, CargoID cargo, TownID town_id, bool keep_monitoring)
|
||||
{
|
||||
CompanyID cid = static_cast<CompanyID>(company);
|
||||
if (cid < OWNER_BEGIN || cid >= MAX_COMPANIES) return -1;
|
||||
if (cid >= MAX_COMPANIES) return -1;
|
||||
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
|
||||
if (!::Town::IsValidID(town_id)) return -1;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
/* static */ int32 ScriptCargoMonitor::GetIndustryDeliveryAmount(ScriptCompany::CompanyID company, CargoID cargo, IndustryID industry_id, bool keep_monitoring)
|
||||
{
|
||||
CompanyID cid = static_cast<CompanyID>(company);
|
||||
if (cid < OWNER_BEGIN || cid >= MAX_COMPANIES) return -1;
|
||||
if (cid >= MAX_COMPANIES) return -1;
|
||||
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
|
||||
if (!::Industry::IsValidID(industry_id)) return -1;
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
/* static */ int32 ScriptCargoMonitor::GetTownPickupAmount(ScriptCompany::CompanyID company, CargoID cargo, TownID town_id, bool keep_monitoring)
|
||||
{
|
||||
CompanyID cid = static_cast<CompanyID>(company);
|
||||
if (cid < OWNER_BEGIN || cid >= MAX_COMPANIES) return -1;
|
||||
if (cid >= MAX_COMPANIES) return -1;
|
||||
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
|
||||
if (!::Town::IsValidID(town_id)) return -1;
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
/* static */ int32 ScriptCargoMonitor::GetIndustryPickupAmount(ScriptCompany::CompanyID company, CargoID cargo, IndustryID industry_id, bool keep_monitoring)
|
||||
{
|
||||
CompanyID cid = static_cast<CompanyID>(company);
|
||||
if (cid < OWNER_BEGIN || cid >= MAX_COMPANIES) return -1;
|
||||
if (cid >= MAX_COMPANIES) return -1;
|
||||
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
|
||||
if (!::Industry::IsValidID(industry_id)) return -1;
|
||||
|
||||
|
||||
@@ -16,59 +16,41 @@
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
/**
|
||||
* Finds NetworkClientInfo given client-identifier,
|
||||
* is used by other methods to resolve client-identifier.
|
||||
* @param client The client to get info structure for
|
||||
* @return A pointer to corresponding CI struct or NULL when not found.
|
||||
* @return A pointer to corresponding CI struct or nullptr when not found.
|
||||
*/
|
||||
static NetworkClientInfo *FindClientInfo(ScriptClient::ClientID client)
|
||||
{
|
||||
if (client == ScriptClient::CLIENT_INVALID) return NULL;
|
||||
if (!_networking) return NULL;
|
||||
if (client == ScriptClient::CLIENT_INVALID) return nullptr;
|
||||
if (!_networking) return nullptr;
|
||||
return NetworkClientInfo::GetByClientID((::ClientID)client);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* static */ ScriptClient::ClientID ScriptClient::ResolveClientID(ScriptClient::ClientID client)
|
||||
{
|
||||
#ifdef ENABLE_NETWORK
|
||||
return (FindClientInfo(client) == NULL ? ScriptClient::CLIENT_INVALID : client);
|
||||
#else
|
||||
return CLIENT_INVALID;
|
||||
#endif
|
||||
return (FindClientInfo(client) == nullptr ? ScriptClient::CLIENT_INVALID : client);
|
||||
}
|
||||
|
||||
/* static */ char *ScriptClient::GetName(ScriptClient::ClientID client)
|
||||
{
|
||||
#ifdef ENABLE_NETWORK
|
||||
NetworkClientInfo *ci = FindClientInfo(client);
|
||||
if (ci == NULL) return NULL;
|
||||
if (ci == nullptr) return nullptr;
|
||||
return stredup(ci->client_name);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* static */ ScriptCompany::CompanyID ScriptClient::GetCompany(ScriptClient::ClientID client)
|
||||
{
|
||||
#ifdef ENABLE_NETWORK
|
||||
NetworkClientInfo *ci = FindClientInfo(client);
|
||||
if (ci == NULL) return ScriptCompany::COMPANY_INVALID;
|
||||
if (ci == nullptr) return ScriptCompany::COMPANY_INVALID;
|
||||
return (ScriptCompany::CompanyID)ci->client_playas;
|
||||
#else
|
||||
return ScriptCompany::COMPANY_INVALID;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* static */ ScriptDate::Date ScriptClient::GetJoinDate(ScriptClient::ClientID client)
|
||||
{
|
||||
#ifdef ENABLE_NETWORK
|
||||
NetworkClientInfo *ci = FindClientInfo(client);
|
||||
if (ci == NULL) return ScriptDate::DATE_INVALID;
|
||||
if (ci == nullptr) return ScriptDate::DATE_INVALID;
|
||||
return (ScriptDate::Date)ci->join_date;
|
||||
#else
|
||||
return ScriptDate::DATE_INVALID;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class ScriptClient : public ScriptObject {
|
||||
public:
|
||||
|
||||
/** Different constants related to ClientID. */
|
||||
enum ClientID {
|
||||
enum ClientID : uint32 {
|
||||
CLIENT_INVALID = 0, ///< Client is not part of anything
|
||||
CLIENT_SERVER = 1, ///< Servers always have this ID
|
||||
CLIENT_FIRST = 2, ///< The first client ID
|
||||
|
||||
@@ -19,18 +19,15 @@
|
||||
|
||||
ScriptClientList::ScriptClientList()
|
||||
{
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (!_networking) return;
|
||||
NetworkClientInfo *ci;
|
||||
FOR_ALL_CLIENT_INFOS(ci) {
|
||||
this->AddItem(ci->client_id);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ScriptClientList_Company::ScriptClientList_Company(ScriptCompany::CompanyID company)
|
||||
{
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (!_networking) return;
|
||||
CompanyID c;
|
||||
if (company == ScriptCompany::COMPANY_SPECTATOR) {
|
||||
@@ -45,5 +42,4 @@ ScriptClientList_Company::ScriptClientList_Company(ScriptCompany::CompanyID comp
|
||||
FOR_ALL_CLIENT_INFOS(ci) {
|
||||
if (ci->client_playas == c) this->AddItem(ci->client_id);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
{
|
||||
CCountedPtr<Text> counter(name);
|
||||
|
||||
EnforcePrecondition(false, name != NULL);
|
||||
EnforcePrecondition(false, name != nullptr);
|
||||
const char *text = name->GetDecodedText();
|
||||
EnforcePreconditionEncodedText(false, text);
|
||||
EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_COMPANY_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
|
||||
@@ -56,7 +56,7 @@
|
||||
/* static */ char *ScriptCompany::GetName(ScriptCompany::CompanyID company)
|
||||
{
|
||||
company = ResolveCompanyID(company);
|
||||
if (company == COMPANY_INVALID) return NULL;
|
||||
if (company == COMPANY_INVALID) return nullptr;
|
||||
|
||||
::SetDParam(0, company);
|
||||
return GetString(STR_COMPANY_NAME);
|
||||
@@ -66,7 +66,7 @@
|
||||
{
|
||||
CCountedPtr<Text> counter(name);
|
||||
|
||||
EnforcePrecondition(false, name != NULL);
|
||||
EnforcePrecondition(false, name != nullptr);
|
||||
const char *text = name->GetDecodedText();
|
||||
EnforcePreconditionEncodedText(false, text);
|
||||
EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_PRESIDENT_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
|
||||
@@ -312,7 +312,7 @@
|
||||
if ((::LiveryScheme)scheme < LS_BEGIN || (::LiveryScheme)scheme >= LS_END) return COLOUR_INVALID;
|
||||
|
||||
const Company *c = ::Company::GetIfValid(_current_company);
|
||||
if (c == NULL) return COLOUR_INVALID;
|
||||
if (c == nullptr) return COLOUR_INVALID;
|
||||
|
||||
return (ScriptCompany::Colours)c->livery[scheme].colour1;
|
||||
}
|
||||
@@ -322,7 +322,7 @@
|
||||
if ((::LiveryScheme)scheme < LS_BEGIN || (::LiveryScheme)scheme >= LS_END) return COLOUR_INVALID;
|
||||
|
||||
const Company *c = ::Company::GetIfValid(_current_company);
|
||||
if (c == NULL) return COLOUR_INVALID;
|
||||
if (c == nullptr) return COLOUR_INVALID;
|
||||
|
||||
return (ScriptCompany::Colours)c->livery[scheme].colour2;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
/**
|
||||
* Set the name of your company.
|
||||
* @param name The new name of the company (can be either a raw string, or a ScriptText object).
|
||||
* @pre name != NULL && len(name) != 0.
|
||||
* @pre name != nullptr && len(name) != 0.
|
||||
* @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE
|
||||
* @return True if the name was changed.
|
||||
*/
|
||||
@@ -156,7 +156,7 @@ public:
|
||||
/**
|
||||
* Set the name of your president.
|
||||
* @param name The new name of the president (can be either a raw string, or a ScriptText object).
|
||||
* @pre name != NULL && len(name) != 0.
|
||||
* @pre name != nullptr && len(name) != 0.
|
||||
* @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE
|
||||
* @return True if the name was changed.
|
||||
*/
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
ticks = 1;
|
||||
}
|
||||
|
||||
throw Script_Suspend(ticks, NULL);
|
||||
throw Script_Suspend(ticks, nullptr);
|
||||
}
|
||||
|
||||
/* static */ void ScriptController::Break(const char* message)
|
||||
@@ -119,7 +119,7 @@ ScriptController::~ScriptController()
|
||||
strtolower(library_name);
|
||||
|
||||
ScriptInfo *lib = ScriptObject::GetActiveInstance()->FindLibrary(library, version);
|
||||
if (lib == NULL) {
|
||||
if (lib == nullptr) {
|
||||
char error[1024];
|
||||
seprintf(error, lastof(error), "couldn't find library '%s' with version %d", library, version);
|
||||
throw sq_throwerror(vm, error);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "../../company_base.h"
|
||||
#include "../../strings_func.h"
|
||||
#include "../../rail.h"
|
||||
#include "../../road.h"
|
||||
#include "../../engine_base.h"
|
||||
#include "../../engine_func.h"
|
||||
#include "../../articulated_vehicles.h"
|
||||
@@ -25,7 +26,7 @@
|
||||
/* static */ bool ScriptEngine::IsValidEngine(EngineID engine_id)
|
||||
{
|
||||
const Engine *e = ::Engine::GetIfValid(engine_id);
|
||||
if (e == NULL || !e->IsEnabled()) return false;
|
||||
if (e == nullptr || !e->IsEnabled()) return false;
|
||||
|
||||
/* AIs have only access to engines they can purchase or still have in use.
|
||||
* Deity has access to all engined that will be or were available ever. */
|
||||
@@ -36,12 +37,12 @@
|
||||
/* static */ bool ScriptEngine::IsBuildable(EngineID engine_id)
|
||||
{
|
||||
const Engine *e = ::Engine::GetIfValid(engine_id);
|
||||
return e != NULL && ::IsEngineBuildable(engine_id, e->type, ScriptObject::GetCompany());
|
||||
return e != nullptr && ::IsEngineBuildable(engine_id, e->type, ScriptObject::GetCompany());
|
||||
}
|
||||
|
||||
/* static */ char *ScriptEngine::GetName(EngineID engine_id)
|
||||
{
|
||||
if (!IsValidEngine(engine_id)) return NULL;
|
||||
if (!IsValidEngine(engine_id)) return nullptr;
|
||||
|
||||
::SetDParam(0, engine_id);
|
||||
return GetString(STR_ENGINE_NAME);
|
||||
@@ -219,12 +220,26 @@
|
||||
return ::HasPowerOnRail((::RailType)::RailVehInfo(engine_id)->railtype, (::RailType)track_rail_type);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptEngine::CanRunOnRoad(EngineID engine_id, ScriptRoad::RoadType road_type)
|
||||
{
|
||||
return HasPowerOnRoad(engine_id, road_type);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptEngine::HasPowerOnRoad(EngineID engine_id, ScriptRoad::RoadType road_type)
|
||||
{
|
||||
if (!IsValidEngine(engine_id)) return false;
|
||||
if (GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) return false;
|
||||
if (!ScriptRoad::IsRoadTypeAvailable(road_type)) return false;
|
||||
|
||||
return ::HasPowerOnRoad((::RoadType)::RoadVehInfo(engine_id)->roadtype, (::RoadType)road_type);
|
||||
}
|
||||
|
||||
/* static */ ScriptRoad::RoadType ScriptEngine::GetRoadType(EngineID engine_id)
|
||||
{
|
||||
if (!IsValidEngine(engine_id)) return ScriptRoad::ROADTYPE_INVALID;
|
||||
if (GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) return ScriptRoad::ROADTYPE_INVALID;
|
||||
|
||||
return HasBit(::EngInfo(engine_id)->misc_flags, EF_ROAD_TRAM) ? ScriptRoad::ROADTYPE_TRAM : ScriptRoad::ROADTYPE_ROAD;
|
||||
return (ScriptRoad::RoadType)(uint)::RoadVehInfo(engine_id)->roadtype;
|
||||
}
|
||||
|
||||
/* static */ ScriptRail::RailType ScriptEngine::GetRailType(EngineID engine_id)
|
||||
@@ -256,9 +271,6 @@
|
||||
if (!IsValidEngine(engine_id)) return 0;
|
||||
|
||||
switch (GetVehicleType(engine_id)) {
|
||||
case ScriptVehicle::VT_WATER:
|
||||
return _settings_game.pf.pathfinder_for_ships != VPF_NPF ? 129 : 0;
|
||||
|
||||
case ScriptVehicle::VT_AIR:
|
||||
return ::Engine::Get(engine_id)->GetRange() * ::Engine::Get(engine_id)->GetRange();
|
||||
|
||||
|
||||
@@ -217,6 +217,28 @@ public:
|
||||
*/
|
||||
static bool HasPowerOnRail(EngineID engine_id, ScriptRail::RailType track_rail_type);
|
||||
|
||||
/**
|
||||
* Check if a road vehicle can run on a RoadType.
|
||||
* @param engine_id The engine to check.
|
||||
* @param road_type Another RoadType.
|
||||
* @pre IsValidEngine(engine_id).
|
||||
* @pre GetVehicleType(engine_id) == ScriptVehicle::VT_ROAD.
|
||||
* @pre ScriptRoad::IsRoadTypeAvailable(road_type).
|
||||
* @return Whether an engine of type 'engine_id' can run on 'road_type'.
|
||||
*/
|
||||
static bool CanRunOnRoad(EngineID engine_id, ScriptRoad::RoadType road_type);
|
||||
|
||||
/**
|
||||
* Check if a road vehicle has power on a RoadType.
|
||||
* @param engine_id The engine to check.
|
||||
* @param road_type Another RoadType.
|
||||
* @pre IsValidEngine(engine_id).
|
||||
* @pre GetVehicleType(engine_id) == ScriptVehicle::VT_ROAD.
|
||||
* @pre ScriptRoad::IsRoadTypeAvailable(road_type).
|
||||
* @return Whether an engine of type 'engine_id' has power on 'road_type'.
|
||||
*/
|
||||
static bool HasPowerOnRoad(EngineID engine_id, ScriptRoad::RoadType road_type);
|
||||
|
||||
/**
|
||||
* Get the RoadType of the engine.
|
||||
* @param engine_id The engine to get the RoadType of.
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
* @param string The string that is checked.
|
||||
*/
|
||||
#define EnforcePreconditionEncodedText(returnval, string) \
|
||||
if ((string) == NULL) { \
|
||||
if ((string) == nullptr) { \
|
||||
ScriptObject::SetLastError(ScriptError::ERR_PRECONDITION_TOO_MANY_PARAMETERS); \
|
||||
return returnval; \
|
||||
} \
|
||||
|
||||
@@ -23,7 +23,7 @@ struct ScriptEventData {
|
||||
|
||||
/* static */ void ScriptEventController::CreateEventPointer()
|
||||
{
|
||||
assert(ScriptObject::GetEventPointer() == NULL);
|
||||
assert(ScriptObject::GetEventPointer() == nullptr);
|
||||
|
||||
ScriptObject::GetEventPointer() = new ScriptEventData();
|
||||
}
|
||||
@@ -45,7 +45,7 @@ struct ScriptEventData {
|
||||
|
||||
/* static */ bool ScriptEventController::IsEventWaiting()
|
||||
{
|
||||
if (ScriptObject::GetEventPointer() == NULL) ScriptEventController::CreateEventPointer();
|
||||
if (ScriptObject::GetEventPointer() == nullptr) ScriptEventController::CreateEventPointer();
|
||||
ScriptEventData *data = (ScriptEventData *)ScriptObject::GetEventPointer();
|
||||
|
||||
return !data->stack.empty();
|
||||
@@ -53,10 +53,10 @@ struct ScriptEventData {
|
||||
|
||||
/* static */ ScriptEvent *ScriptEventController::GetNextEvent()
|
||||
{
|
||||
if (ScriptObject::GetEventPointer() == NULL) ScriptEventController::CreateEventPointer();
|
||||
if (ScriptObject::GetEventPointer() == nullptr) ScriptEventController::CreateEventPointer();
|
||||
ScriptEventData *data = (ScriptEventData *)ScriptObject::GetEventPointer();
|
||||
|
||||
if (data->stack.empty()) return NULL;
|
||||
if (data->stack.empty()) return nullptr;
|
||||
|
||||
ScriptEvent *e = data->stack.front();
|
||||
data->stack.pop();
|
||||
@@ -65,7 +65,7 @@ struct ScriptEventData {
|
||||
|
||||
/* static */ void ScriptEventController::InsertEvent(ScriptEvent *event)
|
||||
{
|
||||
if (ScriptObject::GetEventPointer() == NULL) ScriptEventController::CreateEventPointer();
|
||||
if (ScriptObject::GetEventPointer() == nullptr) ScriptEventController::CreateEventPointer();
|
||||
ScriptEventData *data = (ScriptEventData *)ScriptObject::GetEventPointer();
|
||||
|
||||
event->AddRef();
|
||||
|
||||
@@ -55,6 +55,7 @@ public:
|
||||
ET_GOAL_QUESTION_ANSWER,
|
||||
ET_EXCLUSIVE_TRANSPORT_RIGHTS,
|
||||
ET_ROAD_RECONSTRUCTION,
|
||||
ET_VEHICLE_AUTOREPLACED,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
bool ScriptEventEnginePreview::IsEngineValid() const
|
||||
{
|
||||
const Engine *e = ::Engine::GetIfValid(this->engine);
|
||||
return e != NULL && e->IsEnabled();
|
||||
return e != nullptr && e->IsEnabled();
|
||||
}
|
||||
|
||||
char *ScriptEventEnginePreview::GetName()
|
||||
{
|
||||
if (!this->IsEngineValid()) return NULL;
|
||||
if (!this->IsEngineValid()) return nullptr;
|
||||
|
||||
::SetDParam(0, this->engine);
|
||||
return GetString(STR_ENGINE_NAME);
|
||||
@@ -132,13 +132,13 @@ ScriptEventAdminPort::~ScriptEventAdminPort()
|
||||
}
|
||||
|
||||
#define SKIP_EMPTY(p) while (*(p) == ' ' || *(p) == '\n' || *(p) == '\r') (p)++;
|
||||
#define RETURN_ERROR(stack) { ScriptLog::Error("Received invalid JSON data from AdminPort."); if (stack != 0) sq_pop(vm, stack); return NULL; }
|
||||
#define RETURN_ERROR(stack) { ScriptLog::Error("Received invalid JSON data from AdminPort."); if (stack != 0) sq_pop(vm, stack); return nullptr; }
|
||||
|
||||
SQInteger ScriptEventAdminPort::GetObject(HSQUIRRELVM vm)
|
||||
{
|
||||
char *p = this->json;
|
||||
|
||||
if (this->ReadTable(vm, p) == NULL) {
|
||||
if (this->ReadTable(vm, p) == nullptr) {
|
||||
sq_pushnull(vm);
|
||||
return 1;
|
||||
}
|
||||
@@ -189,18 +189,18 @@ char *ScriptEventAdminPort::ReadTable(HSQUIRRELVM vm, char *p)
|
||||
if (*p++ != '"') RETURN_ERROR(1);
|
||||
|
||||
p = ReadString(vm, p);
|
||||
if (p == NULL) {
|
||||
if (p == nullptr) {
|
||||
sq_pop(vm, 1);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SKIP_EMPTY(p);
|
||||
if (*p++ != ':') RETURN_ERROR(2);
|
||||
|
||||
p = this->ReadValue(vm, p);
|
||||
if (p == NULL) {
|
||||
if (p == nullptr) {
|
||||
sq_pop(vm, 2);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sq_rawset(vm, -3);
|
||||
@@ -241,7 +241,7 @@ char *ScriptEventAdminPort::ReadValue(HSQUIRRELVM vm, char *p)
|
||||
case '"': {
|
||||
/* String */
|
||||
p = ReadString(vm, ++p);
|
||||
if (p == NULL) return NULL;
|
||||
if (p == nullptr) return nullptr;
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -249,7 +249,7 @@ char *ScriptEventAdminPort::ReadValue(HSQUIRRELVM vm, char *p)
|
||||
case '{': {
|
||||
/* Table */
|
||||
p = this->ReadTable(vm, p);
|
||||
if (p == NULL) return NULL;
|
||||
if (p == nullptr) return nullptr;
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -268,9 +268,9 @@ char *ScriptEventAdminPort::ReadValue(HSQUIRRELVM vm, char *p)
|
||||
|
||||
while (*p++ != ']') {
|
||||
p = this->ReadValue(vm, p);
|
||||
if (p == NULL) {
|
||||
if (p == nullptr) {
|
||||
sq_pop(vm, 1);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
sq_arrayappend(vm, -2);
|
||||
|
||||
|
||||
@@ -799,8 +799,8 @@ private:
|
||||
|
||||
/**
|
||||
* Event AircraftDestTooFar, indicating the next destination of an aircraft is too far away.
|
||||
* This event can be trigger when the current oder of an aircraft changes, usually either when
|
||||
* loading is done or when switch manually.
|
||||
* This event can be triggered when the current order of an aircraft changes, usually either when
|
||||
* loading is done or when switched manually.
|
||||
* @api ai
|
||||
*/
|
||||
class ScriptEventAircraftDestTooFar : public ScriptEvent {
|
||||
@@ -1060,4 +1060,44 @@ public:
|
||||
static ScriptEventRoadReconstruction *Convert(ScriptEventCompanyTown *instance) { return (ScriptEventRoadReconstruction *)instance; }
|
||||
};
|
||||
|
||||
/**
|
||||
* Event VehicleAutoReplaced, indicating a vehicle has been auto replaced.
|
||||
* @api ai
|
||||
*/
|
||||
class ScriptEventVehicleAutoReplaced : public ScriptEvent {
|
||||
public:
|
||||
/**
|
||||
* @param old_id The vehicle that has been replaced.
|
||||
* @param new_id The vehicle that has been created in replacement.
|
||||
*/
|
||||
ScriptEventVehicleAutoReplaced(VehicleID old_id, VehicleID new_id) :
|
||||
ScriptEvent(ET_VEHICLE_AUTOREPLACED),
|
||||
old_id(old_id),
|
||||
new_id(new_id)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Convert an ScriptEvent to the real instance.
|
||||
* @param instance The instance to convert.
|
||||
* @return The converted instance.
|
||||
*/
|
||||
static ScriptEventVehicleAutoReplaced *Convert(ScriptEvent *instance) { return (ScriptEventVehicleAutoReplaced *)instance; }
|
||||
|
||||
/**
|
||||
* Get the VehicleID of the vehicle that has been replaced.
|
||||
* @return The VehicleID of the vehicle that has been replaced. This ID is no longer valid for referencing the vehicle.
|
||||
*/
|
||||
VehicleID GetOldVehicleID() { return this->old_id; }
|
||||
|
||||
/**
|
||||
* Get the VehicleID of the vehicle that has been created in replacement.
|
||||
* @return The VehicleID of the vehicle that has been created in replacement.
|
||||
*/
|
||||
VehicleID GetNewVehicleID() { return this->new_id; }
|
||||
|
||||
private:
|
||||
VehicleID old_id; ///< The vehicle that has been replaced.
|
||||
VehicleID new_id; ///< The vehicle that has been created in replacement.
|
||||
};
|
||||
|
||||
#endif /* SCRIPT_EVENT_TYPES_HPP */
|
||||
|
||||
@@ -39,9 +39,5 @@
|
||||
|
||||
/* static */ bool ScriptGame::IsMultiplayer()
|
||||
{
|
||||
#ifdef ENABLE_NETWORK
|
||||
return _network_server;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
{
|
||||
uint i;
|
||||
const SettingDesc *sd = GetSettingFromName(setting, &i);
|
||||
return sd != NULL && sd->desc.cmd != SDT_STRING;
|
||||
return sd != nullptr && sd->desc.cmd != SDT_STRING;
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptGameSettings::GetValue(const char *setting)
|
||||
|
||||
@@ -34,14 +34,14 @@
|
||||
CCountedPtr<Text> counter(goal);
|
||||
|
||||
EnforcePrecondition(GOAL_INVALID, ScriptObject::GetCompany() == OWNER_DEITY);
|
||||
EnforcePrecondition(GOAL_INVALID, goal != NULL);
|
||||
EnforcePrecondition(GOAL_INVALID, goal != nullptr);
|
||||
const char *text = goal->GetEncodedText();
|
||||
EnforcePreconditionEncodedText(GOAL_INVALID, text);
|
||||
EnforcePrecondition(GOAL_INVALID, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID);
|
||||
|
||||
uint8 c = company;
|
||||
if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY;
|
||||
StoryPage *story_page = NULL;
|
||||
StoryPage *story_page = nullptr;
|
||||
if (type == GT_STORY_PAGE && ScriptStoryPage::IsValidStoryPage((ScriptStoryPage::StoryPageID)destination)) story_page = ::StoryPage::Get((ScriptStoryPage::StoryPageID)destination);
|
||||
|
||||
EnforcePrecondition(GOAL_INVALID, (type == GT_NONE && destination == 0) ||
|
||||
@@ -49,7 +49,7 @@
|
||||
(type == GT_INDUSTRY && ScriptIndustry::IsValidIndustry(destination)) ||
|
||||
(type == GT_TOWN && ScriptTown::IsValidTown(destination)) ||
|
||||
(type == GT_COMPANY && ScriptCompany::ResolveCompanyID((ScriptCompany::CompanyID)destination) != ScriptCompany::COMPANY_INVALID) ||
|
||||
(type == GT_STORY_PAGE && story_page != NULL && (c == INVALID_COMPANY ? story_page->company == INVALID_COMPANY : story_page->company == INVALID_COMPANY || story_page->company == c)));
|
||||
(type == GT_STORY_PAGE && story_page != nullptr && (c == INVALID_COMPANY ? story_page->company == INVALID_COMPANY : story_page->company == INVALID_COMPANY || story_page->company == c)));
|
||||
|
||||
if (!ScriptObject::DoCommand(0, type | (c << 8), destination, CMD_CREATE_GOAL, text, &ScriptInstance::DoCommandReturnGoalID)) return GOAL_INVALID;
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
|
||||
EnforcePrecondition(false, IsValidGoal(goal_id));
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
|
||||
EnforcePrecondition(false, goal != NULL);
|
||||
EnforcePrecondition(false, goal != nullptr);
|
||||
EnforcePrecondition(false, !StrEmpty(goal->GetEncodedText()));
|
||||
|
||||
return ScriptObject::DoCommand(0, goal_id, 0, CMD_SET_GOAL_TEXT, goal->GetEncodedText());
|
||||
@@ -84,12 +84,12 @@
|
||||
EnforcePrecondition(false, IsValidGoal(goal_id));
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
|
||||
|
||||
/* Ensure null as used for emtpy string. */
|
||||
if (progress != NULL && StrEmpty(progress->GetEncodedText())) {
|
||||
progress = NULL;
|
||||
/* Ensure null as used for empty string. */
|
||||
if (progress != nullptr && StrEmpty(progress->GetEncodedText())) {
|
||||
progress = nullptr;
|
||||
}
|
||||
|
||||
return ScriptObject::DoCommand(0, goal_id, 0, CMD_SET_GOAL_PROGRESS, progress != NULL ? progress->GetEncodedText() : NULL);
|
||||
return ScriptObject::DoCommand(0, goal_id, 0, CMD_SET_GOAL_PROGRESS, progress != nullptr ? progress->GetEncodedText() : nullptr);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptGoal::SetCompleted(GoalID goal_id, bool completed)
|
||||
@@ -106,7 +106,7 @@
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
|
||||
|
||||
Goal *g = Goal::Get(goal_id);
|
||||
return g != NULL && g->completed;
|
||||
return g != nullptr && g->completed;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptGoal::DoQuestion(uint16 uniqueid, uint32 target, bool is_client, Text *question, QuestionType type, uint32 buttons)
|
||||
@@ -114,7 +114,7 @@
|
||||
CCountedPtr<Text> counter(question);
|
||||
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
|
||||
EnforcePrecondition(false, question != NULL);
|
||||
EnforcePrecondition(false, question != nullptr);
|
||||
const char *text = question->GetEncodedText();
|
||||
EnforcePreconditionEncodedText(false, text);
|
||||
EnforcePrecondition(false, CountBits(buttons) >= 1 && CountBits(buttons) <= 3);
|
||||
@@ -137,13 +137,9 @@
|
||||
{
|
||||
EnforcePrecondition(false, ScriptGame::IsMultiplayer());
|
||||
EnforcePrecondition(false, ScriptClient::ResolveClientID(client) != ScriptClient::CLIENT_INVALID);
|
||||
#ifdef ENABLE_NETWORK
|
||||
/* Can only send 16 bits of client_id before proper fix is implemented */
|
||||
EnforcePrecondition(false, client < (1 << 16));
|
||||
return DoQuestion(uniqueid, client, true, question, type, buttons);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* static */ bool ScriptGoal::CloseQuestion(uint16 uniqueid)
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
* @param destination The destination of the \a type type.
|
||||
* @return The new GoalID, or GOAL_INVALID if it failed.
|
||||
* @pre No ScriptCompanyMode may be in scope.
|
||||
* @pre goal != NULL && len(goal) != 0.
|
||||
* @pre goal != nullptr && len(goal) != 0.
|
||||
* @pre company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID.
|
||||
* @pre if type is GT_STORY_PAGE, the company of the goal and the company of the story page need to match:
|
||||
* \li Global goals can only reference global story pages.
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
* @param goal The new goal text (can be either a raw string, or a ScriptText object).
|
||||
* @return True if the action succeeded.
|
||||
* @pre No ScriptCompanyMode may be in scope.
|
||||
* @pre goal != NULL && len(goal) != 0.
|
||||
* @pre goal != nullptr && len(goal) != 0.
|
||||
* @pre IsValidGoal(goal_id).
|
||||
*/
|
||||
static bool SetText(GoalID goal_id, Text *goal);
|
||||
@@ -133,7 +133,7 @@ public:
|
||||
* the progress string short.
|
||||
* @param goal_id The goal to update.
|
||||
* @param progress The new progress text for the goal (can be either a raw string,
|
||||
* or a ScriptText object). To clear the progress string you can pass NULL or an
|
||||
* or a ScriptText object). To clear the progress string you can pass nullptr or an
|
||||
* empty string.
|
||||
* @return True if the action succeeded.
|
||||
* @pre No ScriptCompanyMode may be in scope.
|
||||
@@ -169,7 +169,7 @@ public:
|
||||
* @param buttons Any combinations (at least 1, up to 3) of buttons defined in QuestionButton. Like BUTTON_YES + BUTTON_NO.
|
||||
* @return True if the action succeeded.
|
||||
* @pre No ScriptCompanyMode may be in scope.
|
||||
* @pre question != NULL && len(question) != 0.
|
||||
* @pre question != nullptr && len(question) != 0.
|
||||
* @pre company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID.
|
||||
* @pre CountBits(buttons) >= 1 && CountBits(buttons) <= 3.
|
||||
* @note Replies to the question are given by you via the event ScriptEvent_GoalQuestionAnswer.
|
||||
@@ -187,7 +187,7 @@ public:
|
||||
* @return True if the action succeeded.
|
||||
* @pre No ScriptCompanyMode may be in scope.
|
||||
* @pre ScriptGame::IsMultiplayer()
|
||||
* @pre question != NULL && len(question) != 0.
|
||||
* @pre question != nullptr && len(question) != 0.
|
||||
* @pre ResolveClientID(client) != CLIENT_INVALID.
|
||||
* @pre CountBits(buttons) >= 1 && CountBits(buttons) <= 3.
|
||||
* @note Replies to the question are given by you via the event ScriptEvent_GoalQuestionAnswer.
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
/* static */ bool ScriptGroup::IsValidGroup(GroupID group_id)
|
||||
{
|
||||
const Group *g = ::Group::GetIfValid(group_id);
|
||||
return g != NULL && g->owner == ScriptObject::GetCompany();
|
||||
return g != nullptr && g->owner == ScriptObject::GetCompany();
|
||||
}
|
||||
|
||||
/* static */ ScriptGroup::GroupID ScriptGroup::CreateGroup(ScriptVehicle::VehicleType vehicle_type, GroupID parent_group_id)
|
||||
{
|
||||
if (!ScriptObject::DoCommand(0, (::VehicleType)vehicle_type, parent_group_id, CMD_CREATE_GROUP, NULL, &ScriptInstance::DoCommandReturnGroupID)) return GROUP_INVALID;
|
||||
if (!ScriptObject::DoCommand(0, (::VehicleType)vehicle_type, parent_group_id, CMD_CREATE_GROUP, nullptr, &ScriptInstance::DoCommandReturnGroupID)) return GROUP_INVALID;
|
||||
|
||||
/* In case of test-mode, we return GroupID 0 */
|
||||
return (ScriptGroup::GroupID)0;
|
||||
@@ -55,7 +55,7 @@
|
||||
CCountedPtr<Text> counter(name);
|
||||
|
||||
EnforcePrecondition(false, IsValidGroup(group_id));
|
||||
EnforcePrecondition(false, name != NULL);
|
||||
EnforcePrecondition(false, name != nullptr);
|
||||
const char *text = name->GetDecodedText();
|
||||
EnforcePreconditionEncodedText(false, text);
|
||||
EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_GROUP_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
/* static */ char *ScriptGroup::GetName(GroupID group_id)
|
||||
{
|
||||
if (!IsValidGroup(group_id)) return NULL;
|
||||
if (!IsValidGroup(group_id)) return nullptr;
|
||||
|
||||
::SetDParam(0, group_id);
|
||||
return GetString(STR_GROUP_NAME);
|
||||
@@ -194,3 +194,35 @@
|
||||
|
||||
return occupancy / vehicle_count;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptGroup::SetPrimaryColour(GroupID group_id, ScriptCompany::Colours colour)
|
||||
{
|
||||
EnforcePrecondition(false, IsValidGroup(group_id));
|
||||
|
||||
return ScriptObject::DoCommand(0, group_id, colour << 16, CMD_SET_GROUP_LIVERY);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptGroup::SetSecondaryColour(GroupID group_id, ScriptCompany::Colours colour)
|
||||
{
|
||||
EnforcePrecondition(false, IsValidGroup(group_id));
|
||||
|
||||
return ScriptObject::DoCommand(0, group_id, (1 << 8) | (colour << 16), CMD_SET_GROUP_LIVERY);
|
||||
}
|
||||
|
||||
/* static */ ScriptCompany::Colours ScriptGroup::GetPrimaryColour(GroupID group_id)
|
||||
{
|
||||
EnforcePrecondition(ScriptCompany::Colours::COLOUR_INVALID, IsValidGroup(group_id));
|
||||
|
||||
const Group *g = ::Group::GetIfValid(group_id);
|
||||
if (!HasBit(g->livery.in_use, 0)) return ScriptCompany::Colours::COLOUR_INVALID;
|
||||
return (ScriptCompany::Colours)g->livery.colour1;
|
||||
}
|
||||
|
||||
/* static */ ScriptCompany::Colours ScriptGroup::GetSecondaryColour(GroupID group_id)
|
||||
{
|
||||
EnforcePrecondition(ScriptCompany::Colours::COLOUR_INVALID, IsValidGroup(group_id));
|
||||
|
||||
const Group *g = ::Group::GetIfValid(group_id);
|
||||
if (!HasBit(g->livery.in_use, 1)) return ScriptCompany::Colours::COLOUR_INVALID;
|
||||
return (ScriptCompany::Colours)g->livery.colour2;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
* @param group_id The group to set the name for.
|
||||
* @param name The name for the group (can be either a raw string, or a ScriptText object).
|
||||
* @pre IsValidGroup(group_id).
|
||||
* @pre name != NULL && len(name) != 0
|
||||
* @pre name != nullptr && len(name) != 0
|
||||
* @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE
|
||||
* @return True if and only if the name was changed.
|
||||
*/
|
||||
@@ -214,6 +214,36 @@ public:
|
||||
* @return The current usage of the group.
|
||||
*/
|
||||
static uint32 GetCurrentUsage(GroupID group_id);
|
||||
|
||||
/**
|
||||
* Set primary colour for a group.
|
||||
* @param group_id The group id to set the colour of.
|
||||
* @param colour Colour to set.
|
||||
* @pre IsValidGroup(group_id).
|
||||
*/
|
||||
static bool SetPrimaryColour(GroupID group_id, ScriptCompany::Colours colour);
|
||||
|
||||
/**
|
||||
* Set secondary colour for a group.
|
||||
* @param group_id The group id to set the colour of.
|
||||
* @param colour Colour to set.
|
||||
* @pre IsValidGroup(group_id).
|
||||
*/
|
||||
static bool SetSecondaryColour(GroupID group_id, ScriptCompany::Colours colour);
|
||||
|
||||
/**
|
||||
* Get primary colour of a group.
|
||||
* @param group_id The group id to get the colour of.
|
||||
* @pre IsValidGroup(group_id).
|
||||
*/
|
||||
static ScriptCompany::Colours GetPrimaryColour(GroupID group_id);
|
||||
|
||||
/**
|
||||
* Get secondary colour for a group.
|
||||
* @param group_id The group id to get the colour of.
|
||||
* @pre IsValidGroup(group_id).
|
||||
*/
|
||||
static ScriptCompany::Colours GetSecondaryColour(GroupID group_id);
|
||||
};
|
||||
|
||||
#endif /* SCRIPT_GROUP_HPP */
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
/* static */ char *ScriptIndustry::GetName(IndustryID industry_id)
|
||||
{
|
||||
if (!IsValidIndustry(industry_id)) return NULL;
|
||||
if (!IsValidIndustry(industry_id)) return nullptr;
|
||||
|
||||
::SetDParam(0, industry_id);
|
||||
return GetString(STR_INDUSTRY_NAME);
|
||||
@@ -132,9 +132,7 @@
|
||||
if (!IsValidIndustry(industry_id)) return -1;
|
||||
|
||||
Industry *ind = ::Industry::Get(industry_id);
|
||||
StationList stations;
|
||||
::FindStationsAroundTiles(ind->location, &stations);
|
||||
return (int32)stations.Length();
|
||||
return (int32)ind->stations_near.size();
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptIndustry::GetDistanceManhattanToTile(IndustryID industry_id, TileIndex tile)
|
||||
|
||||
@@ -59,14 +59,14 @@
|
||||
|
||||
/* static */ char *ScriptIndustryType::GetName(IndustryType industry_type)
|
||||
{
|
||||
if (!IsValidIndustryType(industry_type)) return NULL;
|
||||
if (!IsValidIndustryType(industry_type)) return nullptr;
|
||||
|
||||
return GetString(::GetIndustrySpec(industry_type)->name);
|
||||
}
|
||||
|
||||
/* static */ ScriptList *ScriptIndustryType::GetProducedCargo(IndustryType industry_type)
|
||||
{
|
||||
if (!IsValidIndustryType(industry_type)) return NULL;
|
||||
if (!IsValidIndustryType(industry_type)) return nullptr;
|
||||
|
||||
const IndustrySpec *ins = ::GetIndustrySpec(industry_type);
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
|
||||
/* static */ ScriptList *ScriptIndustryType::GetAcceptedCargo(IndustryType industry_type)
|
||||
{
|
||||
if (!IsValidIndustryType(industry_type)) return NULL;
|
||||
if (!IsValidIndustryType(industry_type)) return nullptr;
|
||||
|
||||
const IndustrySpec *ins = ::GetIndustrySpec(industry_type);
|
||||
|
||||
@@ -123,7 +123,8 @@
|
||||
EnforcePrecondition(false, ScriptMap::IsValidTile(tile));
|
||||
|
||||
uint32 seed = ::InteractiveRandom();
|
||||
return ScriptObject::DoCommand(tile, (1 << 16) | (::InteractiveRandomRange(::GetIndustrySpec(industry_type)->num_table) << 8) | industry_type, seed, CMD_BUILD_INDUSTRY);
|
||||
uint32 layout_index = ::InteractiveRandomRange((uint32)::GetIndustrySpec(industry_type)->layouts.size());
|
||||
return ScriptObject::DoCommand(tile, (1 << 16) | (layout_index << 8) | industry_type, seed, CMD_BUILD_INDUSTRY);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptIndustryType::ProspectIndustry(IndustryType industry_type)
|
||||
|
||||
@@ -90,7 +90,8 @@
|
||||
company = ScriptCompany::ResolveCompanyID(company);
|
||||
if (company == ScriptCompany::COMPANY_INVALID || (::RoadType)roadtype >= ROADTYPE_END || !_settings_game.economy.infrastructure_maintenance) return 0;
|
||||
|
||||
return ::RoadMaintenanceCost((::RoadType)roadtype, ::Company::Get((::CompanyID)company)->infrastructure.road[roadtype]);
|
||||
const ::Company *c = ::Company::Get((::CompanyID)company);
|
||||
return ::RoadMaintenanceCost((::RoadType)roadtype, c->infrastructure.road[roadtype], RoadTypeIsRoad((::RoadType)roadtype) ? c->infrastructure.GetRoadTotal() : c->infrastructure.GetTramTotal());
|
||||
}
|
||||
|
||||
/* static */ Money ScriptInfrastructure::GetMonthlyInfrastructureCosts(ScriptCompany::CompanyID company, Infrastructure infra_type)
|
||||
@@ -114,8 +115,9 @@
|
||||
|
||||
case INFRASTRUCTURE_ROAD: {
|
||||
Money cost;
|
||||
uint32 road_total = c->infrastructure.GetRoadTotal();
|
||||
for (::RoadType rt = ::ROADTYPE_BEGIN; rt != ::ROADTYPE_END; rt++) {
|
||||
cost += RoadMaintenanceCost(rt, c->infrastructure.road[rt]);
|
||||
cost += RoadMaintenanceCost(rt, c->infrastructure.road[rt], road_total);
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
|
||||
void End()
|
||||
{
|
||||
this->bucket_list = NULL;
|
||||
this->bucket_list = nullptr;
|
||||
this->has_no_more_items = true;
|
||||
this->item_next = 0;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ public:
|
||||
*/
|
||||
void FindNext()
|
||||
{
|
||||
if (this->bucket_list == NULL) {
|
||||
if (this->bucket_list == nullptr) {
|
||||
this->has_no_more_items = true;
|
||||
return;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
if (this->bucket_list_iter == this->bucket_list->end()) {
|
||||
this->bucket_iter++;
|
||||
if (this->bucket_iter == this->list->buckets.end()) {
|
||||
this->bucket_list = NULL;
|
||||
this->bucket_list = nullptr;
|
||||
return;
|
||||
}
|
||||
this->bucket_list = &(*this->bucket_iter).second;
|
||||
@@ -203,7 +203,7 @@ public:
|
||||
|
||||
void End()
|
||||
{
|
||||
this->bucket_list = NULL;
|
||||
this->bucket_list = nullptr;
|
||||
this->has_no_more_items = true;
|
||||
this->item_next = 0;
|
||||
}
|
||||
@@ -213,14 +213,14 @@ public:
|
||||
*/
|
||||
void FindNext()
|
||||
{
|
||||
if (this->bucket_list == NULL) {
|
||||
if (this->bucket_list == nullptr) {
|
||||
this->has_no_more_items = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->bucket_list_iter == this->bucket_list->begin()) {
|
||||
if (this->bucket_iter == this->list->buckets.begin()) {
|
||||
this->bucket_list = NULL;
|
||||
this->bucket_list = nullptr;
|
||||
return;
|
||||
}
|
||||
this->bucket_iter--;
|
||||
@@ -845,7 +845,7 @@ SQInteger ScriptList::Valuate(HSQUIRRELVM vm)
|
||||
int nparam = sq_gettop(vm) - 1;
|
||||
|
||||
if (nparam < 1) {
|
||||
return sq_throwerror(vm, "You need to give a least a Valuator as parameter to ScriptList::Valuate");
|
||||
return sq_throwerror(vm, "You need to give at least a Valuator as parameter to ScriptList::Valuate");
|
||||
}
|
||||
|
||||
/* Make sure the valuator function is really a function, and not any
|
||||
|
||||
@@ -198,7 +198,7 @@ public:
|
||||
/**
|
||||
* Remove everything that is in the given list from this list (same item index that is).
|
||||
* @param list the list of items to remove.
|
||||
* @pre list != NULL
|
||||
* @pre list != nullptr
|
||||
*/
|
||||
void RemoveList(ScriptList *list);
|
||||
|
||||
@@ -242,7 +242,7 @@ public:
|
||||
/**
|
||||
* Keeps everything that is in the given list from this list (same item index that is).
|
||||
* @param list the list of items to keep.
|
||||
* @pre list != NULL
|
||||
* @pre list != nullptr
|
||||
*/
|
||||
void KeepList(ScriptList *list);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
/* static */ void ScriptLog::Log(ScriptLog::ScriptLogType level, const char *message)
|
||||
{
|
||||
if (ScriptObject::GetLogPointer() == NULL) {
|
||||
if (ScriptObject::GetLogPointer() == nullptr) {
|
||||
ScriptObject::GetLogPointer() = new LogData();
|
||||
LogData *log = (LogData *)ScriptObject::GetLogPointer();
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
|
||||
/* Cut string after first \n */
|
||||
char *p;
|
||||
while ((p = strchr(log->lines[log->pos], '\n')) != NULL) {
|
||||
while ((p = strchr(log->lines[log->pos], '\n')) != nullptr) {
|
||||
*p = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -166,9 +166,9 @@
|
||||
/* static */ Money ScriptMarine::GetBuildCost(BuildType build_type)
|
||||
{
|
||||
switch (build_type) {
|
||||
case BT_DOCK: return ::GetPrice(PR_BUILD_STATION_DOCK, 1, NULL);
|
||||
case BT_DEPOT: return ::GetPrice(PR_BUILD_DEPOT_SHIP, 1, NULL);
|
||||
case BT_BUOY: return ::GetPrice(PR_BUILD_WAYPOINT_BUOY, 1, NULL);
|
||||
case BT_DOCK: return ::GetPrice(PR_BUILD_STATION_DOCK, 1, nullptr);
|
||||
case BT_DEPOT: return ::GetPrice(PR_BUILD_DEPOT_SHIP, 1, nullptr);
|
||||
case BT_BUOY: return ::GetPrice(PR_BUILD_WAYPOINT_BUOY, 1, nullptr);
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
{
|
||||
CCountedPtr<Text> counter(text);
|
||||
|
||||
EnforcePrecondition(false, text != NULL);
|
||||
EnforcePrecondition(false, text != nullptr);
|
||||
const char *encoded = text->GetEncodedText();
|
||||
EnforcePreconditionEncodedText(false, encoded);
|
||||
EnforcePrecondition(false, type == NT_ECONOMY || type == NT_SUBSIDIES || type == NT_GENERAL);
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
* - For #NR_TOWN this parameter should be a valid townID (ScriptTown::IsValidTown).
|
||||
* @return True if the action succeeded.
|
||||
* @pre type must be #NT_ECONOMY, #NT_SUBSIDIES, or #NT_GENERAL.
|
||||
* @pre text != NULL.
|
||||
* @pre text != nullptr.
|
||||
* @pre company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID.
|
||||
* @pre The \a reference condition must be fulfilled.
|
||||
*/
|
||||
|
||||
@@ -37,9 +37,9 @@ static ScriptStorage *GetStorage()
|
||||
}
|
||||
|
||||
|
||||
/* static */ ScriptInstance *ScriptObject::ActiveInstance::active = NULL;
|
||||
/* static */ ScriptInstance *ScriptObject::ActiveInstance::active = nullptr;
|
||||
|
||||
ScriptObject::ActiveInstance::ActiveInstance(ScriptInstance *instance)
|
||||
ScriptObject::ActiveInstance::ActiveInstance(ScriptInstance *instance) : alc_scope(instance->engine)
|
||||
{
|
||||
this->last_active = ScriptObject::ActiveInstance::active;
|
||||
ScriptObject::ActiveInstance::active = instance;
|
||||
@@ -52,7 +52,7 @@ ScriptObject::ActiveInstance::~ActiveInstance()
|
||||
|
||||
/* static */ ScriptInstance *ScriptObject::GetActiveInstance()
|
||||
{
|
||||
assert(ScriptObject::ActiveInstance::active != NULL);
|
||||
assert(ScriptObject::ActiveInstance::active != nullptr);
|
||||
return ScriptObject::ActiveInstance::active;
|
||||
}
|
||||
|
||||
@@ -318,21 +318,19 @@ ScriptObject::ActiveInstance::~ActiveInstance()
|
||||
}
|
||||
|
||||
/* Set the default callback to return a true/false result of the DoCommand */
|
||||
if (callback == NULL) callback = &ScriptInstance::DoCommandReturn;
|
||||
if (callback == nullptr) callback = &ScriptInstance::DoCommandReturn;
|
||||
|
||||
/* Are we only interested in the estimate costs? */
|
||||
bool estimate_only = GetDoCommandMode() != NULL && !GetDoCommandMode()();
|
||||
bool estimate_only = GetDoCommandMode() != nullptr && !GetDoCommandMode()();
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
/* Only set p2 when the command does not come from the network. */
|
||||
if (GetCommandFlags(cmd) & CMD_CLIENT_ID && p2 == 0) p2 = UINT32_MAX;
|
||||
#endif
|
||||
|
||||
/* Store the command for command callback validation. */
|
||||
if (!estimate_only && _networking && !_generating_world) SetLastCommand(tile, p1, p2, cmd);
|
||||
|
||||
/* Try to perform the command. */
|
||||
CommandCost res = ::DoCommandPInternal(tile, p1, p2, cmd, (_networking && !_generating_world) ? ScriptObject::GetActiveInstance()->GetDoCommandCallback() : NULL, text, false, estimate_only);
|
||||
CommandCost res = ::DoCommandPInternal(tile, p1, p2, cmd, (_networking && !_generating_world) ? ScriptObject::GetActiveInstance()->GetDoCommandCallback() : nullptr, text, false, estimate_only);
|
||||
|
||||
/* We failed; set the error and bail out */
|
||||
if (res.Failed()) {
|
||||
@@ -355,7 +353,7 @@ ScriptObject::ActiveInstance::~ActiveInstance()
|
||||
|
||||
if (_generating_world) {
|
||||
IncreaseDoCommandCosts(res.GetCost());
|
||||
if (callback != NULL) {
|
||||
if (callback != nullptr) {
|
||||
/* Insert return value into to stack and throw a control code that
|
||||
* the return value in the stack should be used. */
|
||||
callback(GetActiveInstance());
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "script_types.hpp"
|
||||
#include "../script_suspend.hpp"
|
||||
#include "../squirrel.hpp"
|
||||
|
||||
/**
|
||||
* The callback function for Mode-classes.
|
||||
@@ -48,6 +49,7 @@ protected:
|
||||
~ActiveInstance();
|
||||
private:
|
||||
ScriptInstance *last_active; ///< The active instance before we go instantiated.
|
||||
ScriptAllocatorScope alc_scope; ///< Keep the correct allocator for the script instance activated
|
||||
|
||||
static ScriptInstance *active; ///< The global current active instance.
|
||||
};
|
||||
@@ -69,7 +71,7 @@ protected:
|
||||
/**
|
||||
* Executes a raw DoCommand for the script.
|
||||
*/
|
||||
static bool DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint cmd, const char *text = NULL, Script_SuspendCallbackProc *callback = NULL);
|
||||
static bool DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint cmd, const char *text = nullptr, Script_SuspendCallbackProc *callback = nullptr);
|
||||
|
||||
/**
|
||||
* Store the latest command executed by the script.
|
||||
|
||||
@@ -66,7 +66,7 @@ static const Order *ResolveOrder(VehicleID vehicle_id, ScriptOrder::OrderPositio
|
||||
const Order *order = &v->current_order;
|
||||
if (order->GetType() == OT_GOTO_DEPOT && !(order->GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) return order;
|
||||
order_position = ScriptOrder::ResolveOrderPosition(vehicle_id, order_position);
|
||||
if (order_position == ScriptOrder::ORDER_INVALID) return NULL;
|
||||
if (order_position == ScriptOrder::ORDER_INVALID) return nullptr;
|
||||
}
|
||||
const Order *order = v->GetFirstOrder();
|
||||
while (order->GetType() == OT_IMPLICIT) order = order->next;
|
||||
@@ -108,7 +108,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||
if (!IsValidVehicleOrder(vehicle_id, order_position)) return false;
|
||||
|
||||
const Order *order = ::ResolveOrder(vehicle_id, order_position);
|
||||
return order != NULL && order->GetType() == OT_GOTO_STATION;
|
||||
return order != nullptr && order->GetType() == OT_GOTO_STATION;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptOrder::IsGotoDepotOrder(VehicleID vehicle_id, OrderPosition order_position)
|
||||
@@ -116,7 +116,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||
if (!IsValidVehicleOrder(vehicle_id, order_position)) return false;
|
||||
|
||||
const Order *order = ::ResolveOrder(vehicle_id, order_position);
|
||||
return order != NULL && order->GetType() == OT_GOTO_DEPOT;
|
||||
return order != nullptr && order->GetType() == OT_GOTO_DEPOT;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptOrder::IsGotoWaypointOrder(VehicleID vehicle_id, OrderPosition order_position)
|
||||
@@ -124,7 +124,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||
if (!IsValidVehicleOrder(vehicle_id, order_position)) return false;
|
||||
|
||||
const Order *order = ::ResolveOrder(vehicle_id, order_position);
|
||||
return order != NULL && order->GetType() == OT_GOTO_WAYPOINT;
|
||||
return order != nullptr && order->GetType() == OT_GOTO_WAYPOINT;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptOrder::IsConditionalOrder(VehicleID vehicle_id, OrderPosition order_position)
|
||||
@@ -150,7 +150,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||
if (!IsValidVehicleOrder(vehicle_id, order_position)) return false;
|
||||
|
||||
const Order *order = ::ResolveOrder(vehicle_id, order_position);
|
||||
return order != NULL && order->IsRefit();
|
||||
return order != nullptr && order->IsRefit();
|
||||
}
|
||||
|
||||
/* static */ bool ScriptOrder::IsCurrentOrderPartOfOrderList(VehicleID vehicle_id)
|
||||
@@ -240,7 +240,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||
if (!IsValidVehicleOrder(vehicle_id, order_position)) return INVALID_TILE;
|
||||
|
||||
const Order *order = ::ResolveOrder(vehicle_id, order_position);
|
||||
if (order == NULL || order->GetType() == OT_CONDITIONAL) return INVALID_TILE;
|
||||
if (order == nullptr || order->GetType() == OT_CONDITIONAL) return INVALID_TILE;
|
||||
const Vehicle *v = ::Vehicle::Get(vehicle_id);
|
||||
|
||||
switch (order->GetType()) {
|
||||
@@ -261,11 +261,13 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||
TILE_AREA_LOOP(t, st->train_station) {
|
||||
if (st->TileBelongsToRailStation(t)) return t;
|
||||
}
|
||||
} else if (st->dock_tile != INVALID_TILE) {
|
||||
return st->dock_tile;
|
||||
} else if (st->bus_stops != NULL) {
|
||||
} else if (st->ship_station.tile != INVALID_TILE) {
|
||||
TILE_AREA_LOOP(t, st->ship_station) {
|
||||
if (IsDockTile(t) && GetStationIndex(t) == st->index) return t;
|
||||
}
|
||||
} else if (st->bus_stops != nullptr) {
|
||||
return st->bus_stops->xy;
|
||||
} else if (st->truck_stops != NULL) {
|
||||
} else if (st->truck_stops != nullptr) {
|
||||
return st->truck_stops->xy;
|
||||
} else if (st->airport.tile != INVALID_TILE) {
|
||||
TILE_AREA_LOOP(tile, st->airport) {
|
||||
@@ -294,7 +296,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||
if (!IsValidVehicleOrder(vehicle_id, order_position)) return OF_INVALID;
|
||||
|
||||
const Order *order = ::ResolveOrder(vehicle_id, order_position);
|
||||
if (order == NULL || order->GetType() == OT_CONDITIONAL || order->GetType() == OT_DUMMY) return OF_INVALID;
|
||||
if (order == nullptr || order->GetType() == OT_CONDITIONAL || order->GetType() == OT_DUMMY) return OF_INVALID;
|
||||
|
||||
ScriptOrderFlags order_flags = OF_NONE;
|
||||
order_flags |= (ScriptOrderFlags)order->GetNonStopType();
|
||||
@@ -586,7 +588,7 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance *instance)
|
||||
EnforcePrecondition(false, (order_flags & OF_GOTO_NEAREST_DEPOT) == (current & OF_GOTO_NEAREST_DEPOT));
|
||||
|
||||
if ((current & OF_NON_STOP_FLAGS) != (order_flags & OF_NON_STOP_FLAGS)) {
|
||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (order_flags & OF_NON_STOP_FLAGS) << 4 | MOF_NON_STOP, CMD_MODIFY_ORDER, NULL, &::_DoCommandReturnSetOrderFlags);
|
||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (order_flags & OF_NON_STOP_FLAGS) << 4 | MOF_NON_STOP, CMD_MODIFY_ORDER, nullptr, &::_DoCommandReturnSetOrderFlags);
|
||||
}
|
||||
|
||||
switch (order->GetType()) {
|
||||
@@ -595,16 +597,16 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance *instance)
|
||||
uint data = DA_ALWAYS_GO;
|
||||
if (order_flags & OF_SERVICE_IF_NEEDED) data = DA_SERVICE;
|
||||
if (order_flags & OF_STOP_IN_DEPOT) data = DA_STOP;
|
||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (data << 4) | MOF_DEPOT_ACTION, CMD_MODIFY_ORDER, NULL, &::_DoCommandReturnSetOrderFlags);
|
||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (data << 4) | MOF_DEPOT_ACTION, CMD_MODIFY_ORDER, nullptr, &::_DoCommandReturnSetOrderFlags);
|
||||
}
|
||||
break;
|
||||
|
||||
case OT_GOTO_STATION:
|
||||
if ((current & OF_UNLOAD_FLAGS) != (order_flags & OF_UNLOAD_FLAGS)) {
|
||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (order_flags & OF_UNLOAD_FLAGS) << 2 | MOF_UNLOAD, CMD_MODIFY_ORDER, NULL, &::_DoCommandReturnSetOrderFlags);
|
||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (order_flags & OF_UNLOAD_FLAGS) << 2 | MOF_UNLOAD, CMD_MODIFY_ORDER, nullptr, &::_DoCommandReturnSetOrderFlags);
|
||||
}
|
||||
if ((current & OF_LOAD_FLAGS) != (order_flags & OF_LOAD_FLAGS)) {
|
||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (order_flags & OF_LOAD_FLAGS) >> 1 | MOF_LOAD, CMD_MODIFY_ORDER, NULL, &::_DoCommandReturnSetOrderFlags);
|
||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (order_flags & OF_LOAD_FLAGS) >> 1 | MOF_LOAD, CMD_MODIFY_ORDER, nullptr, &::_DoCommandReturnSetOrderFlags);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -667,8 +669,14 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance *instance)
|
||||
/* static */ uint ScriptOrder::GetOrderDistance(ScriptVehicle::VehicleType vehicle_type, TileIndex origin_tile, TileIndex dest_tile)
|
||||
{
|
||||
if (vehicle_type == ScriptVehicle::VT_AIR) {
|
||||
if (ScriptTile::IsStationTile(origin_tile) && ::Station::GetByTile(origin_tile)->airport.tile != INVALID_TILE) origin_tile = ::Station::GetByTile(origin_tile)->airport.tile;
|
||||
if (ScriptTile::IsStationTile(dest_tile) && ::Station::GetByTile(dest_tile)->airport.tile != INVALID_TILE) dest_tile = ::Station::GetByTile(dest_tile)->airport.tile;
|
||||
if (ScriptTile::IsStationTile(origin_tile)) {
|
||||
Station *orig_station = ::Station::GetByTile(origin_tile);
|
||||
if (orig_station != nullptr && orig_station->airport.tile != INVALID_TILE) origin_tile = orig_station->airport.tile;
|
||||
}
|
||||
if (ScriptTile::IsStationTile(dest_tile)) {
|
||||
Station *dest_station = ::Station::GetByTile(dest_tile);
|
||||
if (dest_station != nullptr && dest_station->airport.tile != INVALID_TILE) dest_tile = dest_station->airport.tile;
|
||||
}
|
||||
|
||||
return ScriptMap::DistanceSquare(origin_tile, dest_tile);
|
||||
} else {
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
/* static */ char *ScriptRail::GetName(RailType rail_type)
|
||||
{
|
||||
if (!IsRailTypeAvailable(rail_type)) return NULL;
|
||||
if (!IsRailTypeAvailable(rail_type)) return nullptr;
|
||||
|
||||
return GetString(GetRailTypeInfo((::RailType)rail_type)->strings.menu_text);
|
||||
}
|
||||
@@ -68,7 +68,7 @@
|
||||
|
||||
/* static */ bool ScriptRail::IsRailTypeAvailable(RailType rail_type)
|
||||
{
|
||||
if ((::RailType)rail_type < RAILTYPE_BEGIN || (::RailType)rail_type >= RAILTYPE_END) return false;
|
||||
if ((::RailType)rail_type >= RAILTYPE_END) return false;
|
||||
|
||||
return ScriptObject::GetCompany() == OWNER_DEITY || ::HasRailtypeAvail(ScriptObject::GetCompany(), (::RailType)rail_type);
|
||||
}
|
||||
@@ -185,7 +185,7 @@
|
||||
if (res != CALLBACK_FAILED) {
|
||||
int index = 0;
|
||||
const StationSpec *spec = StationClass::GetByGrf(file->grfid, res, &index);
|
||||
if (spec == NULL) {
|
||||
if (spec == nullptr) {
|
||||
DEBUG(grf, 1, "%s returned an invalid station ID for 'AI construction/purchase selection (18)' callback", file->filename);
|
||||
} else {
|
||||
/* We might have gotten an usable station spec. Try to build it, but if it fails we'll fall back to the original station. */
|
||||
@@ -487,10 +487,10 @@ static bool IsValidSignalType(int signal_type)
|
||||
|
||||
switch (build_type) {
|
||||
case BT_TRACK: return ::RailBuildCost((::RailType)railtype);
|
||||
case BT_SIGNAL: return ::GetPrice(PR_BUILD_SIGNALS, 1, NULL);
|
||||
case BT_DEPOT: return ::GetPrice(PR_BUILD_DEPOT_TRAIN, 1, NULL);
|
||||
case BT_STATION: return ::GetPrice(PR_BUILD_STATION_RAIL, 1, NULL) + ::GetPrice(PR_BUILD_STATION_RAIL_LENGTH, 1, NULL);
|
||||
case BT_WAYPOINT: return ::GetPrice(PR_BUILD_WAYPOINT_RAIL, 1, NULL);
|
||||
case BT_SIGNAL: return ::GetPrice(PR_BUILD_SIGNALS, 1, nullptr);
|
||||
case BT_DEPOT: return ::GetPrice(PR_BUILD_DEPOT_TRAIN, 1, nullptr);
|
||||
case BT_STATION: return ::GetPrice(PR_BUILD_STATION_RAIL, 1, nullptr) + ::GetPrice(PR_BUILD_STATION_RAIL_LENGTH, 1, nullptr);
|
||||
case BT_WAYPOINT: return ::GetPrice(PR_BUILD_WAYPOINT_RAIL, 1, nullptr);
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
ERR_UNSUITABLE_TRACK, // [STR_ERROR_NO_SUITABLE_RAILROAD_TRACK, STR_ERROR_THERE_IS_NO_RAILROAD_TRACK, STR_ERROR_THERE_ARE_NO_SIGNALS, STR_ERROR_THERE_IS_NO_STATION]
|
||||
|
||||
/** This railtype cannot have crossings */
|
||||
ERR_RAILTYPE_DISALLOWS_CROSSING, // [STR_ERROR_CROSSING_DISALLOWED]
|
||||
ERR_RAILTYPE_DISALLOWS_CROSSING, // [STR_ERROR_CROSSING_DISALLOWED_RAIL]
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,13 @@
|
||||
return ScriptCargo::HasCargoClass(cargo_type, ScriptCargo::CC_PASSENGERS) ? ROADVEHTYPE_BUS : ROADVEHTYPE_TRUCK;
|
||||
}
|
||||
|
||||
/* static */ char *ScriptRoad::GetName(RoadType road_type)
|
||||
{
|
||||
if (!IsRoadTypeAvailable(road_type)) return nullptr;
|
||||
|
||||
return GetString(GetRoadTypeInfo((::RoadType)road_type)->strings.name);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptRoad::IsRoadTile(TileIndex tile)
|
||||
{
|
||||
if (!::IsValidTile(tile)) return false;
|
||||
@@ -37,7 +44,7 @@
|
||||
if (!IsRoadTypeAvailable(GetCurrentRoadType())) return false;
|
||||
|
||||
return ::IsTileType(tile, MP_ROAD) && ::GetRoadTileType(tile) == ROAD_TILE_DEPOT &&
|
||||
(::RoadTypeToRoadTypes((::RoadType)GetCurrentRoadType()) & ::GetRoadTypes(tile)) != 0;
|
||||
HasBit(::GetPresentRoadTypes(tile), (::RoadType)GetCurrentRoadType());
|
||||
}
|
||||
|
||||
/* static */ bool ScriptRoad::IsRoadStationTile(TileIndex tile)
|
||||
@@ -45,7 +52,7 @@
|
||||
if (!::IsValidTile(tile)) return false;
|
||||
if (!IsRoadTypeAvailable(GetCurrentRoadType())) return false;
|
||||
|
||||
return ::IsRoadStopTile(tile) && (::RoadTypeToRoadTypes((::RoadType)GetCurrentRoadType()) & ::GetRoadTypes(tile)) != 0;
|
||||
return ::IsRoadStopTile(tile) && HasBit(::GetPresentRoadTypes(tile), (::RoadType)GetCurrentRoadType());
|
||||
}
|
||||
|
||||
/* static */ bool ScriptRoad::IsDriveThroughRoadStationTile(TileIndex tile)
|
||||
@@ -53,12 +60,12 @@
|
||||
if (!::IsValidTile(tile)) return false;
|
||||
if (!IsRoadTypeAvailable(GetCurrentRoadType())) return false;
|
||||
|
||||
return ::IsDriveThroughStopTile(tile) && (::RoadTypeToRoadTypes((::RoadType)GetCurrentRoadType()) & ::GetRoadTypes(tile)) != 0;
|
||||
return ::IsDriveThroughStopTile(tile) && HasBit(::GetPresentRoadTypes(tile), (::RoadType)GetCurrentRoadType());
|
||||
}
|
||||
|
||||
/* static */ bool ScriptRoad::IsRoadTypeAvailable(RoadType road_type)
|
||||
{
|
||||
return ::IsValidRoadType((::RoadType)road_type) && ::HasRoadTypesAvail(ScriptObject::GetCompany(), ::RoadTypeToRoadTypes((::RoadType)road_type));
|
||||
return (::RoadType)road_type < ROADTYPE_END && ::HasRoadTypeAvail(ScriptObject::GetCompany(), (::RoadType)road_type);
|
||||
}
|
||||
|
||||
/* static */ ScriptRoad::RoadType ScriptRoad::GetCurrentRoadType()
|
||||
@@ -73,11 +80,24 @@
|
||||
ScriptObject::SetRoadType((::RoadType)road_type);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptRoad::RoadVehCanRunOnRoad(RoadType engine_road_type, RoadType road_road_type)
|
||||
{
|
||||
return RoadVehHasPowerOnRoad(engine_road_type, road_road_type);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptRoad::RoadVehHasPowerOnRoad(RoadType engine_road_type, RoadType road_road_type)
|
||||
{
|
||||
if (!IsRoadTypeAvailable(engine_road_type)) return false;
|
||||
if (!IsRoadTypeAvailable(road_road_type)) return false;
|
||||
|
||||
return ::HasPowerOnRoad((::RoadType)engine_road_type, (::RoadType)road_road_type);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptRoad::HasRoadType(TileIndex tile, RoadType road_type)
|
||||
{
|
||||
if (!ScriptMap::IsValidTile(tile)) return false;
|
||||
if (!IsRoadTypeAvailable(road_type)) return false;
|
||||
return ::GetAnyRoadBits(tile, (::RoadType)road_type, false) != ROAD_NONE;
|
||||
return ::GetAnyRoadBits(tile, ::GetRoadTramType((::RoadType)road_type), false) != ROAD_NONE;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptRoad::AreRoadTilesConnected(TileIndex t1, TileIndex t2)
|
||||
@@ -89,8 +109,9 @@
|
||||
/* Tiles not neighbouring */
|
||||
if ((abs((int)::TileX(t1) - (int)::TileX(t2)) + abs((int)::TileY(t1) - (int)::TileY(t2))) != 1) return false;
|
||||
|
||||
RoadBits r1 = ::GetAnyRoadBits(t1, ScriptObject::GetRoadType());
|
||||
RoadBits r2 = ::GetAnyRoadBits(t2, ScriptObject::GetRoadType());
|
||||
RoadTramType rtt = ::GetRoadTramType(ScriptObject::GetRoadType());
|
||||
RoadBits r1 = ::GetAnyRoadBits(t1, rtt); // TODO
|
||||
RoadBits r2 = ::GetAnyRoadBits(t2, rtt); // TODO
|
||||
|
||||
uint dir_1 = (::TileX(t1) == ::TileX(t2)) ? (::TileY(t1) < ::TileY(t2) ? 2 : 0) : (::TileX(t1) < ::TileX(t2) ? 1 : 3);
|
||||
uint dir_2 = 2 ^ dir_1;
|
||||
@@ -100,6 +121,16 @@
|
||||
return HasBit(r1, dir_1) && HasBit(r2, dir_2) && drd2 != DRD_BOTH && drd2 != (dir_1 > dir_2 ? DRD_SOUTHBOUND : DRD_NORTHBOUND);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptRoad::ConvertRoadType(TileIndex start_tile, TileIndex end_tile, RoadType road_type)
|
||||
{
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
|
||||
EnforcePrecondition(false, ::IsValidTile(start_tile));
|
||||
EnforcePrecondition(false, ::IsValidTile(end_tile));
|
||||
EnforcePrecondition(false, IsRoadTypeAvailable(road_type));
|
||||
|
||||
return ScriptObject::DoCommand(start_tile, end_tile, (::RoadType)road_type, CMD_CONVERT_ROAD);
|
||||
}
|
||||
|
||||
/* Helper functions for ScriptRoad::CanBuildConnectedRoadParts(). */
|
||||
|
||||
/**
|
||||
@@ -245,7 +276,7 @@ static int32 LookupWithBuildOnSlopes(::Slope slope, Array *existing, int32 start
|
||||
|
||||
/* Now perform the actual rotation. */
|
||||
for (int j = 0; j < base_rotate; j++) {
|
||||
for (int i = 0; i < existing->size; i++) {
|
||||
for (size_t i = 0; i < existing->size; i++) {
|
||||
existing->array[i] = RotateNeighbour(existing->array[i]);
|
||||
}
|
||||
start = RotateNeighbour(start);
|
||||
@@ -256,7 +287,7 @@ static int32 LookupWithBuildOnSlopes(::Slope slope, Array *existing, int32 start
|
||||
RoadBits start_roadbits = NeighbourToRoadBits(start);
|
||||
RoadBits new_roadbits = start_roadbits | NeighbourToRoadBits(end);
|
||||
RoadBits existing_roadbits = ROAD_NONE;
|
||||
for (int i = 0; i < existing->size; i++) {
|
||||
for (size_t i = 0; i < existing->size; i++) {
|
||||
existing_roadbits |= NeighbourToRoadBits(existing->array[i]);
|
||||
}
|
||||
|
||||
@@ -354,7 +385,7 @@ static bool NormaliseTileOffset(int32 *tile)
|
||||
/* The start tile and end tile cannot be the same tile either. */
|
||||
if (start == end) return -1;
|
||||
|
||||
for (int i = 0; i < existing->size; i++) {
|
||||
for (size_t i = 0; i < existing->size; i++) {
|
||||
if (!NormaliseTileOffset(&existing->array[i])) return -1;
|
||||
}
|
||||
|
||||
@@ -380,7 +411,7 @@ static bool NormaliseTileOffset(int32 *tile)
|
||||
if (::IsNormalRoadTile(tile)) {
|
||||
rb = ::GetAllRoadBits(tile);
|
||||
} else {
|
||||
for (::RoadType rt = ::ROADTYPE_BEGIN; rt < ::ROADTYPE_END; rt++) rb |= ::GetAnyRoadBits(tile, rt);
|
||||
rb = ::GetAnyRoadBits(tile, RTT_ROAD) | ::GetAnyRoadBits(tile, RTT_TRAM);
|
||||
}
|
||||
for (uint i = 0; i < lengthof(neighbours); i++) {
|
||||
if (HasBit(rb, i)) existing->array[existing->size++] = neighbours[i];
|
||||
@@ -392,15 +423,15 @@ static bool NormaliseTileOffset(int32 *tile)
|
||||
/**
|
||||
* Check whether one can reach (possibly by building) a road piece the center
|
||||
* of the neighbouring tile. This includes roads and (drive through) stations.
|
||||
* @param rts The road type we want to know reachability for
|
||||
* @param rt The road type we want to know reachability for
|
||||
* @param start_tile The tile to "enter" the neighbouring tile.
|
||||
* @param neighbour The direction to the neighbouring tile to "enter".
|
||||
* @return true if and only if the tile is reachable.
|
||||
*/
|
||||
static bool NeighbourHasReachableRoad(::RoadTypes rts, TileIndex start_tile, DiagDirection neighbour)
|
||||
static bool NeighbourHasReachableRoad(::RoadType rt, TileIndex start_tile, DiagDirection neighbour)
|
||||
{
|
||||
TileIndex neighbour_tile = ::TileAddByDiagDir(start_tile, neighbour);
|
||||
if ((rts & ::GetRoadTypes(neighbour_tile)) == 0) return false;
|
||||
if (!HasBit(::GetPresentRoadTypes(neighbour_tile), rt)) return false;
|
||||
|
||||
switch (::GetTileType(neighbour_tile)) {
|
||||
case MP_ROAD:
|
||||
@@ -422,13 +453,13 @@ static bool NeighbourHasReachableRoad(::RoadTypes rts, TileIndex start_tile, Dia
|
||||
if (!::IsValidTile(tile)) return false;
|
||||
if (!IsRoadTypeAvailable(GetCurrentRoadType())) return false;
|
||||
|
||||
::RoadTypes rts = ::RoadTypeToRoadTypes((::RoadType)GetCurrentRoadType());
|
||||
::RoadType rt = (::RoadType)GetCurrentRoadType();
|
||||
int32 neighbour = 0;
|
||||
|
||||
if (TileX(tile) > 0 && NeighbourHasReachableRoad(rts, tile, DIAGDIR_NE)) neighbour++;
|
||||
if (NeighbourHasReachableRoad(rts, tile, DIAGDIR_SE)) neighbour++;
|
||||
if (NeighbourHasReachableRoad(rts, tile, DIAGDIR_SW)) neighbour++;
|
||||
if (TileY(tile) > 0 && NeighbourHasReachableRoad(rts, tile, DIAGDIR_NW)) neighbour++;
|
||||
if (TileX(tile) > 0 && NeighbourHasReachableRoad(rt, tile, DIAGDIR_NE)) neighbour++;
|
||||
if (NeighbourHasReachableRoad(rt, tile, DIAGDIR_SE)) neighbour++;
|
||||
if (NeighbourHasReachableRoad(rt, tile, DIAGDIR_SW)) neighbour++;
|
||||
if (TileY(tile) > 0 && NeighbourHasReachableRoad(rt, tile, DIAGDIR_NW)) neighbour++;
|
||||
|
||||
return neighbour;
|
||||
}
|
||||
@@ -460,10 +491,10 @@ static bool NeighbourHasReachableRoad(::RoadTypes rts, TileIndex start_tile, Dia
|
||||
EnforcePrecondition(false, ::IsValidTile(start));
|
||||
EnforcePrecondition(false, ::IsValidTile(end));
|
||||
EnforcePrecondition(false, ::TileX(start) == ::TileX(end) || ::TileY(start) == ::TileY(end));
|
||||
EnforcePrecondition(false, !one_way || ScriptObject::GetRoadType() == ::ROADTYPE_ROAD);
|
||||
EnforcePrecondition(false, !one_way || RoadTypeIsRoad(ScriptObject::GetRoadType()));
|
||||
EnforcePrecondition(false, IsRoadTypeAvailable(GetCurrentRoadType()));
|
||||
|
||||
return ScriptObject::DoCommand(start, end, (::TileY(start) != ::TileY(end) ? 4 : 0) | (((start < end) == !full) ? 1 : 2) | (ScriptObject::GetRoadType() << 3) | ((one_way ? 1 : 0) << 5) | 1 << 6, CMD_BUILD_LONG_ROAD);
|
||||
return ScriptObject::DoCommand(start, end, (::TileY(start) != ::TileY(end) ? 4 : 0) | (((start < end) == !full) ? 1 : 2) | (ScriptObject::GetRoadType() << 3) | ((one_way ? 1 : 0) << 10) | 1 << 11, CMD_BUILD_LONG_ROAD);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptRoad::BuildRoad(TileIndex start, TileIndex end)
|
||||
@@ -520,11 +551,11 @@ static bool NeighbourHasReachableRoad(::RoadTypes rts, TileIndex start_tile, Dia
|
||||
entrance_dir = (::TileX(tile) == ::TileX(front)) ? (::TileY(tile) < ::TileY(front) ? 1 : 3) : (::TileX(tile) < ::TileX(front) ? 2 : 0);
|
||||
}
|
||||
|
||||
uint p2 = station_id == ScriptStation::STATION_JOIN_ADJACENT ? 0 : 32;
|
||||
uint p2 = station_id == ScriptStation::STATION_JOIN_ADJACENT ? 0 : 4;
|
||||
p2 |= drive_through ? 2 : 0;
|
||||
p2 |= road_veh_type == ROADVEHTYPE_TRUCK ? 1 : 0;
|
||||
p2 |= ::RoadTypeToRoadTypes(ScriptObject::GetRoadType()) << 2;
|
||||
p2 |= entrance_dir << 6;
|
||||
p2 |= ScriptObject::GetRoadType() << 5;
|
||||
p2 |= entrance_dir << 3;
|
||||
p2 |= (ScriptStation::IsValidStation(station_id) ? station_id : INVALID_STATION) << 16;
|
||||
return ScriptObject::DoCommand(tile, 1 | 1 << 8, p2, CMD_BUILD_ROAD_STOP);
|
||||
}
|
||||
@@ -588,17 +619,29 @@ static bool NeighbourHasReachableRoad(::RoadTypes rts, TileIndex start_tile, Dia
|
||||
if (!ScriptRoad::IsRoadTypeAvailable(roadtype)) return -1;
|
||||
|
||||
switch (build_type) {
|
||||
case BT_ROAD: return ::GetPrice(PR_BUILD_ROAD, 1, NULL);
|
||||
case BT_DEPOT: return ::GetPrice(PR_BUILD_DEPOT_ROAD, 1, NULL);
|
||||
case BT_BUS_STOP: return ::GetPrice(PR_BUILD_STATION_BUS, 1, NULL);
|
||||
case BT_TRUCK_STOP: return ::GetPrice(PR_BUILD_STATION_TRUCK, 1, NULL);
|
||||
case BT_ROAD: return ::RoadBuildCost((::RoadType)roadtype);
|
||||
case BT_DEPOT: return ::GetPrice(PR_BUILD_DEPOT_ROAD, 1, nullptr);
|
||||
case BT_BUS_STOP: return ::GetPrice(PR_BUILD_STATION_BUS, 1, nullptr);
|
||||
case BT_TRUCK_STOP: return ::GetPrice(PR_BUILD_STATION_TRUCK, 1, nullptr);
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ ScriptRoad::RoadTramTypes ScriptRoad::GetRoadTramType(RoadType roadtype)
|
||||
{
|
||||
return (RoadTramTypes)(1 << ::GetRoadTramType((::RoadType)roadtype));
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptRoad::GetMaxSpeed(RoadType road_type)
|
||||
{
|
||||
if (!ScriptRoad::IsRoadTypeAvailable(road_type)) return 0;
|
||||
|
||||
return GetRoadTypeInfo((::RoadType)road_type)->max_speed;
|
||||
}
|
||||
|
||||
/* static */ uint16 ScriptRoad::GetMaintenanceCostFactor(RoadType roadtype)
|
||||
{
|
||||
if (!ScriptRoad::IsRoadTypeAvailable(roadtype)) return 0;
|
||||
|
||||
return roadtype == ROADTYPE_TRAM ? 3 : 2;
|
||||
return GetRoadTypeInfo((::RoadType)roadtype)->maintenance_multiplier;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define SCRIPT_ROAD_HPP
|
||||
|
||||
#include "script_tile.hpp"
|
||||
#include "../../../road.h"
|
||||
|
||||
/**
|
||||
* Class that handles all road related functions.
|
||||
@@ -36,16 +37,21 @@ public:
|
||||
/** Drive through roads can't be build on town owned roads */
|
||||
ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD, // [STR_ERROR_DRIVE_THROUGH_ON_TOWN_ROAD]
|
||||
|
||||
|
||||
/** One way roads can't have junctions */
|
||||
ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS, // [STR_ERROR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION]
|
||||
|
||||
/** This roadtype cannot have crossings */
|
||||
ERR_ROADTYPE_DISALLOWS_CROSSING, // [STR_ERROR_CROSSING_DISALLOWED_ROAD]
|
||||
|
||||
/** No suitable road could be found */
|
||||
ERR_UNSUITABLE_ROAD, // [STR_ERROR_NO_SUITABLE_ROAD, STR_ERROR_NO_SUITABLE_TRAMWAY, STR_ERROR_INCOMPATIBLE_ROAD]
|
||||
};
|
||||
|
||||
/**
|
||||
* Types of road known to the game.
|
||||
*/
|
||||
enum RoadType {
|
||||
/* Note: these values represent part of the in-game RoadType enum */
|
||||
/* Note: these values represent part of the in-game static values */
|
||||
ROADTYPE_ROAD = ::ROADTYPE_ROAD, ///< Build road objects.
|
||||
ROADTYPE_TRAM = ::ROADTYPE_TRAM, ///< Build tram objects.
|
||||
|
||||
@@ -53,6 +59,14 @@ public:
|
||||
ROADTYPE_INVALID = -1, ///< Invalid RoadType.
|
||||
};
|
||||
|
||||
/**
|
||||
* Road/tram types
|
||||
*/
|
||||
enum RoadTramTypes {
|
||||
ROADTRAMTYPES_ROAD = ::RTTB_ROAD, ///< Road road types.
|
||||
ROADTRAMTYPES_TRAM = ::RTTB_TRAM, ///< Tram road types.
|
||||
};
|
||||
|
||||
/**
|
||||
* Type of road station.
|
||||
*/
|
||||
@@ -71,6 +85,14 @@ public:
|
||||
BT_TRUCK_STOP, ///< Build a truck stop
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the name of a road type.
|
||||
* @param road_type The road type to get the name of.
|
||||
* @pre IsRoadTypeAvailable(road_type).
|
||||
* @return The name the road type has.
|
||||
*/
|
||||
static char *GetName(RoadType road_type);
|
||||
|
||||
/**
|
||||
* Determines whether a busstop or a truckstop is needed to transport a certain cargo.
|
||||
* @param cargo_type The cargo to test.
|
||||
@@ -137,6 +159,41 @@ public:
|
||||
*/
|
||||
static void SetCurrentRoadType(RoadType road_type);
|
||||
|
||||
/**
|
||||
* Check if a road vehicle built for a road type can run on another road type.
|
||||
* @param engine_road_type The road type the road vehicle is built for.
|
||||
* @param track_road_type The road type you want to check.
|
||||
* @pre ScriptRoad::IsRoadTypeAvailable(engine_road_type).
|
||||
* @pre ScriptRoad::IsRoadTypeAvailable(road_road_type).
|
||||
* @return Whether a road vehicle built for 'engine_road_type' can run on 'road_road_type'.
|
||||
*/
|
||||
static bool RoadVehCanRunOnRoad(ScriptRoad::RoadType engine_road_type, ScriptRoad::RoadType road_road_type);
|
||||
|
||||
/**
|
||||
* Check if a road vehicle built for a road type has power on another road type.
|
||||
* @param engine_road_type The road type the road vehicle is built for.
|
||||
* @param road_road_type The road type you want to check.
|
||||
* @pre ScriptRoad::IsRoadTypeAvailable(engine_road_type).
|
||||
* @pre ScriptRoad::IsRoadTypeAvailable(road_road_type).
|
||||
* @return Whether a road vehicle built for 'engine_road_type' has power on 'road_road_type'.
|
||||
*/
|
||||
static bool RoadVehHasPowerOnRoad(ScriptRoad::RoadType engine_road_type, ScriptRoad::RoadType road_road_type);
|
||||
|
||||
|
||||
/**
|
||||
* Convert the road on all tiles within a rectangle to another RoadType.
|
||||
* @param start_tile One corner of the rectangle.
|
||||
* @param end_tile The opposite corner of the rectangle.
|
||||
* @param road_type The RoadType you want to convert.
|
||||
* @pre ScriptMap::IsValidTile(start_tile).
|
||||
* @pre ScriptMap::IsValidTile(end_tile).
|
||||
* @pre IsRoadTypeAvailable(road_type).
|
||||
* @game @pre Valid ScriptCompanyMode active in scope.
|
||||
* @exception ScriptRoad::ERR_UNSUITABLE_ROAD
|
||||
* @return Whether at least some road has been converted successfully.
|
||||
*/
|
||||
static bool ConvertRoadType(TileIndex start_tile, TileIndex end_tile, RoadType road_type);
|
||||
|
||||
/**
|
||||
* Check if a given tile has RoadType.
|
||||
* @param tile The tile to check.
|
||||
@@ -162,7 +219,7 @@ public:
|
||||
static bool AreRoadTilesConnected(TileIndex tile_from, TileIndex tile_to);
|
||||
|
||||
/**
|
||||
* Lookup function for building road parts independend on whether the
|
||||
* Lookup function for building road parts independent of whether the
|
||||
* "building on slopes" setting is enabled or not.
|
||||
* This implementation can be used for abstract reasoning about a tile as
|
||||
* it needs the slope and existing road parts of the tile as information.
|
||||
@@ -193,10 +250,10 @@ public:
|
||||
static int32 CanBuildConnectedRoadParts(ScriptTile::Slope slope, struct Array *existing, TileIndex start, TileIndex end);
|
||||
|
||||
/**
|
||||
* Lookup function for building road parts independend on whether the
|
||||
* Lookup function for building road parts independent of whether the
|
||||
* "building on slopes" setting is enabled or not.
|
||||
* This implementation can be used for reasoning about an existing tile.
|
||||
* @param tile The the tile to examine.
|
||||
* @param tile The tile to examine.
|
||||
* @param start The tile from where "tile" will be entered.
|
||||
* @param end The tile from where "tile" will be exited.
|
||||
* @pre start != end.
|
||||
@@ -482,16 +539,35 @@ public:
|
||||
|
||||
/**
|
||||
* Get the baseprice of building a road-related object.
|
||||
* @param roadtype the roadtype that is build (on)
|
||||
* @param roadtype the roadtype of the object to build
|
||||
* @param build_type the type of object to build
|
||||
* @pre IsRoadTypeAvailable(railtype)
|
||||
* @pre IsRoadTypeAvailable(roadtype)
|
||||
* @return The baseprice of building the given object.
|
||||
*/
|
||||
static Money GetBuildCost(RoadType roadtype, BuildType build_type);
|
||||
|
||||
/**
|
||||
* Get the maintenance cost factor of a roadtype.
|
||||
* @param roadtype The roadtype to get the maintenance factor of.
|
||||
* Test if a road type is for road or trams.
|
||||
* @param roadtype the roadtype to test.
|
||||
* @return RoadTramTypes of the road types.
|
||||
*/
|
||||
static RoadTramTypes GetRoadTramType(RoadType roadtype);
|
||||
|
||||
/**
|
||||
* Get the maximum speed of road vehicles running on this roadtype.
|
||||
* @param road_type The roadtype to get the maximum speed of.
|
||||
* @pre IsRoadTypeAvailable(road_type)
|
||||
* @return The maximum speed road vehicles can run on this roadtype
|
||||
* or 0 if there is no limit.
|
||||
* @note The speed is in OpenTTD's internal speed unit.
|
||||
* This is mph / 0.8, which is roughly 0.5 km/h.
|
||||
* To get km/h multiply this number by 2.01168.
|
||||
*/
|
||||
static int32 GetMaxSpeed(RoadType road_type);
|
||||
|
||||
/**
|
||||
* Get the maintenance cost factor of a road type.
|
||||
* @param roadtype The road type to get the maintenance factor of.
|
||||
* @pre IsRoadTypeAvailable(roadtype)
|
||||
* @return Maintenance cost factor of the roadtype.
|
||||
*/
|
||||
|
||||
24
src/script/api/script_roadtypelist.cpp
Normal file
24
src/script/api/script_roadtypelist.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/* $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 script_roadtypelist.cpp Implementation of ScriptRoadTypeList and friends. */
|
||||
|
||||
#include "../../stdafx.h"
|
||||
#include "script_roadtypelist.hpp"
|
||||
#include "../../road_func.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
ScriptRoadTypeList::ScriptRoadTypeList(ScriptRoad::RoadTramTypes rtts)
|
||||
{
|
||||
for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
|
||||
if (!HasBit(rtts, GetRoadTramType(rt))) continue;
|
||||
if (ScriptObject::GetCompany() == OWNER_DEITY || ::HasRoadTypeAvail(ScriptObject::GetCompany(), rt)) this->AddItem(rt);
|
||||
}
|
||||
}
|
||||
31
src/script/api/script_roadtypelist.hpp
Normal file
31
src/script/api/script_roadtypelist.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/* $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 script_roadtypelist.hpp List all available roadtypes. */
|
||||
|
||||
#ifndef SCRIPT_ROADTYPELIST_HPP
|
||||
#define SCRIPT_ROADTYPELIST_HPP
|
||||
|
||||
#include "script_list.hpp"
|
||||
#include "script_road.hpp"
|
||||
|
||||
/**
|
||||
* Creates a list of all available roadtypes.
|
||||
* @api ai game
|
||||
* @ingroup ScriptList
|
||||
*/
|
||||
class ScriptRoadTypeList : public ScriptList {
|
||||
public:
|
||||
/**
|
||||
* @param rtts Bitmask of road/tram types to list.
|
||||
*/
|
||||
ScriptRoadTypeList(ScriptRoad::RoadTramTypes rtts);
|
||||
};
|
||||
|
||||
#endif /* SCRIPT_ROADTYPELIST_HPP */
|
||||
@@ -23,7 +23,7 @@
|
||||
/* 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);
|
||||
return si != nullptr && (si->owner == ScriptObject::GetCompany() || si->owner == OWNER_DEITY);
|
||||
}
|
||||
|
||||
/* static */ ScriptCompany::CompanyID ScriptSign::GetOwner(SignID sign_id)
|
||||
@@ -38,7 +38,7 @@
|
||||
CCountedPtr<Text> counter(name);
|
||||
|
||||
EnforcePrecondition(false, IsValidSign(sign_id));
|
||||
EnforcePrecondition(false, name != NULL);
|
||||
EnforcePrecondition(false, name != nullptr);
|
||||
const char *text = name->GetDecodedText();
|
||||
EnforcePreconditionEncodedText(false, text);
|
||||
EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_SIGN_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
|
||||
@@ -48,7 +48,7 @@
|
||||
|
||||
/* static */ char *ScriptSign::GetName(SignID sign_id)
|
||||
{
|
||||
if (!IsValidSign(sign_id)) return NULL;
|
||||
if (!IsValidSign(sign_id)) return nullptr;
|
||||
|
||||
::SetDParam(0, sign_id);
|
||||
return GetString(STR_SIGN_NAME);
|
||||
@@ -73,7 +73,7 @@
|
||||
CCountedPtr<Text> counter(name);
|
||||
|
||||
EnforcePrecondition(INVALID_SIGN, ::IsValidTile(location));
|
||||
EnforcePrecondition(INVALID_SIGN, name != NULL);
|
||||
EnforcePrecondition(INVALID_SIGN, name != nullptr);
|
||||
const char *text = name->GetDecodedText();
|
||||
EnforcePreconditionEncodedText(INVALID_SIGN, text);
|
||||
EnforcePreconditionCustomError(INVALID_SIGN, ::Utf8StringLength(text) < MAX_LENGTH_SIGN_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
* @param sign_id The sign to set the name for.
|
||||
* @param name The name for the sign (can be either a raw string, or a ScriptText object).
|
||||
* @pre IsValidSign(sign_id).
|
||||
* @pre name != NULL && len(name) != 0.
|
||||
* @pre name != nullptr && len(name) != 0.
|
||||
* @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE
|
||||
* @return True if and only if the name was changed.
|
||||
*/
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
* @param location The place to build the sign.
|
||||
* @param name The text to place on the sign (can be either a raw string, or a ScriptText object).
|
||||
* @pre ScriptMap::IsValidTile(location).
|
||||
* @pre name != NULL && len(name) != 0.
|
||||
* @pre name != nullptr && len(name) != 0.
|
||||
* @exception ScriptSign::ERR_SIGN_TOO_MANY_SIGNS
|
||||
* @return The SignID of the build sign (use IsValidSign() to check for validity).
|
||||
* In test-mode it returns 0 if successful, or any other value to indicate
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
/* 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);
|
||||
return st != nullptr && (st->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY || st->owner == OWNER_NONE);
|
||||
}
|
||||
|
||||
/* static */ ScriptCompany::CompanyID ScriptStation::GetOwner(StationID station_id)
|
||||
@@ -211,13 +211,11 @@ template<bool Tfrom, bool Tvia>
|
||||
if (!IsValidStation(station_id)) return false;
|
||||
if (!ScriptRoad::IsRoadTypeAvailable(road_type)) return false;
|
||||
|
||||
::RoadTypes r = RoadTypeToRoadTypes((::RoadType)road_type);
|
||||
|
||||
for (const RoadStop *rs = ::Station::Get(station_id)->GetPrimaryRoadStop(ROADSTOP_BUS); rs != NULL; rs = rs->next) {
|
||||
if ((::GetRoadTypes(rs->xy) & r) != 0) return true;
|
||||
for (const RoadStop *rs = ::Station::Get(station_id)->GetPrimaryRoadStop(ROADSTOP_BUS); rs != nullptr; rs = rs->next) {
|
||||
if (HasBit(::GetPresentRoadTypes(rs->xy), (::RoadType)road_type)) return true;
|
||||
}
|
||||
for (const RoadStop *rs = ::Station::Get(station_id)->GetPrimaryRoadStop(ROADSTOP_TRUCK); rs != NULL; rs = rs->next) {
|
||||
if ((::GetRoadTypes(rs->xy) & r) != 0) return true;
|
||||
for (const RoadStop *rs = ::Station::Get(station_id)->GetPrimaryRoadStop(ROADSTOP_TRUCK); rs != nullptr; rs = rs->next) {
|
||||
if (HasBit(::GetPresentRoadTypes(rs->xy), (::RoadType)road_type)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -32,7 +32,7 @@ ScriptStationList_Vehicle::ScriptStationList_Vehicle(VehicleID vehicle_id)
|
||||
|
||||
Vehicle *v = ::Vehicle::Get(vehicle_id);
|
||||
|
||||
for (Order *o = v->GetFirstOrder(); o != NULL; o = o->next) {
|
||||
for (Order *o = v->GetFirstOrder(); o != nullptr; o = o->next) {
|
||||
if (o->IsType(OT_GOTO_STATION)) this->AddItem(o->GetDestination());
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ private:
|
||||
|
||||
CargoCollector::CargoCollector(ScriptStationList_Cargo *parent,
|
||||
StationID station_id, CargoID cargo, StationID other) :
|
||||
list(parent), ge(NULL), other_station(other), last_key(INVALID_STATION), amount(0)
|
||||
list(parent), ge(nullptr), other_station(other), last_key(INVALID_STATION), amount(0)
|
||||
{
|
||||
if (!ScriptStation::IsValidStation(station_id)) return;
|
||||
if (!ScriptCargo::IsValidCargo(cargo)) return;
|
||||
@@ -176,7 +176,7 @@ template<ScriptStationList_Cargo::CargoSelector Tselector>
|
||||
void ScriptStationList_CargoWaiting::Add(StationID station_id, CargoID cargo, StationID other_station)
|
||||
{
|
||||
CargoCollector collector(this, station_id, cargo, other_station);
|
||||
if (collector.GE() == NULL) return;
|
||||
if (collector.GE() == nullptr) return;
|
||||
|
||||
StationCargoList::ConstIterator iter = collector.GE()->cargo.Packets()->begin();
|
||||
StationCargoList::ConstIterator end = collector.GE()->cargo.Packets()->end();
|
||||
@@ -190,7 +190,7 @@ template<ScriptStationList_Cargo::CargoSelector Tselector>
|
||||
void ScriptStationList_CargoPlanned::Add(StationID station_id, CargoID cargo, StationID other_station)
|
||||
{
|
||||
CargoCollector collector(this, station_id, cargo, other_station);
|
||||
if (collector.GE() == NULL) return;
|
||||
if (collector.GE() == nullptr) return;
|
||||
|
||||
FlowStatMap::const_iterator iter = collector.GE()->flows.begin();
|
||||
FlowStatMap::const_iterator end = collector.GE()->flows.end();
|
||||
@@ -215,7 +215,7 @@ ScriptStationList_CargoWaitingViaByFrom::ScriptStationList_CargoWaitingViaByFrom
|
||||
StationID station_id, CargoID cargo, StationID via)
|
||||
{
|
||||
CargoCollector collector(this, station_id, cargo, via);
|
||||
if (collector.GE() == NULL) return;
|
||||
if (collector.GE() == nullptr) return;
|
||||
|
||||
std::pair<StationCargoList::ConstIterator, StationCargoList::ConstIterator> range =
|
||||
collector.GE()->cargo.Packets()->equal_range(via);
|
||||
@@ -261,7 +261,7 @@ ScriptStationList_CargoPlannedFromByVia::ScriptStationList_CargoPlannedFromByVia
|
||||
StationID station_id, CargoID cargo, StationID from)
|
||||
{
|
||||
CargoCollector collector(this, station_id, cargo, from);
|
||||
if (collector.GE() == NULL) return;
|
||||
if (collector.GE() == nullptr) return;
|
||||
|
||||
FlowStatMap::const_iterator iter = collector.GE()->flows.find(from);
|
||||
if (iter == collector.GE()->flows.end()) return;
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
c,
|
||||
0,
|
||||
CMD_CREATE_STORY_PAGE,
|
||||
title != NULL? title->GetEncodedText() : NULL,
|
||||
title != nullptr? title->GetEncodedText() : nullptr,
|
||||
&ScriptInstance::DoCommandReturnStoryPageID)) return STORY_PAGE_INVALID;
|
||||
|
||||
/* In case of test-mode, we return StoryPageID 0 */
|
||||
@@ -61,7 +61,7 @@
|
||||
|
||||
EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, ScriptObject::GetCompany() == OWNER_DEITY);
|
||||
EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, IsValidStoryPage(story_page_id));
|
||||
EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, (type != SPET_TEXT && type != SPET_LOCATION) || (text != NULL && !StrEmpty(text->GetEncodedText())));
|
||||
EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, (type != SPET_TEXT && type != SPET_LOCATION) || (text != nullptr && !StrEmpty(text->GetEncodedText())));
|
||||
EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, type != SPET_LOCATION || ::IsValidTile(reference));
|
||||
EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, type != SPET_GOAL || ScriptGoal::IsValidGoal((ScriptGoal::GoalID)reference));
|
||||
EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, type != SPET_GOAL || !(StoryPage::Get(story_page_id)->company == INVALID_COMPANY && Goal::Get(reference)->company != INVALID_COMPANY));
|
||||
@@ -70,7 +70,7 @@
|
||||
story_page_id + (type << 16),
|
||||
type == SPET_GOAL ? reference : 0,
|
||||
CMD_CREATE_STORY_PAGE_ELEMENT,
|
||||
type == SPET_TEXT || type == SPET_LOCATION ? text->GetEncodedText() : NULL,
|
||||
type == SPET_TEXT || type == SPET_LOCATION ? text->GetEncodedText() : nullptr,
|
||||
&ScriptInstance::DoCommandReturnStoryPageElementID)) return STORY_PAGE_ELEMENT_INVALID;
|
||||
|
||||
/* In case of test-mode, we return StoryPageElementID 0 */
|
||||
@@ -88,7 +88,7 @@
|
||||
StoryPage *p = StoryPage::Get(pe->page);
|
||||
::StoryPageElementType type = pe->type;
|
||||
|
||||
EnforcePrecondition(false, (type != ::SPET_TEXT && type != ::SPET_LOCATION) || (text != NULL && !StrEmpty(text->GetEncodedText())));
|
||||
EnforcePrecondition(false, (type != ::SPET_TEXT && type != ::SPET_LOCATION) || (text != nullptr && !StrEmpty(text->GetEncodedText())));
|
||||
EnforcePrecondition(false, type != ::SPET_LOCATION || ::IsValidTile(reference));
|
||||
EnforcePrecondition(false, type != ::SPET_GOAL || ScriptGoal::IsValidGoal((ScriptGoal::GoalID)reference));
|
||||
EnforcePrecondition(false, type != ::SPET_GOAL || !(p->company == INVALID_COMPANY && Goal::Get(reference)->company != INVALID_COMPANY));
|
||||
@@ -97,7 +97,7 @@
|
||||
story_page_element_id,
|
||||
type == ::SPET_GOAL ? reference : 0,
|
||||
CMD_UPDATE_STORY_PAGE_ELEMENT,
|
||||
type == ::SPET_TEXT || type == ::SPET_LOCATION ? text->GetEncodedText() : NULL);
|
||||
type == ::SPET_TEXT || type == ::SPET_LOCATION ? text->GetEncodedText() : nullptr);
|
||||
}
|
||||
|
||||
/* static */ uint32 ScriptStoryPage::GetPageSortValue(StoryPageID story_page_id)
|
||||
@@ -121,7 +121,7 @@
|
||||
EnforcePrecondition(false, IsValidStoryPage(story_page_id));
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
|
||||
|
||||
return ScriptObject::DoCommand(0, story_page_id, 0, CMD_SET_STORY_PAGE_TITLE, title != NULL? title->GetEncodedText() : NULL);
|
||||
return ScriptObject::DoCommand(0, story_page_id, 0, CMD_SET_STORY_PAGE_TITLE, title != nullptr? title->GetEncodedText() : nullptr);
|
||||
}
|
||||
|
||||
/* static */ ScriptCompany::CompanyID ScriptStoryPage::GetCompany(StoryPageID story_page_id)
|
||||
@@ -147,7 +147,7 @@
|
||||
EnforcePrecondition(false, IsValidStoryPage(story_page_id));
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
|
||||
|
||||
return ScriptObject::DoCommand(0, story_page_id, date, CMD_SET_STORY_PAGE_DATE, NULL);
|
||||
return ScriptObject::DoCommand(0, story_page_id, date, CMD_SET_STORY_PAGE_DATE, nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -92,12 +92,12 @@ public:
|
||||
* Create a new story page element.
|
||||
* @param story_page_id The page id of the story page which the page element should be appended to.
|
||||
* @param type Which page element type to create.
|
||||
* @param reference A reference value to the object that is refered to by some page element types. When type is SPET_GOAL, this is the goal ID. When type is SPET_LOCATION, this is the TileIndex.
|
||||
* @param reference A reference value to the object that is referred to by some page element types. When type is SPET_GOAL, this is the goal ID. When type is SPET_LOCATION, this is the TileIndex.
|
||||
* @param text The body text of page elements that allow custom text. (SPET_TEXT and SPET_LOCATION)
|
||||
* @return The new StoryPageElementID, or STORY_PAGE_ELEMENT_INVALID if it failed.
|
||||
* @pre No ScriptCompanyMode may be in scope.
|
||||
* @pre IsValidStoryPage(story_page).
|
||||
* @pre (type != SPET_TEXT && type != SPET_LOCATION) || (text != NULL && len(text) != 0).
|
||||
* @pre (type != SPET_TEXT && type != SPET_LOCATION) || (text != nullptr && len(text) != 0).
|
||||
* @pre type != SPET_LOCATION || ScriptMap::IsValidTile(reference).
|
||||
* @pre type != SPET_GOAL || ScriptGoal::IsValidGoal(reference).
|
||||
* @pre if type is SPET_GOAL and story_page is a global page, then referenced goal must be global.
|
||||
@@ -107,12 +107,12 @@ public:
|
||||
/**
|
||||
* Update the content of a page element
|
||||
* @param story_page_element_id The page id of the story page which the page element should be appended to.
|
||||
* @param reference A reference value to the object that is refered to by some page element types. See also NewElement.
|
||||
* @param reference A reference value to the object that is referred to by some page element types. See also NewElement.
|
||||
* @param text The body text of page elements that allow custom text. See also NewElement.
|
||||
* @return True if the action succeeded.
|
||||
* @pre No ScriptCompanyMode may be in scope.
|
||||
* @pre IsValidStoryPage(story_page).
|
||||
* @pre (type != SPET_TEXT && type != SPET_LOCATION) || (text != NULL && len(text) != 0).
|
||||
* @pre (type != SPET_TEXT && type != SPET_LOCATION) || (text != nullptr && len(text) != 0).
|
||||
* @pre type != SPET_LOCATION || ScriptMap::IsValidTile(reference).
|
||||
* @pre type != SPET_GOAL || ScriptGoal::IsValidGoal(reference).
|
||||
* @pre if type is SPET_GOAL and story_page is a global page, then referenced goal must be global.
|
||||
|
||||
@@ -63,7 +63,7 @@ ScriptText::~ScriptText()
|
||||
{
|
||||
for (int i = 0; i < SCRIPT_TEXT_MAX_PARAMETERS; i++) {
|
||||
free(this->params[i]);
|
||||
if (this->paramt[i] != NULL) this->paramt[i]->Release();
|
||||
if (this->paramt[i] != nullptr) this->paramt[i]->Release();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,11 +72,11 @@ SQInteger ScriptText::_SetParam(int parameter, HSQUIRRELVM vm)
|
||||
if (parameter >= SCRIPT_TEXT_MAX_PARAMETERS) return SQ_ERROR;
|
||||
|
||||
free(this->params[parameter]);
|
||||
if (this->paramt[parameter] != NULL) this->paramt[parameter]->Release();
|
||||
if (this->paramt[parameter] != nullptr) this->paramt[parameter]->Release();
|
||||
|
||||
this->parami[parameter] = 0;
|
||||
this->params[parameter] = NULL;
|
||||
this->paramt[parameter] = NULL;
|
||||
this->params[parameter] = nullptr;
|
||||
this->paramt[parameter] = nullptr;
|
||||
|
||||
switch (sq_gettype(vm, -1)) {
|
||||
case OT_STRING: {
|
||||
@@ -97,7 +97,7 @@ SQInteger ScriptText::_SetParam(int parameter, HSQUIRRELVM vm)
|
||||
}
|
||||
|
||||
case OT_INSTANCE: {
|
||||
SQUserPointer real_instance = NULL;
|
||||
SQUserPointer real_instance = nullptr;
|
||||
HSQOBJECT instance;
|
||||
|
||||
sq_getstackobj(vm, -1, &instance);
|
||||
@@ -112,7 +112,7 @@ SQInteger ScriptText::_SetParam(int parameter, HSQUIRRELVM vm)
|
||||
|
||||
/* Get the 'real' instance of this class */
|
||||
sq_getinstanceup(vm, -1, &real_instance, 0);
|
||||
if (real_instance == NULL) return SQ_ERROR;
|
||||
if (real_instance == nullptr) return SQ_ERROR;
|
||||
|
||||
ScriptText *value = static_cast<ScriptText *>(real_instance);
|
||||
value->AddRef();
|
||||
@@ -183,7 +183,7 @@ const char *ScriptText::GetEncodedText()
|
||||
static char buf[1024];
|
||||
int param_count = 0;
|
||||
this->_GetEncodedText(buf, lastof(buf), param_count);
|
||||
return (param_count > SCRIPT_TEXT_MAX_PARAMETERS) ? NULL : buf;
|
||||
return (param_count > SCRIPT_TEXT_MAX_PARAMETERS) ? nullptr : buf;
|
||||
}
|
||||
|
||||
char *ScriptText::_GetEncodedText(char *p, char *lastofp, int ¶m_count)
|
||||
@@ -191,12 +191,12 @@ char *ScriptText::_GetEncodedText(char *p, char *lastofp, int ¶m_count)
|
||||
p += Utf8Encode(p, SCC_ENCODED);
|
||||
p += seprintf(p, lastofp, "%X", this->string);
|
||||
for (int i = 0; i < this->paramc; i++) {
|
||||
if (this->params[i] != NULL) {
|
||||
if (this->params[i] != nullptr) {
|
||||
p += seprintf(p, lastofp, ":\"%s\"", this->params[i]);
|
||||
param_count++;
|
||||
continue;
|
||||
}
|
||||
if (this->paramt[i] != NULL) {
|
||||
if (this->paramt[i] != nullptr) {
|
||||
p += seprintf(p, lastofp, ":");
|
||||
p = this->paramt[i]->_GetEncodedText(p, lastofp, param_count);
|
||||
continue;
|
||||
@@ -211,7 +211,7 @@ char *ScriptText::_GetEncodedText(char *p, char *lastofp, int ¶m_count)
|
||||
const char *Text::GetDecodedText()
|
||||
{
|
||||
const char *encoded_text = this->GetEncodedText();
|
||||
if (encoded_text == NULL) return NULL;
|
||||
if (encoded_text == nullptr) return nullptr;
|
||||
|
||||
static char buf[1024];
|
||||
::SetDParamStr(0, encoded_text);
|
||||
|
||||
@@ -23,14 +23,14 @@ class Text : public ScriptObject {
|
||||
public:
|
||||
/**
|
||||
* Convert a ScriptText to a normal string.
|
||||
* @return A string (in a static buffer), or NULL.
|
||||
* @return A string (in a static buffer), or nullptr.
|
||||
* @api -all
|
||||
*/
|
||||
virtual const char *GetEncodedText() = 0;
|
||||
|
||||
/**
|
||||
* Convert a #ScriptText into a decoded normal string.
|
||||
* @return A string (in a static buffer), or NULL.
|
||||
* @return A string (in a static buffer), or nullptr.
|
||||
* @api -all
|
||||
*/
|
||||
const char *GetDecodedText();
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
RawText(const char *text);
|
||||
~RawText();
|
||||
|
||||
/* virtual */ const char *GetEncodedText() { return this->text; }
|
||||
const char *GetEncodedText() override { return this->text; }
|
||||
private:
|
||||
const char *text;
|
||||
};
|
||||
|
||||
@@ -33,12 +33,12 @@
|
||||
case MP_WATER: return IsCoast(tile);
|
||||
case MP_ROAD:
|
||||
/* Tram bits aren't considered buildable */
|
||||
if (::GetRoadTypes(tile) != ROADTYPES_ROAD) return false;
|
||||
if (::GetRoadTypeTram(tile) != INVALID_ROADTYPE) return false;
|
||||
/* Depots and crossings aren't considered buildable */
|
||||
if (::GetRoadTileType(tile) != ROAD_TILE_NORMAL) return false;
|
||||
if (!HasExactlyOneBit(::GetRoadBits(tile, ROADTYPE_ROAD))) return false;
|
||||
if (::IsRoadOwner(tile, ROADTYPE_ROAD, OWNER_TOWN)) return true;
|
||||
if (::IsRoadOwner(tile, ROADTYPE_ROAD, ScriptObject::GetCompany())) return true;
|
||||
if (!HasExactlyOneBit(::GetRoadBits(tile, RTT_ROAD))) return false;
|
||||
if (::IsRoadOwner(tile, RTT_ROAD, OWNER_TOWN)) return true;
|
||||
if (::IsRoadOwner(tile, RTT_ROAD, ScriptObject::GetCompany())) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -201,7 +201,12 @@
|
||||
{
|
||||
if (!::IsValidTile(tile)) return false;
|
||||
|
||||
return ::TrackStatusToTrackdirBits(::GetTileTrackStatus(tile, (::TransportType)transport_type, UINT32_MAX)) != TRACKDIR_BIT_NONE;
|
||||
if (transport_type == TRANSPORT_ROAD) {
|
||||
return ::TrackStatusToTrackdirBits(::GetTileTrackStatus(tile, (::TransportType)transport_type, 0)) != TRACKDIR_BIT_NONE ||
|
||||
::TrackStatusToTrackdirBits(::GetTileTrackStatus(tile, (::TransportType)transport_type, 1)) != TRACKDIR_BIT_NONE;
|
||||
} else {
|
||||
return ::TrackStatusToTrackdirBits(::GetTileTrackStatus(tile, (::TransportType)transport_type, 0)) != TRACKDIR_BIT_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptTile::GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius)
|
||||
@@ -257,7 +262,6 @@
|
||||
|
||||
/* static */ bool ScriptTile::DemolishTile(TileIndex tile)
|
||||
{
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
|
||||
EnforcePrecondition(false, ::IsValidTile(tile));
|
||||
|
||||
return ScriptObject::DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR);
|
||||
@@ -292,7 +296,7 @@
|
||||
if (!::IsValidTile(tile)) return INVALID_TOWN;
|
||||
|
||||
Town *town = ::ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
|
||||
if (town == NULL) return INVALID_TOWN;
|
||||
if (town == nullptr) return INVALID_TOWN;
|
||||
|
||||
return town->index;
|
||||
}
|
||||
@@ -302,7 +306,7 @@
|
||||
if (!::IsValidTile(tile)) return INVALID_TOWN;
|
||||
|
||||
Town *town = ::ClosestTownFromTile(tile, UINT_MAX);
|
||||
if (town == NULL) return INVALID_TOWN;
|
||||
if (town == nullptr) return INVALID_TOWN;
|
||||
|
||||
return town->index;
|
||||
}
|
||||
@@ -310,14 +314,14 @@
|
||||
/* static */ Money ScriptTile::GetBuildCost(BuildType build_type)
|
||||
{
|
||||
switch (build_type) {
|
||||
case BT_FOUNDATION: return ::GetPrice(PR_BUILD_FOUNDATION, 1, NULL);
|
||||
case BT_TERRAFORM: return ::GetPrice(PR_TERRAFORM, 1, NULL);
|
||||
case BT_BUILD_TREES: return ::GetPrice(PR_BUILD_TREES, 1, NULL);
|
||||
case BT_CLEAR_GRASS: return ::GetPrice(PR_CLEAR_GRASS, 1, NULL);
|
||||
case BT_CLEAR_ROUGH: return ::GetPrice(PR_CLEAR_ROUGH, 1, NULL);
|
||||
case BT_CLEAR_ROCKY: return ::GetPrice(PR_CLEAR_ROCKS, 1, NULL);
|
||||
case BT_CLEAR_FIELDS: return ::GetPrice(PR_CLEAR_FIELDS, 1, NULL);
|
||||
case BT_CLEAR_HOUSE: return ::GetPrice(PR_CLEAR_HOUSE, 1, NULL);
|
||||
case BT_FOUNDATION: return ::GetPrice(PR_BUILD_FOUNDATION, 1, nullptr);
|
||||
case BT_TERRAFORM: return ::GetPrice(PR_TERRAFORM, 1, nullptr);
|
||||
case BT_BUILD_TREES: return ::GetPrice(PR_BUILD_TREES, 1, nullptr);
|
||||
case BT_CLEAR_GRASS: return ::GetPrice(PR_CLEAR_GRASS, 1, nullptr);
|
||||
case BT_CLEAR_ROUGH: return ::GetPrice(PR_CLEAR_ROUGH, 1, nullptr);
|
||||
case BT_CLEAR_ROCKY: return ::GetPrice(PR_CLEAR_ROCKS, 1, nullptr);
|
||||
case BT_CLEAR_FIELDS: return ::GetPrice(PR_CLEAR_FIELDS, 1, nullptr);
|
||||
case BT_CLEAR_HOUSE: return ::GetPrice(PR_CLEAR_HOUSE, 1, nullptr);
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
/** The area was already flat */
|
||||
ERR_AREA_ALREADY_FLAT, // [STR_ERROR_ALREADY_LEVELLED]
|
||||
|
||||
/** There is a tunnel underneed */
|
||||
/** There is a tunnel underneath */
|
||||
ERR_EXCAVATION_WOULD_DAMAGE, // [STR_ERROR_EXCAVATION_WOULD_DAMAGE]
|
||||
};
|
||||
|
||||
@@ -351,7 +351,7 @@ public:
|
||||
* @pre width > 0.
|
||||
* @pre height > 0.
|
||||
* @pre radius >= 0.
|
||||
* @return Value below 8 means no acceptance; the more the better.
|
||||
* @return Values below 8 mean no acceptance; the more the better.
|
||||
*/
|
||||
static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
|
||||
|
||||
@@ -445,7 +445,6 @@ public:
|
||||
* Destroy everything on the given tile.
|
||||
* @param tile The tile to demolish.
|
||||
* @pre ScriptMap::IsValidTile(tile).
|
||||
* @game @pre Valid ScriptCompanyMode active in scope.
|
||||
* @exception ScriptError::ERR_AREA_NOT_CLEAR
|
||||
* @return True if and only if the tile was demolished.
|
||||
*/
|
||||
|
||||
@@ -49,6 +49,32 @@ void ScriptTileList::RemoveTile(TileIndex tile)
|
||||
this->RemoveItem(tile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to get list of tiles that will cover an industry's production or acceptance.
|
||||
* @param i Industry in question
|
||||
* @param radius Catchment radius to test
|
||||
* @param bta BitmapTileArea to fill
|
||||
*/
|
||||
static void FillIndustryCatchment(const Industry *i, int radius, BitmapTileArea &bta)
|
||||
{
|
||||
TILE_AREA_LOOP(cur_tile, i->location) {
|
||||
if (!::IsTileType(cur_tile, MP_INDUSTRY) || ::GetIndustryIndex(cur_tile) != i->index) continue;
|
||||
|
||||
int tx = TileX(cur_tile);
|
||||
int ty = TileY(cur_tile);
|
||||
for (int y = -radius; y <= radius; y++) {
|
||||
if (ty + y < 0 || ty + y > (int)MapMaxY()) continue;
|
||||
for (int x = -radius; x <= radius; x++) {
|
||||
if (tx + x < 0 || tx + x > (int)MapMaxX()) continue;
|
||||
TileIndex tile = TileXY(tx + x, ty + y);
|
||||
if (!IsValidTile(tile)) continue;
|
||||
if (::IsTileType(tile, MP_INDUSTRY) && ::GetIndustryIndex(tile) == i->index) continue;
|
||||
bta.SetTile(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ScriptTileList_IndustryAccepting::ScriptTileList_IndustryAccepting(IndustryID industry_id, int radius)
|
||||
{
|
||||
if (!ScriptIndustry::IsValidIndustry(industry_id) || radius <= 0) return;
|
||||
@@ -66,12 +92,11 @@ ScriptTileList_IndustryAccepting::ScriptTileList_IndustryAccepting(IndustryID in
|
||||
|
||||
if (!_settings_game.station.modified_catchment) radius = CA_UNMODIFIED;
|
||||
|
||||
TileArea ta(i->location.tile - ::TileDiffXY(radius, radius), i->location.w + radius * 2, i->location.h + radius * 2);
|
||||
TILE_AREA_LOOP(cur_tile, ta) {
|
||||
if (!::IsValidTile(cur_tile)) continue;
|
||||
/* Exclude all tiles that belong to this industry */
|
||||
if (::IsTileType(cur_tile, MP_INDUSTRY) && ::GetIndustryIndex(cur_tile) == industry_id) continue;
|
||||
BitmapTileArea bta(TileArea(i->location).Expand(radius));
|
||||
FillIndustryCatchment(i, radius, bta);
|
||||
|
||||
BitmapTileIterator it(bta);
|
||||
for (TileIndex cur_tile = it; cur_tile != INVALID_TILE; cur_tile = ++it) {
|
||||
/* Only add the tile if it accepts the cargo (sometimes just 1 tile of an
|
||||
* industry triggers the acceptance). */
|
||||
CargoArray acceptance = ::GetAcceptanceAroundTiles(cur_tile, 1, 1, radius);
|
||||
@@ -102,12 +127,11 @@ ScriptTileList_IndustryProducing::ScriptTileList_IndustryProducing(IndustryID in
|
||||
|
||||
if (!_settings_game.station.modified_catchment) radius = CA_UNMODIFIED;
|
||||
|
||||
TileArea ta(i->location.tile - ::TileDiffXY(radius, radius), i->location.w + radius * 2, i->location.h + radius * 2);
|
||||
TILE_AREA_LOOP(cur_tile, ta) {
|
||||
if (!::IsValidTile(cur_tile)) continue;
|
||||
/* Exclude all tiles that belong to this industry */
|
||||
if (::IsTileType(cur_tile, MP_INDUSTRY) && ::GetIndustryIndex(cur_tile) == industry_id) continue;
|
||||
BitmapTileArea bta(TileArea(i->location).Expand(radius));
|
||||
FillIndustryCatchment(i, radius, bta);
|
||||
|
||||
BitmapTileIterator it(bta);
|
||||
for (TileIndex cur_tile = it; cur_tile != INVALID_TILE; cur_tile = ++it) {
|
||||
this->AddTile(cur_tile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
/* static */ char *ScriptTown::GetName(TownID town_id)
|
||||
{
|
||||
if (!IsValidTown(town_id)) return NULL;
|
||||
if (!IsValidTown(town_id)) return nullptr;
|
||||
|
||||
::SetDParam(0, town_id);
|
||||
return GetString(STR_TOWN_NAME);
|
||||
@@ -45,8 +45,8 @@
|
||||
{
|
||||
CCountedPtr<Text> counter(name);
|
||||
|
||||
const char *text = NULL;
|
||||
if (name != NULL) {
|
||||
const char *text = nullptr;
|
||||
if (name != nullptr) {
|
||||
text = name->GetDecodedText();
|
||||
EnforcePreconditionEncodedText(false, text);
|
||||
EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_TOWN_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
|
||||
@@ -60,7 +60,7 @@
|
||||
{
|
||||
CCountedPtr<Text> counter(text);
|
||||
|
||||
EnforcePrecondition(false, text != NULL);
|
||||
EnforcePrecondition(false, text != nullptr);
|
||||
const char *encoded_text = text->GetEncodedText();
|
||||
EnforcePreconditionEncodedText(false, encoded_text);
|
||||
EnforcePrecondition(false, IsValidTown(town_id));
|
||||
@@ -257,7 +257,7 @@
|
||||
if (ScriptObject::GetCompany() == OWNER_DEITY) return false;
|
||||
if (!IsValidTown(town_id)) return false;
|
||||
|
||||
return HasBit(::GetMaskOfTownActions(NULL, ScriptObject::GetCompany(), ::Town::Get(town_id)), town_action);
|
||||
return HasBit(::GetMaskOfTownActions(nullptr, ScriptObject::GetCompany(), ::Town::Get(town_id)), town_action);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptTown::PerformTownAction(TownID town_id, TownAction town_action)
|
||||
@@ -293,8 +293,8 @@
|
||||
layout = (RoadLayout) (byte)_settings_game.economy.town_layout;
|
||||
}
|
||||
|
||||
const char *text = NULL;
|
||||
if (name != NULL) {
|
||||
const char *text = nullptr;
|
||||
if (name != nullptr) {
|
||||
text = name->GetDecodedText();
|
||||
EnforcePreconditionEncodedText(false, text);
|
||||
EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_TOWN_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
|
||||
|
||||
@@ -148,7 +148,7 @@ public:
|
||||
/**
|
||||
* Rename a town.
|
||||
* @param town_id The town to rename
|
||||
* @param name The new name of the town. If NULL or an empty string is passed, the town name will be reset to the default name.
|
||||
* @param name The new name of the town. If nullptr or an empty string is passed, the town name will be reset to the default name.
|
||||
* @pre IsValidTown(town_id).
|
||||
* @return True if the action succeeded.
|
||||
* @api -ai
|
||||
@@ -402,7 +402,7 @@ public:
|
||||
* @param size The town size of the new town.
|
||||
* @param city True if the new town should be a city.
|
||||
* @param layout The town layout of the new town.
|
||||
* @param name The name of the new town. Pass NULL to use a random town name.
|
||||
* @param name The name of the new town. Pass nullptr to use a random town name.
|
||||
* @game @pre no company mode in scope || ScriptSettings.GetValue("economy.found_town") != 0.
|
||||
* @ai @pre ScriptSettings.GetValue("economy.found_town") != 0.
|
||||
* @game @pre no company mode in scope || size != TOWN_SIZE_LARGE.
|
||||
|
||||
@@ -90,7 +90,7 @@ static void _DoCommandReturnBuildTunnel1(class ScriptInstance *instance)
|
||||
uint type = 0;
|
||||
if (vehicle_type == ScriptVehicle::VT_ROAD) {
|
||||
type |= (TRANSPORT_ROAD << 8);
|
||||
type |= ::RoadTypeToRoadTypes((::RoadType)ScriptObject::GetRoadType());
|
||||
type |= ScriptRoad::GetCurrentRoadType();
|
||||
} else {
|
||||
type |= (TRANSPORT_RAIL << 8);
|
||||
type |= ScriptRail::GetCurrentRailType();
|
||||
@@ -102,7 +102,7 @@ static void _DoCommandReturnBuildTunnel1(class ScriptInstance *instance)
|
||||
}
|
||||
|
||||
ScriptObject::SetCallbackVariable(0, start);
|
||||
return ScriptObject::DoCommand(start, type, 0, CMD_BUILD_TUNNEL, NULL, &::_DoCommandReturnBuildTunnel1);
|
||||
return ScriptObject::DoCommand(start, type, 0, CMD_BUILD_TUNNEL, nullptr, &::_DoCommandReturnBuildTunnel1);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptTunnel::_BuildTunnelRoad1()
|
||||
@@ -114,7 +114,7 @@ static void _DoCommandReturnBuildTunnel1(class ScriptInstance *instance)
|
||||
DiagDirection dir_1 = ::DiagdirBetweenTiles(end, start);
|
||||
DiagDirection dir_2 = ::ReverseDiagDir(dir_1);
|
||||
|
||||
return ScriptObject::DoCommand(start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2) | (ScriptObject::GetRoadType() << 4), 0, CMD_BUILD_ROAD, NULL, &::_DoCommandReturnBuildTunnel2);
|
||||
return ScriptObject::DoCommand(start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2) | (ScriptObject::GetRoadType() << 4), 0, CMD_BUILD_ROAD, nullptr, &::_DoCommandReturnBuildTunnel2);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptTunnel::_BuildTunnelRoad2()
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
/* 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()));
|
||||
return v != nullptr && (v->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY) && (v->IsPrimaryVehicle() || (v->type == VEH_TRAIN && ::Train::From(v)->IsFreeWagon()));
|
||||
}
|
||||
|
||||
/* static */ ScriptCompany::CompanyID ScriptVehicle::GetOwner(VehicleID vehicle_id)
|
||||
@@ -46,8 +46,8 @@
|
||||
int num = 1;
|
||||
|
||||
const Train *v = ::Train::GetIfValid(vehicle_id);
|
||||
if (v != NULL) {
|
||||
while ((v = v->GetNextUnit()) != NULL) num++;
|
||||
if (v != nullptr) {
|
||||
while ((v = v->GetNextUnit()) != nullptr) num++;
|
||||
}
|
||||
|
||||
return num;
|
||||
@@ -61,27 +61,50 @@
|
||||
return v->IsGroundVehicle() ? v->GetGroundVehicleCache()->cached_total_length : -1;
|
||||
}
|
||||
|
||||
/* static */ VehicleID ScriptVehicle::BuildVehicle(TileIndex depot, EngineID engine_id)
|
||||
/* static */ VehicleID ScriptVehicle::_BuildVehicleInternal(TileIndex depot, EngineID engine_id, CargoID cargo)
|
||||
{
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
|
||||
EnforcePrecondition(VEHICLE_INVALID, ScriptObject::GetCompany() != OWNER_DEITY);
|
||||
EnforcePrecondition(VEHICLE_INVALID, ScriptEngine::IsBuildable(engine_id));
|
||||
EnforcePrecondition(VEHICLE_INVALID, cargo == CT_INVALID || ScriptCargo::IsValidCargo(cargo));
|
||||
|
||||
::VehicleType type = ::Engine::Get(engine_id)->type;
|
||||
|
||||
EnforcePreconditionCustomError(VEHICLE_INVALID, !ScriptGameSettings::IsDisabledVehicleType((ScriptVehicle::VehicleType)type), ScriptVehicle::ERR_VEHICLE_BUILD_DISABLED);
|
||||
|
||||
if (!ScriptObject::DoCommand(depot, engine_id, 0, ::GetCmdBuildVeh(type), NULL, &ScriptInstance::DoCommandReturnVehicleID)) return VEHICLE_INVALID;
|
||||
if (!ScriptObject::DoCommand(depot, engine_id | (cargo << 24), 0, ::GetCmdBuildVeh(type), nullptr, &ScriptInstance::DoCommandReturnVehicleID)) return VEHICLE_INVALID;
|
||||
|
||||
/* In case of test-mode, we return VehicleID 0 */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* static */ VehicleID ScriptVehicle::BuildVehicle(TileIndex depot, EngineID engine_id)
|
||||
{
|
||||
return _BuildVehicleInternal(depot, engine_id, CT_INVALID);
|
||||
}
|
||||
|
||||
/* static */ VehicleID ScriptVehicle::BuildVehicleWithRefit(TileIndex depot, EngineID engine_id, CargoID cargo)
|
||||
{
|
||||
EnforcePrecondition(VEHICLE_INVALID, ScriptCargo::IsValidCargo(cargo));
|
||||
return _BuildVehicleInternal(depot, engine_id, cargo);
|
||||
}
|
||||
|
||||
/* static */ int ScriptVehicle::GetBuildWithRefitCapacity(TileIndex depot, EngineID engine_id, CargoID cargo)
|
||||
{
|
||||
if (!ScriptEngine::IsBuildable(engine_id)) return -1;
|
||||
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
|
||||
|
||||
::VehicleType type = ::Engine::Get(engine_id)->type;
|
||||
|
||||
CommandCost res = ::DoCommand(depot, engine_id | (cargo << 24), 0, DC_QUERY_COST, ::GetCmdBuildVeh(type));
|
||||
return res.Succeeded() ? _returned_refit_capacity : -1;
|
||||
}
|
||||
|
||||
/* static */ VehicleID ScriptVehicle::CloneVehicle(TileIndex depot, VehicleID vehicle_id, bool share_orders)
|
||||
{
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
|
||||
EnforcePrecondition(false, IsValidVehicle(vehicle_id));
|
||||
|
||||
if (!ScriptObject::DoCommand(depot, vehicle_id, share_orders, CMD_CLONE_VEHICLE, NULL, &ScriptInstance::DoCommandReturnVehicleID)) return VEHICLE_INVALID;
|
||||
if (!ScriptObject::DoCommand(depot, vehicle_id, share_orders, CMD_CLONE_VEHICLE, nullptr, &ScriptInstance::DoCommandReturnVehicleID)) return VEHICLE_INVALID;
|
||||
|
||||
/* In case of test-mode, we return VehicleID 0 */
|
||||
return 0;
|
||||
@@ -97,13 +120,13 @@
|
||||
|
||||
const Train *v = ::Train::Get(source_vehicle_id);
|
||||
while (source_wagon-- > 0) v = v->GetNextUnit();
|
||||
const Train *w = NULL;
|
||||
const Train *w = nullptr;
|
||||
if (dest_vehicle_id != -1) {
|
||||
w = ::Train::Get(dest_vehicle_id);
|
||||
while (dest_wagon-- > 0) w = w->GetNextUnit();
|
||||
}
|
||||
|
||||
return ScriptObject::DoCommand(0, v->index | (move_attached_wagons ? 1 : 0) << 20, w == NULL ? ::INVALID_VEHICLE : w->index, CMD_MOVE_RAIL_VEHICLE);
|
||||
return ScriptObject::DoCommand(0, v->index | (move_attached_wagons ? 1 : 0) << 20, w == nullptr ? ::INVALID_VEHICLE : w->index, CMD_MOVE_RAIL_VEHICLE);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptVehicle::MoveWagon(VehicleID source_vehicle_id, int source_wagon, int dest_vehicle_id, int dest_wagon)
|
||||
@@ -220,7 +243,7 @@
|
||||
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
|
||||
EnforcePrecondition(false, IsValidVehicle(vehicle_id));
|
||||
EnforcePrecondition(false, name != NULL);
|
||||
EnforcePrecondition(false, name != nullptr);
|
||||
const char *text = name->GetDecodedText();
|
||||
EnforcePreconditionEncodedText(false, text);
|
||||
EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_VEHICLE_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
|
||||
@@ -270,7 +293,7 @@
|
||||
|
||||
/* static */ char *ScriptVehicle::GetName(VehicleID vehicle_id)
|
||||
{
|
||||
if (!IsValidVehicle(vehicle_id)) return NULL;
|
||||
if (!IsValidVehicle(vehicle_id)) return nullptr;
|
||||
|
||||
::SetDParam(0, vehicle_id);
|
||||
return GetString(STR_VEHICLE_NAME);
|
||||
@@ -378,7 +401,7 @@
|
||||
if (!IsValidVehicle(vehicle_id)) return ScriptRoad::ROADTYPE_INVALID;
|
||||
if (GetVehicleType(vehicle_id) != VT_ROAD) return ScriptRoad::ROADTYPE_INVALID;
|
||||
|
||||
return (ScriptRoad::RoadType)(::RoadVehicle::Get(vehicle_id))->roadtype;
|
||||
return (ScriptRoad::RoadType)(int)(::RoadVehicle::Get(vehicle_id))->roadtype;
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptVehicle::GetCapacity(VehicleID vehicle_id, CargoID cargo)
|
||||
@@ -387,7 +410,7 @@
|
||||
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
|
||||
|
||||
uint32 amount = 0;
|
||||
for (const Vehicle *v = ::Vehicle::Get(vehicle_id); v != NULL; v = v->Next()) {
|
||||
for (const Vehicle *v = ::Vehicle::Get(vehicle_id); v != nullptr; v = v->Next()) {
|
||||
if (v->cargo_type == cargo) amount += v->cargo_cap;
|
||||
}
|
||||
|
||||
@@ -400,7 +423,7 @@
|
||||
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
|
||||
|
||||
uint32 amount = 0;
|
||||
for (const Vehicle *v = ::Vehicle::Get(vehicle_id); v != NULL; v = v->Next()) {
|
||||
for (const Vehicle *v = ::Vehicle::Get(vehicle_id); v != nullptr; v = v->Next()) {
|
||||
if (v->cargo_type == cargo) amount += v->cargo.StoredCount();
|
||||
}
|
||||
|
||||
@@ -432,7 +455,7 @@
|
||||
if (!IsValidVehicle(vehicle_id)) return false;
|
||||
|
||||
Vehicle *v = ::Vehicle::Get(vehicle_id);
|
||||
return v->orders.list != NULL && v->orders.list->GetNumVehicles() > 1;
|
||||
return v->orders.list != nullptr && v->orders.list->GetNumVehicles() > 1;
|
||||
}
|
||||
|
||||
/* static */ int ScriptVehicle::GetReliability(VehicleID vehicle_id)
|
||||
@@ -449,9 +472,6 @@
|
||||
|
||||
const ::Vehicle *v = ::Vehicle::Get(vehicle_id);
|
||||
switch (v->type) {
|
||||
case VEH_SHIP:
|
||||
return _settings_game.pf.pathfinder_for_ships != VPF_NPF ? 129 : 0;
|
||||
|
||||
case VEH_AIRCRAFT:
|
||||
return ::Aircraft::From(v)->acache.cached_max_range_sqr;
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
* @param vehicle_id The vehicle to set the name for.
|
||||
* @param name The name for the vehicle (can be either a raw string, or a ScriptText object).
|
||||
* @pre IsValidVehicle(vehicle_id).
|
||||
* @pre name != NULL && len(name) != 0.
|
||||
* @pre name != nullptr && len(name) != 0.
|
||||
* @game @pre Valid ScriptCompanyMode active in scope.
|
||||
* @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE
|
||||
* @return True if and only if the name was changed.
|
||||
@@ -320,6 +320,41 @@ public:
|
||||
*/
|
||||
static VehicleID BuildVehicle(TileIndex depot, EngineID engine_id);
|
||||
|
||||
/**
|
||||
* Builds a vehicle with the given engine at the given depot and refits it to the given cargo.
|
||||
* @param depot The depot where the vehicle will be build.
|
||||
* @param engine_id The engine to use for this vehicle.
|
||||
* @param cargo The cargo to refit to.
|
||||
* @pre The tile at depot has a depot that can build the engine and
|
||||
* is owned by you.
|
||||
* @pre ScriptEngine::IsBuildable(engine_id).
|
||||
* @pre ScriptCargo::IsValidCargo(cargo).
|
||||
* @game @pre Valid ScriptCompanyMode active in scope.
|
||||
* @exception ScriptVehicle::ERR_VEHICLE_TOO_MANY
|
||||
* @exception ScriptVehicle::ERR_VEHICLE_BUILD_DISABLED
|
||||
* @exception ScriptVehicle::ERR_VEHICLE_WRONG_DEPOT
|
||||
* @return The VehicleID of the new vehicle, or an invalid VehicleID when
|
||||
* it failed. Check the return value using IsValidVehicle. In test-mode
|
||||
* 0 is returned if it was successful; any other value indicates failure.
|
||||
* @note In Test Mode it means you can't assign orders yet to this vehicle,
|
||||
* as the vehicle isn't really built yet. Build it for real first before
|
||||
* assigning orders.
|
||||
*/
|
||||
static VehicleID BuildVehicleWithRefit(TileIndex depot, EngineID engine_id, CargoID cargo);
|
||||
|
||||
/**
|
||||
* Gets the capacity of a vehicle built at the given depot with the given engine and refitted to the given cargo.
|
||||
* @param depot The depot where the vehicle will be build.
|
||||
* @param engine_id The engine to use for this vehicle.
|
||||
* @param cargo The cargo to refit to.
|
||||
* @pre The tile at depot has a depot that can build the engine and
|
||||
* is owned by you.
|
||||
* @pre ScriptEngine::IsBuildable(engine_id).
|
||||
* @pre ScriptCargo::IsValidCargo(cargo).
|
||||
* @return The capacity the vehicle will have when refited.
|
||||
*/
|
||||
static int GetBuildWithRefitCapacity(TileIndex depot, EngineID engine_id, CargoID cargo);
|
||||
|
||||
/**
|
||||
* Clones a vehicle at the given depot, copying or cloning its orders.
|
||||
* @param depot The depot where the vehicle will be build.
|
||||
@@ -563,6 +598,11 @@ public:
|
||||
static uint GetMaximumOrderDistance(VehicleID vehicle_id);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Internal function used by BuildVehicle(WithRefit).
|
||||
*/
|
||||
static VehicleID _BuildVehicleInternal(TileIndex depot, EngineID engine_id, CargoID cargo);
|
||||
|
||||
/**
|
||||
* Internal function used by SellWagon(Chain).
|
||||
*/
|
||||
|
||||
@@ -102,7 +102,7 @@ ScriptVehicleList_SharedOrders::ScriptVehicleList_SharedOrders(VehicleID vehicle
|
||||
{
|
||||
if (!ScriptVehicle::IsValidVehicle(vehicle_id)) return;
|
||||
|
||||
for (const Vehicle *v = Vehicle::Get(vehicle_id)->FirstShared(); v != NULL; v = v->NextShared()) {
|
||||
for (const Vehicle *v = Vehicle::Get(vehicle_id)->FirstShared(); v != nullptr; v = v->NextShared()) {
|
||||
this->AddItem(v->index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
/* 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);
|
||||
return wp != nullptr && (wp->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY || wp->owner == OWNER_NONE);
|
||||
}
|
||||
|
||||
/* static */ StationID ScriptWaypoint::GetWaypointID(TileIndex tile)
|
||||
|
||||
@@ -32,7 +32,7 @@ ScriptWaypointList_Vehicle::ScriptWaypointList_Vehicle(VehicleID vehicle_id)
|
||||
|
||||
const Vehicle *v = ::Vehicle::Get(vehicle_id);
|
||||
|
||||
for (const Order *o = v->GetFirstOrder(); o != NULL; o = o->next) {
|
||||
for (const Order *o = v->GetFirstOrder(); o != nullptr; o = o->next) {
|
||||
if (o->IsType(OT_GOTO_WAYPOINT)) this->AddItem(o->GetDestination());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,10 +34,10 @@
|
||||
if (ScriptGame::IsMultiplayer()) return false;
|
||||
|
||||
if (number == NUMBER_ALL) {
|
||||
return (FindWindowByClass((::WindowClass)window) != NULL);
|
||||
return (FindWindowByClass((::WindowClass)window) != nullptr);
|
||||
}
|
||||
|
||||
return FindWindowById((::WindowClass)window, number) != NULL;
|
||||
return FindWindowById((::WindowClass)window, number) != nullptr;
|
||||
}
|
||||
|
||||
/* static */ void ScriptWindow::Highlight(WindowClass window, uint32 number, uint8 widget, TextColour colour)
|
||||
@@ -56,6 +56,6 @@
|
||||
}
|
||||
|
||||
const NWidgetBase *wid = w->GetWidget<NWidgetBase>(widget);
|
||||
if (wid == NULL) return;
|
||||
if (wid == nullptr) return;
|
||||
w->SetWidgetHighlight(widget, (::TextColour)colour);
|
||||
}
|
||||
|
||||
@@ -954,9 +954,11 @@ public:
|
||||
WID_RV_INFO_TAB = ::WID_RV_INFO_TAB, ///< Info tab.
|
||||
WID_RV_STOP_REPLACE = ::WID_RV_STOP_REPLACE, ///< Stop Replacing button.
|
||||
|
||||
/* Train/road only widgets */
|
||||
WID_RV_RAIL_ROAD_TYPE_DROPDOWN = ::WID_RV_RAIL_ROAD_TYPE_DROPDOWN, ///< Dropdown menu about the rail/roadtype.
|
||||
|
||||
/* Train only widgets. */
|
||||
WID_RV_TRAIN_ENGINEWAGON_DROPDOWN = ::WID_RV_TRAIN_ENGINEWAGON_DROPDOWN, ///< Dropdown to select engines and/or wagons.
|
||||
WID_RV_TRAIN_RAILTYPE_DROPDOWN = ::WID_RV_TRAIN_RAILTYPE_DROPDOWN, ///< Dropdown menu about the railtype.
|
||||
WID_RV_TRAIN_WAGONREMOVE_TOGGLE = ::WID_RV_TRAIN_WAGONREMOVE_TOGGLE, ///< Button to toggle removing wagons.
|
||||
};
|
||||
|
||||
@@ -1170,6 +1172,8 @@ public:
|
||||
WID_CI_RAIL_COUNT = ::WID_CI_RAIL_COUNT, ///< Count of rail.
|
||||
WID_CI_ROAD_DESC = ::WID_CI_ROAD_DESC, ///< Description of road.
|
||||
WID_CI_ROAD_COUNT = ::WID_CI_ROAD_COUNT, ///< Count of road.
|
||||
WID_CI_TRAM_DESC = ::WID_CI_TRAM_DESC, ///< Description of tram.
|
||||
WID_CI_TRAM_COUNT = ::WID_CI_TRAM_COUNT, ///< Count of tram.
|
||||
WID_CI_WATER_DESC = ::WID_CI_WATER_DESC, ///< Description of water.
|
||||
WID_CI_WATER_COUNT = ::WID_CI_WATER_COUNT, ///< Count of water.
|
||||
WID_CI_STATION_DESC = ::WID_CI_STATION_DESC, ///< Description of station.
|
||||
@@ -1305,6 +1309,8 @@ public:
|
||||
WID_FRW_TIMES_NAMES = ::WID_FRW_TIMES_NAMES,
|
||||
WID_FRW_TIMES_CURRENT = ::WID_FRW_TIMES_CURRENT,
|
||||
WID_FRW_TIMES_AVERAGE = ::WID_FRW_TIMES_AVERAGE,
|
||||
WID_FRW_ALLOCSIZE = ::WID_FRW_ALLOCSIZE,
|
||||
WID_FRW_SEL_MEMORY = ::WID_FRW_SEL_MEMORY,
|
||||
WID_FRW_SCROLLBAR = ::WID_FRW_SCROLLBAR,
|
||||
};
|
||||
|
||||
@@ -1598,6 +1604,7 @@ public:
|
||||
enum QueryStringWidgets {
|
||||
WID_QS_CAPTION = ::WID_QS_CAPTION, ///< Caption of the window.
|
||||
WID_QS_TEXT = ::WID_QS_TEXT, ///< Text of the query.
|
||||
WID_QS_WARNING = ::WID_QS_WARNING, ///< Warning label about password security
|
||||
WID_QS_DEFAULT = ::WID_QS_DEFAULT, ///< Default button.
|
||||
WID_QS_CANCEL = ::WID_QS_CANCEL, ///< Cancel button.
|
||||
WID_QS_OK = ::WID_QS_OK, ///< OK button.
|
||||
@@ -1817,6 +1824,7 @@ public:
|
||||
WID_NCP_LABEL = ::WID_NCP_LABEL, ///< Label in front of the password field.
|
||||
WID_NCP_PASSWORD = ::WID_NCP_PASSWORD, ///< Input field for the password.
|
||||
WID_NCP_SAVE_AS_DEFAULT_PASSWORD = ::WID_NCP_SAVE_AS_DEFAULT_PASSWORD, ///< Toggle 'button' for saving the current password as default password.
|
||||
WID_NCP_WARNING = ::WID_NCP_WARNING, ///< Warning text about password security
|
||||
WID_NCP_CANCEL = ::WID_NCP_CANCEL, ///< Close the window without changing anything.
|
||||
WID_NCP_OK = ::WID_NCP_OK, ///< Safe the password etc.
|
||||
};
|
||||
@@ -2123,6 +2131,7 @@ public:
|
||||
/** Widgets of the #BuildRoadToolbarWindow class. */
|
||||
enum RoadToolbarWidgets {
|
||||
/* Name starts with RO instead of R, because of collision with RailToolbarWidgets */
|
||||
WID_ROT_CAPTION = ::WID_ROT_CAPTION, ///< Caption of the window
|
||||
WID_ROT_ROAD_X = ::WID_ROT_ROAD_X, ///< Build road in x-direction.
|
||||
WID_ROT_ROAD_Y = ::WID_ROT_ROAD_Y, ///< Build road in y-direction.
|
||||
WID_ROT_AUTOROAD = ::WID_ROT_AUTOROAD, ///< Autorail.
|
||||
@@ -2134,6 +2143,7 @@ public:
|
||||
WID_ROT_BUILD_BRIDGE = ::WID_ROT_BUILD_BRIDGE, ///< Build bridge.
|
||||
WID_ROT_BUILD_TUNNEL = ::WID_ROT_BUILD_TUNNEL, ///< Build tunnel.
|
||||
WID_ROT_REMOVE = ::WID_ROT_REMOVE, ///< Remove road.
|
||||
WID_ROT_CONVERT_ROAD = ::WID_ROT_CONVERT_ROAD, ///< Convert road.
|
||||
};
|
||||
|
||||
/** Widgets of the #BuildRoadDepotWindow class. */
|
||||
@@ -2287,6 +2297,7 @@ public:
|
||||
WID_SV_ROADVEHS = ::WID_SV_ROADVEHS, ///< List of scheduled road vehs button.
|
||||
WID_SV_SHIPS = ::WID_SV_SHIPS, ///< List of scheduled ships button.
|
||||
WID_SV_PLANES = ::WID_SV_PLANES, ///< List of scheduled planes button.
|
||||
WID_SV_CATCHMENT = ::WID_SV_CATCHMENT, ///< Toggle catchment area highlight.
|
||||
};
|
||||
|
||||
/** Widgets of the #CompanyStationsWindow class. */
|
||||
@@ -2432,6 +2443,7 @@ public:
|
||||
WID_TN_BUILDING_TOOLS_START = ::WID_TN_BUILDING_TOOLS_START, ///< Helper for the offset of the building tools
|
||||
WID_TN_RAILS = ::WID_TN_RAILS, ///< Rail building menu.
|
||||
WID_TN_ROADS = ::WID_TN_ROADS, ///< Road building menu.
|
||||
WID_TN_TRAMS = ::WID_TN_TRAMS, ///< Tram building menu.
|
||||
WID_TN_WATER = ::WID_TN_WATER, ///< Water building toolbar.
|
||||
WID_TN_AIR = ::WID_TN_AIR, ///< Airport building toolbar.
|
||||
WID_TN_LANDSCAPE = ::WID_TN_LANDSCAPE, ///< Landscaping toolbar.
|
||||
@@ -2459,11 +2471,11 @@ public:
|
||||
WID_TE_TOWN_GENERATE = ::WID_TE_TOWN_GENERATE, ///< Town building window.
|
||||
WID_TE_INDUSTRY = ::WID_TE_INDUSTRY, ///< Industry building window.
|
||||
WID_TE_ROADS = ::WID_TE_ROADS, ///< Road building menu.
|
||||
WID_TE_TRAMS = ::WID_TE_TRAMS, ///< Tram building menu.
|
||||
WID_TE_WATER = ::WID_TE_WATER, ///< Water building toolbar.
|
||||
WID_TE_TREES = ::WID_TE_TREES, ///< Tree building toolbar.
|
||||
WID_TE_SIGNS = ::WID_TE_SIGNS, ///< Sign building.
|
||||
WID_TE_DATE_PANEL = ::WID_TE_DATE_PANEL, ///< Container for the date widgets.
|
||||
/* The following three need to have the same actual widget number as the normal toolbar due to shared code. */
|
||||
WID_TE_MUSIC_SOUND = ::WID_TE_MUSIC_SOUND, ///< Music/sound configuration menu.
|
||||
WID_TE_HELP = ::WID_TE_HELP, ///< Help menu.
|
||||
WID_TE_SWITCH_BAR = ::WID_TE_SWITCH_BAR, ///< Only available when toolbar has been split to switch between different subsets.
|
||||
@@ -2474,6 +2486,7 @@ public:
|
||||
enum TownDirectoryWidgets {
|
||||
WID_TD_SORT_ORDER = ::WID_TD_SORT_ORDER, ///< Direction of sort dropdown.
|
||||
WID_TD_SORT_CRITERIA = ::WID_TD_SORT_CRITERIA, ///< Criteria of sort dropdown.
|
||||
WID_TD_FILTER = ::WID_TD_FILTER, ///< Filter of name.
|
||||
WID_TD_LIST = ::WID_TD_LIST, ///< List of towns.
|
||||
WID_TD_SCROLLBAR = ::WID_TD_SCROLLBAR, ///< Scrollbar for the town list.
|
||||
WID_TD_WORLD_POPULATION = ::WID_TD_WORLD_POPULATION, ///< The world's population.
|
||||
@@ -2482,6 +2495,7 @@ public:
|
||||
/** Widgets of the #TownAuthorityWindow class. */
|
||||
enum TownAuthorityWidgets {
|
||||
WID_TA_CAPTION = ::WID_TA_CAPTION, ///< Caption of window.
|
||||
WID_TA_ZONE_BUTTON = ::WID_TA_ZONE_BUTTON, ///< Turn on/off showing local authority zone.
|
||||
WID_TA_RATING_INFO = ::WID_TA_RATING_INFO, ///< Overview with ratings for each company.
|
||||
WID_TA_COMMAND_LIST = ::WID_TA_COMMAND_LIST, ///< List of commands for the player.
|
||||
WID_TA_SCROLLBAR = ::WID_TA_SCROLLBAR, ///< Scrollbar of the list of commands.
|
||||
@@ -2497,6 +2511,7 @@ public:
|
||||
WID_TV_CENTER_VIEW = ::WID_TV_CENTER_VIEW, ///< Center the main view on this town.
|
||||
WID_TV_SHOW_AUTHORITY = ::WID_TV_SHOW_AUTHORITY, ///< Show the town authority window.
|
||||
WID_TV_CHANGE_NAME = ::WID_TV_CHANGE_NAME, ///< Change the name of this town.
|
||||
WID_TV_CATCHMENT = ::WID_TV_CATCHMENT, ///< Toggle catchment area highlight.
|
||||
WID_TV_EXPAND = ::WID_TV_EXPAND, ///< Expand this town (scenario editor only).
|
||||
WID_TV_DELETE = ::WID_TV_DELETE, ///< Delete this town (scenario editor only).
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@ function dump_class_templates(name)
|
||||
print " template <> inline const " name " *GetParam(ForceType<const " name " *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (" name " *)instance; }" CR
|
||||
print " template <> inline const " name " &GetParam(ForceType<const " name " &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(" name " *)instance; }" CR
|
||||
if (name == "ScriptEvent") {
|
||||
print " template <> inline int Return<" name " *>(HSQUIRRELVM vm, " name " *res) { if (res == NULL) { sq_pushnull(vm); return 1; } Squirrel::CreateClassInstanceVM(vm, \"" realname "\", res, NULL, DefSQDestructorCallback<" name ">, true); return 1; }" CR
|
||||
print " template <> inline int Return<" name " *>(HSQUIRRELVM vm, " name " *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } Squirrel::CreateClassInstanceVM(vm, \"" realname "\", res, nullptr, DefSQDestructorCallback<" name ">, true); return 1; }" CR
|
||||
} else if (name == "ScriptText") {
|
||||
print "" CR
|
||||
print " template <> inline Text *GetParam(ForceType<Text *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) {" CR
|
||||
@@ -44,10 +44,10 @@ function dump_class_templates(name)
|
||||
print " if (sq_gettype(vm, index) == OT_STRING) {" CR
|
||||
print " return new RawText(GetParam(ForceType<const char *>(), vm, index, ptr));" CR
|
||||
print " }" CR
|
||||
print " return NULL;" CR
|
||||
print " return nullptr;" CR
|
||||
print " }" CR
|
||||
} else {
|
||||
print " template <> inline int Return<" name " *>(HSQUIRRELVM vm, " name " *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, \"" realname "\", res, NULL, DefSQDestructorCallback<" name ">, true); return 1; }" CR
|
||||
print " template <> inline int Return<" name " *>(HSQUIRRELVM vm, " name " *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, \"" realname "\", res, nullptr, DefSQDestructorCallback<" name ">, true); return 1; }" CR
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ Function DumpClassTemplates(name, file)
|
||||
file.WriteLine " template <> inline const " & name & " *GetParam(ForceType<const " & name & " *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (" & name & " *)instance; }"
|
||||
file.WriteLine " template <> inline const " & name & " &GetParam(ForceType<const " & name & " &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(" & name & " *)instance; }"
|
||||
If name = "ScriptEvent" Then
|
||||
file.WriteLine " template <> inline int Return<" & name & " *>(HSQUIRRELVM vm, " & name & " *res) { if (res == NULL) { sq_pushnull(vm); return 1; } Squirrel::CreateClassInstanceVM(vm, " & Chr(34) & realname & Chr(34) & ", res, NULL, DefSQDestructorCallback<" & name & ">, true); return 1; }"
|
||||
file.WriteLine " template <> inline int Return<" & name & " *>(HSQUIRRELVM vm, " & name & " *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } Squirrel::CreateClassInstanceVM(vm, " & Chr(34) & realname & Chr(34) & ", res, nullptr, DefSQDestructorCallback<" & name & ">, true); return 1; }"
|
||||
ElseIf name = "ScriptText" Then
|
||||
file.WriteLine ""
|
||||
file.WriteLine " template <> inline Text *GetParam(ForceType<Text *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) {"
|
||||
@@ -72,10 +72,10 @@ Function DumpClassTemplates(name, file)
|
||||
file.WriteLine " if (sq_gettype(vm, index) == OT_STRING) {"
|
||||
file.WriteLine " return new RawText(GetParam(ForceType<const char *>(), vm, index, ptr));"
|
||||
file.WriteLine " }"
|
||||
file.WriteLine " return NULL;"
|
||||
file.WriteLine " return nullptr;"
|
||||
file.WriteLine " }"
|
||||
Else
|
||||
file.WriteLine " template <> inline int Return<" & name & " *>(HSQUIRRELVM vm, " & name & " *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, " & Chr(34) & realname & Chr(34) & ", res, NULL, DefSQDestructorCallback<" & name & ">, true); return 1; }"
|
||||
file.WriteLine " template <> inline int Return<" & name & " *>(HSQUIRRELVM vm, " & name & " *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, " & Chr(34) & realname & Chr(34) & ", res, nullptr, DefSQDestructorCallback<" & name & ">, true); return 1; }"
|
||||
End If
|
||||
End Function
|
||||
|
||||
|
||||
@@ -17,5 +17,5 @@ namespace SQConvert {
|
||||
template <> inline ScriptAccounting &GetParam(ForceType<ScriptAccounting &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptAccounting *)instance; }
|
||||
template <> inline const ScriptAccounting *GetParam(ForceType<const ScriptAccounting *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptAccounting *)instance; }
|
||||
template <> inline const ScriptAccounting &GetParam(ForceType<const ScriptAccounting &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptAccounting *)instance; }
|
||||
template <> inline int Return<ScriptAccounting *>(HSQUIRRELVM vm, ScriptAccounting *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Accounting", res, NULL, DefSQDestructorCallback<ScriptAccounting>, true); return 1; }
|
||||
template <> inline int Return<ScriptAccounting *>(HSQUIRRELVM vm, ScriptAccounting *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Accounting", res, nullptr, DefSQDestructorCallback<ScriptAccounting>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
@@ -17,5 +17,5 @@ namespace SQConvert {
|
||||
template <> inline ScriptAdmin &GetParam(ForceType<ScriptAdmin &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptAdmin *)instance; }
|
||||
template <> inline const ScriptAdmin *GetParam(ForceType<const ScriptAdmin *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptAdmin *)instance; }
|
||||
template <> inline const ScriptAdmin &GetParam(ForceType<const ScriptAdmin &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptAdmin *)instance; }
|
||||
template <> inline int Return<ScriptAdmin *>(HSQUIRRELVM vm, ScriptAdmin *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Admin", res, NULL, DefSQDestructorCallback<ScriptAdmin>, true); return 1; }
|
||||
template <> inline int Return<ScriptAdmin *>(HSQUIRRELVM vm, ScriptAdmin *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Admin", res, nullptr, DefSQDestructorCallback<ScriptAdmin>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
@@ -23,5 +23,5 @@ namespace SQConvert {
|
||||
template <> inline ScriptAirport &GetParam(ForceType<ScriptAirport &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptAirport *)instance; }
|
||||
template <> inline const ScriptAirport *GetParam(ForceType<const ScriptAirport *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptAirport *)instance; }
|
||||
template <> inline const ScriptAirport &GetParam(ForceType<const ScriptAirport &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptAirport *)instance; }
|
||||
template <> inline int Return<ScriptAirport *>(HSQUIRRELVM vm, ScriptAirport *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Airport", res, NULL, DefSQDestructorCallback<ScriptAirport>, true); return 1; }
|
||||
template <> inline int Return<ScriptAirport *>(HSQUIRRELVM vm, ScriptAirport *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Airport", res, nullptr, DefSQDestructorCallback<ScriptAirport>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
@@ -17,5 +17,5 @@ namespace SQConvert {
|
||||
template <> inline ScriptBase &GetParam(ForceType<ScriptBase &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptBase *)instance; }
|
||||
template <> inline const ScriptBase *GetParam(ForceType<const ScriptBase *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptBase *)instance; }
|
||||
template <> inline const ScriptBase &GetParam(ForceType<const ScriptBase &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptBase *)instance; }
|
||||
template <> inline int Return<ScriptBase *>(HSQUIRRELVM vm, ScriptBase *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Base", res, NULL, DefSQDestructorCallback<ScriptBase>, true); return 1; }
|
||||
template <> inline int Return<ScriptBase *>(HSQUIRRELVM vm, ScriptBase *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Base", res, nullptr, DefSQDestructorCallback<ScriptBase>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
@@ -21,5 +21,5 @@ namespace SQConvert {
|
||||
template <> inline ScriptBaseStation &GetParam(ForceType<ScriptBaseStation &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptBaseStation *)instance; }
|
||||
template <> inline const ScriptBaseStation *GetParam(ForceType<const ScriptBaseStation *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptBaseStation *)instance; }
|
||||
template <> inline const ScriptBaseStation &GetParam(ForceType<const ScriptBaseStation &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptBaseStation *)instance; }
|
||||
template <> inline int Return<ScriptBaseStation *>(HSQUIRRELVM vm, ScriptBaseStation *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "BaseStation", res, NULL, DefSQDestructorCallback<ScriptBaseStation>, true); return 1; }
|
||||
template <> inline int Return<ScriptBaseStation *>(HSQUIRRELVM vm, ScriptBaseStation *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "BaseStation", res, nullptr, DefSQDestructorCallback<ScriptBaseStation>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
@@ -21,5 +21,5 @@ namespace SQConvert {
|
||||
template <> inline ScriptBridge &GetParam(ForceType<ScriptBridge &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptBridge *)instance; }
|
||||
template <> inline const ScriptBridge *GetParam(ForceType<const ScriptBridge *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptBridge *)instance; }
|
||||
template <> inline const ScriptBridge &GetParam(ForceType<const ScriptBridge &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptBridge *)instance; }
|
||||
template <> inline int Return<ScriptBridge *>(HSQUIRRELVM vm, ScriptBridge *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Bridge", res, NULL, DefSQDestructorCallback<ScriptBridge>, true); return 1; }
|
||||
template <> inline int Return<ScriptBridge *>(HSQUIRRELVM vm, ScriptBridge *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Bridge", res, nullptr, DefSQDestructorCallback<ScriptBridge>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace SQConvert {
|
||||
template <> inline ScriptBridgeList &GetParam(ForceType<ScriptBridgeList &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptBridgeList *)instance; }
|
||||
template <> inline const ScriptBridgeList *GetParam(ForceType<const ScriptBridgeList *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptBridgeList *)instance; }
|
||||
template <> inline const ScriptBridgeList &GetParam(ForceType<const ScriptBridgeList &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptBridgeList *)instance; }
|
||||
template <> inline int Return<ScriptBridgeList *>(HSQUIRRELVM vm, ScriptBridgeList *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "BridgeList", res, NULL, DefSQDestructorCallback<ScriptBridgeList>, true); return 1; }
|
||||
template <> inline int Return<ScriptBridgeList *>(HSQUIRRELVM vm, ScriptBridgeList *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "BridgeList", res, nullptr, DefSQDestructorCallback<ScriptBridgeList>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
namespace SQConvert {
|
||||
@@ -26,5 +26,5 @@ namespace SQConvert {
|
||||
template <> inline ScriptBridgeList_Length &GetParam(ForceType<ScriptBridgeList_Length &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptBridgeList_Length *)instance; }
|
||||
template <> inline const ScriptBridgeList_Length *GetParam(ForceType<const ScriptBridgeList_Length *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptBridgeList_Length *)instance; }
|
||||
template <> inline const ScriptBridgeList_Length &GetParam(ForceType<const ScriptBridgeList_Length &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptBridgeList_Length *)instance; }
|
||||
template <> inline int Return<ScriptBridgeList_Length *>(HSQUIRRELVM vm, ScriptBridgeList_Length *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "BridgeList_Length", res, NULL, DefSQDestructorCallback<ScriptBridgeList_Length>, true); return 1; }
|
||||
template <> inline int Return<ScriptBridgeList_Length *>(HSQUIRRELVM vm, ScriptBridgeList_Length *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "BridgeList_Length", res, nullptr, DefSQDestructorCallback<ScriptBridgeList_Length>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
@@ -27,5 +27,5 @@ namespace SQConvert {
|
||||
template <> inline ScriptCargo &GetParam(ForceType<ScriptCargo &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptCargo *)instance; }
|
||||
template <> inline const ScriptCargo *GetParam(ForceType<const ScriptCargo *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptCargo *)instance; }
|
||||
template <> inline const ScriptCargo &GetParam(ForceType<const ScriptCargo &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptCargo *)instance; }
|
||||
template <> inline int Return<ScriptCargo *>(HSQUIRRELVM vm, ScriptCargo *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Cargo", res, NULL, DefSQDestructorCallback<ScriptCargo>, true); return 1; }
|
||||
template <> inline int Return<ScriptCargo *>(HSQUIRRELVM vm, ScriptCargo *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Cargo", res, nullptr, DefSQDestructorCallback<ScriptCargo>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace SQConvert {
|
||||
template <> inline ScriptCargoList &GetParam(ForceType<ScriptCargoList &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptCargoList *)instance; }
|
||||
template <> inline const ScriptCargoList *GetParam(ForceType<const ScriptCargoList *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptCargoList *)instance; }
|
||||
template <> inline const ScriptCargoList &GetParam(ForceType<const ScriptCargoList &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptCargoList *)instance; }
|
||||
template <> inline int Return<ScriptCargoList *>(HSQUIRRELVM vm, ScriptCargoList *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "CargoList", res, NULL, DefSQDestructorCallback<ScriptCargoList>, true); return 1; }
|
||||
template <> inline int Return<ScriptCargoList *>(HSQUIRRELVM vm, ScriptCargoList *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "CargoList", res, nullptr, DefSQDestructorCallback<ScriptCargoList>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
namespace SQConvert {
|
||||
@@ -26,7 +26,7 @@ namespace SQConvert {
|
||||
template <> inline ScriptCargoList_IndustryAccepting &GetParam(ForceType<ScriptCargoList_IndustryAccepting &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptCargoList_IndustryAccepting *)instance; }
|
||||
template <> inline const ScriptCargoList_IndustryAccepting *GetParam(ForceType<const ScriptCargoList_IndustryAccepting *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptCargoList_IndustryAccepting *)instance; }
|
||||
template <> inline const ScriptCargoList_IndustryAccepting &GetParam(ForceType<const ScriptCargoList_IndustryAccepting &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptCargoList_IndustryAccepting *)instance; }
|
||||
template <> inline int Return<ScriptCargoList_IndustryAccepting *>(HSQUIRRELVM vm, ScriptCargoList_IndustryAccepting *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "CargoList_IndustryAccepting", res, NULL, DefSQDestructorCallback<ScriptCargoList_IndustryAccepting>, true); return 1; }
|
||||
template <> inline int Return<ScriptCargoList_IndustryAccepting *>(HSQUIRRELVM vm, ScriptCargoList_IndustryAccepting *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "CargoList_IndustryAccepting", res, nullptr, DefSQDestructorCallback<ScriptCargoList_IndustryAccepting>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
namespace SQConvert {
|
||||
@@ -35,7 +35,7 @@ namespace SQConvert {
|
||||
template <> inline ScriptCargoList_IndustryProducing &GetParam(ForceType<ScriptCargoList_IndustryProducing &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptCargoList_IndustryProducing *)instance; }
|
||||
template <> inline const ScriptCargoList_IndustryProducing *GetParam(ForceType<const ScriptCargoList_IndustryProducing *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptCargoList_IndustryProducing *)instance; }
|
||||
template <> inline const ScriptCargoList_IndustryProducing &GetParam(ForceType<const ScriptCargoList_IndustryProducing &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptCargoList_IndustryProducing *)instance; }
|
||||
template <> inline int Return<ScriptCargoList_IndustryProducing *>(HSQUIRRELVM vm, ScriptCargoList_IndustryProducing *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "CargoList_IndustryProducing", res, NULL, DefSQDestructorCallback<ScriptCargoList_IndustryProducing>, true); return 1; }
|
||||
template <> inline int Return<ScriptCargoList_IndustryProducing *>(HSQUIRRELVM vm, ScriptCargoList_IndustryProducing *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "CargoList_IndustryProducing", res, nullptr, DefSQDestructorCallback<ScriptCargoList_IndustryProducing>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
namespace SQConvert {
|
||||
@@ -44,5 +44,5 @@ namespace SQConvert {
|
||||
template <> inline ScriptCargoList_StationAccepting &GetParam(ForceType<ScriptCargoList_StationAccepting &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptCargoList_StationAccepting *)instance; }
|
||||
template <> inline const ScriptCargoList_StationAccepting *GetParam(ForceType<const ScriptCargoList_StationAccepting *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptCargoList_StationAccepting *)instance; }
|
||||
template <> inline const ScriptCargoList_StationAccepting &GetParam(ForceType<const ScriptCargoList_StationAccepting &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptCargoList_StationAccepting *)instance; }
|
||||
template <> inline int Return<ScriptCargoList_StationAccepting *>(HSQUIRRELVM vm, ScriptCargoList_StationAccepting *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "CargoList_StationAccepting", res, NULL, DefSQDestructorCallback<ScriptCargoList_StationAccepting>, true); return 1; }
|
||||
template <> inline int Return<ScriptCargoList_StationAccepting *>(HSQUIRRELVM vm, ScriptCargoList_StationAccepting *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "CargoList_StationAccepting", res, nullptr, DefSQDestructorCallback<ScriptCargoList_StationAccepting>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
@@ -17,5 +17,5 @@ namespace SQConvert {
|
||||
template <> inline ScriptCargoMonitor &GetParam(ForceType<ScriptCargoMonitor &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptCargoMonitor *)instance; }
|
||||
template <> inline const ScriptCargoMonitor *GetParam(ForceType<const ScriptCargoMonitor *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptCargoMonitor *)instance; }
|
||||
template <> inline const ScriptCargoMonitor &GetParam(ForceType<const ScriptCargoMonitor &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptCargoMonitor *)instance; }
|
||||
template <> inline int Return<ScriptCargoMonitor *>(HSQUIRRELVM vm, ScriptCargoMonitor *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "CargoMonitor", res, NULL, DefSQDestructorCallback<ScriptCargoMonitor>, true); return 1; }
|
||||
template <> inline int Return<ScriptCargoMonitor *>(HSQUIRRELVM vm, ScriptCargoMonitor *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "CargoMonitor", res, nullptr, DefSQDestructorCallback<ScriptCargoMonitor>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
@@ -21,5 +21,5 @@ namespace SQConvert {
|
||||
template <> inline ScriptClient &GetParam(ForceType<ScriptClient &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptClient *)instance; }
|
||||
template <> inline const ScriptClient *GetParam(ForceType<const ScriptClient *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptClient *)instance; }
|
||||
template <> inline const ScriptClient &GetParam(ForceType<const ScriptClient &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptClient *)instance; }
|
||||
template <> inline int Return<ScriptClient *>(HSQUIRRELVM vm, ScriptClient *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Client", res, NULL, DefSQDestructorCallback<ScriptClient>, true); return 1; }
|
||||
template <> inline int Return<ScriptClient *>(HSQUIRRELVM vm, ScriptClient *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Client", res, nullptr, DefSQDestructorCallback<ScriptClient>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace SQConvert {
|
||||
template <> inline ScriptClientList &GetParam(ForceType<ScriptClientList &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptClientList *)instance; }
|
||||
template <> inline const ScriptClientList *GetParam(ForceType<const ScriptClientList *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptClientList *)instance; }
|
||||
template <> inline const ScriptClientList &GetParam(ForceType<const ScriptClientList &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptClientList *)instance; }
|
||||
template <> inline int Return<ScriptClientList *>(HSQUIRRELVM vm, ScriptClientList *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "ClientList", res, NULL, DefSQDestructorCallback<ScriptClientList>, true); return 1; }
|
||||
template <> inline int Return<ScriptClientList *>(HSQUIRRELVM vm, ScriptClientList *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "ClientList", res, nullptr, DefSQDestructorCallback<ScriptClientList>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
namespace SQConvert {
|
||||
@@ -26,5 +26,5 @@ namespace SQConvert {
|
||||
template <> inline ScriptClientList_Company &GetParam(ForceType<ScriptClientList_Company &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptClientList_Company *)instance; }
|
||||
template <> inline const ScriptClientList_Company *GetParam(ForceType<const ScriptClientList_Company *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptClientList_Company *)instance; }
|
||||
template <> inline const ScriptClientList_Company &GetParam(ForceType<const ScriptClientList_Company &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptClientList_Company *)instance; }
|
||||
template <> inline int Return<ScriptClientList_Company *>(HSQUIRRELVM vm, ScriptClientList_Company *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "ClientList_Company", res, NULL, DefSQDestructorCallback<ScriptClientList_Company>, true); return 1; }
|
||||
template <> inline int Return<ScriptClientList_Company *>(HSQUIRRELVM vm, ScriptClientList_Company *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "ClientList_Company", res, nullptr, DefSQDestructorCallback<ScriptClientList_Company>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
@@ -31,5 +31,5 @@ namespace SQConvert {
|
||||
template <> inline ScriptCompany &GetParam(ForceType<ScriptCompany &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptCompany *)instance; }
|
||||
template <> inline const ScriptCompany *GetParam(ForceType<const ScriptCompany *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptCompany *)instance; }
|
||||
template <> inline const ScriptCompany &GetParam(ForceType<const ScriptCompany &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptCompany *)instance; }
|
||||
template <> inline int Return<ScriptCompany *>(HSQUIRRELVM vm, ScriptCompany *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Company", res, NULL, DefSQDestructorCallback<ScriptCompany>, true); return 1; }
|
||||
template <> inline int Return<ScriptCompany *>(HSQUIRRELVM vm, ScriptCompany *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Company", res, nullptr, DefSQDestructorCallback<ScriptCompany>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
@@ -17,5 +17,5 @@ namespace SQConvert {
|
||||
template <> inline ScriptCompanyMode &GetParam(ForceType<ScriptCompanyMode &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptCompanyMode *)instance; }
|
||||
template <> inline const ScriptCompanyMode *GetParam(ForceType<const ScriptCompanyMode *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptCompanyMode *)instance; }
|
||||
template <> inline const ScriptCompanyMode &GetParam(ForceType<const ScriptCompanyMode &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptCompanyMode *)instance; }
|
||||
template <> inline int Return<ScriptCompanyMode *>(HSQUIRRELVM vm, ScriptCompanyMode *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "CompanyMode", res, NULL, DefSQDestructorCallback<ScriptCompanyMode>, true); return 1; }
|
||||
template <> inline int Return<ScriptCompanyMode *>(HSQUIRRELVM vm, ScriptCompanyMode *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "CompanyMode", res, nullptr, DefSQDestructorCallback<ScriptCompanyMode>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
@@ -21,5 +21,5 @@ namespace SQConvert {
|
||||
template <> inline ScriptDate &GetParam(ForceType<ScriptDate &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptDate *)instance; }
|
||||
template <> inline const ScriptDate *GetParam(ForceType<const ScriptDate *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptDate *)instance; }
|
||||
template <> inline const ScriptDate &GetParam(ForceType<const ScriptDate &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptDate *)instance; }
|
||||
template <> inline int Return<ScriptDate *>(HSQUIRRELVM vm, ScriptDate *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Date", res, NULL, DefSQDestructorCallback<ScriptDate>, true); return 1; }
|
||||
template <> inline int Return<ScriptDate *>(HSQUIRRELVM vm, ScriptDate *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Date", res, nullptr, DefSQDestructorCallback<ScriptDate>, true); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user