Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion vehicle/simvehicle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5544,7 +5544,9 @@ bool air_vehicle_t::block_reserver( uint32 start, uint32 end, bool reserve ) con

// un-reserve if not successful
if( !success && reserve ) {
for( uint32 i=start; i<end; i++ ) {
// Use i<=end so that tile 'end' (where reserve() failed) also gets its
// add_convoi_reservation() entry removed via runway_t::unreserve().
for( uint32 i=start; i<=end; i++ ) {
grund_t *gr = welt->lookup(route->at(i));
if (gr) {
runway_t* sch1 = (runway_t *)gr->get_weg(air_wt);
Expand All @@ -5570,6 +5572,22 @@ bool air_vehicle_t::block_reserver( uint32 start, uint32 end, bool reserve ) con
}
}

// When unreserving the takeoff section (end < touchdown), the landing runway
// tiles were never visited by the main loop, so their load-balancing
// reservations added during the original takeoff must be removed here.
if( !reserve && end<touchdown ) {
for( uint32 i=touchdown; i<route->get_count(); i++ ) {
if( grund_t *gr = welt->lookup(route->at(i)) ) {
if( runway_t* sch1 = (runway_t *)gr->get_weg(air_wt) ) {
if( sch1->get_desc()->get_styp()!=type_runway ) {
break;
}
sch1->remove_convoi_reservation( cnv->self );
}
}
}
}

return success;
}

Expand Down Expand Up @@ -5835,6 +5853,15 @@ void air_vehicle_t::set_convoi(convoi_t *c)
}
}
}
// Airborne during final approach: the plane is not on a runway tile so the
// runway-tile guard above does not fire, but the landing runway reservation
// was already acquired at the approach trigger before saving and must be
// restored now. Calling block_reserver twice (when route_index==touchdown-1
// already handled above) is harmless — reserve() is idempotent for the same
// convoy handle.
if( state==landing && route_index<touchdown ) {
block_reserver( touchdown, search_for_stop+1, true );
}
}
}
else {
Expand Down
Loading