Add some additional logging to requests and world resizes
This commit is contained in:
parent
47df02ec7e
commit
d9e97ea468
2 changed files with 13 additions and 2 deletions
|
@ -3,6 +3,7 @@ package internal
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/mdiluz/rove/pkg/game"
|
"github.com/mdiluz/rove/pkg/game"
|
||||||
"github.com/mdiluz/rove/pkg/rove"
|
"github.com/mdiluz/rove/pkg/rove"
|
||||||
|
@ -18,8 +19,6 @@ func (s *Server) ServerStatus(context.Context, *rove.ServerStatusRequest) (*rove
|
||||||
CurrentTick: int32(s.world.CurrentTicks),
|
CurrentTick: int32(s.world.CurrentTicks),
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Verify the accountant is up and ready too
|
|
||||||
|
|
||||||
// If there's a schedule, respond with it
|
// If there's a schedule, respond with it
|
||||||
if len(s.schedule.Entries()) > 0 {
|
if len(s.schedule.Entries()) > 0 {
|
||||||
response.NextTick = s.schedule.Entries()[0].Next.Format("15:04:05")
|
response.NextTick = s.schedule.Entries()[0].Next.Format("15:04:05")
|
||||||
|
@ -30,6 +29,8 @@ func (s *Server) ServerStatus(context.Context, *rove.ServerStatusRequest) (*rove
|
||||||
|
|
||||||
// Register registers a new account for a gRPC request
|
// Register registers a new account for a gRPC request
|
||||||
func (s *Server) Register(ctx context.Context, req *rove.RegisterRequest) (*rove.RegisterResponse, error) {
|
func (s *Server) Register(ctx context.Context, req *rove.RegisterRequest) (*rove.RegisterResponse, error) {
|
||||||
|
log.Printf("Handling register request: %s\n", req.Name)
|
||||||
|
|
||||||
if len(req.Name) == 0 {
|
if len(req.Name) == 0 {
|
||||||
return nil, fmt.Errorf("empty account name")
|
return nil, fmt.Errorf("empty account name")
|
||||||
}
|
}
|
||||||
|
@ -55,6 +56,8 @@ func (s *Server) Register(ctx context.Context, req *rove.RegisterRequest) (*rove
|
||||||
|
|
||||||
// Status returns rover information for a gRPC request
|
// Status returns rover information for a gRPC request
|
||||||
func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (response *rove.StatusResponse, err error) {
|
func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (response *rove.StatusResponse, err error) {
|
||||||
|
log.Printf("Handling status request: %s\n", req.Account.Name)
|
||||||
|
|
||||||
if valid, err := s.accountant.VerifySecret(req.Account.Name, req.Account.Secret); err != nil {
|
if valid, err := s.accountant.VerifySecret(req.Account.Name, req.Account.Secret); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
||||||
|
@ -110,6 +113,8 @@ func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (response
|
||||||
|
|
||||||
// Radar returns the radar information for a rover
|
// Radar returns the radar information for a rover
|
||||||
func (s *Server) Radar(ctx context.Context, req *rove.RadarRequest) (*rove.RadarResponse, error) {
|
func (s *Server) Radar(ctx context.Context, req *rove.RadarRequest) (*rove.RadarResponse, error) {
|
||||||
|
log.Printf("Handling radar request: %s\n", req.Account.Name)
|
||||||
|
|
||||||
if valid, err := s.accountant.VerifySecret(req.Account.Name, req.Account.Secret); err != nil {
|
if valid, err := s.accountant.VerifySecret(req.Account.Name, req.Account.Secret); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
||||||
|
@ -140,6 +145,8 @@ func (s *Server) Radar(ctx context.Context, req *rove.RadarRequest) (*rove.Radar
|
||||||
|
|
||||||
// Command issues commands to the world based on a gRPC request
|
// Command issues commands to the world based on a gRPC request
|
||||||
func (s *Server) Command(ctx context.Context, req *rove.CommandRequest) (*rove.CommandResponse, error) {
|
func (s *Server) Command(ctx context.Context, req *rove.CommandRequest) (*rove.CommandResponse, error) {
|
||||||
|
log.Printf("Handling command request: %s and %+v\n", req.Account.Name, req.Commands)
|
||||||
|
|
||||||
if valid, err := s.accountant.VerifySecret(req.Account.Name, req.Account.Secret); err != nil {
|
if valid, err := s.accountant.VerifySecret(req.Account.Name, req.Account.Secret); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package atlas
|
package atlas
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
|
||||||
"github.com/mdiluz/rove/pkg/maths"
|
"github.com/mdiluz/rove/pkg/maths"
|
||||||
|
@ -218,6 +219,9 @@ func (a *Atlas) worldSpaceToChunkWithGrow(v vector.Vector) int {
|
||||||
Chunks: make([]Chunk, size.X*size.Y),
|
Chunks: make([]Chunk, size.X*size.Y),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log that we're resizing
|
||||||
|
log.Printf("Re-allocating world, old: %+v,%+v new: %+v,%+v\n", a.LowerBound, a.UpperBound, newAtlas.LowerBound, newAtlas.UpperBound)
|
||||||
|
|
||||||
// Copy all old chunks into the new atlas
|
// Copy all old chunks into the new atlas
|
||||||
for chunk, chunkData := range a.Chunks {
|
for chunk, chunkData := range a.Chunks {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue