1
0
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:
2024-05-07 20:01:28 +01:00
committed by GitHub
parent 8710e9b8c8
commit 9008d793ab
10 changed files with 30 additions and 9 deletions

View File

@@ -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;