refactor: exclude from fleet when break group
This commit is contained in:
@@ -135,7 +135,7 @@ func (c *Cache) ShipGroupJoinFleet(ri int, fleetName string, groupID uuid.UUID)
|
||||
}
|
||||
}
|
||||
|
||||
c.internalShipGroupJoinFleet(sgi, &c.g.Fleets[fi].ID)
|
||||
c.internalShipGroupJoinFleet(sgi, c.g.Fleets[fi].ID)
|
||||
|
||||
if oldFleetID != nil {
|
||||
keepOldFleet := false
|
||||
|
||||
@@ -18,9 +18,9 @@ func (c *Cache) ShipGroup(groupIndex int) *game.ShipGroup {
|
||||
return &c.g.ShipGroups[groupIndex]
|
||||
}
|
||||
|
||||
func (c *Cache) internalShipGroupJoinFleet(groupIndex int, fID *uuid.UUID) {
|
||||
func (c *Cache) internalShipGroupJoinFleet(groupIndex int, fID uuid.UUID) {
|
||||
c.validateShipGroupIndex(groupIndex)
|
||||
c.g.ShipGroups[groupIndex].FleetID = fID
|
||||
c.g.ShipGroups[groupIndex].FleetID = &fID
|
||||
c.invalidateFleetCache()
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ func (c *Cache) shipGroupTransfer(ri, riAccept int, groupID uuid.UUID) (err erro
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Cache) ShipGroupBreak(ri int, groupID, newID uuid.UUID, quantity uint) error {
|
||||
func (c *Cache) ShipGroupBreak(ri int, groupID, newID uuid.UUID, quantity uint) (err error) {
|
||||
c.validateRaceIndex(ri)
|
||||
sgi, ok := c.raceShipGroupIndex(ri, groupID)
|
||||
if !ok {
|
||||
@@ -397,15 +397,14 @@ func (c *Cache) ShipGroupBreak(ri int, groupID, newID uuid.UUID, quantity uint)
|
||||
return e.NewBeakGroupNumberNotEnoughError("%d<%d", c.ShipGroup(sgi).Number, quantity)
|
||||
}
|
||||
|
||||
if quantity == 0 || quantity == c.ShipGroup(sgi).Number {
|
||||
c.internalShipGroupJoinFleet(sgi, nil)
|
||||
} else {
|
||||
// TODO: which group stays in fleet?
|
||||
if _, err := c.breakGroup(ri, groupID, quantity); err != nil {
|
||||
return err
|
||||
if quantity > 0 && quantity < c.ShipGroup(sgi).Number {
|
||||
if sgi, err = c.breakGroup(ri, groupID, quantity); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
c.ShipGroup(sgi).FleetID = nil
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user