refactor: group uuid instead of index

This commit is contained in:
IliaDenisov
2026-02-10 20:54:43 +03:00
parent 6c8384ce7a
commit 56998d4c2d
26 changed files with 333 additions and 363 deletions
+5 -4
View File
@@ -79,8 +79,8 @@ func (c *Cache) SendRoutedGroups() {
sortGroups := func(g []int) {
// sort groups by largest CargoCapacity
slices.SortFunc(g, func(l, r int) int {
return cmp.Or(cmp.Compare(c.ShipGroup(r).CargoCapacity(c.ShipGroupShipClass(r)),
c.ShipGroup(l).CargoCapacity(c.ShipGroupShipClass(l))),
return cmp.Or(
cmp.Compare(c.ShipGroup(r).CargoCapacity(c.ShipGroupShipClass(r)), c.ShipGroup(l).CargoCapacity(c.ShipGroupShipClass(l))),
cmp.Compare(l, r))
})
@@ -115,7 +115,7 @@ func (c *Cache) SendRoutedGroups() {
ct = game.CargoMaterial
default:
for _, sgi := range groups {
c.LaunchShips(c.ShipGroup(sgi), dest)
c.LaunchShips(sgi, dest)
}
groups = reorderGroups(groups)
continue
@@ -131,6 +131,7 @@ func (c *Cache) SendRoutedGroups() {
toLoad = sgCapacity
} else if maxShips := uint(math.Ceil(toLoad / (sgCapacity / float64(ships)))); maxShips < ships {
newGroupIdx := c.breakGroupUnsafe(c.RaceIndex(sg.OwnerID), sgi, maxShips)
sgi = newGroupIdx
sg = c.ShipGroup(newGroupIdx)
}
// decrease planet resource
@@ -138,7 +139,7 @@ func (c *Cache) SendRoutedGroups() {
// load group
sg.Load = sg.Load.Add(toLoad)
sg.CargoType = &ct
c.LaunchShips(sg, dest)
c.LaunchShips(sgi, dest)
groups = reorderGroups(groups)
}
}