Index: vehicle_gui.c =================================================================== --- vehicle_gui.c (revision 5317) +++ vehicle_gui.c (working copy) @@ -1191,3 +1191,32 @@ } } } +StringID VehicleLoadingProgress(const Vehicle *v) +{ + const Vehicle *u; + uint16 cargo_count=0, cargo_cap=0; + + u = v; + + do { + // cycle through all wagons, add currently loaded amount to cargo_count and wagon capacity + // to cargo_cap + cargo_count += u->cargo_count; + cargo_cap += u->cargo_cap; + } while ((u = u->next) != NULL); + + if (cargo_count == 0 && !(v->current_order.flags & OF_FULL_LOAD)) { + // Total cargo = 0 and order for current station is not Full Load means we're unloading + return STR_VEHICLE_UNLOADING; + } else { + if (cargo_count > 0) { + // common notation (cargo_count/cargo_cap)*100 won't work because uint16/uint16 returns a uint16 + // making the display show either 0% or 100% + SetDParam(0, ((cargo_count*100)/cargo_cap)); + } else { + // Can't divide by zero, so display 0% if total capacity if 0. + SetDParam(0, 0); + } + return STR_VEHICLE_LOADING; + } +} Index: vehicle_gui.h =================================================================== --- vehicle_gui.h (revision 5317) +++ vehicle_gui.h (working copy) @@ -61,6 +61,7 @@ void DrawShipPurchaseInfo(int x, int y, EngineID engine_number); void ChangeVehicleViewWindow(const Vehicle *from_v, const Vehicle *to_v); +StringID VehicleLoadingProgress(const Vehicle *v); int ShowAdditionalText(int x, int y, int w, EngineID engine_number); Index: lang/english.txt =================================================================== --- lang/english.txt (revision 5317) +++ lang/english.txt (working copy) @@ -2463,6 +2463,9 @@ STR_882D_VALUE :{LTBLUE}{STRING}{BLACK} Value: {LTBLUE}{CURRENCY} STR_882E :{WHITE}{VEHICLE} STR_882F_LOADING_UNLOADING :{LTBLUE}Loading / Unloading +STR_VEHICLE_LOADING :{LTBLUE}Loading {NUM}% +STR_VEHICLE_UNLOADING :{LTBLUE}Unloading +STR_VEHICLE_DEPARTING :{LTBLUE}Departing STR_TRAIN_MUST_BE_STOPPED :{WHITE}Train must be stopped inside a depot STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT :{WHITE}Can't send train to depot... STR_8831_NO_MORE_SPACE_FOR_ORDERS :{WHITE}No more space for orders Index: aircraft_gui.c =================================================================== --- aircraft_gui.c (revision 5317) +++ aircraft_gui.c (working copy) @@ -530,9 +530,10 @@ str = STR_HEADING_FOR_HANGAR + _patches.vehicle_speed; } break; - case OT_LOADING: - str = STR_882F_LOADING_UNLOADING; + case OT_LOADING: { + str = VehicleLoadingProgress(v); break; + } default: if (v->num_orders == 0) { Index: economy.c =================================================================== --- economy.c (revision 5317) +++ economy.c (working copy) @@ -1466,6 +1466,7 @@ if (result != 0) { InvalidateWindow(WC_VEHICLE_DETAILS, v->index); + InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); if (result & 2) InvalidateWindow(WC_STATION_VIEW, last_visited); Index: roadveh_gui.c =================================================================== --- roadveh_gui.c (revision 5317) +++ roadveh_gui.c (working copy) @@ -343,11 +343,16 @@ str = STR_HEADING_FOR_ROAD_DEPOT + _patches.vehicle_speed; } break; - case OT_LOADING: - case OT_LEAVESTATION: - str = STR_882F_LOADING_UNLOADING; + case OT_LOADING: { + str = VehicleLoadingProgress(v); break; + } + case OT_LEAVESTATION: { + str = STR_VEHICLE_DEPARTING; + break; + } + default: if (v->num_orders == 0) { str = STR_NO_ORDERS + _patches.vehicle_speed; Index: train_gui.c =================================================================== --- train_gui.c (revision 5317) +++ train_gui.c (working copy) @@ -966,11 +966,17 @@ SetDParam(1, v->u.rail.last_speed); } break; - case OT_LOADING: - case OT_LEAVESTATION: - str = STR_882F_LOADING_UNLOADING; + case OT_LOADING: { + str = VehicleLoadingProgress(v); break; + } + case OT_LEAVESTATION: { + str = STR_VEHICLE_DEPARTING; + SetDParam(0, v->current_order.station); + break; + } + case OT_GOTO_WAYPOINT: { SetDParam(0, v->current_order.station); str = STR_HEADING_FOR_WAYPOINT + _patches.vehicle_speed; Index: ship_gui.c =================================================================== --- ship_gui.c (revision 5317) +++ ship_gui.c (working copy) @@ -488,11 +488,16 @@ str = STR_HEADING_FOR_SHIP_DEPOT + _patches.vehicle_speed; } break; - case OT_LOADING: - case OT_LEAVESTATION: - str = STR_882F_LOADING_UNLOADING; + case OT_LOADING: { + str = VehicleLoadingProgress(v); break; + } + case OT_LEAVESTATION: { + str = STR_VEHICLE_DEPARTING; + break; + } + default: if (v->num_orders == 0) { str = STR_NO_ORDERS + _patches.vehicle_speed;