diff --git a/regression/regression/main.nut b/regression/regression/main.nut index bab4bde578..2da20af963 100644 --- a/regression/regression/main.nut +++ b/regression/regression/main.nut @@ -1701,13 +1701,22 @@ function Regression::TownList() } print(" HasStatue(): " + AITown.HasStatue(list.Begin())); - print(" GetRoadReworkDuration(): " + AITown.GetRoadReworkDuration(list.Begin())); - print(" GetExclusiveRightsCompany(): " + AITown.GetExclusiveRightsCompany(list.Begin())); - print(" GetExclusiveRightsDuration(): " + AITown.GetExclusiveRightsDuration(list.Begin())); print(" IsActionAvailable(BUILD_STATUE): " + AITown.IsActionAvailable(list.Begin(), AITown.TOWN_ACTION_BUILD_STATUE)); print(" PerformTownAction(BUILD_STATUE): " + AITown.PerformTownAction(list.Begin(), AITown.TOWN_ACTION_BUILD_STATUE)); print(" IsActionAvailable(BUILD_STATUE): " + AITown.IsActionAvailable(list.Begin(), AITown.TOWN_ACTION_BUILD_STATUE)); print(" HasStatue(): " + AITown.HasStatue(list.Begin())); + print(" GetRoadReworkDuration(): " + AITown.GetRoadReworkDuration(list.Begin())); + print(" IsActionAvailable(ROAD_REBUILD): " + AITown.IsActionAvailable(list.Begin(), AITown.TOWN_ACTION_ROAD_REBUILD)); + print(" PerformTownAction(ROAD_REBUILD): " + AITown.PerformTownAction(list.Begin(), AITown.TOWN_ACTION_ROAD_REBUILD)); + print(" IsActionAvailable(ROAD_REBUILD): " + AITown.IsActionAvailable(list.Begin(), AITown.TOWN_ACTION_ROAD_REBUILD)); + print(" GetRoadReworkDuration(): " + AITown.GetRoadReworkDuration(list.Begin())); + print(" GetExclusiveRightsCompany(): " + AITown.GetExclusiveRightsCompany(list.Begin())); + print(" GetExclusiveRightsDuration(): " + AITown.GetExclusiveRightsDuration(list.Begin())); + print(" IsActionAvailable(BUY_RIGHTS): " + AITown.IsActionAvailable(list.Begin(), AITown.TOWN_ACTION_BUY_RIGHTS)); + print(" PerformTownAction(BUY_RIGHTS): " + AITown.PerformTownAction(list.Begin(), AITown.TOWN_ACTION_BUY_RIGHTS)); + print(" IsActionAvailable(BUY_RIGHTS): " + AITown.IsActionAvailable(list.Begin(), AITown.TOWN_ACTION_BUY_RIGHTS)); + print(" GetExclusiveRightsCompany(): " + AITown.GetExclusiveRightsCompany(list.Begin())); + print(" GetExclusiveRightsDuration(): " + AITown.GetExclusiveRightsDuration(list.Begin())); } function Regression::Tunnel() @@ -2075,6 +2084,20 @@ function Regression::Start() print(" PresidentName: " + c.GetNewName()); } break; + case AIEvent.ET_EXCLUSIVE_TRANSPORT_RIGHTS: { + local c = AIEventExclusiveTransportRights.Convert(e); + print(" EventName: ExclusiveTransportRights"); + print(" CompanyID: " + c.GetCompanyID()); + print(" TownID: " + c.GetTownID()); + } break; + + case AIEvent.ET_ROAD_RECONSTRUCTION: { + local c = AIEventRoadReconstruction.Convert(e); + print(" EventName: RoadReconstruction"); + print(" CompanyID: " + c.GetCompanyID()); + print(" TownID: " + c.GetTownID()); + } break; + default: print(" Unknown Event"); break; diff --git a/regression/regression/result.txt b/regression/regression/result.txt index a26d24a752..f080cca003 100644 --- a/regression/regression/result.txt +++ b/regression/regression/result.txt @@ -9427,13 +9427,22 @@ ERROR: IsEnd() is invalid as Begin() is never called 23 => 652 25 => 563 HasStatue(): false - GetRoadReworkDuration(): 0 - GetExclusiveRightsCompany(): -1 - GetExclusiveRightsDuration(): 0 IsActionAvailable(BUILD_STATUE): true PerformTownAction(BUILD_STATUE): true IsActionAvailable(BUILD_STATUE): false HasStatue(): true + GetRoadReworkDuration(): 0 + IsActionAvailable(ROAD_REBUILD): true + PerformTownAction(ROAD_REBUILD): true + IsActionAvailable(ROAD_REBUILD): true + GetRoadReworkDuration(): 6 + GetExclusiveRightsCompany(): -1 + GetExclusiveRightsDuration(): 0 + IsActionAvailable(BUY_RIGHTS): true + PerformTownAction(BUY_RIGHTS): true + IsActionAvailable(BUY_RIGHTS): false + GetExclusiveRightsCompany(): 1 + GetExclusiveRightsDuration(): 12 --Tunnel-- IsTunnelTile(): false @@ -9738,6 +9747,16 @@ ERROR: IsEnd() is invalid as Begin() is never called EventName: CompanyRenamed CompanyID: 1 CompanyName: Little Frutford Transport + GetNextEvent: instance + GetEventType: 28 + EventName: RoadReconstruction + CompanyID: 1 + TownID: 12 + GetNextEvent: instance + GetEventType: 27 + EventName: ExclusiveTransportRights + CompanyID: 1 + TownID: 12 IsEventWaiting: false --Math-- @@ -9775,9 +9794,9 @@ ERROR: IsEnd() is invalid as Begin() is never called --Valuate() with excessive CPU usage-- Your script made an error: excessive CPU usage in valuator function -*FUNCTION [unknown()] regression/main.nut line [2091] +*FUNCTION [unknown()] regression/main.nut line [2114] *FUNCTION [Valuate()] NATIVE line [-1] -*FUNCTION [Start()] regression/main.nut line [2092] +*FUNCTION [Start()] regression/main.nut line [2115] [id] 0 [this] TABLE @@ -9786,7 +9805,7 @@ Your script made an error: excessive CPU usage in valuator function [this] INSTANCE Your script made an error: excessive CPU usage in valuator function -*FUNCTION [Start()] regression/main.nut line [2092] +*FUNCTION [Start()] regression/main.nut line [2115] [Infinite] CLOSURE [list] INSTANCE diff --git a/src/script/api/script_event_types.hpp b/src/script/api/script_event_types.hpp index 0b67ce9376..25ba6d5bb9 100644 --- a/src/script/api/script_event_types.hpp +++ b/src/script/api/script_event_types.hpp @@ -62,7 +62,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventVehicleCrashed *Convert(ScriptEvent *instance) { return (ScriptEventVehicleCrashed *)instance; } + static ScriptEventVehicleCrashed *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the VehicleID of the crashed vehicle. @@ -123,7 +123,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventSubsidyOffer *Convert(ScriptEvent *instance) { return (ScriptEventSubsidyOffer *)instance; } + static ScriptEventSubsidyOffer *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the SubsidyID of the subsidy. @@ -156,7 +156,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventSubsidyOfferExpired *Convert(ScriptEvent *instance) { return (ScriptEventSubsidyOfferExpired *)instance; } + static ScriptEventSubsidyOfferExpired *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the SubsidyID of the subsidy. @@ -189,7 +189,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventSubsidyAwarded *Convert(ScriptEvent *instance) { return (ScriptEventSubsidyAwarded *)instance; } + static ScriptEventSubsidyAwarded *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the SubsidyID of the subsidy. @@ -222,7 +222,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventSubsidyExpired *Convert(ScriptEvent *instance) { return (ScriptEventSubsidyExpired *)instance; } + static ScriptEventSubsidyExpired *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the SubsidyID of the subsidy. @@ -257,7 +257,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventEnginePreview *Convert(ScriptEvent *instance) { return (ScriptEventEnginePreview *)instance; } + static ScriptEventEnginePreview *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the name of the offered engine. @@ -349,7 +349,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventCompanyNew *Convert(ScriptEvent *instance) { return (ScriptEventCompanyNew *)instance; } + static ScriptEventCompanyNew *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the CompanyID of the company that has been created. @@ -383,7 +383,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventCompanyRenamed *Convert(ScriptEvent *instance) { return static_cast(instance); } + static ScriptEventCompanyRenamed *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the CompanyID of the company that has been renamed. @@ -425,7 +425,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventCompanyInTrouble *Convert(ScriptEvent *instance) { return (ScriptEventCompanyInTrouble *)instance; } + static ScriptEventCompanyInTrouble *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the CompanyID of the company that is in trouble. @@ -460,7 +460,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventCompanyAskMerger *Convert(ScriptEvent *instance) { return (ScriptEventCompanyAskMerger *)instance; } + static ScriptEventCompanyAskMerger *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the CompanyID of the company that can be bought. @@ -511,7 +511,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventCompanyMerger *Convert(ScriptEvent *instance) { return (ScriptEventCompanyMerger *)instance; } + static ScriptEventCompanyMerger *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the CompanyID of the company that has been bought. @@ -554,7 +554,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventCompanyBankrupt *Convert(ScriptEvent *instance) { return (ScriptEventCompanyBankrupt *)instance; } + static ScriptEventCompanyBankrupt *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the CompanyID of the company that has gone bankrupt. @@ -587,7 +587,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventVehicleLost *Convert(ScriptEvent *instance) { return (ScriptEventVehicleLost *)instance; } + static ScriptEventVehicleLost *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the VehicleID of the vehicle that is lost. @@ -620,7 +620,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventVehicleWaitingInDepot *Convert(ScriptEvent *instance) { return (ScriptEventVehicleWaitingInDepot *)instance; } + static ScriptEventVehicleWaitingInDepot *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the VehicleID of the vehicle that is waiting in a depot. @@ -653,7 +653,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventVehicleUnprofitable *Convert(ScriptEvent *instance) { return (ScriptEventVehicleUnprofitable *)instance; } + static ScriptEventVehicleUnprofitable *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the VehicleID of the vehicle that lost money. @@ -686,7 +686,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventIndustryOpen *Convert(ScriptEvent *instance) { return (ScriptEventIndustryOpen *)instance; } + static ScriptEventIndustryOpen *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the IndustryID of the new industry. @@ -719,7 +719,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventIndustryClose *Convert(ScriptEvent *instance) { return (ScriptEventIndustryClose *)instance; } + static ScriptEventIndustryClose *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the IndustryID of the closing industry. @@ -752,7 +752,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventEngineAvailable *Convert(ScriptEvent *instance) { return (ScriptEventEngineAvailable *)instance; } + static ScriptEventEngineAvailable *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the EngineID of the new engine. @@ -787,7 +787,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventStationFirstVehicle *Convert(ScriptEvent *instance) { return (ScriptEventStationFirstVehicle *)instance; } + static ScriptEventStationFirstVehicle *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the StationID of the visited station. @@ -827,7 +827,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventDisasterZeppelinerCrashed *Convert(ScriptEvent *instance) { return (ScriptEventDisasterZeppelinerCrashed *)instance; } + static ScriptEventDisasterZeppelinerCrashed *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the StationID of the station containing the affected airport. @@ -860,7 +860,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventDisasterZeppelinerCleared *Convert(ScriptEvent *instance) { return (ScriptEventDisasterZeppelinerCleared *)instance; } + static ScriptEventDisasterZeppelinerCleared *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the StationID of the station containing the affected airport. @@ -893,7 +893,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventTownFounded *Convert(ScriptEvent *instance) { return (ScriptEventTownFounded *)instance; } + static ScriptEventTownFounded *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the TownID of the town. @@ -928,7 +928,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventAircraftDestTooFar *Convert(ScriptEvent *instance) { return (ScriptEventAircraftDestTooFar *)instance; } + static ScriptEventAircraftDestTooFar *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the VehicleID of the aircraft whose destination is too far away. @@ -958,7 +958,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventAdminPort *Convert(ScriptEvent *instance) { return (ScriptEventAdminPort *)instance; } + static ScriptEventAdminPort *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } #ifndef DOXYGEN_API /** @@ -1003,7 +1003,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventWindowWidgetClick *Convert(ScriptEvent *instance) { return (ScriptEventWindowWidgetClick *)instance; } + static ScriptEventWindowWidgetClick *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the class of the window that was clicked. @@ -1056,7 +1056,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventGoalQuestionAnswer *Convert(ScriptEvent *instance) { return (ScriptEventGoalQuestionAnswer *)instance; } + static ScriptEventGoalQuestionAnswer *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the unique id of the question. @@ -1106,7 +1106,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventCompanyTown *Convert(ScriptEvent *instance) { return (ScriptEventCompanyTown *)instance; } + static ScriptEventCompanyTown *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the CompanyID of the company. @@ -1147,7 +1147,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventExclusiveTransportRights *Convert(ScriptEventCompanyTown *instance) { return (ScriptEventExclusiveTransportRights *)instance; } + static ScriptEventExclusiveTransportRights *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } }; /** @@ -1172,7 +1172,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventRoadReconstruction *Convert(ScriptEventCompanyTown *instance) { return (ScriptEventRoadReconstruction *)instance; } + static ScriptEventRoadReconstruction *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } }; /** @@ -1198,7 +1198,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventVehicleAutoReplaced *Convert(ScriptEvent *instance) { return (ScriptEventVehicleAutoReplaced *)instance; } + static ScriptEventVehicleAutoReplaced *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the VehicleID of the vehicle that has been replaced. @@ -1242,7 +1242,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventStoryPageButtonClick *Convert(ScriptEvent *instance) { return (ScriptEventStoryPageButtonClick *)instance; } + static ScriptEventStoryPageButtonClick *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the CompanyID of the player that selected a tile. @@ -1295,7 +1295,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventStoryPageTileSelect *Convert(ScriptEvent *instance) { return (ScriptEventStoryPageTileSelect *)instance; } + static ScriptEventStoryPageTileSelect *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the CompanyID of the player that selected a tile. @@ -1355,7 +1355,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventStoryPageVehicleSelect *Convert(ScriptEvent *instance) { return (ScriptEventStoryPageVehicleSelect *)instance; } + static ScriptEventStoryPageVehicleSelect *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the CompanyID of the player that selected a tile. @@ -1413,7 +1413,7 @@ public: * @param instance The instance to convert. * @return The converted instance. */ - static ScriptEventPresidentRenamed *Convert(ScriptEvent *instance) { return static_cast(instance); } + static ScriptEventPresidentRenamed *Convert(ScriptEvent *instance) { return dynamic_cast(instance); } /** * Get the CompanyID of the company that got its president renamed.