@@ -24,22 +24,26 @@ ScriptDepotList::ScriptDepotList(ScriptT
case ScriptTile::TRANSPORT_ROAD: tile_type = ::MP_ROAD; break;
case ScriptTile::TRANSPORT_RAIL: tile_type = ::MP_RAILWAY; break;
case ScriptTile::TRANSPORT_WATER: tile_type = ::MP_WATER; break;
case ScriptTile::TRANSPORT_AIR: {
/* Hangars are not seen as real depots by the depot code. */
bool is_deity = ScriptCompanyMode::IsDeity();
CompanyID owner = ScriptObject::GetCompany();
for (const Station *st : Station::Iterate()) {
if (st->owner == ScriptObject::GetCompany() || ScriptCompanyMode::IsDeity()) {
if (is_deity || st->owner == owner) {
for (uint i = 0; i < st->airport.GetNumHangars(); i++) {
this->AddItem(st->airport.GetHangarTile(i).base());
}
return;
/* Handle 'standard' depots. */
for (const Depot *depot : Depot::Iterate()) {
if ((::GetTileOwner(depot->xy) == ScriptObject::GetCompany() || ScriptCompanyMode::IsDeity()) && ::IsTileType(depot->xy, tile_type)) this->AddItem(depot->xy.base());
if ((is_deity || ::GetTileOwner(depot->xy) == owner) && ::IsTileType(depot->xy, tile_type)) this->AddItem(depot->xy.base());
@@ -13,10 +13,12 @@
#include "../../safeguards.h"
ScriptEngineList::ScriptEngineList(ScriptVehicle::VehicleType vehicle_type)
{
EnforceDeityOrCompanyModeValid_Void();
for (const Engine *e : Engine::IterateType((::VehicleType)vehicle_type)) {
if (ScriptCompanyMode::IsDeity() || HasBit(e->company_avail, ScriptObject::GetCompany())) this->AddItem(e->index);
if (is_deity || HasBit(e->company_avail, owner)) this->AddItem(e->index);
@@ -14,10 +14,11 @@
ScriptGroupList::ScriptGroupList()
EnforceCompanyModeValid_Void();
for (const Group *g : Group::Iterate()) {
if (g->owner == ScriptObject::GetCompany()) this->AddItem(g->index);
if (g->owner == owner) this->AddItem(g->index);
@@ -14,10 +14,12 @@
ScriptRailTypeList::ScriptRailTypeList()
for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
if (ScriptCompanyMode::IsDeity() || ::HasRailTypeAvail(ScriptObject::GetCompany(), rt)) this->AddItem(rt);
if (is_deity || ::HasRailTypeAvail(owner, rt)) this->AddItem(rt);
@@ -13,11 +13,12 @@
ScriptRoadTypeList::ScriptRoadTypeList(ScriptRoad::RoadTramTypes rtts)
for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
if (!HasBit(rtts, GetRoadTramType(rt))) continue;
if (::HasRoadTypeAvail(ScriptObject::GetCompany(), rt)) this->AddItem(rt);
if (::HasRoadTypeAvail(owner, rt)) this->AddItem(rt);
@@ -16,14 +16,16 @@
ScriptStationList::ScriptStationList(ScriptStation::StationType station_type)
for (Station *st : Station::Iterate()) {
if ((st->owner == ScriptObject::GetCompany() || ScriptCompanyMode::IsDeity()) && (st->facilities & station_type) != 0) this->AddItem(st->index);
if ((is_deity || st->owner == owner) && (st->facilities & station_type) != 0) this->AddItem(st->index);
ScriptStationList_Vehicle::ScriptStationList_Vehicle(VehicleID vehicle_id)
if (!ScriptVehicle::IsPrimaryVehicle(vehicle_id)) return;
@@ -48,14 +48,16 @@ ScriptVehicleList::ScriptVehicleList(HSQ
if (nparam >= 1 && vm->_ops_till_suspend_error_threshold == INT64_MIN) {
new_ops_error_threshold = vm->_ops_till_suspend - MAX_VALUATE_OPS;
vm->_ops_till_suspend_error_label = "vehicle filter function";
AutoRestoreBackup ops_error_threshold_backup(vm->_ops_till_suspend_error_threshold, new_ops_error_threshold);
for (const Vehicle *v : Vehicle::Iterate()) {
if (v->owner != ScriptObject::GetCompany() && !ScriptCompanyMode::IsDeity()) continue;
if (v->owner != owner && !is_deity) continue;
if (!v->IsPrimaryVehicle() && !(v->type == VEH_TRAIN && ::Train::From(v)->IsFreeWagon())) continue;
if (nparam < 1) {
/* No filter, just add the item. */
this->AddItem(v->index);
continue;
@@ -104,14 +106,16 @@ ScriptVehicleList::ScriptVehicleList(HSQ
ScriptVehicleList_Station::ScriptVehicleList_Station(StationID station_id)
if (!ScriptBaseStation::IsValidBaseStation(station_id)) return;
if ((v->owner == ScriptObject::GetCompany() || ScriptCompanyMode::IsDeity()) && v->IsPrimaryVehicle()) {
if ((v->owner == owner || is_deity) && v->IsPrimaryVehicle()) {
for (const Order *order : v->Orders()) {
if ((order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT)) && order->GetDestination() == station_id) {
break;
@@ -153,14 +157,16 @@ ScriptVehicleList_Depot::ScriptVehicleLi
default: // No depot
if ((v->owner == ScriptObject::GetCompany() || ScriptCompanyMode::IsDeity()) && v->IsPrimaryVehicle() && v->type == type) {
if ((v->owner == owner || is_deity) && v->IsPrimaryVehicle() && v->type == type) {
if (order->IsType(OT_GOTO_DEPOT) && order->GetDestination() == dest) {
@@ -179,24 +185,26 @@ ScriptVehicleList_SharedOrders::ScriptVe
ScriptVehicleList_Group::ScriptVehicleList_Group(GroupID group_id)
if (!ScriptGroup::IsValidGroup((ScriptGroup::GroupID)group_id)) return;
if (v->owner == ScriptObject::GetCompany() && v->IsPrimaryVehicle()) {
if (v->owner == owner && v->IsPrimaryVehicle()) {
if (v->group_id == group_id) this->AddItem(v->index);
ScriptVehicleList_DefaultGroup::ScriptVehicleList_DefaultGroup(ScriptVehicle::VehicleType vehicle_type)
if (vehicle_type < ScriptVehicle::VT_RAIL || vehicle_type > ScriptVehicle::VT_AIR) return;
if (v->type == (::VehicleType)vehicle_type && v->group_id == ScriptGroup::GROUP_DEFAULT) this->AddItem(v->index);
Status change: