feat: enroute groups

This commit is contained in:
Ilia Denisov
2026-01-16 22:20:27 +02:00
parent 16aba8435d
commit 741a5f726b
8 changed files with 299 additions and 9 deletions
+5 -1
View File
@@ -504,6 +504,10 @@ func (c *Cache) breakGroupSafe(ri int, groupIndex uint, newGroupShips uint) (int
if c.ShipGroup(sgi).Number < newGroupShips {
return -1, e.NewBreakGroupIllegalNumberError("group #%d ships: %d -> %d", c.ShipGroup(sgi).Index, c.ShipGroup(sgi).Number, newGroupShips)
}
return c.breakGroupUnsafe(ri, sgi, newGroupShips), nil
}
func (c *Cache) breakGroupUnsafe(ri, sgi int, newGroupShips uint) int {
newGroup := *c.ShipGroup(sgi)
if c.ShipGroup(sgi).CargoType != nil {
newGroup.Load = c.ShipGroup(sgi).Load / float64(c.ShipGroup(sgi).Number) * float64(newGroupShips)
@@ -511,7 +515,7 @@ func (c *Cache) breakGroupSafe(ri int, groupIndex uint, newGroupShips uint) (int
newGroup.Number = newGroupShips
c.ShipGroupShipsNumber(sgi, c.ShipGroup(sgi).Number-newGroup.Number)
newGroup.FleetID = nil
return c.appendShipGroup(ri, &newGroup), nil
return c.appendShipGroup(ri, &newGroup)
}
// Internal funcs