Merge: Codechange: Use null pointer literal instead of the NULL macro
This commit is contained in:
@@ -229,7 +229,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
DateTicksScaled date_fract_scaled = ((DateTicksScaled)_date_fract * _settings_game.economy.day_length_factor) + _tick_skip_counter;
|
||||
|
||||
/* The scheduled order in next_orders with the earliest expected_date field. */
|
||||
OrderDate *least_order = NULL;
|
||||
OrderDate *least_order = nullptr;
|
||||
|
||||
/* Cache for scheduled departure time */
|
||||
schdispatch_cache_t schdispatch_last_planned_dispatch;
|
||||
@@ -259,7 +259,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
bool carries_passengers = false;
|
||||
|
||||
const Vehicle *u = v;
|
||||
while (u != NULL) {
|
||||
while (u != nullptr) {
|
||||
if (u->cargo_cap > 0 && IsCargoInClass(u->cargo_type, CC_PASSENGERS)) {
|
||||
carries_passengers = true;
|
||||
break;
|
||||
@@ -326,7 +326,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
status = D_TRAVELLING;
|
||||
}
|
||||
order = v->GetOrder(order->GetConditionSkipToOrder());
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
if (status != D_CANCELLED) {
|
||||
status = D_TRAVELLING;
|
||||
}
|
||||
order = (order->next == NULL) ? v->GetFirstOrder() : order->next;
|
||||
order = (order->next == nullptr) ? v->GetFirstOrder() : order->next;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -347,7 +347,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
|
||||
/* Skip it if it's an automatic order. */
|
||||
if (order->IsType(OT_IMPLICIT)) {
|
||||
order = (order->next == NULL) ? v->GetFirstOrder() : order->next;
|
||||
order = (order->next == nullptr) ? v->GetFirstOrder() : order->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
}
|
||||
|
||||
/* Update least_order if this is the current least order. */
|
||||
if (least_order == NULL) {
|
||||
if (least_order == nullptr) {
|
||||
least_order = od;
|
||||
} else if (int(least_order->expected_date - least_order->lateness - (type == D_ARRIVAL ? (least_order->scheduled_waiting_time > 0 ? least_order->scheduled_waiting_time : least_order->order->GetWaitTime()) : 0)) > int(od->expected_date - od->lateness - (type == D_ARRIVAL ? (od->scheduled_waiting_time > 0 ? od->scheduled_waiting_time : od->order->GetWaitTime()) : 0))) {
|
||||
/* Somehow my compiler perform an unsigned comparition above so integer cast is required */
|
||||
@@ -402,7 +402,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
if (status != D_CANCELLED) {
|
||||
status = D_TRAVELLING;
|
||||
}
|
||||
order = (order->next == NULL) ? v->GetFirstOrder() : order->next;
|
||||
order = (order->next == nullptr) ? v->GetFirstOrder() : order->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -461,7 +461,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
|
||||
/* Go through the order list, looping if necessary, to find a terminus. */
|
||||
/* Get the next order, which may be the vehicle's first order. */
|
||||
order = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||
order = (order->next == nullptr) ? least_order->v->GetFirstOrder() : order->next;
|
||||
/* We only need to consider each order at most once. */
|
||||
bool found_terminus = false;
|
||||
CallAt c = CallAt((StationID)order->GetDestination(), d->scheduled_date);
|
||||
@@ -483,14 +483,14 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
case 1: {
|
||||
/* Take the branch */
|
||||
order = least_order->v->GetOrder(order->GetConditionSkipToOrder());
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
case 2: {
|
||||
/* Do not take the branch */
|
||||
order = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||
order = (order->next == nullptr) ? least_order->v->GetFirstOrder() : order->next;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -532,7 +532,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
order->GetNonStopType() == ONSF_NO_STOP_AT_ANY_STATION ||
|
||||
order->GetNonStopType() == ONSF_NO_STOP_AT_DESTINATION_STATION) {
|
||||
c.scheduled_date += order->GetWaitTime();
|
||||
order = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||
order = (order->next == nullptr) ? least_order->v->GetFirstOrder() : order->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -566,7 +566,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
c.scheduled_date += order->GetWaitTime();
|
||||
|
||||
/* Get the next order, which may be the vehicle's first order. */
|
||||
order = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||
order = (order->next == nullptr) ? least_order->v->GetFirstOrder() : order->next;
|
||||
}
|
||||
|
||||
if (found_terminus) {
|
||||
@@ -620,7 +620,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
/* However, the very first thing we do is use the arrival time as the scheduled time instead of the departure time. */
|
||||
d->scheduled_date -= d->scheduled_waiting_time > 0 ? d->scheduled_waiting_time : order->GetWaitTime();
|
||||
|
||||
const Order *candidate_origin = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||
const Order *candidate_origin = (order->next == nullptr) ? least_order->v->GetFirstOrder() : order->next;
|
||||
bool found_origin = false;
|
||||
|
||||
while (candidate_origin != least_order->order) {
|
||||
@@ -629,7 +629,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
(candidate_origin->GetType() == OT_GOTO_STATION ||
|
||||
candidate_origin->GetType() == OT_IMPLICIT) &&
|
||||
candidate_origin->GetDestination() != station) {
|
||||
const Order *o = (candidate_origin->next == NULL) ? least_order->v->GetFirstOrder() : candidate_origin->next;
|
||||
const Order *o = (candidate_origin->next == nullptr) ? least_order->v->GetFirstOrder() : candidate_origin->next;
|
||||
bool found_collision = false;
|
||||
|
||||
/* Check if the candidate origin's destination appears again before the original order or the station does. */
|
||||
@@ -647,7 +647,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
break;
|
||||
}
|
||||
|
||||
o = (o->next == NULL) ? least_order->v->GetFirstOrder() : o->next;
|
||||
o = (o->next == nullptr) ? least_order->v->GetFirstOrder() : o->next;
|
||||
}
|
||||
|
||||
/* If it doesn't, then we have found the origin. */
|
||||
@@ -657,10 +657,10 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
}
|
||||
}
|
||||
|
||||
candidate_origin = (candidate_origin->next == NULL) ? least_order->v->GetFirstOrder() : candidate_origin->next;
|
||||
candidate_origin = (candidate_origin->next == nullptr) ? least_order->v->GetFirstOrder() : candidate_origin->next;
|
||||
}
|
||||
|
||||
order = (candidate_origin->next == NULL) ? least_order->v->GetFirstOrder() : candidate_origin->next;
|
||||
order = (candidate_origin->next == nullptr) ? least_order->v->GetFirstOrder() : candidate_origin->next;
|
||||
|
||||
while (order != least_order->order) {
|
||||
if (order->GetType() == OT_GOTO_STATION &&
|
||||
@@ -669,7 +669,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
d->calling_at.push_back(CallAt((StationID)order->GetDestination()));
|
||||
}
|
||||
|
||||
order = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||
order = (order->next == nullptr) ? least_order->v->GetFirstOrder() : order->next;
|
||||
}
|
||||
|
||||
d->terminus = CallAt((StationID)candidate_origin->GetDestination());
|
||||
@@ -699,7 +699,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
/* We do this in a similar way to finding the first suitable order for the vehicle. */
|
||||
|
||||
/* Go to the next order so we don't add the current order again. */
|
||||
order = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||
order = (order->next == nullptr) ? least_order->v->GetFirstOrder() : order->next;
|
||||
if (VehicleSetNextDepartureTime(&least_order->expected_date, &least_order->scheduled_waiting_time, date_only_scaled, least_order->v, order, false, schdispatch_last_planned_dispatch)) {
|
||||
least_order->lateness = 0;
|
||||
}
|
||||
@@ -718,7 +718,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
case 1: {
|
||||
/* Take the branch */
|
||||
order = least_order->v->GetOrder(order->GetConditionSkipToOrder());
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -730,7 +730,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
}
|
||||
case 2: {
|
||||
/* Do not take the branch */
|
||||
order = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||
order = (order->next == nullptr) ? least_order->v->GetFirstOrder() : order->next;
|
||||
if (VehicleSetNextDepartureTime(&least_order->expected_date, &least_order->scheduled_waiting_time, date_only_scaled, least_order->v, order, false, schdispatch_last_planned_dispatch)) {
|
||||
least_order->lateness = 0;
|
||||
}
|
||||
@@ -741,7 +741,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
|
||||
/* Skip it if it's an automatic order. */
|
||||
if (order->IsType(OT_IMPLICIT)) {
|
||||
order = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||
order = (order->next == nullptr) ? least_order->v->GetFirstOrder() : order->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -764,7 +764,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
break;
|
||||
}
|
||||
|
||||
order = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||
order = (order->next == nullptr) ? least_order->v->GetFirstOrder() : order->next;
|
||||
if (VehicleSetNextDepartureTime(&least_order->expected_date, &least_order->scheduled_waiting_time, date_only_scaled, least_order->v, order, false, schdispatch_last_planned_dispatch)) {
|
||||
least_order->lateness = 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user