summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-10-18 17:52:44 +0000
committerrubidium <rubidium@openttd.org>2009-10-18 17:52:44 +0000
commitf11cebfe9b09bf5cf815d37ca6a19212755251ab (patch)
tree664ac4f2e4f2d026dd8612509cdc545e1a0f9e1b /src/saveload
parent4ad30fecdee33708bc95a8e790b4c85814c36317 (diff)
downloadopenttd-f11cebfe9b09bf5cf815d37ca6a19212755251ab.tar.xz
(svn r17807) -Codechange: move all 'updates' just after the 'load' constructor of CargoPackets to the constructor call itself
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/oldloader_sl.cpp14
-rw-r--r--src/saveload/station_sl.cpp9
-rw-r--r--src/saveload/vehicle_sl.cpp5
3 files changed, 9 insertions, 19 deletions
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp
index 900cbd4ab..809d88ed9 100644
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -698,9 +698,7 @@ static bool LoadOldGood(LoadgameState *ls, int num)
SB(ge->acceptance_pickup, GoodsEntry::ACCEPTANCE, 1, HasBit(_waiting_acceptance, 15));
SB(ge->acceptance_pickup, GoodsEntry::PICKUP, 1, _cargo_source != 0xFF);
if (GB(_waiting_acceptance, 0, 12) != 0) {
- CargoPacket *cp = new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_days);
- cp->source = (_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source;
- ge->cargo.Append(cp);
+ ge->cargo.Append(new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_days, (_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source, 0, 0));
}
return true;
@@ -1330,13 +1328,9 @@ bool LoadOldVehicle(LoadgameState *ls, int num)
v->next = (Vehicle *)(size_t)_old_next_ptr;
if (_cargo_count != 0) {
- CargoPacket *cp = new CargoPacket(_cargo_count, _cargo_days);
- cp->source = (_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source;
- cp->source_xy = (cp->source != INVALID_STATION) ? Station::Get(cp->source)->xy : 0;
- cp->loaded_at_xy = cp->source_xy;
- cp->source_type = ST_INDUSTRY;
- cp->source_id = INVALID_SOURCE;
- v->cargo.Append(cp);
+ StationID source = (_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source;
+ TileIndex source_xy = (source != INVALID_STATION) ? Station::Get(source)->xy : 0;
+ v->cargo.Append(new CargoPacket(_cargo_count, _cargo_days, source, source_xy, source_xy));
}
}
diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp
index cce636046..b1cb2bed5 100644
--- a/src/saveload/station_sl.cpp
+++ b/src/saveload/station_sl.cpp
@@ -243,13 +243,12 @@ static void Load_STNS()
if (CheckSavegameVersion(68)) {
SB(ge->acceptance_pickup, GoodsEntry::ACCEPTANCE, 1, HasBit(_waiting_acceptance, 15));
if (GB(_waiting_acceptance, 0, 12) != 0) {
- /* Don't construct the packet with station here, because that'll fail with old savegames */
- CargoPacket *cp = new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_days, _cargo_feeder_share);
/* In old versions, enroute_from used 0xFF as INVALID_STATION */
- cp->source = (CheckSavegameVersion(7) && _cargo_source == 0xFF) ? INVALID_STATION : _cargo_source;
- cp->source_xy = _cargo_source_xy;
+ StationID source = (CheckSavegameVersion(7) && _cargo_source == 0xFF) ? INVALID_STATION : _cargo_source;
+
+ /* Don't construct the packet with station here, because that'll fail with old savegames */
+ ge->cargo.Append(new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_days, source, _cargo_source_xy, _cargo_source_xy, _cargo_feeder_share));
SB(ge->acceptance_pickup, GoodsEntry::PICKUP, 1, 1);
- ge->cargo.Append(cp);
}
}
}
diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp
index f49d4c385..ccb627ebb 100644
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -719,10 +719,7 @@ void Load_VEHS()
if (_cargo_count != 0 && IsCompanyBuildableVehicleType(v)) {
/* Don't construct the packet with station here, because that'll fail with old savegames */
- CargoPacket *cp = new CargoPacket(_cargo_count, _cargo_days, _cargo_feeder_share);
- cp->source = _cargo_source;
- cp->source_xy = _cargo_source_xy;
- cp->loaded_at_xy = _cargo_loaded_at_xy;
+ CargoPacket *cp = new CargoPacket(_cargo_count, _cargo_days, _cargo_source, _cargo_source_xy, _cargo_loaded_at_xy, _cargo_feeder_share);
v->cargo.Append(cp);
}