mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-16 02:59:10 +00:00
Change: Use per-company group numbers. (#12297)
This is used by the default group name, replacing the use of group index.
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user