Changeset - r28438:f8d5478487f3
[Not reviewed]
master
0 4 0
Loïc Guilloux - 11 months ago 2024-01-12 20:19:08
glx22@users.noreply.github.com
Codechange: [Script] Use ScriptList::FillList() in more locations (#11762)
4 files changed with 19 insertions and 17 deletions:
0 comments (0 inline, 0 general)
src/script/api/script_stationlist.cpp
Show inline comments
 
@@ -18,15 +18,17 @@
 

	
 
ScriptStationList::ScriptStationList(ScriptStation::StationType station_type)
 
{
 
	EnforceDeityOrCompanyModeValid_Void();
 
	bool is_deity = ScriptCompanyMode::IsDeity();
 
	CompanyID owner = ScriptObject::GetCompany();
 
	for (Station *st : Station::Iterate()) {
 
		if ((is_deity || st->owner == owner) && (st->facilities & station_type) != 0) this->AddItem(st->index);
 
	}
 
	ScriptList::FillList<Station>(this,
 
		[is_deity, owner, station_type](const Station *st) {
 
			return (is_deity || st->owner == owner) && (st->facilities & station_type) != 0;
 
		}
 
	);
 
}
 

	
 
ScriptStationList_Vehicle::ScriptStationList_Vehicle(VehicleID vehicle_id)
 
{
 
	if (!ScriptVehicle::IsPrimaryVehicle(vehicle_id)) return;
 

	
src/script/api/script_storypageelementlist.cpp
Show inline comments
 
@@ -14,12 +14,10 @@
 
#include "../../safeguards.h"
 

	
 
ScriptStoryPageElementList::ScriptStoryPageElementList(ScriptStoryPage::StoryPageID story_page_id)
 
{
 
	if (!ScriptStoryPage::IsValidStoryPage(story_page_id)) return;
 

	
 
	for (StoryPageElement *pe : StoryPageElement::Iterate()) {
 
		if (pe->page == story_page_id) {
 
			this->AddItem(pe->index);
 
		}
 
	}
 
	ScriptList::FillList<StoryPageElement>(this,
 
		[story_page_id](const StoryPageElement *pe) {return pe->page == story_page_id; }
 
	);
 
}
src/script/api/script_storypagelist.cpp
Show inline comments
 
@@ -16,12 +16,10 @@
 

	
 
ScriptStoryPageList::ScriptStoryPageList(ScriptCompany::CompanyID company)
 
{
 
	uint8_t c = company;
 
	if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY;
 

	
 
	for (StoryPage *p : StoryPage::Iterate()) {
 
		if (p->company == c || p->company == INVALID_COMPANY) {
 
			this->AddItem(p->index);
 
		}
 
	}
 
	ScriptList::FillList<StoryPage>(this,
 
		[c](const StoryPage *p) {return p->company == c || p->company == INVALID_COMPANY; }
 
	);
 
}
src/script/api/script_waypointlist.cpp
Show inline comments
 
@@ -15,16 +15,20 @@
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptWaypointList::ScriptWaypointList(ScriptWaypoint::WaypointType waypoint_type)
 
{
 
	EnforceDeityOrCompanyModeValid_Void();
 
	for (const Waypoint *wp : Waypoint::Iterate()) {
 
		if ((wp->facilities & waypoint_type) &&
 
				(wp->owner == ScriptObject::GetCompany() || ScriptCompanyMode::IsDeity() || wp->owner == OWNER_NONE)) this->AddItem(wp->index);
 
	}
 

	
 
	bool is_deity = ScriptCompanyMode::IsDeity();
 
	CompanyID owner = ScriptObject::GetCompany();
 
	ScriptList::FillList<Waypoint>(this,
 
		[is_deity, owner, waypoint_type](const Waypoint *wp) {
 
			return (is_deity || wp->owner == owner || wp->owner == OWNER_NONE) && (wp->facilities & waypoint_type) != 0;
 
		}
 
	);
 
}
 

	
 
ScriptWaypointList_Vehicle::ScriptWaypointList_Vehicle(VehicleID vehicle_id)
 
{
 
	if (!ScriptVehicle::IsPrimaryVehicle(vehicle_id)) return;
 

	
0 comments (0 inline, 0 general)