1
0
Fork 0

Fix b2c57123: [Script] Conversion from ScriptEvent to ScriptEventCompanyTown subclasses (#14274)

pull/14280/head
Loïc Guilloux 2025-05-18 15:40:47 +02:00 committed by GitHub
parent 9bbc525e53
commit 1b0fd0e6fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 85 additions and 43 deletions

View File

@ -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;

View File

@ -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

View File

@ -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<ScriptEventVehicleCrashed *>(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<ScriptEventSubsidyOffer *>(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<ScriptEventSubsidyOfferExpired *>(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<ScriptEventSubsidyAwarded *>(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<ScriptEventSubsidyExpired *>(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<ScriptEventEnginePreview *>(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<ScriptEventCompanyNew *>(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<ScriptEventCompanyRenamed *>(instance); }
static ScriptEventCompanyRenamed *Convert(ScriptEvent *instance) { return dynamic_cast<ScriptEventCompanyRenamed *>(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<ScriptEventCompanyInTrouble *>(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<ScriptEventCompanyAskMerger *>(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<ScriptEventCompanyMerger *>(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<ScriptEventCompanyBankrupt *>(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<ScriptEventVehicleLost *>(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<ScriptEventVehicleWaitingInDepot *>(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<ScriptEventVehicleUnprofitable *>(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<ScriptEventIndustryOpen *>(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<ScriptEventIndustryClose *>(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<ScriptEventEngineAvailable *>(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<ScriptEventStationFirstVehicle *>(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<ScriptEventDisasterZeppelinerCrashed *>(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<ScriptEventDisasterZeppelinerCleared *>(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<ScriptEventTownFounded *>(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<ScriptEventAircraftDestTooFar *>(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<ScriptEventAdminPort *>(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<ScriptEventWindowWidgetClick *>(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<ScriptEventGoalQuestionAnswer *>(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<ScriptEventCompanyTown *>(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<ScriptEventExclusiveTransportRights *>(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<ScriptEventRoadReconstruction *>(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<ScriptEventVehicleAutoReplaced *>(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<ScriptEventStoryPageButtonClick *>(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<ScriptEventStoryPageTileSelect *>(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<ScriptEventStoryPageVehicleSelect *>(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<ScriptEventPresidentRenamed *>(instance); }
static ScriptEventPresidentRenamed *Convert(ScriptEvent *instance) { return dynamic_cast<ScriptEventPresidentRenamed *>(instance); }
/**
* Get the CompanyID of the company that got its president renamed.