mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r23067) -Fix [FS#4812]: updating the group statistics got more strict checks, so there was some trouble moving a vehicles and groups from one company to another
This commit is contained in:
parent
a561dadb49
commit
c6b2145da6
|
@ -389,11 +389,6 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
|
|||
}
|
||||
|
||||
{
|
||||
FreeUnitIDGenerator unitidgen[] = {
|
||||
FreeUnitIDGenerator(VEH_TRAIN, new_owner), FreeUnitIDGenerator(VEH_ROAD, new_owner),
|
||||
FreeUnitIDGenerator(VEH_SHIP, new_owner), FreeUnitIDGenerator(VEH_AIRCRAFT, new_owner)
|
||||
};
|
||||
|
||||
Vehicle *v;
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
if (v->owner == old_owner && IsCompanyBuildableVehicleType(v->type)) {
|
||||
|
@ -402,23 +397,50 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
|
|||
} else {
|
||||
if (v->IsEngineCountable()) GroupStatistics::CountEngine(v, -1);
|
||||
if (v->IsPrimaryVehicle()) GroupStatistics::CountVehicle(v, -1);
|
||||
|
||||
v->owner = new_owner;
|
||||
v->colourmap = PAL_NONE;
|
||||
|
||||
if (v->IsEngineCountable()) {
|
||||
GroupStatistics::CountEngine(v, 1);
|
||||
}
|
||||
if (v->IsPrimaryVehicle()) {
|
||||
GroupStatistics::CountVehicle(v, 1);
|
||||
v->unitnumber = unitidgen[v->type].NextID();
|
||||
}
|
||||
|
||||
/* Invalidate the vehicle's cargo payment "owner cache". */
|
||||
if (v->cargo_payment != NULL) v->cargo_payment->owner = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* In all cases clear replace engine rules.
|
||||
* Even if it was copied, it could interfere with new owner's rules */
|
||||
RemoveAllEngineReplacementForCompany(Company::Get(old_owner));
|
||||
|
||||
if (new_owner == INVALID_OWNER) {
|
||||
RemoveAllGroupsForCompany(old_owner);
|
||||
} else {
|
||||
Group *g;
|
||||
FOR_ALL_GROUPS(g) {
|
||||
if (g->owner == old_owner) g->owner = new_owner;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
FreeUnitIDGenerator unitidgen[] = {
|
||||
FreeUnitIDGenerator(VEH_TRAIN, new_owner), FreeUnitIDGenerator(VEH_ROAD, new_owner),
|
||||
FreeUnitIDGenerator(VEH_SHIP, new_owner), FreeUnitIDGenerator(VEH_AIRCRAFT, new_owner)
|
||||
};
|
||||
|
||||
Vehicle *v;
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
if (v->owner == old_owner && IsCompanyBuildableVehicleType(v->type)) {
|
||||
assert(new_owner != INVALID_OWNER);
|
||||
|
||||
v->owner = new_owner;
|
||||
v->colourmap = PAL_NONE;
|
||||
|
||||
if (v->IsEngineCountable()) {
|
||||
GroupStatistics::CountEngine(v, 1);
|
||||
}
|
||||
if (v->IsPrimaryVehicle()) {
|
||||
GroupStatistics::CountVehicle(v, 1);
|
||||
v->unitnumber = unitidgen[v->type].NextID();
|
||||
}
|
||||
|
||||
/* Invalidate the vehicle's cargo payment "owner cache". */
|
||||
if (v->cargo_payment != NULL) v->cargo_payment->owner = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (new_owner != INVALID_OWNER) GroupStatistics::UpdateAutoreplace(new_owner);
|
||||
}
|
||||
|
@ -472,19 +494,6 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
|
|||
}
|
||||
}
|
||||
|
||||
/* In all cases clear replace engine rules.
|
||||
* Even if it was copied, it could interfere with new owner's rules */
|
||||
RemoveAllEngineReplacementForCompany(Company::Get(old_owner));
|
||||
|
||||
if (new_owner == INVALID_OWNER) {
|
||||
RemoveAllGroupsForCompany(old_owner);
|
||||
} else {
|
||||
Group *g;
|
||||
FOR_ALL_GROUPS(g) {
|
||||
if (g->owner == old_owner) g->owner = new_owner;
|
||||
}
|
||||
}
|
||||
|
||||
Sign *si;
|
||||
FOR_ALL_SIGNS(si) {
|
||||
if (si->owner == old_owner) si->owner = new_owner == INVALID_OWNER ? OWNER_NONE : new_owner;
|
||||
|
|
Loading…
Reference in New Issue