diff -u b/src/cargopacket.cpp b/src/cargopacket.cpp --- b/src/cargopacket.cpp +++ b/src/cargopacket.cpp @@ -447,7 +447,7 @@ max_move = 0; } - if (max_move > 0 && mta == MTA_CARGO_LOAD && cur_order != INVALID_ORDER) { + if (max_move > 0 && mta == MTA_CARGO_LOAD && cur_order != INVALID_ORDER && Station::Get(st)->goods[cid].cargo.CountForNextHop(INVALID_ORDER) > 0) { /* We loaded all packets for the next hop, now load all packets without destination. */ cur_order = INVALID_ORDER; goto restart; @@ -595,7 +595,7 @@ */ void StationCargoList::UpdateCargoNextHop(Station *st, CargoID cid) { - int count = 0; + uint count = 0; StationCargoList::Iterator iter; for (iter = this->packets.begin(); count < this->next_start + _settings_game.economy.cargodest.route_recalc_chunk && iter != this->packets.end(); count++) { if (count < this->next_start) continue; diff -u b/src/cargopacket.h b/src/cargopacket.h --- b/src/cargopacket.h +++ b/src/cargopacket.h @@ -396,7 +396,7 @@ typedef CargoList Parent; OrderMap order_cache; - int32 next_start; ///< Packet number to start the next hop update loop from. + uint32 next_start; ///< Packet number to start the next hop update loop from. void AddToCache(const CargoPacket *cp); void RemoveFromCache(const CargoPacket *cp); diff -u b/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp --- b/src/saveload/station_sl.cpp +++ b/src/saveload/station_sl.cpp @@ -260,7 +260,7 @@ SLE_CONDVAR(GoodsEntry, amount_fract, SLE_UINT8, 150, SL_MAX_VERSION), SLE_CONDVAR(GoodsEntry, cargo_counter, SLE_UINT16, 161, SL_MAX_VERSION), SLE_CONDLST(GoodsEntry, cargo.packets, REF_CARGO_PACKET, 68, SL_MAX_VERSION), - SLE_CONDVAR(GoodsEntry, cargo.next_start, SLE_INT32, 161, SL_MAX_VERSION), + SLE_CONDVAR(GoodsEntry, cargo.next_start, SLE_UINT32, 161, SL_MAX_VERSION), SLE_CONDLST(GoodsEntry, routes, REF_ROUTE_LINK, 161, SL_MAX_VERSION), SLE_END() diff -u b/src/smallmap_gui.cpp b/src/smallmap_gui.cpp --- b/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -70,25 +70,25 @@ static const uint8 PC_WATER = 0xCA; ///< Dark blue palette colour for water. /** Macro for ordinary entry of LegendAndColour */ -#define MK(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, false} +#define MK(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, INVALID_CARGO, true, false, false} /** Macro for a height legend entry with configurable colour. */ -#define MC(height) {0, STR_TINY_BLACK_HEIGHT, INVALID_INDUSTRYTYPE, height, INVALID_COMPANY, true, false, false} +#define MC(height) {0, STR_TINY_BLACK_HEIGHT, INVALID_INDUSTRYTYPE, height, INVALID_COMPANY, INVALID_CARGO, true, false, false} /** Macro for non-company owned property entry of LegendAndColour */ -#define MO(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, false} +#define MO(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, INVALID_CARGO, true, false, false} /** Macro used for forcing a rebuild of the owner legend the first time it is used. */ -#define MOEND() {0, 0, INVALID_INDUSTRYTYPE, 0, OWNER_NONE, true, true, false} +#define MOEND() {0, 0, INVALID_INDUSTRYTYPE, 0, OWNER_NONE, INVALID_CARGO, true, true, false} /** Macro for end of list marker in arrays of LegendAndColour */ -#define MKEND() {0, STR_NULL, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, true, false} +#define MKEND() {0, STR_NULL, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, INVALID_CARGO, true, true, false} /** * Macro for break marker in arrays of LegendAndColour. * It will have valid data, though */ -#define MS(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, true} +#define MS(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, INVALID_CARGO, true, false, true} /** Structure for holding relevant data for legends in small map */ struct LegendAndColour { @@ -1030,7 +1030,7 @@ dest_pt.y -= d/2; /* Draw black border and company-colour inset. */ - byte colour = _colour_gradient[Company::IsValidID(st->owner) ? Company::Get(st->owner)->colour : COLOUR_GREY][6]; + byte colour = _colour_gradient[Company::IsValidID(st->owner) ? Company::Get(st->owner)->colour : (byte)COLOUR_GREY][6]; GfxFillRect(dest_pt.x - 1, dest_pt.y - 1, dest_pt.x + d + 1, dest_pt.y + d + 1, PC_BLACK); // Draw black frame GfxFillRect(dest_pt.x, dest_pt.y, dest_pt.x + d, dest_pt.y + d, colour); // Draw colour insert } diff -u b/src/station_gui.cpp b/src/station_gui.cpp --- b/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -1488,7 +1488,7 @@ if (entry.start_row == row) { if (_ctrl_pressed) { /* Scroll viewport to destination tile .*/ - TileIndex dest_tile; + TileIndex dest_tile = 0; switch (entry.type) { case CargoDestEntry::FINAL_DEST: switch (entry.data.type) { @@ -1501,6 +1501,9 @@ case ST_HEADQUARTERS: dest_tile = Company::Get(entry.data.css)->location_of_HQ; break; + + default: + NOT_REACHED(); } break; @@ -1508,6 +1511,9 @@ case CargoDestEntry::TRANSFER_HOP: dest_tile = Station::Get(entry.data.station)->xy; break; + + default: + NOT_REACHED(); } ScrollMainWindowToTile(dest_tile); } else if (!entry.children.empty()) { diff -u b/src/train_cmd.cpp b/src/train_cmd.cpp --- b/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1284,6 +1284,9 @@ NormaliseTrainHead(src_head); NormaliseTrainHead(dst_head); + /* Pre-fill route links after adding a vehicle. */ + if (dst_head != NULL && dst_head->IsFrontEngine()) PrefillRouteLinks(dst_head); + /* We are undoubtedly changing something in the depot and train list. */ InvalidateWindowData(WC_VEHICLE_DEPOT, src->tile); InvalidateWindowClassesData(WC_TRAINS_LIST, 0); diff -u b/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp --- b/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -391,7 +391,7 @@ default: NOT_REACHED(); } - PrefillRouteLinks(v); + if (front->IsPrimaryVehicle()) PrefillRouteLinks(front); InvalidateWindowData(WC_VEHICLE_DETAILS, front->index); SetWindowDirty(WC_VEHICLE_DEPOT, front->tile);