Data Structures | Static Public Member Functions | Static Protected Member Functions | Static Private Member Functions | Friends

ScriptObject Class Reference

Uper-parent object of all API classes. More...

#include <script_object.hpp>

Inheritance diagram for ScriptObject:
SimpleCountedObject ScriptAccounting ScriptAdmin ScriptAirport ScriptBase ScriptBaseStation ScriptBridge ScriptCargo ScriptCompany ScriptCompanyMode ScriptDate ScriptEngine ScriptError ScriptEvent ScriptEventController ScriptExecMode ScriptGame ScriptGameSettings ScriptGoal ScriptGroup ScriptIndustry ScriptIndustryType ScriptInfrastructure ScriptList ScriptLog ScriptMap ScriptMarine ScriptNews ScriptOrder ScriptRail ScriptRoad ScriptSign ScriptSubsidy ScriptTestMode ScriptTile ScriptTown ScriptTunnel ScriptVehicle ScriptViewport ScriptWindow Text

Data Structures

class  ActiveInstance
 A class that handles the current active instance. More...

Static Public Member Functions

static void SetLastCommandRes (bool res)
 Store the latest result of a DoCommand per company.
static class ScriptInstanceGetActiveInstance ()
 Get the currently active instance.

Static Protected Member Functions

static bool DoCommand (TileIndex tile, uint32 p1, uint32 p2, uint cmd, const char *text=NULL, Script_SuspendCallbackProc *callback=NULL)
 Executes a raw DoCommand for the AI.
static void SetDoCommandCosts (Money value)
 Sets the DoCommand costs counter to a value.
static void IncreaseDoCommandCosts (Money value)
 Increase the current value of the DoCommand costs counter.
static Money GetDoCommandCosts ()
 Get the current DoCommand costs counter.
static void SetLastError (ScriptErrorType last_error)
 Set the DoCommand last error.
static ScriptErrorType GetLastError ()
 Get the DoCommand last error.
static void SetRoadType (RoadType road_type)
 Set the road type.
static RoadType GetRoadType ()
 Get the road type.
static void SetRailType (RailType rail_type)
 Set the rail type.
static RailType GetRailType ()
 Get the rail type.
static void SetDoCommandMode (ScriptModeProc *proc, ScriptObject *instance)
 Set the current mode of your AI to this proc.
static ScriptModeProcGetDoCommandMode ()
 Get the current mode your AI is currently under.
static ScriptObjectGetDoCommandModeInstance ()
 Get the instance of the current mode your AI is currently under.
static void SetDoCommandDelay (uint ticks)
 Set the delay of the DoCommand.
static uint GetDoCommandDelay ()
 Get the delay of the DoCommand.
static bool GetLastCommandRes ()
 Get the latest result of a DoCommand.
static VehicleID GetNewVehicleID ()
 Get the latest stored new_vehicle_id.
static SignID GetNewSignID ()
 Get the latest stored new_sign_id.
static GroupID GetNewGroupID ()
 Get the latest stored new_group_id.
static GoalID GetNewGoalID ()
 Get the latest stored new_goal_id.
static void SetAllowDoCommand (bool allow)
 Store a allow_do_command per company.
static bool GetAllowDoCommand ()
 Get the internal value of allow_do_command.
static void SetCompany (CompanyID company)
 Set the current company to execute commands for or request information about.
static CompanyID GetCompany ()
 Get the current company we are executing commands for or requesting information about.
static CompanyID GetRootCompany ()
 Get the root company, the company that the script really runs under / for.
static void SetLastCost (Money last_cost)
 Set the cost of the last command.
static Money GetLastCost ()
 Get the cost of the last command.
static void SetCallbackVariable (int index, int value)
 Set a variable that can be used by callback functions to pass information.
static int GetCallbackVariable (int index)
 Get the variable that is used by callback functions to pass information.
static bool CanSuspend ()
 Can we suspend the AI at this moment?
static void *& GetEventPointer ()
 Get the pointer to store event data in.
static void *& GetLogPointer ()
 Get the pointer to store log message in.

Static Private Member Functions

static void SetNewVehicleID (VehicleID vehicle_id)
 Store a new_vehicle_id per company.
static void SetNewSignID (SignID sign_id)
 Store a new_sign_id per company.
static void SetNewGroupID (GroupID group_id)
 Store a new_group_id per company.
static void SetNewGoalID (GoalID goal_id)
 Store a new_goal_id per company.

Friends

class ScriptInstance

Detailed Description

Uper-parent object of all API classes.

You should never use this class in your script, as it doesn't publish any public functions. It is used internally to have a common place to handle general things, like internal command processing, and command-validation checks. none

Definition at line 34 of file script_object.hpp.


Member Function Documentation

ScriptInstance * ScriptObject::GetActiveInstance (  )  [static]
bool ScriptObject::GetAllowDoCommand (  )  [static, protected]

Get the internal value of allow_do_command.

This can differ from CanSuspend() if the reason we are not allowed to execute a DoCommand is in squirrel and not the API. In that case use this function to restore the previous value.

Returns:
True iff DoCommands are allowed in the current scope.

Definition at line 200 of file script_object.cpp.

References ScriptStorage::allow_do_command, and GetStorage().

Referenced by ScriptInstance::Save(), and ScriptList::Valuate().

CompanyID ScriptObject::GetCompany (  )  [static, protected]

Get the current company we are executing commands for or requesting information about.

Returns:
The current company.

Definition at line 213 of file script_object.cpp.

References ScriptStorage::company, and GetStorage().

Referenced by ScriptRoad::_BuildRoadStationInternal(), ScriptVehicle::_MoveWagonInternal(), ScriptVehicle::_SellWagonInternal(), ScriptAirport::BuildAirport(), ScriptBridge::BuildBridge(), ScriptMarine::BuildBuoy(), ScriptMarine::BuildCanal(), ScriptCompany::BuildCompanyHQ(), ScriptMarine::BuildDock(), ScriptIndustryType::BuildIndustry(), ScriptMarine::BuildLock(), ScriptRail::BuildNewGRFRailStation(), ScriptRoad::BuildOneWayRoad(), ScriptRoad::BuildOneWayRoadFull(), ScriptRail::BuildRail(), ScriptRail::BuildRailDepot(), ScriptRail::BuildRailStation(), ScriptRail::BuildRailTrack(), ScriptRail::BuildRailWaypoint(), ScriptRoad::BuildRoadDepot(), ScriptRail::BuildSignal(), ScriptTunnel::BuildTunnel(), ScriptVehicle::BuildVehicle(), ScriptMarine::BuildWaterDepot(), ScriptVehicle::CloneVehicle(), ScriptRail::ConvertRailType(), ScriptTile::DemolishTile(), DoCommand(), ScriptTown::ExpandTown(), ScriptInstance::GameLoop(), ScriptGroup::GetEngineReplacement(), ScriptTown::GetExclusiveRightsCompany(), ScriptAirport::GetHangarOfAirport(), ScriptGroup::GetNumEngines(), ScriptAirport::GetNumHangars(), ScriptTown::HasStatue(), ScriptGroup::HasWagonRemoval(), ScriptTown::IsActionAvailable(), ScriptTile::IsBuildable(), ScriptEngine::IsBuildable(), ScriptRail::IsRailTypeAvailable(), ScriptRoad::IsRoadTypeAvailable(), ScriptBaseStation::IsValidBaseStation(), ScriptEngine::IsValidEngine(), ScriptGroup::IsValidGroup(), ScriptSign::IsValidSign(), ScriptStation::IsValidStation(), ScriptVehicle::IsValidVehicle(), ScriptWaypoint::IsValidWaypoint(), ScriptTile::LevelTiles(), ScriptTile::LowerTile(), ScriptTown::PerformTownAction(), ScriptTile::PlantTree(), ScriptTile::PlantTreeRectangle(), ScriptIndustryType::ProspectIndustry(), ScriptTile::RaiseTile(), ScriptVehicle::RefitVehicle(), ScriptAirport::RemoveAirport(), ScriptBridge::RemoveBridge(), ScriptMarine::RemoveBuoy(), ScriptMarine::RemoveCanal(), ScriptMarine::RemoveDock(), ScriptMarine::RemoveLock(), ScriptRail::RemoveRail(), ScriptRail::RemoveRailStationTileRectangle(), ScriptRail::RemoveRailTrack(), ScriptRail::RemoveRailWaypointTileRectangle(), ScriptRoad::RemoveRoad(), ScriptRoad::RemoveRoadDepot(), ScriptRoad::RemoveRoadFull(), ScriptRoad::RemoveRoadStation(), ScriptRail::RemoveSignal(), ScriptTunnel::RemoveTunnel(), ScriptMarine::RemoveWaterDepot(), ScriptVehicle::ReverseVehicle(), ScriptCompanyMode::ScriptCompanyMode(), ScriptDepotList::ScriptDepotList(), ScriptEngineList::ScriptEngineList(), ScriptStationList::ScriptStationList(), ScriptVehicleList_DefaultGroup::ScriptVehicleList_DefaultGroup(), ScriptVehicleList_Depot::ScriptVehicleList_Depot(), ScriptVehicleList_Group::ScriptVehicleList_Group(), ScriptVehicleList_Station::ScriptVehicleList_Station(), ScriptWaypointList::ScriptWaypointList(), ScriptVehicle::SellVehicle(), ScriptVehicle::SendVehicleToDepot(), ScriptVehicle::SendVehicleToDepotForServicing(), ScriptCompany::SetLoanAmount(), ScriptCompany::SetMinimumLoanAmount(), ScriptVehicle::SetName(), ScriptBaseStation::SetName(), and ScriptVehicle::StartStopVehicle().

CompanyID ScriptObject::GetRootCompany (  )  [static, protected]

Get the root company, the company that the script really runs under / for.

Returns:
The root company.

Definition at line 218 of file script_object.cpp.

References GetStorage(), and ScriptStorage::root_company.

Referenced by ScriptLog::Log().

void ScriptObject::SetAllowDoCommand ( bool  allow  )  [static, protected]

Store a allow_do_command per company.

Parameters:
allow The new allow.

Definition at line 195 of file script_object.cpp.

References ScriptStorage::allow_do_command, and GetStorage().

Referenced by ScriptInstance::GameLoop(), ScriptInstance::Initialize(), ScriptInstance::Save(), and ScriptList::Valuate().

void ScriptObject::SetCompany ( CompanyID  company  )  [static, protected]

Set the current company to execute commands for or request information about.

Parameters:
company The new company.

Definition at line 205 of file script_object.cpp.

References _current_company, ScriptStorage::company, GetStorage(), INVALID_OWNER, and ScriptStorage::root_company.

Referenced by ScriptCompanyMode::ScriptCompanyMode(), ScriptController::ScriptController(), and ScriptCompanyMode::~ScriptCompanyMode().

void ScriptObject::SetLastCommandRes ( bool  res  )  [static]

Store the latest result of a DoCommand per company.

Parameters:
res The result of the last command.

Definition at line 140 of file script_object.cpp.

References _new_sign_id, GetStorage(), ScriptStorage::last_command_res, SetNewGoalID(), SetNewGroupID(), SetNewSignID(), and SetNewVehicleID().

Referenced by _DoCommandReturnSetOrderFlags(), DoCommand(), and ScriptInstance::DoCommandCallback().

void ScriptObject::SetNewGoalID ( GoalID  goal_id  )  [static, private]

Store a new_goal_id per company.

Parameters:
goal_id The new GoalID.

Definition at line 185 of file script_object.cpp.

References GetStorage(), and ScriptStorage::new_goal_id.

Referenced by SetLastCommandRes().

void ScriptObject::SetNewGroupID ( GroupID  group_id  )  [static, private]

Store a new_group_id per company.

Parameters:
group_id The new GroupID.

Definition at line 175 of file script_object.cpp.

References GetStorage(), and ScriptStorage::new_group_id.

Referenced by SetLastCommandRes().

void ScriptObject::SetNewSignID ( SignID  sign_id  )  [static, private]

Store a new_sign_id per company.

Parameters:
sign_id The new SignID.

Definition at line 165 of file script_object.cpp.

References GetStorage(), and ScriptStorage::new_sign_id.

Referenced by SetLastCommandRes().

void ScriptObject::SetNewVehicleID ( VehicleID  vehicle_id  )  [static, private]

Store a new_vehicle_id per company.

Parameters:
vehicle_id The new VehicleID.

Definition at line 155 of file script_object.cpp.

References GetStorage(), and ScriptStorage::new_vehicle_id.

Referenced by SetLastCommandRes().


The documentation for this class was generated from the following files: