|
|
|
@ -350,8 +350,9 @@ std::tuple<CommandCost, GroupID> CmdCreateGroup(DoCommandFlag flags, VehicleType
|
|
|
|
|
g->vehicle_type = vt;
|
|
|
|
|
g->parent = INVALID_GROUP;
|
|
|
|
|
|
|
|
|
|
Company *c = Company::Get(g->owner);
|
|
|
|
|
g->number = c->freegroups.UseID(c->freegroups.NextID());
|
|
|
|
|
if (pg == nullptr) {
|
|
|
|
|
const Company *c = Company::Get(_current_company);
|
|
|
|
|
g->livery.colour1 = c->livery[LS_DEFAULT].colour1;
|
|
|
|
|
g->livery.colour2 = c->livery[LS_DEFAULT].colour2;
|
|
|
|
|
if (c->settings.renew_keep_length) SetBit(g->flags, GroupFlags::GF_REPLACE_WAGON_REMOVAL);
|
|
|
|
@ -397,14 +398,15 @@ CommandCost CmdDeleteGroup(DoCommandFlag flags, GroupID group_id)
|
|
|
|
|
/* Update backupped orders if needed */
|
|
|
|
|
OrderBackup::ClearGroup(g->index);
|
|
|
|
|
|
|
|
|
|
/* If we set an autoreplace for the group we delete, remove it. */
|
|
|
|
|
if (_current_company < MAX_COMPANIES) {
|
|
|
|
|
Company *c;
|
|
|
|
|
if (g->owner < MAX_COMPANIES) {
|
|
|
|
|
Company *c = Company::Get(g->owner);
|
|
|
|
|
|
|
|
|
|
c = Company::Get(_current_company);
|
|
|
|
|
/* If we set an autoreplace for the group we delete, remove it. */
|
|
|
|
|
for (EngineRenew *er : EngineRenew::Iterate()) {
|
|
|
|
|
if (er->group_id == g->index) RemoveEngineReplacementForCompany(c, er->from, g->index, flags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
c->freegroups.ReleaseID(g->number);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VehicleType vt = g->vehicle_type;
|
|
|
|
|