This commit is contained in:
SamuXarick 2024-04-19 13:24:03 +01:00 committed by GitHub
commit 2f1e699985
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 137 additions and 3 deletions

View File

@ -242,6 +242,60 @@ function Regression::Airport()
print(" BuildAirport(): " + AIAirport.BuildAirport(32116, 0, AIStation.STATION_JOIN_ADJACENT));
}
function Regression::AirportTypeList()
{
local list = AIAirportTypeList();
print("");
print("--AirportTypeList--");
print(" Count(): " + list.Count());
list.Valuate(AIAirport.IsValidAirportType);
print(" IsValidAirportType ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIAirport.IsAirportInformationAvailable);
print(" IsAirportInformationAvailable ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIAirport.GetPrice);
print(" GetPrice ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIAirport.GetAirportWidth);
print(" GetAirportWidth ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIAirport.GetAirportHeight);
print(" GetAirportHeight ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIAirport.GetAirportCoverageRadius);
print(" GetAirportCoverageRadius ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIAirport.GetMaintenanceCostFactor);
print(" GetMaintenanceCostFactor ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIAirport.GetMonthlyMaintenanceCost);
print(" GetMonthlyMaintenanceCost ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIAirport.GetAirportNumHelipads);
print(" GetAirportNumHelipads ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
}
function Regression::Bridge()
{
local j = 0;
@ -1987,6 +2041,7 @@ function Regression::Start()
this.Commands();
this.Airport();
this.AirportTypeList()
this.Bridge();
this.BridgeList();
this.Cargo();

View File

@ -883,6 +883,27 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetBankBalance(): 1999989626
BuildAirport(): true
--AirportTypeList--
Count(): 1
IsValidAirportType ListDump:
0 => 1
IsAirportInformationAvailable ListDump:
0 => 1
GetPrice ListDump:
0 => 5400
GetAirportWidth ListDump:
0 => 4
GetAirportHeight ListDump:
0 => 3
GetAirportCoverageRadius ListDump:
0 => 4
GetMaintenanceCostFactor ListDump:
0 => 7
GetMonthlyMaintenanceCost ListDump:
0 => 3281
GetAirportNumHelipads ListDump:
0 => 0
--Bridge--
Bridge -1
IsValidBridge(): false
@ -9748,9 +9769,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 [2051]
*FUNCTION [unknown()] regression/main.nut line [2106]
*FUNCTION [Valuate()] NATIVE line [-1]
*FUNCTION [Start()] regression/main.nut line [2052]
*FUNCTION [Start()] regression/main.nut line [2107]
[id] 0
[this] TABLE
@ -9759,7 +9780,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 [2052]
*FUNCTION [Start()] regression/main.nut line [2107]
[Infinite] CLOSURE
[list] INSTANCE

View File

@ -146,6 +146,7 @@ add_files(
script_accounting.hpp
script_admin.hpp
script_airport.hpp
script_airporttypelist.hpp
script_asyncmode.hpp
script_base.hpp
script_basestation.hpp
@ -220,6 +221,7 @@ add_files(
script_accounting.cpp
script_admin.cpp
script_airport.cpp
script_airporttypelist.cpp
script_asyncmode.cpp
script_base.cpp
script_basestation.cpp

View File

@ -17,6 +17,9 @@
*
* This version is not yet released. The following changes are not set in stone yet.
*
* API additions:
* \li AIAirportTypeList
*
* \b 14.0
*
* API additions:

View File

@ -17,6 +17,9 @@
*
* This version is not yet released. The following changes are not set in stone yet.
*
* API additions:
* \li GSAirportTypeList
*
* \b 14.0
*
* API additions:

View File

@ -0,0 +1,25 @@
/*
* 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_airporttypelist.cpp Implementation of ScriptAirportTypeList and friends. */
#include "../../stdafx.h"
#include "script_airporttypelist.hpp"
#include "script_error.hpp"
#include "../../newgrf_airport.h"
#include "../../safeguards.h"
ScriptAirportTypeList::ScriptAirportTypeList()
{
EnforceDeityOrCompanyModeValid_Void();
bool is_deity = ScriptCompanyMode::IsDeity();
for (uint8_t at = 0; at < ::NUM_AIRPORTS; at++) {
if ((is_deity && ::AirportSpec::Get(at)->enabled) || ::AirportSpec::Get(at)->IsAvailable()) this->AddItem(at);
}
}

View File

@ -0,0 +1,25 @@
/*
* 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_airporttypelist.hpp List all available airport types. */
#ifndef SCRIPT_AIRPORTTYPELIST_HPP
#define SCRIPT_AIRPORTTYPELIST_HPP
#include "script_list.hpp"
/**
* Creates a list of all available airport types.
* @api ai game
* @ingroup ScriptList
*/
class ScriptAirportTypeList : public ScriptList {
public:
ScriptAirportTypeList();
};
#endif /* SCRIPT_AIRPORTTYPELIST_HPP */