File diff r20251:8c2b509af318 → r20252:76a6f1c78ce7
src/vehicle_cmd.cpp
Show inline comments
 
@@ -397,20 +397,16 @@ static CommandCost RefitVehicle(Vehicle 
 
		/* Store the result */
 
		for (RefitResult *result = refit_result.Begin(); result != refit_result.End(); result++) {
 
			Vehicle *u = result->v;
 
			if (u->cargo_type != new_cid) {
 
				u->cargo.Truncate(u->cargo_cap);
 
			} else if (u->cargo_cap > result->capacity) {
 
				u->cargo.Truncate(u->cargo_cap - result->capacity);
 
			}
 
			u->refit_cap = (u->cargo_type == new_cid) ? min(result->capacity, u->refit_cap) : 0;
 
			if (u->cargo.TotalCount() > u->refit_cap) u->cargo.Truncate(u->cargo.TotalCount() - u->refit_cap);
 
			u->cargo_type = new_cid;
 
			u->cargo_cap = result->capacity;
 
			u->cargo_subtype = result->subtype;
 
			if (u->type == VEH_AIRCRAFT) {
 
				Vehicle *w = u->Next();
 
				if (w->cargo_cap > result->mail_capacity) {
 
					w->cargo.Truncate(w->cargo_cap - result->mail_capacity);
 
				}
 
				w->refit_cap = min(w->refit_cap, result->mail_capacity);
 
				w->cargo_cap = result->mail_capacity;
 
				if (w->cargo.TotalCount() > w->refit_cap) w->cargo.Truncate(w->cargo.TotalCount() - w->refit_cap);
 
			}
 
		}
 
	}