# HG changeset patch # User peter1138 # Date 1149443356 0 # Node ID 81e7e25e4599ad22729dd4e501b59ac4bf50b5f5 # Parent 634cd5e3580303d84974a600b1e3fe958978eb25 (svn r5104) - When refitting a vehicle to its existing cargo type, don't lose the cargo onboard (useful when adding wagons to a train) diff -r 634cd5e35803 -r 81e7e25e4599 aircraft_cmd.c --- a/aircraft_cmd.c Sun Jun 04 17:38:48 2006 +0000 +++ b/aircraft_cmd.c Sun Jun 04 17:49:16 2006 +0000 @@ -538,7 +538,13 @@ u = v->next; mail = (new_cid != CT_PASSENGERS) ? 0 : avi->mail_capacity; u->cargo_cap = mail; - v->cargo_count = u->cargo_count = 0; + if (v->cargo_type == new_cid) { + v->cargo_count = min(pass, v->cargo_count); + u->cargo_count = min(mail, u->cargo_count); + } else { + v->cargo_count = 0; + u->cargo_count = 0; + } v->cargo_type = new_cid; v->cargo_subtype = new_subtype; InvalidateWindow(WC_VEHICLE_DETAILS, v->index); diff -r 634cd5e35803 -r 81e7e25e4599 ship_cmd.c --- a/ship_cmd.c Sun Jun 04 17:38:48 2006 +0000 +++ b/ship_cmd.c Sun Jun 04 17:49:16 2006 +0000 @@ -1061,7 +1061,7 @@ } if (flags & DC_EXEC) { - v->cargo_count = 0; + v->cargo_count = (v->cargo_type == new_cid) ? min(v->cargo_cap, v->cargo_count) : 0; v->cargo_type = new_cid; v->cargo_subtype = new_subtype; InvalidateWindow(WC_VEHICLE_DETAILS, v->index); diff -r 634cd5e35803 -r 81e7e25e4599 train_cmd.c --- a/train_cmd.c Sun Jun 04 17:38:48 2006 +0000 +++ b/train_cmd.c Sun Jun 04 17:49:16 2006 +0000 @@ -1789,7 +1789,7 @@ if (new_cid != v->cargo_type) cost += _price.build_railvehicle >> 8; num += amount; if (flags & DC_EXEC) { - v->cargo_count = 0; + v->cargo_count = (v->cargo_type == new_cid) ? min(amount, v->cargo_count) : 0; v->cargo_type = new_cid; v->cargo_cap = amount; v->cargo_subtype = new_subtype;