refactor: group uuid instead of index
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user