mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-23 20:24:12 +01:00
Codechange: strongly type VehicleID
This commit is contained in:
@@ -633,7 +633,7 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance *instance)
|
||||
|
||||
/* static */ bool ScriptOrder::SetOrderFlags(VehicleID vehicle_id, OrderPosition order_position, ScriptOrder::ScriptOrderFlags order_flags)
|
||||
{
|
||||
ScriptObject::SetCallbackVariable(0, vehicle_id);
|
||||
ScriptObject::SetCallbackVariable(0, vehicle_id.base());
|
||||
ScriptObject::SetCallbackVariable(1, order_position);
|
||||
ScriptObject::SetCallbackVariable(2, order_flags);
|
||||
/* In case another client(s) change orders at the same time we could
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
if (!ScriptObject::Command<CMD_BUILD_VEHICLE>::Do(&ScriptInstance::DoCommandReturnVehicleID, depot, engine_id, true, cargo, INVALID_CLIENT_ID)) return VEHICLE_INVALID;
|
||||
|
||||
/* In case of test-mode, we return VehicleID 0 */
|
||||
return ::VEHICLE_BEGIN;
|
||||
return VehicleID::Begin();
|
||||
}
|
||||
|
||||
/* static */ VehicleID ScriptVehicle::BuildVehicle(TileIndex depot, EngineID engine_id)
|
||||
@@ -115,7 +115,7 @@
|
||||
if (!ScriptObject::Command<CMD_CLONE_VEHICLE>::Do(&ScriptInstance::DoCommandReturnVehicleID, depot, vehicle_id, share_orders)) return VEHICLE_INVALID;
|
||||
|
||||
/* In case of test-mode, we return VehicleID 0 */
|
||||
return ::VEHICLE_BEGIN;
|
||||
return VehicleID::Begin();
|
||||
}
|
||||
|
||||
/* static */ bool ScriptVehicle::_MoveWagonInternal(VehicleID source_vehicle_id, SQInteger source_wagon, bool move_attached_wagons, SQInteger dest_vehicle_id, SQInteger dest_wagon)
|
||||
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
VS_INVALID = 0xFF, ///< An invalid vehicle state.
|
||||
};
|
||||
|
||||
static const VehicleID VEHICLE_INVALID = ::INVALID_VEHICLE; ///< Invalid VehicleID.
|
||||
static constexpr VehicleID VEHICLE_INVALID = ::INVALID_VEHICLE; ///< Invalid VehicleID.
|
||||
|
||||
/**
|
||||
* Checks whether the given vehicle is valid and owned by you.
|
||||
|
||||
@@ -44,7 +44,7 @@ ScriptVehicleList_Station::ScriptVehicleList_Station(StationID station_id)
|
||||
FindVehiclesWithOrder(
|
||||
[is_deity, owner](const Vehicle *v) { return is_deity || v->owner == owner; },
|
||||
[station_id](const Order *order) { return (order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT)) && order->GetDestination() == station_id; },
|
||||
[this](const Vehicle *v) { this->AddItem(v->index); }
|
||||
[this](const Vehicle *v) { this->AddItem(v->index.base()); }
|
||||
);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ ScriptVehicleList_Depot::ScriptVehicleList_Depot(TileIndex tile)
|
||||
FindVehiclesWithOrder(
|
||||
[is_deity, owner, type](const Vehicle *v) { return (is_deity || v->owner == owner) && v->type == type; },
|
||||
[dest](const Order *order) { return order->IsType(OT_GOTO_DEPOT) && order->GetDestination() == dest; },
|
||||
[this](const Vehicle *v) { this->AddItem(v->index); }
|
||||
[this](const Vehicle *v) { this->AddItem(v->index.base()); }
|
||||
);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ ScriptVehicleList_SharedOrders::ScriptVehicleList_SharedOrders(VehicleID vehicle
|
||||
if (!ScriptVehicle::IsPrimaryVehicle(vehicle_id)) return;
|
||||
|
||||
for (const Vehicle *v = Vehicle::Get(vehicle_id)->FirstShared(); v != nullptr; v = v->NextShared()) {
|
||||
this->AddItem(v->index);
|
||||
this->AddItem(v->index.base());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user