@@ -27,8 +27,10 @@ ScriptDepotList::ScriptDepotList(ScriptT
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());
}
@@ -39,7 +41,9 @@ ScriptDepotList::ScriptDepotList(ScriptT
/* 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());
@@ -16,7 +16,9 @@
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);
@@ -17,7 +17,8 @@
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);
@@ -17,7 +17,9 @@
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);
@@ -16,8 +16,9 @@
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);
@@ -19,8 +19,10 @@
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);
@@ -51,8 +51,10 @@ ScriptVehicleList::ScriptVehicleList(HSQ
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) {
@@ -107,8 +109,10 @@ ScriptVehicleList_Station::ScriptVehicle
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) {
this->AddItem(v->index);
@@ -156,8 +160,10 @@ ScriptVehicleList_Depot::ScriptVehicleLi
return;
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) {
@@ -182,8 +188,9 @@ ScriptVehicleList_Group::ScriptVehicleLi
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);
@@ -194,8 +201,9 @@ ScriptVehicleList_DefaultGroup::ScriptVe
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: