mirror of https://github.com/OpenTTD/OpenTTD
(svn r8182) -Backport from trunk (r8137, r8147, r8157):
- (FS#551) roadstop->num_vehicles was wrong for old savegames loaded for MP (r8137) - v->leave_depot_instantly was not always reset correctly (r8147) - moving cargo during auto replaces did not update the cached vehicle weight for trains properly (r8157) *NOTE* This fixes several desync issues. Big props to Rubidium for finding, debugging and fixing them!release/0.5
parent
a74b15af79
commit
6c3b245d88
|
@ -1462,6 +1462,11 @@ bool AfterLoadGame(void)
|
||||||
v->u.road.slot_age = 0;
|
v->u.road.slot_age = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Vehicle *v;
|
||||||
|
FOR_ALL_VEHICLES(v) {
|
||||||
|
if (v->type == VEH_Road && v->u.road.slot != NULL) v->u.road.slot->num_vehicles++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CheckSavegameVersion(26)) {
|
if (CheckSavegameVersion(26)) {
|
||||||
|
|
|
@ -3133,7 +3133,6 @@ static void Save_ROADSTOP(void)
|
||||||
static void Load_ROADSTOP(void)
|
static void Load_ROADSTOP(void)
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
Vehicle *v;
|
|
||||||
|
|
||||||
while ((index = SlIterateArray()) != -1) {
|
while ((index = SlIterateArray()) != -1) {
|
||||||
RoadStop *rs;
|
RoadStop *rs;
|
||||||
|
@ -3144,10 +3143,6 @@ static void Load_ROADSTOP(void)
|
||||||
rs = GetRoadStop(index);
|
rs = GetRoadStop(index);
|
||||||
SlObject(rs, _roadstop_desc);
|
SlObject(rs, _roadstop_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
FOR_ALL_VEHICLES(v) {
|
|
||||||
if (v->type == VEH_Road && v->u.road.slot != NULL) v->u.road.slot->num_vehicles++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ChunkHandler _station_chunk_handlers[] = {
|
const ChunkHandler _station_chunk_handlers[] = {
|
||||||
|
|
20
vehicle.c
20
vehicle.c
|
@ -1903,6 +1903,14 @@ static void MoveVehicleCargo(Vehicle *dest, Vehicle *source)
|
||||||
} while (source->cargo_count > 0 && (dest = dest->next) != NULL);
|
} while (source->cargo_count > 0 && (dest = dest->next) != NULL);
|
||||||
dest = v;
|
dest = v;
|
||||||
} while ((source = source->next) != NULL);
|
} while ((source = source->next) != NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The of the train will be incorrect at this moment. This is due
|
||||||
|
* to the fact that removing the old wagon updates the weight of
|
||||||
|
* the complete train, which is without the weight of cargo we just
|
||||||
|
* moved back into some (of the) new wagon(s).
|
||||||
|
*/
|
||||||
|
if (dest->type == VEH_Train) TrainConsistChanged(dest->first);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool VerifyAutoreplaceRefitForOrders(const Vehicle *v, const EngineID engine_type)
|
static bool VerifyAutoreplaceRefitForOrders(const Vehicle *v, const EngineID engine_type)
|
||||||
|
@ -2140,7 +2148,7 @@ static int32 MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs)
|
||||||
const Player *p = GetPlayer(v->owner);
|
const Player *p = GetPlayer(v->owner);
|
||||||
byte flags = 0;
|
byte flags = 0;
|
||||||
int32 cost, temp_cost = 0;
|
int32 cost, temp_cost = 0;
|
||||||
bool stopped = false;
|
bool stopped;
|
||||||
|
|
||||||
/* Remember the length in case we need to trim train later on
|
/* Remember the length in case we need to trim train later on
|
||||||
* If it's not a train, the value is unused
|
* If it's not a train, the value is unused
|
||||||
|
@ -2158,11 +2166,11 @@ static int32 MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs)
|
||||||
|
|
||||||
assert(v->vehstatus & VS_STOPPED); // the vehicle should have been stopped in VehicleEnteredDepotThisTick() if needed
|
assert(v->vehstatus & VS_STOPPED); // the vehicle should have been stopped in VehicleEnteredDepotThisTick() if needed
|
||||||
|
|
||||||
if (v->leave_depot_instantly) {
|
/* Remember the flag v->leave_depot_instantly because if we replace the vehicle, the vehicle holding this flag will be sold
|
||||||
// we stopped the vehicle to do this, so we have to remember to start it again when we are done
|
* If it is set, then we only stopped the vehicle to replace it (if needed) and we will need to start it again.
|
||||||
// we need to store this info as the engine might be replaced and lose this info
|
* We also need to reset the flag since it should remain false except from when the vehicle enters a depot until autoreplace is handled in the same tick */
|
||||||
stopped = true;
|
stopped = v->leave_depot_instantly;
|
||||||
}
|
v->leave_depot_instantly = false;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
cost = 0;
|
cost = 0;
|
||||||
|
|
Loading…
Reference in New Issue