Changeset - r28702:1f79991b026a
[Not reviewed]
master
0 6 0
Loïc Guilloux - 10 months ago 2024-02-06 19:22:18
glx22@users.noreply.github.com
Add: [Script] ScriptTileList_StationCoverage (#12015)
6 files changed with 192 insertions and 4 deletions:
0 comments (0 inline, 0 general)
regression/regression/main.nut
Show inline comments
 
@@ -1358,6 +1358,21 @@ function Regression::Station()
 
	}
 
}
 

	
 
function Regression::StationList()
 
{
 
	print("");
 
	print("--StationList--");
 
	local road_stations = AIStationList(AIStation.STATION_TRUCK_STOP);
 
	for (local st = road_stations.Begin(); !road_stations.IsEnd(); st = road_stations.Next()) {
 
		print("  GetName(): " + AIStation.GetName(st));
 
		print("  TileList_StationCoverage:");
 
		local coverage = AITileList_StationCoverage(st);
 
		for (local i = coverage.Begin(); !coverage.IsEnd(); i = coverage.Next()) {
 
			print("    " + i);
 
		}
 
	}
 
}
 

	
 
function Regression::Tile()
 
{
 
	print("");
 
@@ -1989,6 +2004,7 @@ function Regression::Start()
 
	this.Road();
 
	this.Sign();
 
	this.Station();
 
	this.StationList();
 
	this.Tile();
 
	this.TileList();
 
	this.Town();
regression/regression/result.txt
Show inline comments
 
@@ -7761,6 +7761,153 @@ ERROR: IsEnd() is invalid as Begin() is 
 
  GetCargoPlannedFromVia(1000, 1000, 0, 1000): -1
 
  GetCargoPlannedFromVia(1000, 1000, 1000, 1000): -1
 

	
 
--StationList--
 
  GetName(): Little Frutford Valley
 
  TileList_StationCoverage:
 
    34192
 
    34191
 
    34190
 
    34189
 
    34188
 
    34187
 
    34186
 
    33936
 
    33935
 
    33934
 
    33933
 
    33932
 
    33931
 
    33930
 
    33680
 
    33679
 
    33678
 
    33677
 
    33676
 
    33675
 
    33674
 
    33424
 
    33423
 
    33422
 
    33421
 
    33420
 
    33419
 
    33418
 
    33168
 
    33167
 
    33166
 
    33165
 
    33164
 
    33163
 
    33162
 
    32912
 
    32911
 
    32910
 
    32909
 
    32908
 
    32907
 
    32906
 
    32656
 
    32655
 
    32654
 
    32653
 
    32652
 
    32651
 
    32650
 
  GetName(): Little Frutford Woods
 
  TileList_StationCoverage:
 
    34439
 
    34438
 
    34437
 
    34436
 
    34435
 
    34434
 
    34433
 
    34432
 
    34187
 
    34186
 
    34185
 
    34184
 
    34183
 
    34182
 
    34181
 
    34180
 
    34179
 
    34178
 
    34177
 
    34176
 
    33931
 
    33930
 
    33929
 
    33928
 
    33927
 
    33926
 
    33925
 
    33924
 
    33923
 
    33922
 
    33921
 
    33920
 
    33675
 
    33674
 
    33673
 
    33672
 
    33671
 
    33670
 
    33669
 
    33668
 
    33667
 
    33666
 
    33665
 
    33664
 
    33419
 
    33418
 
    33417
 
    33416
 
    33415
 
    33414
 
    33413
 
    33412
 
    33411
 
    33410
 
    33409
 
    33408
 
    33163
 
    33162
 
    33161
 
    33160
 
    33159
 
    33158
 
    33157
 
    33156
 
    33155
 
    33154
 
    33153
 
    33152
 
    32907
 
    32906
 
    32905
 
    32904
 
    32903
 
    32902
 
    32901
 
    32900
 
    32899
 
    32898
 
    32897
 
    32896
 
    32651
 
    32650
 
    32649
 
    32648
 
    32647
 
    32646
 
    32645
 
    32644
 
    32643
 
    32642
 
    32641
 
    32640
 

	
 
--Tile--
 
  HasTreeOnTile():      false
 
  IsFarmTile():         true
 
@@ -9589,9 +9736,9 @@ ERROR: IsEnd() is invalid as Begin() is 
 
--Valuate() with excessive CPU usage--
 
Your script made an error: excessive CPU usage in valuator function
 

	
 
*FUNCTION [unknown()] regression/main.nut line [2034]
 
*FUNCTION [unknown()] regression/main.nut line [2050]
 
*FUNCTION [Valuate()] NATIVE line [-1]
 
*FUNCTION [Start()] regression/main.nut line [2035]
 
*FUNCTION [Start()] regression/main.nut line [2051]
 

	
 
[id] 0
 
[this] TABLE
 
@@ -9600,7 +9747,7 @@ Your script made an error: excessive CPU
 
[this] INSTANCE
 
Your script made an error: excessive CPU usage in valuator function
 

	
 
*FUNCTION [Start()] regression/main.nut line [2035]
 
*FUNCTION [Start()] regression/main.nut line [2051]
 

	
 
[Infinite] CLOSURE
 
[list] INSTANCE
src/script/api/ai_changelog.hpp
Show inline comments
 
@@ -21,6 +21,7 @@
 
 * \li AITimeMode
 
 * \li AITown::ROAD_LAYOUT_RANDOM
 
 * \li AIVehicle::IsPrimaryVehicle
 
 * \li AITileList_StationCoverage
 
 *
 
 * API removals:
 
 * \li AIError::ERR_PRECONDITION_TOO_MANY_PARAMETERS, that error is never returned anymore.
src/script/api/game_changelog.hpp
Show inline comments
 
@@ -87,10 +87,11 @@
 
 * \li GSStoryPage::IsValidStoryPageButtonColour
 
 * \li GSStoryPage::IsValidStoryPageButtonFlags
 
 * \li GSStoryPage::IsValidStoryPageButtonCursor
 
 * \li GSTileList_StationCoverage
 
 *
 
 * API removals:
 
 * \li GSError::ERR_PRECONDITION_TOO_MANY_PARAMETERS, that error is never returned anymore.
 
 * \li AIInfo::CONFIG_RANDOM, no longer used.
 
 * \li GSInfo::CONFIG_RANDOM, no longer used.
 
 *
 
 * Other changes:
 
 * \li GSGroupList accepts an optional filter function
src/script/api/script_tilelist.cpp
Show inline comments
 
@@ -147,3 +147,13 @@ ScriptTileList_StationType::ScriptTileLi
 
		this->AddTile(cur_tile);
 
	}
 
}
 

	
 
ScriptTileList_StationCoverage::ScriptTileList_StationCoverage(StationID station_id)
 
{
 
	if (!ScriptStation::IsValidStation(station_id)) return;
 

	
 
	BitmapTileIterator it(::Station::Get(station_id)->catchment_tiles);
 
	for (TileIndex tile = it; tile != INVALID_TILE; tile = ++it) {
 
		this->AddTile(tile);
 
	}
 
}
src/script/api/script_tilelist.hpp
Show inline comments
 
@@ -104,4 +104,17 @@ public:
 
	ScriptTileList_StationType(StationID station_id, ScriptStation::StationType station_type);
 
};
 

	
 
/**
 
 * Creates a list of tiles in the catchment area of the StationID.
 
 * @api ai game
 
 * @ingroup ScriptList
 
 */
 
class ScriptTileList_StationCoverage : public ScriptTileList {
 
public:
 
	/**
 
	 * @param station_id The station to create the ScriptTileList for.
 
	 */
 
	ScriptTileList_StationCoverage(StationID station_id);
 
};
 

	
 
#endif /* SCRIPT_TILELIST_HPP */
0 comments (0 inline, 0 general)