feat: move func to calc package
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
"math/rand/v2"
|
||||
"slices"
|
||||
|
||||
"galaxy/util"
|
||||
"galaxy/calc"
|
||||
|
||||
e "galaxy/error"
|
||||
|
||||
@@ -28,7 +28,7 @@ func (c *Cache) PlanetRouteSet(ri int, rt game.RouteType, origin, destination ui
|
||||
if !ok {
|
||||
return e.NewEntityNotExistsError("destination planet #%d", destination)
|
||||
}
|
||||
rangeToDestination := util.ShortDistance(c.g.Map.Width, c.g.Map.Height, p1.X.F(), p1.Y.F(), p2.X.F(), p2.Y.F())
|
||||
rangeToDestination := calc.ShortDistance(c.g.Map.Width, c.g.Map.Height, p1.X.F(), p1.Y.F(), p2.X.F(), p2.Y.F())
|
||||
if rangeToDestination > c.g.Race[ri].FlightDistance() {
|
||||
return e.NewSendUnreachableDestinationError("range=%.03f max=%.03f", rangeToDestination, c.g.Race[ri].FlightDistance())
|
||||
}
|
||||
@@ -194,7 +194,7 @@ func (c *Cache) RemoveUnreachableRoutes() {
|
||||
ri := c.RaceIndex(*p1.Owner)
|
||||
for rt, destination := range p1.Route {
|
||||
p2 := c.MustPlanet(destination)
|
||||
rangeToDestination := util.ShortDistance(c.g.Map.Width, c.g.Map.Height, p1.X.F(), p1.Y.F(), p2.X.F(), p2.Y.F())
|
||||
rangeToDestination := calc.ShortDistance(c.g.Map.Width, c.g.Map.Height, p1.X.F(), p1.Y.F(), p2.X.F(), p2.Y.F())
|
||||
if rangeToDestination > c.g.Race[ri].FlightDistance() {
|
||||
delete(p1.Route, rt)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user