Update to 1.10.0-beta1
This commit is contained in:
@@ -66,7 +66,7 @@ static const Order *ResolveOrder(VehicleID vehicle_id, ScriptOrder::OrderPositio
|
||||
const Order *order = &v->current_order;
|
||||
if (order->GetType() == OT_GOTO_DEPOT && !(order->GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) return order;
|
||||
order_position = ScriptOrder::ResolveOrderPosition(vehicle_id, order_position);
|
||||
if (order_position == ScriptOrder::ORDER_INVALID) return NULL;
|
||||
if (order_position == ScriptOrder::ORDER_INVALID) return nullptr;
|
||||
}
|
||||
const Order *order = v->GetFirstOrder();
|
||||
while (order->GetType() == OT_IMPLICIT) order = order->next;
|
||||
@@ -108,7 +108,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||
if (!IsValidVehicleOrder(vehicle_id, order_position)) return false;
|
||||
|
||||
const Order *order = ::ResolveOrder(vehicle_id, order_position);
|
||||
return order != NULL && order->GetType() == OT_GOTO_STATION;
|
||||
return order != nullptr && order->GetType() == OT_GOTO_STATION;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptOrder::IsGotoDepotOrder(VehicleID vehicle_id, OrderPosition order_position)
|
||||
@@ -116,7 +116,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||
if (!IsValidVehicleOrder(vehicle_id, order_position)) return false;
|
||||
|
||||
const Order *order = ::ResolveOrder(vehicle_id, order_position);
|
||||
return order != NULL && order->GetType() == OT_GOTO_DEPOT;
|
||||
return order != nullptr && order->GetType() == OT_GOTO_DEPOT;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptOrder::IsGotoWaypointOrder(VehicleID vehicle_id, OrderPosition order_position)
|
||||
@@ -124,7 +124,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||
if (!IsValidVehicleOrder(vehicle_id, order_position)) return false;
|
||||
|
||||
const Order *order = ::ResolveOrder(vehicle_id, order_position);
|
||||
return order != NULL && order->GetType() == OT_GOTO_WAYPOINT;
|
||||
return order != nullptr && order->GetType() == OT_GOTO_WAYPOINT;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptOrder::IsConditionalOrder(VehicleID vehicle_id, OrderPosition order_position)
|
||||
@@ -150,7 +150,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||
if (!IsValidVehicleOrder(vehicle_id, order_position)) return false;
|
||||
|
||||
const Order *order = ::ResolveOrder(vehicle_id, order_position);
|
||||
return order != NULL && order->IsRefit();
|
||||
return order != nullptr && order->IsRefit();
|
||||
}
|
||||
|
||||
/* static */ bool ScriptOrder::IsCurrentOrderPartOfOrderList(VehicleID vehicle_id)
|
||||
@@ -240,7 +240,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||
if (!IsValidVehicleOrder(vehicle_id, order_position)) return INVALID_TILE;
|
||||
|
||||
const Order *order = ::ResolveOrder(vehicle_id, order_position);
|
||||
if (order == NULL || order->GetType() == OT_CONDITIONAL) return INVALID_TILE;
|
||||
if (order == nullptr || order->GetType() == OT_CONDITIONAL) return INVALID_TILE;
|
||||
const Vehicle *v = ::Vehicle::Get(vehicle_id);
|
||||
|
||||
switch (order->GetType()) {
|
||||
@@ -261,11 +261,13 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||
TILE_AREA_LOOP(t, st->train_station) {
|
||||
if (st->TileBelongsToRailStation(t)) return t;
|
||||
}
|
||||
} else if (st->dock_tile != INVALID_TILE) {
|
||||
return st->dock_tile;
|
||||
} else if (st->bus_stops != NULL) {
|
||||
} else if (st->ship_station.tile != INVALID_TILE) {
|
||||
TILE_AREA_LOOP(t, st->ship_station) {
|
||||
if (IsDockTile(t) && GetStationIndex(t) == st->index) return t;
|
||||
}
|
||||
} else if (st->bus_stops != nullptr) {
|
||||
return st->bus_stops->xy;
|
||||
} else if (st->truck_stops != NULL) {
|
||||
} else if (st->truck_stops != nullptr) {
|
||||
return st->truck_stops->xy;
|
||||
} else if (st->airport.tile != INVALID_TILE) {
|
||||
TILE_AREA_LOOP(tile, st->airport) {
|
||||
@@ -294,7 +296,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||
if (!IsValidVehicleOrder(vehicle_id, order_position)) return OF_INVALID;
|
||||
|
||||
const Order *order = ::ResolveOrder(vehicle_id, order_position);
|
||||
if (order == NULL || order->GetType() == OT_CONDITIONAL || order->GetType() == OT_DUMMY) return OF_INVALID;
|
||||
if (order == nullptr || order->GetType() == OT_CONDITIONAL || order->GetType() == OT_DUMMY) return OF_INVALID;
|
||||
|
||||
ScriptOrderFlags order_flags = OF_NONE;
|
||||
order_flags |= (ScriptOrderFlags)order->GetNonStopType();
|
||||
@@ -586,7 +588,7 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance *instance)
|
||||
EnforcePrecondition(false, (order_flags & OF_GOTO_NEAREST_DEPOT) == (current & OF_GOTO_NEAREST_DEPOT));
|
||||
|
||||
if ((current & OF_NON_STOP_FLAGS) != (order_flags & OF_NON_STOP_FLAGS)) {
|
||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (order_flags & OF_NON_STOP_FLAGS) << 4 | MOF_NON_STOP, CMD_MODIFY_ORDER, NULL, &::_DoCommandReturnSetOrderFlags);
|
||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (order_flags & OF_NON_STOP_FLAGS) << 4 | MOF_NON_STOP, CMD_MODIFY_ORDER, nullptr, &::_DoCommandReturnSetOrderFlags);
|
||||
}
|
||||
|
||||
switch (order->GetType()) {
|
||||
@@ -595,16 +597,16 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance *instance)
|
||||
uint data = DA_ALWAYS_GO;
|
||||
if (order_flags & OF_SERVICE_IF_NEEDED) data = DA_SERVICE;
|
||||
if (order_flags & OF_STOP_IN_DEPOT) data = DA_STOP;
|
||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (data << 4) | MOF_DEPOT_ACTION, CMD_MODIFY_ORDER, NULL, &::_DoCommandReturnSetOrderFlags);
|
||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (data << 4) | MOF_DEPOT_ACTION, CMD_MODIFY_ORDER, nullptr, &::_DoCommandReturnSetOrderFlags);
|
||||
}
|
||||
break;
|
||||
|
||||
case OT_GOTO_STATION:
|
||||
if ((current & OF_UNLOAD_FLAGS) != (order_flags & OF_UNLOAD_FLAGS)) {
|
||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (order_flags & OF_UNLOAD_FLAGS) << 2 | MOF_UNLOAD, CMD_MODIFY_ORDER, NULL, &::_DoCommandReturnSetOrderFlags);
|
||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (order_flags & OF_UNLOAD_FLAGS) << 2 | MOF_UNLOAD, CMD_MODIFY_ORDER, nullptr, &::_DoCommandReturnSetOrderFlags);
|
||||
}
|
||||
if ((current & OF_LOAD_FLAGS) != (order_flags & OF_LOAD_FLAGS)) {
|
||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (order_flags & OF_LOAD_FLAGS) >> 1 | MOF_LOAD, CMD_MODIFY_ORDER, NULL, &::_DoCommandReturnSetOrderFlags);
|
||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (order_flags & OF_LOAD_FLAGS) >> 1 | MOF_LOAD, CMD_MODIFY_ORDER, nullptr, &::_DoCommandReturnSetOrderFlags);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -667,8 +669,14 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance *instance)
|
||||
/* static */ uint ScriptOrder::GetOrderDistance(ScriptVehicle::VehicleType vehicle_type, TileIndex origin_tile, TileIndex dest_tile)
|
||||
{
|
||||
if (vehicle_type == ScriptVehicle::VT_AIR) {
|
||||
if (ScriptTile::IsStationTile(origin_tile) && ::Station::GetByTile(origin_tile)->airport.tile != INVALID_TILE) origin_tile = ::Station::GetByTile(origin_tile)->airport.tile;
|
||||
if (ScriptTile::IsStationTile(dest_tile) && ::Station::GetByTile(dest_tile)->airport.tile != INVALID_TILE) dest_tile = ::Station::GetByTile(dest_tile)->airport.tile;
|
||||
if (ScriptTile::IsStationTile(origin_tile)) {
|
||||
Station *orig_station = ::Station::GetByTile(origin_tile);
|
||||
if (orig_station != nullptr && orig_station->airport.tile != INVALID_TILE) origin_tile = orig_station->airport.tile;
|
||||
}
|
||||
if (ScriptTile::IsStationTile(dest_tile)) {
|
||||
Station *dest_station = ::Station::GetByTile(dest_tile);
|
||||
if (dest_station != nullptr && dest_station->airport.tile != INVALID_TILE) dest_tile = dest_station->airport.tile;
|
||||
}
|
||||
|
||||
return ScriptMap::DistanceSquare(origin_tile, dest_tile);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user