From 5bbb2ff37f50dda3a42bffcf8c08fb37fc14cb61 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 27 Jun 2020 01:41:19 +0100 Subject: [PATCH 001/228] Fix help text for commands --- cmd/rove/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 15014a1..2fc3eab 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -26,7 +26,7 @@ func printUsage() { fmt.Fprintln(os.Stderr, "\nCommands") fmt.Fprintln(os.Stderr, "\tstatus prints the server status") fmt.Fprintln(os.Stderr, "\tregister NAME registers an account and stores it (use with -name)") - fmt.Fprintln(os.Stderr, "\tcommands COMMAND [VAL...] issues move command to rover, see below") + fmt.Fprintln(os.Stderr, "\tcommands COMMAND [VAL...] issue commands to rover, accepts multiple, see below") fmt.Fprintln(os.Stderr, "\tradar gathers radar data for the current rover") fmt.Fprintln(os.Stderr, "\trover gets data for current rover") fmt.Fprintln(os.Stderr, "\tconfig [HOST] outputs the local config info, optionally sets host") From 5b5f80be7d6f631d3b282cc883609b6f306f7871 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 27 Jun 2020 02:02:18 +0100 Subject: [PATCH 002/228] Clean up logging a little --- cmd/rove-accountant/main.go | 3 +-- pkg/game/world.go | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/cmd/rove-accountant/main.go b/cmd/rove-accountant/main.go index 31f2914..e774797 100644 --- a/cmd/rove-accountant/main.go +++ b/cmd/rove-accountant/main.go @@ -68,8 +68,7 @@ func (a *accountantServer) GetValue(_ context.Context, in *accounts.DataKey) (*a a.sync.RLock() defer a.sync.RUnlock() - // Try and fetch the rover - log.Printf("Getting value for account %s: %s\n", in.Account, in.Key) + // Try and fetch the value data, err := a.accountant.GetValue(in.Account, in.Key) if err != nil { log.Printf("Error: %s\n", err) diff --git a/pkg/game/world.go b/pkg/game/world.go index 8491a7d..9048900 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -430,16 +430,14 @@ func (w *World) ExecuteCommandQueues() { // ExecuteCommand will execute a single command func (w *World) ExecuteCommand(c *Command, rover string) (err error) { - log.Printf("Executing command: %+v\n", *c) + log.Printf("Executing command: %+v for %s\n", *c, rover) switch c.Command { case CommandMove: if dir, err := bearing.FromString(c.Bearing); err != nil { return err - } else if _, err := w.MoveRover(rover, dir); err != nil { return err - } case CommandStash: From 6ba6584ae144497d7621912254d9847ab1623443 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 27 Jun 2020 02:03:12 +0100 Subject: [PATCH 003/228] Default to a much faster tick rate for now --- cmd/rove-server/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/rove-server/main.go b/cmd/rove-server/main.go index d2848b2..286782f 100644 --- a/cmd/rove-server/main.go +++ b/cmd/rove-server/main.go @@ -49,7 +49,7 @@ func InnerMain() { persistence.SetPath(data) // Convert the tick rate - tickRate := 5 + tickRate := 1 if len(tick) > 0 { var err error tickRate, err = strconv.Atoi(tick) From 2556c0d049bade6e4f47d796f6255c2b61b1208d Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 27 Jun 2020 02:08:52 +0100 Subject: [PATCH 004/228] Call rand.Seed to end current determinism --- cmd/rove-server/main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/rove-server/main.go b/cmd/rove-server/main.go index 286782f..abd0a53 100644 --- a/cmd/rove-server/main.go +++ b/cmd/rove-server/main.go @@ -4,10 +4,12 @@ import ( "flag" "fmt" "log" + "math/rand" "os" "os/signal" "strconv" "syscall" + "time" "github.com/mdiluz/rove/cmd/rove-server/internal" "github.com/mdiluz/rove/pkg/persistence" @@ -23,6 +25,9 @@ var data = os.Getenv("DATA_PATH") var tick = os.Getenv("TICK_RATE") func InnerMain() { + // Ensure we've seeded rand + rand.Seed(time.Now().UTC().UnixNano()) + flag.Parse() // Print the version if requested From b116cdf29106f5b7f8d532a71e41cc45b2f28d25 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 27 Jun 2020 14:48:21 +0100 Subject: [PATCH 005/228] Convert Atlas to infinite lazy growth The atlas will now expand as needed for any query, but only initialise the chunk tile memory when requested While this may still be a pre-mature optimisation, it does simplify some code and ensures that our memory footprint stays small, for the most part --- cmd/rove-server/internal/server.go | 9 +- pkg/atlas/atlas.go | 189 ++++++++++++----------------- pkg/atlas/atlas_test.go | 172 ++++++++++---------------- pkg/game/command_test.go | 2 +- pkg/game/world.go | 92 +++++--------- pkg/game/world_test.go | 59 +++------ 6 files changed, 186 insertions(+), 337 deletions(-) diff --git a/cmd/rove-server/internal/server.go b/cmd/rove-server/internal/server.go index 0345936..de9d933 100644 --- a/cmd/rove-server/internal/server.go +++ b/cmd/rove-server/internal/server.go @@ -83,6 +83,7 @@ func NewServer(opts ...ServerOption) *Server { address: "", persistence: EphemeralData, schedule: cron.New(), + world: game.NewWorld(16), } // Apply all options @@ -90,9 +91,6 @@ func NewServer(opts ...ServerOption) *Server { o(s) } - // Start small, we can grow the world later - s.world = game.NewWorld(4, 8) - return s } @@ -114,11 +112,6 @@ func (s *Server) Initialise(fillWorld bool) (err error) { } s.accountant = accounts.NewAccountantClient(s.clientConn) - // Spawn a border on the default world - if err := s.world.SpawnWorld(fillWorld); err != nil { - return err - } - // Load the world file if err := s.LoadWorld(); err != nil { return err diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index 429efcb..969712f 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -1,7 +1,6 @@ package atlas import ( - "fmt" "log" "math/rand" @@ -16,114 +15,98 @@ type Chunk struct { Tiles []byte `json:"tiles"` } +// SpawnContent will create a chunk and fill it with spawned tiles +func (c *Chunk) SpawnContent(size int) { + c.Tiles = make([]byte, size*size) + for i := 0; i < len(c.Tiles); i++ { + c.Tiles[i] = objects.Empty + } + + // For now, fill it randomly with objects + for i := range c.Tiles { + if rand.Intn(16) == 0 { + c.Tiles[i] = objects.LargeRock + } else if rand.Intn(32) == 0 { + c.Tiles[i] = objects.SmallRock + } + } +} + // Atlas represents a grid of Chunks type Atlas struct { // Chunks represents all chunks in the world // This is intentionally not a 2D array so it can be expanded in all directions Chunks []Chunk `json:"chunks"` - // size is the current width/height of the given atlas - Size int `json:"size"` + // CurrentSize is the current width/height of the given atlas + CurrentSize int `json:"currentSize"` // ChunkSize is the dimensions of each chunk ChunkSize int `json:"chunksize"` } // NewAtlas creates a new empty atlas -func NewAtlas(size, chunkSize int) Atlas { - if size%2 != 0 { - log.Fatal("atlas size must always be even") +func NewAtlas(chunkSize int) Atlas { + return Atlas{ + CurrentSize: 0, + Chunks: nil, + ChunkSize: chunkSize, } - - a := Atlas{ - Size: size, - Chunks: make([]Chunk, size*size), - ChunkSize: chunkSize, - } - - // Initialise all the chunks - for i := range a.Chunks { - tiles := make([]byte, chunkSize*chunkSize) - for i := 0; i < len(tiles); i++ { - tiles[i] = objects.Empty - } - a.Chunks[i] = Chunk{ - Tiles: tiles, - } - } - - return a -} - -// SpawnRocks peppers the world with rocks -func (a *Atlas) SpawnRocks() error { - extent := a.ChunkSize * (a.Size / 2) - - // Pepper the current world with rocks - for i := -extent; i < extent; i++ { - for j := -extent; j < extent; j++ { - if rand.Intn(16) == 0 { - if err := a.SetTile(vector.Vector{X: i, Y: j}, objects.SmallRock); err != nil { - return err - } - } - } - } - - return nil -} - -// SpawnWalls spawns the around the world -func (a *Atlas) SpawnWalls() error { - extent := a.ChunkSize * (a.Size / 2) - - // Surround the atlas in walls - for i := -extent; i < extent; i++ { - - if err := a.SetTile(vector.Vector{X: i, Y: extent - 1}, objects.LargeRock); err != nil { // N - return err - } else if err := a.SetTile(vector.Vector{X: extent - 1, Y: i}, objects.LargeRock); err != nil { // E - return err - } else if err := a.SetTile(vector.Vector{X: i, Y: -extent}, objects.LargeRock); err != nil { // S - return err - } else if err := a.SetTile(vector.Vector{X: -extent, Y: i}, objects.LargeRock); err != nil { // W - return err - } - } - - return nil } // SetTile sets an individual tile's kind -func (a *Atlas) SetTile(v vector.Vector, tile byte) error { - chunk := a.toChunk(v) - if chunk >= len(a.Chunks) { - return fmt.Errorf("location outside of allocated atlas") +func (a *Atlas) SetTile(v vector.Vector, tile byte) { + // Get the chunk, expand, and spawn it if needed + c := a.toChunkWithGrow(v) + chunk := a.Chunks[c] + if chunk.Tiles == nil { + chunk.SpawnContent(a.ChunkSize) } local := a.toChunkLocal(v) tileId := local.X + local.Y*a.ChunkSize - if tileId >= len(a.Chunks[chunk].Tiles) { - return fmt.Errorf("location outside of allocated chunk") + + // Sanity check + if tileId >= len(chunk.Tiles) || tileId < 0 { + log.Fatalf("Local tileID is not in valid chunk, somehow, this means something is very wrong") } - a.Chunks[chunk].Tiles[tileId] = tile - return nil + + // Set the chunk back + chunk.Tiles[tileId] = tile + a.Chunks[c] = chunk } // GetTile will return an individual tile -func (a *Atlas) GetTile(v vector.Vector) (byte, error) { - chunk := a.toChunk(v) - if chunk >= len(a.Chunks) { - return 0, fmt.Errorf("location outside of allocated atlas") +func (a *Atlas) GetTile(v vector.Vector) byte { + // Get the chunk, expand, and spawn it if needed + c := a.toChunkWithGrow(v) + chunk := a.Chunks[c] + if chunk.Tiles == nil { + chunk.SpawnContent(a.ChunkSize) } local := a.toChunkLocal(v) tileId := local.X + local.Y*a.ChunkSize - if tileId >= len(a.Chunks[chunk].Tiles) { - return 0, fmt.Errorf("location outside of allocated chunk") + + // Sanity check + if tileId >= len(chunk.Tiles) || tileId < 0 { + log.Fatalf("Local tileID is not in valid chunk, somehow, this means something is very wrong") } - return a.Chunks[chunk].Tiles[tileId], nil + return chunk.Tiles[tileId] +} + +// toChunkWithGrow will expand the atlas for a given tile, returns the new chunk +func (a *Atlas) toChunkWithGrow(v vector.Vector) int { + for { + // Get the chunk, and grow looping until we have a valid chunk + chunk := a.toChunk(v) + if chunk >= len(a.Chunks) || chunk < 0 { + a.grow() + } else { + return chunk + } + } } // toChunkLocal gets a chunk local coordinate for a tile @@ -131,7 +114,7 @@ func (a *Atlas) toChunkLocal(v vector.Vector) vector.Vector { return vector.Vector{X: maths.Pmod(v.X, a.ChunkSize), Y: maths.Pmod(v.Y, a.ChunkSize)} } -// GetChunkID gets the chunk ID for a position in the world +// GetChunkID gets the current chunk ID for a position in the world func (a *Atlas) toChunk(v vector.Vector) int { local := a.toChunkLocal(v) // Get the chunk origin itself @@ -139,50 +122,34 @@ func (a *Atlas) toChunk(v vector.Vector) int { // Divided it by the number of chunks origin = origin.Divided(a.ChunkSize) // Shift it by our size (our origin is in the middle) - origin = origin.Added(vector.Vector{X: a.Size / 2, Y: a.Size / 2}) + origin = origin.Added(vector.Vector{X: a.CurrentSize / 2, Y: a.CurrentSize / 2}) // Get the ID based on the final values - return (a.Size * origin.Y) + origin.X + return (a.CurrentSize * origin.Y) + origin.X } // chunkOrigin gets the chunk origin for a given chunk index func (a *Atlas) chunkOrigin(chunk int) vector.Vector { v := vector.Vector{ - X: maths.Pmod(chunk, a.Size) - (a.Size / 2), - Y: (chunk / a.Size) - (a.Size / 2), + X: maths.Pmod(chunk, a.CurrentSize) - (a.CurrentSize / 2), + Y: (chunk / a.CurrentSize) - (a.CurrentSize / 2), } return v.Multiplied(a.ChunkSize) } -// GetWorldExtent gets the min and max valid coordinates of world -func (a *Atlas) GetWorldExtents() (min, max vector.Vector) { - min = vector.Vector{ - X: -(a.Size / 2) * a.ChunkSize, - Y: -(a.Size / 2) * a.ChunkSize, - } - max = vector.Vector{ - X: -min.X - 1, - Y: -min.Y - 1, - } - return -} - -// Grow will return a grown copy of the current atlas -func (a *Atlas) Grow(size int) error { - if size%2 != 0 { - return fmt.Errorf("atlas size must always be even") - } - delta := size - a.Size - if delta < 0 { - return fmt.Errorf("cannot shrink an atlas") - } else if delta == 0 { - return nil - } - +// grow will expand the current atlas in all directions by one chunk +func (a *Atlas) grow() error { // Create a new atlas - newAtlas := NewAtlas(size, a.ChunkSize) + newAtlas := NewAtlas(a.ChunkSize) - // Copy old chunks into new chunks + // Expand by one on each axis + newAtlas.CurrentSize = a.CurrentSize + 2 + + // Allocate the new atlas chunks + // These chunks will have nil tile slices + newAtlas.Chunks = make([]Chunk, newAtlas.CurrentSize*newAtlas.CurrentSize) + + // Copy all old chunks into the new atlas for index, chunk := range a.Chunks { // Calculate the new chunk location and copy over the data newAtlas.Chunks[newAtlas.toChunk(a.chunkOrigin(index))] = chunk diff --git a/pkg/atlas/atlas_test.go b/pkg/atlas/atlas_test.go index f8cc63a..3aeb328 100644 --- a/pkg/atlas/atlas_test.go +++ b/pkg/atlas/atlas_test.go @@ -3,60 +3,63 @@ package atlas import ( "testing" - "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/vector" "github.com/stretchr/testify/assert" ) func TestAtlas_NewAtlas(t *testing.T) { - a := NewAtlas(2, 1) + a := NewAtlas(1) assert.NotNil(t, a) - // Tiles should look like: 2 | 3 - // ----- - // 0 | 1 - assert.Equal(t, 4, len(a.Chunks)) - - a = NewAtlas(4, 1) - assert.NotNil(t, a) - // Tiles should look like: 2 | 3 - // ----- - // 0 | 1 - assert.Equal(t, 16, len(a.Chunks)) + assert.Equal(t, 1, a.ChunkSize) + assert.Equal(t, 0, len(a.Chunks)) // Should start empty } func TestAtlas_toChunk(t *testing.T) { - a := NewAtlas(2, 1) + a := NewAtlas(1) assert.NotNil(t, a) - // Tiles should look like: 2 | 3 + + // We start empty so we'll look like this + chunkID := a.toChunk(vector.Vector{X: 0, Y: 0}) + assert.Equal(t, 0, chunkID) + + // Get a tile to spawn the chunks + a.GetTile(vector.Vector{}) + + // Chunks should look like: + // 2 | 3 // ----- // 0 | 1 - tile := a.toChunk(vector.Vector{X: 0, Y: 0}) - assert.Equal(t, 3, tile) - tile = a.toChunk(vector.Vector{X: 0, Y: -1}) - assert.Equal(t, 1, tile) - tile = a.toChunk(vector.Vector{X: -1, Y: -1}) - assert.Equal(t, 0, tile) - tile = a.toChunk(vector.Vector{X: -1, Y: 0}) - assert.Equal(t, 2, tile) + chunkID = a.toChunk(vector.Vector{X: 0, Y: 0}) + assert.Equal(t, 3, chunkID) + chunkID = a.toChunk(vector.Vector{X: 0, Y: -1}) + assert.Equal(t, 1, chunkID) + chunkID = a.toChunk(vector.Vector{X: -1, Y: -1}) + assert.Equal(t, 0, chunkID) + chunkID = a.toChunk(vector.Vector{X: -1, Y: 0}) + assert.Equal(t, 2, chunkID) - a = NewAtlas(2, 2) + a = NewAtlas(2) assert.NotNil(t, a) - // Tiles should look like: + // Get a tile to spawn the chunks + a.GetTile(vector.Vector{}) + // Chunks should look like: // 2 | 3 // ----- // 0 | 1 - tile = a.toChunk(vector.Vector{X: 1, Y: 1}) - assert.Equal(t, 3, tile) - tile = a.toChunk(vector.Vector{X: 1, Y: -2}) - assert.Equal(t, 1, tile) - tile = a.toChunk(vector.Vector{X: -2, Y: -2}) - assert.Equal(t, 0, tile) - tile = a.toChunk(vector.Vector{X: -2, Y: 1}) - assert.Equal(t, 2, tile) + chunkID = a.toChunk(vector.Vector{X: 1, Y: 1}) + assert.Equal(t, 3, chunkID) + chunkID = a.toChunk(vector.Vector{X: 1, Y: -2}) + assert.Equal(t, 1, chunkID) + chunkID = a.toChunk(vector.Vector{X: -2, Y: -2}) + assert.Equal(t, 0, chunkID) + chunkID = a.toChunk(vector.Vector{X: -2, Y: 1}) + assert.Equal(t, 2, chunkID) - a = NewAtlas(4, 2) + a = NewAtlas(2) assert.NotNil(t, a) - // Tiles should look like: + // Get a tile to spawn the chunks + a.GetTile(vector.Vector{X: 0, Y: 3}) + // Chunks should look like: // 12| 13|| 14| 15 // ---------------- // 8 | 9 || 10| 11 @@ -64,107 +67,58 @@ func TestAtlas_toChunk(t *testing.T) { // 4 | 5 || 6 | 7 // ---------------- // 0 | 1 || 2 | 3 - tile = a.toChunk(vector.Vector{X: 1, Y: 3}) - assert.Equal(t, 14, tile) - tile = a.toChunk(vector.Vector{X: 1, Y: -3}) - assert.Equal(t, 2, tile) - tile = a.toChunk(vector.Vector{X: -1, Y: -1}) - assert.Equal(t, 5, tile) - tile = a.toChunk(vector.Vector{X: -2, Y: 2}) - assert.Equal(t, 13, tile) + chunkID = a.toChunk(vector.Vector{X: 1, Y: 3}) + assert.Equal(t, 14, chunkID) + chunkID = a.toChunk(vector.Vector{X: 1, Y: -3}) + assert.Equal(t, 2, chunkID) + chunkID = a.toChunk(vector.Vector{X: -1, Y: -1}) + assert.Equal(t, 5, chunkID) + chunkID = a.toChunk(vector.Vector{X: -2, Y: 2}) + assert.Equal(t, 13, chunkID) } func TestAtlas_GetSetTile(t *testing.T) { - a := NewAtlas(4, 10) + a := NewAtlas(10) assert.NotNil(t, a) // Set the origin tile to 1 and test it - assert.NoError(t, a.SetTile(vector.Vector{X: 0, Y: 0}, 1)) - tile, err := a.GetTile(vector.Vector{X: 0, Y: 0}) - assert.NoError(t, err) + a.SetTile(vector.Vector{X: 0, Y: 0}, 1) + tile := a.GetTile(vector.Vector{X: 0, Y: 0}) assert.Equal(t, byte(1), tile) // Set another tile to 1 and test it - assert.NoError(t, a.SetTile(vector.Vector{X: 5, Y: -2}, 2)) - tile, err = a.GetTile(vector.Vector{X: 5, Y: -2}) - assert.NoError(t, err) + a.SetTile(vector.Vector{X: 5, Y: -2}, 2) + tile = a.GetTile(vector.Vector{X: 5, Y: -2}) assert.Equal(t, byte(2), tile) } func TestAtlas_Grown(t *testing.T) { // Start with a small example - a := NewAtlas(2, 2) + a := NewAtlas(2) assert.NotNil(t, a) - assert.Equal(t, 4, len(a.Chunks)) + assert.Equal(t, 0, len(a.Chunks)) // Set a few tiles to values - assert.NoError(t, a.SetTile(vector.Vector{X: 0, Y: 0}, 1)) - assert.NoError(t, a.SetTile(vector.Vector{X: -1, Y: -1}, 2)) - assert.NoError(t, a.SetTile(vector.Vector{X: 1, Y: -2}, 3)) + a.SetTile(vector.Vector{X: 0, Y: 0}, 1) + a.SetTile(vector.Vector{X: -1, Y: -1}, 2) + a.SetTile(vector.Vector{X: 1, Y: -2}, 3) - // Grow once to just double it - err := a.Grow(4) - assert.NoError(t, err) - assert.Equal(t, 16, len(a.Chunks)) - - tile, err := a.GetTile(vector.Vector{X: 0, Y: 0}) - assert.NoError(t, err) + // Check tile values + tile := a.GetTile(vector.Vector{X: 0, Y: 0}) assert.Equal(t, byte(1), tile) - tile, err = a.GetTile(vector.Vector{X: -1, Y: -1}) - assert.NoError(t, err) + tile = a.GetTile(vector.Vector{X: -1, Y: -1}) assert.Equal(t, byte(2), tile) - tile, err = a.GetTile(vector.Vector{X: 1, Y: -2}) - assert.NoError(t, err) + tile = a.GetTile(vector.Vector{X: 1, Y: -2}) assert.Equal(t, byte(3), tile) - // Grow it again even bigger - err = a.Grow(10) - assert.NoError(t, err) - assert.Equal(t, 100, len(a.Chunks)) - - tile, err = a.GetTile(vector.Vector{X: 0, Y: 0}) - assert.NoError(t, err) + tile = a.GetTile(vector.Vector{X: 0, Y: 0}) assert.Equal(t, byte(1), tile) - tile, err = a.GetTile(vector.Vector{X: -1, Y: -1}) - assert.NoError(t, err) + tile = a.GetTile(vector.Vector{X: -1, Y: -1}) assert.Equal(t, byte(2), tile) - tile, err = a.GetTile(vector.Vector{X: 1, Y: -2}) - assert.NoError(t, err) + tile = a.GetTile(vector.Vector{X: 1, Y: -2}) assert.Equal(t, byte(3), tile) } - -func TestAtlas_SpawnWorld(t *testing.T) { - // Start with a small example - a := NewAtlas(2, 4) - assert.NotNil(t, a) - assert.Equal(t, 4, len(a.Chunks)) - assert.NoError(t, a.SpawnWalls()) - - for i := -4; i < 4; i++ { - tile, err := a.GetTile(vector.Vector{X: i, Y: -4}) - assert.NoError(t, err) - assert.Equal(t, objects.LargeRock, tile) - } - - for i := -4; i < 4; i++ { - tile, err := a.GetTile(vector.Vector{X: -4, Y: i}) - assert.NoError(t, err) - assert.Equal(t, objects.LargeRock, tile) - } - - for i := -4; i < 4; i++ { - tile, err := a.GetTile(vector.Vector{X: 3, Y: i}) - assert.NoError(t, err) - assert.Equal(t, objects.LargeRock, tile) - } - - for i := -4; i < 4; i++ { - tile, err := a.GetTile(vector.Vector{X: i, Y: 3}) - assert.NoError(t, err) - assert.Equal(t, objects.LargeRock, tile) - } -} diff --git a/pkg/game/command_test.go b/pkg/game/command_test.go index 11da854..3356f2a 100644 --- a/pkg/game/command_test.go +++ b/pkg/game/command_test.go @@ -8,7 +8,7 @@ import ( ) func TestCommand_Move(t *testing.T) { - world := NewWorld(2, 8) + world := NewWorld(8) a, err := world.SpawnRover() assert.NoError(t, err) pos := vector.Vector{ diff --git a/pkg/game/world.go b/pkg/game/world.go index 9048900..6b04594 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -12,7 +12,6 @@ import ( "github.com/google/uuid" "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/bearing" - "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/vector" ) @@ -44,7 +43,7 @@ type World struct { var wordsFile = os.Getenv("WORDS_FILE") // NewWorld creates a new world object -func NewWorld(size, chunkSize int) *World { +func NewWorld(chunkSize int) *World { // Try and load the words file var lines []string @@ -65,23 +64,11 @@ func NewWorld(size, chunkSize int) *World { Rovers: make(map[string]Rover), CommandQueue: make(map[string]CommandStream), Incoming: make(map[string]CommandStream), - Atlas: atlas.NewAtlas(size, chunkSize), + Atlas: atlas.NewAtlas(chunkSize), words: lines, } } -// SpawnWorld spawns a border at the edge of the world atlas -func (w *World) SpawnWorld(fillWorld bool) error { - w.worldMutex.Lock() - defer w.worldMutex.Unlock() - if fillWorld { - if err := w.Atlas.SpawnRocks(); err != nil { - return err - } - } - return w.Atlas.SpawnWalls() -} - // SpawnRover adds an rover to the game func (w *World) SpawnRover() (string, error) { w.worldMutex.Lock() @@ -114,16 +101,14 @@ func (w *World) SpawnRover() (string, error) { // Seach until we error (run out of world) for { - if tile, err := w.Atlas.GetTile(rover.Pos); err != nil { - return "", err + tile := w.Atlas.GetTile(rover.Pos) + if !objects.IsBlocking(tile) { + break } else { - if !objects.IsBlocking(tile) { - break - } else { - // Try and spawn to the east of the blockage - rover.Pos.Add(vector.Vector{X: 1, Y: 0}) - } + // Try and spawn to the east of the blockage + rover.Pos.Add(vector.Vector{X: 1, Y: 0}) } + } log.Printf("Spawned rover at %+v\n", rover.Pos) @@ -153,9 +138,7 @@ func (w *World) DestroyRover(rover string) error { if i, ok := w.Rovers[rover]; ok { // Clear the tile - if err := w.Atlas.SetTile(i.Pos, objects.Empty); err != nil { - return fmt.Errorf("coudln't clear old rover tile: %s", err) - } + w.Atlas.SetTile(i.Pos, objects.Empty) delete(w.Rovers, rover) } else { return fmt.Errorf("no rover matching id") @@ -213,9 +196,8 @@ func (w *World) WarpRover(rover string, pos vector.Vector) error { } // Check the tile is not blocked - if tile, err := w.Atlas.GetTile(pos); err != nil { - return fmt.Errorf("coudln't get state of destination rover tile: %s", err) - } else if objects.IsBlocking(tile) { + tile := w.Atlas.GetTile(pos) + if objects.IsBlocking(tile) { return fmt.Errorf("can't warp rover to occupied tile, check before warping") } @@ -237,9 +219,8 @@ func (w *World) MoveRover(rover string, b bearing.Bearing) (vector.Vector, error newPos := i.Pos.Added(b.Vector()) // Get the tile and verify it's empty - if tile, err := w.Atlas.GetTile(newPos); err != nil { - return vector.Vector{}, fmt.Errorf("couldn't get tile for new position: %s", err) - } else if !objects.IsBlocking(tile) { + tile := w.Atlas.GetTile(newPos) + if !objects.IsBlocking(tile) { // Perform the move i.Pos = newPos w.Rovers[rover] = i @@ -265,18 +246,12 @@ func (w *World) RoverStash(rover string) (byte, error) { defer w.worldMutex.Unlock() if r, ok := w.Rovers[rover]; ok { - if tile, err := w.Atlas.GetTile(r.Pos); err != nil { - return objects.Empty, err - } else { - if objects.IsStashable(tile) { - r.Inventory = append(r.Inventory, tile) - w.Rovers[rover] = r - if err := w.Atlas.SetTile(r.Pos, objects.Empty); err != nil { - return objects.Empty, err - } else { - return tile, nil - } - } + tile := w.Atlas.GetTile(r.Pos) + if objects.IsStashable(tile) { + r.Inventory = append(r.Inventory, tile) + w.Rovers[rover] = r + w.Atlas.SetTile(r.Pos, objects.Empty) + return tile, nil } } else { @@ -306,32 +281,19 @@ func (w *World) RadarFromRover(rover string) ([]byte, error) { Y: roverPos.Y + r.Range, } - // Make sure we only query within the actual world - worldMin, worldMax := w.Atlas.GetWorldExtents() - scanMin := vector.Vector{ - X: maths.Max(radarMin.X, worldMin.X), - Y: maths.Max(radarMin.Y, worldMin.Y), - } - scanMax := vector.Vector{ - X: maths.Min(radarMax.X, worldMax.X), - Y: maths.Min(radarMax.Y, worldMax.Y), - } - // Gather up all tiles within the range var radar = make([]byte, radarSpan*radarSpan) - for j := scanMin.Y; j <= scanMax.Y; j++ { - for i := scanMin.X; i <= scanMax.X; i++ { + for j := radarMin.Y; j <= radarMax.Y; j++ { + for i := radarMin.X; i <= radarMax.X; i++ { q := vector.Vector{X: i, Y: j} - if tile, err := w.Atlas.GetTile(q); err != nil { - return nil, fmt.Errorf("failed to query tile: %s", err) + tile := w.Atlas.GetTile(q) + + // Get the position relative to the bottom left of the radar + relative := q.Added(radarMin.Negated()) + index := relative.X + relative.Y*radarSpan + radar[index] = tile - } else { - // Get the position relative to the bottom left of the radar - relative := q.Added(radarMin.Negated()) - index := relative.X + relative.Y*radarSpan - radar[index] = tile - } } } diff --git a/pkg/game/world_test.go b/pkg/game/world_test.go index 5a48231..ceda417 100644 --- a/pkg/game/world_test.go +++ b/pkg/game/world_test.go @@ -11,14 +11,14 @@ import ( func TestNewWorld(t *testing.T) { // Very basic for now, nothing to verify - world := NewWorld(4, 4) + world := NewWorld(4) if world == nil { t.Error("Failed to create world") } } func TestWorld_CreateRover(t *testing.T) { - world := NewWorld(2, 8) + world := NewWorld(8) a, err := world.SpawnRover() assert.NoError(t, err) b, err := world.SpawnRover() @@ -33,7 +33,7 @@ func TestWorld_CreateRover(t *testing.T) { } func TestWorld_GetRover(t *testing.T) { - world := NewWorld(2, 4) + world := NewWorld(4) a, err := world.SpawnRover() assert.NoError(t, err) @@ -43,7 +43,7 @@ func TestWorld_GetRover(t *testing.T) { } func TestWorld_DestroyRover(t *testing.T) { - world := NewWorld(4, 1) + world := NewWorld(1) a, err := world.SpawnRover() assert.NoError(t, err) b, err := world.SpawnRover() @@ -61,7 +61,7 @@ func TestWorld_DestroyRover(t *testing.T) { } func TestWorld_GetSetMovePosition(t *testing.T) { - world := NewWorld(4, 4) + world := NewWorld(4) a, err := world.SpawnRover() assert.NoError(t, err) @@ -84,14 +84,14 @@ func TestWorld_GetSetMovePosition(t *testing.T) { assert.Equal(t, pos, newPos, "Failed to correctly move position for rover") // Place a tile in front of the rover - assert.NoError(t, world.Atlas.SetTile(vector.Vector{X: 0, Y: 2}, objects.LargeRock)) + world.Atlas.SetTile(vector.Vector{X: 0, Y: 2}, objects.LargeRock) newPos, err = world.MoveRover(a, b) assert.Equal(t, pos, newPos, "Failed to correctly not move position for rover into wall") } func TestWorld_RadarFromRover(t *testing.T) { // Create world that should have visible walls on the radar - world := NewWorld(4, 2) + world := NewWorld(2) a, err := world.SpawnRover() assert.NoError(t, err) b, err := world.SpawnRover() @@ -102,40 +102,18 @@ func TestWorld_RadarFromRover(t *testing.T) { assert.NoError(t, world.WarpRover(b, bpos), "Failed to warp rover") assert.NoError(t, world.WarpRover(a, vector.Vector{X: 0, Y: 0}), "Failed to warp rover") - // Spawn the world wall - err = world.Atlas.SpawnWalls() - assert.NoError(t, err) - radar, err := world.RadarFromRover(a) assert.NoError(t, err, "Failed to get radar from rover") fullRange := 4 + 4 + 1 assert.Equal(t, fullRange*fullRange, len(radar), "Radar returned wrong length") - // It should look like: - // --------- - // OOOOOOOO- - // O------O- - // O------O- - // O---R--O- - // O------O- - // O------O- - // OR-----O- - // OOOOOOOO- - PrintTiles(radar) - - // Test all expected values + // Test the expected values assert.Equal(t, objects.Rover, radar[1+fullRange]) assert.Equal(t, objects.Rover, radar[4+4*fullRange]) - for i := 0; i < 8; i++ { - assert.Equal(t, objects.LargeRock, radar[i]) - assert.Equal(t, objects.LargeRock, radar[i+(7*9)]) - assert.Equal(t, objects.LargeRock, radar[i*9]) - assert.Equal(t, objects.LargeRock, radar[(i*9)+7]) - } } func TestWorld_RoverStash(t *testing.T) { - world := NewWorld(2, 2) + world := NewWorld(2) a, err := world.SpawnRover() assert.NoError(t, err) @@ -147,15 +125,13 @@ func TestWorld_RoverStash(t *testing.T) { err = world.WarpRover(a, pos) assert.NoError(t, err, "Failed to set position for rover") - err = world.Atlas.SetTile(pos, objects.SmallRock) - assert.NoError(t, err, "Failed to set tile to rock") + world.Atlas.SetTile(pos, objects.SmallRock) o, err := world.RoverStash(a) assert.NoError(t, err, "Failed to stash") assert.Equal(t, objects.SmallRock, o, "Failed to get correct object") - tile, err := world.Atlas.GetTile(pos) - assert.NoError(t, err, "Failed to get tile") + tile := world.Atlas.GetTile(pos) assert.Equal(t, objects.Empty, tile, "Stash failed to remove object from atlas") inv, err := world.RoverInventory(a) @@ -164,7 +140,7 @@ func TestWorld_RoverStash(t *testing.T) { } func TestWorld_RoverDamage(t *testing.T) { - world := NewWorld(2, 2) + world := NewWorld(2) a, err := world.SpawnRover() assert.NoError(t, err) @@ -179,8 +155,7 @@ func TestWorld_RoverDamage(t *testing.T) { info, err := world.GetRover(a) assert.NoError(t, err, "couldn't get rover info") - err = world.Atlas.SetTile(vector.Vector{X: 0.0, Y: 1.0}, objects.LargeRock) - assert.NoError(t, err, "Failed to set tile to rock") + world.Atlas.SetTile(vector.Vector{X: 0.0, Y: 1.0}, objects.LargeRock) vec, err := world.MoveRover(a, bearing.North) assert.NoError(t, err, "Failed to move rover") @@ -192,7 +167,7 @@ func TestWorld_RoverDamage(t *testing.T) { } func TestWorld_RoverRepair(t *testing.T) { - world := NewWorld(2, 2) + world := NewWorld(2) a, err := world.SpawnRover() assert.NoError(t, err) @@ -207,15 +182,13 @@ func TestWorld_RoverRepair(t *testing.T) { originalInfo, err := world.GetRover(a) assert.NoError(t, err, "couldn't get rover info") - err = world.Atlas.SetTile(pos, objects.SmallRock) - assert.NoError(t, err, "Failed to set tile to rock") + world.Atlas.SetTile(pos, objects.SmallRock) o, err := world.RoverStash(a) assert.NoError(t, err, "Failed to stash") assert.Equal(t, objects.SmallRock, o, "Failed to get correct object") - err = world.Atlas.SetTile(vector.Vector{X: 0.0, Y: 1.0}, objects.LargeRock) - assert.NoError(t, err, "Failed to set tile to rock") + world.Atlas.SetTile(vector.Vector{X: 0.0, Y: 1.0}, objects.LargeRock) vec, err := world.MoveRover(a, bearing.North) assert.NoError(t, err, "Failed to move rover") From 9bb91920c95ba8225cdf342a3879c49747aa44fd Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 27 Jun 2020 16:03:53 +0100 Subject: [PATCH 006/228] Make Atlas grow in X and Y dimensions independently Fixes exponential growth --- pkg/atlas/atlas.go | 192 ++++++++++++++++++++++++++++------------ pkg/atlas/atlas_test.go | 41 +++++---- pkg/vector/vector.go | 10 +++ 3 files changed, 163 insertions(+), 80 deletions(-) diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index 969712f..00402ab 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -38,32 +38,40 @@ type Atlas struct { // This is intentionally not a 2D array so it can be expanded in all directions Chunks []Chunk `json:"chunks"` - // CurrentSize is the current width/height of the given atlas - CurrentSize int `json:"currentSize"` + // CurrentSizeInChunks is the current width/height of the atlas in chunks + CurrentSizeInChunks vector.Vector `json:"currentSizeInChunks"` - // ChunkSize is the dimensions of each chunk + // WorldOriginInChunkSpace represents the location of [0,0] in chunk space + WorldOriginInChunkSpace vector.Vector `json:"worldOriginInChunkSpace"` + + // ChunkSize is the x/y dimensions of each square chunk ChunkSize int `json:"chunksize"` } // NewAtlas creates a new empty atlas func NewAtlas(chunkSize int) Atlas { - return Atlas{ - CurrentSize: 0, - Chunks: nil, - ChunkSize: chunkSize, + // Start up with one chunk + a := Atlas{ + ChunkSize: chunkSize, + Chunks: make([]Chunk, 1), + CurrentSizeInChunks: vector.Vector{X: 1, Y: 1}, + WorldOriginInChunkSpace: vector.Vector{X: 0, Y: 0}, } + // Initialise the first chunk + a.Chunks[0].SpawnContent(chunkSize) + return a } // SetTile sets an individual tile's kind func (a *Atlas) SetTile(v vector.Vector, tile byte) { - // Get the chunk, expand, and spawn it if needed - c := a.toChunkWithGrow(v) + // Get the chunk + c := a.worldSpaceToChunkWithGrow(v) chunk := a.Chunks[c] if chunk.Tiles == nil { chunk.SpawnContent(a.ChunkSize) } - local := a.toChunkLocal(v) + local := a.worldSpaceToChunkLocal(v) tileId := local.X + local.Y*a.ChunkSize // Sanity check @@ -78,14 +86,14 @@ func (a *Atlas) SetTile(v vector.Vector, tile byte) { // GetTile will return an individual tile func (a *Atlas) GetTile(v vector.Vector) byte { - // Get the chunk, expand, and spawn it if needed - c := a.toChunkWithGrow(v) + // Get the chunk + c := a.worldSpaceToChunkWithGrow(v) chunk := a.Chunks[c] if chunk.Tiles == nil { chunk.SpawnContent(a.ChunkSize) } - local := a.toChunkLocal(v) + local := a.worldSpaceToChunkLocal(v) tileId := local.X + local.Y*a.ChunkSize // Sanity check @@ -96,68 +104,134 @@ func (a *Atlas) GetTile(v vector.Vector) byte { return chunk.Tiles[tileId] } -// toChunkWithGrow will expand the atlas for a given tile, returns the new chunk -func (a *Atlas) toChunkWithGrow(v vector.Vector) int { - for { - // Get the chunk, and grow looping until we have a valid chunk - chunk := a.toChunk(v) - if chunk >= len(a.Chunks) || chunk < 0 { - a.grow() - } else { - return chunk - } - } -} - -// toChunkLocal gets a chunk local coordinate for a tile -func (a *Atlas) toChunkLocal(v vector.Vector) vector.Vector { +// worldSpaceToChunkLocal gets a chunk local coordinate for a tile +func (a *Atlas) worldSpaceToChunkLocal(v vector.Vector) vector.Vector { return vector.Vector{X: maths.Pmod(v.X, a.ChunkSize), Y: maths.Pmod(v.Y, a.ChunkSize)} } -// GetChunkID gets the current chunk ID for a position in the world -func (a *Atlas) toChunk(v vector.Vector) int { - local := a.toChunkLocal(v) - // Get the chunk origin itself - origin := v.Added(local.Negated()) - // Divided it by the number of chunks - origin = origin.Divided(a.ChunkSize) - // Shift it by our size (our origin is in the middle) - origin = origin.Added(vector.Vector{X: a.CurrentSize / 2, Y: a.CurrentSize / 2}) - // Get the ID based on the final values - return (a.CurrentSize * origin.Y) + origin.X +// worldSpaceToChunk gets the current chunk ID for a position in the world +func (a *Atlas) worldSpaceToChunk(v vector.Vector) int { + // First convert to chunk space + chunkSpace := a.worldSpaceToChunkSpace(v) + + // Then return the ID + return a.chunkSpaceToChunk(chunkSpace) } -// chunkOrigin gets the chunk origin for a given chunk index -func (a *Atlas) chunkOrigin(chunk int) vector.Vector { - v := vector.Vector{ - X: maths.Pmod(chunk, a.CurrentSize) - (a.CurrentSize / 2), - Y: (chunk / a.CurrentSize) - (a.CurrentSize / 2), +// worldSpaceToChunkSpace converts from world space to chunk space +func (a *Atlas) worldSpaceToChunkSpace(v vector.Vector) vector.Vector { + // Remove the chunk local part + chunkOrigin := v.Added(a.worldSpaceToChunkLocal(v).Negated()) + // Convert to chunk space coordinate + chunkSpaceOrigin := chunkOrigin.Divided(a.ChunkSize) + // Shift it by our current chunk origin + chunkIndexOrigin := chunkSpaceOrigin.Added(a.WorldOriginInChunkSpace) + + return chunkIndexOrigin +} + +// chunkSpaceToWorldSpace vonverts from chunk space to world space +func (a *Atlas) chunkSpaceToWorldSpace(v vector.Vector) vector.Vector { + + // Shift it by the current chunk origin + shifted := v.Added(a.WorldOriginInChunkSpace.Negated()) + + // Multiply out by chunk size + return shifted.Multiplied(a.ChunkSize) +} + +// chunkOriginInChunkSpace Gets the chunk origin in chunk space +func (a *Atlas) chunkOriginInChunkSpace(chunk int) vector.Vector { + // convert the chunk to chunk space + chunkOrigin := a.chunkToChunkSpace(chunk) + + // Shift it by the current chunk origin + return chunkOrigin.Added(a.WorldOriginInChunkSpace.Negated()) +} + +// chunkOriginInWorldSpace gets the chunk origin for a given chunk index +func (a *Atlas) chunkOriginInWorldSpace(chunk int) vector.Vector { + // convert the chunk to chunk space + chunkSpace := a.chunkToChunkSpace(chunk) + + // Convert to world space + return a.chunkSpaceToWorldSpace(chunkSpace) +} + +// chunkSpaceToChunk converts from chunk space to the chunk +func (a *Atlas) chunkSpaceToChunk(v vector.Vector) int { + // Along the coridor and up the stair + return (v.Y * a.CurrentSizeInChunks.X) + v.X +} + +// chunkToChunkSpace returns the chunk space coord for the chunk +func (a *Atlas) chunkToChunkSpace(chunk int) vector.Vector { + return vector.Vector{ + X: maths.Pmod(chunk, a.CurrentSizeInChunks.Y), + Y: (chunk / a.CurrentSizeInChunks.X), + } +} + +func (a *Atlas) getExtents() (min vector.Vector, max vector.Vector) { + min = a.WorldOriginInChunkSpace.Negated() + max = min.Added(a.CurrentSizeInChunks) + return +} + +// worldSpaceToTrunkWithGrow will expand the current atlas for a given world space position if needed +func (a *Atlas) worldSpaceToChunkWithGrow(v vector.Vector) int { + min, max := a.getExtents() + + // Divide by the chunk size to bring into chunk space + v = v.Divided(a.ChunkSize) + + // Check we're within the current extents and bail early + if v.X >= min.X && v.Y >= min.Y && v.X < max.X && v.Y < max.Y { + return a.worldSpaceToChunk(v) } - return v.Multiplied(a.ChunkSize) -} + // Calculate the new origin and the new size + origin := min + size := a.CurrentSizeInChunks -// grow will expand the current atlas in all directions by one chunk -func (a *Atlas) grow() error { - // Create a new atlas - newAtlas := NewAtlas(a.ChunkSize) + // If we need to shift the origin back + originDiff := origin.Added(v.Negated()) + if originDiff.X > 0 { + origin.X -= originDiff.X + size.X += originDiff.X + } + if originDiff.Y > 0 { + origin.Y -= originDiff.Y + size.Y += originDiff.Y + } - // Expand by one on each axis - newAtlas.CurrentSize = a.CurrentSize + 2 + // If we need to expand the size + maxDiff := v.Added(max.Negated()) + if maxDiff.X > 0 { + size.X += maxDiff.X + } + if maxDiff.Y > 0 { + size.Y += maxDiff.Y + } - // Allocate the new atlas chunks - // These chunks will have nil tile slices - newAtlas.Chunks = make([]Chunk, newAtlas.CurrentSize*newAtlas.CurrentSize) + // Set up the new size and origin + newAtlas := Atlas{ + ChunkSize: a.ChunkSize, + WorldOriginInChunkSpace: origin.Negated(), + CurrentSizeInChunks: size, + Chunks: make([]Chunk, size.X*size.Y), + } // Copy all old chunks into the new atlas - for index, chunk := range a.Chunks { + for chunk, chunkData := range a.Chunks { // Calculate the new chunk location and copy over the data - newAtlas.Chunks[newAtlas.toChunk(a.chunkOrigin(index))] = chunk + newChunk := newAtlas.worldSpaceToChunk(a.chunkOriginInWorldSpace(chunk)) + // Copy over the old chunk to the new atlas + newAtlas.Chunks[newChunk] = chunkData } // Copy the new atlas data into this one *a = newAtlas - // Return the new atlas - return nil + return a.worldSpaceToChunk(v) } diff --git a/pkg/atlas/atlas_test.go b/pkg/atlas/atlas_test.go index 3aeb328..ae5c705 100644 --- a/pkg/atlas/atlas_test.go +++ b/pkg/atlas/atlas_test.go @@ -11,54 +11,53 @@ func TestAtlas_NewAtlas(t *testing.T) { a := NewAtlas(1) assert.NotNil(t, a) assert.Equal(t, 1, a.ChunkSize) - assert.Equal(t, 0, len(a.Chunks)) // Should start empty + assert.Equal(t, 1, len(a.Chunks)) // Should start empty } func TestAtlas_toChunk(t *testing.T) { a := NewAtlas(1) assert.NotNil(t, a) - // We start empty so we'll look like this - chunkID := a.toChunk(vector.Vector{X: 0, Y: 0}) - assert.Equal(t, 0, chunkID) - // Get a tile to spawn the chunks - a.GetTile(vector.Vector{}) + a.GetTile(vector.Vector{X: -1, Y: -1}) + a.GetTile(vector.Vector{X: 0, Y: 0}) // Chunks should look like: // 2 | 3 // ----- // 0 | 1 - chunkID = a.toChunk(vector.Vector{X: 0, Y: 0}) + chunkID := a.worldSpaceToChunk(vector.Vector{X: 0, Y: 0}) assert.Equal(t, 3, chunkID) - chunkID = a.toChunk(vector.Vector{X: 0, Y: -1}) + chunkID = a.worldSpaceToChunk(vector.Vector{X: 0, Y: -1}) assert.Equal(t, 1, chunkID) - chunkID = a.toChunk(vector.Vector{X: -1, Y: -1}) + chunkID = a.worldSpaceToChunk(vector.Vector{X: -1, Y: -1}) assert.Equal(t, 0, chunkID) - chunkID = a.toChunk(vector.Vector{X: -1, Y: 0}) + chunkID = a.worldSpaceToChunk(vector.Vector{X: -1, Y: 0}) assert.Equal(t, 2, chunkID) a = NewAtlas(2) assert.NotNil(t, a) // Get a tile to spawn the chunks - a.GetTile(vector.Vector{}) + a.GetTile(vector.Vector{X: -2, Y: -2}) + a.GetTile(vector.Vector{X: 1, Y: 1}) // Chunks should look like: // 2 | 3 // ----- // 0 | 1 - chunkID = a.toChunk(vector.Vector{X: 1, Y: 1}) + chunkID = a.worldSpaceToChunk(vector.Vector{X: 1, Y: 1}) assert.Equal(t, 3, chunkID) - chunkID = a.toChunk(vector.Vector{X: 1, Y: -2}) + chunkID = a.worldSpaceToChunk(vector.Vector{X: 1, Y: -2}) assert.Equal(t, 1, chunkID) - chunkID = a.toChunk(vector.Vector{X: -2, Y: -2}) + chunkID = a.worldSpaceToChunk(vector.Vector{X: -2, Y: -2}) assert.Equal(t, 0, chunkID) - chunkID = a.toChunk(vector.Vector{X: -2, Y: 1}) + chunkID = a.worldSpaceToChunk(vector.Vector{X: -2, Y: 1}) assert.Equal(t, 2, chunkID) a = NewAtlas(2) assert.NotNil(t, a) // Get a tile to spawn the chunks - a.GetTile(vector.Vector{X: 0, Y: 3}) + a.GetTile(vector.Vector{X: 5, Y: 5}) + a.GetTile(vector.Vector{X: -5, Y: -5}) // Chunks should look like: // 12| 13|| 14| 15 // ---------------- @@ -67,13 +66,13 @@ func TestAtlas_toChunk(t *testing.T) { // 4 | 5 || 6 | 7 // ---------------- // 0 | 1 || 2 | 3 - chunkID = a.toChunk(vector.Vector{X: 1, Y: 3}) + chunkID = a.worldSpaceToChunk(vector.Vector{X: 1, Y: 3}) assert.Equal(t, 14, chunkID) - chunkID = a.toChunk(vector.Vector{X: 1, Y: -3}) + chunkID = a.worldSpaceToChunk(vector.Vector{X: 1, Y: -3}) assert.Equal(t, 2, chunkID) - chunkID = a.toChunk(vector.Vector{X: -1, Y: -1}) + chunkID = a.worldSpaceToChunk(vector.Vector{X: -1, Y: -1}) assert.Equal(t, 5, chunkID) - chunkID = a.toChunk(vector.Vector{X: -2, Y: 2}) + chunkID = a.worldSpaceToChunk(vector.Vector{X: -2, Y: 2}) assert.Equal(t, 13, chunkID) } @@ -96,7 +95,7 @@ func TestAtlas_Grown(t *testing.T) { // Start with a small example a := NewAtlas(2) assert.NotNil(t, a) - assert.Equal(t, 0, len(a.Chunks)) + assert.Equal(t, 1, len(a.Chunks)) // Set a few tiles to values a.SetTile(vector.Vector{X: 0, Y: 0}, 1) diff --git a/pkg/vector/vector.go b/pkg/vector/vector.go index 1b82c5a..61efc97 100644 --- a/pkg/vector/vector.go +++ b/pkg/vector/vector.go @@ -54,3 +54,13 @@ func (v Vector) Divided(val int) Vector { func (v Vector) Abs() Vector { return Vector{maths.Abs(v.X), maths.Abs(v.Y)} } + +// Min returns the minimum values in both vectors +func Min(v1 Vector, v2 Vector) Vector { + return Vector{maths.Min(v1.X, v2.X), maths.Min(v1.Y, v2.Y)} +} + +// Min returns the max values in both vectors +func Max(v1 Vector, v2 Vector) Vector { + return Vector{maths.Max(v1.X, v2.X), maths.Max(v1.Y, v2.Y)} +} From e5ee0eaece8c6bb64d32e2d42b03f90e2091d694 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 28 Jun 2020 11:01:01 +0100 Subject: [PATCH 007/228] Rename a couple of Atlas variables Sometimes names can be too long --- pkg/atlas/atlas.go | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index 00402ab..0c692d3 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -38,11 +38,11 @@ type Atlas struct { // This is intentionally not a 2D array so it can be expanded in all directions Chunks []Chunk `json:"chunks"` - // CurrentSizeInChunks is the current width/height of the atlas in chunks - CurrentSizeInChunks vector.Vector `json:"currentSizeInChunks"` + // CurrentSize is the current width/height of the atlas in chunks + CurrentSize vector.Vector `json:"currentSize"` - // WorldOriginInChunkSpace represents the location of [0,0] in chunk space - WorldOriginInChunkSpace vector.Vector `json:"worldOriginInChunkSpace"` + // WorldOrigin represents the location of the [0,0] world space point in terms of the allotted current chunks + WorldOrigin vector.Vector `json:"worldOrigin"` // ChunkSize is the x/y dimensions of each square chunk ChunkSize int `json:"chunksize"` @@ -52,10 +52,10 @@ type Atlas struct { func NewAtlas(chunkSize int) Atlas { // Start up with one chunk a := Atlas{ - ChunkSize: chunkSize, - Chunks: make([]Chunk, 1), - CurrentSizeInChunks: vector.Vector{X: 1, Y: 1}, - WorldOriginInChunkSpace: vector.Vector{X: 0, Y: 0}, + ChunkSize: chunkSize, + Chunks: make([]Chunk, 1), + CurrentSize: vector.Vector{X: 1, Y: 1}, + WorldOrigin: vector.Vector{X: 0, Y: 0}, } // Initialise the first chunk a.Chunks[0].SpawnContent(chunkSize) @@ -125,7 +125,7 @@ func (a *Atlas) worldSpaceToChunkSpace(v vector.Vector) vector.Vector { // Convert to chunk space coordinate chunkSpaceOrigin := chunkOrigin.Divided(a.ChunkSize) // Shift it by our current chunk origin - chunkIndexOrigin := chunkSpaceOrigin.Added(a.WorldOriginInChunkSpace) + chunkIndexOrigin := chunkSpaceOrigin.Added(a.WorldOrigin) return chunkIndexOrigin } @@ -134,7 +134,7 @@ func (a *Atlas) worldSpaceToChunkSpace(v vector.Vector) vector.Vector { func (a *Atlas) chunkSpaceToWorldSpace(v vector.Vector) vector.Vector { // Shift it by the current chunk origin - shifted := v.Added(a.WorldOriginInChunkSpace.Negated()) + shifted := v.Added(a.WorldOrigin.Negated()) // Multiply out by chunk size return shifted.Multiplied(a.ChunkSize) @@ -146,7 +146,7 @@ func (a *Atlas) chunkOriginInChunkSpace(chunk int) vector.Vector { chunkOrigin := a.chunkToChunkSpace(chunk) // Shift it by the current chunk origin - return chunkOrigin.Added(a.WorldOriginInChunkSpace.Negated()) + return chunkOrigin.Added(a.WorldOrigin.Negated()) } // chunkOriginInWorldSpace gets the chunk origin for a given chunk index @@ -161,20 +161,20 @@ func (a *Atlas) chunkOriginInWorldSpace(chunk int) vector.Vector { // chunkSpaceToChunk converts from chunk space to the chunk func (a *Atlas) chunkSpaceToChunk(v vector.Vector) int { // Along the coridor and up the stair - return (v.Y * a.CurrentSizeInChunks.X) + v.X + return (v.Y * a.CurrentSize.X) + v.X } // chunkToChunkSpace returns the chunk space coord for the chunk func (a *Atlas) chunkToChunkSpace(chunk int) vector.Vector { return vector.Vector{ - X: maths.Pmod(chunk, a.CurrentSizeInChunks.Y), - Y: (chunk / a.CurrentSizeInChunks.X), + X: maths.Pmod(chunk, a.CurrentSize.Y), + Y: (chunk / a.CurrentSize.X), } } func (a *Atlas) getExtents() (min vector.Vector, max vector.Vector) { - min = a.WorldOriginInChunkSpace.Negated() - max = min.Added(a.CurrentSizeInChunks) + min = a.WorldOrigin.Negated() + max = min.Added(a.CurrentSize) return } @@ -192,7 +192,7 @@ func (a *Atlas) worldSpaceToChunkWithGrow(v vector.Vector) int { // Calculate the new origin and the new size origin := min - size := a.CurrentSizeInChunks + size := a.CurrentSize // If we need to shift the origin back originDiff := origin.Added(v.Negated()) @@ -216,10 +216,10 @@ func (a *Atlas) worldSpaceToChunkWithGrow(v vector.Vector) int { // Set up the new size and origin newAtlas := Atlas{ - ChunkSize: a.ChunkSize, - WorldOriginInChunkSpace: origin.Negated(), - CurrentSizeInChunks: size, - Chunks: make([]Chunk, size.X*size.Y), + ChunkSize: a.ChunkSize, + WorldOrigin: origin.Negated(), + CurrentSize: size, + Chunks: make([]Chunk, size.X*size.Y), } // Copy all old chunks into the new atlas From 06cf44f12908c55cbdeb1d76b871e0fcad8fa693 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 28 Jun 2020 11:02:56 +0100 Subject: [PATCH 008/228] Increase the chunk size to 1kb per chunk --- cmd/rove-server/internal/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/rove-server/internal/server.go b/cmd/rove-server/internal/server.go index de9d933..5aa7936 100644 --- a/cmd/rove-server/internal/server.go +++ b/cmd/rove-server/internal/server.go @@ -83,7 +83,7 @@ func NewServer(opts ...ServerOption) *Server { address: "", persistence: EphemeralData, schedule: cron.New(), - world: game.NewWorld(16), + world: game.NewWorld(32), } // Apply all options From 0d3aac49b10a16406b920db3ac0c9c1f40ada3a4 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 28 Jun 2020 12:26:51 +0100 Subject: [PATCH 009/228] Don't expose the rove-accountant --- docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 91c69c1..8ecce3d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,8 +9,6 @@ services: context: . dockerfile: Dockerfile image: rove:latest - ports: - - "9091:9091" environment: - PORT=9091 - DATA_PATH=/mnt/rove-server From b9198c546c390e7c6f65603f80869a92f6485a5b Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 28 Jun 2020 12:30:32 +0100 Subject: [PATCH 010/228] Update the status HTTPS makes sense for the docs, but is not essential, the real goal is to have token security --- docs/status.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/status.md b/docs/status.md index 5045f0a..58eabfc 100644 --- a/docs/status.md +++ b/docs/status.md @@ -19,10 +19,9 @@ This page tracks the current feature set and the features to implement next ### Incoming features * Rover replacement and advancement mechanic -* HTTPS +* Account token security ### Stretch goals * Render rover camera view -* Account token security From e09cea328bca6595d49150a7b64a0dbbb89771c2 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 28 Jun 2020 15:52:46 +0100 Subject: [PATCH 011/228] Refactor into singular account in the config --- cmd/rove/main.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 2fc3eab..398feb9 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -42,10 +42,15 @@ func printUsage() { const gRPCport = 9090 +// Account stores data for an account +type Account struct { + Name string `json:"name"` +} + // Config is used to store internal data type Config struct { - Host string `json:"host,omitempty"` - Accounts map[string]string `json:"accounts,omitempty"` + Host string `json:"host,omitempty"` + Account Account `json:"account,omitempty"` } // ConfigPath returns the configuration path @@ -65,7 +70,6 @@ func ConfigPath() string { func LoadConfig() (config Config, err error) { datapath := ConfigPath() - config.Accounts = make(map[string]string) // Create the path if needed path := filepath.Dir(datapath) @@ -136,7 +140,7 @@ func InnerMain(command string, args ...string) error { if len(args) > 0 { config.Host = args[0] } - fmt.Printf("host: %s\taccount: %s\n", config.Host, config.Accounts[config.Host]) + fmt.Printf("host: %s\taccount: %s\n", config.Host, config.Account) return SaveConfig(config) } @@ -173,6 +177,7 @@ func InnerMain(command string, args ...string) error { if len(args) == 0 { return fmt.Errorf("must pass name to 'register'") } + name := args[0] d := rove.RegisterRequest{ Name: name, @@ -184,7 +189,7 @@ func InnerMain(command string, args ...string) error { default: fmt.Printf("Registered account with id: %s\n", name) - config.Accounts[config.Host] = name + config.Account.Name = name } case "commands": @@ -219,7 +224,7 @@ func InnerMain(command string, args ...string) error { } d := rove.CommandsRequest{ - Account: config.Accounts[config.Host], + Account: config.Account.Name, Commands: commands, } @@ -237,7 +242,7 @@ func InnerMain(command string, args ...string) error { } case "radar": - dat := rove.RadarRequest{Account: config.Accounts[config.Host]} + dat := rove.RadarRequest{Account: config.Account.Name} if err := verifyID(dat.Account); err != nil { return err } @@ -253,7 +258,7 @@ func InnerMain(command string, args ...string) error { } case "rover": - req := rove.RoverRequest{Account: config.Accounts[config.Host]} + req := rove.RoverRequest{Account: config.Account.Name} if err := verifyID(req.Account); err != nil { return err } From e3169cdbddeef5761555cc0ea2204df1ae2a0073 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 30 Jun 2020 16:50:16 +0100 Subject: [PATCH 012/228] Update the docs and status pages --- docs/design.md | 51 ++++++++++++++++---------------------------------- docs/status.md | 12 ++++++++---- 2 files changed, 24 insertions(+), 39 deletions(-) diff --git a/docs/design.md b/docs/design.md index 578c5e6..21a14d0 100644 --- a/docs/design.md +++ b/docs/design.md @@ -1,8 +1,7 @@ Rove ===== -An asynchronous nomadic game about exploring a planet as part of a loose -community. +An asynchronous nomadic game about exploring a planet as part of a loose community. ------------------------------------------- @@ -14,61 +13,45 @@ Control a rover on the surface of the planet using a remote control interface. Commands are sent and happen asynchronously, and the rover feeds back information about position and surroundings, as well as photos. -### Goal - -To reach the pole. - ### General -Movement is slow and sometimes dangerous. Hazards damage the rover. +Movement is slow and sometimes dangerous. -Resources can be collected to fix and upgrade the rover. +Resources can be collected, and rovers recharge power during the day. -Rovers recharge power during the day. +Hazards damage the rover. Resources can be spent to repair. -Enough collected resources allow you to create and fire a new rover a significant distance in any direction, losing control of the current one and leaving it dormant. +Spend resources to create and spawn a new improved rover a significant distance away, leaving the current one dormant. -Finding a dormant rover gives you a choice - scrap it to gain minor resources, or fire it a distance just like a new rover, taking control of it. +"Dying" leaves the current rover dormant and assigns the users a new rover. -“Dying” triggers a self destruct and fires a new basic rover in a random direction towards the equator +Players can repair dormant rovers to gain control of them, taking on their improvements and inventory. -## Multiplayer +### Multiplayer -The planet itself and things that happen on it are persistent. Players can view each other, and use very rudimentary signals. +Players can see each other and use very rudimentary signals. -Dormant rovers store full history of travel, owners, and keep damage, improvements and resources. - -Players have no other forms of direct communication. - -Players can view progress of all rovers attached to their name. - -Limit too many players in one location with a simple interference mechanic - only a certain density can exist at once to operate properly, additional players can’t move within range. +Dormant rovers store full history of travel and owners, as well as their improvements and resources. ------------------------------------------- ### Implementation -Two functional parts +* A server that receives the commands, sends out data, and handles interactions between players. -A server that receives the commands, sends out data, and handles interactions between players. - -An app, or apps, that interface with the server to let you control and view rover information +* An app, or apps, that interface with the server to let you control and view rover information ------------------------------------------- ### To Solve -#### What kinds of progression/upgrades exist? -Needs a very simple set of rover internals defined, each of which can be upgraded. +* What kinds of progression/upgrades exist? -#### How does the game encourage lateral movement? -Could simply be the terrain is constructed in very lateral ways, blocking progress frequently +* How does the game encourage cooperation? -#### How does the game encourage cooperation? -How exactly would a time delay mechanic enhance the experience? -Currently it’s just to make the multiplayer easier to use, and to make interactions a little more complicated. The game could limit the number of bytes (commands) you can send over time. +* How would the gameplay prevent griefing? -#### How would the gameplay prevent griefing? +* What drives the exploration? ------------------------------------------- @@ -76,8 +59,6 @@ Currently it’s just to make the multiplayer easier to use, and to make interac Feeling “known for” something - the person who did X thing. Limit number of X things that can be done, possibly over time. -Build up a certain level of knowledge and ownership of a place, but then destroy it or give it up. Or build up a character and then leave it behind. - A significant aspect of failure - failing must be a focus of the game. Winning the game might actually be failing in some specific way. A clear and well defined investment vs. payoff curve. diff --git a/docs/status.md b/docs/status.md index 58eabfc..bf3fea2 100644 --- a/docs/status.md +++ b/docs/status.md @@ -3,7 +3,7 @@ Development status This page tracks the current feature set and the features to implement next -### Complete features +### Current features * Users can register account and spawn rover * Users can command the rover to move @@ -13,15 +13,19 @@ This page tracks the current feature set and the features to implement next * Commands are queued and then are executed in sequence * Rover inventory * Collectable materials -* Rover integrity and damage +* Rover has integrity and takes damage on collisions * Rover can repair ### Incoming features * Rover replacement and advancement mechanic -* Account token security +* Dormant rovers +* Rover energy with solar charging +* Day/night cycle +* More hazards +* Simple rover to rover communication ### Stretch goals * Render rover camera view - +* Account token security \ No newline at end of file From 1f2669b64354065f648937e263b03d6a7032837a Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 30 Jun 2020 17:40:23 +0100 Subject: [PATCH 013/228] Set theme jekyll-theme-merlot --- docs/_config.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/_config.yml diff --git a/docs/_config.yml b/docs/_config.yml new file mode 100644 index 0000000..c50ff38 --- /dev/null +++ b/docs/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-merlot \ No newline at end of file From 77bde53a5272095526d5156ec8716e86593eca38 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 30 Jun 2020 17:41:08 +0100 Subject: [PATCH 014/228] Rename the main design doc --- docs/{design.md => README.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/{design.md => README.md} (100%) diff --git a/docs/design.md b/docs/README.md similarity index 100% rename from docs/design.md rename to docs/README.md From 984ff566644e4b033bd6da7babfbd4b68d96e2cf Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 30 Jun 2020 22:43:53 +0100 Subject: [PATCH 015/228] Add flatpak file, unused but functional --- flatpak/io.github.mdiluz.Rove.json | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 flatpak/io.github.mdiluz.Rove.json diff --git a/flatpak/io.github.mdiluz.Rove.json b/flatpak/io.github.mdiluz.Rove.json new file mode 100644 index 0000000..d206be5 --- /dev/null +++ b/flatpak/io.github.mdiluz.Rove.json @@ -0,0 +1,36 @@ +{ + "app-id": "io.github.mdiluz.Rove", + "runtime": "org.freedesktop.Platform", + "runtime-version": "19.08", + "sdk": "org.freedesktop.Sdk", + "sdk-extensions" : [ + "org.freedesktop.Sdk.Extension.golang" + ], + "finish-args" : [ + "--share=network" + ], + "command": "rove", + "modules": [ + { + "name": "rove", + "buildsystem": "simple", + "build-options": { + "env": { + "GOBIN": "/app/bin/" + }, + "build-args": [ + "--share=network" + ] + }, + "build-commands" : [ + ". /usr/lib/sdk/golang/enable.sh; make install" + ], + "sources": [ + { + "type": "dir", + "path": ".." + } + ] + } + ] +} \ No newline at end of file From abcebcebb6906bd24449b144812fc8aa97ac3763 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 30 Jun 2020 23:34:49 +0100 Subject: [PATCH 016/228] Simplify - remove rove-accountant This was a fun little gRPC experiment but it's simply not needed --- Dockerfile | 1 - Makefile | 2 - cmd/rove-accountant/main.go | 134 ---- cmd/rove-server/internal/routes.go | 23 +- cmd/rove-server/internal/server.go | 36 +- cmd/rove-server/internal/server_test.go | 3 - docker-compose.yml | 17 +- .../internal => pkg/accounts}/accounts.go | 6 +- pkg/accounts/accounts.pb.go | 663 ------------------ .../accounts}/accounts_test.go | 2 +- proto/accounts/accounts.proto | 54 -- snap/snapcraft.yaml | 9 +- 12 files changed, 20 insertions(+), 930 deletions(-) delete mode 100644 cmd/rove-accountant/main.go rename {cmd/rove-accountant/internal => pkg/accounts}/accounts.go (95%) delete mode 100644 pkg/accounts/accounts.pb.go rename {cmd/rove-accountant/internal => pkg/accounts}/accounts_test.go (98%) delete mode 100644 proto/accounts/accounts.proto diff --git a/Dockerfile b/Dockerfile index 7c3e6c1..930ed91 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,6 @@ RUN go mod download # Build the executables RUN go build -o rove-server -ldflags="-X 'github.com/mdiluz/rove/pkg/version.Version=$(git describe --always --long --dirty --tags)'" cmd/rove-server/main.go -RUN go build -o rove-accountant cmd/rove-accountant/main.go RUN go build -o rove-reverse-proxy cmd/rove-reverse-proxy/main.go CMD [ "./rove-server" ] diff --git a/Makefile b/Makefile index 31d0ab3..ac45c79 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,6 @@ install: go install -ldflags="-X 'github.com/mdiluz/rove/pkg/version.Version=${VERSION}'" ./... gen: - @echo Generating accountant gRPC - protoc --proto_path proto --go_out=plugins=grpc:pkg/ --go_opt=paths=source_relative proto/accounts/accounts.proto @echo Generating rove server gRPC protoc --proto_path proto --go_out=plugins=grpc:pkg/ --go_opt=paths=source_relative proto/rove/rove.proto protoc --proto_path proto --grpc-gateway_out=paths=source_relative:pkg/ proto/rove/rove.proto diff --git a/cmd/rove-accountant/main.go b/cmd/rove-accountant/main.go deleted file mode 100644 index e774797..0000000 --- a/cmd/rove-accountant/main.go +++ /dev/null @@ -1,134 +0,0 @@ -package main - -import ( - "context" - "fmt" - "log" - "net" - "os" - "os/signal" - "strconv" - "sync" - "syscall" - - "github.com/mdiluz/rove/cmd/rove-accountant/internal" - "github.com/mdiluz/rove/pkg/accounts" - "github.com/mdiluz/rove/pkg/persistence" - "google.golang.org/grpc" -) - -var data = os.Getenv("DATA_PATH") - -// accountantServer is the internal object to manage the requests -type accountantServer struct { - accountant *internal.Accountant - sync sync.RWMutex -} - -// Register will register an account -func (a *accountantServer) Register(ctx context.Context, in *accounts.RegisterInfo) (*accounts.RegisterResponse, error) { - a.sync.Lock() - defer a.sync.Unlock() - - // Try and register the account itself - log.Printf("Registering account: %s\n", in.Name) - if _, err := a.accountant.RegisterAccount(in.Name); err != nil { - log.Printf("Error: %s\n", err) - return nil, err - } - - // Save out the accounts - if err := persistence.Save("accounts", a.accountant); err != nil { - log.Printf("Error: %s\n", err) - return nil, err - } - - return &accounts.RegisterResponse{}, nil -} - -// AssignData assigns a key value pair to an account -func (a *accountantServer) AssignValue(_ context.Context, in *accounts.DataKeyValue) (*accounts.DataKeyResponse, error) { - a.sync.RLock() - defer a.sync.RUnlock() - - // Try and assign the data - log.Printf("Assigning value for account %s: %s->%s\n", in.Account, in.Key, in.Value) - err := a.accountant.AssignData(in.Account, in.Key, in.Value) - if err != nil { - log.Printf("Error: %s\n", err) - return nil, err - } - - return &accounts.DataKeyResponse{}, nil - -} - -// GetData gets the value for a key -func (a *accountantServer) GetValue(_ context.Context, in *accounts.DataKey) (*accounts.DataResponse, error) { - a.sync.RLock() - defer a.sync.RUnlock() - - // Try and fetch the value - data, err := a.accountant.GetValue(in.Account, in.Key) - if err != nil { - log.Printf("Error: %s\n", err) - return nil, err - } - - return &accounts.DataResponse{Value: data}, nil - -} - -// main -func main() { - // Get the port - var iport int - var port = os.Getenv("PORT") - if len(port) == 0 { - iport = 9091 - } else { - var err error - iport, err = strconv.Atoi(port) - if err != nil { - log.Fatal("$PORT not valid int") - } - } - - persistence.SetPath(data) - - // Initialise and load the accountant - accountant := internal.NewAccountant() - if err := persistence.Load("accounts", accountant); err != nil { - log.Fatalf("failed to load account data: %s", err) - } - - // Set up the RPC server and register - lis, err := net.Listen("tcp", fmt.Sprintf(":%d", iport)) - if err != nil { - log.Fatalf("failed to listen: %v", err) - } - grpcServer := grpc.NewServer() - accounts.RegisterAccountantServer(grpcServer, &accountantServer{ - accountant: accountant, - }) - - // Set up the close handler - c := make(chan os.Signal) - signal.Notify(c, os.Interrupt, syscall.SIGTERM) - go func() { - <-c - log.Println("Quit requested, exiting...") - grpcServer.Stop() - }() - - // Serve the RPC server - log.Printf("Serving accountant on %s\n", port) - if err := grpcServer.Serve(lis); err != nil { - log.Fatalf("failed to serve gRPC: %s", err) - } - - // Save out the accountant data - if err := persistence.Save("accounts", accountant); err != nil { - log.Fatalf("failed to save accounts: %s", err) - } -} diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index f558f00..06cf054 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -4,11 +4,9 @@ import ( "context" "fmt" - "github.com/mdiluz/rove/pkg/accounts" "github.com/mdiluz/rove/pkg/game" "github.com/mdiluz/rove/pkg/rove" "github.com/mdiluz/rove/pkg/version" - "google.golang.org/grpc" ) func (s *Server) Status(context.Context, *rove.StatusRequest) (*rove.StatusResponse, error) { @@ -33,7 +31,7 @@ func (s *Server) Register(ctx context.Context, req *rove.RegisterRequest) (*rove return nil, fmt.Errorf("empty account name") } - if _, err := s.accountant.Register(ctx, &accounts.RegisterInfo{Name: req.Name}, grpc.WaitForReady(true)); err != nil { + if _, err := s.accountant.RegisterAccount(req.Name); err != nil { return nil, err } else if _, err := s.SpawnRoverForAccount(req.Name); err != nil { @@ -51,10 +49,10 @@ func (s *Server) Rover(ctx context.Context, req *rove.RoverRequest) (*rove.Rover if len(req.Account) == 0 { return nil, fmt.Errorf("empty account name") - } else if resp, err := s.accountant.GetValue(ctx, &accounts.DataKey{Account: req.Account, Key: "rover"}); err != nil { - return nil, fmt.Errorf("gRPC failed to contact accountant: %s", err) + } else if resp, err := s.accountant.GetValue(req.Account, "rover"); err != nil { + return nil, err - } else if rover, err := s.world.GetRover(resp.Value); err != nil { + } else if rover, err := s.world.GetRover(resp); err != nil { return nil, fmt.Errorf("error getting rover: %s", err) } else { @@ -79,14 +77,14 @@ func (s *Server) Radar(ctx context.Context, req *rove.RadarRequest) (*rove.Radar response := &rove.RadarResponse{} - resp, err := s.accountant.GetValue(ctx, &accounts.DataKey{Account: req.Account, Key: "rover"}) + resp, err := s.accountant.GetValue(req.Account, "rover") if err != nil { - return nil, fmt.Errorf("gRPC failed to contact accountant: %s", err) + return nil, err - } else if rover, err := s.world.GetRover(resp.Value); err != nil { + } else if rover, err := s.world.GetRover(resp); err != nil { return nil, fmt.Errorf("error getting rover attributes: %s", err) - } else if radar, err := s.world.RadarFromRover(resp.Value); err != nil { + } else if radar, err := s.world.RadarFromRover(resp); err != nil { return nil, fmt.Errorf("error getting radar from rover: %s", err) } else { @@ -101,8 +99,7 @@ func (s *Server) Commands(ctx context.Context, req *rove.CommandsRequest) (*rove if len(req.Account) == 0 { return nil, fmt.Errorf("empty account") } - resp, err := s.accountant.GetValue(ctx, &accounts.DataKey{Account: req.Account, Key: "rover"}) - + resp, err := s.accountant.GetValue(req.Account, "rover") if err != nil { return nil, err } @@ -114,7 +111,7 @@ func (s *Server) Commands(ctx context.Context, req *rove.CommandsRequest) (*rove Command: c.Command}) } - if err := s.world.Enqueue(resp.Value, cmds...); err != nil { + if err := s.world.Enqueue(resp, cmds...); err != nil { return nil, err } diff --git a/cmd/rove-server/internal/server.go b/cmd/rove-server/internal/server.go index 5aa7936..39f13d4 100644 --- a/cmd/rove-server/internal/server.go +++ b/cmd/rove-server/internal/server.go @@ -1,11 +1,9 @@ package internal import ( - "context" "fmt" "log" "net" - "os" "sync" "github.com/mdiluz/rove/pkg/accounts" @@ -30,9 +28,8 @@ type Server struct { // Internal state world *game.World - // Accountant server - accountant accounts.AccountantClient - clientConn *grpc.ClientConn + // Accountant + accountant *accounts.Accountant // gRPC server netListener net.Listener @@ -84,6 +81,7 @@ func NewServer(opts ...ServerOption) *Server { persistence: EphemeralData, schedule: cron.New(), world: game.NewWorld(32), + accountant: accounts.NewAccountant(), } // Apply all options @@ -100,18 +98,6 @@ func (s *Server) Initialise(fillWorld bool) (err error) { // Add to our sync s.sync.Add(1) - // Connect to the accountant - accountantAddress := os.Getenv("ROVE_ACCOUNTANT_GRPC") - if len(accountantAddress) == 0 { - accountantAddress = "localhost:9091" - } - log.Printf("Dialing accountant on %s\n", accountantAddress) - s.clientConn, err = grpc.Dial(accountantAddress, grpc.WithInsecure()) - if err != nil { - return err - } - s.accountant = accounts.NewAccountantClient(s.clientConn) - // Load the world file if err := s.LoadWorld(); err != nil { return err @@ -173,11 +159,6 @@ func (s *Server) Stop() error { // Stop the gRPC s.grpcServ.Stop() - // Close the accountant connection - if err := s.clientConn.Close(); err != nil { - return err - } - return nil } @@ -190,7 +171,7 @@ func (s *Server) Close() error { return s.SaveWorld() } -// Close waits until the server is finished and closes up shop +// StopAndClose waits until the server is finished and closes up shop func (s *Server) StopAndClose() error { // Stop the server if err := s.Stop(); err != nil { @@ -225,19 +206,12 @@ func (s *Server) LoadWorld() error { return nil } -// used as the type for the return struct -type BadRequestError struct { - Error string `json:"error"` -} - // SpawnRoverForAccount spawns the rover rover for an account func (s *Server) SpawnRoverForAccount(account string) (string, error) { if inst, err := s.world.SpawnRover(); err != nil { return "", err - } else { - keyval := accounts.DataKeyValue{Account: account, Key: "rover", Value: inst} - _, err := s.accountant.AssignValue(context.Background(), &keyval) + err := s.accountant.AssignData(account, "rover", inst) if err != nil { log.Printf("Failed to assign rover to account, %s", err) diff --git a/cmd/rove-server/internal/server_test.go b/cmd/rove-server/internal/server_test.go index 1297ec2..36db679 100644 --- a/cmd/rove-server/internal/server_test.go +++ b/cmd/rove-server/internal/server_test.go @@ -1,7 +1,6 @@ package internal import ( - "os" "testing" ) @@ -31,7 +30,6 @@ func TestNewServer_OptionPersistentData(t *testing.T) { } func TestServer_Run(t *testing.T) { - os.Setenv("ROVE_ACCOUNTANT_GRPC", "n/a") server := NewServer() if server == nil { t.Error("Failed to create server") @@ -47,7 +45,6 @@ func TestServer_Run(t *testing.T) { } func TestServer_RunPersistentData(t *testing.T) { - os.Setenv("ROVE_ACCOUNTANT_GRPC", "n/a") server := NewServer(OptionPersistentData()) if server == nil { t.Error("Failed to create server") diff --git a/docker-compose.yml b/docker-compose.yml index 8ecce3d..2a8466d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,18 +4,6 @@ volumes: persistent-data: services: - rove-accountant: - build: - context: . - dockerfile: Dockerfile - image: rove:latest - environment: - - PORT=9091 - - DATA_PATH=/mnt/rove-server - volumes: - - persistent-data:/mnt/rove-server:rw - command: [ ./rove-accountant ] - rove-docs: build: context: . @@ -27,7 +15,6 @@ services: - PORT=80 rove-server: - depends_on: [ rove-accountant ] build: context: . dockerfile: Dockerfile @@ -37,11 +24,10 @@ services: environment: - PORT=9090 - DATA_PATH=/mnt/rove-server - - ROVE_ACCOUNTANT_GRPC=rove-accountant:9091 - WORDS_FILE=data/words_alpha.txt volumes: - persistent-data:/mnt/rove-server:rw - command: [ "./script/wait-for-it.sh", "rove-accountant:9091", "--", "./rove-server"] + command: [ "./rove-server"] rove: depends_on: [ rove-server, rove-docs ] @@ -63,7 +49,6 @@ services: dockerfile: Dockerfile image: rove:latest environment: - - ROVE_ACCOUNTANT_GRPC=rove-accountant:9091 - ROVE_HTTP=rove - ROVE_GRPC=rove-server command: [ "./script/wait-for-it.sh", "rove:8080", "--", "go", "test", "-v", "./...", "--tags=integration", "-cover", "-coverprofile=/mnt/coverage-data/c.out", "-count", "1" ] diff --git a/cmd/rove-accountant/internal/accounts.go b/pkg/accounts/accounts.go similarity index 95% rename from cmd/rove-accountant/internal/accounts.go rename to pkg/accounts/accounts.go index 01e29dc..322b145 100644 --- a/cmd/rove-accountant/internal/accounts.go +++ b/pkg/accounts/accounts.go @@ -1,4 +1,4 @@ -package internal +package accounts import ( "fmt" @@ -16,10 +16,6 @@ type Account struct { Data map[string]string `json:"data"` } -// Represents the accountant data to store -type accountantData struct { -} - // Accountant manages a set of accounts type Accountant struct { Accounts map[string]Account `json:"accounts"` diff --git a/pkg/accounts/accounts.pb.go b/pkg/accounts/accounts.pb.go deleted file mode 100644 index ad19fae..0000000 --- a/pkg/accounts/accounts.pb.go +++ /dev/null @@ -1,663 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.23.0 -// protoc v3.6.1 -// source: accounts/accounts.proto - -package accounts - -import ( - context "context" - proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - -// RegisterInfo contains the information needed to register an account -type RegisterInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The name for the account, must be unique - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *RegisterInfo) Reset() { - *x = RegisterInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_accounts_accounts_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RegisterInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterInfo) ProtoMessage() {} - -func (x *RegisterInfo) ProtoReflect() protoreflect.Message { - mi := &file_accounts_accounts_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RegisterInfo.ProtoReflect.Descriptor instead. -func (*RegisterInfo) Descriptor() ([]byte, []int) { - return file_accounts_accounts_proto_rawDescGZIP(), []int{0} -} - -func (x *RegisterInfo) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -// RegisterResponse is the response information from registering an account -type RegisterResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *RegisterResponse) Reset() { - *x = RegisterResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_accounts_accounts_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RegisterResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterResponse) ProtoMessage() {} - -func (x *RegisterResponse) ProtoReflect() protoreflect.Message { - mi := &file_accounts_accounts_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RegisterResponse.ProtoReflect.Descriptor instead. -func (*RegisterResponse) Descriptor() ([]byte, []int) { - return file_accounts_accounts_proto_rawDescGZIP(), []int{1} -} - -// DataKeyValue represents a simple key value pair to assign to an account -type DataKeyValue struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The account to assign the new key value pair to - Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` - // The key value pair to assign - Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` - Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` -} - -func (x *DataKeyValue) Reset() { - *x = DataKeyValue{} - if protoimpl.UnsafeEnabled { - mi := &file_accounts_accounts_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DataKeyValue) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DataKeyValue) ProtoMessage() {} - -func (x *DataKeyValue) ProtoReflect() protoreflect.Message { - mi := &file_accounts_accounts_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DataKeyValue.ProtoReflect.Descriptor instead. -func (*DataKeyValue) Descriptor() ([]byte, []int) { - return file_accounts_accounts_proto_rawDescGZIP(), []int{2} -} - -func (x *DataKeyValue) GetAccount() string { - if x != nil { - return x.Account - } - return "" -} - -func (x *DataKeyValue) GetKey() string { - if x != nil { - return x.Key - } - return "" -} - -func (x *DataKeyValue) GetValue() string { - if x != nil { - return x.Value - } - return "" -} - -// DataKeyResponse is a simple response -type DataKeyResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *DataKeyResponse) Reset() { - *x = DataKeyResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_accounts_accounts_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DataKeyResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DataKeyResponse) ProtoMessage() {} - -func (x *DataKeyResponse) ProtoReflect() protoreflect.Message { - mi := &file_accounts_accounts_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DataKeyResponse.ProtoReflect.Descriptor instead. -func (*DataKeyResponse) Descriptor() ([]byte, []int) { - return file_accounts_accounts_proto_rawDescGZIP(), []int{3} -} - -// DataKey describes a simple key value with an account, for fetching -type DataKey struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The account to fetch data for - Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` - // The key to fetch - Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` -} - -func (x *DataKey) Reset() { - *x = DataKey{} - if protoimpl.UnsafeEnabled { - mi := &file_accounts_accounts_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DataKey) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DataKey) ProtoMessage() {} - -func (x *DataKey) ProtoReflect() protoreflect.Message { - mi := &file_accounts_accounts_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DataKey.ProtoReflect.Descriptor instead. -func (*DataKey) Descriptor() ([]byte, []int) { - return file_accounts_accounts_proto_rawDescGZIP(), []int{4} -} - -func (x *DataKey) GetAccount() string { - if x != nil { - return x.Account - } - return "" -} - -func (x *DataKey) GetKey() string { - if x != nil { - return x.Key - } - return "" -} - -// DataResponse describes a data fetch response -type DataResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The value of the key - Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` -} - -func (x *DataResponse) Reset() { - *x = DataResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_accounts_accounts_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DataResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DataResponse) ProtoMessage() {} - -func (x *DataResponse) ProtoReflect() protoreflect.Message { - mi := &file_accounts_accounts_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DataResponse.ProtoReflect.Descriptor instead. -func (*DataResponse) Descriptor() ([]byte, []int) { - return file_accounts_accounts_proto_rawDescGZIP(), []int{5} -} - -func (x *DataResponse) GetValue() string { - if x != nil { - return x.Value - } - return "" -} - -var File_accounts_accounts_proto protoreflect.FileDescriptor - -var file_accounts_accounts_proto_rawDesc = []byte{ - 0x0a, 0x17, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x73, 0x22, 0x22, 0x0a, 0x0c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, - 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x12, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x50, 0x0a, 0x0c, 0x44, - 0x61, 0x74, 0x61, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x11, 0x0a, - 0x0f, 0x44, 0x61, 0x74, 0x61, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x35, 0x0a, 0x07, 0x44, 0x61, 0x74, 0x61, 0x4b, 0x65, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x61, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x24, 0x0a, 0x0c, 0x44, 0x61, 0x74, 0x61, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x32, 0xcb, 0x01, - 0x0a, 0x0a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x61, 0x6e, 0x74, 0x12, 0x40, 0x0a, 0x08, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x73, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, - 0x1a, 0x1a, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x52, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x42, - 0x0a, 0x0b, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x16, 0x2e, - 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4b, 0x65, 0x79, - 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x19, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, - 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x37, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x11, - 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4b, 0x65, - 0x79, 0x1a, 0x16, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x44, 0x61, 0x74, - 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x25, 0x5a, 0x23, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, - 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_accounts_accounts_proto_rawDescOnce sync.Once - file_accounts_accounts_proto_rawDescData = file_accounts_accounts_proto_rawDesc -) - -func file_accounts_accounts_proto_rawDescGZIP() []byte { - file_accounts_accounts_proto_rawDescOnce.Do(func() { - file_accounts_accounts_proto_rawDescData = protoimpl.X.CompressGZIP(file_accounts_accounts_proto_rawDescData) - }) - return file_accounts_accounts_proto_rawDescData -} - -var file_accounts_accounts_proto_msgTypes = make([]protoimpl.MessageInfo, 6) -var file_accounts_accounts_proto_goTypes = []interface{}{ - (*RegisterInfo)(nil), // 0: accounts.RegisterInfo - (*RegisterResponse)(nil), // 1: accounts.RegisterResponse - (*DataKeyValue)(nil), // 2: accounts.DataKeyValue - (*DataKeyResponse)(nil), // 3: accounts.DataKeyResponse - (*DataKey)(nil), // 4: accounts.DataKey - (*DataResponse)(nil), // 5: accounts.DataResponse -} -var file_accounts_accounts_proto_depIdxs = []int32{ - 0, // 0: accounts.Accountant.Register:input_type -> accounts.RegisterInfo - 2, // 1: accounts.Accountant.AssignValue:input_type -> accounts.DataKeyValue - 4, // 2: accounts.Accountant.GetValue:input_type -> accounts.DataKey - 1, // 3: accounts.Accountant.Register:output_type -> accounts.RegisterResponse - 3, // 4: accounts.Accountant.AssignValue:output_type -> accounts.DataKeyResponse - 5, // 5: accounts.Accountant.GetValue:output_type -> accounts.DataResponse - 3, // [3:6] is the sub-list for method output_type - 0, // [0:3] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_accounts_accounts_proto_init() } -func file_accounts_accounts_proto_init() { - if File_accounts_accounts_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_accounts_accounts_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RegisterInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_accounts_accounts_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RegisterResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_accounts_accounts_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DataKeyValue); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_accounts_accounts_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DataKeyResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_accounts_accounts_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DataKey); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_accounts_accounts_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DataResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_accounts_accounts_proto_rawDesc, - NumEnums: 0, - NumMessages: 6, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_accounts_accounts_proto_goTypes, - DependencyIndexes: file_accounts_accounts_proto_depIdxs, - MessageInfos: file_accounts_accounts_proto_msgTypes, - }.Build() - File_accounts_accounts_proto = out.File - file_accounts_accounts_proto_rawDesc = nil - file_accounts_accounts_proto_goTypes = nil - file_accounts_accounts_proto_depIdxs = nil -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConnInterface - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 - -// AccountantClient is the client API for Accountant service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type AccountantClient interface { - // Register should create a new account in the database - // It will return an error if the account already exists - Register(ctx context.Context, in *RegisterInfo, opts ...grpc.CallOption) (*RegisterResponse, error) - // AssignValue assigns a key-value pair to an account, or overwrites an existing key - AssignValue(ctx context.Context, in *DataKeyValue, opts ...grpc.CallOption) (*DataKeyResponse, error) - // GetValue will get the value for a key for an account - GetValue(ctx context.Context, in *DataKey, opts ...grpc.CallOption) (*DataResponse, error) -} - -type accountantClient struct { - cc grpc.ClientConnInterface -} - -func NewAccountantClient(cc grpc.ClientConnInterface) AccountantClient { - return &accountantClient{cc} -} - -func (c *accountantClient) Register(ctx context.Context, in *RegisterInfo, opts ...grpc.CallOption) (*RegisterResponse, error) { - out := new(RegisterResponse) - err := c.cc.Invoke(ctx, "/accounts.Accountant/Register", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *accountantClient) AssignValue(ctx context.Context, in *DataKeyValue, opts ...grpc.CallOption) (*DataKeyResponse, error) { - out := new(DataKeyResponse) - err := c.cc.Invoke(ctx, "/accounts.Accountant/AssignValue", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *accountantClient) GetValue(ctx context.Context, in *DataKey, opts ...grpc.CallOption) (*DataResponse, error) { - out := new(DataResponse) - err := c.cc.Invoke(ctx, "/accounts.Accountant/GetValue", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// AccountantServer is the server API for Accountant service. -type AccountantServer interface { - // Register should create a new account in the database - // It will return an error if the account already exists - Register(context.Context, *RegisterInfo) (*RegisterResponse, error) - // AssignValue assigns a key-value pair to an account, or overwrites an existing key - AssignValue(context.Context, *DataKeyValue) (*DataKeyResponse, error) - // GetValue will get the value for a key for an account - GetValue(context.Context, *DataKey) (*DataResponse, error) -} - -// UnimplementedAccountantServer can be embedded to have forward compatible implementations. -type UnimplementedAccountantServer struct { -} - -func (*UnimplementedAccountantServer) Register(context.Context, *RegisterInfo) (*RegisterResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") -} -func (*UnimplementedAccountantServer) AssignValue(context.Context, *DataKeyValue) (*DataKeyResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AssignValue not implemented") -} -func (*UnimplementedAccountantServer) GetValue(context.Context, *DataKey) (*DataResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetValue not implemented") -} - -func RegisterAccountantServer(s *grpc.Server, srv AccountantServer) { - s.RegisterService(&_Accountant_serviceDesc, srv) -} - -func _Accountant_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RegisterInfo) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AccountantServer).Register(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/accounts.Accountant/Register", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AccountantServer).Register(ctx, req.(*RegisterInfo)) - } - return interceptor(ctx, in, info, handler) -} - -func _Accountant_AssignValue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DataKeyValue) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AccountantServer).AssignValue(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/accounts.Accountant/AssignValue", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AccountantServer).AssignValue(ctx, req.(*DataKeyValue)) - } - return interceptor(ctx, in, info, handler) -} - -func _Accountant_GetValue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DataKey) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AccountantServer).GetValue(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/accounts.Accountant/GetValue", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AccountantServer).GetValue(ctx, req.(*DataKey)) - } - return interceptor(ctx, in, info, handler) -} - -var _Accountant_serviceDesc = grpc.ServiceDesc{ - ServiceName: "accounts.Accountant", - HandlerType: (*AccountantServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Register", - Handler: _Accountant_Register_Handler, - }, - { - MethodName: "AssignValue", - Handler: _Accountant_AssignValue_Handler, - }, - { - MethodName: "GetValue", - Handler: _Accountant_GetValue_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "accounts/accounts.proto", -} diff --git a/cmd/rove-accountant/internal/accounts_test.go b/pkg/accounts/accounts_test.go similarity index 98% rename from cmd/rove-accountant/internal/accounts_test.go rename to pkg/accounts/accounts_test.go index 8ac3315..893c57d 100644 --- a/cmd/rove-accountant/internal/accounts_test.go +++ b/pkg/accounts/accounts_test.go @@ -1,4 +1,4 @@ -package internal +package accounts import ( "testing" diff --git a/proto/accounts/accounts.proto b/proto/accounts/accounts.proto deleted file mode 100644 index 50f0dd6..0000000 --- a/proto/accounts/accounts.proto +++ /dev/null @@ -1,54 +0,0 @@ -syntax = "proto3"; - -option go_package = "github.com/mdiluz/rove/pkg/accounts"; - -package accounts; - -service Accountant { - // Register should create a new account in the database - // It will return an error if the account already exists - rpc Register(RegisterInfo) returns (RegisterResponse) {} - - // AssignValue assigns a key-value pair to an account, or overwrites an existing key - rpc AssignValue(DataKeyValue) returns (DataKeyResponse) {} - - // GetValue will get the value for a key for an account - rpc GetValue(DataKey) returns (DataResponse) {} -} - -// RegisterInfo contains the information needed to register an account -message RegisterInfo { - // The name for the account, must be unique - string name = 1; -} - -// RegisterResponse is the response information from registering an account -message RegisterResponse {} - -// DataKeyValue represents a simple key value pair to assign to an account -message DataKeyValue { - // The account to assign the new key value pair to - string account = 1; - - // The key value pair to assign - string key = 2; - string value = 3; -} - -// DataKeyResponse is a simple response -message DataKeyResponse {} - -// DataKey describes a simple key value with an account, for fetching -message DataKey { - // The account to fetch data for - string account = 1; - - // The key to fetch - string key = 2; -} - -// DataResponse describes a data fetch response -message DataResponse { - // The value of the key - string value = 3; -} diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 27bbb85..c9384d2 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -18,6 +18,7 @@ apps: - network environment: ROVE_USER_DATA: $SNAP_USER_DATA + rove-server: command: bin/rove-server plugs: @@ -26,13 +27,7 @@ apps: environment: WORDS_FILE : "$SNAP/data/words_alpha.txt" DATA_PATH : $SNAP_USER_DATA - rove-accountant: - command: bin/rove-accountant - plugs: - - network - - network-bind - environment: - DATA_PATH : $SNAP_USER_DATA + rove-rest-server: command: bin/rove-reverse-proxy plugs: From 204c78610305eda1e7b18628867a88b25fad30bf Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 30 Jun 2020 23:37:38 +0100 Subject: [PATCH 017/228] Rename rove-reverse-proxy to rove-server-rest-proxy --- Dockerfile | 2 +- cmd/{rove-reverse-proxy => rove-server-rest-proxy}/http_test.go | 0 cmd/{rove-reverse-proxy => rove-server-rest-proxy}/main.go | 0 docker-compose.yml | 2 +- snap/snapcraft.yaml | 2 +- 5 files changed, 3 insertions(+), 3 deletions(-) rename cmd/{rove-reverse-proxy => rove-server-rest-proxy}/http_test.go (100%) rename cmd/{rove-reverse-proxy => rove-server-rest-proxy}/main.go (100%) diff --git a/Dockerfile b/Dockerfile index 930ed91..727efa4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ RUN go mod download # Build the executables RUN go build -o rove-server -ldflags="-X 'github.com/mdiluz/rove/pkg/version.Version=$(git describe --always --long --dirty --tags)'" cmd/rove-server/main.go -RUN go build -o rove-reverse-proxy cmd/rove-reverse-proxy/main.go +RUN go build -o rove-server-rest-proxy cmd/rove-server-rest-proxy/main.go CMD [ "./rove-server" ] diff --git a/cmd/rove-reverse-proxy/http_test.go b/cmd/rove-server-rest-proxy/http_test.go similarity index 100% rename from cmd/rove-reverse-proxy/http_test.go rename to cmd/rove-server-rest-proxy/http_test.go diff --git a/cmd/rove-reverse-proxy/main.go b/cmd/rove-server-rest-proxy/main.go similarity index 100% rename from cmd/rove-reverse-proxy/main.go rename to cmd/rove-server-rest-proxy/main.go diff --git a/docker-compose.yml b/docker-compose.yml index 2a8466d..96b1ecd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -40,7 +40,7 @@ services: environment: - PORT=8080 - ROVE_GRPC=rove-server:9090 - command: [ "./script/wait-for-it.sh", "rove-server:9090", "--", "./rove-reverse-proxy" ] + command: [ "./script/wait-for-it.sh", "rove-server:9090", "--", "./rove-server-rest-proxy" ] rove-tests: depends_on: [ rove ] diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index c9384d2..fb83f33 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -29,7 +29,7 @@ apps: DATA_PATH : $SNAP_USER_DATA rove-rest-server: - command: bin/rove-reverse-proxy + command: bin/rove-server-rest-proxy plugs: - network - network-bind From b5707ab71c6ce148f6f302f4f35ccbe43cedb441 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 30 Jun 2020 23:59:58 +0100 Subject: [PATCH 018/228] Fix all go vet issues --- cmd/rove-server/internal/routes.go | 5 + cmd/rove-server/internal/server.go | 31 ++-- cmd/rove-server/main.go | 1 + pkg/accounts/accounts.go | 12 +- pkg/atlas/atlas.go | 12 +- pkg/bearing/bearing.go | 8 + pkg/game/command.go | 6 +- pkg/game/world.go | 259 +++++++++++++++-------------- pkg/maths/maths.go | 2 +- pkg/objects/objects.go | 15 +- pkg/persistence/persistence.go | 11 +- pkg/vector/vector.go | 2 +- pkg/version/version.go | 1 + 13 files changed, 195 insertions(+), 170 deletions(-) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 06cf054..4fdf92c 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -9,6 +9,7 @@ import ( "github.com/mdiluz/rove/pkg/version" ) +// Status returns the status of the current server to a gRPC request func (s *Server) Status(context.Context, *rove.StatusRequest) (*rove.StatusResponse, error) { response := &rove.StatusResponse{ Ready: true, @@ -26,6 +27,7 @@ func (s *Server) Status(context.Context, *rove.StatusRequest) (*rove.StatusRespo return response, nil } +// Register registers a new account for a gRPC request func (s *Server) Register(ctx context.Context, req *rove.RegisterRequest) (*rove.RegisterResponse, error) { if len(req.Name) == 0 { return nil, fmt.Errorf("empty account name") @@ -44,6 +46,7 @@ func (s *Server) Register(ctx context.Context, req *rove.RegisterRequest) (*rove return &rove.RegisterResponse{}, nil } +// Rover returns rover information for a gRPC request func (s *Server) Rover(ctx context.Context, req *rove.RoverRequest) (*rove.RoverResponse, error) { response := &rove.RoverResponse{} if len(req.Account) == 0 { @@ -70,6 +73,7 @@ func (s *Server) Rover(ctx context.Context, req *rove.RoverRequest) (*rove.Rover return response, nil } +// Radar returns the radar information for a rover func (s *Server) Radar(ctx context.Context, req *rove.RadarRequest) (*rove.RadarResponse, error) { if len(req.Account) == 0 { return nil, fmt.Errorf("empty account name") @@ -95,6 +99,7 @@ func (s *Server) Radar(ctx context.Context, req *rove.RadarRequest) (*rove.Radar return response, nil } +// Commands issues commands to the world based on a gRPC request func (s *Server) Commands(ctx context.Context, req *rove.CommandsRequest) (*rove.CommandsResponse, error) { if len(req.Account) == 0 { return nil, fmt.Errorf("empty account") diff --git a/cmd/rove-server/internal/server.go b/cmd/rove-server/internal/server.go index 39f13d4..5f918d4 100644 --- a/cmd/rove-server/internal/server.go +++ b/cmd/rove-server/internal/server.go @@ -208,21 +208,22 @@ func (s *Server) LoadWorld() error { // SpawnRoverForAccount spawns the rover rover for an account func (s *Server) SpawnRoverForAccount(account string) (string, error) { - if inst, err := s.world.SpawnRover(); err != nil { + inst, err := s.world.SpawnRover() + if err != nil { return "", err - } else { - err := s.accountant.AssignData(account, "rover", inst) - if err != nil { - log.Printf("Failed to assign rover to account, %s", err) - - // Try and clear up the rover - if err := s.world.DestroyRover(inst); err != nil { - log.Printf("Failed to destroy rover after failed rover assign: %s", err) - } - - return "", err - } else { - return inst, nil - } } + + err = s.accountant.AssignData(account, "rover", inst) + if err != nil { + log.Printf("Failed to assign rover to account, %s", err) + + // Try and clear up the rover + if err := s.world.DestroyRover(inst); err != nil { + log.Printf("Failed to destroy rover after failed rover assign: %s", err) + } + + return "", err + } + + return inst, nil } diff --git a/cmd/rove-server/main.go b/cmd/rove-server/main.go index abd0a53..ef1d675 100644 --- a/cmd/rove-server/main.go +++ b/cmd/rove-server/main.go @@ -24,6 +24,7 @@ var data = os.Getenv("DATA_PATH") // The tick rate of the server in seconds var tick = os.Getenv("TICK_RATE") +// InnerMain is our main function so tests can run it func InnerMain() { // Ensure we've seeded rand rand.Seed(time.Now().UTC().UnixNano()) diff --git a/pkg/accounts/accounts.go b/pkg/accounts/accounts.go index 322b145..3e810fa 100644 --- a/pkg/accounts/accounts.go +++ b/pkg/accounts/accounts.go @@ -5,8 +5,6 @@ import ( "time" ) -const kAccountsFileName = "rove-accounts.json" - // Account represents a registered user type Account struct { // Name simply describes the account and must be unique @@ -51,7 +49,7 @@ func (a *Accountant) RegisterAccount(name string) (acc Account, err error) { return } -// AssignRover assigns data to an account +// AssignData assigns data to an account func (a *Accountant) AssignData(account string, key string, value string) error { // Find the account matching the ID @@ -65,12 +63,12 @@ func (a *Accountant) AssignData(account string, key string, value string) error return nil } -// GetRover gets the rover rover for the account +// GetValue gets the rover rover for the account func (a *Accountant) GetValue(account string, key string) (string, error) { // Find the account matching the ID - if this, ok := a.Accounts[account]; !ok { + this, ok := a.Accounts[account] + if !ok { return "", fmt.Errorf("no account found for id: %s", account) - } else { - return this.Data[key], nil } + return this.Data[key], nil } diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index 0c692d3..f7d1fe1 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -72,15 +72,15 @@ func (a *Atlas) SetTile(v vector.Vector, tile byte) { } local := a.worldSpaceToChunkLocal(v) - tileId := local.X + local.Y*a.ChunkSize + tileID := local.X + local.Y*a.ChunkSize // Sanity check - if tileId >= len(chunk.Tiles) || tileId < 0 { + if tileID >= len(chunk.Tiles) || tileID < 0 { log.Fatalf("Local tileID is not in valid chunk, somehow, this means something is very wrong") } // Set the chunk back - chunk.Tiles[tileId] = tile + chunk.Tiles[tileID] = tile a.Chunks[c] = chunk } @@ -94,14 +94,14 @@ func (a *Atlas) GetTile(v vector.Vector) byte { } local := a.worldSpaceToChunkLocal(v) - tileId := local.X + local.Y*a.ChunkSize + tileID := local.X + local.Y*a.ChunkSize // Sanity check - if tileId >= len(chunk.Tiles) || tileId < 0 { + if tileID >= len(chunk.Tiles) || tileID < 0 { log.Fatalf("Local tileID is not in valid chunk, somehow, this means something is very wrong") } - return chunk.Tiles[tileId] + return chunk.Tiles[tileID] } // worldSpaceToChunkLocal gets a chunk local coordinate for a tile diff --git a/pkg/bearing/bearing.go b/pkg/bearing/bearing.go index 6eec327..62053f2 100644 --- a/pkg/bearing/bearing.go +++ b/pkg/bearing/bearing.go @@ -11,13 +11,21 @@ import ( type Bearing int const ( + // North describes a 0,1 vector North Bearing = iota + // NorthEast describes a 1,1 vector NorthEast + // East describes a 1,0 vector East + // SouthEast describes a 1,-1 vector SouthEast + // South describes a 0,-1 vector South + // SouthWest describes a -1,-1 vector SouthWest + // West describes a -1,0 vector West + // NorthWest describes a -1,1 vector NorthWest ) diff --git a/pkg/game/command.go b/pkg/game/command.go index 2a5f875..cde071e 100644 --- a/pkg/game/command.go +++ b/pkg/game/command.go @@ -1,13 +1,13 @@ package game const ( - // Moves the rover in the chosen bearing + // CommandMove Moves the rover in the chosen bearing CommandMove = "move" - // Will attempt to stash the object at the current location + // CommandStash Will attempt to stash the object at the current location CommandStash = "stash" - // Will attempt to repair the rover with an inventory object + // CommandRepair Will attempt to repair the rover with an inventory object CommandRepair = "repair" ) diff --git a/pkg/game/world.go b/pkg/game/world.go index 6b04594..3e9128b 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -124,25 +124,26 @@ func (w *World) GetRover(rover string) (Rover, error) { w.worldMutex.RLock() defer w.worldMutex.RUnlock() - if i, ok := w.Rovers[rover]; ok { - return i, nil - } else { + i, ok := w.Rovers[rover] + if !ok { return Rover{}, fmt.Errorf("Failed to find rover with name: %s", rover) } + return i, nil } -// Removes an rover from the game +// DestroyRover Removes an rover from the game func (w *World) DestroyRover(rover string) error { w.worldMutex.Lock() defer w.worldMutex.Unlock() - if i, ok := w.Rovers[rover]; ok { - // Clear the tile - w.Atlas.SetTile(i.Pos, objects.Empty) - delete(w.Rovers, rover) - } else { + i, ok := w.Rovers[rover] + if !ok { return fmt.Errorf("no rover matching id") } + + // Clear the tile + w.Atlas.SetTile(i.Pos, objects.Empty) + delete(w.Rovers, rover) return nil } @@ -151,11 +152,11 @@ func (w *World) RoverPosition(rover string) (vector.Vector, error) { w.worldMutex.RLock() defer w.worldMutex.RUnlock() - if i, ok := w.Rovers[rover]; ok { - return i.Pos, nil - } else { + i, ok := w.Rovers[rover] + if !ok { return vector.Vector{}, fmt.Errorf("no rover matching id") } + return i.Pos, nil } // SetRoverPosition sets the position of the rover @@ -163,13 +164,14 @@ func (w *World) SetRoverPosition(rover string, pos vector.Vector) error { w.worldMutex.Lock() defer w.worldMutex.Unlock() - if i, ok := w.Rovers[rover]; ok { - i.Pos = pos - w.Rovers[rover] = i - return nil - } else { + i, ok := w.Rovers[rover] + if !ok { return fmt.Errorf("no rover matching id") } + + i.Pos = pos + w.Rovers[rover] = i + return nil } // RoverInventory returns the inventory of a requested rover @@ -177,11 +179,11 @@ func (w *World) RoverInventory(rover string) ([]byte, error) { w.worldMutex.RLock() defer w.worldMutex.RUnlock() - if i, ok := w.Rovers[rover]; ok { - return i.Inventory, nil - } else { + i, ok := w.Rovers[rover] + if !ok { return nil, fmt.Errorf("no rover matching id") } + return i.Inventory, nil } // WarpRover sets an rovers position @@ -189,55 +191,55 @@ func (w *World) WarpRover(rover string, pos vector.Vector) error { w.worldMutex.Lock() defer w.worldMutex.Unlock() - if i, ok := w.Rovers[rover]; ok { - // Nothing to do if these positions match - if i.Pos == pos { - return nil - } - - // Check the tile is not blocked - tile := w.Atlas.GetTile(pos) - if objects.IsBlocking(tile) { - return fmt.Errorf("can't warp rover to occupied tile, check before warping") - } - - i.Pos = pos - w.Rovers[rover] = i - return nil - } else { + i, ok := w.Rovers[rover] + if !ok { return fmt.Errorf("no rover matching id") } + // Nothing to do if these positions match + if i.Pos == pos { + return nil + } + + // Check the tile is not blocked + tile := w.Atlas.GetTile(pos) + if objects.IsBlocking(tile) { + return fmt.Errorf("can't warp rover to occupied tile, check before warping") + } + + i.Pos = pos + w.Rovers[rover] = i + return nil } -// SetPosition sets an rovers position +// MoveRover attempts to move a rover in a specific direction func (w *World) MoveRover(rover string, b bearing.Bearing) (vector.Vector, error) { w.worldMutex.Lock() defer w.worldMutex.Unlock() - if i, ok := w.Rovers[rover]; ok { - // Try the new move position - newPos := i.Pos.Added(b.Vector()) - - // Get the tile and verify it's empty - tile := w.Atlas.GetTile(newPos) - if !objects.IsBlocking(tile) { - // Perform the move - i.Pos = newPos - w.Rovers[rover] = i - } else { - // If it is a blocking tile, reduce the rover integrity - i.Integrity = i.Integrity - 1 - if i.Integrity == 0 { - // TODO: The rover needs to be left dormant with the player - } else { - w.Rovers[rover] = i - } - } - - return i.Pos, nil - } else { + i, ok := w.Rovers[rover] + if !ok { return vector.Vector{}, fmt.Errorf("no rover matching id") } + // Try the new move position + newPos := i.Pos.Added(b.Vector()) + + // Get the tile and verify it's empty + tile := w.Atlas.GetTile(newPos) + if !objects.IsBlocking(tile) { + // Perform the move + i.Pos = newPos + w.Rovers[rover] = i + } else { + // If it is a blocking tile, reduce the rover integrity + i.Integrity = i.Integrity - 1 + if i.Integrity == 0 { + // TODO: The rover needs to be left dormant with the player + } else { + w.Rovers[rover] = i + } + } + + return i.Pos, nil } // RoverStash will stash an item at the current rovers position @@ -245,20 +247,20 @@ func (w *World) RoverStash(rover string) (byte, error) { w.worldMutex.Lock() defer w.worldMutex.Unlock() - if r, ok := w.Rovers[rover]; ok { - tile := w.Atlas.GetTile(r.Pos) - if objects.IsStashable(tile) { - r.Inventory = append(r.Inventory, tile) - w.Rovers[rover] = r - w.Atlas.SetTile(r.Pos, objects.Empty) - return tile, nil - } - - } else { + r, ok := w.Rovers[rover] + if !ok { return objects.Empty, fmt.Errorf("no rover matching id") } - return objects.Empty, nil + tile := w.Atlas.GetTile(r.Pos) + if !objects.IsStashable(tile) { + return objects.Empty, nil + } + + r.Inventory = append(r.Inventory, tile) + w.Rovers[rover] = r + w.Atlas.SetTile(r.Pos, objects.Empty) + return tile, nil } // RadarFromRover can be used to query what a rover can currently see @@ -266,57 +268,58 @@ func (w *World) RadarFromRover(rover string) ([]byte, error) { w.worldMutex.RLock() defer w.worldMutex.RUnlock() - if r, ok := w.Rovers[rover]; ok { - // The radar should span in range direction on each axis, plus the row/column the rover is currently on - radarSpan := (r.Range * 2) + 1 - roverPos := r.Pos - - // Get the radar min and max values - radarMin := vector.Vector{ - X: roverPos.X - r.Range, - Y: roverPos.Y - r.Range, - } - radarMax := vector.Vector{ - X: roverPos.X + r.Range, - Y: roverPos.Y + r.Range, - } - - // Gather up all tiles within the range - var radar = make([]byte, radarSpan*radarSpan) - for j := radarMin.Y; j <= radarMax.Y; j++ { - for i := radarMin.X; i <= radarMax.X; i++ { - q := vector.Vector{X: i, Y: j} - - tile := w.Atlas.GetTile(q) - - // Get the position relative to the bottom left of the radar - relative := q.Added(radarMin.Negated()) - index := relative.X + relative.Y*radarSpan - radar[index] = tile - - } - } - - // Add all rovers to the radar - for _, r := range w.Rovers { - // If the rover is in range - dist := r.Pos.Added(roverPos.Negated()) - dist = dist.Abs() - - if dist.X <= r.Range && dist.Y <= r.Range { - relative := r.Pos.Added(radarMin.Negated()) - index := relative.X + relative.Y*radarSpan - radar[index] = objects.Rover - } - } - - // Add this rover - radar[len(radar)/2] = objects.Rover - - return radar, nil - } else { + r, ok := w.Rovers[rover] + if !ok { return nil, fmt.Errorf("no rover matching id") } + + // The radar should span in range direction on each axis, plus the row/column the rover is currently on + radarSpan := (r.Range * 2) + 1 + roverPos := r.Pos + + // Get the radar min and max values + radarMin := vector.Vector{ + X: roverPos.X - r.Range, + Y: roverPos.Y - r.Range, + } + radarMax := vector.Vector{ + X: roverPos.X + r.Range, + Y: roverPos.Y + r.Range, + } + + // Gather up all tiles within the range + var radar = make([]byte, radarSpan*radarSpan) + for j := radarMin.Y; j <= radarMax.Y; j++ { + for i := radarMin.X; i <= radarMax.X; i++ { + q := vector.Vector{X: i, Y: j} + + tile := w.Atlas.GetTile(q) + + // Get the position relative to the bottom left of the radar + relative := q.Added(radarMin.Negated()) + index := relative.X + relative.Y*radarSpan + radar[index] = tile + + } + } + + // Add all rovers to the radar + for _, r := range w.Rovers { + // If the rover is in range + dist := r.Pos.Added(roverPos.Negated()) + dist = dist.Abs() + + if dist.X <= r.Range && dist.Y <= r.Range { + relative := r.Pos.Added(radarMin.Negated()) + index := relative.X + relative.Y*radarSpan + radar[index] = objects.Rover + } + } + + // Add this rover + radar[len(radar)/2] = objects.Rover + + return radar, nil } // Enqueue will queue the commands given @@ -362,7 +365,7 @@ func (w *World) EnqueueAllIncoming() { w.Incoming = make(map[string]CommandStream) } -// Execute will execute any commands in the current command queue +// ExecuteCommandQueues will execute any commands in the current command queue func (w *World) ExecuteCommandQueues() { w.cmdMutex.Lock() defer w.cmdMutex.Unlock() @@ -408,15 +411,15 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { } case CommandRepair: - if r, err := w.GetRover(rover); err != nil { + r, err := w.GetRover(rover) + if err != nil { return err - } else { - // Consume an inventory item to repair - if len(r.Inventory) > 0 { - r.Inventory = r.Inventory[:len(r.Inventory)-1] - r.Integrity = r.Integrity + 1 - w.Rovers[rover] = r - } + } + // Consume an inventory item to repair + if len(r.Inventory) > 0 { + r.Inventory = r.Inventory[:len(r.Inventory)-1] + r.Integrity = r.Integrity + 1 + w.Rovers[rover] = r } default: return fmt.Errorf("unknown command: %s", c.Command) diff --git a/pkg/maths/maths.go b/pkg/maths/maths.go index 7e1d0fc..76c00a5 100644 --- a/pkg/maths/maths.go +++ b/pkg/maths/maths.go @@ -8,7 +8,7 @@ func Abs(x int) int { return x } -// pmod is a mositive modulo +// Pmod is a mositive modulo // golang's % is a "remainder" function si misbehaves for negative modulus inputs func Pmod(x, d int) int { if x == 0 || d == 0 { diff --git a/pkg/objects/objects.go b/pkg/objects/objects.go index 2f509c6..e553a1c 100644 --- a/pkg/objects/objects.go +++ b/pkg/objects/objects.go @@ -1,13 +1,20 @@ package objects const ( - Empty = byte(' ') - Rover = byte('R') + // Empty represents an non-existant object + Empty = byte(' ') + + // Rover represents a live rover + Rover = byte('R') + + // SmallRock is a small stashable rock SmallRock = byte('o') + + // LargeRock is a large blocking rock LargeRock = byte('O') ) -// Check if an object is a blocking object +// IsBlocking checks if an object is a blocking object func IsBlocking(object byte) bool { var blocking = [...]byte{ Rover, @@ -22,7 +29,7 @@ func IsBlocking(object byte) bool { return false } -// Check if an object is stashable +// IsStashable checks if an object is stashable func IsStashable(object byte) bool { var stashable = [...]byte{ SmallRock, diff --git a/pkg/persistence/persistence.go b/pkg/persistence/persistence.go index 8bb2e9d..fbe57b0 100644 --- a/pkg/persistence/persistence.go +++ b/pkg/persistence/persistence.go @@ -31,12 +31,13 @@ func jsonPath(name string) string { // Save will serialise the interface into a json file func Save(name string, data interface{}) error { p := jsonPath(name) - if b, err := json.MarshalIndent(data, "", " "); err != nil { + b, err := json.MarshalIndent(data, "", " ") + if err != nil { + return err + } + + if err := ioutil.WriteFile(p, b, os.ModePerm); err != nil { return err - } else { - if err := ioutil.WriteFile(p, b, os.ModePerm); err != nil { - return err - } } log.Printf("Saved %s\n", p) diff --git a/pkg/vector/vector.go b/pkg/vector/vector.go index 61efc97..b661d17 100644 --- a/pkg/vector/vector.go +++ b/pkg/vector/vector.go @@ -60,7 +60,7 @@ func Min(v1 Vector, v2 Vector) Vector { return Vector{maths.Min(v1.X, v2.X), maths.Min(v1.Y, v2.Y)} } -// Min returns the max values in both vectors +// Max returns the max values in both vectors func Max(v1 Vector, v2 Vector) Vector { return Vector{maths.Max(v1.X, v2.X), maths.Max(v1.Y, v2.Y)} } diff --git a/pkg/version/version.go b/pkg/version/version.go index b8b26bb..0daefb3 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -1,3 +1,4 @@ package version +// Version represents a version to be overrided with -ldflags var Version = "undefined" From 13482c189309efec5f414ab1debb778f2f562754 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 1 Jul 2020 13:19:01 +0100 Subject: [PATCH 019/228] Add a docker build action Created from workflow template --- .github/workflows/docker.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..855a4d6 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,18 @@ +name: Build and Push Docker + +on: + push: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build the Docker image + run: | + VERSION=$(git describe --always --long --dirty --tags) + docker login docker.pkg.github.com -p ${{ secrets.GITHUB_TOKEN }} + docker build . --tag rove:$VERSION --tag rove:latest + docker push docker.pkg.github.com/mdiluz/rove/rove:$VERSION + docker push docker.pkg.github.com/mdiluz/rove/rove:latest From c0726a2345d64ec878982a2d70fdcdd14be5990f Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 1 Jul 2020 13:19:50 +0100 Subject: [PATCH 020/228] Rename the tests file --- .github/workflows/{docker-image.yml => tests.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{docker-image.yml => tests.yml} (97%) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/tests.yml similarity index 97% rename from .github/workflows/docker-image.yml rename to .github/workflows/tests.yml index 20dc273..04b2ba8 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -name: Build and Test +name: Tests on: push: From 821c83549b277c05b01e9842a286ac450e214acc Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 1 Jul 2020 13:20:11 +0100 Subject: [PATCH 021/228] Rename the docker action --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 855a4d6..f8cf0e0 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,4 +1,4 @@ -name: Build and Push Docker +name: Docker on: push: From e6bfc7a8fc9b42535caddf4ed71432354738a99b Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 1 Jul 2020 13:23:05 +0100 Subject: [PATCH 022/228] Set up Github docker auth --- .github/workflows/docker.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f8cf0e0..2126419 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -9,10 +9,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + + - name: Docker Login + uses: azure/docker-login@v1 + with: + login-server: docker.pkg.github.com + username: $GITHUB_ACTOR + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build the Docker image run: | VERSION=$(git describe --always --long --dirty --tags) - docker login docker.pkg.github.com -p ${{ secrets.GITHUB_TOKEN }} - docker build . --tag rove:$VERSION --tag rove:latest + docker build . --tag docker.pkg.github.com/mdiluz/rove/rove:$VERSION --tag docker.pkg.github.com/mdiluz/rove/rove:latest docker push docker.pkg.github.com/mdiluz/rove/rove:$VERSION docker push docker.pkg.github.com/mdiluz/rove/rove:latest From 74dcae654236b4e2e46bbe403651b941e2ab351e Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 1 Jul 2020 13:46:39 +0100 Subject: [PATCH 023/228] Fix badges --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fa4b149..562a4bf 100644 --- a/README.md +++ b/README.md @@ -9,5 +9,5 @@ See [api.go](https://github.com/mdiluz/rove/blob/master/pkg/rove/api.go) for the Build Status ------------ -![Build and Test](https://github.com/mdiluz/rove/workflows/Build%20and%20Test/badge.svg) [![rove](https://snapcraft.io//rove/badge.svg)](https://snapcraft.io/rove) +![Tests](https://github.com/mdiluz/rove/workflows/Tests/badge.svg) ![Docker](https://github.com/mdiluz/rove/workflows/Docker/badge.svg) [![rove](https://snapcraft.io//rove/badge.svg)](https://snapcraft.io/rove) From 062f9cfec8bc7cca4a60dca2bbac1e13de8da8d3 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 3 Jul 2020 17:00:04 +0100 Subject: [PATCH 024/228] Split Atlas chunks into tiles and objects --- cmd/rove-server-rest-proxy/http_test.go | 1 + cmd/rove-server/internal/routes.go | 10 +- pkg/atlas/atlas.go | 141 ++++++++++++++++-------- pkg/atlas/atlas_test.go | 44 +++++--- pkg/game/rover.go | 3 +- pkg/game/world.go | 62 ++++++----- pkg/game/world_test.go | 29 +++-- pkg/objects/objects.go | 31 ++++-- pkg/rove/rove.pb.go | 122 +++++++++++--------- pkg/rove/rove.swagger.json | 7 +- proto/rove/rove.proto | 3 + 11 files changed, 284 insertions(+), 169 deletions(-) diff --git a/cmd/rove-server-rest-proxy/http_test.go b/cmd/rove-server-rest-proxy/http_test.go index 995c380..ba55fb9 100644 --- a/cmd/rove-server-rest-proxy/http_test.go +++ b/cmd/rove-server-rest-proxy/http_test.go @@ -108,6 +108,7 @@ func TestServer_Radar(t *testing.T) { assert.NotZero(t, resp.Range, "Radar should return valid range") w := int(resp.Range*2 + 1) assert.Equal(t, w*w, len(resp.Tiles), "radar should return correct number of tiles") + assert.Equal(t, w*w, len(resp.Objects), "radar should return correct number of objects") } func TestServer_Rover(t *testing.T) { diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 4fdf92c..04641bc 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -59,6 +59,11 @@ func (s *Server) Rover(ctx context.Context, req *rove.RoverRequest) (*rove.Rover return nil, fmt.Errorf("error getting rover: %s", err) } else { + var inv []byte + for _, i := range rover.Inventory { + inv = append(inv, byte(i.Type)) + } + response = &rove.RoverResponse{ Name: rover.Name, Position: &rove.Vector{ @@ -66,7 +71,7 @@ func (s *Server) Rover(ctx context.Context, req *rove.RoverRequest) (*rove.Rover Y: int32(rover.Pos.Y), }, Range: int32(rover.Range), - Inventory: rover.Inventory, + Inventory: inv, Integrity: int32(rover.Integrity), } } @@ -88,10 +93,11 @@ func (s *Server) Radar(ctx context.Context, req *rove.RadarRequest) (*rove.Radar } else if rover, err := s.world.GetRover(resp); err != nil { return nil, fmt.Errorf("error getting rover attributes: %s", err) - } else if radar, err := s.world.RadarFromRover(resp); err != nil { + } else if radar, objs, err := s.world.RadarFromRover(resp); err != nil { return nil, fmt.Errorf("error getting radar from rover: %s", err) } else { + response.Objects = objs response.Tiles = radar response.Range = int32(rover.Range) } diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index f7d1fe1..40969e1 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -1,7 +1,6 @@ package atlas import ( - "log" "math/rand" "github.com/mdiluz/rove/pkg/maths" @@ -9,27 +8,28 @@ import ( "github.com/mdiluz/rove/pkg/vector" ) +// Tile describes the type of terrain +type Tile byte + +const ( + // TileNone is a keyword for nothing + TileNone = Tile(0) + + // TileRock is solid rock ground + TileRock = Tile('.') + + // TileSand is sand + TileSand = Tile(',') +) + // Chunk represents a fixed square grid of tiles type Chunk struct { // Tiles represents the tiles within the chunk Tiles []byte `json:"tiles"` -} -// SpawnContent will create a chunk and fill it with spawned tiles -func (c *Chunk) SpawnContent(size int) { - c.Tiles = make([]byte, size*size) - for i := 0; i < len(c.Tiles); i++ { - c.Tiles[i] = objects.Empty - } - - // For now, fill it randomly with objects - for i := range c.Tiles { - if rand.Intn(16) == 0 { - c.Tiles[i] = objects.LargeRock - } else if rand.Intn(32) == 0 { - c.Tiles[i] = objects.SmallRock - } - } + // Objects represents the objects within the chunk + // only one possible object per tile for now + Objects map[int]objects.Object `json:"objects"` } // Atlas represents a grid of Chunks @@ -58,50 +58,101 @@ func NewAtlas(chunkSize int) Atlas { WorldOrigin: vector.Vector{X: 0, Y: 0}, } // Initialise the first chunk - a.Chunks[0].SpawnContent(chunkSize) + a.Chunks[0].populate(chunkSize) return a } // SetTile sets an individual tile's kind -func (a *Atlas) SetTile(v vector.Vector, tile byte) { - // Get the chunk +func (a *Atlas) SetTile(v vector.Vector, tile Tile) { c := a.worldSpaceToChunkWithGrow(v) - chunk := a.Chunks[c] - if chunk.Tiles == nil { - chunk.SpawnContent(a.ChunkSize) - } - local := a.worldSpaceToChunkLocal(v) - tileID := local.X + local.Y*a.ChunkSize - - // Sanity check - if tileID >= len(chunk.Tiles) || tileID < 0 { - log.Fatalf("Local tileID is not in valid chunk, somehow, this means something is very wrong") - } - - // Set the chunk back - chunk.Tiles[tileID] = tile - a.Chunks[c] = chunk + a.setTile(c, local, byte(tile)) } -// GetTile will return an individual tile -func (a *Atlas) GetTile(v vector.Vector) byte { - // Get the chunk +// SetObject sets the object on a tile +func (a *Atlas) SetObject(v vector.Vector, obj objects.Object) { c := a.worldSpaceToChunkWithGrow(v) + local := a.worldSpaceToChunkLocal(v) + a.setObject(c, local, obj) +} + +// QueryPosition will return information for a specific position +func (a *Atlas) QueryPosition(v vector.Vector) (byte, objects.Object) { + c := a.worldSpaceToChunkWithGrow(v) + local := a.worldSpaceToChunkLocal(v) chunk := a.Chunks[c] if chunk.Tiles == nil { - chunk.SpawnContent(a.ChunkSize) + chunk.populate(a.ChunkSize) + } + i := a.chunkTileIndex(local) + return chunk.Tiles[i], chunk.Objects[i] +} + +// chunkTileID returns the tile index within a chunk +func (a *Atlas) chunkTileIndex(local vector.Vector) int { + return local.X + local.Y*a.ChunkSize +} + +// populate will fill a chunk with data +func (c *Chunk) populate(size int) { + c.Tiles = make([]byte, size*size) + c.Objects = make(map[int]objects.Object) + + // Set up the tiles + for i := 0; i < len(c.Tiles); i++ { + if rand.Intn(3) == 0 { + c.Tiles[i] = byte(TileRock) + } else { + c.Tiles[i] = byte(TileSand) + } } - local := a.worldSpaceToChunkLocal(v) - tileID := local.X + local.Y*a.ChunkSize + // Set up any objects + for i := 0; i < len(c.Tiles); i++ { + if rand.Intn(16) == 0 { + c.Objects[i] = objects.Object{Type: objects.LargeRock} + } + } +} - // Sanity check - if tileID >= len(chunk.Tiles) || tileID < 0 { - log.Fatalf("Local tileID is not in valid chunk, somehow, this means something is very wrong") +// setTile sets a tile in a specific chunk +func (a *Atlas) setTile(chunk int, local vector.Vector, tile byte) { + c := a.Chunks[chunk] + if c.Tiles == nil { + c.populate(a.ChunkSize) } - return chunk.Tiles[tileID] + c.Tiles[a.chunkTileIndex(local)] = tile + a.Chunks[chunk] = c +} + +// setObject sets an object in a specific chunk +func (a *Atlas) setObject(chunk int, local vector.Vector, object objects.Object) { + c := a.Chunks[chunk] + if c.Tiles == nil { + c.populate(a.ChunkSize) + } + + i := a.chunkTileIndex(local) + if object.Type != objects.None { + c.Objects[i] = object + } else { + delete(c.Objects, i) + } + a.Chunks[chunk] = c +} + +// setTileAndObject sets both tile and object information for location in chunk +func (a *Atlas) setTileAndObject(chunk int, local vector.Vector, tile byte, object objects.Object) { + c := a.Chunks[chunk] + if c.Tiles == nil { + c.populate(a.ChunkSize) + } + + i := a.chunkTileIndex(local) + c.Tiles[i] = tile + c.Objects[i] = object + a.Chunks[chunk] = c } // worldSpaceToChunkLocal gets a chunk local coordinate for a tile diff --git a/pkg/atlas/atlas_test.go b/pkg/atlas/atlas_test.go index ae5c705..9778150 100644 --- a/pkg/atlas/atlas_test.go +++ b/pkg/atlas/atlas_test.go @@ -3,6 +3,7 @@ package atlas import ( "testing" + "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/vector" "github.com/stretchr/testify/assert" ) @@ -19,8 +20,8 @@ func TestAtlas_toChunk(t *testing.T) { assert.NotNil(t, a) // Get a tile to spawn the chunks - a.GetTile(vector.Vector{X: -1, Y: -1}) - a.GetTile(vector.Vector{X: 0, Y: 0}) + a.QueryPosition(vector.Vector{X: -1, Y: -1}) + a.QueryPosition(vector.Vector{X: 0, Y: 0}) // Chunks should look like: // 2 | 3 @@ -38,8 +39,8 @@ func TestAtlas_toChunk(t *testing.T) { a = NewAtlas(2) assert.NotNil(t, a) // Get a tile to spawn the chunks - a.GetTile(vector.Vector{X: -2, Y: -2}) - a.GetTile(vector.Vector{X: 1, Y: 1}) + a.QueryPosition(vector.Vector{X: -2, Y: -2}) + a.QueryPosition(vector.Vector{X: 1, Y: 1}) // Chunks should look like: // 2 | 3 // ----- @@ -56,8 +57,8 @@ func TestAtlas_toChunk(t *testing.T) { a = NewAtlas(2) assert.NotNil(t, a) // Get a tile to spawn the chunks - a.GetTile(vector.Vector{X: 5, Y: 5}) - a.GetTile(vector.Vector{X: -5, Y: -5}) + a.QueryPosition(vector.Vector{X: 5, Y: 5}) + a.QueryPosition(vector.Vector{X: -5, Y: -5}) // Chunks should look like: // 12| 13|| 14| 15 // ---------------- @@ -82,15 +83,30 @@ func TestAtlas_GetSetTile(t *testing.T) { // Set the origin tile to 1 and test it a.SetTile(vector.Vector{X: 0, Y: 0}, 1) - tile := a.GetTile(vector.Vector{X: 0, Y: 0}) + tile, _ := a.QueryPosition(vector.Vector{X: 0, Y: 0}) assert.Equal(t, byte(1), tile) // Set another tile to 1 and test it a.SetTile(vector.Vector{X: 5, Y: -2}, 2) - tile = a.GetTile(vector.Vector{X: 5, Y: -2}) + tile, _ = a.QueryPosition(vector.Vector{X: 5, Y: -2}) assert.Equal(t, byte(2), tile) } +func TestAtlas_GetSetObject(t *testing.T) { + a := NewAtlas(10) + assert.NotNil(t, a) + + // Set the origin tile to 1 and test it + a.SetObject(vector.Vector{X: 0, Y: 0}, objects.Object{Type: objects.LargeRock}) + _, obj := a.QueryPosition(vector.Vector{X: 0, Y: 0}) + assert.Equal(t, objects.Object{Type: objects.LargeRock}, obj) + + // Set another tile to 1 and test it + a.SetObject(vector.Vector{X: 5, Y: -2}, objects.Object{Type: objects.SmallRock}) + _, obj = a.QueryPosition(vector.Vector{X: 5, Y: -2}) + assert.Equal(t, objects.Object{Type: objects.SmallRock}, obj) +} + func TestAtlas_Grown(t *testing.T) { // Start with a small example a := NewAtlas(2) @@ -103,21 +119,21 @@ func TestAtlas_Grown(t *testing.T) { a.SetTile(vector.Vector{X: 1, Y: -2}, 3) // Check tile values - tile := a.GetTile(vector.Vector{X: 0, Y: 0}) + tile, _ := a.QueryPosition(vector.Vector{X: 0, Y: 0}) assert.Equal(t, byte(1), tile) - tile = a.GetTile(vector.Vector{X: -1, Y: -1}) + tile, _ = a.QueryPosition(vector.Vector{X: -1, Y: -1}) assert.Equal(t, byte(2), tile) - tile = a.GetTile(vector.Vector{X: 1, Y: -2}) + tile, _ = a.QueryPosition(vector.Vector{X: 1, Y: -2}) assert.Equal(t, byte(3), tile) - tile = a.GetTile(vector.Vector{X: 0, Y: 0}) + tile, _ = a.QueryPosition(vector.Vector{X: 0, Y: 0}) assert.Equal(t, byte(1), tile) - tile = a.GetTile(vector.Vector{X: -1, Y: -1}) + tile, _ = a.QueryPosition(vector.Vector{X: -1, Y: -1}) assert.Equal(t, byte(2), tile) - tile = a.GetTile(vector.Vector{X: 1, Y: -2}) + tile, _ = a.QueryPosition(vector.Vector{X: 1, Y: -2}) assert.Equal(t, byte(3), tile) } diff --git a/pkg/game/rover.go b/pkg/game/rover.go index e315363..1779e63 100644 --- a/pkg/game/rover.go +++ b/pkg/game/rover.go @@ -1,6 +1,7 @@ package game import ( + "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/vector" ) @@ -16,7 +17,7 @@ type Rover struct { Range int `json:"range"` // Inventory represents any items the rover is carrying - Inventory []byte `json:"inventory"` + Inventory []objects.Object `json:"inventory"` // Integrity represents current rover health Integrity int `json:"integrity"` diff --git a/pkg/game/world.go b/pkg/game/world.go index 3e9128b..59d004d 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -101,8 +101,8 @@ func (w *World) SpawnRover() (string, error) { // Seach until we error (run out of world) for { - tile := w.Atlas.GetTile(rover.Pos) - if !objects.IsBlocking(tile) { + _, obj := w.Atlas.QueryPosition(rover.Pos) + if !obj.IsBlocking() { break } else { // Try and spawn to the east of the blockage @@ -136,13 +136,11 @@ func (w *World) DestroyRover(rover string) error { w.worldMutex.Lock() defer w.worldMutex.Unlock() - i, ok := w.Rovers[rover] + _, ok := w.Rovers[rover] if !ok { return fmt.Errorf("no rover matching id") } - // Clear the tile - w.Atlas.SetTile(i.Pos, objects.Empty) delete(w.Rovers, rover) return nil } @@ -175,7 +173,7 @@ func (w *World) SetRoverPosition(rover string, pos vector.Vector) error { } // RoverInventory returns the inventory of a requested rover -func (w *World) RoverInventory(rover string) ([]byte, error) { +func (w *World) RoverInventory(rover string) ([]objects.Object, error) { w.worldMutex.RLock() defer w.worldMutex.RUnlock() @@ -201,8 +199,8 @@ func (w *World) WarpRover(rover string, pos vector.Vector) error { } // Check the tile is not blocked - tile := w.Atlas.GetTile(pos) - if objects.IsBlocking(tile) { + _, obj := w.Atlas.QueryPosition(pos) + if obj.IsBlocking() { return fmt.Errorf("can't warp rover to occupied tile, check before warping") } @@ -224,8 +222,8 @@ func (w *World) MoveRover(rover string, b bearing.Bearing) (vector.Vector, error newPos := i.Pos.Added(b.Vector()) // Get the tile and verify it's empty - tile := w.Atlas.GetTile(newPos) - if !objects.IsBlocking(tile) { + _, obj := w.Atlas.QueryPosition(newPos) + if !obj.IsBlocking() { // Perform the move i.Pos = newPos w.Rovers[rover] = i @@ -243,34 +241,35 @@ func (w *World) MoveRover(rover string, b bearing.Bearing) (vector.Vector, error } // RoverStash will stash an item at the current rovers position -func (w *World) RoverStash(rover string) (byte, error) { +func (w *World) RoverStash(rover string) (objects.Type, error) { w.worldMutex.Lock() defer w.worldMutex.Unlock() r, ok := w.Rovers[rover] if !ok { - return objects.Empty, fmt.Errorf("no rover matching id") + return objects.None, fmt.Errorf("no rover matching id") } - tile := w.Atlas.GetTile(r.Pos) - if !objects.IsStashable(tile) { - return objects.Empty, nil + _, obj := w.Atlas.QueryPosition(r.Pos) + if !obj.IsStashable() { + return objects.None, nil } - r.Inventory = append(r.Inventory, tile) + r.Inventory = append(r.Inventory, obj) w.Rovers[rover] = r - w.Atlas.SetTile(r.Pos, objects.Empty) - return tile, nil + w.Atlas.SetObject(r.Pos, objects.Object{Type: objects.None}) + return obj.Type, nil } // RadarFromRover can be used to query what a rover can currently see -func (w *World) RadarFromRover(rover string) ([]byte, error) { +func (w *World) RadarFromRover(rover string) (radar []byte, objs []byte, err error) { w.worldMutex.RLock() defer w.worldMutex.RUnlock() r, ok := w.Rovers[rover] if !ok { - return nil, fmt.Errorf("no rover matching id") + err = fmt.Errorf("no rover matching id") + return } // The radar should span in range direction on each axis, plus the row/column the rover is currently on @@ -288,18 +287,19 @@ func (w *World) RadarFromRover(rover string) ([]byte, error) { } // Gather up all tiles within the range - var radar = make([]byte, radarSpan*radarSpan) + radar = make([]byte, radarSpan*radarSpan) + objs = make([]byte, radarSpan*radarSpan) for j := radarMin.Y; j <= radarMax.Y; j++ { for i := radarMin.X; i <= radarMax.X; i++ { q := vector.Vector{X: i, Y: j} - tile := w.Atlas.GetTile(q) + tile, obj := w.Atlas.QueryPosition(q) // Get the position relative to the bottom left of the radar relative := q.Added(radarMin.Negated()) index := relative.X + relative.Y*radarSpan radar[index] = tile - + objs[index] = byte(obj.Type) } } @@ -312,14 +312,11 @@ func (w *World) RadarFromRover(rover string) ([]byte, error) { if dist.X <= r.Range && dist.Y <= r.Range { relative := r.Pos.Added(radarMin.Negated()) index := relative.X + relative.Y*radarSpan - radar[index] = objects.Rover + objs[index] = byte(objects.Rover) } } - // Add this rover - radar[len(radar)/2] = objects.Rover - - return radar, nil + return radar, objs, nil } // Enqueue will queue the commands given @@ -433,7 +430,14 @@ func PrintTiles(tiles []byte) { num := int(math.Sqrt(float64(len(tiles)))) for j := num - 1; j >= 0; j-- { for i := 0; i < num; i++ { - fmt.Printf("%c", tiles[i+num*j]) + + t := tiles[i+num*j] + if t != 0 { + fmt.Printf("%c", t) + } else { + fmt.Printf(" ") + } + } fmt.Print("\n") } diff --git a/pkg/game/world_test.go b/pkg/game/world_test.go index ceda417..80ca5f9 100644 --- a/pkg/game/world_test.go +++ b/pkg/game/world_test.go @@ -3,6 +3,7 @@ package game import ( "testing" + "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/bearing" "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/vector" @@ -84,7 +85,7 @@ func TestWorld_GetSetMovePosition(t *testing.T) { assert.Equal(t, pos, newPos, "Failed to correctly move position for rover") // Place a tile in front of the rover - world.Atlas.SetTile(vector.Vector{X: 0, Y: 2}, objects.LargeRock) + world.Atlas.SetObject(vector.Vector{X: 0, Y: 2}, objects.Object{Type: objects.LargeRock}) newPos, err = world.MoveRover(a, b) assert.Equal(t, pos, newPos, "Failed to correctly not move position for rover into wall") } @@ -102,14 +103,15 @@ func TestWorld_RadarFromRover(t *testing.T) { assert.NoError(t, world.WarpRover(b, bpos), "Failed to warp rover") assert.NoError(t, world.WarpRover(a, vector.Vector{X: 0, Y: 0}), "Failed to warp rover") - radar, err := world.RadarFromRover(a) + radar, objs, err := world.RadarFromRover(a) assert.NoError(t, err, "Failed to get radar from rover") fullRange := 4 + 4 + 1 assert.Equal(t, fullRange*fullRange, len(radar), "Radar returned wrong length") + assert.Equal(t, fullRange*fullRange, len(objs), "Radar returned wrong length") // Test the expected values - assert.Equal(t, objects.Rover, radar[1+fullRange]) - assert.Equal(t, objects.Rover, radar[4+4*fullRange]) + assert.Equal(t, byte(objects.Rover), objs[1+fullRange]) + assert.Equal(t, byte(objects.Rover), objs[4+4*fullRange]) } func TestWorld_RoverStash(t *testing.T) { @@ -125,18 +127,20 @@ func TestWorld_RoverStash(t *testing.T) { err = world.WarpRover(a, pos) assert.NoError(t, err, "Failed to set position for rover") - world.Atlas.SetTile(pos, objects.SmallRock) + // Set to a traversible tile + world.Atlas.SetTile(pos, atlas.TileRock) + world.Atlas.SetObject(pos, objects.Object{Type: objects.SmallRock}) o, err := world.RoverStash(a) assert.NoError(t, err, "Failed to stash") assert.Equal(t, objects.SmallRock, o, "Failed to get correct object") - tile := world.Atlas.GetTile(pos) - assert.Equal(t, objects.Empty, tile, "Stash failed to remove object from atlas") + _, obj := world.Atlas.QueryPosition(pos) + assert.Equal(t, objects.None, obj.Type, "Stash failed to remove object from atlas") inv, err := world.RoverInventory(a) assert.NoError(t, err, "Failed to get inventory") - assert.Equal(t, objects.SmallRock, inv[0]) + assert.Equal(t, objects.Object{Type: objects.SmallRock}, inv[0]) } func TestWorld_RoverDamage(t *testing.T) { @@ -155,7 +159,7 @@ func TestWorld_RoverDamage(t *testing.T) { info, err := world.GetRover(a) assert.NoError(t, err, "couldn't get rover info") - world.Atlas.SetTile(vector.Vector{X: 0.0, Y: 1.0}, objects.LargeRock) + world.Atlas.SetObject(vector.Vector{X: 0.0, Y: 1.0}, objects.Object{Type: objects.LargeRock}) vec, err := world.MoveRover(a, bearing.North) assert.NoError(t, err, "Failed to move rover") @@ -176,19 +180,22 @@ func TestWorld_RoverRepair(t *testing.T) { Y: 0.0, } + world.Atlas.SetTile(pos, atlas.TileNone) + world.Atlas.SetObject(pos, objects.Object{Type: objects.None}) + err = world.WarpRover(a, pos) assert.NoError(t, err, "Failed to set position for rover") originalInfo, err := world.GetRover(a) assert.NoError(t, err, "couldn't get rover info") - world.Atlas.SetTile(pos, objects.SmallRock) + world.Atlas.SetObject(pos, objects.Object{Type: objects.SmallRock}) o, err := world.RoverStash(a) assert.NoError(t, err, "Failed to stash") assert.Equal(t, objects.SmallRock, o, "Failed to get correct object") - world.Atlas.SetTile(vector.Vector{X: 0.0, Y: 1.0}, objects.LargeRock) + world.Atlas.SetObject(vector.Vector{X: 0.0, Y: 1.0}, objects.Object{Type: objects.LargeRock}) vec, err := world.MoveRover(a, bearing.North) assert.NoError(t, err, "Failed to move rover") diff --git a/pkg/objects/objects.go b/pkg/objects/objects.go index e553a1c..126d0d1 100644 --- a/pkg/objects/objects.go +++ b/pkg/objects/objects.go @@ -1,28 +1,37 @@ package objects +// Type represents an object type +type Type byte + +// Types of objects const ( - // Empty represents an non-existant object - Empty = byte(' ') + // None represents no object at all + None = Type(0) // Rover represents a live rover - Rover = byte('R') + Rover = Type('R') // SmallRock is a small stashable rock - SmallRock = byte('o') + SmallRock = Type('o') // LargeRock is a large blocking rock - LargeRock = byte('O') + LargeRock = Type('o') ) +// Object represents an object in the world +type Object struct { + Type Type `json:"type"` +} + // IsBlocking checks if an object is a blocking object -func IsBlocking(object byte) bool { - var blocking = [...]byte{ +func (o *Object) IsBlocking() bool { + var blocking = [...]Type{ Rover, LargeRock, } for _, t := range blocking { - if object == t { + if o.Type == t { return true } } @@ -30,13 +39,13 @@ func IsBlocking(object byte) bool { } // IsStashable checks if an object is stashable -func IsStashable(object byte) bool { - var stashable = [...]byte{ +func (o *Object) IsStashable() bool { + var stashable = [...]Type{ SmallRock, } for _, t := range stashable { - if object == t { + if o.Type == t { return true } } diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index faf1b9f..6db8b38 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -42,6 +42,7 @@ type Command struct { // The command to execute // "move" - Move the rover in a direction, requires bearing // "stash" - Stashes item at current location in rover inventory + // "repair" - Repairs the rover using an inventory object Command string `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"` // The bearing, example: NE Bearing string `protobuf:"bytes,2,opt,name=bearing,proto3" json:"bearing,omitempty"` @@ -294,6 +295,8 @@ type RadarResponse struct { Range int32 `protobuf:"varint,1,opt,name=range,proto3" json:"range,omitempty"` // A 1D array representing range*2 + 1 squared set of tiles, origin bottom left and in row->column order Tiles []byte `protobuf:"bytes,2,opt,name=tiles,proto3" json:"tiles,omitempty"` + // A similar array to the tile array, but containing objects + Objects []byte `protobuf:"bytes,3,opt,name=objects,proto3" json:"objects,omitempty"` } func (x *RadarResponse) Reset() { @@ -342,6 +345,13 @@ func (x *RadarResponse) GetTiles() []byte { return nil } +func (x *RadarResponse) GetObjects() []byte { + if x != nil { + return x.Objects + } + return nil +} + // Empty placeholder type RegisterResponse struct { state protoimpl.MessageState @@ -751,64 +761,66 @@ var file_rove_rove_proto_rawDesc = []byte{ 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x28, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x3b, 0x0a, 0x0d, 0x52, 0x61, 0x64, + 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x55, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x12, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x25, 0x0a, 0x0f, 0x52, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x22, 0x28, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x9f, 0x01, 0x0a, 0x0d, - 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x12, 0x28, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, - 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, - 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, - 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, - 0x1c, 0x0a, 0x09, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x09, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x22, 0x0f, 0x0a, - 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x71, - 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x14, 0x0a, - 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, - 0x61, 0x64, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x32, 0xf8, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, - 0x12, 0x44, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x0f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x09, 0x12, 0x07, 0x2f, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4f, 0x0a, 0x08, 0x43, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x73, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, - 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, - 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, - 0x05, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x6f, - 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x3a, - 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, - 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, + 0x22, 0x12, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x25, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x28, 0x0a, 0x0c, 0x52, + 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x9f, 0x01, 0x0a, 0x0d, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, + 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, + 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x49, 0x6e, 0x74, + 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x49, 0x6e, + 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x22, 0x0f, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x71, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, + 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, + 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x12, 0x0a, + 0x04, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74, 0x69, 0x63, + 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x24, 0x0a, 0x06, 0x56, + 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, + 0x79, 0x32, 0xf8, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x44, 0x0a, 0x06, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x0f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x09, 0x12, 0x07, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x12, 0x4f, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, + 0x2a, 0x12, 0x4f, 0x0a, 0x08, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x15, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, + 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x3a, + 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, + 0x61, 0x64, 0x61, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x6f, 0x76, 0x65, 0x72, + 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x6f, 0x76, 0x65, + 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, + 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, + 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/rove/rove.swagger.json b/pkg/rove/rove.swagger.json index 3325d41..4362794 100644 --- a/pkg/rove/rove.swagger.json +++ b/pkg/rove/rove.swagger.json @@ -212,7 +212,7 @@ "properties": { "command": { "type": "string", - "title": "The command to execute\n\"move\" - Move the rover in a direction, requires bearing\n\"stash\" - Stashes item at current location in rover inventory" + "title": "The command to execute\n\"move\" - Move the rover in a direction, requires bearing\n\"stash\" - Stashes item at current location in rover inventory\n\"repair\" - Repairs the rover using an inventory object" }, "bearing": { "type": "string", @@ -261,6 +261,11 @@ "type": "string", "format": "byte", "title": "A 1D array representing range*2 + 1 squared set of tiles, origin bottom left and in row-\u003ecolumn order" + }, + "objects": { + "type": "string", + "format": "byte", + "title": "A similar array to the tile array, but containing objects" } } }, diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index f1c6c3d..41a4475 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -98,6 +98,9 @@ message RadarResponse { // A 1D array representing range*2 + 1 squared set of tiles, origin bottom left and in row->column order bytes tiles = 2; + + // A similar array to the tile array, but containing objects + bytes objects = 3; } // Empty placeholder From c4b0762ebec8ac8a08e1769749c0a0c334ddb9d6 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 3 Jul 2020 17:05:31 +0100 Subject: [PATCH 025/228] Fix up the tile print now that the radar returns objects --- cmd/rove/main.go | 21 ++++++++++++++++++++- pkg/game/world.go | 19 ------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 398feb9..17e35aa 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -4,13 +4,16 @@ import ( "encoding/json" "fmt" "io/ioutil" + "math" "os" "path" "path/filepath" "time" + "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/bearing" "github.com/mdiluz/rove/pkg/game" + "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/rove" "github.com/mdiluz/rove/pkg/version" "golang.org/x/net/context" @@ -253,8 +256,24 @@ func InnerMain(command string, args ...string) error { return err default: + // Print out the radar - game.PrintTiles(response.Tiles) + num := int(math.Sqrt(float64(len(response.Tiles)))) + for j := num - 1; j >= 0; j-- { + for i := 0; i < num; i++ { + t := response.Tiles[i+num*j] + o := response.Objects[i+num*j] + if o != byte(objects.None) { + fmt.Printf("%c", o) + } else if t != byte(atlas.TileNone) { + fmt.Printf("%c", t) + } else { + fmt.Printf(" ") + } + + } + fmt.Print("\n") + } } case "rover": diff --git a/pkg/game/world.go b/pkg/game/world.go index 59d004d..a0809ed 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -4,7 +4,6 @@ import ( "bufio" "fmt" "log" - "math" "math/rand" "os" "sync" @@ -425,24 +424,6 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { return } -// PrintTiles simply prints the input tiles directly for debug -func PrintTiles(tiles []byte) { - num := int(math.Sqrt(float64(len(tiles)))) - for j := num - 1; j >= 0; j-- { - for i := 0; i < num; i++ { - - t := tiles[i+num*j] - if t != 0 { - fmt.Printf("%c", t) - } else { - fmt.Printf(" ") - } - - } - fmt.Print("\n") - } -} - // RLock read locks the world func (w *World) RLock() { w.worldMutex.RLock() From 1a1ef9a3764bfa1463a805282289954cbcc1b3f0 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 3 Jul 2020 17:06:28 +0100 Subject: [PATCH 026/228] go mod tidy and update --- go.mod | 17 +++++++++------- go.sum | 64 +++++++++++++++++++++++++++++++--------------------------- 2 files changed, 44 insertions(+), 37 deletions(-) diff --git a/go.mod b/go.mod index e21de42..2165ade 100644 --- a/go.mod +++ b/go.mod @@ -3,16 +3,19 @@ module github.com/mdiluz/rove go 1.14 require ( - github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b + github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang/protobuf v1.4.2 github.com/google/uuid v1.1.1 github.com/grpc-ecosystem/grpc-gateway v1.14.6 - github.com/onsi/ginkgo v1.12.3 // indirect + github.com/kr/pretty v0.1.0 // indirect github.com/robfig/cron v1.2.0 github.com/stretchr/testify v1.6.0 - github.com/tjarratt/babble v0.0.0-20191209142150-eecdf8c2339d - golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7 - google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884 - google.golang.org/grpc v1.29.1 - google.golang.org/protobuf v1.23.0 + golang.org/x/net v0.0.0-20200602114024-627f9648deb9 + golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 // indirect + golang.org/x/text v0.3.3 // indirect + google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 + google.golang.org/grpc v1.30.0 + google.golang.org/protobuf v1.25.0 + gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect + gopkg.in/yaml.v2 v2.3.0 // indirect ) diff --git a/go.sum b/go.sum index 57044e0..029b75f 100644 --- a/go.sum +++ b/go.sum @@ -1,19 +1,23 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0 h1:eOI3/cP2VTU6uZLDYAoic+eyzzB9YyGmJ7eIjl8rOPg= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f h1:WBZRG4aNOuI15bLRrCgN8fCq8E5Xuty6jGbmSNEvSsU= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4 h1:rEvIZUSZ3fx39WIi3JkQqQBitGwpELBIYWeBVh6wn+E= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= @@ -27,6 +31,7 @@ github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:x github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -34,20 +39,17 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway v1.14.6 h1:8ERzHx8aj1Sc47mu9n/AksaKCSWrMchFtkdrS4BIj5o= github.com/grpc-ecosystem/grpc-gateway v1.14.6/go.mod h1:zdiPV4Yse/1gnckTHtghG4GkDEdKCRJduHpTxT3/jcw= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.12.3 h1:+RYp9QczoWz9zfUyLP/5SLXQVhfr6gZOoKGfQqHuLZQ= -github.com/onsi/ginkgo v1.12.3/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -57,8 +59,6 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.6.0 h1:jlIyCplCJFULU/01vCkhKuTyc3OorI3bJFuw6obfgho= github.com/stretchr/testify v1.6.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/tjarratt/babble v0.0.0-20191209142150-eecdf8c2339d h1:b7oHBI6TgTdCDuqTijsVldzlh+6cfQpdYLz1EKtCAoY= -github.com/tjarratt/babble v0.0.0-20191209142150-eecdf8c2339d/go.mod h1:O5hBrCGqzfb+8WyY8ico2AyQau7XQwAfEQeEQ5/5V9E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -66,34 +66,31 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7 h1:AeiKBIuRw3UomYXSbLy0Mc2dDLfdtbT/IVn4keq83P0= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM= +golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 h1:DYfZAGf2WMFjMxbgTjaC+2HC7NkNAQs+6Q8b9WEB/F4= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 h1:OjiUf46hAmXblsZdnoSXsEUSKU8r1UEzcL5RVZ4gO9Y= +golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -109,29 +106,36 @@ google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2El google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884 h1:fiNLklpBwWK1mth30Hlwk+fcdBmIALlgF5iy77O37Ig= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.29.1 h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0 h1:M5a8xTlYTxwMn5ZFkwhRabsygDY5G8TYLyQDBxJNAxE= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= From 9cd5324465ce591325d7507a539d68acb30bd8e8 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 3 Jul 2020 17:13:52 +0100 Subject: [PATCH 027/228] Fix small and large rock spawning --- pkg/atlas/atlas.go | 2 ++ pkg/objects/objects.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index 40969e1..6ec11e2 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -111,6 +111,8 @@ func (c *Chunk) populate(size int) { for i := 0; i < len(c.Tiles); i++ { if rand.Intn(16) == 0 { c.Objects[i] = objects.Object{Type: objects.LargeRock} + } else if rand.Intn(32) == 0 { + c.Objects[i] = objects.Object{Type: objects.SmallRock} } } } diff --git a/pkg/objects/objects.go b/pkg/objects/objects.go index 126d0d1..9338b68 100644 --- a/pkg/objects/objects.go +++ b/pkg/objects/objects.go @@ -15,7 +15,7 @@ const ( SmallRock = Type('o') // LargeRock is a large blocking rock - LargeRock = Type('o') + LargeRock = Type('O') ) // Object represents an object in the world From e6ff453ff1ee39a735982b45d54f0e1388b9cd00 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 4 Jul 2020 12:25:57 +0100 Subject: [PATCH 028/228] Add note for intelligent world-gen --- docs/status.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/status.md b/docs/status.md index bf3fea2..951abc1 100644 --- a/docs/status.md +++ b/docs/status.md @@ -24,6 +24,7 @@ This page tracks the current feature set and the features to implement next * Day/night cycle * More hazards * Simple rover to rover communication +* Deterministic and intelligent world-gen ### Stretch goals From 2eaed1447d19b9ace55d7cc4102d82d7f3ae8ad1 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 4 Jul 2020 12:01:35 +0100 Subject: [PATCH 029/228] Add rover inventory capacity and test --- cmd/rove-server/internal/routes.go | 1 + pkg/game/rover.go | 3 + pkg/game/world.go | 6 ++ pkg/game/world_test.go | 34 ++++++++++- pkg/rove/rove.pb.go | 95 +++++++++++++++++------------- pkg/rove/rove.swagger.json | 7 ++- proto/rove/rove.proto | 5 +- 7 files changed, 104 insertions(+), 47 deletions(-) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 04641bc..ae98dfd 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -72,6 +72,7 @@ func (s *Server) Rover(ctx context.Context, req *rove.RoverRequest) (*rove.Rover }, Range: int32(rover.Range), Inventory: inv, + Capacity: int32(rover.Capacity), Integrity: int32(rover.Integrity), } } diff --git a/pkg/game/rover.go b/pkg/game/rover.go index 1779e63..f6e4f25 100644 --- a/pkg/game/rover.go +++ b/pkg/game/rover.go @@ -19,6 +19,9 @@ type Rover struct { // Inventory represents any items the rover is carrying Inventory []objects.Object `json:"inventory"` + // Capacity is the maximum number of inventory items + Capacity int `json:"capacity"` + // Integrity represents current rover health Integrity int `json:"integrity"` } diff --git a/pkg/game/world.go b/pkg/game/world.go index a0809ed..2e268e9 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -77,6 +77,7 @@ func (w *World) SpawnRover() (string, error) { rover := Rover{ Range: 4.0, Integrity: 10, + Capacity: 10, Name: uuid.New().String(), } @@ -249,6 +250,11 @@ func (w *World) RoverStash(rover string) (objects.Type, error) { return objects.None, fmt.Errorf("no rover matching id") } + // Can't pick up when full + if len(r.Inventory) >= r.Capacity { + return objects.None, nil + } + _, obj := w.Atlas.QueryPosition(r.Pos) if !obj.IsStashable() { return objects.None, nil diff --git a/pkg/game/world_test.go b/pkg/game/world_test.go index 80ca5f9..4803769 100644 --- a/pkg/game/world_test.go +++ b/pkg/game/world_test.go @@ -129,18 +129,46 @@ func TestWorld_RoverStash(t *testing.T) { // Set to a traversible tile world.Atlas.SetTile(pos, atlas.TileRock) + + rover, err := world.GetRover(a) + assert.NoError(t, err, "Failed to get rover") + + for i := 0; i < rover.Capacity; i++ { + // Place an object + world.Atlas.SetObject(pos, objects.Object{Type: objects.SmallRock}) + + // Pick it up + o, err := world.RoverStash(a) + assert.NoError(t, err, "Failed to stash") + assert.Equal(t, objects.SmallRock, o, "Failed to get correct object") + + // Check it's gone + _, obj := world.Atlas.QueryPosition(pos) + assert.Equal(t, objects.None, obj.Type, "Stash failed to remove object from atlas") + + // Check we have it + inv, err := world.RoverInventory(a) + assert.NoError(t, err, "Failed to get inventory") + assert.Equal(t, i+1, len(inv)) + assert.Equal(t, objects.Object{Type: objects.SmallRock}, inv[i]) + } + + // Place an object world.Atlas.SetObject(pos, objects.Object{Type: objects.SmallRock}) + // Try to pick it up o, err := world.RoverStash(a) assert.NoError(t, err, "Failed to stash") - assert.Equal(t, objects.SmallRock, o, "Failed to get correct object") + assert.Equal(t, objects.None, o, "Failed to get correct object") + // Check it's still there _, obj := world.Atlas.QueryPosition(pos) - assert.Equal(t, objects.None, obj.Type, "Stash failed to remove object from atlas") + assert.Equal(t, objects.SmallRock, obj.Type, "Stash failed to remove object from atlas") + // Check we don't have it inv, err := world.RoverInventory(a) assert.NoError(t, err, "Failed to get inventory") - assert.Equal(t, objects.Object{Type: objects.SmallRock}, inv[0]) + assert.Equal(t, rover.Capacity, len(inv)) } func TestWorld_RoverDamage(t *testing.T) { diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index 6db8b38..6b3f7dc 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -500,8 +500,10 @@ type RoverResponse struct { Range int32 `protobuf:"varint,3,opt,name=range,proto3" json:"range,omitempty"` // The items in the rover inventory Inventory []byte `protobuf:"bytes,4,opt,name=inventory,proto3" json:"inventory,omitempty"` + // The capacity of the inventory + Capacity int32 `protobuf:"varint,5,opt,name=capacity,proto3" json:"capacity,omitempty"` // The current health of the rover - Integrity int32 `protobuf:"varint,5,opt,name=Integrity,proto3" json:"Integrity,omitempty"` + Integrity int32 `protobuf:"varint,6,opt,name=integrity,proto3" json:"integrity,omitempty"` } func (x *RoverResponse) Reset() { @@ -564,6 +566,13 @@ func (x *RoverResponse) GetInventory() []byte { return nil } +func (x *RoverResponse) GetCapacity() int32 { + if x != nil { + return x.Capacity + } + return 0 +} + func (x *RoverResponse) GetIntegrity() int32 { if x != nil { return x.Integrity @@ -773,7 +782,7 @@ var file_rove_rove_proto_rawDesc = []byte{ 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x28, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x9f, 0x01, 0x0a, 0x0d, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xbb, 0x01, 0x0a, 0x0d, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, @@ -781,46 +790,48 @@ var file_rove_rove_proto_rawDesc = []byte{ 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, - 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x49, 0x6e, 0x74, - 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x49, 0x6e, - 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x22, 0x0f, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x71, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, - 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, - 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x12, 0x0a, - 0x04, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74, 0x69, 0x63, - 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x24, 0x0a, 0x06, 0x56, - 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, - 0x79, 0x32, 0xf8, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x44, 0x0a, 0x06, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x0f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x09, 0x12, 0x07, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x4f, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, - 0x2a, 0x12, 0x4f, 0x0a, 0x08, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x15, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, - 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x3a, - 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, - 0x61, 0x64, 0x61, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x6f, 0x76, 0x65, 0x72, - 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x6f, 0x76, 0x65, - 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, - 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, + 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, + 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, + 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, + 0x69, 0x74, 0x79, 0x22, 0x0f, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x22, 0x71, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, + 0x69, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, + 0x69, 0x63, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x63, + 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x12, 0x18, 0x0a, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, + 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, + 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x32, 0xf8, 0x02, + 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x44, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x0f, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x09, 0x12, 0x07, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, 0x08, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, + 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4f, 0x0a, + 0x08, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, + 0x22, 0x09, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x3a, 0x01, 0x2a, 0x12, 0x43, + 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, + 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, 0x72, + 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x12, 0x12, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, + 0x72, 0x6f, 0x76, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, + 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/rove/rove.swagger.json b/pkg/rove/rove.swagger.json index 4362794..531769f 100644 --- a/pkg/rove/rove.swagger.json +++ b/pkg/rove/rove.swagger.json @@ -312,7 +312,12 @@ "format": "byte", "title": "The items in the rover inventory" }, - "Integrity": { + "capacity": { + "type": "integer", + "format": "int32", + "title": "The capacity of the inventory" + }, + "integrity": { "type": "integer", "format": "int32", "title": "The current health of the rover" diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index 41a4475..63d8157 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -129,8 +129,11 @@ message RoverResponse { // The items in the rover inventory bytes inventory = 4; + // The capacity of the inventory + int32 capacity = 5; + // The current health of the rover - int32 Integrity = 5; + int32 integrity = 6; } // Empty placeholder From b066277ddf0d91d3a9bce1f833d6036b9d77e17a Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 4 Jul 2020 12:19:51 +0100 Subject: [PATCH 030/228] Add MaximumIntegrity to the rover --- cmd/rove-server/internal/routes.go | 9 +-- pkg/game/rover.go | 3 + pkg/game/world.go | 13 +++-- pkg/game/world_test.go | 16 +++++- pkg/rove/rove.pb.go | 89 +++++++++++++++++------------- pkg/rove/rove.swagger.json | 5 ++ proto/rove/rove.proto | 3 + 7 files changed, 88 insertions(+), 50 deletions(-) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index ae98dfd..4a40290 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -70,10 +70,11 @@ func (s *Server) Rover(ctx context.Context, req *rove.RoverRequest) (*rove.Rover X: int32(rover.Pos.X), Y: int32(rover.Pos.Y), }, - Range: int32(rover.Range), - Inventory: inv, - Capacity: int32(rover.Capacity), - Integrity: int32(rover.Integrity), + Range: int32(rover.Range), + Inventory: inv, + Capacity: int32(rover.Capacity), + Integrity: int32(rover.Integrity), + MaximumIntegrity: int32(rover.MaximumIntegrity), } } return response, nil diff --git a/pkg/game/rover.go b/pkg/game/rover.go index f6e4f25..b0f5dca 100644 --- a/pkg/game/rover.go +++ b/pkg/game/rover.go @@ -24,4 +24,7 @@ type Rover struct { // Integrity represents current rover health Integrity int `json:"integrity"` + + // MaximumIntegrity is the full integrity of the rover + MaximumIntegrity int `json:"maximum-integrity"` } diff --git a/pkg/game/world.go b/pkg/game/world.go index 2e268e9..c0ff212 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -75,10 +75,11 @@ func (w *World) SpawnRover() (string, error) { // Initialise the rover rover := Rover{ - Range: 4.0, - Integrity: 10, - Capacity: 10, - Name: uuid.New().String(), + Range: 4.0, + Integrity: 10, + MaximumIntegrity: 10, + Capacity: 10, + Name: uuid.New().String(), } // Assign a random name if we have words @@ -417,8 +418,8 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { if err != nil { return err } - // Consume an inventory item to repair - if len(r.Inventory) > 0 { + // Consume an inventory item to repair if possible + if len(r.Inventory) > 0 && r.Integrity < r.MaximumIntegrity { r.Inventory = r.Inventory[:len(r.Inventory)-1] r.Integrity = r.Integrity + 1 w.Rovers[rover] = r diff --git a/pkg/game/world_test.go b/pkg/game/world_test.go index 4803769..4ee0676 100644 --- a/pkg/game/world_test.go +++ b/pkg/game/world_test.go @@ -217,14 +217,15 @@ func TestWorld_RoverRepair(t *testing.T) { originalInfo, err := world.GetRover(a) assert.NoError(t, err, "couldn't get rover info") + // Pick up something to repair with world.Atlas.SetObject(pos, objects.Object{Type: objects.SmallRock}) - o, err := world.RoverStash(a) assert.NoError(t, err, "Failed to stash") assert.Equal(t, objects.SmallRock, o, "Failed to get correct object") world.Atlas.SetObject(vector.Vector{X: 0.0, Y: 1.0}, objects.Object{Type: objects.LargeRock}) + // Try and bump into the rock vec, err := world.MoveRover(a, bearing.North) assert.NoError(t, err, "Failed to move rover") assert.Equal(t, pos, vec, "Rover managed to move into large rock") @@ -239,4 +240,17 @@ func TestWorld_RoverRepair(t *testing.T) { newinfo, err = world.GetRover(a) assert.NoError(t, err, "couldn't get rover info") assert.Equal(t, originalInfo.Integrity, newinfo.Integrity, "rover should have gained integrity") + + // Check again that it can't repair past the max + world.Atlas.SetObject(pos, objects.Object{Type: objects.SmallRock}) + o, err = world.RoverStash(a) + assert.NoError(t, err, "Failed to stash") + assert.Equal(t, objects.SmallRock, o, "Failed to get correct object") + + err = world.ExecuteCommand(&Command{Command: CommandRepair}, a) + assert.NoError(t, err, "Failed to repair rover") + + newinfo, err = world.GetRover(a) + assert.NoError(t, err, "couldn't get rover info") + assert.Equal(t, originalInfo.Integrity, newinfo.Integrity, "rover should have kept the same integrity") } diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index 6b3f7dc..733854c 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -504,6 +504,8 @@ type RoverResponse struct { Capacity int32 `protobuf:"varint,5,opt,name=capacity,proto3" json:"capacity,omitempty"` // The current health of the rover Integrity int32 `protobuf:"varint,6,opt,name=integrity,proto3" json:"integrity,omitempty"` + // The maximum health of the rover + MaximumIntegrity int32 `protobuf:"varint,7,opt,name=maximumIntegrity,proto3" json:"maximumIntegrity,omitempty"` } func (x *RoverResponse) Reset() { @@ -580,6 +582,13 @@ func (x *RoverResponse) GetIntegrity() int32 { return 0 } +func (x *RoverResponse) GetMaximumIntegrity() int32 { + if x != nil { + return x.MaximumIntegrity + } + return 0 +} + // Empty placeholder type StatusRequest struct { state protoimpl.MessageState @@ -782,7 +791,7 @@ var file_rove_rove_proto_rawDesc = []byte{ 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x28, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xbb, 0x01, 0x0a, 0x0d, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xe7, 0x01, 0x0a, 0x0d, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, @@ -794,44 +803,46 @@ var file_rove_rove_proto_rawDesc = []byte{ 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, - 0x69, 0x74, 0x79, 0x22, 0x0f, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x22, 0x71, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, - 0x69, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, - 0x69, 0x63, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x63, - 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x12, 0x18, 0x0a, - 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, - 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, - 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x32, 0xf8, 0x02, - 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x44, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x0f, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x09, 0x12, 0x07, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, 0x08, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, - 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4f, 0x0a, - 0x08, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, - 0x22, 0x09, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x3a, 0x01, 0x2a, 0x12, 0x43, - 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, - 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, 0x72, - 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x12, 0x12, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, - 0x72, 0x6f, 0x76, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, - 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, + 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, + 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x22, + 0x0f, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x22, 0x71, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, + 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, + 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, + 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x32, 0xf8, 0x02, 0x0a, 0x04, 0x52, 0x6f, + 0x76, 0x65, 0x12, 0x44, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x0f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x09, 0x12, + 0x07, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4f, 0x0a, 0x08, 0x43, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x61, + 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, + 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, + 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, 0x72, 0x3a, 0x01, 0x2a, 0x12, + 0x43, 0x0a, 0x05, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, + 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x6f, 0x76, 0x65, + 0x72, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, + 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/rove/rove.swagger.json b/pkg/rove/rove.swagger.json index 531769f..04a29d7 100644 --- a/pkg/rove/rove.swagger.json +++ b/pkg/rove/rove.swagger.json @@ -321,6 +321,11 @@ "type": "integer", "format": "int32", "title": "The current health of the rover" + }, + "maximumIntegrity": { + "type": "integer", + "format": "int32", + "title": "The maximum health of the rover" } } }, diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index 63d8157..38cd995 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -134,6 +134,9 @@ message RoverResponse { // The current health of the rover int32 integrity = 6; + + // The maximum health of the rover + int32 maximumIntegrity = 7; } // Empty placeholder From 143fba505e57543bced10155a4cc2d0417f12a4f Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 4 Jul 2020 12:25:15 +0100 Subject: [PATCH 031/228] Add Charge and Max Charge attributes to the rover --- cmd/rove-server/internal/routes.go | 2 + pkg/game/rover.go | 6 ++ pkg/rove/rove.pb.go | 100 ++++++++++++++++++----------- pkg/rove/rove.swagger.json | 10 +++ proto/rove/rove.proto | 6 ++ 5 files changed, 85 insertions(+), 39 deletions(-) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 4a40290..2ee852a 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -75,6 +75,8 @@ func (s *Server) Rover(ctx context.Context, req *rove.RoverRequest) (*rove.Rover Capacity: int32(rover.Capacity), Integrity: int32(rover.Integrity), MaximumIntegrity: int32(rover.MaximumIntegrity), + Charge: int32(rover.Charge), + MaximumCharge: int32(rover.MaximumCharge), } } return response, nil diff --git a/pkg/game/rover.go b/pkg/game/rover.go index b0f5dca..a7e3fb3 100644 --- a/pkg/game/rover.go +++ b/pkg/game/rover.go @@ -27,4 +27,10 @@ type Rover struct { // MaximumIntegrity is the full integrity of the rover MaximumIntegrity int `json:"maximum-integrity"` + + // Charge is the amount of energy the rover has + Charge int `json:"charge"` + + // ChargeCharge is the maximum charge able to be stored + MaximumCharge int `json:"maximum-Charge"` } diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index 733854c..38c507c 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -506,6 +506,10 @@ type RoverResponse struct { Integrity int32 `protobuf:"varint,6,opt,name=integrity,proto3" json:"integrity,omitempty"` // The maximum health of the rover MaximumIntegrity int32 `protobuf:"varint,7,opt,name=maximumIntegrity,proto3" json:"maximumIntegrity,omitempty"` + // The energy stored in the rover + Charge int32 `protobuf:"varint,8,opt,name=charge,proto3" json:"charge,omitempty"` + // The max energy the rover can store + MaximumCharge int32 `protobuf:"varint,9,opt,name=maximumCharge,proto3" json:"maximumCharge,omitempty"` } func (x *RoverResponse) Reset() { @@ -589,6 +593,20 @@ func (x *RoverResponse) GetMaximumIntegrity() int32 { return 0 } +func (x *RoverResponse) GetCharge() int32 { + if x != nil { + return x.Charge + } + return 0 +} + +func (x *RoverResponse) GetMaximumCharge() int32 { + if x != nil { + return x.MaximumCharge + } + return 0 +} + // Empty placeholder type StatusRequest struct { state protoimpl.MessageState @@ -791,7 +809,7 @@ var file_rove_rove_proto_rawDesc = []byte{ 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x28, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xe7, 0x01, 0x0a, 0x0d, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xa5, 0x02, 0x0a, 0x0d, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, @@ -805,44 +823,48 @@ var file_rove_rove_proto_rawDesc = []byte{ 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, - 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x22, - 0x0f, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x22, 0x71, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, - 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, - 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, - 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x32, 0xf8, 0x02, 0x0a, 0x04, 0x52, 0x6f, - 0x76, 0x65, 0x12, 0x44, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x0f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x09, 0x12, - 0x07, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4f, 0x0a, 0x08, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x63, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x61, - 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, - 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, - 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, 0x72, 0x3a, 0x01, 0x2a, 0x12, - 0x43, 0x0a, 0x05, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, - 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x6f, 0x76, 0x65, - 0x72, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, - 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, + 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, + 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, + 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x22, 0x0f, 0x0a, + 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x71, + 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x14, 0x0a, + 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, + 0x61, 0x64, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x32, 0xf8, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, + 0x12, 0x44, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x0f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x09, 0x12, 0x07, 0x2f, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4f, 0x0a, 0x08, 0x43, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x73, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x63, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, + 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, + 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, + 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, + 0x05, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x6f, + 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x3a, + 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, + 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/rove/rove.swagger.json b/pkg/rove/rove.swagger.json index 04a29d7..90b97fb 100644 --- a/pkg/rove/rove.swagger.json +++ b/pkg/rove/rove.swagger.json @@ -326,6 +326,16 @@ "type": "integer", "format": "int32", "title": "The maximum health of the rover" + }, + "charge": { + "type": "integer", + "format": "int32", + "title": "The energy stored in the rover" + }, + "maximumCharge": { + "type": "integer", + "format": "int32", + "title": "The max energy the rover can store" } } }, diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index 38cd995..6c40234 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -137,6 +137,12 @@ message RoverResponse { // The maximum health of the rover int32 maximumIntegrity = 7; + + // The energy stored in the rover + int32 charge = 8; + + // The max energy the rover can store + int32 maximumCharge = 9; } // Empty placeholder From dbe944bb4e75db193e6d9a65c7c30aaa8b878f3e Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 4 Jul 2020 12:30:40 +0100 Subject: [PATCH 032/228] Add charge and apply it to rover actions --- pkg/game/world.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pkg/game/world.go b/pkg/game/world.go index c0ff212..a0a299f 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -75,10 +75,12 @@ func (w *World) SpawnRover() (string, error) { // Initialise the rover rover := Rover{ - Range: 4.0, + Range: 4, Integrity: 10, MaximumIntegrity: 10, Capacity: 10, + Charge: 10, + MaximumCharge: 10, Name: uuid.New().String(), } @@ -219,6 +221,13 @@ func (w *World) MoveRover(rover string, b bearing.Bearing) (vector.Vector, error if !ok { return vector.Vector{}, fmt.Errorf("no rover matching id") } + + // Ensure the rover has energy + if i.Charge <= 0 { + return i.Pos, nil + } + i.Charge-- + // Try the new move position newPos := i.Pos.Added(b.Vector()) @@ -256,6 +265,12 @@ func (w *World) RoverStash(rover string) (objects.Type, error) { return objects.None, nil } + // Ensure the rover has energy + if r.Charge <= 0 { + return objects.None, nil + } + r.Charge-- + _, obj := w.Atlas.QueryPosition(r.Pos) if !obj.IsStashable() { return objects.None, nil From 8b83672dcc21869ee03802cd04cdf9c411779cad Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 4 Jul 2020 22:34:28 +0100 Subject: [PATCH 033/228] Fix Atlas gen with simplification Only track lower and upper bounds in world space, and speak in terms of world space and chunks --- pkg/atlas/atlas.go | 171 +++++++++++++++------------------------- pkg/atlas/atlas_test.go | 141 +++++++++++++++++++++++++++++---- pkg/maths/maths.go | 16 ++++ pkg/maths/maths_test.go | 14 ++++ pkg/vector/vector.go | 19 +++++ 5 files changed, 240 insertions(+), 121 deletions(-) diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index 6ec11e2..ef25d9c 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -38,11 +38,11 @@ type Atlas struct { // This is intentionally not a 2D array so it can be expanded in all directions Chunks []Chunk `json:"chunks"` - // CurrentSize is the current width/height of the atlas in chunks - CurrentSize vector.Vector `json:"currentSize"` + // LowerBound is the origin of the bottom left corner of the current chunks in world space (current chunks cover >= this value) + LowerBound vector.Vector `json:"lowerBound"` - // WorldOrigin represents the location of the [0,0] world space point in terms of the allotted current chunks - WorldOrigin vector.Vector `json:"worldOrigin"` + // UpperBound is the top left corner of the current chunks (curent chunks cover < this value) + UpperBound vector.Vector `json:"upperBound"` // ChunkSize is the x/y dimensions of each square chunk ChunkSize int `json:"chunksize"` @@ -52,10 +52,10 @@ type Atlas struct { func NewAtlas(chunkSize int) Atlas { // Start up with one chunk a := Atlas{ - ChunkSize: chunkSize, - Chunks: make([]Chunk, 1), - CurrentSize: vector.Vector{X: 1, Y: 1}, - WorldOrigin: vector.Vector{X: 0, Y: 0}, + ChunkSize: chunkSize, + Chunks: make([]Chunk, 1), + LowerBound: vector.Vector{X: 0, Y: 0}, + UpperBound: vector.Vector{X: chunkSize, Y: chunkSize}, } // Initialise the first chunk a.Chunks[0].populate(chunkSize) @@ -162,129 +162,88 @@ func (a *Atlas) worldSpaceToChunkLocal(v vector.Vector) vector.Vector { return vector.Vector{X: maths.Pmod(v.X, a.ChunkSize), Y: maths.Pmod(v.Y, a.ChunkSize)} } -// worldSpaceToChunk gets the current chunk ID for a position in the world -func (a *Atlas) worldSpaceToChunk(v vector.Vector) int { - // First convert to chunk space - chunkSpace := a.worldSpaceToChunkSpace(v) +// worldSpaceToChunkID gets the current chunk ID for a position in the world +func (a *Atlas) worldSpaceToChunkIndex(v vector.Vector) int { + // Shift the vector by our current min + v = v.Added(a.LowerBound.Negated()) - // Then return the ID - return a.chunkSpaceToChunk(chunkSpace) + // Divide by the current size and floor, to get chunk-scaled vector from the lower bound + v = v.DividedFloor(a.ChunkSize) + + // Calculate the width + width := a.UpperBound.X - a.LowerBound.X + widthInChunks := width / a.ChunkSize + + // Along the corridor and up the stairs + return (v.Y * widthInChunks) + v.X } -// worldSpaceToChunkSpace converts from world space to chunk space -func (a *Atlas) worldSpaceToChunkSpace(v vector.Vector) vector.Vector { - // Remove the chunk local part - chunkOrigin := v.Added(a.worldSpaceToChunkLocal(v).Negated()) - // Convert to chunk space coordinate - chunkSpaceOrigin := chunkOrigin.Divided(a.ChunkSize) - // Shift it by our current chunk origin - chunkIndexOrigin := chunkSpaceOrigin.Added(a.WorldOrigin) - - return chunkIndexOrigin -} - -// chunkSpaceToWorldSpace vonverts from chunk space to world space -func (a *Atlas) chunkSpaceToWorldSpace(v vector.Vector) vector.Vector { - - // Shift it by the current chunk origin - shifted := v.Added(a.WorldOrigin.Negated()) - - // Multiply out by chunk size - return shifted.Multiplied(a.ChunkSize) -} - -// chunkOriginInChunkSpace Gets the chunk origin in chunk space -func (a *Atlas) chunkOriginInChunkSpace(chunk int) vector.Vector { - // convert the chunk to chunk space - chunkOrigin := a.chunkToChunkSpace(chunk) - - // Shift it by the current chunk origin - return chunkOrigin.Added(a.WorldOrigin.Negated()) -} - -// chunkOriginInWorldSpace gets the chunk origin for a given chunk index +// chunkOriginInWorldSpace returns the origin of the chunk in world space func (a *Atlas) chunkOriginInWorldSpace(chunk int) vector.Vector { - // convert the chunk to chunk space - chunkSpace := a.chunkToChunkSpace(chunk) + // Calculate the width + width := a.UpperBound.X - a.LowerBound.X + widthInChunks := width / a.ChunkSize - // Convert to world space - return a.chunkSpaceToWorldSpace(chunkSpace) -} - -// chunkSpaceToChunk converts from chunk space to the chunk -func (a *Atlas) chunkSpaceToChunk(v vector.Vector) int { - // Along the coridor and up the stair - return (v.Y * a.CurrentSize.X) + v.X -} - -// chunkToChunkSpace returns the chunk space coord for the chunk -func (a *Atlas) chunkToChunkSpace(chunk int) vector.Vector { - return vector.Vector{ - X: maths.Pmod(chunk, a.CurrentSize.Y), - Y: (chunk / a.CurrentSize.X), + // Reverse the along the corridor and up the stairs + v := vector.Vector{ + X: chunk % widthInChunks, + Y: chunk / widthInChunks, } + // Multiply up to world scale + v = v.Multiplied(a.ChunkSize) + // Shift by the lower bound + return v.Added(a.LowerBound) } -func (a *Atlas) getExtents() (min vector.Vector, max vector.Vector) { - min = a.WorldOrigin.Negated() - max = min.Added(a.CurrentSize) +// getNewBounds gets new lower and upper bounds for the world space given a vector +func (a *Atlas) getNewBounds(v vector.Vector) (lower vector.Vector, upper vector.Vector) { + lower = vector.Min(v, a.LowerBound) + upper = vector.Max(v.Added(vector.Vector{X: 1, Y: 1}), a.UpperBound) + + lower = vector.Vector{ + X: maths.RoundDown(lower.X, a.ChunkSize), + Y: maths.RoundDown(lower.Y, a.ChunkSize), + } + upper = vector.Vector{ + X: maths.RoundUp(upper.X, a.ChunkSize), + Y: maths.RoundUp(upper.Y, a.ChunkSize), + } return } // worldSpaceToTrunkWithGrow will expand the current atlas for a given world space position if needed func (a *Atlas) worldSpaceToChunkWithGrow(v vector.Vector) int { - min, max := a.getExtents() - - // Divide by the chunk size to bring into chunk space - v = v.Divided(a.ChunkSize) - - // Check we're within the current extents and bail early - if v.X >= min.X && v.Y >= min.Y && v.X < max.X && v.Y < max.Y { - return a.worldSpaceToChunk(v) + // If we're within bounds, just return the current chunk + if v.X >= a.LowerBound.X && v.Y >= a.LowerBound.Y && v.X < a.UpperBound.X && v.Y < a.UpperBound.Y { + return a.worldSpaceToChunkIndex(v) } - // Calculate the new origin and the new size - origin := min - size := a.CurrentSize + // Calculate the new bounds + lower, upper := a.getNewBounds(v) + size := upper.Added(lower.Negated()) + size = size.Divided(a.ChunkSize) - // If we need to shift the origin back - originDiff := origin.Added(v.Negated()) - if originDiff.X > 0 { - origin.X -= originDiff.X - size.X += originDiff.X - } - if originDiff.Y > 0 { - origin.Y -= originDiff.Y - size.Y += originDiff.Y - } - - // If we need to expand the size - maxDiff := v.Added(max.Negated()) - if maxDiff.X > 0 { - size.X += maxDiff.X - } - if maxDiff.Y > 0 { - size.Y += maxDiff.Y - } - - // Set up the new size and origin + // Create the new empty atlas newAtlas := Atlas{ - ChunkSize: a.ChunkSize, - WorldOrigin: origin.Negated(), - CurrentSize: size, - Chunks: make([]Chunk, size.X*size.Y), + ChunkSize: a.ChunkSize, + LowerBound: lower, + UpperBound: upper, + Chunks: make([]Chunk, size.X*size.Y), } // Copy all old chunks into the new atlas for chunk, chunkData := range a.Chunks { - // Calculate the new chunk location and copy over the data - newChunk := newAtlas.worldSpaceToChunk(a.chunkOriginInWorldSpace(chunk)) + + // Calculate the chunk ID in the new atlas + origin := a.chunkOriginInWorldSpace(chunk) + newChunk := newAtlas.worldSpaceToChunkIndex(origin) + // Copy over the old chunk to the new atlas newAtlas.Chunks[newChunk] = chunkData } - // Copy the new atlas data into this one + // Overwrite the old atlas with this one *a = newAtlas - return a.worldSpaceToChunk(v) + return a.worldSpaceToChunkIndex(v) } diff --git a/pkg/atlas/atlas_test.go b/pkg/atlas/atlas_test.go index 9778150..60c3922 100644 --- a/pkg/atlas/atlas_test.go +++ b/pkg/atlas/atlas_test.go @@ -22,43 +22,49 @@ func TestAtlas_toChunk(t *testing.T) { // Get a tile to spawn the chunks a.QueryPosition(vector.Vector{X: -1, Y: -1}) a.QueryPosition(vector.Vector{X: 0, Y: 0}) + assert.Equal(t, 2*2, len(a.Chunks)) // Chunks should look like: // 2 | 3 // ----- // 0 | 1 - chunkID := a.worldSpaceToChunk(vector.Vector{X: 0, Y: 0}) + chunkID := a.worldSpaceToChunkIndex(vector.Vector{X: 0, Y: 0}) assert.Equal(t, 3, chunkID) - chunkID = a.worldSpaceToChunk(vector.Vector{X: 0, Y: -1}) + chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: 0, Y: -1}) assert.Equal(t, 1, chunkID) - chunkID = a.worldSpaceToChunk(vector.Vector{X: -1, Y: -1}) + chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -1, Y: -1}) assert.Equal(t, 0, chunkID) - chunkID = a.worldSpaceToChunk(vector.Vector{X: -1, Y: 0}) + chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -1, Y: 0}) assert.Equal(t, 2, chunkID) a = NewAtlas(2) assert.NotNil(t, a) // Get a tile to spawn the chunks a.QueryPosition(vector.Vector{X: -2, Y: -2}) + assert.Equal(t, 2*2, len(a.Chunks)) a.QueryPosition(vector.Vector{X: 1, Y: 1}) + assert.Equal(t, 2*2, len(a.Chunks)) // Chunks should look like: // 2 | 3 // ----- // 0 | 1 - chunkID = a.worldSpaceToChunk(vector.Vector{X: 1, Y: 1}) + chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: 1, Y: 1}) assert.Equal(t, 3, chunkID) - chunkID = a.worldSpaceToChunk(vector.Vector{X: 1, Y: -2}) + chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: 1, Y: -2}) assert.Equal(t, 1, chunkID) - chunkID = a.worldSpaceToChunk(vector.Vector{X: -2, Y: -2}) + chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -2, Y: -2}) assert.Equal(t, 0, chunkID) - chunkID = a.worldSpaceToChunk(vector.Vector{X: -2, Y: 1}) + chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -2, Y: 1}) assert.Equal(t, 2, chunkID) a = NewAtlas(2) assert.NotNil(t, a) - // Get a tile to spawn the chunks - a.QueryPosition(vector.Vector{X: 5, Y: 5}) - a.QueryPosition(vector.Vector{X: -5, Y: -5}) + // Get a tile to spawn a 4x4 grid of chunks + a.QueryPosition(vector.Vector{X: 3, Y: 3}) + assert.Equal(t, 2*2, len(a.Chunks)) + a.QueryPosition(vector.Vector{X: -3, Y: -3}) + assert.Equal(t, 4*4, len(a.Chunks)) + // Chunks should look like: // 12| 13|| 14| 15 // ---------------- @@ -67,14 +73,96 @@ func TestAtlas_toChunk(t *testing.T) { // 4 | 5 || 6 | 7 // ---------------- // 0 | 1 || 2 | 3 - chunkID = a.worldSpaceToChunk(vector.Vector{X: 1, Y: 3}) + chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: 1, Y: 3}) assert.Equal(t, 14, chunkID) - chunkID = a.worldSpaceToChunk(vector.Vector{X: 1, Y: -3}) + chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: 1, Y: -3}) assert.Equal(t, 2, chunkID) - chunkID = a.worldSpaceToChunk(vector.Vector{X: -1, Y: -1}) + chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -1, Y: -1}) assert.Equal(t, 5, chunkID) - chunkID = a.worldSpaceToChunk(vector.Vector{X: -2, Y: 2}) + chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -2, Y: 2}) assert.Equal(t, 13, chunkID) + + a = NewAtlas(3) + assert.NotNil(t, a) + // Get a tile to spawn a 4x4 grid of chunks + a.QueryPosition(vector.Vector{X: 3, Y: 3}) + assert.Equal(t, 2*2, len(a.Chunks)) + + // Chunks should look like: + // || 2| 3 + // ------- + // || 0| 1 + // ======= + chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: 1, Y: 1}) + assert.Equal(t, 0, chunkID) + chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: 3, Y: 1}) + assert.Equal(t, 1, chunkID) + chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: 1, Y: 4}) + assert.Equal(t, 2, chunkID) + chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: 5, Y: 5}) + assert.Equal(t, 3, chunkID) +} + +func TestAtlas_toWorld(t *testing.T) { + a := NewAtlas(1) + assert.NotNil(t, a) + + // Get a tile to spawn some chunks + a.QueryPosition(vector.Vector{X: -1, Y: -1}) + assert.Equal(t, 2*2, len(a.Chunks)) + + // Chunks should look like: + // 2 | 3 + // ----- + // 0 | 1 + assert.Equal(t, vector.Vector{X: -1, Y: -1}, a.chunkOriginInWorldSpace(0)) + assert.Equal(t, vector.Vector{X: 0, Y: -1}, a.chunkOriginInWorldSpace(1)) + + a = NewAtlas(2) + assert.NotNil(t, a) + // Get a tile to spawn the chunks + a.QueryPosition(vector.Vector{X: -2, Y: -2}) + assert.Equal(t, 2*2, len(a.Chunks)) + a.QueryPosition(vector.Vector{X: 1, Y: 1}) + assert.Equal(t, 2*2, len(a.Chunks)) + // Chunks should look like: + // 2 | 3 + // ----- + // 0 | 1 + assert.Equal(t, vector.Vector{X: -2, Y: -2}, a.chunkOriginInWorldSpace(0)) + assert.Equal(t, vector.Vector{X: -2, Y: 0}, a.chunkOriginInWorldSpace(2)) + + a = NewAtlas(2) + assert.NotNil(t, a) + // Get a tile to spawn a 4x4 grid of chunks + a.QueryPosition(vector.Vector{X: 3, Y: 3}) + assert.Equal(t, 2*2, len(a.Chunks)) + a.QueryPosition(vector.Vector{X: -3, Y: -3}) + assert.Equal(t, 4*4, len(a.Chunks)) + + // Chunks should look like: + // 12| 13|| 14| 15 + // ---------------- + // 8 | 9 || 10| 11 + // ================ + // 4 | 5 || 6 | 7 + // ---------------- + // 0 | 1 || 2 | 3 + assert.Equal(t, vector.Vector{X: -4, Y: -4}, a.chunkOriginInWorldSpace(0)) + assert.Equal(t, vector.Vector{X: 2, Y: -2}, a.chunkOriginInWorldSpace(7)) + + a = NewAtlas(3) + assert.NotNil(t, a) + // Get a tile to spawn a 4x4 grid of chunks + a.QueryPosition(vector.Vector{X: 3, Y: 3}) + assert.Equal(t, 2*2, len(a.Chunks)) + + // Chunks should look like: + // || 2| 3 + // ------- + // || 0| 1 + // ======= + assert.Equal(t, vector.Vector{X: 0, Y: 0}, a.chunkOriginInWorldSpace(0)) } func TestAtlas_GetSetTile(t *testing.T) { @@ -137,3 +225,26 @@ func TestAtlas_Grown(t *testing.T) { tile, _ = a.QueryPosition(vector.Vector{X: 1, Y: -2}) assert.Equal(t, byte(3), tile) } + +func TestAtlas_GetSetCorrect(t *testing.T) { + // Big stress test to ensure we do actually properly expand for all reasonable values + for i := 1; i <= 4; i++ { + + for x := -i * 2; x < i*2; x++ { + for y := -i * 2; y < i*2; y++ { + a := NewAtlas(i) + assert.NotNil(t, a) + assert.Equal(t, 1, len(a.Chunks)) + + pos := vector.Vector{X: x, Y: y} + a.SetTile(pos, TileRock) + a.SetObject(pos, objects.Object{Type: objects.LargeRock}) + tile, obj := a.QueryPosition(pos) + + assert.Equal(t, TileRock, Tile(tile)) + assert.Equal(t, objects.Object{Type: objects.LargeRock}, obj) + + } + } + } +} diff --git a/pkg/maths/maths.go b/pkg/maths/maths.go index 76c00a5..cd40516 100644 --- a/pkg/maths/maths.go +++ b/pkg/maths/maths.go @@ -39,3 +39,19 @@ func Min(x, y int) int { } return x } + +// RoundUp rounds a value up to the nearest multiple +func RoundUp(toRound int, multiple int) int { + remainder := Pmod(toRound, multiple) + if remainder == 0 { + return toRound + } + + return (multiple - remainder) + toRound +} + +// RoundDown rounds a value down to the nearest multiple +func RoundDown(toRound int, multiple int) int { + remainder := Pmod(toRound, multiple) + return toRound - remainder +} diff --git a/pkg/maths/maths_test.go b/pkg/maths/maths_test.go index cf2c180..730da77 100644 --- a/pkg/maths/maths_test.go +++ b/pkg/maths/maths_test.go @@ -29,5 +29,19 @@ func TestMin(t *testing.T) { assert.Equal(t, 100, Min(100, 500)) assert.Equal(t, -4, Min(-4, 1)) assert.Equal(t, -4, Min(-4, -2)) +} + +func TestRoundUp(t *testing.T) { + assert.Equal(t, 10, RoundUp(10, 5)) + assert.Equal(t, 12, RoundUp(10, 4)) + assert.Equal(t, -8, RoundUp(-8, 4)) + assert.Equal(t, -4, RoundUp(-7, 4)) +} + +func TestRoundDown(t *testing.T) { + assert.Equal(t, 10, RoundDown(10, 5)) + assert.Equal(t, 8, RoundDown(10, 4)) + assert.Equal(t, -8, RoundDown(-8, 4)) + assert.Equal(t, -8, RoundDown(-7, 4)) } diff --git a/pkg/vector/vector.go b/pkg/vector/vector.go index b661d17..a8955be 100644 --- a/pkg/vector/vector.go +++ b/pkg/vector/vector.go @@ -50,6 +50,25 @@ func (v Vector) Divided(val int) Vector { return Vector{v.X / val, v.Y / val} } +// DividedFloor returns the vector divided but floors the value regardless +func (v Vector) DividedFloor(val int) Vector { + x := float64(v.X) / float64(val) + + if x < 0 { + x = math.Floor(x) + } else { + x = math.Floor(x) + } + y := float64(v.Y) / float64(val) + if y < 0 { + y = math.Floor(y) + } else { + y = math.Floor(y) + } + + return Vector{X: int(x), Y: int(y)} +} + // Abs returns an absolute version of the vector func (v Vector) Abs() Vector { return Vector{maths.Abs(v.X), maths.Abs(v.Y)} From 15c337c0675829ba54e965ca76e91cb7eba70586 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 4 Jul 2020 22:35:25 +0100 Subject: [PATCH 034/228] Make moving and stashing cost rover charge --- pkg/game/world.go | 19 ++++++++++++++ pkg/game/world_test.go | 56 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/pkg/game/world.go b/pkg/game/world.go index a0a299f..c5e9769 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -134,6 +134,25 @@ func (w *World) GetRover(rover string) (Rover, error) { return i, nil } +// ChargeRover charges up a rover +func (w *World) ChargeRover(rover string) (int, error) { + w.worldMutex.Lock() + defer w.worldMutex.Unlock() + + i, ok := w.Rovers[rover] + if !ok { + return 0, fmt.Errorf("Failed to find rover with name: %s", rover) + } + + // Add one charge + if i.Charge < i.MaximumCharge { + i.Charge++ + } + w.Rovers[rover] = i + + return i.Charge, nil +} + // DestroyRover Removes an rover from the game func (w *World) DestroyRover(rover string) error { w.worldMutex.Lock() diff --git a/pkg/game/world_test.go b/pkg/game/world_test.go index 4ee0676..b19ce97 100644 --- a/pkg/game/world_test.go +++ b/pkg/game/world_test.go @@ -84,10 +84,18 @@ func TestWorld_GetSetMovePosition(t *testing.T) { pos.Add(vector.Vector{X: 0, Y: 1}) assert.Equal(t, pos, newPos, "Failed to correctly move position for rover") + rover, err := world.GetRover(a) + assert.NoError(t, err, "Failed to get rover information") + assert.Equal(t, rover.MaximumCharge-1, rover.Charge, "Rover should have lost charge for moving") + // Place a tile in front of the rover world.Atlas.SetObject(vector.Vector{X: 0, Y: 2}, objects.Object{Type: objects.LargeRock}) newPos, err = world.MoveRover(a, b) assert.Equal(t, pos, newPos, "Failed to correctly not move position for rover into wall") + + rover, err = world.GetRover(a) + assert.NoError(t, err, "Failed to get rover information") + assert.Equal(t, rover.MaximumCharge-2, rover.Charge, "Rover should have lost charge for move attempt") } func TestWorld_RadarFromRover(t *testing.T) { @@ -151,6 +159,16 @@ func TestWorld_RoverStash(t *testing.T) { assert.NoError(t, err, "Failed to get inventory") assert.Equal(t, i+1, len(inv)) assert.Equal(t, objects.Object{Type: objects.SmallRock}, inv[i]) + + // Check that this didn't reduce the charge + info, err := world.GetRover(a) + assert.NoError(t, err, "Failed to get rover") + assert.Equal(t, info.MaximumCharge-(i+1), info.Charge, "Rover lost charge for stash") + } + + // Recharge the rover + for i := 0; i < rover.MaximumCharge; i++ { + world.ChargeRover(a) } // Place an object @@ -169,6 +187,11 @@ func TestWorld_RoverStash(t *testing.T) { inv, err := world.RoverInventory(a) assert.NoError(t, err, "Failed to get inventory") assert.Equal(t, rover.Capacity, len(inv)) + + // Check that this didn't reduce the charge + info, err := world.GetRover(a) + assert.NoError(t, err, "Failed to get rover") + assert.Equal(t, info.MaximumCharge, info.Charge, "Rover lost charge for non-stash") } func TestWorld_RoverDamage(t *testing.T) { @@ -254,3 +277,36 @@ func TestWorld_RoverRepair(t *testing.T) { assert.NoError(t, err, "couldn't get rover info") assert.Equal(t, originalInfo.Integrity, newinfo.Integrity, "rover should have kept the same integrity") } + +func TestWorld_Charge(t *testing.T) { + world := NewWorld(4) + a, err := world.SpawnRover() + assert.NoError(t, err) + + // Get the rover information + rover, err := world.GetRover(a) + assert.NoError(t, err, "Failed to get rover information") + assert.Equal(t, rover.MaximumCharge, rover.Charge, "Rover should start with maximum charge") + + // Use up all the charge + for i := 0; i < rover.MaximumCharge; i++ { + // Get the initial position + initialPos, err := world.RoverPosition(a) + assert.NoError(t, err, "Failed to get position for rover") + + // Ensure the path ahead is empty + world.Atlas.SetTile(initialPos.Added(bearing.North.Vector()), atlas.TileRock) + world.Atlas.SetObject(initialPos.Added(bearing.North.Vector()), objects.Object{Type: objects.None}) + + // Try and move north (along unblocked path) + newPos, err := world.MoveRover(a, bearing.North) + assert.NoError(t, err, "Failed to set position for rover") + assert.Equal(t, initialPos.Added(bearing.North.Vector()), newPos, "Failed to correctly move position for rover") + + // Ensure rover lost charge + rover, err := world.GetRover(a) + assert.NoError(t, err, "Failed to get rover information") + assert.Equal(t, rover.MaximumCharge-(i+1), rover.Charge, "Rover should have lost charge") + } + +} From e875f82b137dcee995e082623f2c63346948083d Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 4 Jul 2020 22:42:20 +0100 Subject: [PATCH 035/228] Add command "charge" to charge up the rover's energy store --- pkg/game/command.go | 3 +++ pkg/game/command_test.go | 35 +++++++++++++++++++++++++++++++++++ pkg/game/world.go | 6 ++++++ proto/rove/rove.proto | 1 + 4 files changed, 45 insertions(+) diff --git a/pkg/game/command.go b/pkg/game/command.go index cde071e..caecaec 100644 --- a/pkg/game/command.go +++ b/pkg/game/command.go @@ -9,6 +9,9 @@ const ( // CommandRepair Will attempt to repair the rover with an inventory object CommandRepair = "repair" + + // CommandCharge Will use one tick to charge the rover + CommandCharge = "charge" ) // Command represends a single command to execute diff --git a/pkg/game/command_test.go b/pkg/game/command_test.go index 3356f2a..a809753 100644 --- a/pkg/game/command_test.go +++ b/pkg/game/command_test.go @@ -32,3 +32,38 @@ func TestCommand_Move(t *testing.T) { pos.Add(vector.Vector{X: 0.0, Y: 1}) assert.Equal(t, pos, newPos, "Failed to correctly set position for rover") } + +func TestCommand_Charge(t *testing.T) { + world := NewWorld(8) + a, err := world.SpawnRover() + assert.NoError(t, err) + pos := vector.Vector{ + X: 1.0, + Y: 2.0, + } + + err = world.WarpRover(a, pos) + assert.NoError(t, err, "Failed to set position for rover") + + // Move to use up some charge + moveCommand := Command{Command: CommandMove, Bearing: "N"} + assert.NoError(t, world.Enqueue(a, moveCommand), "Failed to queue move command") + + // Tick the world + world.EnqueueAllIncoming() + world.ExecuteCommandQueues() + + rover, _ := world.GetRover(a) + assert.Equal(t, rover.MaximumCharge-1, rover.Charge) + + chargeCommand := Command{Command: CommandCharge} + assert.NoError(t, world.Enqueue(a, chargeCommand), "Failed to queue charge command") + + // Tick the world + world.EnqueueAllIncoming() + world.ExecuteCommandQueues() + + rover, _ = world.GetRover(a) + assert.Equal(t, rover.MaximumCharge, rover.Charge) + +} diff --git a/pkg/game/world.go b/pkg/game/world.go index c5e9769..7e9147c 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -371,6 +371,7 @@ func (w *World) Enqueue(rover string, commands ...Command) error { } case CommandStash: case CommandRepair: + case CommandCharge: // Nothing to verify default: return fmt.Errorf("unknown command: %s", c.Command) @@ -458,6 +459,11 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { r.Integrity = r.Integrity + 1 w.Rovers[rover] = r } + case CommandCharge: + _, err := w.ChargeRover(rover) + if err != nil { + return err + } default: return fmt.Errorf("unknown command: %s", c.Command) } diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index 6c40234..35b658f 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -65,6 +65,7 @@ message Command { // "move" - Move the rover in a direction, requires bearing // "stash" - Stashes item at current location in rover inventory // "repair" - Repairs the rover using an inventory object + // "charge" - Waits a tick to add more charge to the rover string command = 1; // The bearing, example: NE From 72727496148afe8bdf9260d98cc79903f64f4ebd Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 4 Jul 2020 22:42:37 +0100 Subject: [PATCH 036/228] Enable command line client to accept new commands --- cmd/rove/main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 17e35aa..cf47692 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -217,10 +217,11 @@ func InnerMain(command string, args ...string) error { Bearing: args[i], }, ) - case "stash": + default: + // By default just use the command literally commands = append(commands, &rove.Command{ - Command: game.CommandStash, + Command: args[i], }, ) } From 87af905bc8b85b214a33cdf7a1b803e7cce25613 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 4 Jul 2020 22:56:58 +0100 Subject: [PATCH 037/228] Rename charge command to recharge --- pkg/game/command.go | 4 ++-- pkg/game/command_test.go | 6 +++--- pkg/game/world.go | 10 +++++----- pkg/game/world_test.go | 2 +- pkg/rove/rove.pb.go | 1 + pkg/rove/rove.swagger.json | 2 +- proto/rove/rove.proto | 2 +- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/pkg/game/command.go b/pkg/game/command.go index caecaec..11428c3 100644 --- a/pkg/game/command.go +++ b/pkg/game/command.go @@ -10,8 +10,8 @@ const ( // CommandRepair Will attempt to repair the rover with an inventory object CommandRepair = "repair" - // CommandCharge Will use one tick to charge the rover - CommandCharge = "charge" + // CommandRecharge Will use one tick to charge the rover + CommandRecharge = "recharge" ) // Command represends a single command to execute diff --git a/pkg/game/command_test.go b/pkg/game/command_test.go index a809753..45cb182 100644 --- a/pkg/game/command_test.go +++ b/pkg/game/command_test.go @@ -33,7 +33,7 @@ func TestCommand_Move(t *testing.T) { assert.Equal(t, pos, newPos, "Failed to correctly set position for rover") } -func TestCommand_Charge(t *testing.T) { +func TestCommand_Recharge(t *testing.T) { world := NewWorld(8) a, err := world.SpawnRover() assert.NoError(t, err) @@ -56,8 +56,8 @@ func TestCommand_Charge(t *testing.T) { rover, _ := world.GetRover(a) assert.Equal(t, rover.MaximumCharge-1, rover.Charge) - chargeCommand := Command{Command: CommandCharge} - assert.NoError(t, world.Enqueue(a, chargeCommand), "Failed to queue charge command") + chargeCommand := Command{Command: CommandRecharge} + assert.NoError(t, world.Enqueue(a, chargeCommand), "Failed to queue recharge command") // Tick the world world.EnqueueAllIncoming() diff --git a/pkg/game/world.go b/pkg/game/world.go index 7e9147c..a3f1e10 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -134,8 +134,8 @@ func (w *World) GetRover(rover string) (Rover, error) { return i, nil } -// ChargeRover charges up a rover -func (w *World) ChargeRover(rover string) (int, error) { +// RoverRecharge charges up a rover +func (w *World) RoverRecharge(rover string) (int, error) { w.worldMutex.Lock() defer w.worldMutex.Unlock() @@ -371,7 +371,7 @@ func (w *World) Enqueue(rover string, commands ...Command) error { } case CommandStash: case CommandRepair: - case CommandCharge: + case CommandRecharge: // Nothing to verify default: return fmt.Errorf("unknown command: %s", c.Command) @@ -459,8 +459,8 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { r.Integrity = r.Integrity + 1 w.Rovers[rover] = r } - case CommandCharge: - _, err := w.ChargeRover(rover) + case CommandRecharge: + _, err := w.RoverRecharge(rover) if err != nil { return err } diff --git a/pkg/game/world_test.go b/pkg/game/world_test.go index b19ce97..9b4e696 100644 --- a/pkg/game/world_test.go +++ b/pkg/game/world_test.go @@ -168,7 +168,7 @@ func TestWorld_RoverStash(t *testing.T) { // Recharge the rover for i := 0; i < rover.MaximumCharge; i++ { - world.ChargeRover(a) + world.RoverRecharge(a) } // Place an object diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index 38c507c..2bee993 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -43,6 +43,7 @@ type Command struct { // "move" - Move the rover in a direction, requires bearing // "stash" - Stashes item at current location in rover inventory // "repair" - Repairs the rover using an inventory object + // "recharge" - Waits a tick to add more charge to the rover Command string `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"` // The bearing, example: NE Bearing string `protobuf:"bytes,2,opt,name=bearing,proto3" json:"bearing,omitempty"` diff --git a/pkg/rove/rove.swagger.json b/pkg/rove/rove.swagger.json index 90b97fb..4e55cab 100644 --- a/pkg/rove/rove.swagger.json +++ b/pkg/rove/rove.swagger.json @@ -212,7 +212,7 @@ "properties": { "command": { "type": "string", - "title": "The command to execute\n\"move\" - Move the rover in a direction, requires bearing\n\"stash\" - Stashes item at current location in rover inventory\n\"repair\" - Repairs the rover using an inventory object" + "title": "The command to execute\n\"move\" - Move the rover in a direction, requires bearing\n\"stash\" - Stashes item at current location in rover inventory\n\"repair\" - Repairs the rover using an inventory object\n\"recharge\" - Waits a tick to add more charge to the rover" }, "bearing": { "type": "string", diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index 35b658f..73659f2 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -65,7 +65,7 @@ message Command { // "move" - Move the rover in a direction, requires bearing // "stash" - Stashes item at current location in rover inventory // "repair" - Repairs the rover using an inventory object - // "charge" - Waits a tick to add more charge to the rover + // "recharge" - Waits a tick to add more charge to the rover string command = 1; // The bearing, example: NE From 31308db6b533f1f95b86667653217c59e92d0d14 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 4 Jul 2020 22:57:19 +0100 Subject: [PATCH 038/228] Tick off energy in upcoming features and simplify current features --- docs/status.md | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/docs/status.md b/docs/status.md index 951abc1..6a54ecf 100644 --- a/docs/status.md +++ b/docs/status.md @@ -5,22 +5,18 @@ This page tracks the current feature set and the features to implement next ### Current features -* Users can register account and spawn rover -* Users can command the rover to move -* Server can return rover's current radar -* Server supports multiple users and rovers -* Map is populated with rocks -* Commands are queued and then are executed in sequence -* Rover inventory -* Collectable materials -* Rover has integrity and takes damage on collisions -* Rover can repair +* Users can register and spawn a rover +* The rover can be commanded to move, stash, repair and recharge +* Rover commands use energy +* The rover has a radar function to view nearby terrain and objects +* The server supports multiple users +* The map is populated with terrain and objects +* Rovers take damage and can use collected materials to repair ### Incoming features * Rover replacement and advancement mechanic * Dormant rovers -* Rover energy with solar charging * Day/night cycle * More hazards * Simple rover to rover communication From 98eea894847a6604396d60b74c356b4256b64e13 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 4 Jul 2020 22:59:27 +0100 Subject: [PATCH 039/228] Adjust goals to focus on core rover gameplay --- docs/status.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/status.md b/docs/status.md index 6a54ecf..c9d5f1b 100644 --- a/docs/status.md +++ b/docs/status.md @@ -15,14 +15,14 @@ This page tracks the current feature set and the features to implement next ### Incoming features -* Rover replacement and advancement mechanic -* Dormant rovers * Day/night cycle -* More hazards -* Simple rover to rover communication +* Weather cycle * Deterministic and intelligent world-gen ### Stretch goals +* Simple rover to rover communication +* Rover replacement and advancement mechanic +* Dormant rovers * Render rover camera view * Account token security \ No newline at end of file From f8e594cb3926b47541d90be0e37234f51b8af3a4 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 4 Jul 2020 23:05:08 +0100 Subject: [PATCH 040/228] Rename "status" command to "server-status" --- cmd/rove-server-rest-proxy/http_test.go | 8 +- cmd/rove-server/internal/routes.go | 4 +- cmd/rove/main.go | 6 +- cmd/rove/main_test.go | 4 +- pkg/rove/rove.pb.go | 181 ++++++++++++------------ pkg/rove/rove.pb.gw.go | 28 ++-- pkg/rove/rove.swagger.json | 8 +- proto/rove/rove.proto | 8 +- 8 files changed, 125 insertions(+), 122 deletions(-) diff --git a/cmd/rove-server-rest-proxy/http_test.go b/cmd/rove-server-rest-proxy/http_test.go index ba55fb9..586b5e1 100644 --- a/cmd/rove-server-rest-proxy/http_test.go +++ b/cmd/rove-server-rest-proxy/http_test.go @@ -61,10 +61,10 @@ func (s Server) Request(method, path string, in, out interface{}) error { var serv = Server(os.Getenv("ROVE_HTTP")) -func TestServer_Status(t *testing.T) { - req := &rove.StatusRequest{} - resp := &rove.StatusResponse{} - if err := serv.Request("GET", "status", req, resp); err != nil { +func TestServer_ServerStatus(t *testing.T) { + req := &rove.ServerStatusRequest{} + resp := &rove.ServerStatusResponse{} + if err := serv.Request("GET", "server-status", req, resp); err != nil { log.Fatal(err) } } diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 2ee852a..c7e8f5c 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -10,8 +10,8 @@ import ( ) // Status returns the status of the current server to a gRPC request -func (s *Server) Status(context.Context, *rove.StatusRequest) (*rove.StatusResponse, error) { - response := &rove.StatusResponse{ +func (s *Server) ServerStatus(context.Context, *rove.ServerStatusRequest) (*rove.ServerStatusResponse, error) { + response := &rove.ServerStatusResponse{ Ready: true, Version: version.Version, Tick: int32(s.tick), diff --git a/cmd/rove/main.go b/cmd/rove/main.go index cf47692..e9f4db7 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -27,7 +27,7 @@ var defaultDataPath = path.Join(home, ".local/share/") func printUsage() { fmt.Fprintf(os.Stderr, "Usage: rove COMMAND [ARGS...]\n") fmt.Fprintln(os.Stderr, "\nCommands") - fmt.Fprintln(os.Stderr, "\tstatus prints the server status") + fmt.Fprintln(os.Stderr, "\tserver-status prints the server status") fmt.Fprintln(os.Stderr, "\tregister NAME registers an account and stores it (use with -name)") fmt.Fprintln(os.Stderr, "\tcommands COMMAND [VAL...] issue commands to rover, accepts multiple, see below") fmt.Fprintln(os.Stderr, "\tradar gathers radar data for the current rover") @@ -163,8 +163,8 @@ func InnerMain(command string, args ...string) error { // Handle all the commands switch command { - case "status": - response, err := client.Status(ctx, &rove.StatusRequest{}) + case "server-status": + response, err := client.ServerStatus(ctx, &rove.ServerStatusRequest{}) switch { case err != nil: return err diff --git a/cmd/rove/main_test.go b/cmd/rove/main_test.go index 1c06374..9600733 100644 --- a/cmd/rove/main_test.go +++ b/cmd/rove/main_test.go @@ -26,11 +26,11 @@ func Test_InnerMain(t *testing.T) { } // First attempt should error without a host - assert.Error(t, InnerMain("status")) + assert.Error(t, InnerMain("server-status")) // Set the host in the config assert.NoError(t, InnerMain("config", address)) - assert.NoError(t, InnerMain("status")) + assert.NoError(t, InnerMain("server-status")) // Register should fail without a name assert.Error(t, InnerMain("register")) diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index 2bee993..f2c318b 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -609,14 +609,14 @@ func (x *RoverResponse) GetMaximumCharge() int32 { } // Empty placeholder -type StatusRequest struct { +type ServerStatusRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } -func (x *StatusRequest) Reset() { - *x = StatusRequest{} +func (x *ServerStatusRequest) Reset() { + *x = ServerStatusRequest{} if protoimpl.UnsafeEnabled { mi := &file_rove_rove_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -624,13 +624,13 @@ func (x *StatusRequest) Reset() { } } -func (x *StatusRequest) String() string { +func (x *ServerStatusRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*StatusRequest) ProtoMessage() {} +func (*ServerStatusRequest) ProtoMessage() {} -func (x *StatusRequest) ProtoReflect() protoreflect.Message { +func (x *ServerStatusRequest) ProtoReflect() protoreflect.Message { mi := &file_rove_rove_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -642,12 +642,12 @@ func (x *StatusRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use StatusRequest.ProtoReflect.Descriptor instead. -func (*StatusRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use ServerStatusRequest.ProtoReflect.Descriptor instead. +func (*ServerStatusRequest) Descriptor() ([]byte, []int) { return file_rove_rove_proto_rawDescGZIP(), []int{10} } -type StatusResponse struct { +type ServerStatusResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -662,8 +662,8 @@ type StatusResponse struct { Version string `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty"` } -func (x *StatusResponse) Reset() { - *x = StatusResponse{} +func (x *ServerStatusResponse) Reset() { + *x = ServerStatusResponse{} if protoimpl.UnsafeEnabled { mi := &file_rove_rove_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -671,13 +671,13 @@ func (x *StatusResponse) Reset() { } } -func (x *StatusResponse) String() string { +func (x *ServerStatusResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*StatusResponse) ProtoMessage() {} +func (*ServerStatusResponse) ProtoMessage() {} -func (x *StatusResponse) ProtoReflect() protoreflect.Message { +func (x *ServerStatusResponse) ProtoReflect() protoreflect.Message { mi := &file_rove_rove_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -689,33 +689,33 @@ func (x *StatusResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use StatusResponse.ProtoReflect.Descriptor instead. -func (*StatusResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use ServerStatusResponse.ProtoReflect.Descriptor instead. +func (*ServerStatusResponse) Descriptor() ([]byte, []int) { return file_rove_rove_proto_rawDescGZIP(), []int{11} } -func (x *StatusResponse) GetNextTick() string { +func (x *ServerStatusResponse) GetNextTick() string { if x != nil { return x.NextTick } return "" } -func (x *StatusResponse) GetReady() bool { +func (x *ServerStatusResponse) GetReady() bool { if x != nil { return x.Ready } return false } -func (x *StatusResponse) GetTick() int32 { +func (x *ServerStatusResponse) GetTick() int32 { if x != nil { return x.Tick } return 0 } -func (x *StatusResponse) GetVersion() string { +func (x *ServerStatusResponse) GetVersion() string { if x != nil { return x.Version } @@ -828,44 +828,47 @@ var file_rove_rove_proto_rawDesc = []byte{ 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, - 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x22, 0x0f, 0x0a, - 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x71, - 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x14, 0x0a, - 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, - 0x61, 0x64, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x32, 0xf8, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, - 0x12, 0x44, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x0f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x09, 0x12, 0x07, 0x2f, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4f, 0x0a, 0x08, 0x43, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x73, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, - 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, - 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, - 0x05, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x6f, - 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x3a, - 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, - 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x22, 0x15, 0x0a, + 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x22, 0x77, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, + 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, + 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, + 0x12, 0x0a, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74, + 0x69, 0x63, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x24, 0x0a, + 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x01, 0x79, 0x32, 0x91, 0x03, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x5d, 0x0a, 0x0c, + 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, 0x73, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, 0x08, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, + 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4f, 0x0a, 0x08, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, + 0x09, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, + 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, + 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, 0x72, 0x3a, + 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, + 0x6f, 0x76, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, + 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -882,29 +885,29 @@ func file_rove_rove_proto_rawDescGZIP() []byte { var file_rove_rove_proto_msgTypes = make([]protoimpl.MessageInfo, 13) var file_rove_rove_proto_goTypes = []interface{}{ - (*Command)(nil), // 0: rove.Command - (*CommandsRequest)(nil), // 1: rove.CommandsRequest - (*CommandsResponse)(nil), // 2: rove.CommandsResponse - (*Error)(nil), // 3: rove.Error - (*RadarRequest)(nil), // 4: rove.RadarRequest - (*RadarResponse)(nil), // 5: rove.RadarResponse - (*RegisterResponse)(nil), // 6: rove.RegisterResponse - (*RegisterRequest)(nil), // 7: rove.RegisterRequest - (*RoverRequest)(nil), // 8: rove.RoverRequest - (*RoverResponse)(nil), // 9: rove.RoverResponse - (*StatusRequest)(nil), // 10: rove.StatusRequest - (*StatusResponse)(nil), // 11: rove.StatusResponse - (*Vector)(nil), // 12: rove.Vector + (*Command)(nil), // 0: rove.Command + (*CommandsRequest)(nil), // 1: rove.CommandsRequest + (*CommandsResponse)(nil), // 2: rove.CommandsResponse + (*Error)(nil), // 3: rove.Error + (*RadarRequest)(nil), // 4: rove.RadarRequest + (*RadarResponse)(nil), // 5: rove.RadarResponse + (*RegisterResponse)(nil), // 6: rove.RegisterResponse + (*RegisterRequest)(nil), // 7: rove.RegisterRequest + (*RoverRequest)(nil), // 8: rove.RoverRequest + (*RoverResponse)(nil), // 9: rove.RoverResponse + (*ServerStatusRequest)(nil), // 10: rove.ServerStatusRequest + (*ServerStatusResponse)(nil), // 11: rove.ServerStatusResponse + (*Vector)(nil), // 12: rove.Vector } var file_rove_rove_proto_depIdxs = []int32{ 0, // 0: rove.CommandsRequest.commands:type_name -> rove.Command 12, // 1: rove.RoverResponse.position:type_name -> rove.Vector - 10, // 2: rove.Rove.Status:input_type -> rove.StatusRequest + 10, // 2: rove.Rove.ServerStatus:input_type -> rove.ServerStatusRequest 7, // 3: rove.Rove.Register:input_type -> rove.RegisterRequest 1, // 4: rove.Rove.Commands:input_type -> rove.CommandsRequest 4, // 5: rove.Rove.Radar:input_type -> rove.RadarRequest 8, // 6: rove.Rove.Rover:input_type -> rove.RoverRequest - 11, // 7: rove.Rove.Status:output_type -> rove.StatusResponse + 11, // 7: rove.Rove.ServerStatus:output_type -> rove.ServerStatusResponse 6, // 8: rove.Rove.Register:output_type -> rove.RegisterResponse 2, // 9: rove.Rove.Commands:output_type -> rove.CommandsResponse 5, // 10: rove.Rove.Radar:output_type -> rove.RadarResponse @@ -1043,7 +1046,7 @@ func file_rove_rove_proto_init() { } } file_rove_rove_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StatusRequest); i { + switch v := v.(*ServerStatusRequest); i { case 0: return &v.state case 1: @@ -1055,7 +1058,7 @@ func file_rove_rove_proto_init() { } } file_rove_rove_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StatusResponse); i { + switch v := v.(*ServerStatusResponse); i { case 0: return &v.state case 1: @@ -1114,7 +1117,7 @@ type RoveClient interface { // Server status // // Responds with various details about the current server status - Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) + ServerStatus(ctx context.Context, in *ServerStatusRequest, opts ...grpc.CallOption) (*ServerStatusResponse, error) // Register an account // // Tries to register an account with the given name @@ -1141,9 +1144,9 @@ func NewRoveClient(cc grpc.ClientConnInterface) RoveClient { return &roveClient{cc} } -func (c *roveClient) Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) { - out := new(StatusResponse) - err := c.cc.Invoke(ctx, "/rove.Rove/Status", in, out, opts...) +func (c *roveClient) ServerStatus(ctx context.Context, in *ServerStatusRequest, opts ...grpc.CallOption) (*ServerStatusResponse, error) { + out := new(ServerStatusResponse) + err := c.cc.Invoke(ctx, "/rove.Rove/ServerStatus", in, out, opts...) if err != nil { return nil, err } @@ -1191,7 +1194,7 @@ type RoveServer interface { // Server status // // Responds with various details about the current server status - Status(context.Context, *StatusRequest) (*StatusResponse, error) + ServerStatus(context.Context, *ServerStatusRequest) (*ServerStatusResponse, error) // Register an account // // Tries to register an account with the given name @@ -1214,8 +1217,8 @@ type RoveServer interface { type UnimplementedRoveServer struct { } -func (*UnimplementedRoveServer) Status(context.Context, *StatusRequest) (*StatusResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Status not implemented") +func (*UnimplementedRoveServer) ServerStatus(context.Context, *ServerStatusRequest) (*ServerStatusResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ServerStatus not implemented") } func (*UnimplementedRoveServer) Register(context.Context, *RegisterRequest) (*RegisterResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") @@ -1234,20 +1237,20 @@ func RegisterRoveServer(s *grpc.Server, srv RoveServer) { s.RegisterService(&_Rove_serviceDesc, srv) } -func _Rove_Status_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(StatusRequest) +func _Rove_ServerStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ServerStatusRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(RoveServer).Status(ctx, in) + return srv.(RoveServer).ServerStatus(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/rove.Rove/Status", + FullMethod: "/rove.Rove/ServerStatus", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RoveServer).Status(ctx, req.(*StatusRequest)) + return srv.(RoveServer).ServerStatus(ctx, req.(*ServerStatusRequest)) } return interceptor(ctx, in, info, handler) } @@ -1329,8 +1332,8 @@ var _Rove_serviceDesc = grpc.ServiceDesc{ HandlerType: (*RoveServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "Status", - Handler: _Rove_Status_Handler, + MethodName: "ServerStatus", + Handler: _Rove_ServerStatus_Handler, }, { MethodName: "Register", diff --git a/pkg/rove/rove.pb.gw.go b/pkg/rove/rove.pb.gw.go index 0d19891..f253655 100644 --- a/pkg/rove/rove.pb.gw.go +++ b/pkg/rove/rove.pb.gw.go @@ -31,20 +31,20 @@ var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage -func request_Rove_Status_0(ctx context.Context, marshaler runtime.Marshaler, client RoveClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq StatusRequest +func request_Rove_ServerStatus_0(ctx context.Context, marshaler runtime.Marshaler, client RoveClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ServerStatusRequest var metadata runtime.ServerMetadata - msg, err := client.Status(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.ServerStatus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Rove_Status_0(ctx context.Context, marshaler runtime.Marshaler, server RoveServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq StatusRequest +func local_request_Rove_ServerStatus_0(ctx context.Context, marshaler runtime.Marshaler, server RoveServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ServerStatusRequest var metadata runtime.ServerMetadata - msg, err := server.Status(ctx, &protoReq) + msg, err := server.ServerStatus(ctx, &protoReq) return msg, metadata, err } @@ -190,7 +190,7 @@ func local_request_Rove_Rover_0(ctx context.Context, marshaler runtime.Marshaler // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. func RegisterRoveHandlerServer(ctx context.Context, mux *runtime.ServeMux, server RoveServer) error { - mux.Handle("GET", pattern_Rove_Status_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Rove_ServerStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -199,14 +199,14 @@ func RegisterRoveHandlerServer(ctx context.Context, mux *runtime.ServeMux, serve runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Rove_Status_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Rove_ServerStatus_0(rctx, inboundMarshaler, server, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Rove_Status_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Rove_ServerStatus_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -331,7 +331,7 @@ func RegisterRoveHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc. // "RoveClient" to call the correct interceptors. func RegisterRoveHandlerClient(ctx context.Context, mux *runtime.ServeMux, client RoveClient) error { - mux.Handle("GET", pattern_Rove_Status_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Rove_ServerStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -340,14 +340,14 @@ func RegisterRoveHandlerClient(ctx context.Context, mux *runtime.ServeMux, clien runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Rove_Status_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Rove_ServerStatus_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Rove_Status_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Rove_ServerStatus_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -435,7 +435,7 @@ func RegisterRoveHandlerClient(ctx context.Context, mux *runtime.ServeMux, clien } var ( - pattern_Rove_Status_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"status"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Rove_ServerStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"server-status"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Rove_Register_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"register"}, "", runtime.AssumeColonVerbOpt(true))) @@ -447,7 +447,7 @@ var ( ) var ( - forward_Rove_Status_0 = runtime.ForwardResponseMessage + forward_Rove_ServerStatus_0 = runtime.ForwardResponseMessage forward_Rove_Register_0 = runtime.ForwardResponseMessage diff --git a/pkg/rove/rove.swagger.json b/pkg/rove/rove.swagger.json index 4e55cab..c0a318a 100644 --- a/pkg/rove/rove.swagger.json +++ b/pkg/rove/rove.swagger.json @@ -148,16 +148,16 @@ ] } }, - "/status": { + "/server-status": { "get": { "summary": "Server status", "description": "Responds with various details about the current server status", - "operationId": "Rove_Status", + "operationId": "Rove_ServerStatus", "responses": { "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/roveStatusResponse" + "$ref": "#/definitions/roveServerStatusResponse" } }, "default": { @@ -339,7 +339,7 @@ } } }, - "roveStatusResponse": { + "roveServerStatusResponse": { "type": "object", "properties": { "next_tick": { diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index 73659f2..ada631a 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -13,9 +13,9 @@ service Rove { // Server status // // Responds with various details about the current server status - rpc Status(StatusRequest) returns (StatusResponse) { + rpc ServerStatus(ServerStatusRequest) returns (ServerStatusResponse) { option (google.api.http) = { - get: "/status" + get: "/server-status" }; } @@ -147,9 +147,9 @@ message RoverResponse { } // Empty placeholder -message StatusRequest {} +message ServerStatusRequest {} -message StatusResponse { +message ServerStatusResponse { // The time the next tick will occur string next_tick = 1; From 894359142b4f4c3c1fb703b443b4dfb3f0f9e4a0 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 4 Jul 2020 23:11:12 +0100 Subject: [PATCH 041/228] Rename "rover" to "status" --- cmd/rove-server-rest-proxy/http_test.go | 4 +- cmd/rove-server/internal/routes.go | 8 +- cmd/rove/main.go | 8 +- pkg/rove/rove.pb.go | 218 ++++++++++++------------ pkg/rove/rove.pb.gw.go | 28 +-- pkg/rove/rove.swagger.json | 118 ++++++------- proto/rove/rove.proto | 8 +- 7 files changed, 196 insertions(+), 196 deletions(-) diff --git a/cmd/rove-server-rest-proxy/http_test.go b/cmd/rove-server-rest-proxy/http_test.go index 586b5e1..e797a3b 100644 --- a/cmd/rove-server-rest-proxy/http_test.go +++ b/cmd/rove-server-rest-proxy/http_test.go @@ -116,8 +116,8 @@ func TestServer_Rover(t *testing.T) { err := serv.Request("POST", "register", &rove.RegisterRequest{Name: acc}, &rove.RegisterResponse{}) assert.NoError(t, err, "First register attempt should pass") - resp := &rove.RoverResponse{} - err = serv.Request("POST", "rover", &rove.RoverRequest{ + resp := &rove.StatusResponse{} + err = serv.Request("POST", "status", &rove.StatusRequest{ Account: acc, }, resp) assert.NoError(t, err, "Rover sould pass should pass") diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index c7e8f5c..76485c4 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -46,9 +46,9 @@ func (s *Server) Register(ctx context.Context, req *rove.RegisterRequest) (*rove return &rove.RegisterResponse{}, nil } -// Rover returns rover information for a gRPC request -func (s *Server) Rover(ctx context.Context, req *rove.RoverRequest) (*rove.RoverResponse, error) { - response := &rove.RoverResponse{} +// Status returns rover information for a gRPC request +func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (*rove.StatusResponse, error) { + response := &rove.StatusResponse{} if len(req.Account) == 0 { return nil, fmt.Errorf("empty account name") @@ -64,7 +64,7 @@ func (s *Server) Rover(ctx context.Context, req *rove.RoverRequest) (*rove.Rover inv = append(inv, byte(i.Type)) } - response = &rove.RoverResponse{ + response = &rove.StatusResponse{ Name: rover.Name, Position: &rove.Vector{ X: int32(rover.Pos.X), diff --git a/cmd/rove/main.go b/cmd/rove/main.go index e9f4db7..4cb9075 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -31,7 +31,7 @@ func printUsage() { fmt.Fprintln(os.Stderr, "\tregister NAME registers an account and stores it (use with -name)") fmt.Fprintln(os.Stderr, "\tcommands COMMAND [VAL...] issue commands to rover, accepts multiple, see below") fmt.Fprintln(os.Stderr, "\tradar gathers radar data for the current rover") - fmt.Fprintln(os.Stderr, "\trover gets data for current rover") + fmt.Fprintln(os.Stderr, "\tstatus gets status info for current rover") fmt.Fprintln(os.Stderr, "\tconfig [HOST] outputs the local config info, optionally sets host") fmt.Fprintln(os.Stderr, "\thelp outputs this usage information") fmt.Fprintln(os.Stderr, "\tversion outputs version info") @@ -277,12 +277,12 @@ func InnerMain(command string, args ...string) error { } } - case "rover": - req := rove.RoverRequest{Account: config.Account.Name} + case "status": + req := rove.StatusRequest{Account: config.Account.Name} if err := verifyID(req.Account); err != nil { return err } - response, err := client.Rover(ctx, &req) + response, err := client.Status(ctx, &req) switch { case err != nil: diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index f2c318b..a1ef12a 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -440,7 +440,7 @@ func (x *RegisterRequest) GetName() string { return "" } -type RoverRequest struct { +type StatusRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -449,8 +449,8 @@ type RoverRequest struct { Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` } -func (x *RoverRequest) Reset() { - *x = RoverRequest{} +func (x *StatusRequest) Reset() { + *x = StatusRequest{} if protoimpl.UnsafeEnabled { mi := &file_rove_rove_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -458,13 +458,13 @@ func (x *RoverRequest) Reset() { } } -func (x *RoverRequest) String() string { +func (x *StatusRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*RoverRequest) ProtoMessage() {} +func (*StatusRequest) ProtoMessage() {} -func (x *RoverRequest) ProtoReflect() protoreflect.Message { +func (x *StatusRequest) ProtoReflect() protoreflect.Message { mi := &file_rove_rove_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -476,19 +476,19 @@ func (x *RoverRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use RoverRequest.ProtoReflect.Descriptor instead. -func (*RoverRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use StatusRequest.ProtoReflect.Descriptor instead. +func (*StatusRequest) Descriptor() ([]byte, []int) { return file_rove_rove_proto_rawDescGZIP(), []int{8} } -func (x *RoverRequest) GetAccount() string { +func (x *StatusRequest) GetAccount() string { if x != nil { return x.Account } return "" } -type RoverResponse struct { +type StatusResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -513,8 +513,8 @@ type RoverResponse struct { MaximumCharge int32 `protobuf:"varint,9,opt,name=maximumCharge,proto3" json:"maximumCharge,omitempty"` } -func (x *RoverResponse) Reset() { - *x = RoverResponse{} +func (x *StatusResponse) Reset() { + *x = StatusResponse{} if protoimpl.UnsafeEnabled { mi := &file_rove_rove_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -522,13 +522,13 @@ func (x *RoverResponse) Reset() { } } -func (x *RoverResponse) String() string { +func (x *StatusResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*RoverResponse) ProtoMessage() {} +func (*StatusResponse) ProtoMessage() {} -func (x *RoverResponse) ProtoReflect() protoreflect.Message { +func (x *StatusResponse) ProtoReflect() protoreflect.Message { mi := &file_rove_rove_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -540,68 +540,68 @@ func (x *RoverResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use RoverResponse.ProtoReflect.Descriptor instead. -func (*RoverResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use StatusResponse.ProtoReflect.Descriptor instead. +func (*StatusResponse) Descriptor() ([]byte, []int) { return file_rove_rove_proto_rawDescGZIP(), []int{9} } -func (x *RoverResponse) GetName() string { +func (x *StatusResponse) GetName() string { if x != nil { return x.Name } return "" } -func (x *RoverResponse) GetPosition() *Vector { +func (x *StatusResponse) GetPosition() *Vector { if x != nil { return x.Position } return nil } -func (x *RoverResponse) GetRange() int32 { +func (x *StatusResponse) GetRange() int32 { if x != nil { return x.Range } return 0 } -func (x *RoverResponse) GetInventory() []byte { +func (x *StatusResponse) GetInventory() []byte { if x != nil { return x.Inventory } return nil } -func (x *RoverResponse) GetCapacity() int32 { +func (x *StatusResponse) GetCapacity() int32 { if x != nil { return x.Capacity } return 0 } -func (x *RoverResponse) GetIntegrity() int32 { +func (x *StatusResponse) GetIntegrity() int32 { if x != nil { return x.Integrity } return 0 } -func (x *RoverResponse) GetMaximumIntegrity() int32 { +func (x *StatusResponse) GetMaximumIntegrity() int32 { if x != nil { return x.MaximumIntegrity } return 0 } -func (x *RoverResponse) GetCharge() int32 { +func (x *StatusResponse) GetCharge() int32 { if x != nil { return x.Charge } return 0 } -func (x *RoverResponse) GetMaximumCharge() int32 { +func (x *StatusResponse) GetMaximumCharge() int32 { if x != nil { return x.MaximumCharge } @@ -807,68 +807,68 @@ var file_rove_rove_proto_rawDesc = []byte{ 0x22, 0x12, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x25, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x28, 0x0a, 0x0c, 0x52, - 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xa5, 0x02, 0x0a, 0x0d, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x70, - 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, - 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, - 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, - 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, - 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, - 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, - 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, - 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, - 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, - 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, - 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, - 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x22, 0x15, 0x0a, - 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x22, 0x77, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, - 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, - 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, - 0x12, 0x0a, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74, - 0x69, 0x63, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x24, 0x0a, - 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x01, 0x79, 0x32, 0x91, 0x03, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x5d, 0x0a, 0x0c, - 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, 0x73, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, 0x08, 0x52, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, - 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4f, 0x0a, 0x08, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, - 0x09, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, - 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, - 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, 0x72, 0x3a, - 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, - 0x6f, 0x76, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, - 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x29, 0x0a, 0x0d, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, + 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xa6, 0x02, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, + 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, + 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, + 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, + 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, + 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, + 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, + 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, + 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, + 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x22, + 0x15, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x77, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, + 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x72, + 0x65, 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, + 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x04, 0x74, 0x69, 0x63, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, + 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x01, 0x79, 0x32, 0x95, 0x03, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x5d, + 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, + 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, + 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, + 0x22, 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4f, + 0x0a, 0x08, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, + 0x0e, 0x22, 0x09, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x3a, 0x01, 0x2a, 0x12, + 0x43, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, + 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, + 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x47, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x12, 0x82, 0xd3, 0xe4, 0x93, 0x02, + 0x0c, 0x22, 0x07, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, + 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, + 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -893,25 +893,25 @@ var file_rove_rove_proto_goTypes = []interface{}{ (*RadarResponse)(nil), // 5: rove.RadarResponse (*RegisterResponse)(nil), // 6: rove.RegisterResponse (*RegisterRequest)(nil), // 7: rove.RegisterRequest - (*RoverRequest)(nil), // 8: rove.RoverRequest - (*RoverResponse)(nil), // 9: rove.RoverResponse + (*StatusRequest)(nil), // 8: rove.StatusRequest + (*StatusResponse)(nil), // 9: rove.StatusResponse (*ServerStatusRequest)(nil), // 10: rove.ServerStatusRequest (*ServerStatusResponse)(nil), // 11: rove.ServerStatusResponse (*Vector)(nil), // 12: rove.Vector } var file_rove_rove_proto_depIdxs = []int32{ 0, // 0: rove.CommandsRequest.commands:type_name -> rove.Command - 12, // 1: rove.RoverResponse.position:type_name -> rove.Vector + 12, // 1: rove.StatusResponse.position:type_name -> rove.Vector 10, // 2: rove.Rove.ServerStatus:input_type -> rove.ServerStatusRequest 7, // 3: rove.Rove.Register:input_type -> rove.RegisterRequest 1, // 4: rove.Rove.Commands:input_type -> rove.CommandsRequest 4, // 5: rove.Rove.Radar:input_type -> rove.RadarRequest - 8, // 6: rove.Rove.Rover:input_type -> rove.RoverRequest + 8, // 6: rove.Rove.Status:input_type -> rove.StatusRequest 11, // 7: rove.Rove.ServerStatus:output_type -> rove.ServerStatusResponse 6, // 8: rove.Rove.Register:output_type -> rove.RegisterResponse 2, // 9: rove.Rove.Commands:output_type -> rove.CommandsResponse 5, // 10: rove.Rove.Radar:output_type -> rove.RadarResponse - 9, // 11: rove.Rove.Rover:output_type -> rove.RoverResponse + 9, // 11: rove.Rove.Status:output_type -> rove.StatusResponse 7, // [7:12] is the sub-list for method output_type 2, // [2:7] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name @@ -1022,7 +1022,7 @@ func file_rove_rove_proto_init() { } } file_rove_rove_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RoverRequest); i { + switch v := v.(*StatusRequest); i { case 0: return &v.state case 1: @@ -1034,7 +1034,7 @@ func file_rove_rove_proto_init() { } } file_rove_rove_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RoverResponse); i { + switch v := v.(*StatusResponse); i { case 0: return &v.state case 1: @@ -1133,7 +1133,7 @@ type RoveClient interface { // Get rover information // // Gets information for the account's rover - Rover(ctx context.Context, in *RoverRequest, opts ...grpc.CallOption) (*RoverResponse, error) + Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) } type roveClient struct { @@ -1180,9 +1180,9 @@ func (c *roveClient) Radar(ctx context.Context, in *RadarRequest, opts ...grpc.C return out, nil } -func (c *roveClient) Rover(ctx context.Context, in *RoverRequest, opts ...grpc.CallOption) (*RoverResponse, error) { - out := new(RoverResponse) - err := c.cc.Invoke(ctx, "/rove.Rove/Rover", in, out, opts...) +func (c *roveClient) Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) { + out := new(StatusResponse) + err := c.cc.Invoke(ctx, "/rove.Rove/Status", in, out, opts...) if err != nil { return nil, err } @@ -1210,7 +1210,7 @@ type RoveServer interface { // Get rover information // // Gets information for the account's rover - Rover(context.Context, *RoverRequest) (*RoverResponse, error) + Status(context.Context, *StatusRequest) (*StatusResponse, error) } // UnimplementedRoveServer can be embedded to have forward compatible implementations. @@ -1229,8 +1229,8 @@ func (*UnimplementedRoveServer) Commands(context.Context, *CommandsRequest) (*Co func (*UnimplementedRoveServer) Radar(context.Context, *RadarRequest) (*RadarResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Radar not implemented") } -func (*UnimplementedRoveServer) Rover(context.Context, *RoverRequest) (*RoverResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Rover not implemented") +func (*UnimplementedRoveServer) Status(context.Context, *StatusRequest) (*StatusResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Status not implemented") } func RegisterRoveServer(s *grpc.Server, srv RoveServer) { @@ -1309,20 +1309,20 @@ func _Rove_Radar_Handler(srv interface{}, ctx context.Context, dec func(interfac return interceptor(ctx, in, info, handler) } -func _Rove_Rover_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RoverRequest) +func _Rove_Status_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StatusRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(RoveServer).Rover(ctx, in) + return srv.(RoveServer).Status(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/rove.Rove/Rover", + FullMethod: "/rove.Rove/Status", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RoveServer).Rover(ctx, req.(*RoverRequest)) + return srv.(RoveServer).Status(ctx, req.(*StatusRequest)) } return interceptor(ctx, in, info, handler) } @@ -1348,8 +1348,8 @@ var _Rove_serviceDesc = grpc.ServiceDesc{ Handler: _Rove_Radar_Handler, }, { - MethodName: "Rover", - Handler: _Rove_Rover_Handler, + MethodName: "Status", + Handler: _Rove_Status_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/pkg/rove/rove.pb.gw.go b/pkg/rove/rove.pb.gw.go index f253655..cfb9d54 100644 --- a/pkg/rove/rove.pb.gw.go +++ b/pkg/rove/rove.pb.gw.go @@ -151,8 +151,8 @@ func local_request_Rove_Radar_0(ctx context.Context, marshaler runtime.Marshaler } -func request_Rove_Rover_0(ctx context.Context, marshaler runtime.Marshaler, client RoveClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq RoverRequest +func request_Rove_Status_0(ctx context.Context, marshaler runtime.Marshaler, client RoveClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq StatusRequest var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) @@ -163,13 +163,13 @@ func request_Rove_Rover_0(ctx context.Context, marshaler runtime.Marshaler, clie return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.Rover(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.Status(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Rove_Rover_0(ctx context.Context, marshaler runtime.Marshaler, server RoveServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq RoverRequest +func local_request_Rove_Status_0(ctx context.Context, marshaler runtime.Marshaler, server RoveServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq StatusRequest var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) @@ -180,7 +180,7 @@ func local_request_Rove_Rover_0(ctx context.Context, marshaler runtime.Marshaler return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.Rover(ctx, &protoReq) + msg, err := server.Status(ctx, &protoReq) return msg, metadata, err } @@ -270,7 +270,7 @@ func RegisterRoveHandlerServer(ctx context.Context, mux *runtime.ServeMux, serve }) - mux.Handle("POST", pattern_Rove_Rover_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_Rove_Status_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -279,14 +279,14 @@ func RegisterRoveHandlerServer(ctx context.Context, mux *runtime.ServeMux, serve runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Rove_Rover_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Rove_Status_0(rctx, inboundMarshaler, server, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Rove_Rover_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Rove_Status_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -411,7 +411,7 @@ func RegisterRoveHandlerClient(ctx context.Context, mux *runtime.ServeMux, clien }) - mux.Handle("POST", pattern_Rove_Rover_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_Rove_Status_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -420,14 +420,14 @@ func RegisterRoveHandlerClient(ctx context.Context, mux *runtime.ServeMux, clien runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Rove_Rover_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Rove_Status_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Rove_Rover_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Rove_Status_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -443,7 +443,7 @@ var ( pattern_Rove_Radar_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"radar"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Rove_Rover_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"rover"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Rove_Status_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"status"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -455,5 +455,5 @@ var ( forward_Rove_Radar_0 = runtime.ForwardResponseMessage - forward_Rove_Rover_0 = runtime.ForwardResponseMessage + forward_Rove_Status_0 = runtime.ForwardResponseMessage ) diff --git a/pkg/rove/rove.swagger.json b/pkg/rove/rove.swagger.json index c0a318a..cc4e6d6 100644 --- a/pkg/rove/rove.swagger.json +++ b/pkg/rove/rove.swagger.json @@ -114,40 +114,6 @@ ] } }, - "/rover": { - "post": { - "summary": "Get rover information", - "description": "Gets information for the account's rover", - "operationId": "Rove_Rover", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/roveRoverResponse" - } - }, - "default": { - "description": "An unexpected error response", - "schema": { - "$ref": "#/definitions/gatewayruntimeError" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/roveRoverRequest" - } - } - ], - "tags": [ - "Rove" - ] - } - }, "/server-status": { "get": { "summary": "Server status", @@ -171,6 +137,40 @@ "Rove" ] } + }, + "/status": { + "post": { + "summary": "Get rover information", + "description": "Gets information for the account's rover", + "operationId": "Rove_Status", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/roveStatusResponse" + } + }, + "default": { + "description": "An unexpected error response", + "schema": { + "$ref": "#/definitions/gatewayruntimeError" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/roveStatusRequest" + } + } + ], + "tags": [ + "Rove" + ] + } } }, "definitions": { @@ -282,7 +282,30 @@ "type": "object", "title": "Empty placeholder" }, - "roveRoverRequest": { + "roveServerStatusResponse": { + "type": "object", + "properties": { + "next_tick": { + "type": "string", + "title": "The time the next tick will occur" + }, + "ready": { + "type": "boolean", + "format": "boolean", + "title": "Whether the server is ready to accept requests" + }, + "tick": { + "type": "integer", + "format": "int32", + "title": "The tick rate of the server in minutes (how many minutes per tick)" + }, + "version": { + "type": "string", + "title": "The version of the server in v{major}.{minor}-{delta}-{sha} form" + } + } + }, + "roveStatusRequest": { "type": "object", "properties": { "account": { @@ -291,7 +314,7 @@ } } }, - "roveRoverResponse": { + "roveStatusResponse": { "type": "object", "properties": { "name": { @@ -339,29 +362,6 @@ } } }, - "roveServerStatusResponse": { - "type": "object", - "properties": { - "next_tick": { - "type": "string", - "title": "The time the next tick will occur" - }, - "ready": { - "type": "boolean", - "format": "boolean", - "title": "Whether the server is ready to accept requests" - }, - "tick": { - "type": "integer", - "format": "int32", - "title": "The tick rate of the server in minutes (how many minutes per tick)" - }, - "version": { - "type": "string", - "title": "The version of the server in v{major}.{minor}-{delta}-{sha} form" - } - } - }, "roveVector": { "type": "object", "properties": { diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index ada631a..54609b0 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -52,9 +52,9 @@ service Rove { // Get rover information // // Gets information for the account's rover - rpc Rover(RoverRequest) returns (RoverResponse) { + rpc Status(StatusRequest) returns (StatusResponse) { option (google.api.http) = { - post: "/rover" + post: "/status" body: "*" }; } @@ -112,12 +112,12 @@ message RegisterRequest { string name = 1; } -message RoverRequest { +message StatusRequest { // The account for this request string account = 1; } -message RoverResponse { +message StatusResponse { // The name of the rover string name = 1; From 28639b4cac79ae4a5c2a7159932b2038b8b7200e Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 4 Jul 2020 23:11:22 +0100 Subject: [PATCH 042/228] Fix up a comment and the help text --- cmd/rove-server/internal/routes.go | 2 +- cmd/rove/main.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 76485c4..264ede3 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -9,7 +9,7 @@ import ( "github.com/mdiluz/rove/pkg/version" ) -// Status returns the status of the current server to a gRPC request +// ServerStatus returns the status of the current server to a gRPC request func (s *Server) ServerStatus(context.Context, *rove.ServerStatusRequest) (*rove.ServerStatusResponse, error) { response := &rove.ServerStatusResponse{ Ready: true, diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 4cb9075..1498c74 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -39,6 +39,7 @@ func printUsage() { fmt.Fprintln(os.Stderr, "\tmove BEARING moves the rover in the chosen direction") fmt.Fprintln(os.Stderr, "\tstash stores the object at the rover location in the inventory") fmt.Fprintln(os.Stderr, "\trepair uses an inventory object to repair the rover") + fmt.Fprintln(os.Stderr, "\trecharge wait a tick to recharge the rover") fmt.Fprintln(os.Stderr, "\nEnvironment") fmt.Fprintln(os.Stderr, "\tROVE_USER_DATA path to user data, defaults to "+defaultDataPath) } From 31c07533419a6dc1b1f8b785a2bd7de2d09096f8 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 4 Jul 2020 23:15:12 +0100 Subject: [PATCH 043/228] Fix InnerMain test --- cmd/rove/main_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/rove/main_test.go b/cmd/rove/main_test.go index 9600733..2118d1c 100644 --- a/cmd/rove/main_test.go +++ b/cmd/rove/main_test.go @@ -37,14 +37,14 @@ func Test_InnerMain(t *testing.T) { // These methods should fail without an account assert.Error(t, InnerMain("radar")) - assert.Error(t, InnerMain("rover")) + assert.Error(t, InnerMain("status")) // Now set the name assert.NoError(t, InnerMain("register", uuid.New().String())) // These should now work assert.NoError(t, InnerMain("radar")) - assert.NoError(t, InnerMain("rover")) + assert.NoError(t, InnerMain("status")) // Commands should fail with no commands assert.Error(t, InnerMain("commands")) From 1554b7c21b2a745673f1ff4712ee5c4d0cbb74c8 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 4 Jul 2020 23:31:47 +0100 Subject: [PATCH 044/228] Update README.md Fix the link to the proto Add the logo --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 562a4bf..8846cc3 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,11 @@ Rove ==== +![Tests](https://github.com/mdiluz/rove/workflows/Tests/badge.svg) ![Docker](https://github.com/mdiluz/rove/workflows/Docker/badge.svg) [![rove](https://snapcraft.io//rove/badge.svg)](https://snapcraft.io/rove) + +![Rove](https://github.com/mdiluz/rove/blob/master/data/icon.svg) Rove is an asynchronous nomadic game about exploring as part of a loose community. This repository is a [living document](https://github.com/mdiluz/rove/tree/master/docs) of current game design, as well as source code for the `rove-server` deployment and the `rove` command line client. -See [api.go](https://github.com/mdiluz/rove/blob/master/pkg/rove/api.go) for the current server-client API. - -Build Status ------------- -![Tests](https://github.com/mdiluz/rove/workflows/Tests/badge.svg) ![Docker](https://github.com/mdiluz/rove/workflows/Docker/badge.svg) [![rove](https://snapcraft.io//rove/badge.svg)](https://snapcraft.io/rove) - +See [rove.proto](https://github.com/mdiluz/rove/blob/master/proto/rove/rove.proto) for the current server-client API. From ea4b7de4ac3265b954afc04527ffb3f695a9bac4 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 5 Jul 2020 12:55:01 +0100 Subject: [PATCH 045/228] Rename "commands" to "command" --- cmd/rove-server-rest-proxy/http_test.go | 4 +- cmd/rove-server/internal/routes.go | 6 +- cmd/rove/main.go | 8 +- cmd/rove/main_test.go | 10 +- pkg/rove/rove.pb.go | 242 ++++++++++++------------ pkg/rove/rove.pb.gw.go | 28 +-- pkg/rove/rove.swagger.json | 12 +- proto/rove/rove.proto | 8 +- 8 files changed, 159 insertions(+), 159 deletions(-) diff --git a/cmd/rove-server-rest-proxy/http_test.go b/cmd/rove-server-rest-proxy/http_test.go index e797a3b..c17081b 100644 --- a/cmd/rove-server-rest-proxy/http_test.go +++ b/cmd/rove-server-rest-proxy/http_test.go @@ -83,7 +83,7 @@ func TestServer_Command(t *testing.T) { err := serv.Request("POST", "register", &rove.RegisterRequest{Name: acc}, &rove.RegisterResponse{}) assert.NoError(t, err, "First register attempt should pass") - err = serv.Request("POST", "commands", &rove.CommandsRequest{ + err = serv.Request("POST", "command", &rove.CommandRequest{ Account: acc, Commands: []*rove.Command{ { @@ -91,7 +91,7 @@ func TestServer_Command(t *testing.T) { Bearing: "NE", }, }, - }, &rove.CommandsResponse{}) + }, &rove.CommandResponse{}) assert.NoError(t, err, "Commands should should pass") } diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 264ede3..519856b 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -109,8 +109,8 @@ func (s *Server) Radar(ctx context.Context, req *rove.RadarRequest) (*rove.Radar return response, nil } -// Commands issues commands to the world based on a gRPC request -func (s *Server) Commands(ctx context.Context, req *rove.CommandsRequest) (*rove.CommandsResponse, error) { +// Command issues commands to the world based on a gRPC request +func (s *Server) Command(ctx context.Context, req *rove.CommandRequest) (*rove.CommandResponse, error) { if len(req.Account) == 0 { return nil, fmt.Errorf("empty account") } @@ -130,5 +130,5 @@ func (s *Server) Commands(ctx context.Context, req *rove.CommandsRequest) (*rove return nil, err } - return &rove.CommandsResponse{}, nil + return &rove.CommandResponse{}, nil } diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 1498c74..af1fd6d 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -29,7 +29,7 @@ func printUsage() { fmt.Fprintln(os.Stderr, "\nCommands") fmt.Fprintln(os.Stderr, "\tserver-status prints the server status") fmt.Fprintln(os.Stderr, "\tregister NAME registers an account and stores it (use with -name)") - fmt.Fprintln(os.Stderr, "\tcommands COMMAND [VAL...] issue commands to rover, accepts multiple, see below") + fmt.Fprintln(os.Stderr, "\tcommand COMMAND [VAL...] issue commands to rover, accepts multiple, see below") fmt.Fprintln(os.Stderr, "\tradar gathers radar data for the current rover") fmt.Fprintln(os.Stderr, "\tstatus gets status info for current rover") fmt.Fprintln(os.Stderr, "\tconfig [HOST] outputs the local config info, optionally sets host") @@ -196,7 +196,7 @@ func InnerMain(command string, args ...string) error { config.Account.Name = name } - case "commands": + case "command": if len(args) == 0 { return fmt.Errorf("must pass commands to 'commands'") } @@ -228,7 +228,7 @@ func InnerMain(command string, args ...string) error { } } - d := rove.CommandsRequest{ + d := rove.CommandRequest{ Account: config.Account.Name, Commands: commands, } @@ -237,7 +237,7 @@ func InnerMain(command string, args ...string) error { return err } - _, err := client.Commands(ctx, &d) + _, err := client.Command(ctx, &d) switch { case err != nil: return err diff --git a/cmd/rove/main_test.go b/cmd/rove/main_test.go index 2118d1c..6f90fcd 100644 --- a/cmd/rove/main_test.go +++ b/cmd/rove/main_test.go @@ -47,13 +47,13 @@ func Test_InnerMain(t *testing.T) { assert.NoError(t, InnerMain("status")) // Commands should fail with no commands - assert.Error(t, InnerMain("commands")) + assert.Error(t, InnerMain("command")) // Give it commands - assert.NoError(t, InnerMain("commands", "move", "N")) - assert.NoError(t, InnerMain("commands", "stash")) - assert.NoError(t, InnerMain("commands", "repair")) + assert.NoError(t, InnerMain("command", "move", "N")) + assert.NoError(t, InnerMain("command", "stash")) + assert.NoError(t, InnerMain("command", "repair")) // Give it malformed commands - assert.Error(t, InnerMain("commands", "move", "stash")) + assert.Error(t, InnerMain("command", "move", "stash")) } diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index a1ef12a..d5ca946 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -95,7 +95,7 @@ func (x *Command) GetBearing() string { return "" } -type CommandsRequest struct { +type CommandRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -106,8 +106,8 @@ type CommandsRequest struct { Commands []*Command `protobuf:"bytes,2,rep,name=commands,proto3" json:"commands,omitempty"` } -func (x *CommandsRequest) Reset() { - *x = CommandsRequest{} +func (x *CommandRequest) Reset() { + *x = CommandRequest{} if protoimpl.UnsafeEnabled { mi := &file_rove_rove_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -115,13 +115,13 @@ func (x *CommandsRequest) Reset() { } } -func (x *CommandsRequest) String() string { +func (x *CommandRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*CommandsRequest) ProtoMessage() {} +func (*CommandRequest) ProtoMessage() {} -func (x *CommandsRequest) ProtoReflect() protoreflect.Message { +func (x *CommandRequest) ProtoReflect() protoreflect.Message { mi := &file_rove_rove_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -133,19 +133,19 @@ func (x *CommandsRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use CommandsRequest.ProtoReflect.Descriptor instead. -func (*CommandsRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use CommandRequest.ProtoReflect.Descriptor instead. +func (*CommandRequest) Descriptor() ([]byte, []int) { return file_rove_rove_proto_rawDescGZIP(), []int{1} } -func (x *CommandsRequest) GetAccount() string { +func (x *CommandRequest) GetAccount() string { if x != nil { return x.Account } return "" } -func (x *CommandsRequest) GetCommands() []*Command { +func (x *CommandRequest) GetCommands() []*Command { if x != nil { return x.Commands } @@ -153,14 +153,14 @@ func (x *CommandsRequest) GetCommands() []*Command { } // Empty placeholder -type CommandsResponse struct { +type CommandResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } -func (x *CommandsResponse) Reset() { - *x = CommandsResponse{} +func (x *CommandResponse) Reset() { + *x = CommandResponse{} if protoimpl.UnsafeEnabled { mi := &file_rove_rove_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -168,13 +168,13 @@ func (x *CommandsResponse) Reset() { } } -func (x *CommandsResponse) String() string { +func (x *CommandResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*CommandsResponse) ProtoMessage() {} +func (*CommandResponse) ProtoMessage() {} -func (x *CommandsResponse) ProtoReflect() protoreflect.Message { +func (x *CommandResponse) ProtoReflect() protoreflect.Message { mi := &file_rove_rove_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -186,8 +186,8 @@ func (x *CommandsResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use CommandsResponse.ProtoReflect.Descriptor instead. -func (*CommandsResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use CommandResponse.ProtoReflect.Descriptor instead. +func (*CommandResponse) Descriptor() ([]byte, []int) { return file_rove_rove_proto_rawDescGZIP(), []int{2} } @@ -787,88 +787,88 @@ var file_rove_rove_proto_rawDesc = []byte{ 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x65, 0x61, - 0x72, 0x69, 0x6e, 0x67, 0x22, 0x56, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x12, 0x29, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x12, 0x0a, 0x10, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x1d, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, - 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, - 0x28, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x55, 0x0a, 0x0d, 0x52, 0x61, 0x64, - 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, - 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, - 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, - 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, - 0x22, 0x12, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x25, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x29, 0x0a, 0x0d, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, - 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xa6, 0x02, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, - 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, - 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, - 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, - 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, - 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, - 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, - 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, - 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, - 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, - 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x22, - 0x15, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x77, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, - 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x72, - 0x65, 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, - 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x04, 0x74, 0x69, 0x63, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, - 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x01, 0x79, 0x32, 0x95, 0x03, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x5d, - 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, - 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, - 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, - 0x22, 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4f, - 0x0a, 0x08, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x0e, 0x22, 0x09, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x3a, 0x01, 0x2a, 0x12, - 0x43, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, - 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, - 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x47, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x12, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x0c, 0x22, 0x07, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, - 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, - 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x69, 0x6e, 0x67, 0x22, 0x55, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x12, 0x29, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, + 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x28, 0x0a, + 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, + 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x55, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x14, + 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, + 0x69, 0x6c, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x12, + 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x25, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x29, 0x0a, 0x0d, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xa6, 0x02, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, + 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, + 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, + 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, + 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, + 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, + 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, + 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, + 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, + 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, + 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, + 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x22, 0x15, 0x0a, + 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x22, 0x77, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, + 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, + 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, + 0x12, 0x0a, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74, + 0x69, 0x63, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x24, 0x0a, + 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x01, 0x79, 0x32, 0x91, 0x03, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x5d, 0x0a, 0x0c, + 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, 0x73, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, 0x08, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, + 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4b, 0x0a, 0x07, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x22, 0x08, 0x2f, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x61, 0x64, + 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, + 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x47, + 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x12, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0c, 0x22, 0x07, 0x2f, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, + 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -886,8 +886,8 @@ func file_rove_rove_proto_rawDescGZIP() []byte { var file_rove_rove_proto_msgTypes = make([]protoimpl.MessageInfo, 13) var file_rove_rove_proto_goTypes = []interface{}{ (*Command)(nil), // 0: rove.Command - (*CommandsRequest)(nil), // 1: rove.CommandsRequest - (*CommandsResponse)(nil), // 2: rove.CommandsResponse + (*CommandRequest)(nil), // 1: rove.CommandRequest + (*CommandResponse)(nil), // 2: rove.CommandResponse (*Error)(nil), // 3: rove.Error (*RadarRequest)(nil), // 4: rove.RadarRequest (*RadarResponse)(nil), // 5: rove.RadarResponse @@ -900,16 +900,16 @@ var file_rove_rove_proto_goTypes = []interface{}{ (*Vector)(nil), // 12: rove.Vector } var file_rove_rove_proto_depIdxs = []int32{ - 0, // 0: rove.CommandsRequest.commands:type_name -> rove.Command + 0, // 0: rove.CommandRequest.commands:type_name -> rove.Command 12, // 1: rove.StatusResponse.position:type_name -> rove.Vector 10, // 2: rove.Rove.ServerStatus:input_type -> rove.ServerStatusRequest 7, // 3: rove.Rove.Register:input_type -> rove.RegisterRequest - 1, // 4: rove.Rove.Commands:input_type -> rove.CommandsRequest + 1, // 4: rove.Rove.Command:input_type -> rove.CommandRequest 4, // 5: rove.Rove.Radar:input_type -> rove.RadarRequest 8, // 6: rove.Rove.Status:input_type -> rove.StatusRequest 11, // 7: rove.Rove.ServerStatus:output_type -> rove.ServerStatusResponse 6, // 8: rove.Rove.Register:output_type -> rove.RegisterResponse - 2, // 9: rove.Rove.Commands:output_type -> rove.CommandsResponse + 2, // 9: rove.Rove.Command:output_type -> rove.CommandResponse 5, // 10: rove.Rove.Radar:output_type -> rove.RadarResponse 9, // 11: rove.Rove.Status:output_type -> rove.StatusResponse 7, // [7:12] is the sub-list for method output_type @@ -938,7 +938,7 @@ func file_rove_rove_proto_init() { } } file_rove_rove_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CommandsRequest); i { + switch v := v.(*CommandRequest); i { case 0: return &v.state case 1: @@ -950,7 +950,7 @@ func file_rove_rove_proto_init() { } } file_rove_rove_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CommandsResponse); i { + switch v := v.(*CommandResponse); i { case 0: return &v.state case 1: @@ -1125,7 +1125,7 @@ type RoveClient interface { // Send commands to rover // // Sending commands to this endpoint will queue them to be executed during the following ticks, in the order sent - Commands(ctx context.Context, in *CommandsRequest, opts ...grpc.CallOption) (*CommandsResponse, error) + Command(ctx context.Context, in *CommandRequest, opts ...grpc.CallOption) (*CommandResponse, error) // Get radar information // // Gets the radar output for the given rover @@ -1162,9 +1162,9 @@ func (c *roveClient) Register(ctx context.Context, in *RegisterRequest, opts ... return out, nil } -func (c *roveClient) Commands(ctx context.Context, in *CommandsRequest, opts ...grpc.CallOption) (*CommandsResponse, error) { - out := new(CommandsResponse) - err := c.cc.Invoke(ctx, "/rove.Rove/Commands", in, out, opts...) +func (c *roveClient) Command(ctx context.Context, in *CommandRequest, opts ...grpc.CallOption) (*CommandResponse, error) { + out := new(CommandResponse) + err := c.cc.Invoke(ctx, "/rove.Rove/Command", in, out, opts...) if err != nil { return nil, err } @@ -1202,7 +1202,7 @@ type RoveServer interface { // Send commands to rover // // Sending commands to this endpoint will queue them to be executed during the following ticks, in the order sent - Commands(context.Context, *CommandsRequest) (*CommandsResponse, error) + Command(context.Context, *CommandRequest) (*CommandResponse, error) // Get radar information // // Gets the radar output for the given rover @@ -1223,8 +1223,8 @@ func (*UnimplementedRoveServer) ServerStatus(context.Context, *ServerStatusReque func (*UnimplementedRoveServer) Register(context.Context, *RegisterRequest) (*RegisterResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") } -func (*UnimplementedRoveServer) Commands(context.Context, *CommandsRequest) (*CommandsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Commands not implemented") +func (*UnimplementedRoveServer) Command(context.Context, *CommandRequest) (*CommandResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Command not implemented") } func (*UnimplementedRoveServer) Radar(context.Context, *RadarRequest) (*RadarResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Radar not implemented") @@ -1273,20 +1273,20 @@ func _Rove_Register_Handler(srv interface{}, ctx context.Context, dec func(inter return interceptor(ctx, in, info, handler) } -func _Rove_Commands_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CommandsRequest) +func _Rove_Command_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CommandRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(RoveServer).Commands(ctx, in) + return srv.(RoveServer).Command(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/rove.Rove/Commands", + FullMethod: "/rove.Rove/Command", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RoveServer).Commands(ctx, req.(*CommandsRequest)) + return srv.(RoveServer).Command(ctx, req.(*CommandRequest)) } return interceptor(ctx, in, info, handler) } @@ -1340,8 +1340,8 @@ var _Rove_serviceDesc = grpc.ServiceDesc{ Handler: _Rove_Register_Handler, }, { - MethodName: "Commands", - Handler: _Rove_Commands_Handler, + MethodName: "Command", + Handler: _Rove_Command_Handler, }, { MethodName: "Radar", diff --git a/pkg/rove/rove.pb.gw.go b/pkg/rove/rove.pb.gw.go index cfb9d54..db3d25e 100644 --- a/pkg/rove/rove.pb.gw.go +++ b/pkg/rove/rove.pb.gw.go @@ -83,8 +83,8 @@ func local_request_Rove_Register_0(ctx context.Context, marshaler runtime.Marsha } -func request_Rove_Commands_0(ctx context.Context, marshaler runtime.Marshaler, client RoveClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq CommandsRequest +func request_Rove_Command_0(ctx context.Context, marshaler runtime.Marshaler, client RoveClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CommandRequest var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) @@ -95,13 +95,13 @@ func request_Rove_Commands_0(ctx context.Context, marshaler runtime.Marshaler, c return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.Commands(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.Command(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Rove_Commands_0(ctx context.Context, marshaler runtime.Marshaler, server RoveServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq CommandsRequest +func local_request_Rove_Command_0(ctx context.Context, marshaler runtime.Marshaler, server RoveServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CommandRequest var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) @@ -112,7 +112,7 @@ func local_request_Rove_Commands_0(ctx context.Context, marshaler runtime.Marsha return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.Commands(ctx, &protoReq) + msg, err := server.Command(ctx, &protoReq) return msg, metadata, err } @@ -230,7 +230,7 @@ func RegisterRoveHandlerServer(ctx context.Context, mux *runtime.ServeMux, serve }) - mux.Handle("POST", pattern_Rove_Commands_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_Rove_Command_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -239,14 +239,14 @@ func RegisterRoveHandlerServer(ctx context.Context, mux *runtime.ServeMux, serve runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Rove_Commands_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Rove_Command_0(rctx, inboundMarshaler, server, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Rove_Commands_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Rove_Command_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -371,7 +371,7 @@ func RegisterRoveHandlerClient(ctx context.Context, mux *runtime.ServeMux, clien }) - mux.Handle("POST", pattern_Rove_Commands_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_Rove_Command_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -380,14 +380,14 @@ func RegisterRoveHandlerClient(ctx context.Context, mux *runtime.ServeMux, clien runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Rove_Commands_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Rove_Command_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Rove_Commands_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Rove_Command_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -439,7 +439,7 @@ var ( pattern_Rove_Register_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"register"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Rove_Commands_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"commands"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Rove_Command_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"command"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Rove_Radar_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"radar"}, "", runtime.AssumeColonVerbOpt(true))) @@ -451,7 +451,7 @@ var ( forward_Rove_Register_0 = runtime.ForwardResponseMessage - forward_Rove_Commands_0 = runtime.ForwardResponseMessage + forward_Rove_Command_0 = runtime.ForwardResponseMessage forward_Rove_Radar_0 = runtime.ForwardResponseMessage diff --git a/pkg/rove/rove.swagger.json b/pkg/rove/rove.swagger.json index cc4e6d6..d9f0932 100644 --- a/pkg/rove/rove.swagger.json +++ b/pkg/rove/rove.swagger.json @@ -12,16 +12,16 @@ "application/json" ], "paths": { - "/commands": { + "/command": { "post": { "summary": "Send commands to rover", "description": "Sending commands to this endpoint will queue them to be executed during the following ticks, in the order sent", - "operationId": "Rove_Commands", + "operationId": "Rove_Command", "responses": { "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/roveCommandsResponse" + "$ref": "#/definitions/roveCommandResponse" } }, "default": { @@ -37,7 +37,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/roveCommandsRequest" + "$ref": "#/definitions/roveCommandRequest" } } ], @@ -220,7 +220,7 @@ } } }, - "roveCommandsRequest": { + "roveCommandRequest": { "type": "object", "properties": { "account": { @@ -236,7 +236,7 @@ } } }, - "roveCommandsResponse": { + "roveCommandResponse": { "type": "object", "title": "Empty placeholder" }, diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index 54609b0..0c0c7bc 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -32,9 +32,9 @@ service Rove { // Send commands to rover // // Sending commands to this endpoint will queue them to be executed during the following ticks, in the order sent - rpc Commands(CommandsRequest) returns (CommandsResponse) { + rpc Command(CommandRequest) returns (CommandResponse) { option (google.api.http) = { - post: "/commands" + post: "/command" body: "*" }; } @@ -72,7 +72,7 @@ message Command { string bearing = 2; } -message CommandsRequest { +message CommandRequest { // The account to execute these commands string account = 1; @@ -81,7 +81,7 @@ message CommandsRequest { } // Empty placeholder -message CommandsResponse {} +message CommandResponse {} message Error { // An explanation for the HTTP error returned From 233a6b328145a2b4407486737361f0a77938e489 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 5 Jul 2020 13:16:08 +0100 Subject: [PATCH 046/228] Add incoming and queued commands to status output --- cmd/rove-server/internal/routes.go | 17 ++++ pkg/game/world.go | 27 ++++-- pkg/rove/rove.pb.go | 141 +++++++++++++++++------------ pkg/rove/rove.swagger.json | 14 +++ proto/rove/rove.proto | 6 ++ 5 files changed, 140 insertions(+), 65 deletions(-) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 519856b..afbc568 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -64,6 +64,21 @@ func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (*rove.Sta inv = append(inv, byte(i.Type)) } + i, q := s.world.RoverCommands(resp) + var incoming, queued []*rove.Command + for _, i := range i { + incoming = append(incoming, &rove.Command{ + Command: i.Command, + Bearing: i.Bearing, + }) + } + for _, q := range q { + queued = append(queued, &rove.Command{ + Command: q.Command, + Bearing: q.Bearing, + }) + } + response = &rove.StatusResponse{ Name: rover.Name, Position: &rove.Vector{ @@ -77,6 +92,8 @@ func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (*rove.Sta MaximumIntegrity: int32(rover.MaximumIntegrity), Charge: int32(rover.Charge), MaximumCharge: int32(rover.MaximumCharge), + IncomingCommands: incoming, + QueuedCommands: queued, } } return response, nil diff --git a/pkg/game/world.go b/pkg/game/world.go index a3f1e10..737219d 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -30,7 +30,7 @@ type World struct { CommandQueue map[string]CommandStream `json:"commands"` // Incoming represents the set of commands to add to the queue at the end of the current tick - Incoming map[string]CommandStream `json:"incoming"` + CommandIncoming map[string]CommandStream `json:"incoming"` // Mutex to lock around command operations cmdMutex sync.RWMutex @@ -60,11 +60,11 @@ func NewWorld(chunkSize int) *World { } return &World{ - Rovers: make(map[string]Rover), - CommandQueue: make(map[string]CommandStream), - Incoming: make(map[string]CommandStream), - Atlas: atlas.NewAtlas(chunkSize), - words: lines, + Rovers: make(map[string]Rover), + CommandQueue: make(map[string]CommandStream), + CommandIncoming: make(map[string]CommandStream), + Atlas: atlas.NewAtlas(chunkSize), + words: lines, } } @@ -359,6 +359,17 @@ func (w *World) RadarFromRover(rover string) (radar []byte, objs []byte, err err return radar, objs, nil } +// RoverCommands returns current commands for the given rover +func (w *World) RoverCommands(rover string) (incoming []Command, queued []Command) { + if c, ok := w.CommandIncoming[rover]; ok { + incoming = c + } + if c, ok := w.CommandQueue[rover]; ok { + queued = c + } + return +} + // Enqueue will queue the commands given func (w *World) Enqueue(rover string, commands ...Command) error { @@ -395,12 +406,12 @@ func (w *World) Enqueue(rover string, commands ...Command) error { // EnqueueAllIncoming will enqueue the incoming commands func (w *World) EnqueueAllIncoming() { // Add any incoming commands from this tick and clear that queue - for id, incoming := range w.Incoming { + for id, incoming := range w.CommandIncoming { commands := w.CommandQueue[id] commands = append(commands, incoming...) w.CommandQueue[id] = commands } - w.Incoming = make(map[string]CommandStream) + w.CommandIncoming = make(map[string]CommandStream) } // ExecuteCommandQueues will execute any commands in the current command queue diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index d5ca946..70f0191 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -511,6 +511,10 @@ type StatusResponse struct { Charge int32 `protobuf:"varint,8,opt,name=charge,proto3" json:"charge,omitempty"` // The max energy the rover can store MaximumCharge int32 `protobuf:"varint,9,opt,name=maximumCharge,proto3" json:"maximumCharge,omitempty"` + // The set of currently incoming commands for this tick + IncomingCommands []*Command `protobuf:"bytes,10,rep,name=incomingCommands,proto3" json:"incomingCommands,omitempty"` + // The set of currently queued commands + QueuedCommands []*Command `protobuf:"bytes,11,rep,name=queuedCommands,proto3" json:"queuedCommands,omitempty"` } func (x *StatusResponse) Reset() { @@ -608,6 +612,20 @@ func (x *StatusResponse) GetMaximumCharge() int32 { return 0 } +func (x *StatusResponse) GetIncomingCommands() []*Command { + if x != nil { + return x.IncomingCommands + } + return nil +} + +func (x *StatusResponse) GetQueuedCommands() []*Command { + if x != nil { + return x.QueuedCommands + } + return nil +} + // Empty placeholder type ServerStatusRequest struct { state protoimpl.MessageState @@ -810,7 +828,7 @@ var file_rove_rove_proto_rawDesc = []byte{ 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x29, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xa6, 0x02, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x98, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, @@ -828,47 +846,54 @@ var file_rove_rove_proto_rawDesc = []byte{ 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, - 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x22, 0x15, 0x0a, - 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x22, 0x77, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, - 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, - 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, - 0x12, 0x0a, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74, - 0x69, 0x63, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x24, 0x0a, - 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x01, 0x79, 0x32, 0x91, 0x03, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x5d, 0x0a, 0x0c, - 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, 0x73, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, 0x08, 0x52, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, - 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4b, 0x0a, 0x07, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x22, 0x08, 0x2f, 0x63, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x61, 0x64, - 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, - 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x47, - 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x12, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0c, 0x22, 0x07, 0x2f, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, - 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x39, 0x0a, + 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x35, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, + 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, + 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, + 0x15, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x77, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, + 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x72, + 0x65, 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, + 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x04, 0x74, 0x69, 0x63, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, + 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x01, 0x79, 0x32, 0x91, 0x03, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x5d, + 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, + 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, + 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, + 0x22, 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4b, + 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x22, 0x08, + 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, + 0x61, 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, + 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, + 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, + 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, 0x72, 0x3a, 0x01, 0x2a, + 0x12, 0x47, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x12, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0c, 0x22, 0x07, 0x2f, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, + 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -902,21 +927,23 @@ var file_rove_rove_proto_goTypes = []interface{}{ var file_rove_rove_proto_depIdxs = []int32{ 0, // 0: rove.CommandRequest.commands:type_name -> rove.Command 12, // 1: rove.StatusResponse.position:type_name -> rove.Vector - 10, // 2: rove.Rove.ServerStatus:input_type -> rove.ServerStatusRequest - 7, // 3: rove.Rove.Register:input_type -> rove.RegisterRequest - 1, // 4: rove.Rove.Command:input_type -> rove.CommandRequest - 4, // 5: rove.Rove.Radar:input_type -> rove.RadarRequest - 8, // 6: rove.Rove.Status:input_type -> rove.StatusRequest - 11, // 7: rove.Rove.ServerStatus:output_type -> rove.ServerStatusResponse - 6, // 8: rove.Rove.Register:output_type -> rove.RegisterResponse - 2, // 9: rove.Rove.Command:output_type -> rove.CommandResponse - 5, // 10: rove.Rove.Radar:output_type -> rove.RadarResponse - 9, // 11: rove.Rove.Status:output_type -> rove.StatusResponse - 7, // [7:12] is the sub-list for method output_type - 2, // [2:7] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 0, // 2: rove.StatusResponse.incomingCommands:type_name -> rove.Command + 0, // 3: rove.StatusResponse.queuedCommands:type_name -> rove.Command + 10, // 4: rove.Rove.ServerStatus:input_type -> rove.ServerStatusRequest + 7, // 5: rove.Rove.Register:input_type -> rove.RegisterRequest + 1, // 6: rove.Rove.Command:input_type -> rove.CommandRequest + 4, // 7: rove.Rove.Radar:input_type -> rove.RadarRequest + 8, // 8: rove.Rove.Status:input_type -> rove.StatusRequest + 11, // 9: rove.Rove.ServerStatus:output_type -> rove.ServerStatusResponse + 6, // 10: rove.Rove.Register:output_type -> rove.RegisterResponse + 2, // 11: rove.Rove.Command:output_type -> rove.CommandResponse + 5, // 12: rove.Rove.Radar:output_type -> rove.RadarResponse + 9, // 13: rove.Rove.Status:output_type -> rove.StatusResponse + 9, // [9:14] is the sub-list for method output_type + 4, // [4:9] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_rove_rove_proto_init() } diff --git a/pkg/rove/rove.swagger.json b/pkg/rove/rove.swagger.json index d9f0932..1749dc7 100644 --- a/pkg/rove/rove.swagger.json +++ b/pkg/rove/rove.swagger.json @@ -359,6 +359,20 @@ "type": "integer", "format": "int32", "title": "The max energy the rover can store" + }, + "incomingCommands": { + "type": "array", + "items": { + "$ref": "#/definitions/roveCommand" + }, + "title": "The set of currently incoming commands for this tick" + }, + "queuedCommands": { + "type": "array", + "items": { + "$ref": "#/definitions/roveCommand" + }, + "title": "The set of currently queued commands" } } }, diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index 0c0c7bc..59df2c5 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -144,6 +144,12 @@ message StatusResponse { // The max energy the rover can store int32 maximumCharge = 9; + + // The set of currently incoming commands for this tick + repeated Command incomingCommands = 10; + + // The set of currently queued commands + repeated Command queuedCommands = 11; } // Empty placeholder From a112c3ed470f2c6c77213d976d0fb3dc943689f3 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 5 Jul 2020 13:16:19 +0100 Subject: [PATCH 047/228] Override incoming commands rather than appending --- pkg/game/world.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pkg/game/world.go b/pkg/game/world.go index 737219d..cdd8fa1 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -393,12 +393,8 @@ func (w *World) Enqueue(rover string, commands ...Command) error { w.cmdMutex.Lock() defer w.cmdMutex.Unlock() - // Append the commands to the incoming set - if cmds, ok := w.Incoming[rover]; ok { - w.Incoming[rover] = append(cmds, commands...) - } else { - w.Incoming[rover] = commands - } + // Override the incoming command set + w.CommandIncoming[rover] = commands return nil } From 35d7400a83db2fa62f687dc16f2d79bbc08fcf81 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 5 Jul 2020 13:36:51 +0100 Subject: [PATCH 048/228] Also build the rove command line client into the docker --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 727efa4..f5a1f4b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,7 @@ COPY . . RUN go mod download # Build the executables +RUN go build -o rove -ldflags="-X 'github.com/mdiluz/rove/pkg/version.Version=$(git describe --always --long --dirty --tags)'" cmd/rove/main.go RUN go build -o rove-server -ldflags="-X 'github.com/mdiluz/rove/pkg/version.Version=$(git describe --always --long --dirty --tags)'" cmd/rove-server/main.go RUN go build -o rove-server-rest-proxy cmd/rove-server-rest-proxy/main.go From 9eb2e0866702d463196893fa9002c772296c8db5 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Mon, 6 Jul 2020 17:09:49 +0100 Subject: [PATCH 049/228] Add check to github action that we've run make gen --- .github/workflows/tests.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 04b2ba8..11d1ab0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,6 +23,13 @@ jobs: run: | sudo curl -o /usr/local/bin/swagger -L'#' https://github.com/go-swagger/go-swagger/releases/download/v0.23.0/swagger_linux_amd64 sudo chmod +x /usr/local/bin/swagger + + - name: Install protoc and check no difference + run: | + sudo apt install protobuf-compiler + make gen + git update-index --refresh + git diff-index --quiet HEAD -- - name: Check out repo uses: actions/checkout@v2 From 2c6aba6897fd6139afca3e9219e4f06d7e9673a4 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Mon, 6 Jul 2020 17:10:04 +0100 Subject: [PATCH 050/228] Remove Gopkg usage in github action --- .github/workflows/tests.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 11d1ab0..15742d5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -37,10 +37,6 @@ jobs: - name: Get go dependencies run: | go get -v -t -d ./... - if [ -f Gopkg.toml ]; then - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh - dep ensure - fi - name: Build and Test run: make test From 771c95da14496900a731203a5403e4315175afcd Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Mon, 6 Jul 2020 17:10:14 +0100 Subject: [PATCH 051/228] Update makefile with more echos --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ac45c79..4e08041 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,20 @@ VERSION := $(shell git describe --always --long --dirty --tags) build: + @echo Running no-output build go mod download go build -ldflags="-X 'github.com/mdiluz/rove/pkg/version.Version=${VERSION}'" ./... install: + @echo Installing to GOPATH go mod download go install -ldflags="-X 'github.com/mdiluz/rove/pkg/version.Version=${VERSION}'" ./... gen: - @echo Generating rove server gRPC + @echo Generating rove server gRPC and gateway protoc --proto_path proto --go_out=plugins=grpc:pkg/ --go_opt=paths=source_relative proto/rove/rove.proto protoc --proto_path proto --grpc-gateway_out=paths=source_relative:pkg/ proto/rove/rove.proto + @echo Generating rove server swagger protoc --proto_path proto --swagger_out=logtostderr=true:pkg/ proto/rove/rove.proto test: From 62741caf5e12d175e1a6741040ece021f666f580 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Mon, 6 Jul 2020 17:12:32 +0100 Subject: [PATCH 052/228] Add check for golang lint --- .github/workflows/tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 15742d5..8f2fcfd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,6 +34,9 @@ jobs: - name: Check out repo uses: actions/checkout@v2 + - name: Check golangci-lint + uses: matoous/golangci-lint-action@v1.1.0 + - name: Get go dependencies run: | go get -v -t -d ./... From 408fffb0c63d11ec42d52f2885b70b0b815dc18d Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Mon, 6 Jul 2020 17:16:09 +0100 Subject: [PATCH 053/228] Fix to use the new golangci-lint action --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8f2fcfd..f5a2275 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,8 +34,8 @@ jobs: - name: Check out repo uses: actions/checkout@v2 - - name: Check golangci-lint - uses: matoous/golangci-lint-action@v1.1.0 + - name: Run golangci-lint + uses: actions-contrib/golangci-lint@v1 - name: Get go dependencies run: | From 2fbe2dc1a8ee27ba9a0dc5923f19645b33ca7d3b Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Mon, 6 Jul 2020 17:18:40 +0100 Subject: [PATCH 054/228] Re-order code checkout --- .github/workflows/tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f5a2275..1d99059 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,15 +24,15 @@ jobs: sudo curl -o /usr/local/bin/swagger -L'#' https://github.com/go-swagger/go-swagger/releases/download/v0.23.0/swagger_linux_amd64 sudo chmod +x /usr/local/bin/swagger + - name: Check out repo + uses: actions/checkout@v2 + - name: Install protoc and check no difference run: | sudo apt install protobuf-compiler make gen git update-index --refresh git diff-index --quiet HEAD -- - - - name: Check out repo - uses: actions/checkout@v2 - name: Run golangci-lint uses: actions-contrib/golangci-lint@v1 From 718252731b82f43ef5d35e4b37cedbd918278ca3 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Mon, 6 Jul 2020 17:46:39 +0100 Subject: [PATCH 055/228] Give up on getting protoc and lint to work in the action --- .github/workflows/tests.yml | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1d99059..86c9b12 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,6 +13,8 @@ jobs: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v2 + - name: Set up Go 1.x uses: actions/setup-go@v2 with: @@ -24,19 +26,6 @@ jobs: sudo curl -o /usr/local/bin/swagger -L'#' https://github.com/go-swagger/go-swagger/releases/download/v0.23.0/swagger_linux_amd64 sudo chmod +x /usr/local/bin/swagger - - name: Check out repo - uses: actions/checkout@v2 - - - name: Install protoc and check no difference - run: | - sudo apt install protobuf-compiler - make gen - git update-index --refresh - git diff-index --quiet HEAD -- - - - name: Run golangci-lint - uses: actions-contrib/golangci-lint@v1 - - name: Get go dependencies run: | go get -v -t -d ./... From ed6de9eac49aba7e35a8bb4acbddbfecd79a5a6c Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Mon, 6 Jul 2020 17:49:01 +0100 Subject: [PATCH 056/228] Remove swagger install from tests --- .github/workflows/tests.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 86c9b12..71d2c3e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,11 +21,6 @@ jobs: go-version: ^1.13 id: go - - name: Install swagger - run: | - sudo curl -o /usr/local/bin/swagger -L'#' https://github.com/go-swagger/go-swagger/releases/download/v0.23.0/swagger_linux_amd64 - sudo chmod +x /usr/local/bin/swagger - - name: Get go dependencies run: | go get -v -t -d ./... From 945b3299acaa6757176eb506b672b6ae72a1879a Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Mon, 6 Jul 2020 17:53:35 +0100 Subject: [PATCH 057/228] Add golangci-lint from https://github.com/actions-contrib/golangci-lint --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 71d2c3e..9d3bc5c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,6 +14,8 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Run golangci-lint + uses: actions-contrib/golangci-lint@v1 - name: Set up Go 1.x uses: actions/setup-go@v2 From 75910efbe5668bb3809c37674eed993d957895ac Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Mon, 6 Jul 2020 18:04:10 +0100 Subject: [PATCH 058/228] Apply all golangci-lint fixes --- cmd/rove-server/internal/routes.go | 3 +-- cmd/rove-server/internal/server.go | 4 +++- cmd/rove-server/main.go | 4 +++- cmd/rove-server/main_test.go | 6 ++++-- cmd/rove/main.go | 4 +++- pkg/atlas/atlas.go | 13 ------------- pkg/bearing/bearing.go | 2 +- pkg/game/world_test.go | 5 ++++- 8 files changed, 19 insertions(+), 22 deletions(-) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index afbc568..341c9ee 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -47,8 +47,7 @@ func (s *Server) Register(ctx context.Context, req *rove.RegisterRequest) (*rove } // Status returns rover information for a gRPC request -func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (*rove.StatusResponse, error) { - response := &rove.StatusResponse{} +func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (response *rove.StatusResponse, err error) { if len(req.Account) == 0 { return nil, fmt.Errorf("empty account name") diff --git a/cmd/rove-server/internal/server.go b/cmd/rove-server/internal/server.go index 5f918d4..a80005e 100644 --- a/cmd/rove-server/internal/server.go +++ b/cmd/rove-server/internal/server.go @@ -136,7 +136,9 @@ func (s *Server) Run() { s.world.ExecuteCommandQueues() // Save out the new world state - s.SaveWorld() + if err := s.SaveWorld(); err != nil { + log.Fatalf("Failed to save the world: %s", err) + } }); err != nil { log.Fatal(err) } diff --git a/cmd/rove-server/main.go b/cmd/rove-server/main.go index ef1d675..db09130 100644 --- a/cmd/rove-server/main.go +++ b/cmd/rove-server/main.go @@ -52,7 +52,9 @@ func InnerMain() { log.Printf("Initialising version %s...\n", version.Version) // Set the persistence path - persistence.SetPath(data) + if err := persistence.SetPath(data); err != nil { + log.Fatal(err) + } // Convert the tick rate tickRate := 1 diff --git a/cmd/rove-server/main_test.go b/cmd/rove-server/main_test.go index fcf9a55..e689ead 100644 --- a/cmd/rove-server/main_test.go +++ b/cmd/rove-server/main_test.go @@ -3,10 +3,12 @@ package main import ( "flag" "testing" + + "github.com/stretchr/testify/assert" ) func Test_InnerMain_Version(t *testing.T) { - flag.Set("version", "1") + assert.NoError(t, flag.Set("version", "1")) InnerMain() - flag.Set("version", "0") + assert.NoError(t, flag.Set("version", "0")) } diff --git a/cmd/rove/main.go b/cmd/rove/main.go index af1fd6d..7ef4b91 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -78,7 +78,9 @@ func LoadConfig() (config Config, err error) { // Create the path if needed path := filepath.Dir(datapath) if _, err := os.Stat(path); os.IsNotExist(err) { - os.MkdirAll(path, os.ModePerm) + if err := os.MkdirAll(path, os.ModePerm); err != nil { + return Config{}, fmt.Errorf("Failed to create data path %s: %s", path, err) + } } else { // Read the file _, err = os.Stat(datapath) diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index ef25d9c..0840873 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -144,19 +144,6 @@ func (a *Atlas) setObject(chunk int, local vector.Vector, object objects.Object) a.Chunks[chunk] = c } -// setTileAndObject sets both tile and object information for location in chunk -func (a *Atlas) setTileAndObject(chunk int, local vector.Vector, tile byte, object objects.Object) { - c := a.Chunks[chunk] - if c.Tiles == nil { - c.populate(a.ChunkSize) - } - - i := a.chunkTileIndex(local) - c.Tiles[i] = tile - c.Objects[i] = object - a.Chunks[chunk] = c -} - // worldSpaceToChunkLocal gets a chunk local coordinate for a tile func (a *Atlas) worldSpaceToChunkLocal(v vector.Vector) vector.Vector { return vector.Vector{X: maths.Pmod(v.X, a.ChunkSize), Y: maths.Pmod(v.Y, a.ChunkSize)} diff --git a/pkg/bearing/bearing.go b/pkg/bearing/bearing.go index 62053f2..303c195 100644 --- a/pkg/bearing/bearing.go +++ b/pkg/bearing/bearing.go @@ -60,7 +60,7 @@ func (d Bearing) ShortString() string { // FromString gets the Direction from a string func FromString(s string) (Bearing, error) { for i, d := range bearingStrings { - if strings.ToLower(d.Long) == strings.ToLower(s) || strings.ToLower(d.Short) == strings.ToLower(s) { + if strings.EqualFold(d.Long, s) || strings.EqualFold(d.Short, s) { return Bearing(i), nil } } diff --git a/pkg/game/world_test.go b/pkg/game/world_test.go index 9b4e696..6e5f7d7 100644 --- a/pkg/game/world_test.go +++ b/pkg/game/world_test.go @@ -91,6 +91,7 @@ func TestWorld_GetSetMovePosition(t *testing.T) { // Place a tile in front of the rover world.Atlas.SetObject(vector.Vector{X: 0, Y: 2}, objects.Object{Type: objects.LargeRock}) newPos, err = world.MoveRover(a, b) + assert.NoError(t, err, "Failed to move rover") assert.Equal(t, pos, newPos, "Failed to correctly not move position for rover into wall") rover, err = world.GetRover(a) @@ -168,7 +169,9 @@ func TestWorld_RoverStash(t *testing.T) { // Recharge the rover for i := 0; i < rover.MaximumCharge; i++ { - world.RoverRecharge(a) + _, err = world.RoverRecharge(a) + assert.NoError(t, err) + } // Place an object From fc4fa3decfcfd83ab85284760d6169d4d597e861 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Mon, 6 Jul 2020 18:10:02 +0100 Subject: [PATCH 059/228] Remove go dependencies fetch to test need for it --- .github/workflows/tests.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9d3bc5c..5246994 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,10 +23,6 @@ jobs: go-version: ^1.13 id: go - - name: Get go dependencies - run: | - go get -v -t -d ./... - - name: Build and Test run: make test From c66e61921fbbf390a4185a4effd1ab7aae652c94 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 7 Jul 2020 12:59:10 +0100 Subject: [PATCH 060/228] Add generated files check to github actions --- .github/workflows/tests.yml | 12 ++++++++++++ Makefile | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5246994..8388cce 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,6 +23,18 @@ jobs: go-version: ^1.13 id: go + - name: Check generated files + run: | + PROTOC_ZIP=protoc-3.6.1-linux-x86_64.zip + curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/$PROTOC_ZIP + sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc + sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*' + sudo chmod -R o+r /usr/local/include/google/ + rm -f $PROTOC_ZIP + make gen + git update-index --refresh + git diff-index --quiet HEAD + - name: Build and Test run: make test diff --git a/Makefile b/Makefile index 4e08041..cf7f33b 100644 --- a/Makefile +++ b/Makefile @@ -11,8 +11,14 @@ install: go install -ldflags="-X 'github.com/mdiluz/rove/pkg/version.Version=${VERSION}'" ./... gen: + @echo Installing go dependencies + go install \ + github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway \ + github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger \ + github.com/golang/protobuf/protoc-gen-go + go mod download @echo Generating rove server gRPC and gateway - protoc --proto_path proto --go_out=plugins=grpc:pkg/ --go_opt=paths=source_relative proto/rove/rove.proto + protoc --proto_path proto --go_out=plugins=grpc,paths=source_relative:pkg/ proto/rove/rove.proto protoc --proto_path proto --grpc-gateway_out=paths=source_relative:pkg/ proto/rove/rove.proto @echo Generating rove server swagger protoc --proto_path proto --swagger_out=logtostderr=true:pkg/ proto/rove/rove.proto From a1b79a8df5d406379d0733481359a64933c33643 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 7 Jul 2020 13:08:33 +0100 Subject: [PATCH 061/228] Display diff change --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8388cce..3abb139 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,7 +33,7 @@ jobs: rm -f $PROTOC_ZIP make gen git update-index --refresh - git diff-index --quiet HEAD + git diff-index --quiet HEAD || (git diff; exit 1) - name: Build and Test run: make test From 5b4b9c30eb8cf05fcb4c0173b2f36e6786bd1fc2 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 7 Jul 2020 13:13:02 +0100 Subject: [PATCH 062/228] Update rove.pb.go --- pkg/rove/rove.pb.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index 70f0191..1c01b4f 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.23.0 +// protoc-gen-go v1.25.0 // protoc v3.6.1 // source: rove/rove.proto From ad13ed8ee2817e145bce5ca6288c49cf9294303b Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 7 Jul 2020 13:13:17 +0100 Subject: [PATCH 063/228] Fix git diff check --- .github/workflows/tests.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3abb139..82092a8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,8 +32,7 @@ jobs: sudo chmod -R o+r /usr/local/include/google/ rm -f $PROTOC_ZIP make gen - git update-index --refresh - git diff-index --quiet HEAD || (git diff; exit 1) + git update-index --refresh || (git diff; exit 1) - name: Build and Test run: make test From 3493d51d36d27585e5f492579eba99aecd219557 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 7 Jul 2020 17:45:36 +0100 Subject: [PATCH 064/228] Set the server tick rate to 5 --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 96b1ecd..7109118 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -25,6 +25,7 @@ services: - PORT=9090 - DATA_PATH=/mnt/rove-server - WORDS_FILE=data/words_alpha.txt + - TICK_RATE=5 volumes: - persistent-data:/mnt/rove-server:rw command: [ "./rove-server"] From 3faf709f102fca7db1d0a817309967e5489576a5 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 7 Jul 2020 17:58:41 +0100 Subject: [PATCH 065/228] Remove status doc, now tracked on GitHub --- docs/status.md | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 docs/status.md diff --git a/docs/status.md b/docs/status.md deleted file mode 100644 index c9d5f1b..0000000 --- a/docs/status.md +++ /dev/null @@ -1,28 +0,0 @@ -Development status -================ - -This page tracks the current feature set and the features to implement next - -### Current features - -* Users can register and spawn a rover -* The rover can be commanded to move, stash, repair and recharge -* Rover commands use energy -* The rover has a radar function to view nearby terrain and objects -* The server supports multiple users -* The map is populated with terrain and objects -* Rovers take damage and can use collected materials to repair - -### Incoming features - -* Day/night cycle -* Weather cycle -* Deterministic and intelligent world-gen - -### Stretch goals - -* Simple rover to rover communication -* Rover replacement and advancement mechanic -* Dormant rovers -* Render rover camera view -* Account token security \ No newline at end of file From 5928dfdb2083eede2690a43dd0475bbb0ff8dd1f Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 7 Jul 2020 18:24:16 +0100 Subject: [PATCH 066/228] Rename the tick variable --- cmd/rove-server/internal/server.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/rove-server/internal/server.go b/cmd/rove-server/internal/server.go index a80005e..ff98f76 100644 --- a/cmd/rove-server/internal/server.go +++ b/cmd/rove-server/internal/server.go @@ -36,9 +36,9 @@ type Server struct { grpcServ *grpc.Server // Config settings - address string - persistence int - tick int + address string + persistence int + minutesPerTick int // sync point for sub-threads sync sync.WaitGroup @@ -68,7 +68,7 @@ func OptionPersistentData() ServerOption { // 0 means no automatic server tick func OptionTick(minutes int) ServerOption { return func(s *Server) { - s.tick = minutes + s.minutesPerTick = minutes } } @@ -124,8 +124,8 @@ func (s *Server) Run() { defer s.sync.Done() // Set up the schedule if requested - if s.tick != 0 { - if err := s.schedule.AddFunc(fmt.Sprintf("0 */%d * * *", s.tick), func() { + if s.minutesPerTick != 0 { + if err := s.schedule.AddFunc(fmt.Sprintf("0 */%d * * *", s.minutesPerTick), func() { // Ensure we don't quit during this function s.sync.Add(1) defer s.sync.Done() From 20385c5ae77567a9ebe77a4bdb3798e7b5a582e5 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 7 Jul 2020 18:36:20 +0100 Subject: [PATCH 067/228] Add tick tracking to the world --- pkg/game/world.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/game/world.go b/pkg/game/world.go index cdd8fa1..4358ef3 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -37,6 +37,12 @@ type World struct { // Set of possible words to use for names words []string + + // TicksPerDay is the amount of ticks in a single day + TicksPerDay int + + // Current number of ticks from the start + CurrentTicks int } var wordsFile = os.Getenv("WORDS_FILE") @@ -65,6 +71,8 @@ func NewWorld(chunkSize int) *World { CommandIncoming: make(map[string]CommandStream), Atlas: atlas.NewAtlas(chunkSize), words: lines, + TicksPerDay: 24, + CurrentTicks: 0, } } @@ -436,6 +444,9 @@ func (w *World) ExecuteCommandQueues() { // Add any incoming commands from this tick and clear that queue w.EnqueueAllIncoming() + + // Increment the current tick count + w.CurrentTicks++ } // ExecuteCommand will execute a single command From 526e9c69eb94d7be2328f5874041a4af0137cd30 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 7 Jul 2020 18:37:45 +0100 Subject: [PATCH 068/228] Ensure world tick properties are properly named in json --- pkg/game/world.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/game/world.go b/pkg/game/world.go index 4358ef3..2792511 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -39,10 +39,10 @@ type World struct { words []string // TicksPerDay is the amount of ticks in a single day - TicksPerDay int + TicksPerDay int `json:"ticks-per-day"` // Current number of ticks from the start - CurrentTicks int + CurrentTicks int `json:"current-ticks"` } var wordsFile = os.Getenv("WORDS_FILE") From 1412579c6c72c457c16e170cb685c50bcb608565 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 7 Jul 2020 18:37:59 +0100 Subject: [PATCH 069/228] Only charge during the day --- pkg/game/world.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/game/world.go b/pkg/game/world.go index 2792511..a4a70af 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -152,6 +152,11 @@ func (w *World) RoverRecharge(rover string) (int, error) { return 0, fmt.Errorf("Failed to find rover with name: %s", rover) } + // We can only recharge during the day + if !w.Daytime() { + return i.Charge, nil + } + // Add one charge if i.Charge < i.MaximumCharge { i.Charge++ @@ -489,6 +494,13 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { return } +// Daytime returns if it's currently daytime +// for simplicity this uses the 1st half of the day as daytime, the 2nd half as nighttime +func (w *World) Daytime() bool { + tickInDay := w.CurrentTicks % w.TicksPerDay + return tickInDay < w.TicksPerDay/2 +} + // RLock read locks the world func (w *World) RLock() { w.worldMutex.RLock() From 3ba7652c749e21e79283cc769f9504d5b4e3181a Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 7 Jul 2020 18:40:38 +0100 Subject: [PATCH 070/228] Add current tick information to the server-status --- cmd/rove-server/internal/routes.go | 7 +- cmd/rove/main.go | 3 +- pkg/rove/rove.pb.go | 111 ++++++++++++++++------------- pkg/rove/rove.swagger.json | 15 ++-- proto/rove/rove.proto | 13 ++-- 5 files changed, 85 insertions(+), 64 deletions(-) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 341c9ee..63b3108 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -12,9 +12,10 @@ import ( // ServerStatus returns the status of the current server to a gRPC request func (s *Server) ServerStatus(context.Context, *rove.ServerStatusRequest) (*rove.ServerStatusResponse, error) { response := &rove.ServerStatusResponse{ - Ready: true, - Version: version.Version, - Tick: int32(s.tick), + Ready: true, + Version: version.Version, + TickRate: int32(s.minutesPerTick), + CurrentTick: int32(s.world.CurrentTicks), } // TODO: Verify the accountant is up and ready too diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 7ef4b91..0f1b014 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -175,7 +175,8 @@ func InnerMain(command string, args ...string) error { default: fmt.Printf("Ready: %t\n", response.Ready) fmt.Printf("Version: %s\n", response.Version) - fmt.Printf("Tick: %d\n", response.Tick) + fmt.Printf("Tick Rate: %d\n", response.TickRate) + fmt.Printf("Current Tick: %d\n", response.CurrentTick) fmt.Printf("Next Tick: %s\n", response.NextTick) } diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index 1c01b4f..a628535 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -670,14 +670,16 @@ type ServerStatusResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The time the next tick will occur - NextTick string `protobuf:"bytes,1,opt,name=next_tick,json=nextTick,proto3" json:"next_tick,omitempty"` + // The version of the server in v{major}.{minor}-{delta}-{sha} form + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` // Whether the server is ready to accept requests Ready bool `protobuf:"varint,2,opt,name=ready,proto3" json:"ready,omitempty"` // The tick rate of the server in minutes (how many minutes per tick) - Tick int32 `protobuf:"varint,3,opt,name=tick,proto3" json:"tick,omitempty"` - // The version of the server in v{major}.{minor}-{delta}-{sha} form - Version string `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty"` + TickRate int32 `protobuf:"varint,3,opt,name=tickRate,proto3" json:"tickRate,omitempty"` + // The current tick of the server + CurrentTick int32 `protobuf:"varint,4,opt,name=currentTick,proto3" json:"currentTick,omitempty"` + // The time the next tick will occur + NextTick string `protobuf:"bytes,5,opt,name=next_tick,json=nextTick,proto3" json:"next_tick,omitempty"` } func (x *ServerStatusResponse) Reset() { @@ -712,9 +714,9 @@ func (*ServerStatusResponse) Descriptor() ([]byte, []int) { return file_rove_rove_proto_rawDescGZIP(), []int{11} } -func (x *ServerStatusResponse) GetNextTick() string { +func (x *ServerStatusResponse) GetVersion() string { if x != nil { - return x.NextTick + return x.Version } return "" } @@ -726,16 +728,23 @@ func (x *ServerStatusResponse) GetReady() bool { return false } -func (x *ServerStatusResponse) GetTick() int32 { +func (x *ServerStatusResponse) GetTickRate() int32 { if x != nil { - return x.Tick + return x.TickRate } return 0 } -func (x *ServerStatusResponse) GetVersion() string { +func (x *ServerStatusResponse) GetCurrentTick() int32 { if x != nil { - return x.Version + return x.CurrentTick + } + return 0 +} + +func (x *ServerStatusResponse) GetNextTick() string { + if x != nil { + return x.NextTick } return "" } @@ -855,45 +864,47 @@ var file_rove_rove_proto_rawDesc = []byte{ 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x15, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x77, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, - 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x72, - 0x65, 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, - 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x04, 0x74, 0x69, 0x63, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, - 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x01, 0x79, 0x32, 0x91, 0x03, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x5d, - 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, - 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, - 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, - 0x22, 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4b, - 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x22, 0x08, - 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, - 0x61, 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, - 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, - 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, 0x72, 0x3a, 0x01, 0x2a, - 0x12, 0x47, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x12, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0c, 0x22, 0x07, 0x2f, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, - 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa1, 0x01, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, + 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, + 0x1a, 0x0a, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, + 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x1b, 0x0a, + 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, + 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, + 0x32, 0x91, 0x03, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x5d, 0x0a, 0x0c, 0x53, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4b, 0x0a, 0x07, 0x43, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x22, 0x08, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, + 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, + 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x47, 0x0a, 0x06, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x12, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0c, 0x22, 0x07, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, + 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/rove/rove.swagger.json b/pkg/rove/rove.swagger.json index 1749dc7..e629dab 100644 --- a/pkg/rove/rove.swagger.json +++ b/pkg/rove/rove.swagger.json @@ -285,23 +285,28 @@ "roveServerStatusResponse": { "type": "object", "properties": { - "next_tick": { + "version": { "type": "string", - "title": "The time the next tick will occur" + "title": "The version of the server in v{major}.{minor}-{delta}-{sha} form" }, "ready": { "type": "boolean", "format": "boolean", "title": "Whether the server is ready to accept requests" }, - "tick": { + "tickRate": { "type": "integer", "format": "int32", "title": "The tick rate of the server in minutes (how many minutes per tick)" }, - "version": { + "currentTick": { + "type": "integer", + "format": "int32", + "title": "The current tick of the server" + }, + "next_tick": { "type": "string", - "title": "The version of the server in v{major}.{minor}-{delta}-{sha} form" + "title": "The time the next tick will occur" } } }, diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index 59df2c5..586af22 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -156,17 +156,20 @@ message StatusResponse { message ServerStatusRequest {} message ServerStatusResponse { - // The time the next tick will occur - string next_tick = 1; + // The version of the server in v{major}.{minor}-{delta}-{sha} form + string version = 1; // Whether the server is ready to accept requests bool ready = 2; // The tick rate of the server in minutes (how many minutes per tick) - int32 tick = 3; + int32 tickRate = 3; - // The version of the server in v{major}.{minor}-{delta}-{sha} form - string version = 4; + // The current tick of the server + int32 currentTick = 4; + + // The time the next tick will occur + string next_tick = 5; } message Vector { From 254957cde5e8818305993ea38facd142deac20e7 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 7 Jul 2020 21:30:51 +0100 Subject: [PATCH 071/228] Add a test to check daytime and rover recharge --- pkg/game/world_test.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/pkg/game/world_test.go b/pkg/game/world_test.go index 6e5f7d7..06f659d 100644 --- a/pkg/game/world_test.go +++ b/pkg/game/world_test.go @@ -313,3 +313,40 @@ func TestWorld_Charge(t *testing.T) { } } + +func TestWorld_Daytime(t *testing.T) { + world := NewWorld(1) + + a, err := world.SpawnRover() + assert.NoError(t, err) + + // Remove rover charge + rover := world.Rovers[a] + rover.Charge = 0 + world.Rovers[a] = rover + + // Try and recharge, should work + world.RoverRecharge(a) + assert.Equal(t, 1, world.Rovers[a].Charge) + + // Loop for half the day + for i := 0; i < world.TicksPerDay/2; i++ { + assert.True(t, world.Daytime()) + world.ExecuteCommandQueues() + } + + // Remove rover charge again + rover = world.Rovers[a] + rover.Charge = 0 + world.Rovers[a] = rover + + // Try and recharge, should fail + world.RoverRecharge(a) + assert.Equal(t, 0, world.Rovers[a].Charge) + + // Loop for half the day + for i := 0; i < world.TicksPerDay/2; i++ { + assert.False(t, world.Daytime()) + world.ExecuteCommandQueues() + } +} From 5980de5ba77ce3d10db7bb9352f1cb0ee49ef64f Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 7 Jul 2020 21:33:32 +0100 Subject: [PATCH 072/228] Fix lint check --- pkg/game/world_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/game/world_test.go b/pkg/game/world_test.go index 06f659d..3e5939e 100644 --- a/pkg/game/world_test.go +++ b/pkg/game/world_test.go @@ -326,7 +326,8 @@ func TestWorld_Daytime(t *testing.T) { world.Rovers[a] = rover // Try and recharge, should work - world.RoverRecharge(a) + _, err = world.RoverRecharge(a) + assert.NoError(t, err) assert.Equal(t, 1, world.Rovers[a].Charge) // Loop for half the day @@ -341,7 +342,8 @@ func TestWorld_Daytime(t *testing.T) { world.Rovers[a] = rover // Try and recharge, should fail - world.RoverRecharge(a) + _, err = world.RoverRecharge(a) + assert.NoError(t, err) assert.Equal(t, 0, world.Rovers[a].Charge) // Loop for half the day From 92222127a61e85e44dcc72f4ce5b947db7ffa139 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 7 Jul 2020 22:20:23 +0100 Subject: [PATCH 073/228] Add basic account security This adds a secret token associated with each account The token must then be sent with follow-up requests to ensure they get accepted This is _very_ basic security, and without TLS is completely vulnerable to MITM attacks, as well as brute force guessing (though it'd take a while to guess the a correct UUID) --- cmd/rove-server-rest-proxy/http_test.go | 54 ++- cmd/rove-server/internal/routes.go | 40 ++- cmd/rove/main.go | 66 ++-- pkg/accounts/accounts.go | 17 +- pkg/rove/rove.pb.go | 425 ++++++++++++++---------- pkg/rove/rove.swagger.json | 23 +- proto/rove/rove.proto | 20 +- 7 files changed, 413 insertions(+), 232 deletions(-) diff --git a/cmd/rove-server-rest-proxy/http_test.go b/cmd/rove-server-rest-proxy/http_test.go index c17081b..f590f74 100644 --- a/cmd/rove-server-rest-proxy/http_test.go +++ b/cmd/rove-server-rest-proxy/http_test.go @@ -80,47 +80,69 @@ func TestServer_Register(t *testing.T) { func TestServer_Command(t *testing.T) { acc := uuid.New().String() - err := serv.Request("POST", "register", &rove.RegisterRequest{Name: acc}, &rove.RegisterResponse{}) + var resp rove.RegisterResponse + err := serv.Request("POST", "register", &rove.RegisterRequest{Name: acc}, &resp) assert.NoError(t, err, "First register attempt should pass") - err = serv.Request("POST", "command", &rove.CommandRequest{ - Account: acc, + req := &rove.CommandRequest{ + Account: &rove.Account{ + Name: resp.Account.Name, + }, Commands: []*rove.Command{ { Command: "move", Bearing: "NE", }, }, - }, &rove.CommandResponse{}) - assert.NoError(t, err, "Commands should should pass") + } + + assert.Error(t, serv.Request("POST", "command", req, &rove.CommandResponse{}), "Commands should fail with no secret") + + req.Account.Secret = resp.Account.Secret + assert.NoError(t, serv.Request("POST", "command", req, &rove.CommandResponse{}), "Commands should pass") } func TestServer_Radar(t *testing.T) { acc := uuid.New().String() - err := serv.Request("POST", "register", &rove.RegisterRequest{Name: acc}, &rove.RegisterResponse{}) + var reg rove.RegisterResponse + err := serv.Request("POST", "register", &rove.RegisterRequest{Name: acc}, ®) assert.NoError(t, err, "First register attempt should pass") resp := &rove.RadarResponse{} - err = serv.Request("POST", "radar", &rove.RadarRequest{ - Account: acc, - }, resp) - assert.NoError(t, err, "Radar sould pass should pass") + req := &rove.RadarRequest{ + Account: &rove.Account{ + Name: reg.Account.Name, + }, + } + + assert.Error(t, serv.Request("POST", "radar", req, resp), "Radar should fail without secret") + req.Account.Secret = reg.Account.Secret + + assert.NoError(t, serv.Request("POST", "radar", req, resp), "Radar should pass") assert.NotZero(t, resp.Range, "Radar should return valid range") + w := int(resp.Range*2 + 1) assert.Equal(t, w*w, len(resp.Tiles), "radar should return correct number of tiles") assert.Equal(t, w*w, len(resp.Objects), "radar should return correct number of objects") } -func TestServer_Rover(t *testing.T) { +func TestServer_Status(t *testing.T) { acc := uuid.New().String() - err := serv.Request("POST", "register", &rove.RegisterRequest{Name: acc}, &rove.RegisterResponse{}) + var reg rove.RegisterResponse + err := serv.Request("POST", "register", &rove.RegisterRequest{Name: acc}, ®) assert.NoError(t, err, "First register attempt should pass") resp := &rove.StatusResponse{} - err = serv.Request("POST", "status", &rove.StatusRequest{ - Account: acc, - }, resp) - assert.NoError(t, err, "Rover sould pass should pass") + req := &rove.StatusRequest{ + Account: &rove.Account{ + Name: reg.Account.Name, + }, + } + + assert.Error(t, serv.Request("POST", "status", req, resp), "Status should fail without secret") + req.Account.Secret = reg.Account.Secret + + assert.NoError(t, serv.Request("POST", "status", req, resp), "Status should pass") assert.NotZero(t, resp.Range, "Rover should return valid range") assert.NotZero(t, len(resp.Name), "Rover should return valid name") assert.NotZero(t, resp.Position, "Rover should return valid position") diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 63b3108..c8d04ef 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -34,7 +34,7 @@ func (s *Server) Register(ctx context.Context, req *rove.RegisterRequest) (*rove return nil, fmt.Errorf("empty account name") } - if _, err := s.accountant.RegisterAccount(req.Name); err != nil { + if acc, err := s.accountant.RegisterAccount(req.Name); err != nil { return nil, err } else if _, err := s.SpawnRoverForAccount(req.Name); err != nil { @@ -42,17 +42,26 @@ func (s *Server) Register(ctx context.Context, req *rove.RegisterRequest) (*rove } else if err := s.SaveWorld(); err != nil { return nil, fmt.Errorf("internal server error when saving world: %s", err) - } - return &rove.RegisterResponse{}, nil + } else { + return &rove.RegisterResponse{ + Account: &rove.Account{ + Name: acc.Name, + Secret: acc.Data["secret"], + }, + }, nil + } } // Status returns rover information for a gRPC request func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (response *rove.StatusResponse, err error) { - if len(req.Account) == 0 { - return nil, fmt.Errorf("empty account name") + if valid, err := s.accountant.VerifySecret(req.Account.Name, req.Account.Secret); err != nil { + return nil, err - } else if resp, err := s.accountant.GetValue(req.Account, "rover"); err != nil { + } else if !valid { + return nil, fmt.Errorf("Secret incorrect for account %s", req.Account.Name) + + } else if resp, err := s.accountant.GetValue(req.Account.Name, "rover"); err != nil { return nil, err } else if rover, err := s.world.GetRover(resp); err != nil { @@ -101,13 +110,16 @@ func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (response // Radar returns the radar information for a rover func (s *Server) Radar(ctx context.Context, req *rove.RadarRequest) (*rove.RadarResponse, error) { - if len(req.Account) == 0 { - return nil, fmt.Errorf("empty account name") + if valid, err := s.accountant.VerifySecret(req.Account.Name, req.Account.Secret); err != nil { + return nil, err + + } else if !valid { + return nil, fmt.Errorf("Secret incorrect for account %s", req.Account.Name) } response := &rove.RadarResponse{} - resp, err := s.accountant.GetValue(req.Account, "rover") + resp, err := s.accountant.GetValue(req.Account.Name, "rover") if err != nil { return nil, err @@ -128,10 +140,14 @@ func (s *Server) Radar(ctx context.Context, req *rove.RadarRequest) (*rove.Radar // Command issues commands to the world based on a gRPC request func (s *Server) Command(ctx context.Context, req *rove.CommandRequest) (*rove.CommandResponse, error) { - if len(req.Account) == 0 { - return nil, fmt.Errorf("empty account") + if valid, err := s.accountant.VerifySecret(req.Account.Name, req.Account.Secret); err != nil { + return nil, err + + } else if !valid { + return nil, fmt.Errorf("Secret incorrect for account %s", req.Account.Name) } - resp, err := s.accountant.GetValue(req.Account, "rover") + + resp, err := s.accountant.GetValue(req.Account.Name, "rover") if err != nil { return nil, err } diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 0f1b014..80fe702 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -48,7 +48,8 @@ const gRPCport = 9090 // Account stores data for an account type Account struct { - Name string `json:"name"` + Name string `json:"name"` + Secret string `json:"secret"` } // Config is used to store internal data @@ -114,10 +115,12 @@ func SaveConfig(config Config) error { return nil } -// verifyID will verify an account ID -func verifyID(id string) error { - if len(id) == 0 { +// checkAccount will verify an account ID +func checkAccount(a Account) error { + if len(a.Name) == 0 { return fmt.Errorf("no account ID set, must register first") + } else if len(a.Secret) == 0 { + return fmt.Errorf("empty account secret, must register first") } return nil } @@ -181,26 +184,27 @@ func InnerMain(command string, args ...string) error { } case "register": - if len(args) == 0 { + if len(args) == 0 || len(args[0]) == 0 { return fmt.Errorf("must pass name to 'register'") } - name := args[0] - d := rove.RegisterRequest{ - Name: name, - } - _, err := client.Register(ctx, &d) + resp, err := client.Register(ctx, &rove.RegisterRequest{ + Name: args[0], + }) switch { case err != nil: return err default: - fmt.Printf("Registered account with id: %s\n", name) - config.Account.Name = name + fmt.Printf("Registered account with id: %s\n", resp.Account.Name) + config.Account.Name = resp.Account.Name + config.Account.Secret = resp.Account.Secret } case "command": - if len(args) == 0 { + if err := checkAccount(config.Account); err != nil { + return err + } else if len(args) == 0 { return fmt.Errorf("must pass commands to 'commands'") } @@ -231,16 +235,14 @@ func InnerMain(command string, args ...string) error { } } - d := rove.CommandRequest{ - Account: config.Account.Name, + _, err := client.Command(ctx, &rove.CommandRequest{ + Account: &rove.Account{ + Name: config.Account.Name, + Secret: config.Account.Secret, + }, Commands: commands, - } + }) - if err := verifyID(d.Account); err != nil { - return err - } - - _, err := client.Command(ctx, &d) switch { case err != nil: return err @@ -250,12 +252,17 @@ func InnerMain(command string, args ...string) error { } case "radar": - dat := rove.RadarRequest{Account: config.Account.Name} - if err := verifyID(dat.Account); err != nil { + if err := checkAccount(config.Account); err != nil { return err } - response, err := client.Radar(ctx, &dat) + response, err := client.Radar(ctx, &rove.RadarRequest{ + Account: &rove.Account{ + Name: config.Account.Name, + Secret: config.Account.Secret, + }, + }) + switch { case err != nil: return err @@ -282,11 +289,16 @@ func InnerMain(command string, args ...string) error { } case "status": - req := rove.StatusRequest{Account: config.Account.Name} - if err := verifyID(req.Account); err != nil { + if err := checkAccount(config.Account); err != nil { return err } - response, err := client.Status(ctx, &req) + + response, err := client.Status(ctx, &rove.StatusRequest{ + Account: &rove.Account{ + Name: config.Account.Name, + Secret: config.Account.Secret, + }, + }) switch { case err != nil: diff --git a/pkg/accounts/accounts.go b/pkg/accounts/accounts.go index 3e810fa..08f3ee3 100644 --- a/pkg/accounts/accounts.go +++ b/pkg/accounts/accounts.go @@ -3,6 +3,8 @@ package accounts import ( "fmt" "time" + + "github.com/google/uuid" ) // Account represents a registered user @@ -29,7 +31,7 @@ func NewAccountant() *Accountant { // RegisterAccount adds an account to the set of internal accounts func (a *Accountant) RegisterAccount(name string) (acc Account, err error) { - // Set the account name + // Set up the account info acc.Name = name acc.Data = make(map[string]string) @@ -43,12 +45,25 @@ func (a *Accountant) RegisterAccount(name string) (acc Account, err error) { // Set the creation time acc.Data["created"] = time.Now().String() + // Create a secret + acc.Data["secret"] = uuid.New().String() + // Simply add the account to the map a.Accounts[acc.Name] = acc return } +// VerifySecret verifies if an account secret is correct +func (a *Accountant) VerifySecret(account string, secret string) (bool, error) { + // Find the account matching the ID + if this, ok := a.Accounts[account]; ok { + return this.Data["secret"] == secret, nil + } + + return false, fmt.Errorf("no account found for id: %s", account) +} + // AssignData assigns data to an account func (a *Accountant) AssignData(account string, key string, value string) error { diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index a628535..2ef8d33 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -101,7 +101,7 @@ type CommandRequest struct { unknownFields protoimpl.UnknownFields // The account to execute these commands - Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` + Account *Account `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` // The set of desired commands Commands []*Command `protobuf:"bytes,2,rep,name=commands,proto3" json:"commands,omitempty"` } @@ -138,11 +138,11 @@ func (*CommandRequest) Descriptor() ([]byte, []int) { return file_rove_rove_proto_rawDescGZIP(), []int{1} } -func (x *CommandRequest) GetAccount() string { +func (x *CommandRequest) GetAccount() *Account { if x != nil { return x.Account } - return "" + return nil } func (x *CommandRequest) GetCommands() []*Command { @@ -245,7 +245,7 @@ type RadarRequest struct { unknownFields protoimpl.UnknownFields // The account for this request - Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` + Account *Account `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` } func (x *RadarRequest) Reset() { @@ -280,11 +280,11 @@ func (*RadarRequest) Descriptor() ([]byte, []int) { return file_rove_rove_proto_rawDescGZIP(), []int{4} } -func (x *RadarRequest) GetAccount() string { +func (x *RadarRequest) GetAccount() *Account { if x != nil { return x.Account } - return "" + return nil } type RadarResponse struct { @@ -353,45 +353,6 @@ func (x *RadarResponse) GetObjects() []byte { return nil } -// Empty placeholder -type RegisterResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *RegisterResponse) Reset() { - *x = RegisterResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RegisterResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterResponse) ProtoMessage() {} - -func (x *RegisterResponse) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RegisterResponse.ProtoReflect.Descriptor instead. -func (*RegisterResponse) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{6} -} - type RegisterRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -404,7 +365,7 @@ type RegisterRequest struct { func (x *RegisterRequest) Reset() { *x = RegisterRequest{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[7] + mi := &file_rove_rove_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -417,7 +378,7 @@ func (x *RegisterRequest) String() string { func (*RegisterRequest) ProtoMessage() {} func (x *RegisterRequest) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[7] + mi := &file_rove_rove_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -430,7 +391,7 @@ func (x *RegisterRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RegisterRequest.ProtoReflect.Descriptor instead. func (*RegisterRequest) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{7} + return file_rove_rove_proto_rawDescGZIP(), []int{6} } func (x *RegisterRequest) GetName() string { @@ -440,13 +401,62 @@ func (x *RegisterRequest) GetName() string { return "" } +// Empty placeholder +type RegisterResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The registered account information + Account *Account `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` +} + +func (x *RegisterResponse) Reset() { + *x = RegisterResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_rove_rove_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RegisterResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterResponse) ProtoMessage() {} + +func (x *RegisterResponse) ProtoReflect() protoreflect.Message { + mi := &file_rove_rove_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RegisterResponse.ProtoReflect.Descriptor instead. +func (*RegisterResponse) Descriptor() ([]byte, []int) { + return file_rove_rove_proto_rawDescGZIP(), []int{7} +} + +func (x *RegisterResponse) GetAccount() *Account { + if x != nil { + return x.Account + } + return nil +} + type StatusRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // The account for this request - Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` + Account *Account `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` } func (x *StatusRequest) Reset() { @@ -481,11 +491,11 @@ func (*StatusRequest) Descriptor() ([]byte, []int) { return file_rove_rove_proto_rawDescGZIP(), []int{8} } -func (x *StatusRequest) GetAccount() string { +func (x *StatusRequest) GetAccount() *Account { if x != nil { return x.Account } - return "" + return nil } type StatusResponse struct { @@ -804,6 +814,61 @@ func (x *Vector) GetY() int32 { return 0 } +type Account struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Secret string `protobuf:"bytes,2,opt,name=secret,proto3" json:"secret,omitempty"` +} + +func (x *Account) Reset() { + *x = Account{} + if protoimpl.UnsafeEnabled { + mi := &file_rove_rove_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Account) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Account) ProtoMessage() {} + +func (x *Account) ProtoReflect() protoreflect.Message { + mi := &file_rove_rove_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Account.ProtoReflect.Descriptor instead. +func (*Account) Descriptor() ([]byte, []int) { + return file_rove_rove_proto_rawDescGZIP(), []int{13} +} + +func (x *Account) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Account) GetSecret() string { + if x != nil { + return x.Secret + } + return "" +} + var File_rove_rove_proto protoreflect.FileDescriptor var file_rove_rove_proto_rawDesc = []byte{ @@ -814,97 +879,106 @@ var file_rove_rove_proto_rawDesc = []byte{ 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x65, 0x61, - 0x72, 0x69, 0x6e, 0x67, 0x22, 0x55, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x12, 0x29, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, - 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x28, 0x0a, - 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, - 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x55, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x14, - 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, - 0x69, 0x6c, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x12, - 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x25, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x29, 0x0a, 0x0d, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x98, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x70, - 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, - 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, - 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, - 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, - 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, - 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, - 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, - 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, - 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, - 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, - 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, - 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x39, 0x0a, - 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x35, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, - 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, - 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, - 0x15, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa1, 0x01, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, - 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, - 0x1a, 0x0a, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, - 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x1b, 0x0a, - 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, - 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, - 0x32, 0x91, 0x03, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x5d, 0x0a, 0x0c, 0x53, 0x65, 0x72, - 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4b, 0x0a, 0x07, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x22, 0x08, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, - 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, - 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x47, 0x0a, 0x06, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x12, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0c, 0x22, 0x07, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, - 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x69, 0x6e, 0x67, 0x22, 0x64, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, + 0x29, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x0a, + 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x37, 0x0a, 0x0c, + 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, + 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x55, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, + 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x69, 0x6c, + 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x25, 0x0a, 0x0f, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x22, 0x3b, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x22, 0x38, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x98, 0x03, 0x0a, 0x0e, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x28, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, + 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, + 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, + 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, + 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, + 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, + 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, + 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, + 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, + 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, + 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, + 0x72, 0x67, 0x65, 0x12, 0x39, 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, + 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x35, + 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, + 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x15, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa1, 0x01, 0x0a, + 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, + 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, + 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, + 0x69, 0x63, 0x6b, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, + 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0x35, 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x32, 0x91, 0x03, + 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x5d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x16, 0x82, + 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2d, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, + 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, + 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4b, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x12, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x13, + 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x22, 0x08, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, + 0x72, 0x61, 0x64, 0x61, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x47, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x12, 0x82, + 0xd3, 0xe4, 0x93, 0x02, 0x0c, 0x22, 0x07, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x3a, 0x01, + 0x2a, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, + 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -919,7 +993,7 @@ func file_rove_rove_proto_rawDescGZIP() []byte { return file_rove_rove_proto_rawDescData } -var file_rove_rove_proto_msgTypes = make([]protoimpl.MessageInfo, 13) +var file_rove_rove_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_rove_rove_proto_goTypes = []interface{}{ (*Command)(nil), // 0: rove.Command (*CommandRequest)(nil), // 1: rove.CommandRequest @@ -927,34 +1001,39 @@ var file_rove_rove_proto_goTypes = []interface{}{ (*Error)(nil), // 3: rove.Error (*RadarRequest)(nil), // 4: rove.RadarRequest (*RadarResponse)(nil), // 5: rove.RadarResponse - (*RegisterResponse)(nil), // 6: rove.RegisterResponse - (*RegisterRequest)(nil), // 7: rove.RegisterRequest + (*RegisterRequest)(nil), // 6: rove.RegisterRequest + (*RegisterResponse)(nil), // 7: rove.RegisterResponse (*StatusRequest)(nil), // 8: rove.StatusRequest (*StatusResponse)(nil), // 9: rove.StatusResponse (*ServerStatusRequest)(nil), // 10: rove.ServerStatusRequest (*ServerStatusResponse)(nil), // 11: rove.ServerStatusResponse (*Vector)(nil), // 12: rove.Vector + (*Account)(nil), // 13: rove.Account } var file_rove_rove_proto_depIdxs = []int32{ - 0, // 0: rove.CommandRequest.commands:type_name -> rove.Command - 12, // 1: rove.StatusResponse.position:type_name -> rove.Vector - 0, // 2: rove.StatusResponse.incomingCommands:type_name -> rove.Command - 0, // 3: rove.StatusResponse.queuedCommands:type_name -> rove.Command - 10, // 4: rove.Rove.ServerStatus:input_type -> rove.ServerStatusRequest - 7, // 5: rove.Rove.Register:input_type -> rove.RegisterRequest - 1, // 6: rove.Rove.Command:input_type -> rove.CommandRequest - 4, // 7: rove.Rove.Radar:input_type -> rove.RadarRequest - 8, // 8: rove.Rove.Status:input_type -> rove.StatusRequest - 11, // 9: rove.Rove.ServerStatus:output_type -> rove.ServerStatusResponse - 6, // 10: rove.Rove.Register:output_type -> rove.RegisterResponse - 2, // 11: rove.Rove.Command:output_type -> rove.CommandResponse - 5, // 12: rove.Rove.Radar:output_type -> rove.RadarResponse - 9, // 13: rove.Rove.Status:output_type -> rove.StatusResponse - 9, // [9:14] is the sub-list for method output_type - 4, // [4:9] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name + 13, // 0: rove.CommandRequest.account:type_name -> rove.Account + 0, // 1: rove.CommandRequest.commands:type_name -> rove.Command + 13, // 2: rove.RadarRequest.account:type_name -> rove.Account + 13, // 3: rove.RegisterResponse.account:type_name -> rove.Account + 13, // 4: rove.StatusRequest.account:type_name -> rove.Account + 12, // 5: rove.StatusResponse.position:type_name -> rove.Vector + 0, // 6: rove.StatusResponse.incomingCommands:type_name -> rove.Command + 0, // 7: rove.StatusResponse.queuedCommands:type_name -> rove.Command + 10, // 8: rove.Rove.ServerStatus:input_type -> rove.ServerStatusRequest + 6, // 9: rove.Rove.Register:input_type -> rove.RegisterRequest + 1, // 10: rove.Rove.Command:input_type -> rove.CommandRequest + 4, // 11: rove.Rove.Radar:input_type -> rove.RadarRequest + 8, // 12: rove.Rove.Status:input_type -> rove.StatusRequest + 11, // 13: rove.Rove.ServerStatus:output_type -> rove.ServerStatusResponse + 7, // 14: rove.Rove.Register:output_type -> rove.RegisterResponse + 2, // 15: rove.Rove.Command:output_type -> rove.CommandResponse + 5, // 16: rove.Rove.Radar:output_type -> rove.RadarResponse + 9, // 17: rove.Rove.Status:output_type -> rove.StatusResponse + 13, // [13:18] is the sub-list for method output_type + 8, // [8:13] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name } func init() { file_rove_rove_proto_init() } @@ -1036,7 +1115,7 @@ func file_rove_rove_proto_init() { } } file_rove_rove_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RegisterResponse); i { + switch v := v.(*RegisterRequest); i { case 0: return &v.state case 1: @@ -1048,7 +1127,7 @@ func file_rove_rove_proto_init() { } } file_rove_rove_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RegisterRequest); i { + switch v := v.(*RegisterResponse); i { case 0: return &v.state case 1: @@ -1119,6 +1198,18 @@ func file_rove_rove_proto_init() { return nil } } + file_rove_rove_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Account); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -1126,7 +1217,7 @@ func file_rove_rove_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_rove_rove_proto_rawDesc, NumEnums: 0, - NumMessages: 13, + NumMessages: 14, NumExtensions: 0, NumServices: 1, }, diff --git a/pkg/rove/rove.swagger.json b/pkg/rove/rove.swagger.json index e629dab..392817a 100644 --- a/pkg/rove/rove.swagger.json +++ b/pkg/rove/rove.swagger.json @@ -207,6 +207,17 @@ } } }, + "roveAccount": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "secret": { + "type": "string" + } + } + }, "roveCommand": { "type": "object", "properties": { @@ -224,7 +235,7 @@ "type": "object", "properties": { "account": { - "type": "string", + "$ref": "#/definitions/roveAccount", "title": "The account to execute these commands" }, "commands": { @@ -244,7 +255,7 @@ "type": "object", "properties": { "account": { - "type": "string", + "$ref": "#/definitions/roveAccount", "title": "The account for this request" } } @@ -280,6 +291,12 @@ }, "roveRegisterResponse": { "type": "object", + "properties": { + "account": { + "$ref": "#/definitions/roveAccount", + "title": "The registered account information" + } + }, "title": "Empty placeholder" }, "roveServerStatusResponse": { @@ -314,7 +331,7 @@ "type": "object", "properties": { "account": { - "type": "string", + "$ref": "#/definitions/roveAccount", "title": "The account for this request" } } diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index 586af22..6882d40 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -74,7 +74,7 @@ message Command { message CommandRequest { // The account to execute these commands - string account = 1; + Account account = 1; // The set of desired commands repeated Command commands = 2; @@ -90,7 +90,7 @@ message Error { message RadarRequest { // The account for this request - string account = 1; + Account account = 1; } message RadarResponse { @@ -104,17 +104,20 @@ message RadarResponse { bytes objects = 3; } -// Empty placeholder -message RegisterResponse{} - message RegisterRequest { // The desired account name string name = 1; } +// Empty placeholder +message RegisterResponse{ + // The registered account information + Account account = 1; +} + message StatusRequest { // The account for this request - string account = 1; + Account account = 1; } message StatusResponse { @@ -175,4 +178,9 @@ message ServerStatusResponse { message Vector { int32 x = 1; int32 y = 2; +} + +message Account { + string name = 1; + string secret = 2; } \ No newline at end of file From d9e97ea468a6a45d7455ee5d87eaa7aaf3dbec14 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 7 Jul 2020 22:46:34 +0100 Subject: [PATCH 074/228] Add some additional logging to requests and world resizes --- cmd/rove-server/internal/routes.go | 11 +++++++++-- pkg/atlas/atlas.go | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index c8d04ef..8ec49bc 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -3,6 +3,7 @@ package internal import ( "context" "fmt" + "log" "github.com/mdiluz/rove/pkg/game" "github.com/mdiluz/rove/pkg/rove" @@ -18,8 +19,6 @@ func (s *Server) ServerStatus(context.Context, *rove.ServerStatusRequest) (*rove CurrentTick: int32(s.world.CurrentTicks), } - // TODO: Verify the accountant is up and ready too - // If there's a schedule, respond with it if len(s.schedule.Entries()) > 0 { 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 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 { 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 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 { 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 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 { 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 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 { return nil, err diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index 0840873..2e157b7 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -1,6 +1,7 @@ package atlas import ( + "log" "math/rand" "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), } + // 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 for chunk, chunkData := range a.Chunks { From 3e1e3a5456d5a3c676aa87130e8bc797474bd40e Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 7 Jul 2020 22:49:34 +0100 Subject: [PATCH 075/228] Amend to TestWorld_RadarFromRover to show the issue --- pkg/game/world_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/game/world_test.go b/pkg/game/world_test.go index 3e5939e..719312a 100644 --- a/pkg/game/world_test.go +++ b/pkg/game/world_test.go @@ -121,6 +121,12 @@ func TestWorld_RadarFromRover(t *testing.T) { // Test the expected values assert.Equal(t, byte(objects.Rover), objs[1+fullRange]) assert.Equal(t, byte(objects.Rover), objs[4+4*fullRange]) + + // Check the radar results are stable + radar1, objs1, err := world.RadarFromRover(a) + radar2, objs2, err := world.RadarFromRover(a) + assert.Equal(t, radar1, radar2) + assert.Equal(t, objs1, objs2) } func TestWorld_RoverStash(t *testing.T) { From 089f5e53374bc25b78d776310da63b7cf79b65d3 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 7 Jul 2020 22:57:55 +0100 Subject: [PATCH 076/228] Fix chunk empty chunk population in QueryPosition --- pkg/atlas/atlas.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index 2e157b7..1c194af 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -84,6 +84,7 @@ func (a *Atlas) QueryPosition(v vector.Vector) (byte, objects.Object) { chunk := a.Chunks[c] if chunk.Tiles == nil { chunk.populate(a.ChunkSize) + a.Chunks[c] = chunk } i := a.chunkTileIndex(local) return chunk.Tiles[i], chunk.Objects[i] From 0386617c519441f82fc55c1de9eafd5515999901 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 7 Jul 2020 23:01:28 +0100 Subject: [PATCH 077/228] Add error checks in TestWorld_RadarFromRover --- pkg/game/world_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/game/world_test.go b/pkg/game/world_test.go index 719312a..0246785 100644 --- a/pkg/game/world_test.go +++ b/pkg/game/world_test.go @@ -124,7 +124,9 @@ func TestWorld_RadarFromRover(t *testing.T) { // Check the radar results are stable radar1, objs1, err := world.RadarFromRover(a) + assert.NoError(t, err) radar2, objs2, err := world.RadarFromRover(a) + assert.NoError(t, err) assert.Equal(t, radar1, radar2) assert.Equal(t, objs1, objs2) } From 10959ef7266018ff3bee284c97f82318fc4e9be1 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 8 Jul 2020 19:40:15 +0100 Subject: [PATCH 078/228] Refactor populate to be an Atlas function This simplifies usage greatly --- pkg/atlas/atlas.go | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index 1c194af..209d4b7 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -59,7 +59,7 @@ func NewAtlas(chunkSize int) Atlas { UpperBound: vector.Vector{X: chunkSize, Y: chunkSize}, } // Initialise the first chunk - a.Chunks[0].populate(chunkSize) + a.populate(0) return a } @@ -81,11 +81,8 @@ func (a *Atlas) SetObject(v vector.Vector, obj objects.Object) { func (a *Atlas) QueryPosition(v vector.Vector) (byte, objects.Object) { c := a.worldSpaceToChunkWithGrow(v) local := a.worldSpaceToChunkLocal(v) + a.populate(c) chunk := a.Chunks[c] - if chunk.Tiles == nil { - chunk.populate(a.ChunkSize) - a.Chunks[c] = chunk - } i := a.chunkTileIndex(local) return chunk.Tiles[i], chunk.Objects[i] } @@ -96,8 +93,13 @@ func (a *Atlas) chunkTileIndex(local vector.Vector) int { } // populate will fill a chunk with data -func (c *Chunk) populate(size int) { - c.Tiles = make([]byte, size*size) +func (a *Atlas) populate(chunk int) { + c := a.Chunks[chunk] + if c.Tiles != nil { + return + } + + c.Tiles = make([]byte, a.ChunkSize*a.ChunkSize) c.Objects = make(map[int]objects.Object) // Set up the tiles @@ -117,26 +119,23 @@ func (c *Chunk) populate(size int) { c.Objects[i] = objects.Object{Type: objects.SmallRock} } } + + a.Chunks[chunk] = c } // setTile sets a tile in a specific chunk func (a *Atlas) setTile(chunk int, local vector.Vector, tile byte) { + a.populate(chunk) c := a.Chunks[chunk] - if c.Tiles == nil { - c.populate(a.ChunkSize) - } - c.Tiles[a.chunkTileIndex(local)] = tile a.Chunks[chunk] = c } // setObject sets an object in a specific chunk func (a *Atlas) setObject(chunk int, local vector.Vector, object objects.Object) { - c := a.Chunks[chunk] - if c.Tiles == nil { - c.populate(a.ChunkSize) - } + a.populate(chunk) + c := a.Chunks[chunk] i := a.chunkTileIndex(local) if object.Type != objects.None { c.Objects[i] = object From ed9ecef80a8c6d834d9bf779fc6d53f2298bc2c5 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 8 Jul 2020 20:10:28 +0100 Subject: [PATCH 079/228] Add perlin based generation for the terrain tiles --- go.mod | 1 + go.sum | 2 ++ pkg/atlas/atlas.go | 29 +++++++++++++++++++++++------ pkg/atlas/atlas_test.go | 24 ++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 2165ade..6c4320a 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/mdiluz/rove go 1.14 require ( + github.com/aquilax/go-perlin v0.0.0-20191229124216-0af9ce917c28 github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang/protobuf v1.4.2 github.com/google/uuid v1.1.1 diff --git a/go.sum b/go.sum index 029b75f..e579bf8 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/aquilax/go-perlin v0.0.0-20191229124216-0af9ce917c28 h1:iQUvYFmTKLXaDf3N0YfsJG5vgVtA1La82fHFDkpX5y4= +github.com/aquilax/go-perlin v0.0.0-20191229124216-0af9ce917c28/go.mod h1:z9Rl7EM4BZY0Ikp2fEN1I5mKSOJ26HQpk0O2TBdN2HE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f h1:WBZRG4aNOuI15bLRrCgN8fCq8E5Xuty6jGbmSNEvSsU= diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index 209d4b7..c6bcc37 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -4,6 +4,7 @@ import ( "log" "math/rand" + "github.com/aquilax/go-perlin" "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/vector" @@ -47,6 +48,9 @@ type Atlas struct { // ChunkSize is the x/y dimensions of each square chunk ChunkSize int `json:"chunksize"` + + // perlin is the current perlin noise generator + perlin *perlin.Perlin } // NewAtlas creates a new empty atlas @@ -57,6 +61,7 @@ func NewAtlas(chunkSize int) Atlas { Chunks: make([]Chunk, 1), LowerBound: vector.Vector{X: 0, Y: 0}, UpperBound: vector.Vector{X: chunkSize, Y: chunkSize}, + perlin: perlin.NewPerlin(2, 2, 3, 100), } // Initialise the first chunk a.populate(0) @@ -102,12 +107,23 @@ func (a *Atlas) populate(chunk int) { c.Tiles = make([]byte, a.ChunkSize*a.ChunkSize) c.Objects = make(map[int]objects.Object) - // Set up the tiles - for i := 0; i < len(c.Tiles); i++ { - if rand.Intn(3) == 0 { - c.Tiles[i] = byte(TileRock) - } else { - c.Tiles[i] = byte(TileSand) + origin := a.chunkOriginInWorldSpace(chunk) + for i := 0; i < a.ChunkSize; i++ { + for j := 0; j < a.ChunkSize; j++ { + + // Get the perlin noise value for this location + pl := a.perlin.Noise2D(float64(origin.X+i)/10, float64(origin.Y+j)/10) + + // Choose a tile based on the perlin noise value + var tile Tile + switch { + case pl > 0.1: + tile = TileSand + default: + tile = TileRock + } + + c.Tiles[j*a.ChunkSize+i] = byte(tile) } } @@ -217,6 +233,7 @@ func (a *Atlas) worldSpaceToChunkWithGrow(v vector.Vector) int { LowerBound: lower, UpperBound: upper, Chunks: make([]Chunk, size.X*size.Y), + perlin: a.perlin, } // Log that we're resizing diff --git a/pkg/atlas/atlas_test.go b/pkg/atlas/atlas_test.go index 60c3922..dedf4b1 100644 --- a/pkg/atlas/atlas_test.go +++ b/pkg/atlas/atlas_test.go @@ -1,6 +1,7 @@ package atlas import ( + "fmt" "testing" "github.com/mdiluz/rove/pkg/objects" @@ -248,3 +249,26 @@ func TestAtlas_GetSetCorrect(t *testing.T) { } } } + +func TestAtlas_WorldGen(t *testing.T) { + a := NewAtlas(8) + // Spawn a large world + _, _ = a.QueryPosition(vector.Vector{X: 20, Y: 20}) + + // Print out the world for manual evaluation + num := 20 + for j := num - 1; j >= 0; j-- { + for i := 0; i < num; i++ { + t, o := a.QueryPosition(vector.Vector{X: i, Y: j}) + if o.Type != objects.None { + fmt.Printf("%c", o.Type) + } else if t != byte(TileNone) { + fmt.Printf("%c", t) + } else { + fmt.Printf(" ") + } + + } + fmt.Print("\n") + } +} From 7b4541716abaf4db3eb2365a631a32ddcd91121d Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 8 Jul 2020 23:45:52 +0100 Subject: [PATCH 080/228] Add gravel tiles --- pkg/atlas/atlas.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index c6bcc37..144ce93 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -18,10 +18,13 @@ const ( TileNone = Tile(0) // TileRock is solid rock ground - TileRock = Tile('.') + TileRock = Tile('-') + + // TileGravel is loose rocks + TileGravel = Tile(':') // TileSand is sand - TileSand = Tile(',') + TileSand = Tile('~') ) // Chunk represents a fixed square grid of tiles @@ -112,12 +115,14 @@ func (a *Atlas) populate(chunk int) { for j := 0; j < a.ChunkSize; j++ { // Get the perlin noise value for this location - pl := a.perlin.Noise2D(float64(origin.X+i)/10, float64(origin.Y+j)/10) + pl := a.perlin.Noise2D(float64(origin.X+i)/15, float64(origin.Y+j)/15) // Choose a tile based on the perlin noise value var tile Tile switch { - case pl > 0.1: + case pl > 0.2: + tile = TileGravel + case pl > 0.05: tile = TileSand default: tile = TileRock From 4b715bdff3684eab0426932b6a48aa3110ed0634 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 8 Jul 2020 23:58:11 +0100 Subject: [PATCH 081/228] Move to OpenSimplex noise Apart from other benefits, this produces much nicer direction agnostic noise --- go.mod | 2 +- go.sum | 4 ++-- pkg/atlas/atlas.go | 18 +++++++++++------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 6c4320a..db01c84 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,12 @@ module github.com/mdiluz/rove go 1.14 require ( - github.com/aquilax/go-perlin v0.0.0-20191229124216-0af9ce917c28 github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang/protobuf v1.4.2 github.com/google/uuid v1.1.1 github.com/grpc-ecosystem/grpc-gateway v1.14.6 github.com/kr/pretty v0.1.0 // indirect + github.com/ojrac/opensimplex-go v1.0.1 github.com/robfig/cron v1.2.0 github.com/stretchr/testify v1.6.0 golang.org/x/net v0.0.0-20200602114024-627f9648deb9 diff --git a/go.sum b/go.sum index e579bf8..a2bd9a2 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,6 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/aquilax/go-perlin v0.0.0-20191229124216-0af9ce917c28 h1:iQUvYFmTKLXaDf3N0YfsJG5vgVtA1La82fHFDkpX5y4= -github.com/aquilax/go-perlin v0.0.0-20191229124216-0af9ce917c28/go.mod h1:z9Rl7EM4BZY0Ikp2fEN1I5mKSOJ26HQpk0O2TBdN2HE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f h1:WBZRG4aNOuI15bLRrCgN8fCq8E5Xuty6jGbmSNEvSsU= @@ -52,6 +50,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/ojrac/opensimplex-go v1.0.1 h1:XslvpLP6XqQSATUtsOnGBYtFPw7FQ6h6y0ihjVeOLHo= +github.com/ojrac/opensimplex-go v1.0.1/go.mod h1:MoSgj04tZpH8U0RefZabnHV2AbLgv/2mo3hLJtWqSEs= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index 144ce93..0526488 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -4,10 +4,10 @@ import ( "log" "math/rand" - "github.com/aquilax/go-perlin" "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/vector" + "github.com/ojrac/opensimplex-go" ) // Tile describes the type of terrain @@ -52,10 +52,14 @@ type Atlas struct { // ChunkSize is the x/y dimensions of each square chunk ChunkSize int `json:"chunksize"` - // perlin is the current perlin noise generator - perlin *perlin.Perlin + // noise is an OpenSimplex noise generator + noise opensimplex.Noise } +const ( + noiseSeed = 1024 +) + // NewAtlas creates a new empty atlas func NewAtlas(chunkSize int) Atlas { // Start up with one chunk @@ -64,7 +68,7 @@ func NewAtlas(chunkSize int) Atlas { Chunks: make([]Chunk, 1), LowerBound: vector.Vector{X: 0, Y: 0}, UpperBound: vector.Vector{X: chunkSize, Y: chunkSize}, - perlin: perlin.NewPerlin(2, 2, 3, 100), + noise: opensimplex.New(noiseSeed), } // Initialise the first chunk a.populate(0) @@ -115,12 +119,12 @@ func (a *Atlas) populate(chunk int) { for j := 0; j < a.ChunkSize; j++ { // Get the perlin noise value for this location - pl := a.perlin.Noise2D(float64(origin.X+i)/15, float64(origin.Y+j)/15) + pl := a.noise.Eval2(float64(origin.X+i)/6, float64(origin.Y+j)/6) // Choose a tile based on the perlin noise value var tile Tile switch { - case pl > 0.2: + case pl > 0.5: tile = TileGravel case pl > 0.05: tile = TileSand @@ -238,7 +242,7 @@ func (a *Atlas) worldSpaceToChunkWithGrow(v vector.Vector) int { LowerBound: lower, UpperBound: upper, Chunks: make([]Chunk, size.X*size.Y), - perlin: a.perlin, + noise: a.noise, } // Log that we're resizing From 9682cfa7ea331c265b45c516b32a5ea207bbbf20 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 9 Jul 2020 00:04:46 +0100 Subject: [PATCH 082/228] Spawn objects using OpenSimplex noise as well --- pkg/atlas/atlas.go | 57 ++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index 0526488..dd618e7 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -52,23 +52,29 @@ type Atlas struct { // ChunkSize is the x/y dimensions of each square chunk ChunkSize int `json:"chunksize"` - // noise is an OpenSimplex noise generator - noise opensimplex.Noise + // terrainNoise describes the noise function for the terrain + terrainNoise opensimplex.Noise + + // terrainNoise describes the noise function for the terrain + objectNoise opensimplex.Noise } const ( - noiseSeed = 1024 + noiseSeed = 1024 + terrainNoiseScale = 6 + objectNoiseScale = 3 ) // NewAtlas creates a new empty atlas func NewAtlas(chunkSize int) Atlas { // Start up with one chunk a := Atlas{ - ChunkSize: chunkSize, - Chunks: make([]Chunk, 1), - LowerBound: vector.Vector{X: 0, Y: 0}, - UpperBound: vector.Vector{X: chunkSize, Y: chunkSize}, - noise: opensimplex.New(noiseSeed), + ChunkSize: chunkSize, + Chunks: make([]Chunk, 1), + LowerBound: vector.Vector{X: 0, Y: 0}, + UpperBound: vector.Vector{X: chunkSize, Y: chunkSize}, + terrainNoise: opensimplex.New(noiseSeed), + objectNoise: opensimplex.New(noiseSeed), } // Initialise the first chunk a.populate(0) @@ -118,21 +124,31 @@ func (a *Atlas) populate(chunk int) { for i := 0; i < a.ChunkSize; i++ { for j := 0; j < a.ChunkSize; j++ { - // Get the perlin noise value for this location - pl := a.noise.Eval2(float64(origin.X+i)/6, float64(origin.Y+j)/6) - - // Choose a tile based on the perlin noise value + // Get the terrain noise value for this location + t := a.terrainNoise.Eval2(float64(origin.X+i)/terrainNoiseScale, float64(origin.Y+j)/terrainNoiseScale) var tile Tile switch { - case pl > 0.5: + case t > 0.5: tile = TileGravel - case pl > 0.05: + case t > 0.05: tile = TileSand default: tile = TileRock } - c.Tiles[j*a.ChunkSize+i] = byte(tile) + + // Get the object noise value for this location + o := a.objectNoise.Eval2(float64(origin.X+i)/objectNoiseScale, float64(origin.Y+j)/objectNoiseScale) + var obj = objects.None + switch { + case o > 0.6: + obj = objects.LargeRock + case o > 0.5: + obj = objects.SmallRock + } + if obj != objects.None { + c.Objects[j*a.ChunkSize+i] = objects.Object{Type: obj} + } } } @@ -238,11 +254,12 @@ func (a *Atlas) worldSpaceToChunkWithGrow(v vector.Vector) int { // Create the new empty atlas newAtlas := Atlas{ - ChunkSize: a.ChunkSize, - LowerBound: lower, - UpperBound: upper, - Chunks: make([]Chunk, size.X*size.Y), - noise: a.noise, + ChunkSize: a.ChunkSize, + LowerBound: lower, + UpperBound: upper, + Chunks: make([]Chunk, size.X*size.Y), + terrainNoise: a.terrainNoise, + objectNoise: a.objectNoise, } // Log that we're resizing From 0dc3cab9c0daa803d1f8822c7abc3aef7bfbc97c Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 9 Jul 2020 18:19:49 +0100 Subject: [PATCH 083/228] Store log entries for actions in the rover --- pkg/game/rover.go | 30 +++++++++++++++++++++++++++++- pkg/game/world.go | 10 +++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/pkg/game/rover.go b/pkg/game/rover.go index a7e3fb3..693ba9a 100644 --- a/pkg/game/rover.go +++ b/pkg/game/rover.go @@ -1,10 +1,23 @@ package game import ( + "fmt" + "log" + "time" + "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/vector" ) +// RoverLogEntry describes a single log entry for the rover +type RoverLogEntry struct { + // Time is the timestamp of the entry + Time time.Time `json:"time"` + + // Text contains the information in this log entry + Text string `json:"text"` +} + // Rover describes a single rover in the world type Rover struct { // Unique name of this rover @@ -31,6 +44,21 @@ type Rover struct { // Charge is the amount of energy the rover has Charge int `json:"charge"` - // ChargeCharge is the maximum charge able to be stored + // MaximumCharge is the maximum charge able to be stored MaximumCharge int `json:"maximum-Charge"` + + // Logs Stores log of information + Logs []RoverLogEntry `json:"logs"` +} + +// AddLogEntryf adds an entry to the rovers log +func (r *Rover) AddLogEntryf(format string, args ...interface{}) { + text := fmt.Sprintf(format, args...) + log.Printf("%s log entry: %s", r.Name, text) + r.Logs = append(r.Logs, + RoverLogEntry{ + Time: time.Now(), + Text: text, + }, + ) } diff --git a/pkg/game/world.go b/pkg/game/world.go index a4a70af..b53dc7e 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -122,7 +122,8 @@ func (w *World) SpawnRover() (string, error) { } - log.Printf("Spawned rover at %+v\n", rover.Pos) + // Add a log entry for robot creation + rover.AddLogEntryf("created at %+v", rover.Pos) // Append the rover to the list w.Rovers[rover.Name] = rover @@ -160,6 +161,7 @@ func (w *World) RoverRecharge(rover string) (int, error) { // Add one charge if i.Charge < i.MaximumCharge { i.Charge++ + i.AddLogEntryf("recharged to %d", i.Charge) } w.Rovers[rover] = i @@ -239,6 +241,7 @@ func (w *World) WarpRover(rover string, pos vector.Vector) error { return fmt.Errorf("can't warp rover to occupied tile, check before warping") } + i.AddLogEntryf("warped to %+v", pos) i.Pos = pos w.Rovers[rover] = i return nil @@ -266,12 +269,15 @@ func (w *World) MoveRover(rover string, b bearing.Bearing) (vector.Vector, error // Get the tile and verify it's empty _, obj := w.Atlas.QueryPosition(newPos) if !obj.IsBlocking() { + i.AddLogEntryf("moved %s to %+v", b.String(), newPos) // Perform the move i.Pos = newPos w.Rovers[rover] = i } else { // If it is a blocking tile, reduce the rover integrity + i.AddLogEntryf("tried to move %s to %+v", b.String(), newPos) i.Integrity = i.Integrity - 1 + i.AddLogEntryf("had a collision, new integrity %d", i.Integrity) if i.Integrity == 0 { // TODO: The rover needs to be left dormant with the player } else { @@ -308,6 +314,7 @@ func (w *World) RoverStash(rover string) (objects.Type, error) { return objects.None, nil } + r.AddLogEntryf("stashed %c", obj.Type) r.Inventory = append(r.Inventory, obj) w.Rovers[rover] = r w.Atlas.SetObject(r.Pos, objects.Object{Type: objects.None}) @@ -480,6 +487,7 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { if len(r.Inventory) > 0 && r.Integrity < r.MaximumIntegrity { r.Inventory = r.Inventory[:len(r.Inventory)-1] r.Integrity = r.Integrity + 1 + r.AddLogEntryf("repaired self to %d", r.Integrity) w.Rovers[rover] = r } case CommandRecharge: From 8866f28bf57f5877f3ddce17fcca56038e32ada0 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 9 Jul 2020 18:26:24 +0100 Subject: [PATCH 084/228] Add test coverage checks for logging additions --- pkg/game/world_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/game/world_test.go b/pkg/game/world_test.go index 0246785..ab9b290 100644 --- a/pkg/game/world_test.go +++ b/pkg/game/world_test.go @@ -41,6 +41,7 @@ func TestWorld_GetRover(t *testing.T) { rover, err := world.GetRover(a) assert.NoError(t, err, "Failed to get rover attribs") assert.NotZero(t, rover.Range, "Rover should not be spawned blind") + assert.Contains(t, rover.Logs[len(rover.Logs)-1].Text, "created", "Rover logs should contain the creation") } func TestWorld_DestroyRover(t *testing.T) { @@ -87,6 +88,7 @@ func TestWorld_GetSetMovePosition(t *testing.T) { rover, err := world.GetRover(a) assert.NoError(t, err, "Failed to get rover information") assert.Equal(t, rover.MaximumCharge-1, rover.Charge, "Rover should have lost charge for moving") + assert.Contains(t, rover.Logs[len(rover.Logs)-1].Text, "moved", "Rover logs should contain the move") // Place a tile in front of the rover world.Atlas.SetObject(vector.Vector{X: 0, Y: 2}, objects.Object{Type: objects.LargeRock}) @@ -169,10 +171,11 @@ func TestWorld_RoverStash(t *testing.T) { assert.Equal(t, i+1, len(inv)) assert.Equal(t, objects.Object{Type: objects.SmallRock}, inv[i]) - // Check that this didn't reduce the charge + // Check that this did reduce the charge info, err := world.GetRover(a) assert.NoError(t, err, "Failed to get rover") assert.Equal(t, info.MaximumCharge-(i+1), info.Charge, "Rover lost charge for stash") + assert.Contains(t, info.Logs[len(info.Logs)-1].Text, "stashed", "Rover logs should contain the move") } // Recharge the rover @@ -220,6 +223,7 @@ func TestWorld_RoverDamage(t *testing.T) { info, err := world.GetRover(a) assert.NoError(t, err, "couldn't get rover info") + assert.Contains(t, info.Logs[len(info.Logs)-1].Text, "warped", "Rover logs should contain the warp") world.Atlas.SetObject(vector.Vector{X: 0.0, Y: 1.0}, objects.Object{Type: objects.LargeRock}) @@ -230,6 +234,7 @@ func TestWorld_RoverDamage(t *testing.T) { newinfo, err := world.GetRover(a) assert.NoError(t, err, "couldn't get rover info") assert.Equal(t, info.Integrity-1, newinfo.Integrity, "rover should have lost integrity") + assert.Contains(t, newinfo.Logs[len(newinfo.Logs)-1].Text, "collision", "Rover logs should contain the collision") } func TestWorld_RoverRepair(t *testing.T) { @@ -274,6 +279,7 @@ func TestWorld_RoverRepair(t *testing.T) { newinfo, err = world.GetRover(a) assert.NoError(t, err, "couldn't get rover info") assert.Equal(t, originalInfo.Integrity, newinfo.Integrity, "rover should have gained integrity") + assert.Contains(t, newinfo.Logs[len(newinfo.Logs)-1].Text, "repair", "Rover logs should contain the repair") // Check again that it can't repair past the max world.Atlas.SetObject(pos, objects.Object{Type: objects.SmallRock}) From b2f169d99f341bbca3f0b4d3bc74d46859d25f37 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 9 Jul 2020 18:31:51 +0100 Subject: [PATCH 085/228] Remove Warped log, unneeded --- pkg/game/world.go | 1 - pkg/game/world_test.go | 1 - 2 files changed, 2 deletions(-) diff --git a/pkg/game/world.go b/pkg/game/world.go index b53dc7e..bd6d806 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -241,7 +241,6 @@ func (w *World) WarpRover(rover string, pos vector.Vector) error { return fmt.Errorf("can't warp rover to occupied tile, check before warping") } - i.AddLogEntryf("warped to %+v", pos) i.Pos = pos w.Rovers[rover] = i return nil diff --git a/pkg/game/world_test.go b/pkg/game/world_test.go index ab9b290..c67588a 100644 --- a/pkg/game/world_test.go +++ b/pkg/game/world_test.go @@ -223,7 +223,6 @@ func TestWorld_RoverDamage(t *testing.T) { info, err := world.GetRover(a) assert.NoError(t, err, "couldn't get rover info") - assert.Contains(t, info.Logs[len(info.Logs)-1].Text, "warped", "Rover logs should contain the warp") world.Atlas.SetObject(vector.Vector{X: 0.0, Y: 1.0}, objects.Object{Type: objects.LargeRock}) From 55c85d2a2268fb53b932c20b4b41613c5ef7a51c Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 9 Jul 2020 19:01:09 +0100 Subject: [PATCH 086/228] Add logs to the rover status output --- cmd/rove-server/internal/routes.go | 9 + pkg/rove/rove.pb.go | 392 ++++++++++++++++++----------- pkg/rove/rove.swagger.json | 21 ++ proto/rove/rove.proto | 12 + 4 files changed, 284 insertions(+), 150 deletions(-) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 8ec49bc..e3f280d 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -8,6 +8,7 @@ import ( "github.com/mdiluz/rove/pkg/game" "github.com/mdiluz/rove/pkg/rove" "github.com/mdiluz/rove/pkg/version" + "google.golang.org/protobuf/types/known/timestamppb" ) // ServerStatus returns the status of the current server to a gRPC request @@ -90,6 +91,13 @@ func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (response Bearing: q.Bearing, }) } + var logs []*rove.Log + for _, log := range rover.Logs { + logs = append(logs, &rove.Log{ + Text: log.Text, + Time: timestamppb.New(log.Time), + }) + } response = &rove.StatusResponse{ Name: rover.Name, @@ -106,6 +114,7 @@ func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (response MaximumCharge: int32(rover.MaximumCharge), IncomingCommands: incoming, QueuedCommands: queued, + Logs: logs, } } return response, nil diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index 2ef8d33..b73e07b 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -13,6 +13,7 @@ package rove import ( context "context" proto "github.com/golang/protobuf/proto" + timestamp "github.com/golang/protobuf/ptypes/timestamp" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -498,6 +499,63 @@ func (x *StatusRequest) GetAccount() *Account { return nil } +type Log struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The timestamp of the log + Time *timestamp.Timestamp `protobuf:"bytes,1,opt,name=time,proto3" json:"time,omitempty"` + // The text of the log + Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"` +} + +func (x *Log) Reset() { + *x = Log{} + if protoimpl.UnsafeEnabled { + mi := &file_rove_rove_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Log) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Log) ProtoMessage() {} + +func (x *Log) ProtoReflect() protoreflect.Message { + mi := &file_rove_rove_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Log.ProtoReflect.Descriptor instead. +func (*Log) Descriptor() ([]byte, []int) { + return file_rove_rove_proto_rawDescGZIP(), []int{9} +} + +func (x *Log) GetTime() *timestamp.Timestamp { + if x != nil { + return x.Time + } + return nil +} + +func (x *Log) GetText() string { + if x != nil { + return x.Text + } + return "" +} + type StatusResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -525,12 +583,14 @@ type StatusResponse struct { IncomingCommands []*Command `protobuf:"bytes,10,rep,name=incomingCommands,proto3" json:"incomingCommands,omitempty"` // The set of currently queued commands QueuedCommands []*Command `protobuf:"bytes,11,rep,name=queuedCommands,proto3" json:"queuedCommands,omitempty"` + // The most recent logs + Logs []*Log `protobuf:"bytes,12,rep,name=logs,proto3" json:"logs,omitempty"` } func (x *StatusResponse) Reset() { *x = StatusResponse{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[9] + mi := &file_rove_rove_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -543,7 +603,7 @@ func (x *StatusResponse) String() string { func (*StatusResponse) ProtoMessage() {} func (x *StatusResponse) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[9] + mi := &file_rove_rove_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -556,7 +616,7 @@ func (x *StatusResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use StatusResponse.ProtoReflect.Descriptor instead. func (*StatusResponse) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{9} + return file_rove_rove_proto_rawDescGZIP(), []int{10} } func (x *StatusResponse) GetName() string { @@ -636,6 +696,13 @@ func (x *StatusResponse) GetQueuedCommands() []*Command { return nil } +func (x *StatusResponse) GetLogs() []*Log { + if x != nil { + return x.Logs + } + return nil +} + // Empty placeholder type ServerStatusRequest struct { state protoimpl.MessageState @@ -646,7 +713,7 @@ type ServerStatusRequest struct { func (x *ServerStatusRequest) Reset() { *x = ServerStatusRequest{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[10] + mi := &file_rove_rove_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -659,7 +726,7 @@ func (x *ServerStatusRequest) String() string { func (*ServerStatusRequest) ProtoMessage() {} func (x *ServerStatusRequest) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[10] + mi := &file_rove_rove_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -672,7 +739,7 @@ func (x *ServerStatusRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ServerStatusRequest.ProtoReflect.Descriptor instead. func (*ServerStatusRequest) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{10} + return file_rove_rove_proto_rawDescGZIP(), []int{11} } type ServerStatusResponse struct { @@ -695,7 +762,7 @@ type ServerStatusResponse struct { func (x *ServerStatusResponse) Reset() { *x = ServerStatusResponse{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[11] + mi := &file_rove_rove_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -708,7 +775,7 @@ func (x *ServerStatusResponse) String() string { func (*ServerStatusResponse) ProtoMessage() {} func (x *ServerStatusResponse) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[11] + mi := &file_rove_rove_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -721,7 +788,7 @@ func (x *ServerStatusResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ServerStatusResponse.ProtoReflect.Descriptor instead. func (*ServerStatusResponse) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{11} + return file_rove_rove_proto_rawDescGZIP(), []int{12} } func (x *ServerStatusResponse) GetVersion() string { @@ -771,7 +838,7 @@ type Vector struct { func (x *Vector) Reset() { *x = Vector{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[12] + mi := &file_rove_rove_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -784,7 +851,7 @@ func (x *Vector) String() string { func (*Vector) ProtoMessage() {} func (x *Vector) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[12] + mi := &file_rove_rove_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -797,7 +864,7 @@ func (x *Vector) ProtoReflect() protoreflect.Message { // Deprecated: Use Vector.ProtoReflect.Descriptor instead. func (*Vector) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{12} + return file_rove_rove_proto_rawDescGZIP(), []int{13} } func (x *Vector) GetX() int32 { @@ -826,7 +893,7 @@ type Account struct { func (x *Account) Reset() { *x = Account{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[13] + mi := &file_rove_rove_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -839,7 +906,7 @@ func (x *Account) String() string { func (*Account) ProtoMessage() {} func (x *Account) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[13] + mi := &file_rove_rove_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -852,7 +919,7 @@ func (x *Account) ProtoReflect() protoreflect.Message { // Deprecated: Use Account.ProtoReflect.Descriptor instead. func (*Account) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{13} + return file_rove_rove_proto_rawDescGZIP(), []int{14} } func (x *Account) GetName() string { @@ -875,110 +942,119 @@ var file_rove_rove_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x72, 0x6f, 0x76, 0x65, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3d, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x65, - 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x65, 0x61, - 0x72, 0x69, 0x6e, 0x67, 0x22, 0x64, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, - 0x29, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x0a, - 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x37, 0x0a, 0x0c, - 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, - 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x55, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, - 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x69, 0x6c, - 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x25, 0x0a, 0x0f, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x22, 0x3b, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3d, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x62, + 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x65, + 0x61, 0x72, 0x69, 0x6e, 0x67, 0x22, 0x64, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x22, 0x38, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x98, 0x03, 0x0a, 0x0e, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x12, 0x28, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, - 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, - 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, - 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, - 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, - 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, - 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, - 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, - 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, - 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, - 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, - 0x72, 0x67, 0x65, 0x12, 0x39, 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, - 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x35, - 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, - 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x15, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa1, 0x01, 0x0a, - 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, - 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, - 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, - 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, - 0x69, 0x63, 0x6b, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, - 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0x35, 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x32, 0x91, 0x03, - 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x5d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x16, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2d, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, - 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, - 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4b, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x12, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x13, - 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x22, 0x08, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, - 0x72, 0x61, 0x64, 0x61, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x47, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x12, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x0c, 0x22, 0x07, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x3a, 0x01, - 0x2a, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, - 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x29, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, + 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x37, 0x0a, + 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, + 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x55, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x14, 0x0a, + 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x69, + 0x6c, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x25, 0x0a, + 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3b, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x22, 0x38, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x49, 0x0a, 0x03, 0x4c, + 0x6f, 0x67, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, + 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0xb7, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, + 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, + 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, + 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, + 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, + 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, + 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, + 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, + 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, + 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, + 0x39, 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, + 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x35, 0x0a, 0x0e, 0x71, 0x75, + 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0b, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x73, 0x12, 0x1d, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x09, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, + 0x22, 0x15, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa1, 0x01, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, + 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, + 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x12, 0x20, 0x0a, 0x0b, + 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x1b, + 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x22, 0x24, 0x0a, 0x06, 0x56, + 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, + 0x79, 0x22, 0x35, 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x32, 0x91, 0x03, 0x0a, 0x04, 0x52, 0x6f, 0x76, + 0x65, 0x12, 0x5d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, + 0x12, 0x0e, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x12, 0x4f, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, + 0x2a, 0x12, 0x4b, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x14, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, + 0x0d, 0x22, 0x08, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x3a, 0x01, 0x2a, 0x12, 0x43, + 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, + 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, 0x72, + 0x3a, 0x01, 0x2a, 0x12, 0x47, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x12, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0c, + 0x22, 0x07, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, + 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -993,7 +1069,7 @@ func file_rove_rove_proto_rawDescGZIP() []byte { return file_rove_rove_proto_rawDescData } -var file_rove_rove_proto_msgTypes = make([]protoimpl.MessageInfo, 14) +var file_rove_rove_proto_msgTypes = make([]protoimpl.MessageInfo, 15) var file_rove_rove_proto_goTypes = []interface{}{ (*Command)(nil), // 0: rove.Command (*CommandRequest)(nil), // 1: rove.CommandRequest @@ -1004,36 +1080,40 @@ var file_rove_rove_proto_goTypes = []interface{}{ (*RegisterRequest)(nil), // 6: rove.RegisterRequest (*RegisterResponse)(nil), // 7: rove.RegisterResponse (*StatusRequest)(nil), // 8: rove.StatusRequest - (*StatusResponse)(nil), // 9: rove.StatusResponse - (*ServerStatusRequest)(nil), // 10: rove.ServerStatusRequest - (*ServerStatusResponse)(nil), // 11: rove.ServerStatusResponse - (*Vector)(nil), // 12: rove.Vector - (*Account)(nil), // 13: rove.Account + (*Log)(nil), // 9: rove.Log + (*StatusResponse)(nil), // 10: rove.StatusResponse + (*ServerStatusRequest)(nil), // 11: rove.ServerStatusRequest + (*ServerStatusResponse)(nil), // 12: rove.ServerStatusResponse + (*Vector)(nil), // 13: rove.Vector + (*Account)(nil), // 14: rove.Account + (*timestamp.Timestamp)(nil), // 15: google.protobuf.Timestamp } var file_rove_rove_proto_depIdxs = []int32{ - 13, // 0: rove.CommandRequest.account:type_name -> rove.Account + 14, // 0: rove.CommandRequest.account:type_name -> rove.Account 0, // 1: rove.CommandRequest.commands:type_name -> rove.Command - 13, // 2: rove.RadarRequest.account:type_name -> rove.Account - 13, // 3: rove.RegisterResponse.account:type_name -> rove.Account - 13, // 4: rove.StatusRequest.account:type_name -> rove.Account - 12, // 5: rove.StatusResponse.position:type_name -> rove.Vector - 0, // 6: rove.StatusResponse.incomingCommands:type_name -> rove.Command - 0, // 7: rove.StatusResponse.queuedCommands:type_name -> rove.Command - 10, // 8: rove.Rove.ServerStatus:input_type -> rove.ServerStatusRequest - 6, // 9: rove.Rove.Register:input_type -> rove.RegisterRequest - 1, // 10: rove.Rove.Command:input_type -> rove.CommandRequest - 4, // 11: rove.Rove.Radar:input_type -> rove.RadarRequest - 8, // 12: rove.Rove.Status:input_type -> rove.StatusRequest - 11, // 13: rove.Rove.ServerStatus:output_type -> rove.ServerStatusResponse - 7, // 14: rove.Rove.Register:output_type -> rove.RegisterResponse - 2, // 15: rove.Rove.Command:output_type -> rove.CommandResponse - 5, // 16: rove.Rove.Radar:output_type -> rove.RadarResponse - 9, // 17: rove.Rove.Status:output_type -> rove.StatusResponse - 13, // [13:18] is the sub-list for method output_type - 8, // [8:13] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name + 14, // 2: rove.RadarRequest.account:type_name -> rove.Account + 14, // 3: rove.RegisterResponse.account:type_name -> rove.Account + 14, // 4: rove.StatusRequest.account:type_name -> rove.Account + 15, // 5: rove.Log.time:type_name -> google.protobuf.Timestamp + 13, // 6: rove.StatusResponse.position:type_name -> rove.Vector + 0, // 7: rove.StatusResponse.incomingCommands:type_name -> rove.Command + 0, // 8: rove.StatusResponse.queuedCommands:type_name -> rove.Command + 9, // 9: rove.StatusResponse.logs:type_name -> rove.Log + 11, // 10: rove.Rove.ServerStatus:input_type -> rove.ServerStatusRequest + 6, // 11: rove.Rove.Register:input_type -> rove.RegisterRequest + 1, // 12: rove.Rove.Command:input_type -> rove.CommandRequest + 4, // 13: rove.Rove.Radar:input_type -> rove.RadarRequest + 8, // 14: rove.Rove.Status:input_type -> rove.StatusRequest + 12, // 15: rove.Rove.ServerStatus:output_type -> rove.ServerStatusResponse + 7, // 16: rove.Rove.Register:output_type -> rove.RegisterResponse + 2, // 17: rove.Rove.Command:output_type -> rove.CommandResponse + 5, // 18: rove.Rove.Radar:output_type -> rove.RadarResponse + 10, // 19: rove.Rove.Status:output_type -> rove.StatusResponse + 15, // [15:20] is the sub-list for method output_type + 10, // [10:15] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_rove_rove_proto_init() } @@ -1151,7 +1231,7 @@ func file_rove_rove_proto_init() { } } file_rove_rove_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StatusResponse); i { + switch v := v.(*Log); i { case 0: return &v.state case 1: @@ -1163,7 +1243,7 @@ func file_rove_rove_proto_init() { } } file_rove_rove_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ServerStatusRequest); i { + switch v := v.(*StatusResponse); i { case 0: return &v.state case 1: @@ -1175,7 +1255,7 @@ func file_rove_rove_proto_init() { } } file_rove_rove_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ServerStatusResponse); i { + switch v := v.(*ServerStatusRequest); i { case 0: return &v.state case 1: @@ -1187,7 +1267,7 @@ func file_rove_rove_proto_init() { } } file_rove_rove_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Vector); i { + switch v := v.(*ServerStatusResponse); i { case 0: return &v.state case 1: @@ -1199,6 +1279,18 @@ func file_rove_rove_proto_init() { } } file_rove_rove_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Vector); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rove_rove_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Account); i { case 0: return &v.state @@ -1217,7 +1309,7 @@ func file_rove_rove_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_rove_rove_proto_rawDesc, NumEnums: 0, - NumMessages: 14, + NumMessages: 15, NumExtensions: 0, NumServices: 1, }, diff --git a/pkg/rove/rove.swagger.json b/pkg/rove/rove.swagger.json index 392817a..5cb3734 100644 --- a/pkg/rove/rove.swagger.json +++ b/pkg/rove/rove.swagger.json @@ -251,6 +251,20 @@ "type": "object", "title": "Empty placeholder" }, + "roveLog": { + "type": "object", + "properties": { + "time": { + "type": "string", + "format": "date-time", + "title": "The timestamp of the log" + }, + "text": { + "type": "string", + "title": "The text of the log" + } + } + }, "roveRadarRequest": { "type": "object", "properties": { @@ -395,6 +409,13 @@ "$ref": "#/definitions/roveCommand" }, "title": "The set of currently queued commands" + }, + "logs": { + "type": "array", + "items": { + "$ref": "#/definitions/roveLog" + }, + "title": "The most recent logs" } } }, diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index 6882d40..74eb69e 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -8,6 +8,7 @@ package rove; option go_package = "github.com/mdiluz/rove/pkg/rove"; import "google/api/annotations.proto"; +import "google/protobuf/timestamp.proto"; service Rove { // Server status @@ -120,6 +121,14 @@ message StatusRequest { Account account = 1; } +message Log { + // The timestamp of the log + google.protobuf.Timestamp time = 1; + + // The text of the log + string text = 2; +} + message StatusResponse { // The name of the rover string name = 1; @@ -153,6 +162,9 @@ message StatusResponse { // The set of currently queued commands repeated Command queuedCommands = 11; + + // The most recent logs + repeated Log logs = 12; } // Empty placeholder From b748846c55c8383cfa3d29e34cea69ea0c33ba95 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 9 Jul 2020 19:29:04 +0100 Subject: [PATCH 087/228] Use a unix timestamp rather than a timestamppb --- cmd/rove-server/internal/routes.go | 3 +- pkg/rove/rove.pb.go | 265 ++++++++++++++--------------- pkg/rove/rove.swagger.json | 4 +- proto/rove/rove.proto | 5 +- 4 files changed, 134 insertions(+), 143 deletions(-) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index e3f280d..1079a9d 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -8,7 +8,6 @@ import ( "github.com/mdiluz/rove/pkg/game" "github.com/mdiluz/rove/pkg/rove" "github.com/mdiluz/rove/pkg/version" - "google.golang.org/protobuf/types/known/timestamppb" ) // ServerStatus returns the status of the current server to a gRPC request @@ -95,7 +94,7 @@ func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (response for _, log := range rover.Logs { logs = append(logs, &rove.Log{ Text: log.Text, - Time: timestamppb.New(log.Time), + Time: log.Time.Unix(), }) } diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index b73e07b..eeaeba6 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -13,7 +13,6 @@ package rove import ( context "context" proto "github.com/golang/protobuf/proto" - timestamp "github.com/golang/protobuf/ptypes/timestamp" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -504,8 +503,8 @@ type Log struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The timestamp of the log - Time *timestamp.Timestamp `protobuf:"bytes,1,opt,name=time,proto3" json:"time,omitempty"` + // The unix timestamp of the log + Time int64 `protobuf:"varint,1,opt,name=time,proto3" json:"time,omitempty"` // The text of the log Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"` } @@ -542,11 +541,11 @@ func (*Log) Descriptor() ([]byte, []int) { return file_rove_rove_proto_rawDescGZIP(), []int{9} } -func (x *Log) GetTime() *timestamp.Timestamp { +func (x *Log) GetTime() int64 { if x != nil { return x.Time } - return nil + return 0 } func (x *Log) GetText() string { @@ -942,119 +941,115 @@ var file_rove_rove_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x72, 0x6f, 0x76, 0x65, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3d, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x62, - 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x65, - 0x61, 0x72, 0x69, 0x6e, 0x67, 0x22, 0x64, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3d, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x65, + 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x65, 0x61, + 0x72, 0x69, 0x6e, 0x67, 0x22, 0x64, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, + 0x29, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x0a, + 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x37, 0x0a, 0x0c, + 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, + 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x55, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, + 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x69, 0x6c, + 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x25, 0x0a, 0x0f, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x22, 0x3b, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x12, 0x29, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, - 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x37, 0x0a, - 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, - 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x55, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x14, 0x0a, - 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x69, - 0x6c, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x25, 0x0a, - 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3b, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x22, 0x38, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x49, 0x0a, 0x03, 0x4c, - 0x6f, 0x67, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, - 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0xb7, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, - 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, - 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, - 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, - 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, - 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, - 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, - 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, - 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, - 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, - 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, - 0x39, 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, - 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x35, 0x0a, 0x0e, 0x71, 0x75, - 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0b, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x73, 0x12, 0x1d, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x09, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, - 0x22, 0x15, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa1, 0x01, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, - 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, - 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x12, 0x20, 0x0a, 0x0b, - 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x1b, - 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x22, 0x24, 0x0a, 0x06, 0x56, - 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, - 0x79, 0x22, 0x35, 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, + 0x22, 0x38, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, + 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0xb7, 0x03, 0x0a, 0x0e, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x32, 0x91, 0x03, 0x0a, 0x04, 0x52, 0x6f, 0x76, - 0x65, 0x12, 0x5d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x12, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, - 0x12, 0x0e, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x4f, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, - 0x2a, 0x12, 0x4b, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x14, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x0d, 0x22, 0x08, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x3a, 0x01, 0x2a, 0x12, 0x43, - 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, - 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, 0x72, - 0x3a, 0x01, 0x2a, 0x12, 0x47, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x12, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0c, - 0x22, 0x07, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, - 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x28, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, + 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, + 0x6e, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, + 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, + 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, + 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, + 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, + 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, + 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x08, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, + 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, + 0x67, 0x65, 0x12, 0x39, 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, + 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x35, 0x0a, + 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, + 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x73, 0x12, 0x1d, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x0c, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, + 0x6f, 0x67, 0x73, 0x22, 0x15, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa1, 0x01, 0x0a, 0x14, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, + 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, + 0x61, 0x64, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x12, + 0x20, 0x0a, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, + 0x6b, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x22, 0x24, + 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x01, 0x79, 0x22, 0x35, 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x32, 0x91, 0x03, 0x0a, 0x04, + 0x52, 0x6f, 0x76, 0x65, 0x12, 0x5d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x16, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, + 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, + 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, + 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4b, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, + 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x13, 0x82, 0xd3, + 0xe4, 0x93, 0x02, 0x0d, 0x22, 0x08, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x3a, 0x01, + 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, + 0x64, 0x61, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x47, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x12, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x0c, 0x22, 0x07, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x3a, 0x01, 0x2a, 0x42, + 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, + 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, + 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1086,7 +1081,6 @@ var file_rove_rove_proto_goTypes = []interface{}{ (*ServerStatusResponse)(nil), // 12: rove.ServerStatusResponse (*Vector)(nil), // 13: rove.Vector (*Account)(nil), // 14: rove.Account - (*timestamp.Timestamp)(nil), // 15: google.protobuf.Timestamp } var file_rove_rove_proto_depIdxs = []int32{ 14, // 0: rove.CommandRequest.account:type_name -> rove.Account @@ -1094,26 +1088,25 @@ var file_rove_rove_proto_depIdxs = []int32{ 14, // 2: rove.RadarRequest.account:type_name -> rove.Account 14, // 3: rove.RegisterResponse.account:type_name -> rove.Account 14, // 4: rove.StatusRequest.account:type_name -> rove.Account - 15, // 5: rove.Log.time:type_name -> google.protobuf.Timestamp - 13, // 6: rove.StatusResponse.position:type_name -> rove.Vector - 0, // 7: rove.StatusResponse.incomingCommands:type_name -> rove.Command - 0, // 8: rove.StatusResponse.queuedCommands:type_name -> rove.Command - 9, // 9: rove.StatusResponse.logs:type_name -> rove.Log - 11, // 10: rove.Rove.ServerStatus:input_type -> rove.ServerStatusRequest - 6, // 11: rove.Rove.Register:input_type -> rove.RegisterRequest - 1, // 12: rove.Rove.Command:input_type -> rove.CommandRequest - 4, // 13: rove.Rove.Radar:input_type -> rove.RadarRequest - 8, // 14: rove.Rove.Status:input_type -> rove.StatusRequest - 12, // 15: rove.Rove.ServerStatus:output_type -> rove.ServerStatusResponse - 7, // 16: rove.Rove.Register:output_type -> rove.RegisterResponse - 2, // 17: rove.Rove.Command:output_type -> rove.CommandResponse - 5, // 18: rove.Rove.Radar:output_type -> rove.RadarResponse - 10, // 19: rove.Rove.Status:output_type -> rove.StatusResponse - 15, // [15:20] is the sub-list for method output_type - 10, // [10:15] is the sub-list for method input_type - 10, // [10:10] is the sub-list for extension type_name - 10, // [10:10] is the sub-list for extension extendee - 0, // [0:10] is the sub-list for field type_name + 13, // 5: rove.StatusResponse.position:type_name -> rove.Vector + 0, // 6: rove.StatusResponse.incomingCommands:type_name -> rove.Command + 0, // 7: rove.StatusResponse.queuedCommands:type_name -> rove.Command + 9, // 8: rove.StatusResponse.logs:type_name -> rove.Log + 11, // 9: rove.Rove.ServerStatus:input_type -> rove.ServerStatusRequest + 6, // 10: rove.Rove.Register:input_type -> rove.RegisterRequest + 1, // 11: rove.Rove.Command:input_type -> rove.CommandRequest + 4, // 12: rove.Rove.Radar:input_type -> rove.RadarRequest + 8, // 13: rove.Rove.Status:input_type -> rove.StatusRequest + 12, // 14: rove.Rove.ServerStatus:output_type -> rove.ServerStatusResponse + 7, // 15: rove.Rove.Register:output_type -> rove.RegisterResponse + 2, // 16: rove.Rove.Command:output_type -> rove.CommandResponse + 5, // 17: rove.Rove.Radar:output_type -> rove.RadarResponse + 10, // 18: rove.Rove.Status:output_type -> rove.StatusResponse + 14, // [14:19] is the sub-list for method output_type + 9, // [9:14] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name } func init() { file_rove_rove_proto_init() } diff --git a/pkg/rove/rove.swagger.json b/pkg/rove/rove.swagger.json index 5cb3734..a28fee0 100644 --- a/pkg/rove/rove.swagger.json +++ b/pkg/rove/rove.swagger.json @@ -256,8 +256,8 @@ "properties": { "time": { "type": "string", - "format": "date-time", - "title": "The timestamp of the log" + "format": "int64", + "title": "The unix timestamp of the log" }, "text": { "type": "string", diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index 74eb69e..c49e2d8 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -8,7 +8,6 @@ package rove; option go_package = "github.com/mdiluz/rove/pkg/rove"; import "google/api/annotations.proto"; -import "google/protobuf/timestamp.proto"; service Rove { // Server status @@ -122,8 +121,8 @@ message StatusRequest { } message Log { - // The timestamp of the log - google.protobuf.Timestamp time = 1; + // The unix timestamp of the log + int64 time = 1; // The text of the log string text = 2; From 30ca488890d75802e10336f61b7a811e38473b16 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 9 Jul 2020 19:38:23 +0100 Subject: [PATCH 088/228] Use string for the timestamp, proto uses this under the hood anyway https://github.com/grpc-ecosystem/grpc-gateway/issues/438 --- cmd/rove-server/internal/routes.go | 2 +- pkg/rove/rove.pb.go | 8 ++++---- pkg/rove/rove.swagger.json | 1 - proto/rove/rove.proto | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 1079a9d..5236a52 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -94,7 +94,7 @@ func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (response for _, log := range rover.Logs { logs = append(logs, &rove.Log{ Text: log.Text, - Time: log.Time.Unix(), + Time: fmt.Sprintf("%d", log.Time.Unix()), // proto uses strings under the hood for 64bit ints anyway }) } diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index eeaeba6..e38875d 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -504,7 +504,7 @@ type Log struct { unknownFields protoimpl.UnknownFields // The unix timestamp of the log - Time int64 `protobuf:"varint,1,opt,name=time,proto3" json:"time,omitempty"` + Time string `protobuf:"bytes,1,opt,name=time,proto3" json:"time,omitempty"` // The text of the log Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"` } @@ -541,11 +541,11 @@ func (*Log) Descriptor() ([]byte, []int) { return file_rove_rove_proto_rawDescGZIP(), []int{9} } -func (x *Log) GetTime() int64 { +func (x *Log) GetTime() string { if x != nil { return x.Time } - return 0 + return "" } func (x *Log) GetText() string { @@ -974,7 +974,7 @@ var file_rove_rove_proto_rawDesc = []byte{ 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, - 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0xb7, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, diff --git a/pkg/rove/rove.swagger.json b/pkg/rove/rove.swagger.json index a28fee0..5575c89 100644 --- a/pkg/rove/rove.swagger.json +++ b/pkg/rove/rove.swagger.json @@ -256,7 +256,6 @@ "properties": { "time": { "type": "string", - "format": "int64", "title": "The unix timestamp of the log" }, "text": { diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index c49e2d8..70b766c 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -122,7 +122,7 @@ message StatusRequest { message Log { // The unix timestamp of the log - int64 time = 1; + string time = 1; // The text of the log string text = 2; From d4d82c38e08057f6e43b409392b4451100248a71 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 9 Jul 2020 22:05:12 +0100 Subject: [PATCH 089/228] Add "broadcast" command This will send a readable ascii triplet to all rovers in range --- pkg/game/command.go | 6 +++++ pkg/game/world.go | 47 +++++++++++++++++++++++++++++++++ pkg/game/world_test.go | 60 ++++++++++++++++++++++++++++++++++++++++++ proto/rove/rove.proto | 9 +++++-- 4 files changed, 120 insertions(+), 2 deletions(-) diff --git a/pkg/game/command.go b/pkg/game/command.go index 11428c3..96f95d8 100644 --- a/pkg/game/command.go +++ b/pkg/game/command.go @@ -12,6 +12,9 @@ const ( // CommandRecharge Will use one tick to charge the rover CommandRecharge = "recharge" + + // CommandBroadcast will broadcast a message to nearby rovers within range + CommandBroadcast = "broadcast" ) // Command represends a single command to execute @@ -20,6 +23,9 @@ type Command struct { // Used in the move command Bearing string `json:"bearing,omitempty"` + + // Used in the broadcast command + Message []byte `json:"message,omitempty"` } // CommandStream is a list of commands to execute in order diff --git a/pkg/game/world.go b/pkg/game/world.go index bd6d806..a48bea0 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -168,6 +168,40 @@ func (w *World) RoverRecharge(rover string) (int, error) { return i.Charge, nil } +// RoverBroadcast broadcasts a message to nearby rovers +func (w *World) RoverBroadcast(rover string, message []byte) (err error) { + w.worldMutex.Lock() + defer w.worldMutex.Unlock() + + i, ok := w.Rovers[rover] + if !ok { + return fmt.Errorf("Failed to find rover with name: %s", rover) + } + + // Use up a charge as needed, if available + if i.Charge == 0 { + return + } + i.Charge-- + + // Check all rovers + for r, rover := range w.Rovers { + if rover.Name == i.Name { + continue + } + + // Check if this rover is within range + if i.Pos.Distance(rover.Pos) < float64(i.Range) { + rover.AddLogEntryf("recieved %s from %s", string(message), i.Name) + w.Rovers[r] = rover + } + } + + i.AddLogEntryf("broadcasted %s", string(message)) + w.Rovers[rover] = i + return +} + // DestroyRover Removes an rover from the game func (w *World) DestroyRover(rover string) error { w.worldMutex.Lock() @@ -399,6 +433,15 @@ func (w *World) Enqueue(rover string, commands ...Command) error { if _, err := bearing.FromString(c.Bearing); err != nil { return fmt.Errorf("unknown bearing: %s", c.Bearing) } + case CommandBroadcast: + if len(c.Message) > 3 { + return fmt.Errorf("too many characters in message (limit 3): %d", len(c.Message)) + } + for _, b := range c.Message { + if b < 37 || b > 126 { + return fmt.Errorf("invalid message character: %c", b) + } + } case CommandStash: case CommandRepair: case CommandRecharge: @@ -494,6 +537,10 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { if err != nil { return err } + case CommandBroadcast: + if err := w.RoverBroadcast(rover, c.Message); err != nil { + return err + } default: return fmt.Errorf("unknown command: %s", c.Command) } diff --git a/pkg/game/world_test.go b/pkg/game/world_test.go index c67588a..c9654c5 100644 --- a/pkg/game/world_test.go +++ b/pkg/game/world_test.go @@ -365,3 +365,63 @@ func TestWorld_Daytime(t *testing.T) { world.ExecuteCommandQueues() } } + +func TestWorld_Broadcast(t *testing.T) { + world := NewWorld(8) + + a, err := world.SpawnRover() + assert.NoError(t, err) + + b, err := world.SpawnRover() + assert.NoError(t, err) + + // Warp rovers near to eachother + assert.NoError(t, world.WarpRover(a, vector.Vector{X: 0, Y: 0})) + assert.NoError(t, world.WarpRover(b, vector.Vector{X: 1, Y: 0})) + + // Broadcast from a + assert.NoError(t, world.RoverBroadcast(a, []byte{'A', 'B', 'C'})) + + // Check if b heard it + ra, err := world.GetRover(a) + assert.NoError(t, err) + assert.Equal(t, ra.MaximumCharge-1, ra.Charge, "A should have used a charge to broadcast") + assert.Contains(t, ra.Logs[len(ra.Logs)-1].Text, "ABC", "Rover B should have heard the broadcast") + + // Check if a logged it + rb, err := world.GetRover(b) + assert.NoError(t, err) + assert.Contains(t, rb.Logs[len(rb.Logs)-1].Text, "ABC", "Rover A should have logged it's broadcast") + + // Warp B outside of the range of A + assert.NoError(t, world.WarpRover(b, vector.Vector{X: ra.Range, Y: 0})) + + // Broadcast from a again + assert.NoError(t, world.RoverBroadcast(a, []byte{'X', 'Y', 'Z'})) + + // Check if b heard it + ra, err = world.GetRover(b) + assert.NoError(t, err) + assert.NotContains(t, ra.Logs[len(ra.Logs)-1].Text, "XYZ", "Rover B should not have heard the broadcast") + + // Check if a logged it + rb, err = world.GetRover(a) + assert.NoError(t, err) + assert.Contains(t, rb.Logs[len(rb.Logs)-1].Text, "XYZ", "Rover A should have logged it's broadcast") + + // Warp B outside of the range of A + assert.NoError(t, world.WarpRover(b, vector.Vector{X: ra.Range + 1, Y: 0})) + + // Broadcast from a again + assert.NoError(t, world.RoverBroadcast(a, []byte{'H', 'J', 'K'})) + + // Check if b heard it + ra, err = world.GetRover(b) + assert.NoError(t, err) + assert.NotContains(t, ra.Logs[len(ra.Logs)-1].Text, "HJK", "Rover B should have heard the broadcast") + + // Check if a logged it + rb, err = world.GetRover(a) + assert.NoError(t, err) + assert.Contains(t, rb.Logs[len(rb.Logs)-1].Text, "HJK", "Rover A should have logged it's broadcast") +} diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index 70b766c..d643e9c 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -66,10 +66,15 @@ message Command { // "stash" - Stashes item at current location in rover inventory // "repair" - Repairs the rover using an inventory object // "recharge" - Waits a tick to add more charge to the rover + // "broadcast" - Broadcasts a message to nearby rovers string command = 1; - // The bearing, example: NE + // A bearing, example: NE string bearing = 2; + + // A simple message, must be composed of printable ASCII glyphs (32-126) + // maximum of three characters + bytes message = 3; } message CommandRequest { @@ -135,7 +140,7 @@ message StatusResponse { // Position of the rover in world coordinates Vector position = 2; - // The range of this rover's radar + // The range of this rover's radar and broadcasting int32 range = 3; // The items in the rover inventory From e21023ec250b82e569c69dd0fe704c4e1828389d Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 9 Jul 2020 22:12:13 +0100 Subject: [PATCH 090/228] Update generated files --- pkg/rove/rove.pb.go | 223 ++++++++++++++++++++----------------- pkg/rove/rove.swagger.json | 11 +- 2 files changed, 126 insertions(+), 108 deletions(-) diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index e38875d..19fa01d 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -44,9 +44,13 @@ type Command struct { // "stash" - Stashes item at current location in rover inventory // "repair" - Repairs the rover using an inventory object // "recharge" - Waits a tick to add more charge to the rover + // "broadcast" - Broadcasts a message to nearby rovers Command string `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"` - // The bearing, example: NE + // A bearing, example: NE Bearing string `protobuf:"bytes,2,opt,name=bearing,proto3" json:"bearing,omitempty"` + // A simple message, must be composed of printable ASCII glyphs (32-126) + // maximum of three characters + Message []byte `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` } func (x *Command) Reset() { @@ -95,6 +99,13 @@ func (x *Command) GetBearing() string { return "" } +func (x *Command) GetMessage() []byte { + if x != nil { + return x.Message + } + return nil +} + type CommandRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -564,7 +575,7 @@ type StatusResponse struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // Position of the rover in world coordinates Position *Vector `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` - // The range of this rover's radar + // The range of this rover's radar and broadcasting Range int32 `protobuf:"varint,3,opt,name=range,proto3" json:"range,omitempty"` // The items in the rover inventory Inventory []byte `protobuf:"bytes,4,opt,name=inventory,proto3" json:"inventory,omitempty"` @@ -941,115 +952,117 @@ var file_rove_rove_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x72, 0x6f, 0x76, 0x65, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3d, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x57, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x65, 0x61, - 0x72, 0x69, 0x6e, 0x67, 0x22, 0x64, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, + 0x72, 0x69, 0x6e, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x64, + 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x29, 0x0a, 0x08, 0x63, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, + 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x37, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, - 0x29, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x0a, - 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x37, 0x0a, 0x0c, - 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, - 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x55, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, - 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x69, 0x6c, - 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x25, 0x0a, 0x0f, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x22, 0x3b, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, - 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x22, 0x38, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, + 0x55, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, + 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x25, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3b, 0x0a, + 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, - 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0xb7, 0x03, 0x0a, 0x0e, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x28, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, - 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, - 0x6e, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, - 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, - 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, - 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, - 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, - 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, - 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x08, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, - 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, - 0x67, 0x65, 0x12, 0x39, 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, - 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x35, 0x0a, - 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, - 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x73, 0x12, 0x1d, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x0c, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, - 0x6f, 0x67, 0x73, 0x22, 0x15, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa1, 0x01, 0x0a, 0x14, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, - 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, - 0x61, 0x64, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x12, - 0x20, 0x0a, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, - 0x6b, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x22, 0x24, - 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x01, 0x79, 0x22, 0x35, 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x32, 0x91, 0x03, 0x0a, 0x04, - 0x52, 0x6f, 0x76, 0x65, 0x12, 0x5d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x16, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, - 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, - 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, - 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4b, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, - 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x13, 0x82, 0xd3, - 0xe4, 0x93, 0x02, 0x0d, 0x22, 0x08, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x3a, 0x01, - 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, - 0x64, 0x61, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x47, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x12, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x0c, 0x22, 0x07, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x3a, 0x01, 0x2a, 0x42, - 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, - 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, - 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x38, 0x0a, 0x0d, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, + 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, + 0x65, 0x78, 0x74, 0x22, 0xb7, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, + 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, + 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, + 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, + 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, + 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, + 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, + 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, + 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, + 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, + 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, + 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, + 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x39, 0x0a, 0x10, + 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, + 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x35, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, + 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, + 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x1d, + 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x22, 0x15, 0x0a, + 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x22, 0xa1, 0x01, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x1a, 0x0a, + 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x75, 0x72, + 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, + 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x1b, 0x0a, 0x09, 0x6e, + 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, + 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, + 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0x35, + 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, + 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, + 0x65, 0x63, 0x72, 0x65, 0x74, 0x32, 0x91, 0x03, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x5d, + 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, + 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, + 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, + 0x22, 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4b, + 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x22, 0x08, + 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, + 0x61, 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, + 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, + 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, + 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, 0x72, 0x3a, 0x01, 0x2a, + 0x12, 0x47, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x12, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0c, 0x22, 0x07, 0x2f, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, + 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/rove/rove.swagger.json b/pkg/rove/rove.swagger.json index 5575c89..e4dcbee 100644 --- a/pkg/rove/rove.swagger.json +++ b/pkg/rove/rove.swagger.json @@ -223,11 +223,16 @@ "properties": { "command": { "type": "string", - "title": "The command to execute\n\"move\" - Move the rover in a direction, requires bearing\n\"stash\" - Stashes item at current location in rover inventory\n\"repair\" - Repairs the rover using an inventory object\n\"recharge\" - Waits a tick to add more charge to the rover" + "title": "The command to execute\n\"move\" - Move the rover in a direction, requires bearing\n\"stash\" - Stashes item at current location in rover inventory\n\"repair\" - Repairs the rover using an inventory object\n\"recharge\" - Waits a tick to add more charge to the rover\n\"broadcast\" - Broadcasts a message to nearby rovers" }, "bearing": { "type": "string", - "title": "The bearing, example: NE" + "title": "A bearing, example: NE" + }, + "message": { + "type": "string", + "format": "byte", + "title": "A simple message, must be composed of printable ASCII glyphs (32-126)\nmaximum of three characters" } } }, @@ -363,7 +368,7 @@ "range": { "type": "integer", "format": "int32", - "title": "The range of this rover's radar" + "title": "The range of this rover's radar and broadcasting" }, "inventory": { "type": "string", From 091469dd91d263483f2c3c12d5fd4693c72b40a8 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 9 Jul 2020 22:37:55 +0100 Subject: [PATCH 091/228] Add broadcast command to the cmdline client --- cmd/rove/main.go | 14 ++++++++++++++ cmd/rove/main_test.go | 2 ++ 2 files changed, 16 insertions(+) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 80fe702..059052d 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -40,6 +40,7 @@ func printUsage() { fmt.Fprintln(os.Stderr, "\tstash stores the object at the rover location in the inventory") fmt.Fprintln(os.Stderr, "\trepair uses an inventory object to repair the rover") fmt.Fprintln(os.Stderr, "\trecharge wait a tick to recharge the rover") + fmt.Fprintln(os.Stderr, "\tbroadcast MSG broadcast a simple ASCII triplet to nearby rovers") fmt.Fprintln(os.Stderr, "\nEnvironment") fmt.Fprintln(os.Stderr, "\tROVE_USER_DATA path to user data, defaults to "+defaultDataPath) } @@ -225,6 +226,19 @@ func InnerMain(command string, args ...string) error { Bearing: args[i], }, ) + case "broadcast": + i++ + if len(args) == i { + return fmt.Errorf("broadcast command must be passed an ASCII triplet") + } else if len(args[i]) > 3 { + return fmt.Errorf("broadcast command must be given ASCII triplet of 3 or less: %s", args[i]) + } + commands = append(commands, + &rove.Command{ + Command: game.CommandBroadcast, + Message: []byte(args[i]), + }, + ) default: // By default just use the command literally commands = append(commands, diff --git a/cmd/rove/main_test.go b/cmd/rove/main_test.go index 6f90fcd..dd588e1 100644 --- a/cmd/rove/main_test.go +++ b/cmd/rove/main_test.go @@ -53,7 +53,9 @@ func Test_InnerMain(t *testing.T) { assert.NoError(t, InnerMain("command", "move", "N")) assert.NoError(t, InnerMain("command", "stash")) assert.NoError(t, InnerMain("command", "repair")) + assert.NoError(t, InnerMain("command", "broadcast", "abc")) // Give it malformed commands assert.Error(t, InnerMain("command", "move", "stash")) + assert.Error(t, InnerMain("command", "broadcast")) } From b032fdbfe2938d5b2d59c3d307ec8bc0e31ccaff Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 9 Jul 2020 22:52:58 +0100 Subject: [PATCH 092/228] Fix missing broadcast message in status reply --- cmd/rove-server/internal/routes.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 5236a52..702d227 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -82,12 +82,14 @@ func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (response incoming = append(incoming, &rove.Command{ Command: i.Command, Bearing: i.Bearing, + Message: i.Message, }) } for _, q := range q { queued = append(queued, &rove.Command{ Command: q.Command, Bearing: q.Bearing, + Message: q.Message, }) } var logs []*rove.Log From 59a1bdc14bd31b249c24db54a4fba08ed3415ba4 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 9 Jul 2020 23:15:33 +0100 Subject: [PATCH 093/228] Update launch.json Remove old comments --- .vscode/launch.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 539f842..57d654f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,7 +1,4 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { @@ -27,4 +24,4 @@ "args": ["radar"], } ] -} \ No newline at end of file +} From 7d780d05bd75f48b41bc0d0f69c6181eed34ee09 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 00:12:35 +0100 Subject: [PATCH 094/228] De-scope - remove swagger docs and http proxy HTTP proxy was becoming annoying to maintain, and gRPC is easier to use anyway swagger docs are just part of the fallout --- Dockerfile | 1 - Makefile | 2 -- docker-compose.yml | 28 ++-------------------------- snap/snapcraft.yaml | 10 +--------- 4 files changed, 3 insertions(+), 38 deletions(-) diff --git a/Dockerfile b/Dockerfile index f5a1f4b..74b87c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,6 @@ RUN go mod download # Build the executables RUN go build -o rove -ldflags="-X 'github.com/mdiluz/rove/pkg/version.Version=$(git describe --always --long --dirty --tags)'" cmd/rove/main.go RUN go build -o rove-server -ldflags="-X 'github.com/mdiluz/rove/pkg/version.Version=$(git describe --always --long --dirty --tags)'" cmd/rove-server/main.go -RUN go build -o rove-server-rest-proxy cmd/rove-server-rest-proxy/main.go CMD [ "./rove-server" ] diff --git a/Makefile b/Makefile index cf7f33b..0ef8cd7 100644 --- a/Makefile +++ b/Makefile @@ -20,8 +20,6 @@ gen: @echo Generating rove server gRPC and gateway protoc --proto_path proto --go_out=plugins=grpc,paths=source_relative:pkg/ proto/rove/rove.proto protoc --proto_path proto --grpc-gateway_out=paths=source_relative:pkg/ proto/rove/rove.proto - @echo Generating rove server swagger - protoc --proto_path proto --swagger_out=logtostderr=true:pkg/ proto/rove/rove.proto test: @echo Unit tests diff --git a/docker-compose.yml b/docker-compose.yml index 7109118..71013b5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,16 +4,6 @@ volumes: persistent-data: services: - rove-docs: - build: - context: . - dockerfile: Dockerfile.docs - image: rove-docs:latest - ports: - - "80:80" - environment: - - PORT=80 - rove-server: build: context: . @@ -30,29 +20,15 @@ services: - persistent-data:/mnt/rove-server:rw command: [ "./rove-server"] - rove: - depends_on: [ rove-server, rove-docs ] - build: - context: . - dockerfile: Dockerfile - image: rove:latest - ports: - - "8080:8080" - environment: - - PORT=8080 - - ROVE_GRPC=rove-server:9090 - command: [ "./script/wait-for-it.sh", "rove-server:9090", "--", "./rove-server-rest-proxy" ] - rove-tests: - depends_on: [ rove ] + depends_on: [ rove-server ] build: context: . dockerfile: Dockerfile image: rove:latest environment: - - ROVE_HTTP=rove - ROVE_GRPC=rove-server - command: [ "./script/wait-for-it.sh", "rove:8080", "--", "go", "test", "-v", "./...", "--tags=integration", "-cover", "-coverprofile=/mnt/coverage-data/c.out", "-count", "1" ] + command: [ "./script/wait-for-it.sh", "rove-server:9090", "--", "go", "test", "-v", "./...", "--tags=integration", "-cover", "-coverprofile=/mnt/coverage-data/c.out", "-count", "1" ] volumes: - /tmp/coverage-data:/mnt/coverage-data:rw diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index fb83f33..86a2118 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -27,15 +27,7 @@ apps: environment: WORDS_FILE : "$SNAP/data/words_alpha.txt" DATA_PATH : $SNAP_USER_DATA - - rove-rest-server: - command: bin/rove-server-rest-proxy - plugs: - - network - - network-bind - environment: - DATA_PATH : $SNAP_USER_DATA - + parts: go-rove: plugin: go From 96a137ad2f39a255d93eba1541515fa4134eb207 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 00:12:54 +0100 Subject: [PATCH 095/228] Simplify - remove duplicate command types in favor of a better defined Command type in proto --- cmd/rove-server/internal/routes.go | 47 +++- cmd/rove/main.go | 11 +- pkg/game/command.go | 19 +- pkg/game/command_test.go | 7 +- pkg/game/world.go | 21 +- pkg/game/world_test.go | 5 +- pkg/rove/rove.pb.go | 429 +++++++++++++++++------------ pkg/rove/rove.swagger.json | 227 ++------------- proto/rove/rove.proto | 75 +++-- 9 files changed, 370 insertions(+), 471 deletions(-) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 702d227..e533cbf 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -79,18 +79,36 @@ func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (response i, q := s.world.RoverCommands(resp) var incoming, queued []*rove.Command for _, i := range i { - incoming = append(incoming, &rove.Command{ + c := &rove.Command{ Command: i.Command, - Bearing: i.Bearing, - Message: i.Message, - }) + } + switch i.Command { + case rove.CommandType_move: + c.Data = &rove.Command_Bearing{ + Bearing: i.Bearing, + } + case rove.CommandType_broadcast: + c.Data = &rove.Command_Message{ + Message: i.Message, + } + } + incoming = append(incoming, c) } for _, q := range q { - queued = append(queued, &rove.Command{ + c := &rove.Command{ Command: q.Command, - Bearing: q.Bearing, - Message: q.Message, - }) + } + switch q.Command { + case rove.CommandType_move: + c.Data = &rove.Command_Bearing{ + Bearing: q.Bearing, + } + case rove.CommandType_broadcast: + c.Data = &rove.Command_Message{ + Message: q.Message, + } + } + queued = append(queued, c) } var logs []*rove.Log for _, log := range rover.Logs { @@ -171,9 +189,16 @@ func (s *Server) Command(ctx context.Context, req *rove.CommandRequest) (*rove.C var cmds []game.Command for _, c := range req.Commands { - cmds = append(cmds, game.Command{ - Bearing: c.Bearing, - Command: c.Command}) + n := game.Command{ + Command: c.Command, + } + switch c.Command { + case rove.CommandType_move: + n.Bearing = c.GetBearing() + case rove.CommandType_broadcast: + n.Message = c.GetMessage() + } + cmds = append(cmds, n) } if err := s.world.Enqueue(resp, cmds...); err != nil { diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 059052d..5f51e32 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -12,7 +12,6 @@ import ( "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/bearing" - "github.com/mdiluz/rove/pkg/game" "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/rove" "github.com/mdiluz/rove/pkg/version" @@ -222,8 +221,8 @@ func InnerMain(command string, args ...string) error { } commands = append(commands, &rove.Command{ - Command: game.CommandMove, - Bearing: args[i], + Command: rove.CommandType_move, + Data: &rove.Command_Bearing{Bearing: args[i]}, }, ) case "broadcast": @@ -235,15 +234,15 @@ func InnerMain(command string, args ...string) error { } commands = append(commands, &rove.Command{ - Command: game.CommandBroadcast, - Message: []byte(args[i]), + Command: rove.CommandType_broadcast, + Data: &rove.Command_Message{Message: []byte(args[i])}, }, ) default: // By default just use the command literally commands = append(commands, &rove.Command{ - Command: args[i], + Command: rove.CommandType(rove.CommandType_value[args[i]]), }, ) } diff --git a/pkg/game/command.go b/pkg/game/command.go index 96f95d8..b57f678 100644 --- a/pkg/game/command.go +++ b/pkg/game/command.go @@ -1,25 +1,10 @@ package game -const ( - // CommandMove Moves the rover in the chosen bearing - CommandMove = "move" - - // CommandStash Will attempt to stash the object at the current location - CommandStash = "stash" - - // CommandRepair Will attempt to repair the rover with an inventory object - CommandRepair = "repair" - - // CommandRecharge Will use one tick to charge the rover - CommandRecharge = "recharge" - - // CommandBroadcast will broadcast a message to nearby rovers within range - CommandBroadcast = "broadcast" -) +import "github.com/mdiluz/rove/pkg/rove" // Command represends a single command to execute type Command struct { - Command string `json:"command"` + Command rove.CommandType `json:"command"` // Used in the move command Bearing string `json:"bearing,omitempty"` diff --git a/pkg/game/command_test.go b/pkg/game/command_test.go index 45cb182..10ccbe5 100644 --- a/pkg/game/command_test.go +++ b/pkg/game/command_test.go @@ -3,6 +3,7 @@ package game import ( "testing" + "github.com/mdiluz/rove/pkg/rove" "github.com/mdiluz/rove/pkg/vector" "github.com/stretchr/testify/assert" ) @@ -20,7 +21,7 @@ func TestCommand_Move(t *testing.T) { assert.NoError(t, err, "Failed to set position for rover") // Try the move command - moveCommand := Command{Command: CommandMove, Bearing: "N"} + moveCommand := Command{Command: rove.CommandType_move, Bearing: "N"} assert.NoError(t, world.Enqueue(a, moveCommand), "Failed to execute move command") // Tick the world @@ -46,7 +47,7 @@ func TestCommand_Recharge(t *testing.T) { assert.NoError(t, err, "Failed to set position for rover") // Move to use up some charge - moveCommand := Command{Command: CommandMove, Bearing: "N"} + moveCommand := Command{Command: rove.CommandType_move, Bearing: "N"} assert.NoError(t, world.Enqueue(a, moveCommand), "Failed to queue move command") // Tick the world @@ -56,7 +57,7 @@ func TestCommand_Recharge(t *testing.T) { rover, _ := world.GetRover(a) assert.Equal(t, rover.MaximumCharge-1, rover.Charge) - chargeCommand := Command{Command: CommandRecharge} + chargeCommand := Command{Command: rove.CommandType_recharge} assert.NoError(t, world.Enqueue(a, chargeCommand), "Failed to queue recharge command") // Tick the world diff --git a/pkg/game/world.go b/pkg/game/world.go index a48bea0..19183f5 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -12,6 +12,7 @@ import ( "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/bearing" "github.com/mdiluz/rove/pkg/objects" + "github.com/mdiluz/rove/pkg/rove" "github.com/mdiluz/rove/pkg/vector" ) @@ -429,11 +430,11 @@ func (w *World) Enqueue(rover string, commands ...Command) error { // First validate the commands for _, c := range commands { switch c.Command { - case CommandMove: + case rove.CommandType_move: if _, err := bearing.FromString(c.Bearing); err != nil { return fmt.Errorf("unknown bearing: %s", c.Bearing) } - case CommandBroadcast: + case rove.CommandType_broadcast: if len(c.Message) > 3 { return fmt.Errorf("too many characters in message (limit 3): %d", len(c.Message)) } @@ -442,9 +443,9 @@ func (w *World) Enqueue(rover string, commands ...Command) error { return fmt.Errorf("invalid message character: %c", b) } } - case CommandStash: - case CommandRepair: - case CommandRecharge: + case rove.CommandType_stash: + case rove.CommandType_repair: + case rove.CommandType_recharge: // Nothing to verify default: return fmt.Errorf("unknown command: %s", c.Command) @@ -508,19 +509,19 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { log.Printf("Executing command: %+v for %s\n", *c, rover) switch c.Command { - case CommandMove: + case rove.CommandType_move: if dir, err := bearing.FromString(c.Bearing); err != nil { return err } else if _, err := w.MoveRover(rover, dir); err != nil { return err } - case CommandStash: + case rove.CommandType_stash: if _, err := w.RoverStash(rover); err != nil { return err } - case CommandRepair: + case rove.CommandType_repair: r, err := w.GetRover(rover) if err != nil { return err @@ -532,12 +533,12 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { r.AddLogEntryf("repaired self to %d", r.Integrity) w.Rovers[rover] = r } - case CommandRecharge: + case rove.CommandType_recharge: _, err := w.RoverRecharge(rover) if err != nil { return err } - case CommandBroadcast: + case rove.CommandType_broadcast: if err := w.RoverBroadcast(rover, c.Message); err != nil { return err } diff --git a/pkg/game/world_test.go b/pkg/game/world_test.go index c9654c5..35c0a22 100644 --- a/pkg/game/world_test.go +++ b/pkg/game/world_test.go @@ -6,6 +6,7 @@ import ( "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/bearing" "github.com/mdiluz/rove/pkg/objects" + "github.com/mdiluz/rove/pkg/rove" "github.com/mdiluz/rove/pkg/vector" "github.com/stretchr/testify/assert" ) @@ -272,7 +273,7 @@ func TestWorld_RoverRepair(t *testing.T) { assert.NoError(t, err, "couldn't get rover info") assert.Equal(t, originalInfo.Integrity-1, newinfo.Integrity, "rover should have lost integrity") - err = world.ExecuteCommand(&Command{Command: CommandRepair}, a) + err = world.ExecuteCommand(&Command{Command: rove.CommandType_repair}, a) assert.NoError(t, err, "Failed to repair rover") newinfo, err = world.GetRover(a) @@ -286,7 +287,7 @@ func TestWorld_RoverRepair(t *testing.T) { assert.NoError(t, err, "Failed to stash") assert.Equal(t, objects.SmallRock, o, "Failed to get correct object") - err = world.ExecuteCommand(&Command{Command: CommandRepair}, a) + err = world.ExecuteCommand(&Command{Command: rove.CommandType_repair}, a) assert.NoError(t, err, "Failed to repair rover") newinfo, err = world.GetRover(a) diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index 19fa01d..12bfce1 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -13,7 +13,6 @@ package rove import ( context "context" proto "github.com/golang/protobuf/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -34,23 +33,80 @@ const ( // of the legacy proto package is being used. const _ = proto.ProtoPackageIsVersion4 +type CommandType int32 + +const ( + CommandType_none CommandType = 0 + // Move the rover in a direction, requires bearing + CommandType_move CommandType = 1 + // Stashes item at current location in rover inventory + CommandType_stash CommandType = 2 + // Repairs the rover using an inventory object + CommandType_repair CommandType = 3 + // Waits a tick to add more charge to the rover + CommandType_recharge CommandType = 4 + // Broadcasts a message to nearby rovers + CommandType_broadcast CommandType = 5 +) + +// Enum value maps for CommandType. +var ( + CommandType_name = map[int32]string{ + 0: "none", + 1: "move", + 2: "stash", + 3: "repair", + 4: "recharge", + 5: "broadcast", + } + CommandType_value = map[string]int32{ + "none": 0, + "move": 1, + "stash": 2, + "repair": 3, + "recharge": 4, + "broadcast": 5, + } +) + +func (x CommandType) Enum() *CommandType { + p := new(CommandType) + *p = x + return p +} + +func (x CommandType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (CommandType) Descriptor() protoreflect.EnumDescriptor { + return file_rove_rove_proto_enumTypes[0].Descriptor() +} + +func (CommandType) Type() protoreflect.EnumType { + return &file_rove_rove_proto_enumTypes[0] +} + +func (x CommandType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use CommandType.Descriptor instead. +func (CommandType) EnumDescriptor() ([]byte, []int) { + return file_rove_rove_proto_rawDescGZIP(), []int{0} +} + type Command struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The command to execute - // "move" - Move the rover in a direction, requires bearing - // "stash" - Stashes item at current location in rover inventory - // "repair" - Repairs the rover using an inventory object - // "recharge" - Waits a tick to add more charge to the rover - // "broadcast" - Broadcasts a message to nearby rovers - Command string `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"` - // A bearing, example: NE - Bearing string `protobuf:"bytes,2,opt,name=bearing,proto3" json:"bearing,omitempty"` - // A simple message, must be composed of printable ASCII glyphs (32-126) - // maximum of three characters - Message []byte `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` + // The command type + Command CommandType `protobuf:"varint,1,opt,name=command,proto3,enum=rove.CommandType" json:"command,omitempty"` + // Types that are assignable to Data: + // *Command_Bearing + // *Command_Message + Data isCommand_Data `protobuf_oneof:"data"` } func (x *Command) Reset() { @@ -85,27 +141,55 @@ func (*Command) Descriptor() ([]byte, []int) { return file_rove_rove_proto_rawDescGZIP(), []int{0} } -func (x *Command) GetCommand() string { +func (x *Command) GetCommand() CommandType { if x != nil { return x.Command } - return "" + return CommandType_none +} + +func (m *Command) GetData() isCommand_Data { + if m != nil { + return m.Data + } + return nil } func (x *Command) GetBearing() string { - if x != nil { + if x, ok := x.GetData().(*Command_Bearing); ok { return x.Bearing } return "" } func (x *Command) GetMessage() []byte { - if x != nil { + if x, ok := x.GetData().(*Command_Message); ok { return x.Message } return nil } +type isCommand_Data interface { + isCommand_Data() +} + +type Command_Bearing struct { + // A bearing, example: NE + // Used with MOVE + Bearing string `protobuf:"bytes,2,opt,name=bearing,proto3,oneof"` +} + +type Command_Message struct { + // A simple message, must be composed of printable ASCII glyphs (32-126) + // maximum of three characters + // Used with BROADCAST + Message []byte `protobuf:"bytes,3,opt,name=message,proto3,oneof"` +} + +func (*Command_Bearing) isCommand_Data() {} + +func (*Command_Message) isCommand_Data() {} + type CommandRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -950,119 +1034,118 @@ var File_rove_rove_proto protoreflect.FileDescriptor var file_rove_rove_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x04, 0x72, 0x6f, 0x76, 0x65, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, - 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x57, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x65, - 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x65, 0x61, - 0x72, 0x69, 0x6e, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x64, - 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x29, 0x0a, 0x08, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, - 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x37, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, - 0x55, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, - 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x25, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3b, 0x0a, - 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x6f, 0x12, 0x04, 0x72, 0x6f, 0x76, 0x65, 0x22, 0x76, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x12, 0x2b, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, + 0x1a, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x48, 0x00, 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x1a, 0x0a, 0x07, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x07, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, + 0x64, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x38, 0x0a, 0x0d, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, - 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, - 0x65, 0x78, 0x74, 0x22, 0xb7, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x70, 0x6f, - 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, - 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, - 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, - 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, - 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, - 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, - 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, - 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, - 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, - 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, - 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, - 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, - 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x39, 0x0a, 0x10, - 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, - 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x35, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, - 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, - 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x1d, - 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x22, 0x15, 0x0a, - 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x22, 0xa1, 0x01, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, - 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x1a, 0x0a, - 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x75, 0x72, - 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, - 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x1b, 0x0a, 0x09, 0x6e, - 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, - 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, - 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0x35, - 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, - 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, - 0x65, 0x63, 0x72, 0x65, 0x74, 0x32, 0x91, 0x03, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x5d, - 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, - 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, - 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, - 0x22, 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x3a, 0x01, 0x2a, 0x12, 0x4b, - 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x22, 0x08, - 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x3a, 0x01, 0x2a, 0x12, 0x43, 0x0a, 0x05, 0x52, - 0x61, 0x64, 0x61, 0x72, 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, - 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, - 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 0x2f, 0x72, 0x61, 0x64, 0x61, 0x72, 0x3a, 0x01, 0x2a, - 0x12, 0x47, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x12, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0c, 0x22, 0x07, 0x2f, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x3a, 0x01, 0x2a, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, - 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x29, 0x0a, 0x08, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, + 0x72, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x37, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x22, 0x55, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x18, 0x0a, + 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, + 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x25, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3b, + 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x38, 0x0a, 0x0d, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, + 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, 0x0a, 0x04, + 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x74, 0x65, 0x78, 0x74, 0x22, 0xb7, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, + 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, + 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, + 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, + 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, + 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, + 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, + 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, + 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, + 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, + 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, + 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x39, 0x0a, + 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x35, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, + 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, + 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, + 0x1d, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x22, 0x15, + 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa1, 0x01, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, + 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, + 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x1a, + 0x0a, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x75, + 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x1b, 0x0a, 0x09, + 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, + 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, + 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, + 0x35, 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, + 0x0a, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x2a, 0x55, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, + 0x08, 0x0a, 0x04, 0x6d, 0x6f, 0x76, 0x65, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, + 0x73, 0x68, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x03, + 0x12, 0x0c, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x12, 0x0d, + 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x05, 0x32, 0xb1, 0x02, + 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x47, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x3b, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x07, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x32, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, + 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x35, 0x0a, 0x06, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, + 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1077,49 +1160,52 @@ func file_rove_rove_proto_rawDescGZIP() []byte { return file_rove_rove_proto_rawDescData } +var file_rove_rove_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_rove_rove_proto_msgTypes = make([]protoimpl.MessageInfo, 15) var file_rove_rove_proto_goTypes = []interface{}{ - (*Command)(nil), // 0: rove.Command - (*CommandRequest)(nil), // 1: rove.CommandRequest - (*CommandResponse)(nil), // 2: rove.CommandResponse - (*Error)(nil), // 3: rove.Error - (*RadarRequest)(nil), // 4: rove.RadarRequest - (*RadarResponse)(nil), // 5: rove.RadarResponse - (*RegisterRequest)(nil), // 6: rove.RegisterRequest - (*RegisterResponse)(nil), // 7: rove.RegisterResponse - (*StatusRequest)(nil), // 8: rove.StatusRequest - (*Log)(nil), // 9: rove.Log - (*StatusResponse)(nil), // 10: rove.StatusResponse - (*ServerStatusRequest)(nil), // 11: rove.ServerStatusRequest - (*ServerStatusResponse)(nil), // 12: rove.ServerStatusResponse - (*Vector)(nil), // 13: rove.Vector - (*Account)(nil), // 14: rove.Account + (CommandType)(0), // 0: rove.CommandType + (*Command)(nil), // 1: rove.Command + (*CommandRequest)(nil), // 2: rove.CommandRequest + (*CommandResponse)(nil), // 3: rove.CommandResponse + (*Error)(nil), // 4: rove.Error + (*RadarRequest)(nil), // 5: rove.RadarRequest + (*RadarResponse)(nil), // 6: rove.RadarResponse + (*RegisterRequest)(nil), // 7: rove.RegisterRequest + (*RegisterResponse)(nil), // 8: rove.RegisterResponse + (*StatusRequest)(nil), // 9: rove.StatusRequest + (*Log)(nil), // 10: rove.Log + (*StatusResponse)(nil), // 11: rove.StatusResponse + (*ServerStatusRequest)(nil), // 12: rove.ServerStatusRequest + (*ServerStatusResponse)(nil), // 13: rove.ServerStatusResponse + (*Vector)(nil), // 14: rove.Vector + (*Account)(nil), // 15: rove.Account } var file_rove_rove_proto_depIdxs = []int32{ - 14, // 0: rove.CommandRequest.account:type_name -> rove.Account - 0, // 1: rove.CommandRequest.commands:type_name -> rove.Command - 14, // 2: rove.RadarRequest.account:type_name -> rove.Account - 14, // 3: rove.RegisterResponse.account:type_name -> rove.Account - 14, // 4: rove.StatusRequest.account:type_name -> rove.Account - 13, // 5: rove.StatusResponse.position:type_name -> rove.Vector - 0, // 6: rove.StatusResponse.incomingCommands:type_name -> rove.Command - 0, // 7: rove.StatusResponse.queuedCommands:type_name -> rove.Command - 9, // 8: rove.StatusResponse.logs:type_name -> rove.Log - 11, // 9: rove.Rove.ServerStatus:input_type -> rove.ServerStatusRequest - 6, // 10: rove.Rove.Register:input_type -> rove.RegisterRequest - 1, // 11: rove.Rove.Command:input_type -> rove.CommandRequest - 4, // 12: rove.Rove.Radar:input_type -> rove.RadarRequest - 8, // 13: rove.Rove.Status:input_type -> rove.StatusRequest - 12, // 14: rove.Rove.ServerStatus:output_type -> rove.ServerStatusResponse - 7, // 15: rove.Rove.Register:output_type -> rove.RegisterResponse - 2, // 16: rove.Rove.Command:output_type -> rove.CommandResponse - 5, // 17: rove.Rove.Radar:output_type -> rove.RadarResponse - 10, // 18: rove.Rove.Status:output_type -> rove.StatusResponse - 14, // [14:19] is the sub-list for method output_type - 9, // [9:14] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name + 0, // 0: rove.Command.command:type_name -> rove.CommandType + 15, // 1: rove.CommandRequest.account:type_name -> rove.Account + 1, // 2: rove.CommandRequest.commands:type_name -> rove.Command + 15, // 3: rove.RadarRequest.account:type_name -> rove.Account + 15, // 4: rove.RegisterResponse.account:type_name -> rove.Account + 15, // 5: rove.StatusRequest.account:type_name -> rove.Account + 14, // 6: rove.StatusResponse.position:type_name -> rove.Vector + 1, // 7: rove.StatusResponse.incomingCommands:type_name -> rove.Command + 1, // 8: rove.StatusResponse.queuedCommands:type_name -> rove.Command + 10, // 9: rove.StatusResponse.logs:type_name -> rove.Log + 12, // 10: rove.Rove.ServerStatus:input_type -> rove.ServerStatusRequest + 7, // 11: rove.Rove.Register:input_type -> rove.RegisterRequest + 2, // 12: rove.Rove.Command:input_type -> rove.CommandRequest + 5, // 13: rove.Rove.Radar:input_type -> rove.RadarRequest + 9, // 14: rove.Rove.Status:input_type -> rove.StatusRequest + 13, // 15: rove.Rove.ServerStatus:output_type -> rove.ServerStatusResponse + 8, // 16: rove.Rove.Register:output_type -> rove.RegisterResponse + 3, // 17: rove.Rove.Command:output_type -> rove.CommandResponse + 6, // 18: rove.Rove.Radar:output_type -> rove.RadarResponse + 11, // 19: rove.Rove.Status:output_type -> rove.StatusResponse + 15, // [15:20] is the sub-list for method output_type + 10, // [10:15] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_rove_rove_proto_init() } @@ -1309,18 +1395,23 @@ func file_rove_rove_proto_init() { } } } + file_rove_rove_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*Command_Bearing)(nil), + (*Command_Message)(nil), + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_rove_rove_proto_rawDesc, - NumEnums: 0, + NumEnums: 1, NumMessages: 15, NumExtensions: 0, NumServices: 1, }, GoTypes: file_rove_rove_proto_goTypes, DependencyIndexes: file_rove_rove_proto_depIdxs, + EnumInfos: file_rove_rove_proto_enumTypes, MessageInfos: file_rove_rove_proto_msgTypes, }.Build() File_rove_rove_proto = out.File diff --git a/pkg/rove/rove.swagger.json b/pkg/rove/rove.swagger.json index e4dcbee..b1ad0aa 100644 --- a/pkg/rove/rove.swagger.json +++ b/pkg/rove/rove.swagger.json @@ -11,168 +11,7 @@ "produces": [ "application/json" ], - "paths": { - "/command": { - "post": { - "summary": "Send commands to rover", - "description": "Sending commands to this endpoint will queue them to be executed during the following ticks, in the order sent", - "operationId": "Rove_Command", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/roveCommandResponse" - } - }, - "default": { - "description": "An unexpected error response", - "schema": { - "$ref": "#/definitions/gatewayruntimeError" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/roveCommandRequest" - } - } - ], - "tags": [ - "Rove" - ] - } - }, - "/radar": { - "post": { - "summary": "Get radar information", - "description": "Gets the radar output for the given rover", - "operationId": "Rove_Radar", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/roveRadarResponse" - } - }, - "default": { - "description": "An unexpected error response", - "schema": { - "$ref": "#/definitions/gatewayruntimeError" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/roveRadarRequest" - } - } - ], - "tags": [ - "Rove" - ] - } - }, - "/register": { - "post": { - "summary": "Register an account", - "description": "Tries to register an account with the given name", - "operationId": "Rove_Register", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/roveRegisterResponse" - } - }, - "default": { - "description": "An unexpected error response", - "schema": { - "$ref": "#/definitions/gatewayruntimeError" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/roveRegisterRequest" - } - } - ], - "tags": [ - "Rove" - ] - } - }, - "/server-status": { - "get": { - "summary": "Server status", - "description": "Responds with various details about the current server status", - "operationId": "Rove_ServerStatus", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/roveServerStatusResponse" - } - }, - "default": { - "description": "An unexpected error response", - "schema": { - "$ref": "#/definitions/gatewayruntimeError" - } - } - }, - "tags": [ - "Rove" - ] - } - }, - "/status": { - "post": { - "summary": "Get rover information", - "description": "Gets information for the account's rover", - "operationId": "Rove_Status", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/roveStatusResponse" - } - }, - "default": { - "description": "An unexpected error response", - "schema": { - "$ref": "#/definitions/gatewayruntimeError" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/roveStatusRequest" - } - } - ], - "tags": [ - "Rove" - ] - } - } - }, + "paths": {}, "definitions": { "gatewayruntimeError": { "type": "object", @@ -222,33 +61,17 @@ "type": "object", "properties": { "command": { - "type": "string", - "title": "The command to execute\n\"move\" - Move the rover in a direction, requires bearing\n\"stash\" - Stashes item at current location in rover inventory\n\"repair\" - Repairs the rover using an inventory object\n\"recharge\" - Waits a tick to add more charge to the rover\n\"broadcast\" - Broadcasts a message to nearby rovers" + "$ref": "#/definitions/roveCommandType", + "title": "The command type" }, "bearing": { "type": "string", - "title": "A bearing, example: NE" + "title": "A bearing, example: NE\nUsed with MOVE" }, "message": { "type": "string", "format": "byte", - "title": "A simple message, must be composed of printable ASCII glyphs (32-126)\nmaximum of three characters" - } - } - }, - "roveCommandRequest": { - "type": "object", - "properties": { - "account": { - "$ref": "#/definitions/roveAccount", - "title": "The account to execute these commands" - }, - "commands": { - "type": "array", - "items": { - "$ref": "#/definitions/roveCommand" - }, - "title": "The set of desired commands" + "title": "A simple message, must be composed of printable ASCII glyphs (32-126)\nmaximum of three characters\nUsed with BROADCAST" } } }, @@ -256,6 +79,19 @@ "type": "object", "title": "Empty placeholder" }, + "roveCommandType": { + "type": "string", + "enum": [ + "none", + "move", + "stash", + "repair", + "recharge", + "broadcast" + ], + "default": "none", + "title": "- move: Move the rover in a direction, requires bearing\n - stash: Stashes item at current location in rover inventory\n - repair: Repairs the rover using an inventory object\n - recharge: Waits a tick to add more charge to the rover\n - broadcast: Broadcasts a message to nearby rovers" + }, "roveLog": { "type": "object", "properties": { @@ -269,15 +105,6 @@ } } }, - "roveRadarRequest": { - "type": "object", - "properties": { - "account": { - "$ref": "#/definitions/roveAccount", - "title": "The account for this request" - } - } - }, "roveRadarResponse": { "type": "object", "properties": { @@ -298,15 +125,6 @@ } } }, - "roveRegisterRequest": { - "type": "object", - "properties": { - "name": { - "type": "string", - "title": "The desired account name" - } - } - }, "roveRegisterResponse": { "type": "object", "properties": { @@ -345,15 +163,6 @@ } } }, - "roveStatusRequest": { - "type": "object", - "properties": { - "account": { - "$ref": "#/definitions/roveAccount", - "title": "The account for this request" - } - } - }, "roveStatusResponse": { "type": "object", "properties": { diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index d643e9c..de2ad2b 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -7,74 +7,61 @@ package rove; option go_package = "github.com/mdiluz/rove/pkg/rove"; -import "google/api/annotations.proto"; - service Rove { // Server status // // Responds with various details about the current server status - rpc ServerStatus(ServerStatusRequest) returns (ServerStatusResponse) { - option (google.api.http) = { - get: "/server-status" - }; - } + rpc ServerStatus(ServerStatusRequest) returns (ServerStatusResponse) {} // Register an account // // Tries to register an account with the given name - rpc Register(RegisterRequest) returns (RegisterResponse) { - option (google.api.http) = { - post: "/register" - body: "*" - }; - } + rpc Register(RegisterRequest) returns (RegisterResponse) {} // Send commands to rover // // Sending commands to this endpoint will queue them to be executed during the following ticks, in the order sent - rpc Command(CommandRequest) returns (CommandResponse) { - option (google.api.http) = { - post: "/command" - body: "*" - }; - } + rpc Command(CommandRequest) returns (CommandResponse) {} // Get radar information // // Gets the radar output for the given rover - rpc Radar(RadarRequest) returns (RadarResponse) { - option (google.api.http) = { - post: "/radar" - body: "*" - }; - } + rpc Radar(RadarRequest) returns (RadarResponse) {} // Get rover information // // Gets information for the account's rover - rpc Status(StatusRequest) returns (StatusResponse) { - option (google.api.http) = { - post: "/status" - body: "*" - }; - } + rpc Status(StatusRequest) returns (StatusResponse) {} +} + +enum CommandType { + none = 0; + // Move the rover in a direction, requires bearing + move = 1; + // Stashes item at current location in rover inventory + stash = 2; + // Repairs the rover using an inventory object + repair = 3; + // Waits a tick to add more charge to the rover + recharge = 4; + // Broadcasts a message to nearby rovers + broadcast = 5; } message Command { - // The command to execute - // "move" - Move the rover in a direction, requires bearing - // "stash" - Stashes item at current location in rover inventory - // "repair" - Repairs the rover using an inventory object - // "recharge" - Waits a tick to add more charge to the rover - // "broadcast" - Broadcasts a message to nearby rovers - string command = 1; + // The command type + CommandType command = 1; - // A bearing, example: NE - string bearing = 2; - - // A simple message, must be composed of printable ASCII glyphs (32-126) - // maximum of three characters - bytes message = 3; + oneof data { + // A bearing, example: NE + // Used with MOVE + string bearing = 2; + + // A simple message, must be composed of printable ASCII glyphs (32-126) + // maximum of three characters + // Used with BROADCAST + bytes message = 3; + } } message CommandRequest { From 0be6aa7c1282af4f9b8552eb6e3c09372fc44aa4 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 00:26:49 +0100 Subject: [PATCH 096/228] Clean, format and comment the rove.proto file --- proto/rove/rove.proto | 351 +++++++++++++++++++++++------------------- 1 file changed, 190 insertions(+), 161 deletions(-) diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index de2ad2b..ab0160e 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -2,188 +2,217 @@ syntax = "proto3"; // Rove // -// Rove is an asychronous nomadic game about exploring a planet as part of a loose community +// Rove is an asychronous nomadic game about exploring a planet as part of a +// loose community package rove; - option go_package = "github.com/mdiluz/rove/pkg/rove"; +// The Rove server hosts a single game session and world with multiple players service Rove { - // Server status - // - // Responds with various details about the current server status - rpc ServerStatus(ServerStatusRequest) returns (ServerStatusResponse) {} + // Server status + // Responds with various details about the current server status + rpc ServerStatus(ServerStatusRequest) returns (ServerStatusResponse) {} - // Register an account - // - // Tries to register an account with the given name - rpc Register(RegisterRequest) returns (RegisterResponse) {} + // Register an account + // Tries to register an account with the given name + rpc Register(RegisterRequest) returns (RegisterResponse) {} - // Send commands to rover - // - // Sending commands to this endpoint will queue them to be executed during the following ticks, in the order sent - rpc Command(CommandRequest) returns (CommandResponse) {} + // Send commands to rover + // Sending commands to this endpoint will queue them to be executed during the + // following ticks, in the order sent. Commands sent within the same tick will + // overwrite until the tick has finished and the commands are queued + rpc Command(CommandRequest) returns (CommandResponse) {} - // Get radar information - // - // Gets the radar output for the given rover - rpc Radar(RadarRequest) returns (RadarResponse) {} + // Get radar information + // Gets the radar output for the given rover + rpc Radar(RadarRequest) returns (RadarResponse) {} - // Get rover information - // - // Gets information for the account's rover - rpc Status(StatusRequest) returns (StatusResponse) {} + // Get rover information + // Gets information for the account's rover + rpc Status(StatusRequest) returns (StatusResponse) {} } -enum CommandType { - none = 0; - // Move the rover in a direction, requires bearing - move = 1; - // Stashes item at current location in rover inventory - stash = 2; - // Repairs the rover using an inventory object - repair = 3; - // Waits a tick to add more charge to the rover - recharge = 4; - // Broadcasts a message to nearby rovers - broadcast = 5; -} +// +// ServerStatus +// -message Command { - // The command type - CommandType command = 1; - - oneof data { - // A bearing, example: NE - // Used with MOVE - string bearing = 2; - - // A simple message, must be composed of printable ASCII glyphs (32-126) - // maximum of three characters - // Used with BROADCAST - bytes message = 3; - } -} - -message CommandRequest { - // The account to execute these commands - Account account = 1; - - // The set of desired commands - repeated Command commands = 2; -} - -// Empty placeholder -message CommandResponse {} - -message Error { - // An explanation for the HTTP error returned - string error = 1; -} - -message RadarRequest { - // The account for this request - Account account = 1; -} - -message RadarResponse { - // The range in tiles from the rover of the radar data - int32 range = 1; - - // A 1D array representing range*2 + 1 squared set of tiles, origin bottom left and in row->column order - bytes tiles = 2; - - // A similar array to the tile array, but containing objects - bytes objects = 3; -} - -message RegisterRequest { - // The desired account name - string name = 1; -} - -// Empty placeholder -message RegisterResponse{ - // The registered account information - Account account = 1; -} - -message StatusRequest { - // The account for this request - Account account = 1; -} - -message Log { - // The unix timestamp of the log - string time = 1; - - // The text of the log - string text = 2; -} - -message StatusResponse { - // The name of the rover - string name = 1; - - // Position of the rover in world coordinates - Vector position = 2; - - // The range of this rover's radar and broadcasting - int32 range = 3; - - // The items in the rover inventory - bytes inventory = 4; - - // The capacity of the inventory - int32 capacity = 5; - - // The current health of the rover - int32 integrity = 6; - - // The maximum health of the rover - int32 maximumIntegrity = 7; - - // The energy stored in the rover - int32 charge = 8; - - // The max energy the rover can store - int32 maximumCharge = 9; - - // The set of currently incoming commands for this tick - repeated Command incomingCommands = 10; - - // The set of currently queued commands - repeated Command queuedCommands = 11; - - // The most recent logs - repeated Log logs = 12; -} - -// Empty placeholder +// ServerStatusRequest is an empty placeholder message ServerStatusRequest {} +// ServerStatusResponse is a response with useful server information message ServerStatusResponse { - // The version of the server in v{major}.{minor}-{delta}-{sha} form - string version = 1; + // The version of the server in v{major}.{minor}-{delta}-{sha} form + string version = 1; - // Whether the server is ready to accept requests - bool ready = 2; + // Whether the server is ready to accept requests + bool ready = 2; - // The tick rate of the server in minutes (how many minutes per tick) - int32 tickRate = 3; + // The tick rate of the server in minutes (how many minutes per tick) + int32 tickRate = 3; - // The current tick of the server - int32 currentTick = 4; + // The current tick of the server + int32 currentTick = 4; - // The time the next tick will occur - string next_tick = 5; + // The time the next tick will occur + string next_tick = 5; } -message Vector { - int32 x = 1; - int32 y = 2; +// +// Register +// + +// RegisterRequest contains data to register an account +message RegisterRequest { + // The desired account name + string name = 1; } +// Account describes a registered account message Account { - string name = 1; - string secret = 2; + // The account name + string name = 1; + + // The account secret value, given when creating the account + string secret = 2; +} + +// RegisterResponse is the response given to registering an account +message RegisterResponse { + // The registered account information + Account account = 1; +} + +// +// Command +// + +// CommandType defines the type of a command to give to the rover +enum CommandType { + none = 0; + // Move the rover in a direction, requires bearing + move = 1; + // Stashes item at current location in rover inventory + stash = 2; + // Repairs the rover using an inventory object + repair = 3; + // Waits a tick to add more charge to the rover + recharge = 4; + // Broadcasts a message to nearby rovers + broadcast = 5; +} + +// Command is a single command for a rover +message Command { + // The command type + CommandType command = 1; + + oneof data { + // A bearing, example: NE + // Used with MOVE + string bearing = 2; + + // A simple message, must be composed of printable ASCII glyphs (32-126) + // maximum of three characters + // Used with BROADCAST + bytes message = 3; + } +} + +// CommandRequest describes a set of commands to be requested for the rover +message CommandRequest { + // The account to execute these commands + Account account = 1; + + // The set of desired commands + repeated Command commands = 2; +} + +// CommandResponse is an empty placeholder +message CommandResponse {} + +// +// Radar +// + +// RadarRequest is the data needed to request the radar for a rover +message RadarRequest { + // The account for this request + Account account = 1; +} + +// RadarResponse describes radar information +message RadarResponse { + // The range in tiles from the rover of the radar data + int32 range = 1; + + // A 1D array representing range*2 + 1 squared set of tiles, origin bottom + // left and in row->column order + bytes tiles = 2; + + // A similar array to the tile array, but containing objects + bytes objects = 3; +} + +// +// Status +// + +// StatusRequest is information needed to request rover status +message StatusRequest { + // The account for this request + Account account = 1; +} + +// Log is a single log item +message Log { + // The unix timestamp of the log + string time = 1; + + // The text of the log + string text = 2; +} + +// Vector describes a point or vector in 2D space +message Vector { + int32 x = 1; + int32 y = 2; +} + +// StatusResponse is the response given to a status request +message StatusResponse { + // The name of the rover + string name = 1; + + // Position of the rover in world coordinates + Vector position = 2; + + // The range of this rover's radar and broadcasting + int32 range = 3; + + // The items in the rover inventory + bytes inventory = 4; + + // The capacity of the inventory + int32 capacity = 5; + + // The current health of the rover + int32 integrity = 6; + + // The maximum health of the rover + int32 maximumIntegrity = 7; + + // The energy stored in the rover + int32 charge = 8; + + // The max energy the rover can store + int32 maximumCharge = 9; + + // The set of currently incoming commands for this tick + repeated Command incomingCommands = 10; + + // The set of currently queued commands + repeated Command queuedCommands = 11; + + // The most recent logs + repeated Log logs = 12; } \ No newline at end of file From fe6dae4c527055e8a350a15e3abd2955c15316b1 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 00:27:14 +0100 Subject: [PATCH 097/228] Update the generated file for rove.pb.go --- pkg/rove/rove.pb.go | 1345 +++++++++++++++++++++---------------------- 1 file changed, 646 insertions(+), 699 deletions(-) diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index 12bfce1..2186fd9 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -6,7 +6,8 @@ // Rove // -// Rove is an asychronous nomadic game about exploring a planet as part of a loose community +// Rove is an asychronous nomadic game about exploring a planet as part of a +// loose community package rove @@ -33,6 +34,7 @@ const ( // of the legacy proto package is being used. const _ = proto.ProtoPackageIsVersion4 +// CommandType defines the type of a command to give to the rover type CommandType int32 const ( @@ -96,6 +98,287 @@ func (CommandType) EnumDescriptor() ([]byte, []int) { return file_rove_rove_proto_rawDescGZIP(), []int{0} } +// ServerStatusRequest is an empty placeholder +type ServerStatusRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ServerStatusRequest) Reset() { + *x = ServerStatusRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_rove_rove_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServerStatusRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServerStatusRequest) ProtoMessage() {} + +func (x *ServerStatusRequest) ProtoReflect() protoreflect.Message { + mi := &file_rove_rove_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServerStatusRequest.ProtoReflect.Descriptor instead. +func (*ServerStatusRequest) Descriptor() ([]byte, []int) { + return file_rove_rove_proto_rawDescGZIP(), []int{0} +} + +// ServerStatusResponse is a response with useful server information +type ServerStatusResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The version of the server in v{major}.{minor}-{delta}-{sha} form + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + // Whether the server is ready to accept requests + Ready bool `protobuf:"varint,2,opt,name=ready,proto3" json:"ready,omitempty"` + // The tick rate of the server in minutes (how many minutes per tick) + TickRate int32 `protobuf:"varint,3,opt,name=tickRate,proto3" json:"tickRate,omitempty"` + // The current tick of the server + CurrentTick int32 `protobuf:"varint,4,opt,name=currentTick,proto3" json:"currentTick,omitempty"` + // The time the next tick will occur + NextTick string `protobuf:"bytes,5,opt,name=next_tick,json=nextTick,proto3" json:"next_tick,omitempty"` +} + +func (x *ServerStatusResponse) Reset() { + *x = ServerStatusResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_rove_rove_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServerStatusResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServerStatusResponse) ProtoMessage() {} + +func (x *ServerStatusResponse) ProtoReflect() protoreflect.Message { + mi := &file_rove_rove_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServerStatusResponse.ProtoReflect.Descriptor instead. +func (*ServerStatusResponse) Descriptor() ([]byte, []int) { + return file_rove_rove_proto_rawDescGZIP(), []int{1} +} + +func (x *ServerStatusResponse) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +func (x *ServerStatusResponse) GetReady() bool { + if x != nil { + return x.Ready + } + return false +} + +func (x *ServerStatusResponse) GetTickRate() int32 { + if x != nil { + return x.TickRate + } + return 0 +} + +func (x *ServerStatusResponse) GetCurrentTick() int32 { + if x != nil { + return x.CurrentTick + } + return 0 +} + +func (x *ServerStatusResponse) GetNextTick() string { + if x != nil { + return x.NextTick + } + return "" +} + +// RegisterRequest contains data to register an account +type RegisterRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The desired account name + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *RegisterRequest) Reset() { + *x = RegisterRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_rove_rove_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RegisterRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterRequest) ProtoMessage() {} + +func (x *RegisterRequest) ProtoReflect() protoreflect.Message { + mi := &file_rove_rove_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RegisterRequest.ProtoReflect.Descriptor instead. +func (*RegisterRequest) Descriptor() ([]byte, []int) { + return file_rove_rove_proto_rawDescGZIP(), []int{2} +} + +func (x *RegisterRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +// Account describes a registered account +type Account struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The account name + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // The account secret value, given when creating the account + Secret string `protobuf:"bytes,2,opt,name=secret,proto3" json:"secret,omitempty"` +} + +func (x *Account) Reset() { + *x = Account{} + if protoimpl.UnsafeEnabled { + mi := &file_rove_rove_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Account) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Account) ProtoMessage() {} + +func (x *Account) ProtoReflect() protoreflect.Message { + mi := &file_rove_rove_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Account.ProtoReflect.Descriptor instead. +func (*Account) Descriptor() ([]byte, []int) { + return file_rove_rove_proto_rawDescGZIP(), []int{3} +} + +func (x *Account) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Account) GetSecret() string { + if x != nil { + return x.Secret + } + return "" +} + +// RegisterResponse is the response given to registering an account +type RegisterResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The registered account information + Account *Account `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` +} + +func (x *RegisterResponse) Reset() { + *x = RegisterResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_rove_rove_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RegisterResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterResponse) ProtoMessage() {} + +func (x *RegisterResponse) ProtoReflect() protoreflect.Message { + mi := &file_rove_rove_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RegisterResponse.ProtoReflect.Descriptor instead. +func (*RegisterResponse) Descriptor() ([]byte, []int) { + return file_rove_rove_proto_rawDescGZIP(), []int{4} +} + +func (x *RegisterResponse) GetAccount() *Account { + if x != nil { + return x.Account + } + return nil +} + +// Command is a single command for a rover type Command struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -112,7 +395,7 @@ type Command struct { func (x *Command) Reset() { *x = Command{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[0] + mi := &file_rove_rove_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -125,7 +408,7 @@ func (x *Command) String() string { func (*Command) ProtoMessage() {} func (x *Command) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[0] + mi := &file_rove_rove_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -138,7 +421,7 @@ func (x *Command) ProtoReflect() protoreflect.Message { // Deprecated: Use Command.ProtoReflect.Descriptor instead. func (*Command) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{0} + return file_rove_rove_proto_rawDescGZIP(), []int{5} } func (x *Command) GetCommand() CommandType { @@ -190,6 +473,7 @@ func (*Command_Bearing) isCommand_Data() {} func (*Command_Message) isCommand_Data() {} +// CommandRequest describes a set of commands to be requested for the rover type CommandRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -204,7 +488,7 @@ type CommandRequest struct { func (x *CommandRequest) Reset() { *x = CommandRequest{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[1] + mi := &file_rove_rove_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -217,7 +501,7 @@ func (x *CommandRequest) String() string { func (*CommandRequest) ProtoMessage() {} func (x *CommandRequest) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[1] + mi := &file_rove_rove_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -230,7 +514,7 @@ func (x *CommandRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CommandRequest.ProtoReflect.Descriptor instead. func (*CommandRequest) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{1} + return file_rove_rove_proto_rawDescGZIP(), []int{6} } func (x *CommandRequest) GetAccount() *Account { @@ -247,7 +531,7 @@ func (x *CommandRequest) GetCommands() []*Command { return nil } -// Empty placeholder +// CommandResponse is an empty placeholder type CommandResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -257,7 +541,7 @@ type CommandResponse struct { func (x *CommandResponse) Reset() { *x = CommandResponse{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[2] + mi := &file_rove_rove_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -270,7 +554,7 @@ func (x *CommandResponse) String() string { func (*CommandResponse) ProtoMessage() {} func (x *CommandResponse) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[2] + mi := &file_rove_rove_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -283,57 +567,10 @@ func (x *CommandResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CommandResponse.ProtoReflect.Descriptor instead. func (*CommandResponse) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{2} -} - -type Error struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // An explanation for the HTTP error returned - Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` -} - -func (x *Error) Reset() { - *x = Error{} - if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Error) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Error) ProtoMessage() {} - -func (x *Error) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Error.ProtoReflect.Descriptor instead. -func (*Error) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{3} -} - -func (x *Error) GetError() string { - if x != nil { - return x.Error - } - return "" + return file_rove_rove_proto_rawDescGZIP(), []int{7} } +// RadarRequest is the data needed to request the radar for a rover type RadarRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -346,7 +583,7 @@ type RadarRequest struct { func (x *RadarRequest) Reset() { *x = RadarRequest{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[4] + mi := &file_rove_rove_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -359,7 +596,7 @@ func (x *RadarRequest) String() string { func (*RadarRequest) ProtoMessage() {} func (x *RadarRequest) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[4] + mi := &file_rove_rove_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -372,7 +609,7 @@ func (x *RadarRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RadarRequest.ProtoReflect.Descriptor instead. func (*RadarRequest) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{4} + return file_rove_rove_proto_rawDescGZIP(), []int{8} } func (x *RadarRequest) GetAccount() *Account { @@ -382,6 +619,7 @@ func (x *RadarRequest) GetAccount() *Account { return nil } +// RadarResponse describes radar information type RadarResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -389,7 +627,8 @@ type RadarResponse struct { // The range in tiles from the rover of the radar data Range int32 `protobuf:"varint,1,opt,name=range,proto3" json:"range,omitempty"` - // A 1D array representing range*2 + 1 squared set of tiles, origin bottom left and in row->column order + // A 1D array representing range*2 + 1 squared set of tiles, origin bottom + // left and in row->column order Tiles []byte `protobuf:"bytes,2,opt,name=tiles,proto3" json:"tiles,omitempty"` // A similar array to the tile array, but containing objects Objects []byte `protobuf:"bytes,3,opt,name=objects,proto3" json:"objects,omitempty"` @@ -398,7 +637,7 @@ type RadarResponse struct { func (x *RadarResponse) Reset() { *x = RadarResponse{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[5] + mi := &file_rove_rove_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -411,7 +650,7 @@ func (x *RadarResponse) String() string { func (*RadarResponse) ProtoMessage() {} func (x *RadarResponse) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[5] + mi := &file_rove_rove_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -424,7 +663,7 @@ func (x *RadarResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RadarResponse.ProtoReflect.Descriptor instead. func (*RadarResponse) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{5} + return file_rove_rove_proto_rawDescGZIP(), []int{9} } func (x *RadarResponse) GetRange() int32 { @@ -448,103 +687,7 @@ func (x *RadarResponse) GetObjects() []byte { return nil } -type RegisterRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The desired account name - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *RegisterRequest) Reset() { - *x = RegisterRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RegisterRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterRequest) ProtoMessage() {} - -func (x *RegisterRequest) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RegisterRequest.ProtoReflect.Descriptor instead. -func (*RegisterRequest) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{6} -} - -func (x *RegisterRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -// Empty placeholder -type RegisterResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The registered account information - Account *Account `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` -} - -func (x *RegisterResponse) Reset() { - *x = RegisterResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RegisterResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterResponse) ProtoMessage() {} - -func (x *RegisterResponse) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RegisterResponse.ProtoReflect.Descriptor instead. -func (*RegisterResponse) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{7} -} - -func (x *RegisterResponse) GetAccount() *Account { - if x != nil { - return x.Account - } - return nil -} - +// StatusRequest is information needed to request rover status type StatusRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -557,7 +700,7 @@ type StatusRequest struct { func (x *StatusRequest) Reset() { *x = StatusRequest{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[8] + mi := &file_rove_rove_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -570,7 +713,7 @@ func (x *StatusRequest) String() string { func (*StatusRequest) ProtoMessage() {} func (x *StatusRequest) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[8] + mi := &file_rove_rove_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -583,7 +726,7 @@ func (x *StatusRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use StatusRequest.ProtoReflect.Descriptor instead. func (*StatusRequest) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{8} + return file_rove_rove_proto_rawDescGZIP(), []int{10} } func (x *StatusRequest) GetAccount() *Account { @@ -593,6 +736,7 @@ func (x *StatusRequest) GetAccount() *Account { return nil } +// Log is a single log item type Log struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -607,7 +751,7 @@ type Log struct { func (x *Log) Reset() { *x = Log{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[9] + mi := &file_rove_rove_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -620,7 +764,7 @@ func (x *Log) String() string { func (*Log) ProtoMessage() {} func (x *Log) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[9] + mi := &file_rove_rove_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -633,7 +777,7 @@ func (x *Log) ProtoReflect() protoreflect.Message { // Deprecated: Use Log.ProtoReflect.Descriptor instead. func (*Log) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{9} + return file_rove_rove_proto_rawDescGZIP(), []int{11} } func (x *Log) GetTime() string { @@ -650,6 +794,63 @@ func (x *Log) GetText() string { return "" } +// Vector describes a point or vector in 2D space +type Vector struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + X int32 `protobuf:"varint,1,opt,name=x,proto3" json:"x,omitempty"` + Y int32 `protobuf:"varint,2,opt,name=y,proto3" json:"y,omitempty"` +} + +func (x *Vector) Reset() { + *x = Vector{} + if protoimpl.UnsafeEnabled { + mi := &file_rove_rove_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Vector) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Vector) ProtoMessage() {} + +func (x *Vector) ProtoReflect() protoreflect.Message { + mi := &file_rove_rove_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Vector.ProtoReflect.Descriptor instead. +func (*Vector) Descriptor() ([]byte, []int) { + return file_rove_rove_proto_rawDescGZIP(), []int{12} +} + +func (x *Vector) GetX() int32 { + if x != nil { + return x.X + } + return 0 +} + +func (x *Vector) GetY() int32 { + if x != nil { + return x.Y + } + return 0 +} + +// StatusResponse is the response given to a status request type StatusResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -684,7 +885,7 @@ type StatusResponse struct { func (x *StatusResponse) Reset() { *x = StatusResponse{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[10] + mi := &file_rove_rove_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -697,7 +898,7 @@ func (x *StatusResponse) String() string { func (*StatusResponse) ProtoMessage() {} func (x *StatusResponse) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[10] + mi := &file_rove_rove_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -710,7 +911,7 @@ func (x *StatusResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use StatusResponse.ProtoReflect.Descriptor instead. func (*StatusResponse) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{10} + return file_rove_rove_proto_rawDescGZIP(), []int{13} } func (x *StatusResponse) GetName() string { @@ -797,355 +998,120 @@ func (x *StatusResponse) GetLogs() []*Log { return nil } -// Empty placeholder -type ServerStatusRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *ServerStatusRequest) Reset() { - *x = ServerStatusRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ServerStatusRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ServerStatusRequest) ProtoMessage() {} - -func (x *ServerStatusRequest) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[11] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ServerStatusRequest.ProtoReflect.Descriptor instead. -func (*ServerStatusRequest) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{11} -} - -type ServerStatusResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The version of the server in v{major}.{minor}-{delta}-{sha} form - Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` - // Whether the server is ready to accept requests - Ready bool `protobuf:"varint,2,opt,name=ready,proto3" json:"ready,omitempty"` - // The tick rate of the server in minutes (how many minutes per tick) - TickRate int32 `protobuf:"varint,3,opt,name=tickRate,proto3" json:"tickRate,omitempty"` - // The current tick of the server - CurrentTick int32 `protobuf:"varint,4,opt,name=currentTick,proto3" json:"currentTick,omitempty"` - // The time the next tick will occur - NextTick string `protobuf:"bytes,5,opt,name=next_tick,json=nextTick,proto3" json:"next_tick,omitempty"` -} - -func (x *ServerStatusResponse) Reset() { - *x = ServerStatusResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ServerStatusResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ServerStatusResponse) ProtoMessage() {} - -func (x *ServerStatusResponse) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[12] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ServerStatusResponse.ProtoReflect.Descriptor instead. -func (*ServerStatusResponse) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{12} -} - -func (x *ServerStatusResponse) GetVersion() string { - if x != nil { - return x.Version - } - return "" -} - -func (x *ServerStatusResponse) GetReady() bool { - if x != nil { - return x.Ready - } - return false -} - -func (x *ServerStatusResponse) GetTickRate() int32 { - if x != nil { - return x.TickRate - } - return 0 -} - -func (x *ServerStatusResponse) GetCurrentTick() int32 { - if x != nil { - return x.CurrentTick - } - return 0 -} - -func (x *ServerStatusResponse) GetNextTick() string { - if x != nil { - return x.NextTick - } - return "" -} - -type Vector struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - X int32 `protobuf:"varint,1,opt,name=x,proto3" json:"x,omitempty"` - Y int32 `protobuf:"varint,2,opt,name=y,proto3" json:"y,omitempty"` -} - -func (x *Vector) Reset() { - *x = Vector{} - if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Vector) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Vector) ProtoMessage() {} - -func (x *Vector) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[13] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Vector.ProtoReflect.Descriptor instead. -func (*Vector) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{13} -} - -func (x *Vector) GetX() int32 { - if x != nil { - return x.X - } - return 0 -} - -func (x *Vector) GetY() int32 { - if x != nil { - return x.Y - } - return 0 -} - -type Account struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Secret string `protobuf:"bytes,2,opt,name=secret,proto3" json:"secret,omitempty"` -} - -func (x *Account) Reset() { - *x = Account{} - if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Account) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Account) ProtoMessage() {} - -func (x *Account) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[14] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Account.ProtoReflect.Descriptor instead. -func (*Account) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{14} -} - -func (x *Account) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Account) GetSecret() string { - if x != nil { - return x.Secret - } - return "" -} - var File_rove_rove_proto protoreflect.FileDescriptor var file_rove_rove_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x04, 0x72, 0x6f, 0x76, 0x65, 0x22, 0x76, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x12, 0x2b, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, - 0x1a, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x48, 0x00, 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x1a, 0x0a, 0x07, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x07, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, - 0x64, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x29, 0x0a, 0x08, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, - 0x72, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x37, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, + 0x6f, 0x12, 0x04, 0x72, 0x6f, 0x76, 0x65, 0x22, 0x15, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa1, + 0x01, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, + 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, + 0x61, 0x74, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, + 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, + 0x63, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, + 0x63, 0x6b, 0x22, 0x25, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x35, 0x0a, 0x07, 0x41, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x63, 0x72, + 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, + 0x22, 0x3b, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x76, 0x0a, + 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2b, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1a, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, + 0x67, 0x12, 0x1a, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0c, 0x48, 0x00, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x06, 0x0a, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x64, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x22, 0x55, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x18, 0x0a, - 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, - 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x25, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3b, - 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x38, 0x0a, 0x0d, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, - 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, 0x0a, 0x04, - 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x74, 0x65, 0x78, 0x74, 0x22, 0xb7, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x70, - 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, - 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, - 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, - 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, - 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, - 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, - 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, - 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, - 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, - 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, - 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, - 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x39, 0x0a, - 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x35, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, - 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, + 0x12, 0x29, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x37, + 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, + 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, + 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x55, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x14, + 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, + 0x69, 0x6c, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x38, + 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, + 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, + 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, + 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, + 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, + 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xb7, 0x03, + 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x56, 0x65, + 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, + 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, + 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, + 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, + 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, + 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, + 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, + 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, + 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, + 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, + 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, + 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x39, 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, + 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, - 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, - 0x1d, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x22, 0x15, - 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa1, 0x01, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, - 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, - 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x1a, - 0x0a, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x75, - 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x1b, 0x0a, 0x09, - 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, - 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, - 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, - 0x35, 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, - 0x0a, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, - 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x2a, 0x55, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, - 0x08, 0x0a, 0x04, 0x6d, 0x6f, 0x76, 0x65, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, - 0x73, 0x68, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x03, - 0x12, 0x0c, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x12, 0x0d, - 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x05, 0x32, 0xb1, 0x02, - 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x47, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x3b, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x07, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x32, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, - 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x35, 0x0a, 0x06, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, - 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x73, 0x12, 0x35, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x1d, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, + 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x4c, 0x6f, + 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x2a, 0x55, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, + 0x12, 0x08, 0x0a, 0x04, 0x6d, 0x6f, 0x76, 0x65, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, + 0x61, 0x73, 0x68, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, + 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x12, + 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x05, 0x32, 0xb1, + 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x47, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x3b, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, + 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x32, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, + 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, + 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x35, 0x0a, 0x06, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, + 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1161,46 +1127,45 @@ func file_rove_rove_proto_rawDescGZIP() []byte { } var file_rove_rove_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_rove_rove_proto_msgTypes = make([]protoimpl.MessageInfo, 15) +var file_rove_rove_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_rove_rove_proto_goTypes = []interface{}{ (CommandType)(0), // 0: rove.CommandType - (*Command)(nil), // 1: rove.Command - (*CommandRequest)(nil), // 2: rove.CommandRequest - (*CommandResponse)(nil), // 3: rove.CommandResponse - (*Error)(nil), // 4: rove.Error - (*RadarRequest)(nil), // 5: rove.RadarRequest - (*RadarResponse)(nil), // 6: rove.RadarResponse - (*RegisterRequest)(nil), // 7: rove.RegisterRequest - (*RegisterResponse)(nil), // 8: rove.RegisterResponse - (*StatusRequest)(nil), // 9: rove.StatusRequest - (*Log)(nil), // 10: rove.Log - (*StatusResponse)(nil), // 11: rove.StatusResponse - (*ServerStatusRequest)(nil), // 12: rove.ServerStatusRequest - (*ServerStatusResponse)(nil), // 13: rove.ServerStatusResponse - (*Vector)(nil), // 14: rove.Vector - (*Account)(nil), // 15: rove.Account + (*ServerStatusRequest)(nil), // 1: rove.ServerStatusRequest + (*ServerStatusResponse)(nil), // 2: rove.ServerStatusResponse + (*RegisterRequest)(nil), // 3: rove.RegisterRequest + (*Account)(nil), // 4: rove.Account + (*RegisterResponse)(nil), // 5: rove.RegisterResponse + (*Command)(nil), // 6: rove.Command + (*CommandRequest)(nil), // 7: rove.CommandRequest + (*CommandResponse)(nil), // 8: rove.CommandResponse + (*RadarRequest)(nil), // 9: rove.RadarRequest + (*RadarResponse)(nil), // 10: rove.RadarResponse + (*StatusRequest)(nil), // 11: rove.StatusRequest + (*Log)(nil), // 12: rove.Log + (*Vector)(nil), // 13: rove.Vector + (*StatusResponse)(nil), // 14: rove.StatusResponse } var file_rove_rove_proto_depIdxs = []int32{ - 0, // 0: rove.Command.command:type_name -> rove.CommandType - 15, // 1: rove.CommandRequest.account:type_name -> rove.Account - 1, // 2: rove.CommandRequest.commands:type_name -> rove.Command - 15, // 3: rove.RadarRequest.account:type_name -> rove.Account - 15, // 4: rove.RegisterResponse.account:type_name -> rove.Account - 15, // 5: rove.StatusRequest.account:type_name -> rove.Account - 14, // 6: rove.StatusResponse.position:type_name -> rove.Vector - 1, // 7: rove.StatusResponse.incomingCommands:type_name -> rove.Command - 1, // 8: rove.StatusResponse.queuedCommands:type_name -> rove.Command - 10, // 9: rove.StatusResponse.logs:type_name -> rove.Log - 12, // 10: rove.Rove.ServerStatus:input_type -> rove.ServerStatusRequest - 7, // 11: rove.Rove.Register:input_type -> rove.RegisterRequest - 2, // 12: rove.Rove.Command:input_type -> rove.CommandRequest - 5, // 13: rove.Rove.Radar:input_type -> rove.RadarRequest - 9, // 14: rove.Rove.Status:input_type -> rove.StatusRequest - 13, // 15: rove.Rove.ServerStatus:output_type -> rove.ServerStatusResponse - 8, // 16: rove.Rove.Register:output_type -> rove.RegisterResponse - 3, // 17: rove.Rove.Command:output_type -> rove.CommandResponse - 6, // 18: rove.Rove.Radar:output_type -> rove.RadarResponse - 11, // 19: rove.Rove.Status:output_type -> rove.StatusResponse + 4, // 0: rove.RegisterResponse.account:type_name -> rove.Account + 0, // 1: rove.Command.command:type_name -> rove.CommandType + 4, // 2: rove.CommandRequest.account:type_name -> rove.Account + 6, // 3: rove.CommandRequest.commands:type_name -> rove.Command + 4, // 4: rove.RadarRequest.account:type_name -> rove.Account + 4, // 5: rove.StatusRequest.account:type_name -> rove.Account + 13, // 6: rove.StatusResponse.position:type_name -> rove.Vector + 6, // 7: rove.StatusResponse.incomingCommands:type_name -> rove.Command + 6, // 8: rove.StatusResponse.queuedCommands:type_name -> rove.Command + 12, // 9: rove.StatusResponse.logs:type_name -> rove.Log + 1, // 10: rove.Rove.ServerStatus:input_type -> rove.ServerStatusRequest + 3, // 11: rove.Rove.Register:input_type -> rove.RegisterRequest + 7, // 12: rove.Rove.Command:input_type -> rove.CommandRequest + 9, // 13: rove.Rove.Radar:input_type -> rove.RadarRequest + 11, // 14: rove.Rove.Status:input_type -> rove.StatusRequest + 2, // 15: rove.Rove.ServerStatus:output_type -> rove.ServerStatusResponse + 5, // 16: rove.Rove.Register:output_type -> rove.RegisterResponse + 8, // 17: rove.Rove.Command:output_type -> rove.CommandResponse + 10, // 18: rove.Rove.Radar:output_type -> rove.RadarResponse + 14, // 19: rove.Rove.Status:output_type -> rove.StatusResponse 15, // [15:20] is the sub-list for method output_type 10, // [10:15] is the sub-list for method input_type 10, // [10:10] is the sub-list for extension type_name @@ -1215,138 +1180,6 @@ func file_rove_rove_proto_init() { } if !protoimpl.UnsafeEnabled { file_rove_rove_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Command); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_rove_rove_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CommandRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_rove_rove_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CommandResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_rove_rove_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Error); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_rove_rove_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RadarRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_rove_rove_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RadarResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_rove_rove_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RegisterRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_rove_rove_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RegisterResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_rove_rove_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StatusRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_rove_rove_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Log); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_rove_rove_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StatusResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_rove_rove_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ServerStatusRequest); i { case 0: return &v.state @@ -1358,7 +1191,7 @@ func file_rove_rove_proto_init() { return nil } } - file_rove_rove_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_rove_rove_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ServerStatusResponse); i { case 0: return &v.state @@ -1370,8 +1203,8 @@ func file_rove_rove_proto_init() { return nil } } - file_rove_rove_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Vector); i { + file_rove_rove_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RegisterRequest); i { case 0: return &v.state case 1: @@ -1382,7 +1215,7 @@ func file_rove_rove_proto_init() { return nil } } - file_rove_rove_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + file_rove_rove_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Account); i { case 0: return &v.state @@ -1394,8 +1227,128 @@ func file_rove_rove_proto_init() { return nil } } + file_rove_rove_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RegisterResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rove_rove_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Command); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rove_rove_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CommandRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rove_rove_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CommandResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rove_rove_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RadarRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rove_rove_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RadarResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rove_rove_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StatusRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rove_rove_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Log); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rove_rove_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Vector); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rove_rove_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StatusResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } - file_rove_rove_proto_msgTypes[0].OneofWrappers = []interface{}{ + file_rove_rove_proto_msgTypes[5].OneofWrappers = []interface{}{ (*Command_Bearing)(nil), (*Command_Message)(nil), } @@ -1405,7 +1358,7 @@ func file_rove_rove_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_rove_rove_proto_rawDesc, NumEnums: 1, - NumMessages: 15, + NumMessages: 14, NumExtensions: 0, NumServices: 1, }, @@ -1433,23 +1386,20 @@ const _ = grpc.SupportPackageIsVersion6 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type RoveClient interface { // Server status - // // Responds with various details about the current server status ServerStatus(ctx context.Context, in *ServerStatusRequest, opts ...grpc.CallOption) (*ServerStatusResponse, error) // Register an account - // // Tries to register an account with the given name Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) // Send commands to rover - // - // Sending commands to this endpoint will queue them to be executed during the following ticks, in the order sent + // Sending commands to this endpoint will queue them to be executed during the + // following ticks, in the order sent. Commands sent within the same tick will + // overwrite until the tick has finished and the commands are queued Command(ctx context.Context, in *CommandRequest, opts ...grpc.CallOption) (*CommandResponse, error) // Get radar information - // // Gets the radar output for the given rover Radar(ctx context.Context, in *RadarRequest, opts ...grpc.CallOption) (*RadarResponse, error) // Get rover information - // // Gets information for the account's rover Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) } @@ -1510,23 +1460,20 @@ func (c *roveClient) Status(ctx context.Context, in *StatusRequest, opts ...grpc // RoveServer is the server API for Rove service. type RoveServer interface { // Server status - // // Responds with various details about the current server status ServerStatus(context.Context, *ServerStatusRequest) (*ServerStatusResponse, error) // Register an account - // // Tries to register an account with the given name Register(context.Context, *RegisterRequest) (*RegisterResponse, error) // Send commands to rover - // - // Sending commands to this endpoint will queue them to be executed during the following ticks, in the order sent + // Sending commands to this endpoint will queue them to be executed during the + // following ticks, in the order sent. Commands sent within the same tick will + // overwrite until the tick has finished and the commands are queued Command(context.Context, *CommandRequest) (*CommandResponse, error) // Get radar information - // // Gets the radar output for the given rover Radar(context.Context, *RadarRequest) (*RadarResponse, error) // Get rover information - // // Gets information for the account's rover Status(context.Context, *StatusRequest) (*StatusResponse, error) } From 6c1ee311cd6b04495ff5cef9bd31756cfc157d25 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 00:29:06 +0100 Subject: [PATCH 098/228] Delete unused files --- Dockerfile.docs | 8 - cmd/rove-server-rest-proxy/http_test.go | 150 -------- cmd/rove-server-rest-proxy/main.go | 51 --- pkg/rove/rove.pb.gw.go | 459 ------------------------ pkg/rove/rove.swagger.json | 249 ------------- 5 files changed, 917 deletions(-) delete mode 100644 Dockerfile.docs delete mode 100644 cmd/rove-server-rest-proxy/http_test.go delete mode 100644 cmd/rove-server-rest-proxy/main.go delete mode 100644 pkg/rove/rove.pb.gw.go delete mode 100644 pkg/rove/rove.swagger.json diff --git a/Dockerfile.docs b/Dockerfile.docs deleted file mode 100644 index c74f94b..0000000 --- a/Dockerfile.docs +++ /dev/null @@ -1,8 +0,0 @@ -FROM quay.io/goswagger/swagger:latest -LABEL maintainer="Marc Di Luzio " - -WORKDIR /app -COPY . . - -CMD [ "serve", "pkg/rove/rove.swagger.json", "--no-open" ] - diff --git a/cmd/rove-server-rest-proxy/http_test.go b/cmd/rove-server-rest-proxy/http_test.go deleted file mode 100644 index f590f74..0000000 --- a/cmd/rove-server-rest-proxy/http_test.go +++ /dev/null @@ -1,150 +0,0 @@ -// +build integration - -package main - -import ( - "bytes" - "encoding/json" - "fmt" - "io/ioutil" - "log" - "net/http" - "net/url" - "os" - "testing" - - "github.com/google/uuid" - "github.com/mdiluz/rove/pkg/rove" - "github.com/stretchr/testify/assert" -) - -// Server is a simple wrapper to a server path -type Server string - -// Request performs a HTTP -func (s Server) Request(method, path string, in, out interface{}) error { - u := url.URL{ - Scheme: "http", - Host: fmt.Sprintf("%s:8080", string(s)), - Path: path, - } - client := &http.Client{} - - // Marshal the input - marshalled, err := json.Marshal(in) - if err != nil { - return err - } - - // Set up the request - req, err := http.NewRequest(method, u.String(), bytes.NewReader(marshalled)) - if err != nil { - return err - } - - // Do the POST - req.Header.Set("Content-Type", "application/json") - if resp, err := client.Do(req); err != nil { - return err - - } else if resp.StatusCode != http.StatusOK { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("failed to read response body to code %d", resp.StatusCode) - } - return fmt.Errorf("http returned status %d: %s", resp.StatusCode, string(body)) - - } else { - return json.NewDecoder(resp.Body).Decode(out) - } -} - -var serv = Server(os.Getenv("ROVE_HTTP")) - -func TestServer_ServerStatus(t *testing.T) { - req := &rove.ServerStatusRequest{} - resp := &rove.ServerStatusResponse{} - if err := serv.Request("GET", "server-status", req, resp); err != nil { - log.Fatal(err) - } -} - -func TestServer_Register(t *testing.T) { - req := &rove.RegisterRequest{Name: uuid.New().String()} - resp := &rove.RegisterResponse{} - err := serv.Request("POST", "register", req, resp) - assert.NoError(t, err, "First register attempt should pass") - err = serv.Request("POST", "register", req, resp) - assert.Error(t, err, "Second identical register attempt should fail") -} - -func TestServer_Command(t *testing.T) { - acc := uuid.New().String() - var resp rove.RegisterResponse - err := serv.Request("POST", "register", &rove.RegisterRequest{Name: acc}, &resp) - assert.NoError(t, err, "First register attempt should pass") - - req := &rove.CommandRequest{ - Account: &rove.Account{ - Name: resp.Account.Name, - }, - Commands: []*rove.Command{ - { - Command: "move", - Bearing: "NE", - }, - }, - } - - assert.Error(t, serv.Request("POST", "command", req, &rove.CommandResponse{}), "Commands should fail with no secret") - - req.Account.Secret = resp.Account.Secret - assert.NoError(t, serv.Request("POST", "command", req, &rove.CommandResponse{}), "Commands should pass") -} - -func TestServer_Radar(t *testing.T) { - acc := uuid.New().String() - var reg rove.RegisterResponse - err := serv.Request("POST", "register", &rove.RegisterRequest{Name: acc}, ®) - assert.NoError(t, err, "First register attempt should pass") - - resp := &rove.RadarResponse{} - req := &rove.RadarRequest{ - Account: &rove.Account{ - Name: reg.Account.Name, - }, - } - - assert.Error(t, serv.Request("POST", "radar", req, resp), "Radar should fail without secret") - req.Account.Secret = reg.Account.Secret - - assert.NoError(t, serv.Request("POST", "radar", req, resp), "Radar should pass") - assert.NotZero(t, resp.Range, "Radar should return valid range") - - w := int(resp.Range*2 + 1) - assert.Equal(t, w*w, len(resp.Tiles), "radar should return correct number of tiles") - assert.Equal(t, w*w, len(resp.Objects), "radar should return correct number of objects") -} - -func TestServer_Status(t *testing.T) { - acc := uuid.New().String() - var reg rove.RegisterResponse - err := serv.Request("POST", "register", &rove.RegisterRequest{Name: acc}, ®) - assert.NoError(t, err, "First register attempt should pass") - - resp := &rove.StatusResponse{} - req := &rove.StatusRequest{ - Account: &rove.Account{ - Name: reg.Account.Name, - }, - } - - assert.Error(t, serv.Request("POST", "status", req, resp), "Status should fail without secret") - req.Account.Secret = reg.Account.Secret - - assert.NoError(t, serv.Request("POST", "status", req, resp), "Status should pass") - assert.NotZero(t, resp.Range, "Rover should return valid range") - assert.NotZero(t, len(resp.Name), "Rover should return valid name") - assert.NotZero(t, resp.Position, "Rover should return valid position") - assert.NotZero(t, resp.Integrity, "Rover should have positive integrity") -} diff --git a/cmd/rove-server-rest-proxy/main.go b/cmd/rove-server-rest-proxy/main.go deleted file mode 100644 index 06653b6..0000000 --- a/cmd/rove-server-rest-proxy/main.go +++ /dev/null @@ -1,51 +0,0 @@ -package main - -import ( - "context" - "fmt" - "log" - "net/http" - "os" - "strconv" - - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - - "github.com/mdiluz/rove/pkg/rove" -) - -func main() { - ctx := context.Background() - ctx, cancel := context.WithCancel(ctx) - defer cancel() - - var endpoint = os.Getenv("ROVE_GRPC") - if len(endpoint) == 0 { - endpoint = "localhost:9090" - } - - var iport int - var port = os.Getenv("PORT") - if len(port) == 0 { - iport = 8080 - } else { - var err error - iport, err = strconv.Atoi(port) - if err != nil { - log.Fatal("$PORT not valid int") - } - } - - // Create a new mux and register it with the gRPC endpoint - fmt.Printf("Hosting reverse-proxy on %d for %s\n", iport, endpoint) - mux := runtime.NewServeMux() - opts := []grpc.DialOption{grpc.WithInsecure()} - if err := rove.RegisterRoveHandlerFromEndpoint(ctx, mux, endpoint, opts); err != nil { - log.Fatal(err) - } - - // Start the HTTP server and proxy calls to gRPC endpoint when needed - if err := http.ListenAndServe(fmt.Sprintf(":%d", iport), mux); err != nil { - log.Fatal(err) - } -} diff --git a/pkg/rove/rove.pb.gw.go b/pkg/rove/rove.pb.gw.go deleted file mode 100644 index db3d25e..0000000 --- a/pkg/rove/rove.pb.gw.go +++ /dev/null @@ -1,459 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: rove/rove.proto - -/* -Package rove is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package rove - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage - -func request_Rove_ServerStatus_0(ctx context.Context, marshaler runtime.Marshaler, client RoveClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ServerStatusRequest - var metadata runtime.ServerMetadata - - msg, err := client.ServerStatus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Rove_ServerStatus_0(ctx context.Context, marshaler runtime.Marshaler, server RoveServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ServerStatusRequest - var metadata runtime.ServerMetadata - - msg, err := server.ServerStatus(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Rove_Register_0(ctx context.Context, marshaler runtime.Marshaler, client RoveClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq RegisterRequest - var metadata runtime.ServerMetadata - - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Register(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Rove_Register_0(ctx context.Context, marshaler runtime.Marshaler, server RoveServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq RegisterRequest - var metadata runtime.ServerMetadata - - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Register(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Rove_Command_0(ctx context.Context, marshaler runtime.Marshaler, client RoveClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq CommandRequest - var metadata runtime.ServerMetadata - - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Command(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Rove_Command_0(ctx context.Context, marshaler runtime.Marshaler, server RoveServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq CommandRequest - var metadata runtime.ServerMetadata - - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Command(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Rove_Radar_0(ctx context.Context, marshaler runtime.Marshaler, client RoveClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq RadarRequest - var metadata runtime.ServerMetadata - - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Radar(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Rove_Radar_0(ctx context.Context, marshaler runtime.Marshaler, server RoveServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq RadarRequest - var metadata runtime.ServerMetadata - - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Radar(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Rove_Status_0(ctx context.Context, marshaler runtime.Marshaler, client RoveClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq StatusRequest - var metadata runtime.ServerMetadata - - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Status(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Rove_Status_0(ctx context.Context, marshaler runtime.Marshaler, server RoveServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq StatusRequest - var metadata runtime.ServerMetadata - - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Status(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterRoveHandlerServer registers the http handlers for service Rove to "mux". -// UnaryRPC :call RoveServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -func RegisterRoveHandlerServer(ctx context.Context, mux *runtime.ServeMux, server RoveServer) error { - - mux.Handle("GET", pattern_Rove_ServerStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Rove_ServerStatus_0(rctx, inboundMarshaler, server, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Rove_ServerStatus_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("POST", pattern_Rove_Register_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Rove_Register_0(rctx, inboundMarshaler, server, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Rove_Register_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("POST", pattern_Rove_Command_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Rove_Command_0(rctx, inboundMarshaler, server, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Rove_Command_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("POST", pattern_Rove_Radar_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Rove_Radar_0(rctx, inboundMarshaler, server, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Rove_Radar_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("POST", pattern_Rove_Status_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Rove_Status_0(rctx, inboundMarshaler, server, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Rove_Status_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterRoveHandlerFromEndpoint is same as RegisterRoveHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterRoveHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterRoveHandler(ctx, mux, conn) -} - -// RegisterRoveHandler registers the http handlers for service Rove to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterRoveHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterRoveHandlerClient(ctx, mux, NewRoveClient(conn)) -} - -// RegisterRoveHandlerClient registers the http handlers for service Rove -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "RoveClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "RoveClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "RoveClient" to call the correct interceptors. -func RegisterRoveHandlerClient(ctx context.Context, mux *runtime.ServeMux, client RoveClient) error { - - mux.Handle("GET", pattern_Rove_ServerStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Rove_ServerStatus_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Rove_ServerStatus_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("POST", pattern_Rove_Register_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Rove_Register_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Rove_Register_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("POST", pattern_Rove_Command_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Rove_Command_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Rove_Command_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("POST", pattern_Rove_Radar_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Rove_Radar_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Rove_Radar_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("POST", pattern_Rove_Status_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Rove_Status_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Rove_Status_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Rove_ServerStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"server-status"}, "", runtime.AssumeColonVerbOpt(true))) - - pattern_Rove_Register_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"register"}, "", runtime.AssumeColonVerbOpt(true))) - - pattern_Rove_Command_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"command"}, "", runtime.AssumeColonVerbOpt(true))) - - pattern_Rove_Radar_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"radar"}, "", runtime.AssumeColonVerbOpt(true))) - - pattern_Rove_Status_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"status"}, "", runtime.AssumeColonVerbOpt(true))) -) - -var ( - forward_Rove_ServerStatus_0 = runtime.ForwardResponseMessage - - forward_Rove_Register_0 = runtime.ForwardResponseMessage - - forward_Rove_Command_0 = runtime.ForwardResponseMessage - - forward_Rove_Radar_0 = runtime.ForwardResponseMessage - - forward_Rove_Status_0 = runtime.ForwardResponseMessage -) diff --git a/pkg/rove/rove.swagger.json b/pkg/rove/rove.swagger.json deleted file mode 100644 index b1ad0aa..0000000 --- a/pkg/rove/rove.swagger.json +++ /dev/null @@ -1,249 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Rove", - "description": "Rove is an asychronous nomadic game about exploring a planet as part of a loose community", - "version": "version not set" - }, - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "paths": {}, - "definitions": { - "gatewayruntimeError": { - "type": "object", - "properties": { - "error": { - "type": "string" - }, - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - }, - "details": { - "type": "array", - "items": { - "$ref": "#/definitions/protobufAny" - } - } - } - }, - "protobufAny": { - "type": "object", - "properties": { - "type_url": { - "type": "string" - }, - "value": { - "type": "string", - "format": "byte" - } - } - }, - "roveAccount": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "secret": { - "type": "string" - } - } - }, - "roveCommand": { - "type": "object", - "properties": { - "command": { - "$ref": "#/definitions/roveCommandType", - "title": "The command type" - }, - "bearing": { - "type": "string", - "title": "A bearing, example: NE\nUsed with MOVE" - }, - "message": { - "type": "string", - "format": "byte", - "title": "A simple message, must be composed of printable ASCII glyphs (32-126)\nmaximum of three characters\nUsed with BROADCAST" - } - } - }, - "roveCommandResponse": { - "type": "object", - "title": "Empty placeholder" - }, - "roveCommandType": { - "type": "string", - "enum": [ - "none", - "move", - "stash", - "repair", - "recharge", - "broadcast" - ], - "default": "none", - "title": "- move: Move the rover in a direction, requires bearing\n - stash: Stashes item at current location in rover inventory\n - repair: Repairs the rover using an inventory object\n - recharge: Waits a tick to add more charge to the rover\n - broadcast: Broadcasts a message to nearby rovers" - }, - "roveLog": { - "type": "object", - "properties": { - "time": { - "type": "string", - "title": "The unix timestamp of the log" - }, - "text": { - "type": "string", - "title": "The text of the log" - } - } - }, - "roveRadarResponse": { - "type": "object", - "properties": { - "range": { - "type": "integer", - "format": "int32", - "title": "The range in tiles from the rover of the radar data" - }, - "tiles": { - "type": "string", - "format": "byte", - "title": "A 1D array representing range*2 + 1 squared set of tiles, origin bottom left and in row-\u003ecolumn order" - }, - "objects": { - "type": "string", - "format": "byte", - "title": "A similar array to the tile array, but containing objects" - } - } - }, - "roveRegisterResponse": { - "type": "object", - "properties": { - "account": { - "$ref": "#/definitions/roveAccount", - "title": "The registered account information" - } - }, - "title": "Empty placeholder" - }, - "roveServerStatusResponse": { - "type": "object", - "properties": { - "version": { - "type": "string", - "title": "The version of the server in v{major}.{minor}-{delta}-{sha} form" - }, - "ready": { - "type": "boolean", - "format": "boolean", - "title": "Whether the server is ready to accept requests" - }, - "tickRate": { - "type": "integer", - "format": "int32", - "title": "The tick rate of the server in minutes (how many minutes per tick)" - }, - "currentTick": { - "type": "integer", - "format": "int32", - "title": "The current tick of the server" - }, - "next_tick": { - "type": "string", - "title": "The time the next tick will occur" - } - } - }, - "roveStatusResponse": { - "type": "object", - "properties": { - "name": { - "type": "string", - "title": "The name of the rover" - }, - "position": { - "$ref": "#/definitions/roveVector", - "title": "Position of the rover in world coordinates" - }, - "range": { - "type": "integer", - "format": "int32", - "title": "The range of this rover's radar and broadcasting" - }, - "inventory": { - "type": "string", - "format": "byte", - "title": "The items in the rover inventory" - }, - "capacity": { - "type": "integer", - "format": "int32", - "title": "The capacity of the inventory" - }, - "integrity": { - "type": "integer", - "format": "int32", - "title": "The current health of the rover" - }, - "maximumIntegrity": { - "type": "integer", - "format": "int32", - "title": "The maximum health of the rover" - }, - "charge": { - "type": "integer", - "format": "int32", - "title": "The energy stored in the rover" - }, - "maximumCharge": { - "type": "integer", - "format": "int32", - "title": "The max energy the rover can store" - }, - "incomingCommands": { - "type": "array", - "items": { - "$ref": "#/definitions/roveCommand" - }, - "title": "The set of currently incoming commands for this tick" - }, - "queuedCommands": { - "type": "array", - "items": { - "$ref": "#/definitions/roveCommand" - }, - "title": "The set of currently queued commands" - }, - "logs": { - "type": "array", - "items": { - "$ref": "#/definitions/roveLog" - }, - "title": "The most recent logs" - } - } - }, - "roveVector": { - "type": "object", - "properties": { - "x": { - "type": "integer", - "format": "int32" - }, - "y": { - "type": "integer", - "format": "int32" - } - } - } - } -} From 5ac44d85cbd1f71351ee9fa254da06ea56b43b2c Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 16:38:49 +0100 Subject: [PATCH 099/228] Add a warning to missing DATA_PATH env --- cmd/rove-server/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/rove-server/main.go b/cmd/rove-server/main.go index db09130..66621cf 100644 --- a/cmd/rove-server/main.go +++ b/cmd/rove-server/main.go @@ -52,7 +52,9 @@ func InnerMain() { log.Printf("Initialising version %s...\n", version.Version) // Set the persistence path - if err := persistence.SetPath(data); err != nil { + if len(data) == 0 { + log.Fatal("DATA_PATH not set") + } else if err := persistence.SetPath(data); err != nil { log.Fatal(err) } From fb2ffc52523faf8659790ecf6b80392948bbaa1a Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 16:52:00 +0100 Subject: [PATCH 100/228] Convert Atlas to an interface --- pkg/atlas/atlas.go | 46 ++++++++++++++++++++++++++--------------- pkg/atlas/atlas_test.go | 22 ++++++++++---------- pkg/game/world.go | 4 ++-- 3 files changed, 42 insertions(+), 30 deletions(-) diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index dd618e7..b94d923 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -27,6 +27,18 @@ const ( TileSand = Tile('~') ) +// Atlas represents a 2D world atlas of tiles and objects +type Atlas interface { + // SetTile sets a location on the Atlas to a type of tile + SetTile(v vector.Vector, tile Tile) + + // SetObject will set a location on the Atlas to contain an object + SetObject(v vector.Vector, obj objects.Object) + + // QueryPosition queries a position on the atlas + QueryPosition(v vector.Vector) (byte, objects.Object) +} + // Chunk represents a fixed square grid of tiles type Chunk struct { // Tiles represents the tiles within the chunk @@ -37,8 +49,8 @@ type Chunk struct { Objects map[int]objects.Object `json:"objects"` } -// Atlas represents a grid of Chunks -type Atlas struct { +// ChunkBasedAtlas represents a grid of Chunks +type ChunkBasedAtlas struct { // Chunks represents all chunks in the world // This is intentionally not a 2D array so it can be expanded in all directions Chunks []Chunk `json:"chunks"` @@ -68,7 +80,7 @@ const ( // NewAtlas creates a new empty atlas func NewAtlas(chunkSize int) Atlas { // Start up with one chunk - a := Atlas{ + a := ChunkBasedAtlas{ ChunkSize: chunkSize, Chunks: make([]Chunk, 1), LowerBound: vector.Vector{X: 0, Y: 0}, @@ -78,25 +90,25 @@ func NewAtlas(chunkSize int) Atlas { } // Initialise the first chunk a.populate(0) - return a + return &a } // SetTile sets an individual tile's kind -func (a *Atlas) SetTile(v vector.Vector, tile Tile) { +func (a *ChunkBasedAtlas) SetTile(v vector.Vector, tile Tile) { c := a.worldSpaceToChunkWithGrow(v) local := a.worldSpaceToChunkLocal(v) a.setTile(c, local, byte(tile)) } // SetObject sets the object on a tile -func (a *Atlas) SetObject(v vector.Vector, obj objects.Object) { +func (a *ChunkBasedAtlas) SetObject(v vector.Vector, obj objects.Object) { c := a.worldSpaceToChunkWithGrow(v) local := a.worldSpaceToChunkLocal(v) a.setObject(c, local, obj) } // QueryPosition will return information for a specific position -func (a *Atlas) QueryPosition(v vector.Vector) (byte, objects.Object) { +func (a *ChunkBasedAtlas) QueryPosition(v vector.Vector) (byte, objects.Object) { c := a.worldSpaceToChunkWithGrow(v) local := a.worldSpaceToChunkLocal(v) a.populate(c) @@ -106,12 +118,12 @@ func (a *Atlas) QueryPosition(v vector.Vector) (byte, objects.Object) { } // chunkTileID returns the tile index within a chunk -func (a *Atlas) chunkTileIndex(local vector.Vector) int { +func (a *ChunkBasedAtlas) chunkTileIndex(local vector.Vector) int { return local.X + local.Y*a.ChunkSize } // populate will fill a chunk with data -func (a *Atlas) populate(chunk int) { +func (a *ChunkBasedAtlas) populate(chunk int) { c := a.Chunks[chunk] if c.Tiles != nil { return @@ -165,7 +177,7 @@ func (a *Atlas) populate(chunk int) { } // setTile sets a tile in a specific chunk -func (a *Atlas) setTile(chunk int, local vector.Vector, tile byte) { +func (a *ChunkBasedAtlas) setTile(chunk int, local vector.Vector, tile byte) { a.populate(chunk) c := a.Chunks[chunk] c.Tiles[a.chunkTileIndex(local)] = tile @@ -173,7 +185,7 @@ func (a *Atlas) setTile(chunk int, local vector.Vector, tile byte) { } // setObject sets an object in a specific chunk -func (a *Atlas) setObject(chunk int, local vector.Vector, object objects.Object) { +func (a *ChunkBasedAtlas) setObject(chunk int, local vector.Vector, object objects.Object) { a.populate(chunk) c := a.Chunks[chunk] @@ -187,12 +199,12 @@ func (a *Atlas) setObject(chunk int, local vector.Vector, object objects.Object) } // worldSpaceToChunkLocal gets a chunk local coordinate for a tile -func (a *Atlas) worldSpaceToChunkLocal(v vector.Vector) vector.Vector { +func (a *ChunkBasedAtlas) worldSpaceToChunkLocal(v vector.Vector) vector.Vector { return vector.Vector{X: maths.Pmod(v.X, a.ChunkSize), Y: maths.Pmod(v.Y, a.ChunkSize)} } // worldSpaceToChunkID gets the current chunk ID for a position in the world -func (a *Atlas) worldSpaceToChunkIndex(v vector.Vector) int { +func (a *ChunkBasedAtlas) worldSpaceToChunkIndex(v vector.Vector) int { // Shift the vector by our current min v = v.Added(a.LowerBound.Negated()) @@ -208,7 +220,7 @@ func (a *Atlas) worldSpaceToChunkIndex(v vector.Vector) int { } // chunkOriginInWorldSpace returns the origin of the chunk in world space -func (a *Atlas) chunkOriginInWorldSpace(chunk int) vector.Vector { +func (a *ChunkBasedAtlas) chunkOriginInWorldSpace(chunk int) vector.Vector { // Calculate the width width := a.UpperBound.X - a.LowerBound.X widthInChunks := width / a.ChunkSize @@ -225,7 +237,7 @@ func (a *Atlas) chunkOriginInWorldSpace(chunk int) vector.Vector { } // getNewBounds gets new lower and upper bounds for the world space given a vector -func (a *Atlas) getNewBounds(v vector.Vector) (lower vector.Vector, upper vector.Vector) { +func (a *ChunkBasedAtlas) getNewBounds(v vector.Vector) (lower vector.Vector, upper vector.Vector) { lower = vector.Min(v, a.LowerBound) upper = vector.Max(v.Added(vector.Vector{X: 1, Y: 1}), a.UpperBound) @@ -241,7 +253,7 @@ func (a *Atlas) getNewBounds(v vector.Vector) (lower vector.Vector, upper vector } // worldSpaceToTrunkWithGrow will expand the current atlas for a given world space position if needed -func (a *Atlas) worldSpaceToChunkWithGrow(v vector.Vector) int { +func (a *ChunkBasedAtlas) worldSpaceToChunkWithGrow(v vector.Vector) int { // If we're within bounds, just return the current chunk if v.X >= a.LowerBound.X && v.Y >= a.LowerBound.Y && v.X < a.UpperBound.X && v.Y < a.UpperBound.Y { return a.worldSpaceToChunkIndex(v) @@ -253,7 +265,7 @@ func (a *Atlas) worldSpaceToChunkWithGrow(v vector.Vector) int { size = size.Divided(a.ChunkSize) // Create the new empty atlas - newAtlas := Atlas{ + newAtlas := ChunkBasedAtlas{ ChunkSize: a.ChunkSize, LowerBound: lower, UpperBound: upper, diff --git a/pkg/atlas/atlas_test.go b/pkg/atlas/atlas_test.go index dedf4b1..1803bea 100644 --- a/pkg/atlas/atlas_test.go +++ b/pkg/atlas/atlas_test.go @@ -10,14 +10,14 @@ import ( ) func TestAtlas_NewAtlas(t *testing.T) { - a := NewAtlas(1) + a := NewAtlas(1).(*ChunkBasedAtlas) assert.NotNil(t, a) assert.Equal(t, 1, a.ChunkSize) assert.Equal(t, 1, len(a.Chunks)) // Should start empty } func TestAtlas_toChunk(t *testing.T) { - a := NewAtlas(1) + a := NewAtlas(1).(*ChunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn the chunks @@ -38,7 +38,7 @@ func TestAtlas_toChunk(t *testing.T) { chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -1, Y: 0}) assert.Equal(t, 2, chunkID) - a = NewAtlas(2) + a = NewAtlas(2).(*ChunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn the chunks a.QueryPosition(vector.Vector{X: -2, Y: -2}) @@ -58,7 +58,7 @@ func TestAtlas_toChunk(t *testing.T) { chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -2, Y: 1}) assert.Equal(t, 2, chunkID) - a = NewAtlas(2) + a = NewAtlas(2).(*ChunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn a 4x4 grid of chunks a.QueryPosition(vector.Vector{X: 3, Y: 3}) @@ -83,7 +83,7 @@ func TestAtlas_toChunk(t *testing.T) { chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -2, Y: 2}) assert.Equal(t, 13, chunkID) - a = NewAtlas(3) + a = NewAtlas(3).(*ChunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn a 4x4 grid of chunks a.QueryPosition(vector.Vector{X: 3, Y: 3}) @@ -105,7 +105,7 @@ func TestAtlas_toChunk(t *testing.T) { } func TestAtlas_toWorld(t *testing.T) { - a := NewAtlas(1) + a := NewAtlas(1).(*ChunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn some chunks @@ -119,7 +119,7 @@ func TestAtlas_toWorld(t *testing.T) { assert.Equal(t, vector.Vector{X: -1, Y: -1}, a.chunkOriginInWorldSpace(0)) assert.Equal(t, vector.Vector{X: 0, Y: -1}, a.chunkOriginInWorldSpace(1)) - a = NewAtlas(2) + a = NewAtlas(2).(*ChunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn the chunks a.QueryPosition(vector.Vector{X: -2, Y: -2}) @@ -133,7 +133,7 @@ func TestAtlas_toWorld(t *testing.T) { assert.Equal(t, vector.Vector{X: -2, Y: -2}, a.chunkOriginInWorldSpace(0)) assert.Equal(t, vector.Vector{X: -2, Y: 0}, a.chunkOriginInWorldSpace(2)) - a = NewAtlas(2) + a = NewAtlas(2).(*ChunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn a 4x4 grid of chunks a.QueryPosition(vector.Vector{X: 3, Y: 3}) @@ -152,7 +152,7 @@ func TestAtlas_toWorld(t *testing.T) { assert.Equal(t, vector.Vector{X: -4, Y: -4}, a.chunkOriginInWorldSpace(0)) assert.Equal(t, vector.Vector{X: 2, Y: -2}, a.chunkOriginInWorldSpace(7)) - a = NewAtlas(3) + a = NewAtlas(3).(*ChunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn a 4x4 grid of chunks a.QueryPosition(vector.Vector{X: 3, Y: 3}) @@ -198,7 +198,7 @@ func TestAtlas_GetSetObject(t *testing.T) { func TestAtlas_Grown(t *testing.T) { // Start with a small example - a := NewAtlas(2) + a := NewAtlas(2).(*ChunkBasedAtlas) assert.NotNil(t, a) assert.Equal(t, 1, len(a.Chunks)) @@ -233,7 +233,7 @@ func TestAtlas_GetSetCorrect(t *testing.T) { for x := -i * 2; x < i*2; x++ { for y := -i * 2; y < i*2; y++ { - a := NewAtlas(i) + a := NewAtlas(i).(*ChunkBasedAtlas) assert.NotNil(t, a) assert.Equal(t, 1, len(a.Chunks)) diff --git a/pkg/game/world.go b/pkg/game/world.go index 19183f5..89a70e5 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -107,8 +107,8 @@ func (w *World) SpawnRover() (string, error) { // Spawn in a random place near the origin rover.Pos = vector.Vector{ - X: w.Atlas.ChunkSize/2 - rand.Intn(w.Atlas.ChunkSize), - Y: w.Atlas.ChunkSize/2 - rand.Intn(w.Atlas.ChunkSize), + X: 10 - rand.Intn(20), + Y: 10 - rand.Intn(20), } // Seach until we error (run out of world) From 655e00b41fbe33b9e63fa478baa29acb5c3957b2 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 16:52:31 +0100 Subject: [PATCH 101/228] Don't expose Chunk externally --- pkg/atlas/atlas.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index b94d923..0793dc9 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -39,8 +39,8 @@ type Atlas interface { QueryPosition(v vector.Vector) (byte, objects.Object) } -// Chunk represents a fixed square grid of tiles -type Chunk struct { +// chunk represents a fixed square grid of tiles +type chunk struct { // Tiles represents the tiles within the chunk Tiles []byte `json:"tiles"` @@ -53,7 +53,7 @@ type Chunk struct { type ChunkBasedAtlas struct { // Chunks represents all chunks in the world // This is intentionally not a 2D array so it can be expanded in all directions - Chunks []Chunk `json:"chunks"` + Chunks []chunk `json:"chunks"` // LowerBound is the origin of the bottom left corner of the current chunks in world space (current chunks cover >= this value) LowerBound vector.Vector `json:"lowerBound"` @@ -82,7 +82,7 @@ func NewAtlas(chunkSize int) Atlas { // Start up with one chunk a := ChunkBasedAtlas{ ChunkSize: chunkSize, - Chunks: make([]Chunk, 1), + Chunks: make([]chunk, 1), LowerBound: vector.Vector{X: 0, Y: 0}, UpperBound: vector.Vector{X: chunkSize, Y: chunkSize}, terrainNoise: opensimplex.New(noiseSeed), @@ -269,7 +269,7 @@ func (a *ChunkBasedAtlas) worldSpaceToChunkWithGrow(v vector.Vector) int { ChunkSize: a.ChunkSize, LowerBound: lower, UpperBound: upper, - Chunks: make([]Chunk, size.X*size.Y), + Chunks: make([]chunk, size.X*size.Y), terrainNoise: a.terrainNoise, objectNoise: a.objectNoise, } From a0be8a463c72ffdfe4e52fff7823316f1bedd660 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 16:54:43 +0100 Subject: [PATCH 102/228] Pull out chunk based atlas into new file --- pkg/atlas/atlas.go | 260 --------------------------------------- pkg/atlas/atlas_test.go | 28 ++--- pkg/atlas/chunkAtlas.go | 266 ++++++++++++++++++++++++++++++++++++++++ pkg/game/world.go | 2 +- 4 files changed, 281 insertions(+), 275 deletions(-) create mode 100644 pkg/atlas/chunkAtlas.go diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index 0793dc9..d4054db 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -1,13 +1,8 @@ package atlas import ( - "log" - "math/rand" - - "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/vector" - "github.com/ojrac/opensimplex-go" ) // Tile describes the type of terrain @@ -38,258 +33,3 @@ type Atlas interface { // QueryPosition queries a position on the atlas QueryPosition(v vector.Vector) (byte, objects.Object) } - -// chunk represents a fixed square grid of tiles -type chunk struct { - // Tiles represents the tiles within the chunk - Tiles []byte `json:"tiles"` - - // Objects represents the objects within the chunk - // only one possible object per tile for now - Objects map[int]objects.Object `json:"objects"` -} - -// ChunkBasedAtlas represents a grid of Chunks -type ChunkBasedAtlas struct { - // Chunks represents all chunks in the world - // This is intentionally not a 2D array so it can be expanded in all directions - Chunks []chunk `json:"chunks"` - - // LowerBound is the origin of the bottom left corner of the current chunks in world space (current chunks cover >= this value) - LowerBound vector.Vector `json:"lowerBound"` - - // UpperBound is the top left corner of the current chunks (curent chunks cover < this value) - UpperBound vector.Vector `json:"upperBound"` - - // ChunkSize is the x/y dimensions of each square chunk - ChunkSize int `json:"chunksize"` - - // terrainNoise describes the noise function for the terrain - terrainNoise opensimplex.Noise - - // terrainNoise describes the noise function for the terrain - objectNoise opensimplex.Noise -} - -const ( - noiseSeed = 1024 - terrainNoiseScale = 6 - objectNoiseScale = 3 -) - -// NewAtlas creates a new empty atlas -func NewAtlas(chunkSize int) Atlas { - // Start up with one chunk - a := ChunkBasedAtlas{ - ChunkSize: chunkSize, - Chunks: make([]chunk, 1), - LowerBound: vector.Vector{X: 0, Y: 0}, - UpperBound: vector.Vector{X: chunkSize, Y: chunkSize}, - terrainNoise: opensimplex.New(noiseSeed), - objectNoise: opensimplex.New(noiseSeed), - } - // Initialise the first chunk - a.populate(0) - return &a -} - -// SetTile sets an individual tile's kind -func (a *ChunkBasedAtlas) SetTile(v vector.Vector, tile Tile) { - c := a.worldSpaceToChunkWithGrow(v) - local := a.worldSpaceToChunkLocal(v) - a.setTile(c, local, byte(tile)) -} - -// SetObject sets the object on a tile -func (a *ChunkBasedAtlas) SetObject(v vector.Vector, obj objects.Object) { - c := a.worldSpaceToChunkWithGrow(v) - local := a.worldSpaceToChunkLocal(v) - a.setObject(c, local, obj) -} - -// QueryPosition will return information for a specific position -func (a *ChunkBasedAtlas) QueryPosition(v vector.Vector) (byte, objects.Object) { - c := a.worldSpaceToChunkWithGrow(v) - local := a.worldSpaceToChunkLocal(v) - a.populate(c) - chunk := a.Chunks[c] - i := a.chunkTileIndex(local) - return chunk.Tiles[i], chunk.Objects[i] -} - -// chunkTileID returns the tile index within a chunk -func (a *ChunkBasedAtlas) chunkTileIndex(local vector.Vector) int { - return local.X + local.Y*a.ChunkSize -} - -// populate will fill a chunk with data -func (a *ChunkBasedAtlas) populate(chunk int) { - c := a.Chunks[chunk] - if c.Tiles != nil { - return - } - - c.Tiles = make([]byte, a.ChunkSize*a.ChunkSize) - c.Objects = make(map[int]objects.Object) - - origin := a.chunkOriginInWorldSpace(chunk) - for i := 0; i < a.ChunkSize; i++ { - for j := 0; j < a.ChunkSize; j++ { - - // Get the terrain noise value for this location - t := a.terrainNoise.Eval2(float64(origin.X+i)/terrainNoiseScale, float64(origin.Y+j)/terrainNoiseScale) - var tile Tile - switch { - case t > 0.5: - tile = TileGravel - case t > 0.05: - tile = TileSand - default: - tile = TileRock - } - c.Tiles[j*a.ChunkSize+i] = byte(tile) - - // Get the object noise value for this location - o := a.objectNoise.Eval2(float64(origin.X+i)/objectNoiseScale, float64(origin.Y+j)/objectNoiseScale) - var obj = objects.None - switch { - case o > 0.6: - obj = objects.LargeRock - case o > 0.5: - obj = objects.SmallRock - } - if obj != objects.None { - c.Objects[j*a.ChunkSize+i] = objects.Object{Type: obj} - } - } - } - - // Set up any objects - for i := 0; i < len(c.Tiles); i++ { - if rand.Intn(16) == 0 { - c.Objects[i] = objects.Object{Type: objects.LargeRock} - } else if rand.Intn(32) == 0 { - c.Objects[i] = objects.Object{Type: objects.SmallRock} - } - } - - a.Chunks[chunk] = c -} - -// setTile sets a tile in a specific chunk -func (a *ChunkBasedAtlas) setTile(chunk int, local vector.Vector, tile byte) { - a.populate(chunk) - c := a.Chunks[chunk] - c.Tiles[a.chunkTileIndex(local)] = tile - a.Chunks[chunk] = c -} - -// setObject sets an object in a specific chunk -func (a *ChunkBasedAtlas) setObject(chunk int, local vector.Vector, object objects.Object) { - a.populate(chunk) - - c := a.Chunks[chunk] - i := a.chunkTileIndex(local) - if object.Type != objects.None { - c.Objects[i] = object - } else { - delete(c.Objects, i) - } - a.Chunks[chunk] = c -} - -// worldSpaceToChunkLocal gets a chunk local coordinate for a tile -func (a *ChunkBasedAtlas) worldSpaceToChunkLocal(v vector.Vector) vector.Vector { - return vector.Vector{X: maths.Pmod(v.X, a.ChunkSize), Y: maths.Pmod(v.Y, a.ChunkSize)} -} - -// worldSpaceToChunkID gets the current chunk ID for a position in the world -func (a *ChunkBasedAtlas) worldSpaceToChunkIndex(v vector.Vector) int { - // Shift the vector by our current min - v = v.Added(a.LowerBound.Negated()) - - // Divide by the current size and floor, to get chunk-scaled vector from the lower bound - v = v.DividedFloor(a.ChunkSize) - - // Calculate the width - width := a.UpperBound.X - a.LowerBound.X - widthInChunks := width / a.ChunkSize - - // Along the corridor and up the stairs - return (v.Y * widthInChunks) + v.X -} - -// chunkOriginInWorldSpace returns the origin of the chunk in world space -func (a *ChunkBasedAtlas) chunkOriginInWorldSpace(chunk int) vector.Vector { - // Calculate the width - width := a.UpperBound.X - a.LowerBound.X - widthInChunks := width / a.ChunkSize - - // Reverse the along the corridor and up the stairs - v := vector.Vector{ - X: chunk % widthInChunks, - Y: chunk / widthInChunks, - } - // Multiply up to world scale - v = v.Multiplied(a.ChunkSize) - // Shift by the lower bound - return v.Added(a.LowerBound) -} - -// getNewBounds gets new lower and upper bounds for the world space given a vector -func (a *ChunkBasedAtlas) getNewBounds(v vector.Vector) (lower vector.Vector, upper vector.Vector) { - lower = vector.Min(v, a.LowerBound) - upper = vector.Max(v.Added(vector.Vector{X: 1, Y: 1}), a.UpperBound) - - lower = vector.Vector{ - X: maths.RoundDown(lower.X, a.ChunkSize), - Y: maths.RoundDown(lower.Y, a.ChunkSize), - } - upper = vector.Vector{ - X: maths.RoundUp(upper.X, a.ChunkSize), - Y: maths.RoundUp(upper.Y, a.ChunkSize), - } - return -} - -// worldSpaceToTrunkWithGrow will expand the current atlas for a given world space position if needed -func (a *ChunkBasedAtlas) worldSpaceToChunkWithGrow(v vector.Vector) int { - // If we're within bounds, just return the current chunk - if v.X >= a.LowerBound.X && v.Y >= a.LowerBound.Y && v.X < a.UpperBound.X && v.Y < a.UpperBound.Y { - return a.worldSpaceToChunkIndex(v) - } - - // Calculate the new bounds - lower, upper := a.getNewBounds(v) - size := upper.Added(lower.Negated()) - size = size.Divided(a.ChunkSize) - - // Create the new empty atlas - newAtlas := ChunkBasedAtlas{ - ChunkSize: a.ChunkSize, - LowerBound: lower, - UpperBound: upper, - Chunks: make([]chunk, size.X*size.Y), - terrainNoise: a.terrainNoise, - objectNoise: a.objectNoise, - } - - // 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 - for chunk, chunkData := range a.Chunks { - - // Calculate the chunk ID in the new atlas - origin := a.chunkOriginInWorldSpace(chunk) - newChunk := newAtlas.worldSpaceToChunkIndex(origin) - - // Copy over the old chunk to the new atlas - newAtlas.Chunks[newChunk] = chunkData - } - - // Overwrite the old atlas with this one - *a = newAtlas - - return a.worldSpaceToChunkIndex(v) -} diff --git a/pkg/atlas/atlas_test.go b/pkg/atlas/atlas_test.go index 1803bea..1805d66 100644 --- a/pkg/atlas/atlas_test.go +++ b/pkg/atlas/atlas_test.go @@ -10,14 +10,14 @@ import ( ) func TestAtlas_NewAtlas(t *testing.T) { - a := NewAtlas(1).(*ChunkBasedAtlas) + a := NewChunkAtlas(1).(*ChunkBasedAtlas) assert.NotNil(t, a) assert.Equal(t, 1, a.ChunkSize) assert.Equal(t, 1, len(a.Chunks)) // Should start empty } func TestAtlas_toChunk(t *testing.T) { - a := NewAtlas(1).(*ChunkBasedAtlas) + a := NewChunkAtlas(1).(*ChunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn the chunks @@ -38,7 +38,7 @@ func TestAtlas_toChunk(t *testing.T) { chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -1, Y: 0}) assert.Equal(t, 2, chunkID) - a = NewAtlas(2).(*ChunkBasedAtlas) + a = NewChunkAtlas(2).(*ChunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn the chunks a.QueryPosition(vector.Vector{X: -2, Y: -2}) @@ -58,7 +58,7 @@ func TestAtlas_toChunk(t *testing.T) { chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -2, Y: 1}) assert.Equal(t, 2, chunkID) - a = NewAtlas(2).(*ChunkBasedAtlas) + a = NewChunkAtlas(2).(*ChunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn a 4x4 grid of chunks a.QueryPosition(vector.Vector{X: 3, Y: 3}) @@ -83,7 +83,7 @@ func TestAtlas_toChunk(t *testing.T) { chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -2, Y: 2}) assert.Equal(t, 13, chunkID) - a = NewAtlas(3).(*ChunkBasedAtlas) + a = NewChunkAtlas(3).(*ChunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn a 4x4 grid of chunks a.QueryPosition(vector.Vector{X: 3, Y: 3}) @@ -105,7 +105,7 @@ func TestAtlas_toChunk(t *testing.T) { } func TestAtlas_toWorld(t *testing.T) { - a := NewAtlas(1).(*ChunkBasedAtlas) + a := NewChunkAtlas(1).(*ChunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn some chunks @@ -119,7 +119,7 @@ func TestAtlas_toWorld(t *testing.T) { assert.Equal(t, vector.Vector{X: -1, Y: -1}, a.chunkOriginInWorldSpace(0)) assert.Equal(t, vector.Vector{X: 0, Y: -1}, a.chunkOriginInWorldSpace(1)) - a = NewAtlas(2).(*ChunkBasedAtlas) + a = NewChunkAtlas(2).(*ChunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn the chunks a.QueryPosition(vector.Vector{X: -2, Y: -2}) @@ -133,7 +133,7 @@ func TestAtlas_toWorld(t *testing.T) { assert.Equal(t, vector.Vector{X: -2, Y: -2}, a.chunkOriginInWorldSpace(0)) assert.Equal(t, vector.Vector{X: -2, Y: 0}, a.chunkOriginInWorldSpace(2)) - a = NewAtlas(2).(*ChunkBasedAtlas) + a = NewChunkAtlas(2).(*ChunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn a 4x4 grid of chunks a.QueryPosition(vector.Vector{X: 3, Y: 3}) @@ -152,7 +152,7 @@ func TestAtlas_toWorld(t *testing.T) { assert.Equal(t, vector.Vector{X: -4, Y: -4}, a.chunkOriginInWorldSpace(0)) assert.Equal(t, vector.Vector{X: 2, Y: -2}, a.chunkOriginInWorldSpace(7)) - a = NewAtlas(3).(*ChunkBasedAtlas) + a = NewChunkAtlas(3).(*ChunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn a 4x4 grid of chunks a.QueryPosition(vector.Vector{X: 3, Y: 3}) @@ -167,7 +167,7 @@ func TestAtlas_toWorld(t *testing.T) { } func TestAtlas_GetSetTile(t *testing.T) { - a := NewAtlas(10) + a := NewChunkAtlas(10) assert.NotNil(t, a) // Set the origin tile to 1 and test it @@ -182,7 +182,7 @@ func TestAtlas_GetSetTile(t *testing.T) { } func TestAtlas_GetSetObject(t *testing.T) { - a := NewAtlas(10) + a := NewChunkAtlas(10) assert.NotNil(t, a) // Set the origin tile to 1 and test it @@ -198,7 +198,7 @@ func TestAtlas_GetSetObject(t *testing.T) { func TestAtlas_Grown(t *testing.T) { // Start with a small example - a := NewAtlas(2).(*ChunkBasedAtlas) + a := NewChunkAtlas(2).(*ChunkBasedAtlas) assert.NotNil(t, a) assert.Equal(t, 1, len(a.Chunks)) @@ -233,7 +233,7 @@ func TestAtlas_GetSetCorrect(t *testing.T) { for x := -i * 2; x < i*2; x++ { for y := -i * 2; y < i*2; y++ { - a := NewAtlas(i).(*ChunkBasedAtlas) + a := NewChunkAtlas(i).(*ChunkBasedAtlas) assert.NotNil(t, a) assert.Equal(t, 1, len(a.Chunks)) @@ -251,7 +251,7 @@ func TestAtlas_GetSetCorrect(t *testing.T) { } func TestAtlas_WorldGen(t *testing.T) { - a := NewAtlas(8) + a := NewChunkAtlas(8) // Spawn a large world _, _ = a.QueryPosition(vector.Vector{X: 20, Y: 20}) diff --git a/pkg/atlas/chunkAtlas.go b/pkg/atlas/chunkAtlas.go new file mode 100644 index 0000000..00231af --- /dev/null +++ b/pkg/atlas/chunkAtlas.go @@ -0,0 +1,266 @@ +package atlas + +import ( + "log" + "math/rand" + + "github.com/mdiluz/rove/pkg/maths" + "github.com/mdiluz/rove/pkg/objects" + "github.com/mdiluz/rove/pkg/vector" + "github.com/ojrac/opensimplex-go" +) + +// chunk represents a fixed square grid of tiles +type chunk struct { + // Tiles represents the tiles within the chunk + Tiles []byte `json:"tiles"` + + // Objects represents the objects within the chunk + // only one possible object per tile for now + Objects map[int]objects.Object `json:"objects"` +} + +// ChunkBasedAtlas represents a grid of Chunks +type ChunkBasedAtlas struct { + // Chunks represents all chunks in the world + // This is intentionally not a 2D array so it can be expanded in all directions + Chunks []chunk `json:"chunks"` + + // LowerBound is the origin of the bottom left corner of the current chunks in world space (current chunks cover >= this value) + LowerBound vector.Vector `json:"lowerBound"` + + // UpperBound is the top left corner of the current chunks (curent chunks cover < this value) + UpperBound vector.Vector `json:"upperBound"` + + // ChunkSize is the x/y dimensions of each square chunk + ChunkSize int `json:"chunksize"` + + // terrainNoise describes the noise function for the terrain + terrainNoise opensimplex.Noise + + // terrainNoise describes the noise function for the terrain + objectNoise opensimplex.Noise +} + +const ( + noiseSeed = 1024 + terrainNoiseScale = 6 + objectNoiseScale = 3 +) + +// NewChunkAtlas creates a new empty atlas +func NewChunkAtlas(chunkSize int) Atlas { + // Start up with one chunk + a := ChunkBasedAtlas{ + ChunkSize: chunkSize, + Chunks: make([]chunk, 1), + LowerBound: vector.Vector{X: 0, Y: 0}, + UpperBound: vector.Vector{X: chunkSize, Y: chunkSize}, + terrainNoise: opensimplex.New(noiseSeed), + objectNoise: opensimplex.New(noiseSeed), + } + // Initialise the first chunk + a.populate(0) + return &a +} + +// SetTile sets an individual tile's kind +func (a *ChunkBasedAtlas) SetTile(v vector.Vector, tile Tile) { + c := a.worldSpaceToChunkWithGrow(v) + local := a.worldSpaceToChunkLocal(v) + a.setTile(c, local, byte(tile)) +} + +// SetObject sets the object on a tile +func (a *ChunkBasedAtlas) SetObject(v vector.Vector, obj objects.Object) { + c := a.worldSpaceToChunkWithGrow(v) + local := a.worldSpaceToChunkLocal(v) + a.setObject(c, local, obj) +} + +// QueryPosition will return information for a specific position +func (a *ChunkBasedAtlas) QueryPosition(v vector.Vector) (byte, objects.Object) { + c := a.worldSpaceToChunkWithGrow(v) + local := a.worldSpaceToChunkLocal(v) + a.populate(c) + chunk := a.Chunks[c] + i := a.chunkTileIndex(local) + return chunk.Tiles[i], chunk.Objects[i] +} + +// chunkTileID returns the tile index within a chunk +func (a *ChunkBasedAtlas) chunkTileIndex(local vector.Vector) int { + return local.X + local.Y*a.ChunkSize +} + +// populate will fill a chunk with data +func (a *ChunkBasedAtlas) populate(chunk int) { + c := a.Chunks[chunk] + if c.Tiles != nil { + return + } + + c.Tiles = make([]byte, a.ChunkSize*a.ChunkSize) + c.Objects = make(map[int]objects.Object) + + origin := a.chunkOriginInWorldSpace(chunk) + for i := 0; i < a.ChunkSize; i++ { + for j := 0; j < a.ChunkSize; j++ { + + // Get the terrain noise value for this location + t := a.terrainNoise.Eval2(float64(origin.X+i)/terrainNoiseScale, float64(origin.Y+j)/terrainNoiseScale) + var tile Tile + switch { + case t > 0.5: + tile = TileGravel + case t > 0.05: + tile = TileSand + default: + tile = TileRock + } + c.Tiles[j*a.ChunkSize+i] = byte(tile) + + // Get the object noise value for this location + o := a.objectNoise.Eval2(float64(origin.X+i)/objectNoiseScale, float64(origin.Y+j)/objectNoiseScale) + var obj = objects.None + switch { + case o > 0.6: + obj = objects.LargeRock + case o > 0.5: + obj = objects.SmallRock + } + if obj != objects.None { + c.Objects[j*a.ChunkSize+i] = objects.Object{Type: obj} + } + } + } + + // Set up any objects + for i := 0; i < len(c.Tiles); i++ { + if rand.Intn(16) == 0 { + c.Objects[i] = objects.Object{Type: objects.LargeRock} + } else if rand.Intn(32) == 0 { + c.Objects[i] = objects.Object{Type: objects.SmallRock} + } + } + + a.Chunks[chunk] = c +} + +// setTile sets a tile in a specific chunk +func (a *ChunkBasedAtlas) setTile(chunk int, local vector.Vector, tile byte) { + a.populate(chunk) + c := a.Chunks[chunk] + c.Tiles[a.chunkTileIndex(local)] = tile + a.Chunks[chunk] = c +} + +// setObject sets an object in a specific chunk +func (a *ChunkBasedAtlas) setObject(chunk int, local vector.Vector, object objects.Object) { + a.populate(chunk) + + c := a.Chunks[chunk] + i := a.chunkTileIndex(local) + if object.Type != objects.None { + c.Objects[i] = object + } else { + delete(c.Objects, i) + } + a.Chunks[chunk] = c +} + +// worldSpaceToChunkLocal gets a chunk local coordinate for a tile +func (a *ChunkBasedAtlas) worldSpaceToChunkLocal(v vector.Vector) vector.Vector { + return vector.Vector{X: maths.Pmod(v.X, a.ChunkSize), Y: maths.Pmod(v.Y, a.ChunkSize)} +} + +// worldSpaceToChunkID gets the current chunk ID for a position in the world +func (a *ChunkBasedAtlas) worldSpaceToChunkIndex(v vector.Vector) int { + // Shift the vector by our current min + v = v.Added(a.LowerBound.Negated()) + + // Divide by the current size and floor, to get chunk-scaled vector from the lower bound + v = v.DividedFloor(a.ChunkSize) + + // Calculate the width + width := a.UpperBound.X - a.LowerBound.X + widthInChunks := width / a.ChunkSize + + // Along the corridor and up the stairs + return (v.Y * widthInChunks) + v.X +} + +// chunkOriginInWorldSpace returns the origin of the chunk in world space +func (a *ChunkBasedAtlas) chunkOriginInWorldSpace(chunk int) vector.Vector { + // Calculate the width + width := a.UpperBound.X - a.LowerBound.X + widthInChunks := width / a.ChunkSize + + // Reverse the along the corridor and up the stairs + v := vector.Vector{ + X: chunk % widthInChunks, + Y: chunk / widthInChunks, + } + // Multiply up to world scale + v = v.Multiplied(a.ChunkSize) + // Shift by the lower bound + return v.Added(a.LowerBound) +} + +// getNewBounds gets new lower and upper bounds for the world space given a vector +func (a *ChunkBasedAtlas) getNewBounds(v vector.Vector) (lower vector.Vector, upper vector.Vector) { + lower = vector.Min(v, a.LowerBound) + upper = vector.Max(v.Added(vector.Vector{X: 1, Y: 1}), a.UpperBound) + + lower = vector.Vector{ + X: maths.RoundDown(lower.X, a.ChunkSize), + Y: maths.RoundDown(lower.Y, a.ChunkSize), + } + upper = vector.Vector{ + X: maths.RoundUp(upper.X, a.ChunkSize), + Y: maths.RoundUp(upper.Y, a.ChunkSize), + } + return +} + +// worldSpaceToTrunkWithGrow will expand the current atlas for a given world space position if needed +func (a *ChunkBasedAtlas) worldSpaceToChunkWithGrow(v vector.Vector) int { + // If we're within bounds, just return the current chunk + if v.X >= a.LowerBound.X && v.Y >= a.LowerBound.Y && v.X < a.UpperBound.X && v.Y < a.UpperBound.Y { + return a.worldSpaceToChunkIndex(v) + } + + // Calculate the new bounds + lower, upper := a.getNewBounds(v) + size := upper.Added(lower.Negated()) + size = size.Divided(a.ChunkSize) + + // Create the new empty atlas + newAtlas := ChunkBasedAtlas{ + ChunkSize: a.ChunkSize, + LowerBound: lower, + UpperBound: upper, + Chunks: make([]chunk, size.X*size.Y), + terrainNoise: a.terrainNoise, + objectNoise: a.objectNoise, + } + + // 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 + for chunk, chunkData := range a.Chunks { + + // Calculate the chunk ID in the new atlas + origin := a.chunkOriginInWorldSpace(chunk) + newChunk := newAtlas.worldSpaceToChunkIndex(origin) + + // Copy over the old chunk to the new atlas + newAtlas.Chunks[newChunk] = chunkData + } + + // Overwrite the old atlas with this one + *a = newAtlas + + return a.worldSpaceToChunkIndex(v) +} diff --git a/pkg/game/world.go b/pkg/game/world.go index 89a70e5..f7476fb 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -70,7 +70,7 @@ func NewWorld(chunkSize int) *World { Rovers: make(map[string]Rover), CommandQueue: make(map[string]CommandStream), CommandIncoming: make(map[string]CommandStream), - Atlas: atlas.NewAtlas(chunkSize), + Atlas: atlas.NewChunkAtlas(chunkSize), words: lines, TicksPerDay: 24, CurrentTicks: 0, From 9a7c48ae7828f1fc192b6e820117e2a1b66cd42f Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 16:56:17 +0100 Subject: [PATCH 103/228] Make chunkBasedAtlas private --- pkg/atlas/atlas_test.go | 22 +++++++++++----------- pkg/atlas/chunkAtlas.go | 32 ++++++++++++++++---------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/pkg/atlas/atlas_test.go b/pkg/atlas/atlas_test.go index 1805d66..1b1447e 100644 --- a/pkg/atlas/atlas_test.go +++ b/pkg/atlas/atlas_test.go @@ -10,14 +10,14 @@ import ( ) func TestAtlas_NewAtlas(t *testing.T) { - a := NewChunkAtlas(1).(*ChunkBasedAtlas) + a := NewChunkAtlas(1).(*chunkBasedAtlas) assert.NotNil(t, a) assert.Equal(t, 1, a.ChunkSize) assert.Equal(t, 1, len(a.Chunks)) // Should start empty } func TestAtlas_toChunk(t *testing.T) { - a := NewChunkAtlas(1).(*ChunkBasedAtlas) + a := NewChunkAtlas(1).(*chunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn the chunks @@ -38,7 +38,7 @@ func TestAtlas_toChunk(t *testing.T) { chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -1, Y: 0}) assert.Equal(t, 2, chunkID) - a = NewChunkAtlas(2).(*ChunkBasedAtlas) + a = NewChunkAtlas(2).(*chunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn the chunks a.QueryPosition(vector.Vector{X: -2, Y: -2}) @@ -58,7 +58,7 @@ func TestAtlas_toChunk(t *testing.T) { chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -2, Y: 1}) assert.Equal(t, 2, chunkID) - a = NewChunkAtlas(2).(*ChunkBasedAtlas) + a = NewChunkAtlas(2).(*chunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn a 4x4 grid of chunks a.QueryPosition(vector.Vector{X: 3, Y: 3}) @@ -83,7 +83,7 @@ func TestAtlas_toChunk(t *testing.T) { chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -2, Y: 2}) assert.Equal(t, 13, chunkID) - a = NewChunkAtlas(3).(*ChunkBasedAtlas) + a = NewChunkAtlas(3).(*chunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn a 4x4 grid of chunks a.QueryPosition(vector.Vector{X: 3, Y: 3}) @@ -105,7 +105,7 @@ func TestAtlas_toChunk(t *testing.T) { } func TestAtlas_toWorld(t *testing.T) { - a := NewChunkAtlas(1).(*ChunkBasedAtlas) + a := NewChunkAtlas(1).(*chunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn some chunks @@ -119,7 +119,7 @@ func TestAtlas_toWorld(t *testing.T) { assert.Equal(t, vector.Vector{X: -1, Y: -1}, a.chunkOriginInWorldSpace(0)) assert.Equal(t, vector.Vector{X: 0, Y: -1}, a.chunkOriginInWorldSpace(1)) - a = NewChunkAtlas(2).(*ChunkBasedAtlas) + a = NewChunkAtlas(2).(*chunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn the chunks a.QueryPosition(vector.Vector{X: -2, Y: -2}) @@ -133,7 +133,7 @@ func TestAtlas_toWorld(t *testing.T) { assert.Equal(t, vector.Vector{X: -2, Y: -2}, a.chunkOriginInWorldSpace(0)) assert.Equal(t, vector.Vector{X: -2, Y: 0}, a.chunkOriginInWorldSpace(2)) - a = NewChunkAtlas(2).(*ChunkBasedAtlas) + a = NewChunkAtlas(2).(*chunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn a 4x4 grid of chunks a.QueryPosition(vector.Vector{X: 3, Y: 3}) @@ -152,7 +152,7 @@ func TestAtlas_toWorld(t *testing.T) { assert.Equal(t, vector.Vector{X: -4, Y: -4}, a.chunkOriginInWorldSpace(0)) assert.Equal(t, vector.Vector{X: 2, Y: -2}, a.chunkOriginInWorldSpace(7)) - a = NewChunkAtlas(3).(*ChunkBasedAtlas) + a = NewChunkAtlas(3).(*chunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn a 4x4 grid of chunks a.QueryPosition(vector.Vector{X: 3, Y: 3}) @@ -198,7 +198,7 @@ func TestAtlas_GetSetObject(t *testing.T) { func TestAtlas_Grown(t *testing.T) { // Start with a small example - a := NewChunkAtlas(2).(*ChunkBasedAtlas) + a := NewChunkAtlas(2).(*chunkBasedAtlas) assert.NotNil(t, a) assert.Equal(t, 1, len(a.Chunks)) @@ -233,7 +233,7 @@ func TestAtlas_GetSetCorrect(t *testing.T) { for x := -i * 2; x < i*2; x++ { for y := -i * 2; y < i*2; y++ { - a := NewChunkAtlas(i).(*ChunkBasedAtlas) + a := NewChunkAtlas(i).(*chunkBasedAtlas) assert.NotNil(t, a) assert.Equal(t, 1, len(a.Chunks)) diff --git a/pkg/atlas/chunkAtlas.go b/pkg/atlas/chunkAtlas.go index 00231af..1caac1e 100644 --- a/pkg/atlas/chunkAtlas.go +++ b/pkg/atlas/chunkAtlas.go @@ -20,8 +20,8 @@ type chunk struct { Objects map[int]objects.Object `json:"objects"` } -// ChunkBasedAtlas represents a grid of Chunks -type ChunkBasedAtlas struct { +// chunkBasedAtlas represents a grid of Chunks +type chunkBasedAtlas struct { // Chunks represents all chunks in the world // This is intentionally not a 2D array so it can be expanded in all directions Chunks []chunk `json:"chunks"` @@ -51,7 +51,7 @@ const ( // NewChunkAtlas creates a new empty atlas func NewChunkAtlas(chunkSize int) Atlas { // Start up with one chunk - a := ChunkBasedAtlas{ + a := chunkBasedAtlas{ ChunkSize: chunkSize, Chunks: make([]chunk, 1), LowerBound: vector.Vector{X: 0, Y: 0}, @@ -65,21 +65,21 @@ func NewChunkAtlas(chunkSize int) Atlas { } // SetTile sets an individual tile's kind -func (a *ChunkBasedAtlas) SetTile(v vector.Vector, tile Tile) { +func (a *chunkBasedAtlas) SetTile(v vector.Vector, tile Tile) { c := a.worldSpaceToChunkWithGrow(v) local := a.worldSpaceToChunkLocal(v) a.setTile(c, local, byte(tile)) } // SetObject sets the object on a tile -func (a *ChunkBasedAtlas) SetObject(v vector.Vector, obj objects.Object) { +func (a *chunkBasedAtlas) SetObject(v vector.Vector, obj objects.Object) { c := a.worldSpaceToChunkWithGrow(v) local := a.worldSpaceToChunkLocal(v) a.setObject(c, local, obj) } // QueryPosition will return information for a specific position -func (a *ChunkBasedAtlas) QueryPosition(v vector.Vector) (byte, objects.Object) { +func (a *chunkBasedAtlas) QueryPosition(v vector.Vector) (byte, objects.Object) { c := a.worldSpaceToChunkWithGrow(v) local := a.worldSpaceToChunkLocal(v) a.populate(c) @@ -89,12 +89,12 @@ func (a *ChunkBasedAtlas) QueryPosition(v vector.Vector) (byte, objects.Object) } // chunkTileID returns the tile index within a chunk -func (a *ChunkBasedAtlas) chunkTileIndex(local vector.Vector) int { +func (a *chunkBasedAtlas) chunkTileIndex(local vector.Vector) int { return local.X + local.Y*a.ChunkSize } // populate will fill a chunk with data -func (a *ChunkBasedAtlas) populate(chunk int) { +func (a *chunkBasedAtlas) populate(chunk int) { c := a.Chunks[chunk] if c.Tiles != nil { return @@ -148,7 +148,7 @@ func (a *ChunkBasedAtlas) populate(chunk int) { } // setTile sets a tile in a specific chunk -func (a *ChunkBasedAtlas) setTile(chunk int, local vector.Vector, tile byte) { +func (a *chunkBasedAtlas) setTile(chunk int, local vector.Vector, tile byte) { a.populate(chunk) c := a.Chunks[chunk] c.Tiles[a.chunkTileIndex(local)] = tile @@ -156,7 +156,7 @@ func (a *ChunkBasedAtlas) setTile(chunk int, local vector.Vector, tile byte) { } // setObject sets an object in a specific chunk -func (a *ChunkBasedAtlas) setObject(chunk int, local vector.Vector, object objects.Object) { +func (a *chunkBasedAtlas) setObject(chunk int, local vector.Vector, object objects.Object) { a.populate(chunk) c := a.Chunks[chunk] @@ -170,12 +170,12 @@ func (a *ChunkBasedAtlas) setObject(chunk int, local vector.Vector, object objec } // worldSpaceToChunkLocal gets a chunk local coordinate for a tile -func (a *ChunkBasedAtlas) worldSpaceToChunkLocal(v vector.Vector) vector.Vector { +func (a *chunkBasedAtlas) worldSpaceToChunkLocal(v vector.Vector) vector.Vector { return vector.Vector{X: maths.Pmod(v.X, a.ChunkSize), Y: maths.Pmod(v.Y, a.ChunkSize)} } // worldSpaceToChunkID gets the current chunk ID for a position in the world -func (a *ChunkBasedAtlas) worldSpaceToChunkIndex(v vector.Vector) int { +func (a *chunkBasedAtlas) worldSpaceToChunkIndex(v vector.Vector) int { // Shift the vector by our current min v = v.Added(a.LowerBound.Negated()) @@ -191,7 +191,7 @@ func (a *ChunkBasedAtlas) worldSpaceToChunkIndex(v vector.Vector) int { } // chunkOriginInWorldSpace returns the origin of the chunk in world space -func (a *ChunkBasedAtlas) chunkOriginInWorldSpace(chunk int) vector.Vector { +func (a *chunkBasedAtlas) chunkOriginInWorldSpace(chunk int) vector.Vector { // Calculate the width width := a.UpperBound.X - a.LowerBound.X widthInChunks := width / a.ChunkSize @@ -208,7 +208,7 @@ func (a *ChunkBasedAtlas) chunkOriginInWorldSpace(chunk int) vector.Vector { } // getNewBounds gets new lower and upper bounds for the world space given a vector -func (a *ChunkBasedAtlas) getNewBounds(v vector.Vector) (lower vector.Vector, upper vector.Vector) { +func (a *chunkBasedAtlas) getNewBounds(v vector.Vector) (lower vector.Vector, upper vector.Vector) { lower = vector.Min(v, a.LowerBound) upper = vector.Max(v.Added(vector.Vector{X: 1, Y: 1}), a.UpperBound) @@ -224,7 +224,7 @@ func (a *ChunkBasedAtlas) getNewBounds(v vector.Vector) (lower vector.Vector, up } // worldSpaceToTrunkWithGrow will expand the current atlas for a given world space position if needed -func (a *ChunkBasedAtlas) worldSpaceToChunkWithGrow(v vector.Vector) int { +func (a *chunkBasedAtlas) worldSpaceToChunkWithGrow(v vector.Vector) int { // If we're within bounds, just return the current chunk if v.X >= a.LowerBound.X && v.Y >= a.LowerBound.Y && v.X < a.UpperBound.X && v.Y < a.UpperBound.Y { return a.worldSpaceToChunkIndex(v) @@ -236,7 +236,7 @@ func (a *ChunkBasedAtlas) worldSpaceToChunkWithGrow(v vector.Vector) int { size = size.Divided(a.ChunkSize) // Create the new empty atlas - newAtlas := ChunkBasedAtlas{ + newAtlas := chunkBasedAtlas{ ChunkSize: a.ChunkSize, LowerBound: lower, UpperBound: upper, From d6349d081eaa74e47dacee1008b9cf467f2983fb Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 16:59:55 +0100 Subject: [PATCH 104/228] Clear the tile before warping to it --- pkg/game/world_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/game/world_test.go b/pkg/game/world_test.go index 35c0a22..262a7e9 100644 --- a/pkg/game/world_test.go +++ b/pkg/game/world_test.go @@ -395,6 +395,7 @@ func TestWorld_Broadcast(t *testing.T) { assert.Contains(t, rb.Logs[len(rb.Logs)-1].Text, "ABC", "Rover A should have logged it's broadcast") // Warp B outside of the range of A + world.Atlas.SetObject(vector.Vector{X: ra.Range, Y: 0}, objects.Object{Type: objects.None}) assert.NoError(t, world.WarpRover(b, vector.Vector{X: ra.Range, Y: 0})) // Broadcast from a again @@ -411,6 +412,7 @@ func TestWorld_Broadcast(t *testing.T) { assert.Contains(t, rb.Logs[len(rb.Logs)-1].Text, "XYZ", "Rover A should have logged it's broadcast") // Warp B outside of the range of A + world.Atlas.SetObject(vector.Vector{X: ra.Range + 1, Y: 0}, objects.Object{Type: objects.None}) assert.NoError(t, world.WarpRover(b, vector.Vector{X: ra.Range + 1, Y: 0})) // Broadcast from a again From c1267829ac6b95834cf41a925fe7fe5ef9b29bb6 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 17:00:30 +0100 Subject: [PATCH 105/228] Clear out genproto mod require --- go.mod | 1 - 1 file changed, 1 deletion(-) diff --git a/go.mod b/go.mod index db01c84..32caba4 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,6 @@ require ( golang.org/x/net v0.0.0-20200602114024-627f9648deb9 golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 // indirect golang.org/x/text v0.3.3 // indirect - google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 google.golang.org/grpc v1.30.0 google.golang.org/protobuf v1.25.0 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect From dc2800fa5461de76f35e12a12c361c9e20a18ea1 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 17:09:47 +0100 Subject: [PATCH 106/228] Move Accountant behind an interface --- cmd/rove-server/internal/server.go | 4 +- pkg/accounts/accounts.go | 93 +++++------------------------- pkg/accounts/accounts_test.go | 9 +-- pkg/accounts/simpleAccountant.go | 90 +++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 85 deletions(-) create mode 100644 pkg/accounts/simpleAccountant.go diff --git a/cmd/rove-server/internal/server.go b/cmd/rove-server/internal/server.go index ff98f76..a38e20d 100644 --- a/cmd/rove-server/internal/server.go +++ b/cmd/rove-server/internal/server.go @@ -29,7 +29,7 @@ type Server struct { world *game.World // Accountant - accountant *accounts.Accountant + accountant accounts.Accountant // gRPC server netListener net.Listener @@ -81,7 +81,7 @@ func NewServer(opts ...ServerOption) *Server { persistence: EphemeralData, schedule: cron.New(), world: game.NewWorld(32), - accountant: accounts.NewAccountant(), + accountant: accounts.NewSimpleAccountant(), } // Apply all options diff --git a/pkg/accounts/accounts.go b/pkg/accounts/accounts.go index 08f3ee3..69508c0 100644 --- a/pkg/accounts/accounts.go +++ b/pkg/accounts/accounts.go @@ -1,11 +1,22 @@ package accounts -import ( - "fmt" - "time" +// Accountant decribes something that stores accounts and account values +type Accountant interface { + // RegisterAccount will register a new account and return it's info + RegisterAccount(name string) (acc Account, err error) - "github.com/google/uuid" -) + // AssignData stores a custom account key value pair + AssignData(account string, key string, value string) error + + // GetValue returns custom account data for a specific key + GetValue(account string, key string) (string, error) + + // VerifySecret will verify whether the account secret matches with the + VerifySecret(account string, secret string) (bool, error) + + // GetSecret gets the secret associated with an account + GetSecret(account string) (string, error) +} // Account represents a registered user type Account struct { @@ -15,75 +26,3 @@ type Account struct { // Data represents internal account data Data map[string]string `json:"data"` } - -// Accountant manages a set of accounts -type Accountant struct { - Accounts map[string]Account `json:"accounts"` -} - -// NewAccountant creates a new accountant -func NewAccountant() *Accountant { - return &Accountant{ - Accounts: make(map[string]Account), - } -} - -// RegisterAccount adds an account to the set of internal accounts -func (a *Accountant) RegisterAccount(name string) (acc Account, err error) { - - // Set up the account info - acc.Name = name - acc.Data = make(map[string]string) - - // Verify this acount isn't already registered - for _, a := range a.Accounts { - if a.Name == acc.Name { - return Account{}, fmt.Errorf("account name already registered: %s", a.Name) - } - } - - // Set the creation time - acc.Data["created"] = time.Now().String() - - // Create a secret - acc.Data["secret"] = uuid.New().String() - - // Simply add the account to the map - a.Accounts[acc.Name] = acc - - return -} - -// VerifySecret verifies if an account secret is correct -func (a *Accountant) VerifySecret(account string, secret string) (bool, error) { - // Find the account matching the ID - if this, ok := a.Accounts[account]; ok { - return this.Data["secret"] == secret, nil - } - - return false, fmt.Errorf("no account found for id: %s", account) -} - -// AssignData assigns data to an account -func (a *Accountant) AssignData(account string, key string, value string) error { - - // Find the account matching the ID - if this, ok := a.Accounts[account]; ok { - this.Data[key] = value - a.Accounts[account] = this - } else { - return fmt.Errorf("no account found for id: %s", account) - } - - return nil -} - -// GetValue gets the rover rover for the account -func (a *Accountant) GetValue(account string, key string) (string, error) { - // Find the account matching the ID - this, ok := a.Accounts[account] - if !ok { - return "", fmt.Errorf("no account found for id: %s", account) - } - return this.Data[key], nil -} diff --git a/pkg/accounts/accounts_test.go b/pkg/accounts/accounts_test.go index 893c57d..bd2416f 100644 --- a/pkg/accounts/accounts_test.go +++ b/pkg/accounts/accounts_test.go @@ -8,7 +8,7 @@ import ( func TestNewAccountant(t *testing.T) { // Very basic verify here for now - accountant := NewAccountant() + accountant := NewSimpleAccountant() if accountant == nil { t.Error("Failed to create accountant") } @@ -16,7 +16,7 @@ func TestNewAccountant(t *testing.T) { func TestAccountant_RegisterAccount(t *testing.T) { - accountant := NewAccountant() + accountant := NewSimpleAccountant() // Start by making two accounts @@ -44,10 +44,7 @@ func TestAccountant_RegisterAccount(t *testing.T) { } func TestAccountant_AssignGetData(t *testing.T) { - accountant := NewAccountant() - if len(accountant.Accounts) != 0 { - t.Error("New accountant created with non-zero account number") - } + accountant := NewSimpleAccountant() name := uuid.New().String() a, err := accountant.RegisterAccount(name) diff --git a/pkg/accounts/simpleAccountant.go b/pkg/accounts/simpleAccountant.go new file mode 100644 index 0000000..023fe2f --- /dev/null +++ b/pkg/accounts/simpleAccountant.go @@ -0,0 +1,90 @@ +package accounts + +import ( + "fmt" + "time" + + "github.com/google/uuid" +) + +// SimpleAccountant manages a set of accounts +type SimpleAccountant struct { + Accounts map[string]Account `json:"accounts"` +} + +// NewSimpleAccountant creates a new accountant +func NewSimpleAccountant() Accountant { + return &SimpleAccountant{ + Accounts: make(map[string]Account), + } +} + +// RegisterAccount adds an account to the set of internal accounts +func (a *SimpleAccountant) RegisterAccount(name string) (acc Account, err error) { + + // Set up the account info + acc.Name = name + acc.Data = make(map[string]string) + + // Verify this acount isn't already registered + for _, a := range a.Accounts { + if a.Name == acc.Name { + return Account{}, fmt.Errorf("account name already registered: %s", a.Name) + } + } + + // Set the creation time + acc.Data["created"] = time.Now().String() + + // Create a secret + acc.Data["secret"] = uuid.New().String() + + // Simply add the account to the map + a.Accounts[acc.Name] = acc + + return +} + +// VerifySecret verifies if an account secret is correct +func (a *SimpleAccountant) VerifySecret(account string, secret string) (bool, error) { + // Find the account matching the ID + if this, ok := a.Accounts[account]; ok { + return this.Data["secret"] == secret, nil + } + + return false, fmt.Errorf("no account found for id: %s", account) +} + +// GetSecret gets the internal secret +func (a *SimpleAccountant) GetSecret(account string) (string, error) { + // Find the account matching the ID + if this, ok := a.Accounts[account]; ok { + return this.Data["secret"], nil + } + + return "", fmt.Errorf("no account found for id: %s", account) +} + +// AssignData assigns data to an account +func (a *SimpleAccountant) AssignData(account string, key string, value string) error { + + // Find the account matching the ID + if this, ok := a.Accounts[account]; ok { + this.Data[key] = value + a.Accounts[account] = this + } else { + return fmt.Errorf("no account found for id: %s", account) + } + + return nil +} + +// GetValue gets the rover rover for the account +func (a *SimpleAccountant) GetValue(account string, key string) (string, error) { + // Find the account matching the ID + this, ok := a.Accounts[account] + if !ok { + return "", fmt.Errorf("no account found for id: %s", account) + } + return this.Data[key], nil +} From b451ea519deb0c05668b3b47d3f0e1de57e18d67 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 17:21:59 +0100 Subject: [PATCH 107/228] Make sure the accounts are saved as well --- cmd/rove-server/internal/server.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/rove-server/internal/server.go b/cmd/rove-server/internal/server.go index a38e20d..5ccd004 100644 --- a/cmd/rove-server/internal/server.go +++ b/cmd/rove-server/internal/server.go @@ -189,7 +189,7 @@ func (s *Server) SaveWorld() error { if s.persistence == PersistentData { s.world.RLock() defer s.world.RUnlock() - if err := persistence.SaveAll("world", s.world); err != nil { + if err := persistence.SaveAll("world", s.world, "accounts", s.accountant); err != nil { return fmt.Errorf("failed to save out persistent data: %s", err) } } @@ -201,7 +201,7 @@ func (s *Server) LoadWorld() error { if s.persistence == PersistentData { s.world.Lock() defer s.world.Unlock() - if err := persistence.LoadAll("world", &s.world); err != nil { + if err := persistence.LoadAll("world", &s.world, "accounts", &s.accountant); err != nil { return err } } From b534ac0516947030772da2f3197288d38df10e15 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 18:01:35 +0100 Subject: [PATCH 108/228] Rename generated rove package to roveapi and the game package to rove --- Makefile | 4 +- README.md | 2 +- cmd/rove-server/internal/routes.go | 60 +-- cmd/rove-server/internal/server.go | 8 +- cmd/rove/main.go | 40 +- pkg/{game => rove}/command.go | 6 +- pkg/{game => rove}/command_test.go | 10 +- pkg/{game => rove}/rover.go | 2 +- pkg/{game => rove}/world.go | 24 +- pkg/{game => rove}/world_test.go | 8 +- .../rove.pb.go => roveapi/roveapi.pb.go} | 495 +++++++++--------- .../rove.proto => roveapi/roveapi.proto} | 4 +- 12 files changed, 334 insertions(+), 329 deletions(-) rename pkg/{game => rove}/command.go (75%) rename pkg/{game => rove}/command_test.go (85%) rename pkg/{game => rove}/rover.go (99%) rename pkg/{game => rove}/world.go (97%) rename pkg/{game => rove}/world_test.go (98%) rename pkg/{rove/rove.pb.go => roveapi/roveapi.pb.go} (65%) rename proto/{rove/rove.proto => roveapi/roveapi.proto} (98%) diff --git a/Makefile b/Makefile index 0ef8cd7..b28ac4f 100644 --- a/Makefile +++ b/Makefile @@ -18,8 +18,8 @@ gen: github.com/golang/protobuf/protoc-gen-go go mod download @echo Generating rove server gRPC and gateway - protoc --proto_path proto --go_out=plugins=grpc,paths=source_relative:pkg/ proto/rove/rove.proto - protoc --proto_path proto --grpc-gateway_out=paths=source_relative:pkg/ proto/rove/rove.proto + protoc --proto_path proto --go_out=plugins=grpc,paths=source_relative:pkg/ proto/roveapi/roveapi.proto + protoc --proto_path proto --grpc-gateway_out=paths=source_relative:pkg/ proto/roveapi/roveapi.proto test: @echo Unit tests diff --git a/README.md b/README.md index 8846cc3..445ecac 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,4 @@ Rove is an asynchronous nomadic game about exploring as part of a loose communit This repository is a [living document](https://github.com/mdiluz/rove/tree/master/docs) of current game design, as well as source code for the `rove-server` deployment and the `rove` command line client. -See [rove.proto](https://github.com/mdiluz/rove/blob/master/proto/rove/rove.proto) for the current server-client API. +See [roveapi.proto](https://github.com/mdiluz/rove/blob/master/proto/rove/roveapi.proto) for the current server-client API. diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index e533cbf..8e8706c 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -5,14 +5,14 @@ import ( "fmt" "log" - "github.com/mdiluz/rove/pkg/game" "github.com/mdiluz/rove/pkg/rove" + "github.com/mdiluz/rove/pkg/roveapi" "github.com/mdiluz/rove/pkg/version" ) // ServerStatus returns the status of the current server to a gRPC request -func (s *Server) ServerStatus(context.Context, *rove.ServerStatusRequest) (*rove.ServerStatusResponse, error) { - response := &rove.ServerStatusResponse{ +func (s *Server) ServerStatus(context.Context, *roveapi.ServerStatusRequest) (*roveapi.ServerStatusResponse, error) { + response := &roveapi.ServerStatusResponse{ Ready: true, Version: version.Version, TickRate: int32(s.minutesPerTick), @@ -28,7 +28,7 @@ func (s *Server) ServerStatus(context.Context, *rove.ServerStatusRequest) (*rove } // 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 *roveapi.RegisterRequest) (*roveapi.RegisterResponse, error) { log.Printf("Handling register request: %s\n", req.Name) if len(req.Name) == 0 { @@ -45,8 +45,8 @@ func (s *Server) Register(ctx context.Context, req *rove.RegisterRequest) (*rove return nil, fmt.Errorf("internal server error when saving world: %s", err) } else { - return &rove.RegisterResponse{ - Account: &rove.Account{ + return &roveapi.RegisterResponse{ + Account: &roveapi.Account{ Name: acc.Name, Secret: acc.Data["secret"], }, @@ -55,7 +55,7 @@ func (s *Server) Register(ctx context.Context, req *rove.RegisterRequest) (*rove } // 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 *roveapi.StatusRequest) (response *roveapi.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 { @@ -77,50 +77,50 @@ func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (response } i, q := s.world.RoverCommands(resp) - var incoming, queued []*rove.Command + var incoming, queued []*roveapi.Command for _, i := range i { - c := &rove.Command{ + c := &roveapi.Command{ Command: i.Command, } switch i.Command { - case rove.CommandType_move: - c.Data = &rove.Command_Bearing{ + case roveapi.CommandType_move: + c.Data = &roveapi.Command_Bearing{ Bearing: i.Bearing, } - case rove.CommandType_broadcast: - c.Data = &rove.Command_Message{ + case roveapi.CommandType_broadcast: + c.Data = &roveapi.Command_Message{ Message: i.Message, } } incoming = append(incoming, c) } for _, q := range q { - c := &rove.Command{ + c := &roveapi.Command{ Command: q.Command, } switch q.Command { - case rove.CommandType_move: - c.Data = &rove.Command_Bearing{ + case roveapi.CommandType_move: + c.Data = &roveapi.Command_Bearing{ Bearing: q.Bearing, } - case rove.CommandType_broadcast: - c.Data = &rove.Command_Message{ + case roveapi.CommandType_broadcast: + c.Data = &roveapi.Command_Message{ Message: q.Message, } } queued = append(queued, c) } - var logs []*rove.Log + var logs []*roveapi.Log for _, log := range rover.Logs { - logs = append(logs, &rove.Log{ + logs = append(logs, &roveapi.Log{ Text: log.Text, Time: fmt.Sprintf("%d", log.Time.Unix()), // proto uses strings under the hood for 64bit ints anyway }) } - response = &rove.StatusResponse{ + response = &roveapi.StatusResponse{ Name: rover.Name, - Position: &rove.Vector{ + Position: &roveapi.Vector{ X: int32(rover.Pos.X), Y: int32(rover.Pos.Y), }, @@ -140,7 +140,7 @@ func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (response } // 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 *roveapi.RadarRequest) (*roveapi.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 { @@ -150,7 +150,7 @@ func (s *Server) Radar(ctx context.Context, req *rove.RadarRequest) (*rove.Radar return nil, fmt.Errorf("Secret incorrect for account %s", req.Account.Name) } - response := &rove.RadarResponse{} + response := &roveapi.RadarResponse{} resp, err := s.accountant.GetValue(req.Account.Name, "rover") if err != nil { @@ -172,7 +172,7 @@ func (s *Server) Radar(ctx context.Context, req *rove.RadarRequest) (*rove.Radar } // 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 *roveapi.CommandRequest) (*roveapi.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 { @@ -187,15 +187,15 @@ func (s *Server) Command(ctx context.Context, req *rove.CommandRequest) (*rove.C return nil, err } - var cmds []game.Command + var cmds []rove.Command for _, c := range req.Commands { - n := game.Command{ + n := rove.Command{ Command: c.Command, } switch c.Command { - case rove.CommandType_move: + case roveapi.CommandType_move: n.Bearing = c.GetBearing() - case rove.CommandType_broadcast: + case roveapi.CommandType_broadcast: n.Message = c.GetMessage() } cmds = append(cmds, n) @@ -205,5 +205,5 @@ func (s *Server) Command(ctx context.Context, req *rove.CommandRequest) (*rove.C return nil, err } - return &rove.CommandResponse{}, nil + return &roveapi.CommandResponse{}, nil } diff --git a/cmd/rove-server/internal/server.go b/cmd/rove-server/internal/server.go index 5ccd004..f633601 100644 --- a/cmd/rove-server/internal/server.go +++ b/cmd/rove-server/internal/server.go @@ -7,9 +7,9 @@ import ( "sync" "github.com/mdiluz/rove/pkg/accounts" - "github.com/mdiluz/rove/pkg/game" "github.com/mdiluz/rove/pkg/persistence" "github.com/mdiluz/rove/pkg/rove" + "github.com/mdiluz/rove/pkg/roveapi" "github.com/robfig/cron" "google.golang.org/grpc" ) @@ -26,7 +26,7 @@ const ( type Server struct { // Internal state - world *game.World + world *rove.World // Accountant accountant accounts.Accountant @@ -80,7 +80,7 @@ func NewServer(opts ...ServerOption) *Server { address: "", persistence: EphemeralData, schedule: cron.New(), - world: game.NewWorld(32), + world: rove.NewWorld(32), accountant: accounts.NewSimpleAccountant(), } @@ -109,7 +109,7 @@ func (s *Server) Initialise(fillWorld bool) (err error) { log.Fatalf("failed to listen: %v", err) } s.grpcServ = grpc.NewServer() - rove.RegisterRoveServer(s.grpcServ, s) + roveapi.RegisterRoveServer(s.grpcServ, s) return nil } diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 5f51e32..af48a61 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -13,7 +13,7 @@ import ( "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/bearing" "github.com/mdiluz/rove/pkg/objects" - "github.com/mdiluz/rove/pkg/rove" + "github.com/mdiluz/rove/pkg/roveapi" "github.com/mdiluz/rove/pkg/version" "golang.org/x/net/context" "google.golang.org/grpc" @@ -66,7 +66,7 @@ func ConfigPath() string { if len(override) > 0 { datapath = override } - datapath = path.Join(datapath, "rove.json") + datapath = path.Join(datapath, "roveapi.json") return datapath } @@ -163,14 +163,14 @@ func InnerMain(command string, args ...string) error { if err != nil { return err } - var client = rove.NewRoveClient(clientConn) + var client = roveapi.NewRoveClient(clientConn) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() // Handle all the commands switch command { case "server-status": - response, err := client.ServerStatus(ctx, &rove.ServerStatusRequest{}) + response, err := client.ServerStatus(ctx, &roveapi.ServerStatusRequest{}) switch { case err != nil: return err @@ -188,7 +188,7 @@ func InnerMain(command string, args ...string) error { return fmt.Errorf("must pass name to 'register'") } - resp, err := client.Register(ctx, &rove.RegisterRequest{ + resp, err := client.Register(ctx, &roveapi.RegisterRequest{ Name: args[0], }) switch { @@ -209,7 +209,7 @@ func InnerMain(command string, args ...string) error { } // Iterate through each command - var commands []*rove.Command + var commands []*roveapi.Command for i := 0; i < len(args); i++ { switch args[i] { case "move": @@ -220,9 +220,9 @@ func InnerMain(command string, args ...string) error { return err } commands = append(commands, - &rove.Command{ - Command: rove.CommandType_move, - Data: &rove.Command_Bearing{Bearing: args[i]}, + &roveapi.Command{ + Command: roveapi.CommandType_move, + Data: &roveapi.Command_Bearing{Bearing: args[i]}, }, ) case "broadcast": @@ -233,23 +233,23 @@ func InnerMain(command string, args ...string) error { return fmt.Errorf("broadcast command must be given ASCII triplet of 3 or less: %s", args[i]) } commands = append(commands, - &rove.Command{ - Command: rove.CommandType_broadcast, - Data: &rove.Command_Message{Message: []byte(args[i])}, + &roveapi.Command{ + Command: roveapi.CommandType_broadcast, + Data: &roveapi.Command_Message{Message: []byte(args[i])}, }, ) default: // By default just use the command literally commands = append(commands, - &rove.Command{ - Command: rove.CommandType(rove.CommandType_value[args[i]]), + &roveapi.Command{ + Command: roveapi.CommandType(roveapi.CommandType_value[args[i]]), }, ) } } - _, err := client.Command(ctx, &rove.CommandRequest{ - Account: &rove.Account{ + _, err := client.Command(ctx, &roveapi.CommandRequest{ + Account: &roveapi.Account{ Name: config.Account.Name, Secret: config.Account.Secret, }, @@ -269,8 +269,8 @@ func InnerMain(command string, args ...string) error { return err } - response, err := client.Radar(ctx, &rove.RadarRequest{ - Account: &rove.Account{ + response, err := client.Radar(ctx, &roveapi.RadarRequest{ + Account: &roveapi.Account{ Name: config.Account.Name, Secret: config.Account.Secret, }, @@ -306,8 +306,8 @@ func InnerMain(command string, args ...string) error { return err } - response, err := client.Status(ctx, &rove.StatusRequest{ - Account: &rove.Account{ + response, err := client.Status(ctx, &roveapi.StatusRequest{ + Account: &roveapi.Account{ Name: config.Account.Name, Secret: config.Account.Secret, }, diff --git a/pkg/game/command.go b/pkg/rove/command.go similarity index 75% rename from pkg/game/command.go rename to pkg/rove/command.go index b57f678..6016555 100644 --- a/pkg/game/command.go +++ b/pkg/rove/command.go @@ -1,10 +1,10 @@ -package game +package rove -import "github.com/mdiluz/rove/pkg/rove" +import "github.com/mdiluz/rove/pkg/roveapi" // Command represends a single command to execute type Command struct { - Command rove.CommandType `json:"command"` + Command roveapi.CommandType `json:"command"` // Used in the move command Bearing string `json:"bearing,omitempty"` diff --git a/pkg/game/command_test.go b/pkg/rove/command_test.go similarity index 85% rename from pkg/game/command_test.go rename to pkg/rove/command_test.go index 10ccbe5..f4f6bd9 100644 --- a/pkg/game/command_test.go +++ b/pkg/rove/command_test.go @@ -1,9 +1,9 @@ -package game +package rove import ( "testing" - "github.com/mdiluz/rove/pkg/rove" + "github.com/mdiluz/rove/pkg/roveapi" "github.com/mdiluz/rove/pkg/vector" "github.com/stretchr/testify/assert" ) @@ -21,7 +21,7 @@ func TestCommand_Move(t *testing.T) { assert.NoError(t, err, "Failed to set position for rover") // Try the move command - moveCommand := Command{Command: rove.CommandType_move, Bearing: "N"} + moveCommand := Command{Command: roveapi.CommandType_move, Bearing: "N"} assert.NoError(t, world.Enqueue(a, moveCommand), "Failed to execute move command") // Tick the world @@ -47,7 +47,7 @@ func TestCommand_Recharge(t *testing.T) { assert.NoError(t, err, "Failed to set position for rover") // Move to use up some charge - moveCommand := Command{Command: rove.CommandType_move, Bearing: "N"} + moveCommand := Command{Command: roveapi.CommandType_move, Bearing: "N"} assert.NoError(t, world.Enqueue(a, moveCommand), "Failed to queue move command") // Tick the world @@ -57,7 +57,7 @@ func TestCommand_Recharge(t *testing.T) { rover, _ := world.GetRover(a) assert.Equal(t, rover.MaximumCharge-1, rover.Charge) - chargeCommand := Command{Command: rove.CommandType_recharge} + chargeCommand := Command{Command: roveapi.CommandType_recharge} assert.NoError(t, world.Enqueue(a, chargeCommand), "Failed to queue recharge command") // Tick the world diff --git a/pkg/game/rover.go b/pkg/rove/rover.go similarity index 99% rename from pkg/game/rover.go rename to pkg/rove/rover.go index 693ba9a..9ab0401 100644 --- a/pkg/game/rover.go +++ b/pkg/rove/rover.go @@ -1,4 +1,4 @@ -package game +package rove import ( "fmt" diff --git a/pkg/game/world.go b/pkg/rove/world.go similarity index 97% rename from pkg/game/world.go rename to pkg/rove/world.go index f7476fb..490747b 100644 --- a/pkg/game/world.go +++ b/pkg/rove/world.go @@ -1,4 +1,4 @@ -package game +package rove import ( "bufio" @@ -12,7 +12,7 @@ import ( "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/bearing" "github.com/mdiluz/rove/pkg/objects" - "github.com/mdiluz/rove/pkg/rove" + "github.com/mdiluz/rove/pkg/roveapi" "github.com/mdiluz/rove/pkg/vector" ) @@ -430,11 +430,11 @@ func (w *World) Enqueue(rover string, commands ...Command) error { // First validate the commands for _, c := range commands { switch c.Command { - case rove.CommandType_move: + case roveapi.CommandType_move: if _, err := bearing.FromString(c.Bearing); err != nil { return fmt.Errorf("unknown bearing: %s", c.Bearing) } - case rove.CommandType_broadcast: + case roveapi.CommandType_broadcast: if len(c.Message) > 3 { return fmt.Errorf("too many characters in message (limit 3): %d", len(c.Message)) } @@ -443,9 +443,9 @@ func (w *World) Enqueue(rover string, commands ...Command) error { return fmt.Errorf("invalid message character: %c", b) } } - case rove.CommandType_stash: - case rove.CommandType_repair: - case rove.CommandType_recharge: + case roveapi.CommandType_stash: + case roveapi.CommandType_repair: + case roveapi.CommandType_recharge: // Nothing to verify default: return fmt.Errorf("unknown command: %s", c.Command) @@ -509,19 +509,19 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { log.Printf("Executing command: %+v for %s\n", *c, rover) switch c.Command { - case rove.CommandType_move: + case roveapi.CommandType_move: if dir, err := bearing.FromString(c.Bearing); err != nil { return err } else if _, err := w.MoveRover(rover, dir); err != nil { return err } - case rove.CommandType_stash: + case roveapi.CommandType_stash: if _, err := w.RoverStash(rover); err != nil { return err } - case rove.CommandType_repair: + case roveapi.CommandType_repair: r, err := w.GetRover(rover) if err != nil { return err @@ -533,12 +533,12 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { r.AddLogEntryf("repaired self to %d", r.Integrity) w.Rovers[rover] = r } - case rove.CommandType_recharge: + case roveapi.CommandType_recharge: _, err := w.RoverRecharge(rover) if err != nil { return err } - case rove.CommandType_broadcast: + case roveapi.CommandType_broadcast: if err := w.RoverBroadcast(rover, c.Message); err != nil { return err } diff --git a/pkg/game/world_test.go b/pkg/rove/world_test.go similarity index 98% rename from pkg/game/world_test.go rename to pkg/rove/world_test.go index 262a7e9..33ae973 100644 --- a/pkg/game/world_test.go +++ b/pkg/rove/world_test.go @@ -1,4 +1,4 @@ -package game +package rove import ( "testing" @@ -6,7 +6,7 @@ import ( "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/bearing" "github.com/mdiluz/rove/pkg/objects" - "github.com/mdiluz/rove/pkg/rove" + "github.com/mdiluz/rove/pkg/roveapi" "github.com/mdiluz/rove/pkg/vector" "github.com/stretchr/testify/assert" ) @@ -273,7 +273,7 @@ func TestWorld_RoverRepair(t *testing.T) { assert.NoError(t, err, "couldn't get rover info") assert.Equal(t, originalInfo.Integrity-1, newinfo.Integrity, "rover should have lost integrity") - err = world.ExecuteCommand(&Command{Command: rove.CommandType_repair}, a) + err = world.ExecuteCommand(&Command{Command: roveapi.CommandType_repair}, a) assert.NoError(t, err, "Failed to repair rover") newinfo, err = world.GetRover(a) @@ -287,7 +287,7 @@ func TestWorld_RoverRepair(t *testing.T) { assert.NoError(t, err, "Failed to stash") assert.Equal(t, objects.SmallRock, o, "Failed to get correct object") - err = world.ExecuteCommand(&Command{Command: rove.CommandType_repair}, a) + err = world.ExecuteCommand(&Command{Command: roveapi.CommandType_repair}, a) assert.NoError(t, err, "Failed to repair rover") newinfo, err = world.GetRover(a) diff --git a/pkg/rove/rove.pb.go b/pkg/roveapi/roveapi.pb.go similarity index 65% rename from pkg/rove/rove.pb.go rename to pkg/roveapi/roveapi.pb.go index 2186fd9..491231d 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/roveapi/roveapi.pb.go @@ -2,14 +2,14 @@ // versions: // protoc-gen-go v1.25.0 // protoc v3.6.1 -// source: rove/rove.proto +// source: roveapi/roveapi.proto // Rove // // Rove is an asychronous nomadic game about exploring a planet as part of a // loose community -package rove +package roveapi import ( context "context" @@ -82,11 +82,11 @@ func (x CommandType) String() string { } func (CommandType) Descriptor() protoreflect.EnumDescriptor { - return file_rove_rove_proto_enumTypes[0].Descriptor() + return file_roveapi_roveapi_proto_enumTypes[0].Descriptor() } func (CommandType) Type() protoreflect.EnumType { - return &file_rove_rove_proto_enumTypes[0] + return &file_roveapi_roveapi_proto_enumTypes[0] } func (x CommandType) Number() protoreflect.EnumNumber { @@ -95,7 +95,7 @@ func (x CommandType) Number() protoreflect.EnumNumber { // Deprecated: Use CommandType.Descriptor instead. func (CommandType) EnumDescriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{0} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{0} } // ServerStatusRequest is an empty placeholder @@ -108,7 +108,7 @@ type ServerStatusRequest struct { func (x *ServerStatusRequest) Reset() { *x = ServerStatusRequest{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[0] + mi := &file_roveapi_roveapi_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -121,7 +121,7 @@ func (x *ServerStatusRequest) String() string { func (*ServerStatusRequest) ProtoMessage() {} func (x *ServerStatusRequest) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[0] + mi := &file_roveapi_roveapi_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -134,7 +134,7 @@ func (x *ServerStatusRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ServerStatusRequest.ProtoReflect.Descriptor instead. func (*ServerStatusRequest) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{0} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{0} } // ServerStatusResponse is a response with useful server information @@ -158,7 +158,7 @@ type ServerStatusResponse struct { func (x *ServerStatusResponse) Reset() { *x = ServerStatusResponse{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[1] + mi := &file_roveapi_roveapi_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -171,7 +171,7 @@ func (x *ServerStatusResponse) String() string { func (*ServerStatusResponse) ProtoMessage() {} func (x *ServerStatusResponse) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[1] + mi := &file_roveapi_roveapi_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -184,7 +184,7 @@ func (x *ServerStatusResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ServerStatusResponse.ProtoReflect.Descriptor instead. func (*ServerStatusResponse) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{1} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{1} } func (x *ServerStatusResponse) GetVersion() string { @@ -235,7 +235,7 @@ type RegisterRequest struct { func (x *RegisterRequest) Reset() { *x = RegisterRequest{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[2] + mi := &file_roveapi_roveapi_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -248,7 +248,7 @@ func (x *RegisterRequest) String() string { func (*RegisterRequest) ProtoMessage() {} func (x *RegisterRequest) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[2] + mi := &file_roveapi_roveapi_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -261,7 +261,7 @@ func (x *RegisterRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RegisterRequest.ProtoReflect.Descriptor instead. func (*RegisterRequest) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{2} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{2} } func (x *RegisterRequest) GetName() string { @@ -286,7 +286,7 @@ type Account struct { func (x *Account) Reset() { *x = Account{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[3] + mi := &file_roveapi_roveapi_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -299,7 +299,7 @@ func (x *Account) String() string { func (*Account) ProtoMessage() {} func (x *Account) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[3] + mi := &file_roveapi_roveapi_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -312,7 +312,7 @@ func (x *Account) ProtoReflect() protoreflect.Message { // Deprecated: Use Account.ProtoReflect.Descriptor instead. func (*Account) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{3} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{3} } func (x *Account) GetName() string { @@ -342,7 +342,7 @@ type RegisterResponse struct { func (x *RegisterResponse) Reset() { *x = RegisterResponse{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[4] + mi := &file_roveapi_roveapi_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -355,7 +355,7 @@ func (x *RegisterResponse) String() string { func (*RegisterResponse) ProtoMessage() {} func (x *RegisterResponse) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[4] + mi := &file_roveapi_roveapi_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -368,7 +368,7 @@ func (x *RegisterResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RegisterResponse.ProtoReflect.Descriptor instead. func (*RegisterResponse) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{4} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{4} } func (x *RegisterResponse) GetAccount() *Account { @@ -385,7 +385,7 @@ type Command struct { unknownFields protoimpl.UnknownFields // The command type - Command CommandType `protobuf:"varint,1,opt,name=command,proto3,enum=rove.CommandType" json:"command,omitempty"` + Command CommandType `protobuf:"varint,1,opt,name=command,proto3,enum=roveapi.CommandType" json:"command,omitempty"` // Types that are assignable to Data: // *Command_Bearing // *Command_Message @@ -395,7 +395,7 @@ type Command struct { func (x *Command) Reset() { *x = Command{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[5] + mi := &file_roveapi_roveapi_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -408,7 +408,7 @@ func (x *Command) String() string { func (*Command) ProtoMessage() {} func (x *Command) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[5] + mi := &file_roveapi_roveapi_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -421,7 +421,7 @@ func (x *Command) ProtoReflect() protoreflect.Message { // Deprecated: Use Command.ProtoReflect.Descriptor instead. func (*Command) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{5} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{5} } func (x *Command) GetCommand() CommandType { @@ -488,7 +488,7 @@ type CommandRequest struct { func (x *CommandRequest) Reset() { *x = CommandRequest{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[6] + mi := &file_roveapi_roveapi_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -501,7 +501,7 @@ func (x *CommandRequest) String() string { func (*CommandRequest) ProtoMessage() {} func (x *CommandRequest) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[6] + mi := &file_roveapi_roveapi_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -514,7 +514,7 @@ func (x *CommandRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CommandRequest.ProtoReflect.Descriptor instead. func (*CommandRequest) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{6} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{6} } func (x *CommandRequest) GetAccount() *Account { @@ -541,7 +541,7 @@ type CommandResponse struct { func (x *CommandResponse) Reset() { *x = CommandResponse{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[7] + mi := &file_roveapi_roveapi_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -554,7 +554,7 @@ func (x *CommandResponse) String() string { func (*CommandResponse) ProtoMessage() {} func (x *CommandResponse) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[7] + mi := &file_roveapi_roveapi_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -567,7 +567,7 @@ func (x *CommandResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CommandResponse.ProtoReflect.Descriptor instead. func (*CommandResponse) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{7} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{7} } // RadarRequest is the data needed to request the radar for a rover @@ -583,7 +583,7 @@ type RadarRequest struct { func (x *RadarRequest) Reset() { *x = RadarRequest{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[8] + mi := &file_roveapi_roveapi_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -596,7 +596,7 @@ func (x *RadarRequest) String() string { func (*RadarRequest) ProtoMessage() {} func (x *RadarRequest) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[8] + mi := &file_roveapi_roveapi_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -609,7 +609,7 @@ func (x *RadarRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RadarRequest.ProtoReflect.Descriptor instead. func (*RadarRequest) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{8} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{8} } func (x *RadarRequest) GetAccount() *Account { @@ -637,7 +637,7 @@ type RadarResponse struct { func (x *RadarResponse) Reset() { *x = RadarResponse{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[9] + mi := &file_roveapi_roveapi_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -650,7 +650,7 @@ func (x *RadarResponse) String() string { func (*RadarResponse) ProtoMessage() {} func (x *RadarResponse) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[9] + mi := &file_roveapi_roveapi_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -663,7 +663,7 @@ func (x *RadarResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RadarResponse.ProtoReflect.Descriptor instead. func (*RadarResponse) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{9} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{9} } func (x *RadarResponse) GetRange() int32 { @@ -700,7 +700,7 @@ type StatusRequest struct { func (x *StatusRequest) Reset() { *x = StatusRequest{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[10] + mi := &file_roveapi_roveapi_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -713,7 +713,7 @@ func (x *StatusRequest) String() string { func (*StatusRequest) ProtoMessage() {} func (x *StatusRequest) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[10] + mi := &file_roveapi_roveapi_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -726,7 +726,7 @@ func (x *StatusRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use StatusRequest.ProtoReflect.Descriptor instead. func (*StatusRequest) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{10} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{10} } func (x *StatusRequest) GetAccount() *Account { @@ -751,7 +751,7 @@ type Log struct { func (x *Log) Reset() { *x = Log{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[11] + mi := &file_roveapi_roveapi_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -764,7 +764,7 @@ func (x *Log) String() string { func (*Log) ProtoMessage() {} func (x *Log) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[11] + mi := &file_roveapi_roveapi_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -777,7 +777,7 @@ func (x *Log) ProtoReflect() protoreflect.Message { // Deprecated: Use Log.ProtoReflect.Descriptor instead. func (*Log) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{11} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{11} } func (x *Log) GetTime() string { @@ -807,7 +807,7 @@ type Vector struct { func (x *Vector) Reset() { *x = Vector{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[12] + mi := &file_roveapi_roveapi_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -820,7 +820,7 @@ func (x *Vector) String() string { func (*Vector) ProtoMessage() {} func (x *Vector) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[12] + mi := &file_roveapi_roveapi_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -833,7 +833,7 @@ func (x *Vector) ProtoReflect() protoreflect.Message { // Deprecated: Use Vector.ProtoReflect.Descriptor instead. func (*Vector) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{12} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{12} } func (x *Vector) GetX() int32 { @@ -885,7 +885,7 @@ type StatusResponse struct { func (x *StatusResponse) Reset() { *x = StatusResponse{} if protoimpl.UnsafeEnabled { - mi := &file_rove_rove_proto_msgTypes[13] + mi := &file_roveapi_roveapi_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -898,7 +898,7 @@ func (x *StatusResponse) String() string { func (*StatusResponse) ProtoMessage() {} func (x *StatusResponse) ProtoReflect() protoreflect.Message { - mi := &file_rove_rove_proto_msgTypes[13] + mi := &file_roveapi_roveapi_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -911,7 +911,7 @@ func (x *StatusResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use StatusResponse.ProtoReflect.Descriptor instead. func (*StatusResponse) Descriptor() ([]byte, []int) { - return file_rove_rove_proto_rawDescGZIP(), []int{13} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{13} } func (x *StatusResponse) GetName() string { @@ -998,174 +998,179 @@ func (x *StatusResponse) GetLogs() []*Log { return nil } -var File_rove_rove_proto protoreflect.FileDescriptor +var File_roveapi_roveapi_proto protoreflect.FileDescriptor -var file_rove_rove_proto_rawDesc = []byte{ - 0x0a, 0x0f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x04, 0x72, 0x6f, 0x76, 0x65, 0x22, 0x15, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa1, - 0x01, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, - 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, - 0x61, 0x74, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, - 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, - 0x63, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, - 0x63, 0x6b, 0x22, 0x25, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x35, 0x0a, 0x07, 0x41, 0x63, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x63, 0x72, - 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, - 0x22, 0x3b, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x76, 0x0a, - 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2b, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1a, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, - 0x67, 0x12, 0x1a, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0c, 0x48, 0x00, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x06, 0x0a, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x64, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, - 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x12, 0x29, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x37, - 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, - 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, - 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x55, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x14, - 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, - 0x69, 0x6c, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x38, - 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, - 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, - 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, - 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, - 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, - 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xb7, 0x03, - 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x56, 0x65, - 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, - 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, - 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, - 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, - 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, - 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, - 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, - 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, - 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, - 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, - 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, - 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, - 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x39, 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, - 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, - 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x73, 0x12, 0x35, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x1d, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, - 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x4c, 0x6f, - 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x2a, 0x55, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, - 0x12, 0x08, 0x0a, 0x04, 0x6d, 0x6f, 0x76, 0x65, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, - 0x61, 0x73, 0x68, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, - 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x12, - 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x05, 0x32, 0xb1, - 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x47, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x3b, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, - 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x32, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, - 0x12, 0x12, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x52, 0x61, 0x64, 0x61, - 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x35, 0x0a, 0x06, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x6b, 0x67, - 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +var file_roveapi_roveapi_proto_rawDesc = []byte{ + 0x0a, 0x15, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, + 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x22, 0x15, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa1, 0x01, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, + 0x61, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, + 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x08, 0x74, 0x69, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x12, 0x20, 0x0a, 0x0b, + 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x12, 0x1b, + 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x22, 0x25, 0x0a, 0x0f, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x22, 0x35, 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x22, 0x3e, 0x0a, 0x10, 0x52, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, + 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x79, 0x0a, 0x07, 0x43, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1a, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, + 0x12, 0x1a, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0c, 0x48, 0x00, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x06, 0x0a, 0x04, + 0x64, 0x61, 0x74, 0x61, 0x22, 0x6a, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, + 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, + 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, + 0x55, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, + 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, + 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, + 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xc3, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x56, 0x65, 0x63, 0x74, + 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, + 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, + 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, + 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, + 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, + 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, + 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, + 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, + 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, + 0x61, 0x72, 0x67, 0x65, 0x12, 0x3c, 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x52, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x73, 0x12, 0x38, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, + 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x20, 0x0a, 0x04, + 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x2a, 0x55, + 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, + 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x6d, 0x6f, 0x76, 0x65, 0x10, + 0x01, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, + 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x68, + 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, + 0x61, 0x73, 0x74, 0x10, 0x05, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, + 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, + 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x24, 0x5a, 0x22, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, + 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_rove_rove_proto_rawDescOnce sync.Once - file_rove_rove_proto_rawDescData = file_rove_rove_proto_rawDesc + file_roveapi_roveapi_proto_rawDescOnce sync.Once + file_roveapi_roveapi_proto_rawDescData = file_roveapi_roveapi_proto_rawDesc ) -func file_rove_rove_proto_rawDescGZIP() []byte { - file_rove_rove_proto_rawDescOnce.Do(func() { - file_rove_rove_proto_rawDescData = protoimpl.X.CompressGZIP(file_rove_rove_proto_rawDescData) +func file_roveapi_roveapi_proto_rawDescGZIP() []byte { + file_roveapi_roveapi_proto_rawDescOnce.Do(func() { + file_roveapi_roveapi_proto_rawDescData = protoimpl.X.CompressGZIP(file_roveapi_roveapi_proto_rawDescData) }) - return file_rove_rove_proto_rawDescData + return file_roveapi_roveapi_proto_rawDescData } -var file_rove_rove_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_rove_rove_proto_msgTypes = make([]protoimpl.MessageInfo, 14) -var file_rove_rove_proto_goTypes = []interface{}{ - (CommandType)(0), // 0: rove.CommandType - (*ServerStatusRequest)(nil), // 1: rove.ServerStatusRequest - (*ServerStatusResponse)(nil), // 2: rove.ServerStatusResponse - (*RegisterRequest)(nil), // 3: rove.RegisterRequest - (*Account)(nil), // 4: rove.Account - (*RegisterResponse)(nil), // 5: rove.RegisterResponse - (*Command)(nil), // 6: rove.Command - (*CommandRequest)(nil), // 7: rove.CommandRequest - (*CommandResponse)(nil), // 8: rove.CommandResponse - (*RadarRequest)(nil), // 9: rove.RadarRequest - (*RadarResponse)(nil), // 10: rove.RadarResponse - (*StatusRequest)(nil), // 11: rove.StatusRequest - (*Log)(nil), // 12: rove.Log - (*Vector)(nil), // 13: rove.Vector - (*StatusResponse)(nil), // 14: rove.StatusResponse +var file_roveapi_roveapi_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_roveapi_roveapi_proto_msgTypes = make([]protoimpl.MessageInfo, 14) +var file_roveapi_roveapi_proto_goTypes = []interface{}{ + (CommandType)(0), // 0: roveapi.CommandType + (*ServerStatusRequest)(nil), // 1: roveapi.ServerStatusRequest + (*ServerStatusResponse)(nil), // 2: roveapi.ServerStatusResponse + (*RegisterRequest)(nil), // 3: roveapi.RegisterRequest + (*Account)(nil), // 4: roveapi.Account + (*RegisterResponse)(nil), // 5: roveapi.RegisterResponse + (*Command)(nil), // 6: roveapi.Command + (*CommandRequest)(nil), // 7: roveapi.CommandRequest + (*CommandResponse)(nil), // 8: roveapi.CommandResponse + (*RadarRequest)(nil), // 9: roveapi.RadarRequest + (*RadarResponse)(nil), // 10: roveapi.RadarResponse + (*StatusRequest)(nil), // 11: roveapi.StatusRequest + (*Log)(nil), // 12: roveapi.Log + (*Vector)(nil), // 13: roveapi.Vector + (*StatusResponse)(nil), // 14: roveapi.StatusResponse } -var file_rove_rove_proto_depIdxs = []int32{ - 4, // 0: rove.RegisterResponse.account:type_name -> rove.Account - 0, // 1: rove.Command.command:type_name -> rove.CommandType - 4, // 2: rove.CommandRequest.account:type_name -> rove.Account - 6, // 3: rove.CommandRequest.commands:type_name -> rove.Command - 4, // 4: rove.RadarRequest.account:type_name -> rove.Account - 4, // 5: rove.StatusRequest.account:type_name -> rove.Account - 13, // 6: rove.StatusResponse.position:type_name -> rove.Vector - 6, // 7: rove.StatusResponse.incomingCommands:type_name -> rove.Command - 6, // 8: rove.StatusResponse.queuedCommands:type_name -> rove.Command - 12, // 9: rove.StatusResponse.logs:type_name -> rove.Log - 1, // 10: rove.Rove.ServerStatus:input_type -> rove.ServerStatusRequest - 3, // 11: rove.Rove.Register:input_type -> rove.RegisterRequest - 7, // 12: rove.Rove.Command:input_type -> rove.CommandRequest - 9, // 13: rove.Rove.Radar:input_type -> rove.RadarRequest - 11, // 14: rove.Rove.Status:input_type -> rove.StatusRequest - 2, // 15: rove.Rove.ServerStatus:output_type -> rove.ServerStatusResponse - 5, // 16: rove.Rove.Register:output_type -> rove.RegisterResponse - 8, // 17: rove.Rove.Command:output_type -> rove.CommandResponse - 10, // 18: rove.Rove.Radar:output_type -> rove.RadarResponse - 14, // 19: rove.Rove.Status:output_type -> rove.StatusResponse +var file_roveapi_roveapi_proto_depIdxs = []int32{ + 4, // 0: roveapi.RegisterResponse.account:type_name -> roveapi.Account + 0, // 1: roveapi.Command.command:type_name -> roveapi.CommandType + 4, // 2: roveapi.CommandRequest.account:type_name -> roveapi.Account + 6, // 3: roveapi.CommandRequest.commands:type_name -> roveapi.Command + 4, // 4: roveapi.RadarRequest.account:type_name -> roveapi.Account + 4, // 5: roveapi.StatusRequest.account:type_name -> roveapi.Account + 13, // 6: roveapi.StatusResponse.position:type_name -> roveapi.Vector + 6, // 7: roveapi.StatusResponse.incomingCommands:type_name -> roveapi.Command + 6, // 8: roveapi.StatusResponse.queuedCommands:type_name -> roveapi.Command + 12, // 9: roveapi.StatusResponse.logs:type_name -> roveapi.Log + 1, // 10: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest + 3, // 11: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest + 7, // 12: roveapi.Rove.Command:input_type -> roveapi.CommandRequest + 9, // 13: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest + 11, // 14: roveapi.Rove.Status:input_type -> roveapi.StatusRequest + 2, // 15: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse + 5, // 16: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse + 8, // 17: roveapi.Rove.Command:output_type -> roveapi.CommandResponse + 10, // 18: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse + 14, // 19: roveapi.Rove.Status:output_type -> roveapi.StatusResponse 15, // [15:20] is the sub-list for method output_type 10, // [10:15] is the sub-list for method input_type 10, // [10:10] is the sub-list for extension type_name @@ -1173,13 +1178,13 @@ var file_rove_rove_proto_depIdxs = []int32{ 0, // [0:10] is the sub-list for field type_name } -func init() { file_rove_rove_proto_init() } -func file_rove_rove_proto_init() { - if File_rove_rove_proto != nil { +func init() { file_roveapi_roveapi_proto_init() } +func file_roveapi_roveapi_proto_init() { + if File_roveapi_roveapi_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_rove_rove_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_roveapi_roveapi_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ServerStatusRequest); i { case 0: return &v.state @@ -1191,7 +1196,7 @@ func file_rove_rove_proto_init() { return nil } } - file_rove_rove_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_roveapi_roveapi_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ServerStatusResponse); i { case 0: return &v.state @@ -1203,7 +1208,7 @@ func file_rove_rove_proto_init() { return nil } } - file_rove_rove_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_roveapi_roveapi_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RegisterRequest); i { case 0: return &v.state @@ -1215,7 +1220,7 @@ func file_rove_rove_proto_init() { return nil } } - file_rove_rove_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_roveapi_roveapi_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Account); i { case 0: return &v.state @@ -1227,7 +1232,7 @@ func file_rove_rove_proto_init() { return nil } } - file_rove_rove_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_roveapi_roveapi_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RegisterResponse); i { case 0: return &v.state @@ -1239,7 +1244,7 @@ func file_rove_rove_proto_init() { return nil } } - file_rove_rove_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_roveapi_roveapi_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Command); i { case 0: return &v.state @@ -1251,7 +1256,7 @@ func file_rove_rove_proto_init() { return nil } } - file_rove_rove_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_roveapi_roveapi_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*CommandRequest); i { case 0: return &v.state @@ -1263,7 +1268,7 @@ func file_rove_rove_proto_init() { return nil } } - file_rove_rove_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_roveapi_roveapi_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*CommandResponse); i { case 0: return &v.state @@ -1275,7 +1280,7 @@ func file_rove_rove_proto_init() { return nil } } - file_rove_rove_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_roveapi_roveapi_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RadarRequest); i { case 0: return &v.state @@ -1287,7 +1292,7 @@ func file_rove_rove_proto_init() { return nil } } - file_rove_rove_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_roveapi_roveapi_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RadarResponse); i { case 0: return &v.state @@ -1299,7 +1304,7 @@ func file_rove_rove_proto_init() { return nil } } - file_rove_rove_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_roveapi_roveapi_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*StatusRequest); i { case 0: return &v.state @@ -1311,7 +1316,7 @@ func file_rove_rove_proto_init() { return nil } } - file_rove_rove_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_roveapi_roveapi_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Log); i { case 0: return &v.state @@ -1323,7 +1328,7 @@ func file_rove_rove_proto_init() { return nil } } - file_rove_rove_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_roveapi_roveapi_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Vector); i { case 0: return &v.state @@ -1335,7 +1340,7 @@ func file_rove_rove_proto_init() { return nil } } - file_rove_rove_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + file_roveapi_roveapi_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*StatusResponse); i { case 0: return &v.state @@ -1348,7 +1353,7 @@ func file_rove_rove_proto_init() { } } } - file_rove_rove_proto_msgTypes[5].OneofWrappers = []interface{}{ + file_roveapi_roveapi_proto_msgTypes[5].OneofWrappers = []interface{}{ (*Command_Bearing)(nil), (*Command_Message)(nil), } @@ -1356,21 +1361,21 @@ func file_rove_rove_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_rove_rove_proto_rawDesc, + RawDescriptor: file_roveapi_roveapi_proto_rawDesc, NumEnums: 1, NumMessages: 14, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_rove_rove_proto_goTypes, - DependencyIndexes: file_rove_rove_proto_depIdxs, - EnumInfos: file_rove_rove_proto_enumTypes, - MessageInfos: file_rove_rove_proto_msgTypes, + GoTypes: file_roveapi_roveapi_proto_goTypes, + DependencyIndexes: file_roveapi_roveapi_proto_depIdxs, + EnumInfos: file_roveapi_roveapi_proto_enumTypes, + MessageInfos: file_roveapi_roveapi_proto_msgTypes, }.Build() - File_rove_rove_proto = out.File - file_rove_rove_proto_rawDesc = nil - file_rove_rove_proto_goTypes = nil - file_rove_rove_proto_depIdxs = nil + File_roveapi_roveapi_proto = out.File + file_roveapi_roveapi_proto_rawDesc = nil + file_roveapi_roveapi_proto_goTypes = nil + file_roveapi_roveapi_proto_depIdxs = nil } // Reference imports to suppress errors if they are not otherwise used. @@ -1414,7 +1419,7 @@ func NewRoveClient(cc grpc.ClientConnInterface) RoveClient { func (c *roveClient) ServerStatus(ctx context.Context, in *ServerStatusRequest, opts ...grpc.CallOption) (*ServerStatusResponse, error) { out := new(ServerStatusResponse) - err := c.cc.Invoke(ctx, "/rove.Rove/ServerStatus", in, out, opts...) + err := c.cc.Invoke(ctx, "/roveapi.Rove/ServerStatus", in, out, opts...) if err != nil { return nil, err } @@ -1423,7 +1428,7 @@ func (c *roveClient) ServerStatus(ctx context.Context, in *ServerStatusRequest, func (c *roveClient) Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) { out := new(RegisterResponse) - err := c.cc.Invoke(ctx, "/rove.Rove/Register", in, out, opts...) + err := c.cc.Invoke(ctx, "/roveapi.Rove/Register", in, out, opts...) if err != nil { return nil, err } @@ -1432,7 +1437,7 @@ func (c *roveClient) Register(ctx context.Context, in *RegisterRequest, opts ... func (c *roveClient) Command(ctx context.Context, in *CommandRequest, opts ...grpc.CallOption) (*CommandResponse, error) { out := new(CommandResponse) - err := c.cc.Invoke(ctx, "/rove.Rove/Command", in, out, opts...) + err := c.cc.Invoke(ctx, "/roveapi.Rove/Command", in, out, opts...) if err != nil { return nil, err } @@ -1441,7 +1446,7 @@ func (c *roveClient) Command(ctx context.Context, in *CommandRequest, opts ...gr func (c *roveClient) Radar(ctx context.Context, in *RadarRequest, opts ...grpc.CallOption) (*RadarResponse, error) { out := new(RadarResponse) - err := c.cc.Invoke(ctx, "/rove.Rove/Radar", in, out, opts...) + err := c.cc.Invoke(ctx, "/roveapi.Rove/Radar", in, out, opts...) if err != nil { return nil, err } @@ -1450,7 +1455,7 @@ func (c *roveClient) Radar(ctx context.Context, in *RadarRequest, opts ...grpc.C func (c *roveClient) Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) { out := new(StatusResponse) - err := c.cc.Invoke(ctx, "/rove.Rove/Status", in, out, opts...) + err := c.cc.Invoke(ctx, "/roveapi.Rove/Status", in, out, opts...) if err != nil { return nil, err } @@ -1512,7 +1517,7 @@ func _Rove_ServerStatus_Handler(srv interface{}, ctx context.Context, dec func(i } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/rove.Rove/ServerStatus", + FullMethod: "/roveapi.Rove/ServerStatus", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RoveServer).ServerStatus(ctx, req.(*ServerStatusRequest)) @@ -1530,7 +1535,7 @@ func _Rove_Register_Handler(srv interface{}, ctx context.Context, dec func(inter } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/rove.Rove/Register", + FullMethod: "/roveapi.Rove/Register", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RoveServer).Register(ctx, req.(*RegisterRequest)) @@ -1548,7 +1553,7 @@ func _Rove_Command_Handler(srv interface{}, ctx context.Context, dec func(interf } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/rove.Rove/Command", + FullMethod: "/roveapi.Rove/Command", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RoveServer).Command(ctx, req.(*CommandRequest)) @@ -1566,7 +1571,7 @@ func _Rove_Radar_Handler(srv interface{}, ctx context.Context, dec func(interfac } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/rove.Rove/Radar", + FullMethod: "/roveapi.Rove/Radar", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RoveServer).Radar(ctx, req.(*RadarRequest)) @@ -1584,7 +1589,7 @@ func _Rove_Status_Handler(srv interface{}, ctx context.Context, dec func(interfa } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/rove.Rove/Status", + FullMethod: "/roveapi.Rove/Status", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RoveServer).Status(ctx, req.(*StatusRequest)) @@ -1593,7 +1598,7 @@ func _Rove_Status_Handler(srv interface{}, ctx context.Context, dec func(interfa } var _Rove_serviceDesc = grpc.ServiceDesc{ - ServiceName: "rove.Rove", + ServiceName: "roveapi.Rove", HandlerType: (*RoveServer)(nil), Methods: []grpc.MethodDesc{ { @@ -1618,5 +1623,5 @@ var _Rove_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "rove/rove.proto", + Metadata: "roveapi/roveapi.proto", } diff --git a/proto/rove/rove.proto b/proto/roveapi/roveapi.proto similarity index 98% rename from proto/rove/rove.proto rename to proto/roveapi/roveapi.proto index ab0160e..f39d2a6 100644 --- a/proto/rove/rove.proto +++ b/proto/roveapi/roveapi.proto @@ -4,8 +4,8 @@ syntax = "proto3"; // // Rove is an asychronous nomadic game about exploring a planet as part of a // loose community -package rove; -option go_package = "github.com/mdiluz/rove/pkg/rove"; +package roveapi; +option go_package = "github.com/mdiluz/rove/pkg/roveapi"; // The Rove server hosts a single game session and world with multiple players service Rove { From 065f79cbb308bf60e4244cc30ba89d499ee44a07 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 18:11:38 +0100 Subject: [PATCH 109/228] Fix warping to non-empty space --- pkg/rove/world_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index 33ae973..52e8eec 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -144,6 +144,7 @@ func TestWorld_RoverStash(t *testing.T) { Y: 0.0, } + world.Atlas.SetObject(pos, objects.Object{Type: objects.None}) err = world.WarpRover(a, pos) assert.NoError(t, err, "Failed to set position for rover") From 97d3be000b7aba3748c1283c645b0ce01f131939 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 18:14:32 +0100 Subject: [PATCH 110/228] Re-order some World members --- pkg/rove/world.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 490747b..dcb39ea 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -18,32 +18,29 @@ import ( // World describes a self contained universe and everything in it type World struct { + // TicksPerDay is the amount of ticks in a single day + TicksPerDay int `json:"ticks-per-day"` + + // Current number of ticks from the start + CurrentTicks int `json:"current-ticks"` + // Rovers is a id->data map of all the rovers in the game Rovers map[string]Rover `json:"rovers"` // Atlas represends the world map of chunks and tiles Atlas atlas.Atlas `json:"atlas"` - // Mutex to lock around all world operations - worldMutex sync.RWMutex - // Commands is the set of currently executing command streams per rover CommandQueue map[string]CommandStream `json:"commands"` - // Incoming represents the set of commands to add to the queue at the end of the current tick CommandIncoming map[string]CommandStream `json:"incoming"` + // Mutex to lock around all world operations + worldMutex sync.RWMutex // Mutex to lock around command operations cmdMutex sync.RWMutex - // Set of possible words to use for names words []string - - // TicksPerDay is the amount of ticks in a single day - TicksPerDay int `json:"ticks-per-day"` - - // Current number of ticks from the start - CurrentTicks int `json:"current-ticks"` } var wordsFile = os.Getenv("WORDS_FILE") From 5b1fe61097e81e3220c95dfacbca8f72c3b28a9d Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 18:22:59 +0100 Subject: [PATCH 111/228] Move vector into maths package --- pkg/atlas/atlas.go | 8 +- pkg/atlas/atlas_test.go | 114 +++++++++++++-------------- pkg/atlas/chunkAtlas.go | 43 +++++----- pkg/bearing/bearing.go | 6 +- pkg/bearing/bearing_test.go | 4 +- pkg/{vector => maths}/vector.go | 18 ++--- pkg/{vector => maths}/vector_test.go | 2 +- pkg/rove/command_test.go | 8 +- pkg/rove/rover.go | 4 +- pkg/rove/world.go | 24 +++--- pkg/rove/world_test.go | 34 ++++---- 11 files changed, 131 insertions(+), 134 deletions(-) rename pkg/{vector => maths}/vector.go (78%) rename pkg/{vector => maths}/vector_test.go (99%) diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index d4054db..22873f7 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -1,8 +1,8 @@ package atlas import ( + "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/pkg/objects" - "github.com/mdiluz/rove/pkg/vector" ) // Tile describes the type of terrain @@ -25,11 +25,11 @@ const ( // Atlas represents a 2D world atlas of tiles and objects type Atlas interface { // SetTile sets a location on the Atlas to a type of tile - SetTile(v vector.Vector, tile Tile) + SetTile(v maths.Vector, tile Tile) // SetObject will set a location on the Atlas to contain an object - SetObject(v vector.Vector, obj objects.Object) + SetObject(v maths.Vector, obj objects.Object) // QueryPosition queries a position on the atlas - QueryPosition(v vector.Vector) (byte, objects.Object) + QueryPosition(v maths.Vector) (byte, objects.Object) } diff --git a/pkg/atlas/atlas_test.go b/pkg/atlas/atlas_test.go index 1b1447e..4792e0b 100644 --- a/pkg/atlas/atlas_test.go +++ b/pkg/atlas/atlas_test.go @@ -4,8 +4,8 @@ import ( "fmt" "testing" + "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/pkg/objects" - "github.com/mdiluz/rove/pkg/vector" "github.com/stretchr/testify/assert" ) @@ -21,49 +21,49 @@ func TestAtlas_toChunk(t *testing.T) { assert.NotNil(t, a) // Get a tile to spawn the chunks - a.QueryPosition(vector.Vector{X: -1, Y: -1}) - a.QueryPosition(vector.Vector{X: 0, Y: 0}) + a.QueryPosition(maths.Vector{X: -1, Y: -1}) + a.QueryPosition(maths.Vector{X: 0, Y: 0}) assert.Equal(t, 2*2, len(a.Chunks)) // Chunks should look like: // 2 | 3 // ----- // 0 | 1 - chunkID := a.worldSpaceToChunkIndex(vector.Vector{X: 0, Y: 0}) + chunkID := a.worldSpaceToChunkIndex(maths.Vector{X: 0, Y: 0}) assert.Equal(t, 3, chunkID) - chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: 0, Y: -1}) + chunkID = a.worldSpaceToChunkIndex(maths.Vector{X: 0, Y: -1}) assert.Equal(t, 1, chunkID) - chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -1, Y: -1}) + chunkID = a.worldSpaceToChunkIndex(maths.Vector{X: -1, Y: -1}) assert.Equal(t, 0, chunkID) - chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -1, Y: 0}) + chunkID = a.worldSpaceToChunkIndex(maths.Vector{X: -1, Y: 0}) assert.Equal(t, 2, chunkID) a = NewChunkAtlas(2).(*chunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn the chunks - a.QueryPosition(vector.Vector{X: -2, Y: -2}) + a.QueryPosition(maths.Vector{X: -2, Y: -2}) assert.Equal(t, 2*2, len(a.Chunks)) - a.QueryPosition(vector.Vector{X: 1, Y: 1}) + a.QueryPosition(maths.Vector{X: 1, Y: 1}) assert.Equal(t, 2*2, len(a.Chunks)) // Chunks should look like: // 2 | 3 // ----- // 0 | 1 - chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: 1, Y: 1}) + chunkID = a.worldSpaceToChunkIndex(maths.Vector{X: 1, Y: 1}) assert.Equal(t, 3, chunkID) - chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: 1, Y: -2}) + chunkID = a.worldSpaceToChunkIndex(maths.Vector{X: 1, Y: -2}) assert.Equal(t, 1, chunkID) - chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -2, Y: -2}) + chunkID = a.worldSpaceToChunkIndex(maths.Vector{X: -2, Y: -2}) assert.Equal(t, 0, chunkID) - chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -2, Y: 1}) + chunkID = a.worldSpaceToChunkIndex(maths.Vector{X: -2, Y: 1}) assert.Equal(t, 2, chunkID) a = NewChunkAtlas(2).(*chunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn a 4x4 grid of chunks - a.QueryPosition(vector.Vector{X: 3, Y: 3}) + a.QueryPosition(maths.Vector{X: 3, Y: 3}) assert.Equal(t, 2*2, len(a.Chunks)) - a.QueryPosition(vector.Vector{X: -3, Y: -3}) + a.QueryPosition(maths.Vector{X: -3, Y: -3}) assert.Equal(t, 4*4, len(a.Chunks)) // Chunks should look like: @@ -74,19 +74,19 @@ func TestAtlas_toChunk(t *testing.T) { // 4 | 5 || 6 | 7 // ---------------- // 0 | 1 || 2 | 3 - chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: 1, Y: 3}) + chunkID = a.worldSpaceToChunkIndex(maths.Vector{X: 1, Y: 3}) assert.Equal(t, 14, chunkID) - chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: 1, Y: -3}) + chunkID = a.worldSpaceToChunkIndex(maths.Vector{X: 1, Y: -3}) assert.Equal(t, 2, chunkID) - chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -1, Y: -1}) + chunkID = a.worldSpaceToChunkIndex(maths.Vector{X: -1, Y: -1}) assert.Equal(t, 5, chunkID) - chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: -2, Y: 2}) + chunkID = a.worldSpaceToChunkIndex(maths.Vector{X: -2, Y: 2}) assert.Equal(t, 13, chunkID) a = NewChunkAtlas(3).(*chunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn a 4x4 grid of chunks - a.QueryPosition(vector.Vector{X: 3, Y: 3}) + a.QueryPosition(maths.Vector{X: 3, Y: 3}) assert.Equal(t, 2*2, len(a.Chunks)) // Chunks should look like: @@ -94,13 +94,13 @@ func TestAtlas_toChunk(t *testing.T) { // ------- // || 0| 1 // ======= - chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: 1, Y: 1}) + chunkID = a.worldSpaceToChunkIndex(maths.Vector{X: 1, Y: 1}) assert.Equal(t, 0, chunkID) - chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: 3, Y: 1}) + chunkID = a.worldSpaceToChunkIndex(maths.Vector{X: 3, Y: 1}) assert.Equal(t, 1, chunkID) - chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: 1, Y: 4}) + chunkID = a.worldSpaceToChunkIndex(maths.Vector{X: 1, Y: 4}) assert.Equal(t, 2, chunkID) - chunkID = a.worldSpaceToChunkIndex(vector.Vector{X: 5, Y: 5}) + chunkID = a.worldSpaceToChunkIndex(maths.Vector{X: 5, Y: 5}) assert.Equal(t, 3, chunkID) } @@ -109,36 +109,36 @@ func TestAtlas_toWorld(t *testing.T) { assert.NotNil(t, a) // Get a tile to spawn some chunks - a.QueryPosition(vector.Vector{X: -1, Y: -1}) + a.QueryPosition(maths.Vector{X: -1, Y: -1}) assert.Equal(t, 2*2, len(a.Chunks)) // Chunks should look like: // 2 | 3 // ----- // 0 | 1 - assert.Equal(t, vector.Vector{X: -1, Y: -1}, a.chunkOriginInWorldSpace(0)) - assert.Equal(t, vector.Vector{X: 0, Y: -1}, a.chunkOriginInWorldSpace(1)) + assert.Equal(t, maths.Vector{X: -1, Y: -1}, a.chunkOriginInWorldSpace(0)) + assert.Equal(t, maths.Vector{X: 0, Y: -1}, a.chunkOriginInWorldSpace(1)) a = NewChunkAtlas(2).(*chunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn the chunks - a.QueryPosition(vector.Vector{X: -2, Y: -2}) + a.QueryPosition(maths.Vector{X: -2, Y: -2}) assert.Equal(t, 2*2, len(a.Chunks)) - a.QueryPosition(vector.Vector{X: 1, Y: 1}) + a.QueryPosition(maths.Vector{X: 1, Y: 1}) assert.Equal(t, 2*2, len(a.Chunks)) // Chunks should look like: // 2 | 3 // ----- // 0 | 1 - assert.Equal(t, vector.Vector{X: -2, Y: -2}, a.chunkOriginInWorldSpace(0)) - assert.Equal(t, vector.Vector{X: -2, Y: 0}, a.chunkOriginInWorldSpace(2)) + assert.Equal(t, maths.Vector{X: -2, Y: -2}, a.chunkOriginInWorldSpace(0)) + assert.Equal(t, maths.Vector{X: -2, Y: 0}, a.chunkOriginInWorldSpace(2)) a = NewChunkAtlas(2).(*chunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn a 4x4 grid of chunks - a.QueryPosition(vector.Vector{X: 3, Y: 3}) + a.QueryPosition(maths.Vector{X: 3, Y: 3}) assert.Equal(t, 2*2, len(a.Chunks)) - a.QueryPosition(vector.Vector{X: -3, Y: -3}) + a.QueryPosition(maths.Vector{X: -3, Y: -3}) assert.Equal(t, 4*4, len(a.Chunks)) // Chunks should look like: @@ -149,13 +149,13 @@ func TestAtlas_toWorld(t *testing.T) { // 4 | 5 || 6 | 7 // ---------------- // 0 | 1 || 2 | 3 - assert.Equal(t, vector.Vector{X: -4, Y: -4}, a.chunkOriginInWorldSpace(0)) - assert.Equal(t, vector.Vector{X: 2, Y: -2}, a.chunkOriginInWorldSpace(7)) + assert.Equal(t, maths.Vector{X: -4, Y: -4}, a.chunkOriginInWorldSpace(0)) + assert.Equal(t, maths.Vector{X: 2, Y: -2}, a.chunkOriginInWorldSpace(7)) a = NewChunkAtlas(3).(*chunkBasedAtlas) assert.NotNil(t, a) // Get a tile to spawn a 4x4 grid of chunks - a.QueryPosition(vector.Vector{X: 3, Y: 3}) + a.QueryPosition(maths.Vector{X: 3, Y: 3}) assert.Equal(t, 2*2, len(a.Chunks)) // Chunks should look like: @@ -163,7 +163,7 @@ func TestAtlas_toWorld(t *testing.T) { // ------- // || 0| 1 // ======= - assert.Equal(t, vector.Vector{X: 0, Y: 0}, a.chunkOriginInWorldSpace(0)) + assert.Equal(t, maths.Vector{X: 0, Y: 0}, a.chunkOriginInWorldSpace(0)) } func TestAtlas_GetSetTile(t *testing.T) { @@ -171,13 +171,13 @@ func TestAtlas_GetSetTile(t *testing.T) { assert.NotNil(t, a) // Set the origin tile to 1 and test it - a.SetTile(vector.Vector{X: 0, Y: 0}, 1) - tile, _ := a.QueryPosition(vector.Vector{X: 0, Y: 0}) + a.SetTile(maths.Vector{X: 0, Y: 0}, 1) + tile, _ := a.QueryPosition(maths.Vector{X: 0, Y: 0}) assert.Equal(t, byte(1), tile) // Set another tile to 1 and test it - a.SetTile(vector.Vector{X: 5, Y: -2}, 2) - tile, _ = a.QueryPosition(vector.Vector{X: 5, Y: -2}) + a.SetTile(maths.Vector{X: 5, Y: -2}, 2) + tile, _ = a.QueryPosition(maths.Vector{X: 5, Y: -2}) assert.Equal(t, byte(2), tile) } @@ -186,13 +186,13 @@ func TestAtlas_GetSetObject(t *testing.T) { assert.NotNil(t, a) // Set the origin tile to 1 and test it - a.SetObject(vector.Vector{X: 0, Y: 0}, objects.Object{Type: objects.LargeRock}) - _, obj := a.QueryPosition(vector.Vector{X: 0, Y: 0}) + a.SetObject(maths.Vector{X: 0, Y: 0}, objects.Object{Type: objects.LargeRock}) + _, obj := a.QueryPosition(maths.Vector{X: 0, Y: 0}) assert.Equal(t, objects.Object{Type: objects.LargeRock}, obj) // Set another tile to 1 and test it - a.SetObject(vector.Vector{X: 5, Y: -2}, objects.Object{Type: objects.SmallRock}) - _, obj = a.QueryPosition(vector.Vector{X: 5, Y: -2}) + a.SetObject(maths.Vector{X: 5, Y: -2}, objects.Object{Type: objects.SmallRock}) + _, obj = a.QueryPosition(maths.Vector{X: 5, Y: -2}) assert.Equal(t, objects.Object{Type: objects.SmallRock}, obj) } @@ -203,27 +203,27 @@ func TestAtlas_Grown(t *testing.T) { assert.Equal(t, 1, len(a.Chunks)) // Set a few tiles to values - a.SetTile(vector.Vector{X: 0, Y: 0}, 1) - a.SetTile(vector.Vector{X: -1, Y: -1}, 2) - a.SetTile(vector.Vector{X: 1, Y: -2}, 3) + a.SetTile(maths.Vector{X: 0, Y: 0}, 1) + a.SetTile(maths.Vector{X: -1, Y: -1}, 2) + a.SetTile(maths.Vector{X: 1, Y: -2}, 3) // Check tile values - tile, _ := a.QueryPosition(vector.Vector{X: 0, Y: 0}) + tile, _ := a.QueryPosition(maths.Vector{X: 0, Y: 0}) assert.Equal(t, byte(1), tile) - tile, _ = a.QueryPosition(vector.Vector{X: -1, Y: -1}) + tile, _ = a.QueryPosition(maths.Vector{X: -1, Y: -1}) assert.Equal(t, byte(2), tile) - tile, _ = a.QueryPosition(vector.Vector{X: 1, Y: -2}) + tile, _ = a.QueryPosition(maths.Vector{X: 1, Y: -2}) assert.Equal(t, byte(3), tile) - tile, _ = a.QueryPosition(vector.Vector{X: 0, Y: 0}) + tile, _ = a.QueryPosition(maths.Vector{X: 0, Y: 0}) assert.Equal(t, byte(1), tile) - tile, _ = a.QueryPosition(vector.Vector{X: -1, Y: -1}) + tile, _ = a.QueryPosition(maths.Vector{X: -1, Y: -1}) assert.Equal(t, byte(2), tile) - tile, _ = a.QueryPosition(vector.Vector{X: 1, Y: -2}) + tile, _ = a.QueryPosition(maths.Vector{X: 1, Y: -2}) assert.Equal(t, byte(3), tile) } @@ -237,7 +237,7 @@ func TestAtlas_GetSetCorrect(t *testing.T) { assert.NotNil(t, a) assert.Equal(t, 1, len(a.Chunks)) - pos := vector.Vector{X: x, Y: y} + pos := maths.Vector{X: x, Y: y} a.SetTile(pos, TileRock) a.SetObject(pos, objects.Object{Type: objects.LargeRock}) tile, obj := a.QueryPosition(pos) @@ -253,13 +253,13 @@ func TestAtlas_GetSetCorrect(t *testing.T) { func TestAtlas_WorldGen(t *testing.T) { a := NewChunkAtlas(8) // Spawn a large world - _, _ = a.QueryPosition(vector.Vector{X: 20, Y: 20}) + _, _ = a.QueryPosition(maths.Vector{X: 20, Y: 20}) // Print out the world for manual evaluation num := 20 for j := num - 1; j >= 0; j-- { for i := 0; i < num; i++ { - t, o := a.QueryPosition(vector.Vector{X: i, Y: j}) + t, o := a.QueryPosition(maths.Vector{X: i, Y: j}) if o.Type != objects.None { fmt.Printf("%c", o.Type) } else if t != byte(TileNone) { diff --git a/pkg/atlas/chunkAtlas.go b/pkg/atlas/chunkAtlas.go index 1caac1e..c3c969e 100644 --- a/pkg/atlas/chunkAtlas.go +++ b/pkg/atlas/chunkAtlas.go @@ -6,7 +6,6 @@ import ( "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/pkg/objects" - "github.com/mdiluz/rove/pkg/vector" "github.com/ojrac/opensimplex-go" ) @@ -27,10 +26,10 @@ type chunkBasedAtlas struct { Chunks []chunk `json:"chunks"` // LowerBound is the origin of the bottom left corner of the current chunks in world space (current chunks cover >= this value) - LowerBound vector.Vector `json:"lowerBound"` + LowerBound maths.Vector `json:"lowerBound"` // UpperBound is the top left corner of the current chunks (curent chunks cover < this value) - UpperBound vector.Vector `json:"upperBound"` + UpperBound maths.Vector `json:"upperBound"` // ChunkSize is the x/y dimensions of each square chunk ChunkSize int `json:"chunksize"` @@ -54,8 +53,8 @@ func NewChunkAtlas(chunkSize int) Atlas { a := chunkBasedAtlas{ ChunkSize: chunkSize, Chunks: make([]chunk, 1), - LowerBound: vector.Vector{X: 0, Y: 0}, - UpperBound: vector.Vector{X: chunkSize, Y: chunkSize}, + LowerBound: maths.Vector{X: 0, Y: 0}, + UpperBound: maths.Vector{X: chunkSize, Y: chunkSize}, terrainNoise: opensimplex.New(noiseSeed), objectNoise: opensimplex.New(noiseSeed), } @@ -65,21 +64,21 @@ func NewChunkAtlas(chunkSize int) Atlas { } // SetTile sets an individual tile's kind -func (a *chunkBasedAtlas) SetTile(v vector.Vector, tile Tile) { +func (a *chunkBasedAtlas) SetTile(v maths.Vector, tile Tile) { c := a.worldSpaceToChunkWithGrow(v) local := a.worldSpaceToChunkLocal(v) a.setTile(c, local, byte(tile)) } // SetObject sets the object on a tile -func (a *chunkBasedAtlas) SetObject(v vector.Vector, obj objects.Object) { +func (a *chunkBasedAtlas) SetObject(v maths.Vector, obj objects.Object) { c := a.worldSpaceToChunkWithGrow(v) local := a.worldSpaceToChunkLocal(v) a.setObject(c, local, obj) } // QueryPosition will return information for a specific position -func (a *chunkBasedAtlas) QueryPosition(v vector.Vector) (byte, objects.Object) { +func (a *chunkBasedAtlas) QueryPosition(v maths.Vector) (byte, objects.Object) { c := a.worldSpaceToChunkWithGrow(v) local := a.worldSpaceToChunkLocal(v) a.populate(c) @@ -89,7 +88,7 @@ func (a *chunkBasedAtlas) QueryPosition(v vector.Vector) (byte, objects.Object) } // chunkTileID returns the tile index within a chunk -func (a *chunkBasedAtlas) chunkTileIndex(local vector.Vector) int { +func (a *chunkBasedAtlas) chunkTileIndex(local maths.Vector) int { return local.X + local.Y*a.ChunkSize } @@ -148,7 +147,7 @@ func (a *chunkBasedAtlas) populate(chunk int) { } // setTile sets a tile in a specific chunk -func (a *chunkBasedAtlas) setTile(chunk int, local vector.Vector, tile byte) { +func (a *chunkBasedAtlas) setTile(chunk int, local maths.Vector, tile byte) { a.populate(chunk) c := a.Chunks[chunk] c.Tiles[a.chunkTileIndex(local)] = tile @@ -156,7 +155,7 @@ func (a *chunkBasedAtlas) setTile(chunk int, local vector.Vector, tile byte) { } // setObject sets an object in a specific chunk -func (a *chunkBasedAtlas) setObject(chunk int, local vector.Vector, object objects.Object) { +func (a *chunkBasedAtlas) setObject(chunk int, local maths.Vector, object objects.Object) { a.populate(chunk) c := a.Chunks[chunk] @@ -170,12 +169,12 @@ func (a *chunkBasedAtlas) setObject(chunk int, local vector.Vector, object objec } // worldSpaceToChunkLocal gets a chunk local coordinate for a tile -func (a *chunkBasedAtlas) worldSpaceToChunkLocal(v vector.Vector) vector.Vector { - return vector.Vector{X: maths.Pmod(v.X, a.ChunkSize), Y: maths.Pmod(v.Y, a.ChunkSize)} +func (a *chunkBasedAtlas) worldSpaceToChunkLocal(v maths.Vector) maths.Vector { + return maths.Vector{X: maths.Pmod(v.X, a.ChunkSize), Y: maths.Pmod(v.Y, a.ChunkSize)} } // worldSpaceToChunkID gets the current chunk ID for a position in the world -func (a *chunkBasedAtlas) worldSpaceToChunkIndex(v vector.Vector) int { +func (a *chunkBasedAtlas) worldSpaceToChunkIndex(v maths.Vector) int { // Shift the vector by our current min v = v.Added(a.LowerBound.Negated()) @@ -191,13 +190,13 @@ func (a *chunkBasedAtlas) worldSpaceToChunkIndex(v vector.Vector) int { } // chunkOriginInWorldSpace returns the origin of the chunk in world space -func (a *chunkBasedAtlas) chunkOriginInWorldSpace(chunk int) vector.Vector { +func (a *chunkBasedAtlas) chunkOriginInWorldSpace(chunk int) maths.Vector { // Calculate the width width := a.UpperBound.X - a.LowerBound.X widthInChunks := width / a.ChunkSize // Reverse the along the corridor and up the stairs - v := vector.Vector{ + v := maths.Vector{ X: chunk % widthInChunks, Y: chunk / widthInChunks, } @@ -208,15 +207,15 @@ func (a *chunkBasedAtlas) chunkOriginInWorldSpace(chunk int) vector.Vector { } // getNewBounds gets new lower and upper bounds for the world space given a vector -func (a *chunkBasedAtlas) getNewBounds(v vector.Vector) (lower vector.Vector, upper vector.Vector) { - lower = vector.Min(v, a.LowerBound) - upper = vector.Max(v.Added(vector.Vector{X: 1, Y: 1}), a.UpperBound) +func (a *chunkBasedAtlas) getNewBounds(v maths.Vector) (lower maths.Vector, upper maths.Vector) { + lower = maths.Min2(v, a.LowerBound) + upper = maths.Max2(v.Added(maths.Vector{X: 1, Y: 1}), a.UpperBound) - lower = vector.Vector{ + lower = maths.Vector{ X: maths.RoundDown(lower.X, a.ChunkSize), Y: maths.RoundDown(lower.Y, a.ChunkSize), } - upper = vector.Vector{ + upper = maths.Vector{ X: maths.RoundUp(upper.X, a.ChunkSize), Y: maths.RoundUp(upper.Y, a.ChunkSize), } @@ -224,7 +223,7 @@ func (a *chunkBasedAtlas) getNewBounds(v vector.Vector) (lower vector.Vector, up } // worldSpaceToTrunkWithGrow will expand the current atlas for a given world space position if needed -func (a *chunkBasedAtlas) worldSpaceToChunkWithGrow(v vector.Vector) int { +func (a *chunkBasedAtlas) worldSpaceToChunkWithGrow(v maths.Vector) int { // If we're within bounds, just return the current chunk if v.X >= a.LowerBound.X && v.Y >= a.LowerBound.Y && v.X < a.UpperBound.X && v.Y < a.UpperBound.Y { return a.worldSpaceToChunkIndex(v) diff --git a/pkg/bearing/bearing.go b/pkg/bearing/bearing.go index 303c195..2eec3ba 100644 --- a/pkg/bearing/bearing.go +++ b/pkg/bearing/bearing.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/mdiluz/rove/pkg/vector" + "github.com/mdiluz/rove/pkg/maths" ) // Bearing describes a compass direction @@ -67,7 +67,7 @@ func FromString(s string) (Bearing, error) { return -1, fmt.Errorf("unknown bearing: %s", s) } -var bearingVectors = []vector.Vector{ +var bearingVectors = []maths.Vector{ {X: 0, Y: 1}, // N {X: 1, Y: 1}, // NE {X: 1, Y: 0}, // E @@ -79,6 +79,6 @@ var bearingVectors = []vector.Vector{ } // Vector converts a Direction to a Vector -func (d Bearing) Vector() vector.Vector { +func (d Bearing) Vector() maths.Vector { return bearingVectors[d] } diff --git a/pkg/bearing/bearing_test.go b/pkg/bearing/bearing_test.go index 1232239..5bb36bc 100644 --- a/pkg/bearing/bearing_test.go +++ b/pkg/bearing/bearing_test.go @@ -3,7 +3,7 @@ package bearing import ( "testing" - "github.com/mdiluz/rove/pkg/vector" + "github.com/mdiluz/rove/pkg/maths" "github.com/stretchr/testify/assert" ) @@ -12,7 +12,7 @@ func TestDirection(t *testing.T) { assert.Equal(t, "North", dir.String()) assert.Equal(t, "N", dir.ShortString()) - assert.Equal(t, vector.Vector{X: 0, Y: 1}, dir.Vector()) + assert.Equal(t, maths.Vector{X: 0, Y: 1}, dir.Vector()) dir, err := FromString("N") assert.NoError(t, err) diff --git a/pkg/vector/vector.go b/pkg/maths/vector.go similarity index 78% rename from pkg/vector/vector.go rename to pkg/maths/vector.go index a8955be..2dd3bad 100644 --- a/pkg/vector/vector.go +++ b/pkg/maths/vector.go @@ -1,9 +1,7 @@ -package vector +package maths import ( "math" - - "github.com/mdiluz/rove/pkg/maths" ) // Vector desribes a 3D vector @@ -71,15 +69,15 @@ func (v Vector) DividedFloor(val int) Vector { // Abs returns an absolute version of the vector func (v Vector) Abs() Vector { - return Vector{maths.Abs(v.X), maths.Abs(v.Y)} + return Vector{Abs(v.X), Abs(v.Y)} } -// Min returns the minimum values in both vectors -func Min(v1 Vector, v2 Vector) Vector { - return Vector{maths.Min(v1.X, v2.X), maths.Min(v1.Y, v2.Y)} +// Min2 returns the minimum values in both vectors +func Min2(v1 Vector, v2 Vector) Vector { + return Vector{Min(v1.X, v2.X), Min(v1.Y, v2.Y)} } -// Max returns the max values in both vectors -func Max(v1 Vector, v2 Vector) Vector { - return Vector{maths.Max(v1.X, v2.X), maths.Max(v1.Y, v2.Y)} +// Max2 returns the max values in both vectors +func Max2(v1 Vector, v2 Vector) Vector { + return Vector{Max(v1.X, v2.X), Max(v1.Y, v2.Y)} } diff --git a/pkg/vector/vector_test.go b/pkg/maths/vector_test.go similarity index 99% rename from pkg/vector/vector_test.go rename to pkg/maths/vector_test.go index 5d92136..4177780 100644 --- a/pkg/vector/vector_test.go +++ b/pkg/maths/vector_test.go @@ -1,4 +1,4 @@ -package vector +package maths import ( "math" diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index f4f6bd9..e01a487 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -3,8 +3,8 @@ package rove import ( "testing" + "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/pkg/roveapi" - "github.com/mdiluz/rove/pkg/vector" "github.com/stretchr/testify/assert" ) @@ -12,7 +12,7 @@ func TestCommand_Move(t *testing.T) { world := NewWorld(8) a, err := world.SpawnRover() assert.NoError(t, err) - pos := vector.Vector{ + pos := maths.Vector{ X: 1.0, Y: 2.0, } @@ -30,7 +30,7 @@ func TestCommand_Move(t *testing.T) { newPos, err := world.RoverPosition(a) assert.NoError(t, err, "Failed to set position for rover") - pos.Add(vector.Vector{X: 0.0, Y: 1}) + pos.Add(maths.Vector{X: 0.0, Y: 1}) assert.Equal(t, pos, newPos, "Failed to correctly set position for rover") } @@ -38,7 +38,7 @@ func TestCommand_Recharge(t *testing.T) { world := NewWorld(8) a, err := world.SpawnRover() assert.NoError(t, err) - pos := vector.Vector{ + pos := maths.Vector{ X: 1.0, Y: 2.0, } diff --git a/pkg/rove/rover.go b/pkg/rove/rover.go index 9ab0401..45fb8f0 100644 --- a/pkg/rove/rover.go +++ b/pkg/rove/rover.go @@ -5,8 +5,8 @@ import ( "log" "time" + "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/pkg/objects" - "github.com/mdiluz/rove/pkg/vector" ) // RoverLogEntry describes a single log entry for the rover @@ -24,7 +24,7 @@ type Rover struct { Name string `json:"name"` // Pos represents where this rover is in the world - Pos vector.Vector `json:"pos"` + Pos maths.Vector `json:"pos"` // Range represents the distance the unit's radar can see Range int `json:"range"` diff --git a/pkg/rove/world.go b/pkg/rove/world.go index dcb39ea..eb2ef85 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -11,9 +11,9 @@ import ( "github.com/google/uuid" "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/bearing" + "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/roveapi" - "github.com/mdiluz/rove/pkg/vector" ) // World describes a self contained universe and everything in it @@ -103,7 +103,7 @@ func (w *World) SpawnRover() (string, error) { } // Spawn in a random place near the origin - rover.Pos = vector.Vector{ + rover.Pos = maths.Vector{ X: 10 - rand.Intn(20), Y: 10 - rand.Intn(20), } @@ -115,7 +115,7 @@ func (w *World) SpawnRover() (string, error) { break } else { // Try and spawn to the east of the blockage - rover.Pos.Add(vector.Vector{X: 1, Y: 0}) + rover.Pos.Add(maths.Vector{X: 1, Y: 0}) } } @@ -215,19 +215,19 @@ func (w *World) DestroyRover(rover string) error { } // RoverPosition returns the position of the rover -func (w *World) RoverPosition(rover string) (vector.Vector, error) { +func (w *World) RoverPosition(rover string) (maths.Vector, error) { w.worldMutex.RLock() defer w.worldMutex.RUnlock() i, ok := w.Rovers[rover] if !ok { - return vector.Vector{}, fmt.Errorf("no rover matching id") + return maths.Vector{}, fmt.Errorf("no rover matching id") } return i.Pos, nil } // SetRoverPosition sets the position of the rover -func (w *World) SetRoverPosition(rover string, pos vector.Vector) error { +func (w *World) SetRoverPosition(rover string, pos maths.Vector) error { w.worldMutex.Lock() defer w.worldMutex.Unlock() @@ -254,7 +254,7 @@ func (w *World) RoverInventory(rover string) ([]objects.Object, error) { } // WarpRover sets an rovers position -func (w *World) WarpRover(rover string, pos vector.Vector) error { +func (w *World) WarpRover(rover string, pos maths.Vector) error { w.worldMutex.Lock() defer w.worldMutex.Unlock() @@ -279,13 +279,13 @@ func (w *World) WarpRover(rover string, pos vector.Vector) error { } // MoveRover attempts to move a rover in a specific direction -func (w *World) MoveRover(rover string, b bearing.Bearing) (vector.Vector, error) { +func (w *World) MoveRover(rover string, b bearing.Bearing) (maths.Vector, error) { w.worldMutex.Lock() defer w.worldMutex.Unlock() i, ok := w.Rovers[rover] if !ok { - return vector.Vector{}, fmt.Errorf("no rover matching id") + return maths.Vector{}, fmt.Errorf("no rover matching id") } // Ensure the rover has energy @@ -368,11 +368,11 @@ func (w *World) RadarFromRover(rover string) (radar []byte, objs []byte, err err roverPos := r.Pos // Get the radar min and max values - radarMin := vector.Vector{ + radarMin := maths.Vector{ X: roverPos.X - r.Range, Y: roverPos.Y - r.Range, } - radarMax := vector.Vector{ + radarMax := maths.Vector{ X: roverPos.X + r.Range, Y: roverPos.Y + r.Range, } @@ -382,7 +382,7 @@ func (w *World) RadarFromRover(rover string) (radar []byte, objs []byte, err err objs = make([]byte, radarSpan*radarSpan) for j := radarMin.Y; j <= radarMax.Y; j++ { for i := radarMin.X; i <= radarMax.X; i++ { - q := vector.Vector{X: i, Y: j} + q := maths.Vector{X: i, Y: j} tile, obj := w.Atlas.QueryPosition(q) diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index 52e8eec..89ea9c7 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -5,9 +5,9 @@ import ( "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/bearing" + "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/roveapi" - "github.com/mdiluz/rove/pkg/vector" "github.com/stretchr/testify/assert" ) @@ -68,7 +68,7 @@ func TestWorld_GetSetMovePosition(t *testing.T) { a, err := world.SpawnRover() assert.NoError(t, err) - pos := vector.Vector{ + pos := maths.Vector{ X: 0.0, Y: 0.0, } @@ -83,7 +83,7 @@ func TestWorld_GetSetMovePosition(t *testing.T) { b := bearing.North newPos, err = world.MoveRover(a, b) assert.NoError(t, err, "Failed to set position for rover") - pos.Add(vector.Vector{X: 0, Y: 1}) + pos.Add(maths.Vector{X: 0, Y: 1}) assert.Equal(t, pos, newPos, "Failed to correctly move position for rover") rover, err := world.GetRover(a) @@ -92,7 +92,7 @@ func TestWorld_GetSetMovePosition(t *testing.T) { assert.Contains(t, rover.Logs[len(rover.Logs)-1].Text, "moved", "Rover logs should contain the move") // Place a tile in front of the rover - world.Atlas.SetObject(vector.Vector{X: 0, Y: 2}, objects.Object{Type: objects.LargeRock}) + world.Atlas.SetObject(maths.Vector{X: 0, Y: 2}, objects.Object{Type: objects.LargeRock}) newPos, err = world.MoveRover(a, b) assert.NoError(t, err, "Failed to move rover") assert.Equal(t, pos, newPos, "Failed to correctly not move position for rover into wall") @@ -111,9 +111,9 @@ func TestWorld_RadarFromRover(t *testing.T) { assert.NoError(t, err) // Warp the rovers into position - bpos := vector.Vector{X: -3, Y: -3} + bpos := maths.Vector{X: -3, Y: -3} assert.NoError(t, world.WarpRover(b, bpos), "Failed to warp rover") - assert.NoError(t, world.WarpRover(a, vector.Vector{X: 0, Y: 0}), "Failed to warp rover") + assert.NoError(t, world.WarpRover(a, maths.Vector{X: 0, Y: 0}), "Failed to warp rover") radar, objs, err := world.RadarFromRover(a) assert.NoError(t, err, "Failed to get radar from rover") @@ -139,7 +139,7 @@ func TestWorld_RoverStash(t *testing.T) { a, err := world.SpawnRover() assert.NoError(t, err) - pos := vector.Vector{ + pos := maths.Vector{ X: 0.0, Y: 0.0, } @@ -215,7 +215,7 @@ func TestWorld_RoverDamage(t *testing.T) { a, err := world.SpawnRover() assert.NoError(t, err) - pos := vector.Vector{ + pos := maths.Vector{ X: 0.0, Y: 0.0, } @@ -226,7 +226,7 @@ func TestWorld_RoverDamage(t *testing.T) { info, err := world.GetRover(a) assert.NoError(t, err, "couldn't get rover info") - world.Atlas.SetObject(vector.Vector{X: 0.0, Y: 1.0}, objects.Object{Type: objects.LargeRock}) + world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, objects.Object{Type: objects.LargeRock}) vec, err := world.MoveRover(a, bearing.North) assert.NoError(t, err, "Failed to move rover") @@ -243,7 +243,7 @@ func TestWorld_RoverRepair(t *testing.T) { a, err := world.SpawnRover() assert.NoError(t, err) - pos := vector.Vector{ + pos := maths.Vector{ X: 0.0, Y: 0.0, } @@ -263,7 +263,7 @@ func TestWorld_RoverRepair(t *testing.T) { assert.NoError(t, err, "Failed to stash") assert.Equal(t, objects.SmallRock, o, "Failed to get correct object") - world.Atlas.SetObject(vector.Vector{X: 0.0, Y: 1.0}, objects.Object{Type: objects.LargeRock}) + world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, objects.Object{Type: objects.LargeRock}) // Try and bump into the rock vec, err := world.MoveRover(a, bearing.North) @@ -378,8 +378,8 @@ func TestWorld_Broadcast(t *testing.T) { assert.NoError(t, err) // Warp rovers near to eachother - assert.NoError(t, world.WarpRover(a, vector.Vector{X: 0, Y: 0})) - assert.NoError(t, world.WarpRover(b, vector.Vector{X: 1, Y: 0})) + assert.NoError(t, world.WarpRover(a, maths.Vector{X: 0, Y: 0})) + assert.NoError(t, world.WarpRover(b, maths.Vector{X: 1, Y: 0})) // Broadcast from a assert.NoError(t, world.RoverBroadcast(a, []byte{'A', 'B', 'C'})) @@ -396,8 +396,8 @@ func TestWorld_Broadcast(t *testing.T) { assert.Contains(t, rb.Logs[len(rb.Logs)-1].Text, "ABC", "Rover A should have logged it's broadcast") // Warp B outside of the range of A - world.Atlas.SetObject(vector.Vector{X: ra.Range, Y: 0}, objects.Object{Type: objects.None}) - assert.NoError(t, world.WarpRover(b, vector.Vector{X: ra.Range, Y: 0})) + world.Atlas.SetObject(maths.Vector{X: ra.Range, Y: 0}, objects.Object{Type: objects.None}) + assert.NoError(t, world.WarpRover(b, maths.Vector{X: ra.Range, Y: 0})) // Broadcast from a again assert.NoError(t, world.RoverBroadcast(a, []byte{'X', 'Y', 'Z'})) @@ -413,8 +413,8 @@ func TestWorld_Broadcast(t *testing.T) { assert.Contains(t, rb.Logs[len(rb.Logs)-1].Text, "XYZ", "Rover A should have logged it's broadcast") // Warp B outside of the range of A - world.Atlas.SetObject(vector.Vector{X: ra.Range + 1, Y: 0}, objects.Object{Type: objects.None}) - assert.NoError(t, world.WarpRover(b, vector.Vector{X: ra.Range + 1, Y: 0})) + world.Atlas.SetObject(maths.Vector{X: ra.Range + 1, Y: 0}, objects.Object{Type: objects.None}) + assert.NoError(t, world.WarpRover(b, maths.Vector{X: ra.Range + 1, Y: 0})) // Broadcast from a again assert.NoError(t, world.RoverBroadcast(a, []byte{'H', 'J', 'K'})) From f40f7123d43b6f3731c3fa4937be851a35e76053 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 18:24:54 +0100 Subject: [PATCH 112/228] Move bearing into maths --- cmd/rove/main.go | 4 ++-- pkg/{bearing => maths}/bearing.go | 8 +++----- pkg/{bearing => maths}/bearing_test.go | 5 ++--- pkg/rove/world.go | 7 +++---- pkg/rove/world_test.go | 15 +++++++-------- 5 files changed, 17 insertions(+), 22 deletions(-) rename pkg/{bearing => maths}/bearing.go (92%) rename pkg/{bearing => maths}/bearing_test.go (83%) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index af48a61..cf239bf 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -11,7 +11,7 @@ import ( "time" "github.com/mdiluz/rove/pkg/atlas" - "github.com/mdiluz/rove/pkg/bearing" + "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/roveapi" "github.com/mdiluz/rove/pkg/version" @@ -216,7 +216,7 @@ func InnerMain(command string, args ...string) error { i++ if len(args) == i { return fmt.Errorf("move command must be passed bearing") - } else if _, err := bearing.FromString(args[i]); err != nil { + } else if _, err := maths.FromString(args[i]); err != nil { return err } commands = append(commands, diff --git a/pkg/bearing/bearing.go b/pkg/maths/bearing.go similarity index 92% rename from pkg/bearing/bearing.go rename to pkg/maths/bearing.go index 2eec3ba..220855b 100644 --- a/pkg/bearing/bearing.go +++ b/pkg/maths/bearing.go @@ -1,10 +1,8 @@ -package bearing +package maths import ( "fmt" "strings" - - "github.com/mdiluz/rove/pkg/maths" ) // Bearing describes a compass direction @@ -67,7 +65,7 @@ func FromString(s string) (Bearing, error) { return -1, fmt.Errorf("unknown bearing: %s", s) } -var bearingVectors = []maths.Vector{ +var bearingVectors = []Vector{ {X: 0, Y: 1}, // N {X: 1, Y: 1}, // NE {X: 1, Y: 0}, // E @@ -79,6 +77,6 @@ var bearingVectors = []maths.Vector{ } // Vector converts a Direction to a Vector -func (d Bearing) Vector() maths.Vector { +func (d Bearing) Vector() Vector { return bearingVectors[d] } diff --git a/pkg/bearing/bearing_test.go b/pkg/maths/bearing_test.go similarity index 83% rename from pkg/bearing/bearing_test.go rename to pkg/maths/bearing_test.go index 5bb36bc..bb97043 100644 --- a/pkg/bearing/bearing_test.go +++ b/pkg/maths/bearing_test.go @@ -1,9 +1,8 @@ -package bearing +package maths import ( "testing" - "github.com/mdiluz/rove/pkg/maths" "github.com/stretchr/testify/assert" ) @@ -12,7 +11,7 @@ func TestDirection(t *testing.T) { assert.Equal(t, "North", dir.String()) assert.Equal(t, "N", dir.ShortString()) - assert.Equal(t, maths.Vector{X: 0, Y: 1}, dir.Vector()) + assert.Equal(t, Vector{X: 0, Y: 1}, dir.Vector()) dir, err := FromString("N") assert.NoError(t, err) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index eb2ef85..559073e 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -10,7 +10,6 @@ import ( "github.com/google/uuid" "github.com/mdiluz/rove/pkg/atlas" - "github.com/mdiluz/rove/pkg/bearing" "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/roveapi" @@ -279,7 +278,7 @@ func (w *World) WarpRover(rover string, pos maths.Vector) error { } // MoveRover attempts to move a rover in a specific direction -func (w *World) MoveRover(rover string, b bearing.Bearing) (maths.Vector, error) { +func (w *World) MoveRover(rover string, b maths.Bearing) (maths.Vector, error) { w.worldMutex.Lock() defer w.worldMutex.Unlock() @@ -428,7 +427,7 @@ func (w *World) Enqueue(rover string, commands ...Command) error { for _, c := range commands { switch c.Command { case roveapi.CommandType_move: - if _, err := bearing.FromString(c.Bearing); err != nil { + if _, err := maths.FromString(c.Bearing); err != nil { return fmt.Errorf("unknown bearing: %s", c.Bearing) } case roveapi.CommandType_broadcast: @@ -507,7 +506,7 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { switch c.Command { case roveapi.CommandType_move: - if dir, err := bearing.FromString(c.Bearing); err != nil { + if dir, err := maths.FromString(c.Bearing); err != nil { return err } else if _, err := w.MoveRover(rover, dir); err != nil { return err diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index 89ea9c7..78e9160 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -4,7 +4,6 @@ import ( "testing" "github.com/mdiluz/rove/pkg/atlas" - "github.com/mdiluz/rove/pkg/bearing" "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/roveapi" @@ -80,7 +79,7 @@ func TestWorld_GetSetMovePosition(t *testing.T) { assert.NoError(t, err, "Failed to set position for rover") assert.Equal(t, pos, newPos, "Failed to correctly set position for rover") - b := bearing.North + b := maths.North newPos, err = world.MoveRover(a, b) assert.NoError(t, err, "Failed to set position for rover") pos.Add(maths.Vector{X: 0, Y: 1}) @@ -228,7 +227,7 @@ func TestWorld_RoverDamage(t *testing.T) { world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, objects.Object{Type: objects.LargeRock}) - vec, err := world.MoveRover(a, bearing.North) + vec, err := world.MoveRover(a, maths.North) assert.NoError(t, err, "Failed to move rover") assert.Equal(t, pos, vec, "Rover managed to move into large rock") @@ -266,7 +265,7 @@ func TestWorld_RoverRepair(t *testing.T) { world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, objects.Object{Type: objects.LargeRock}) // Try and bump into the rock - vec, err := world.MoveRover(a, bearing.North) + vec, err := world.MoveRover(a, maths.North) assert.NoError(t, err, "Failed to move rover") assert.Equal(t, pos, vec, "Rover managed to move into large rock") @@ -313,13 +312,13 @@ func TestWorld_Charge(t *testing.T) { assert.NoError(t, err, "Failed to get position for rover") // Ensure the path ahead is empty - world.Atlas.SetTile(initialPos.Added(bearing.North.Vector()), atlas.TileRock) - world.Atlas.SetObject(initialPos.Added(bearing.North.Vector()), objects.Object{Type: objects.None}) + world.Atlas.SetTile(initialPos.Added(maths.North.Vector()), atlas.TileRock) + world.Atlas.SetObject(initialPos.Added(maths.North.Vector()), objects.Object{Type: objects.None}) // Try and move north (along unblocked path) - newPos, err := world.MoveRover(a, bearing.North) + newPos, err := world.MoveRover(a, maths.North) assert.NoError(t, err, "Failed to set position for rover") - assert.Equal(t, initialPos.Added(bearing.North.Vector()), newPos, "Failed to correctly move position for rover") + assert.Equal(t, initialPos.Added(maths.North.Vector()), newPos, "Failed to correctly move position for rover") // Ensure rover lost charge rover, err := world.GetRover(a) From f0ab2abf6e81488f1f07c02a6f203d023b4a70d9 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 18:39:33 +0100 Subject: [PATCH 113/228] Move object into atlas --- cmd/rove/main.go | 3 +-- pkg/atlas/atlas.go | 5 ++-- pkg/atlas/atlas_test.go | 15 +++++------ pkg/atlas/chunkAtlas.go | 27 ++++++++++--------- pkg/{objects => atlas}/objects.go | 24 ++++++++--------- pkg/rove/rover.go | 4 +-- pkg/rove/world.go | 17 ++++++------ pkg/rove/world_test.go | 43 +++++++++++++++---------------- 8 files changed, 66 insertions(+), 72 deletions(-) rename pkg/{objects => atlas}/objects.go (63%) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index cf239bf..1ec0b24 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -12,7 +12,6 @@ import ( "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/maths" - "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/roveapi" "github.com/mdiluz/rove/pkg/version" "golang.org/x/net/context" @@ -288,7 +287,7 @@ func InnerMain(command string, args ...string) error { for i := 0; i < num; i++ { t := response.Tiles[i+num*j] o := response.Objects[i+num*j] - if o != byte(objects.None) { + if o != byte(atlas.ObjectNone) { fmt.Printf("%c", o) } else if t != byte(atlas.TileNone) { fmt.Printf("%c", t) diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index 22873f7..1a2f3fb 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -2,7 +2,6 @@ package atlas import ( "github.com/mdiluz/rove/pkg/maths" - "github.com/mdiluz/rove/pkg/objects" ) // Tile describes the type of terrain @@ -28,8 +27,8 @@ type Atlas interface { SetTile(v maths.Vector, tile Tile) // SetObject will set a location on the Atlas to contain an object - SetObject(v maths.Vector, obj objects.Object) + SetObject(v maths.Vector, obj Object) // QueryPosition queries a position on the atlas - QueryPosition(v maths.Vector) (byte, objects.Object) + QueryPosition(v maths.Vector) (byte, Object) } diff --git a/pkg/atlas/atlas_test.go b/pkg/atlas/atlas_test.go index 4792e0b..9305b07 100644 --- a/pkg/atlas/atlas_test.go +++ b/pkg/atlas/atlas_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/mdiluz/rove/pkg/maths" - "github.com/mdiluz/rove/pkg/objects" "github.com/stretchr/testify/assert" ) @@ -186,14 +185,14 @@ func TestAtlas_GetSetObject(t *testing.T) { assert.NotNil(t, a) // Set the origin tile to 1 and test it - a.SetObject(maths.Vector{X: 0, Y: 0}, objects.Object{Type: objects.LargeRock}) + a.SetObject(maths.Vector{X: 0, Y: 0}, Object{Type: ObjectLargeRock}) _, obj := a.QueryPosition(maths.Vector{X: 0, Y: 0}) - assert.Equal(t, objects.Object{Type: objects.LargeRock}, obj) + assert.Equal(t, Object{Type: ObjectLargeRock}, obj) // Set another tile to 1 and test it - a.SetObject(maths.Vector{X: 5, Y: -2}, objects.Object{Type: objects.SmallRock}) + a.SetObject(maths.Vector{X: 5, Y: -2}, Object{Type: ObjectSmallRock}) _, obj = a.QueryPosition(maths.Vector{X: 5, Y: -2}) - assert.Equal(t, objects.Object{Type: objects.SmallRock}, obj) + assert.Equal(t, Object{Type: ObjectSmallRock}, obj) } func TestAtlas_Grown(t *testing.T) { @@ -239,11 +238,11 @@ func TestAtlas_GetSetCorrect(t *testing.T) { pos := maths.Vector{X: x, Y: y} a.SetTile(pos, TileRock) - a.SetObject(pos, objects.Object{Type: objects.LargeRock}) + a.SetObject(pos, Object{Type: ObjectLargeRock}) tile, obj := a.QueryPosition(pos) assert.Equal(t, TileRock, Tile(tile)) - assert.Equal(t, objects.Object{Type: objects.LargeRock}, obj) + assert.Equal(t, Object{Type: ObjectLargeRock}, obj) } } @@ -260,7 +259,7 @@ func TestAtlas_WorldGen(t *testing.T) { for j := num - 1; j >= 0; j-- { for i := 0; i < num; i++ { t, o := a.QueryPosition(maths.Vector{X: i, Y: j}) - if o.Type != objects.None { + if o.Type != ObjectNone { fmt.Printf("%c", o.Type) } else if t != byte(TileNone) { fmt.Printf("%c", t) diff --git a/pkg/atlas/chunkAtlas.go b/pkg/atlas/chunkAtlas.go index c3c969e..daee6e6 100644 --- a/pkg/atlas/chunkAtlas.go +++ b/pkg/atlas/chunkAtlas.go @@ -5,7 +5,6 @@ import ( "math/rand" "github.com/mdiluz/rove/pkg/maths" - "github.com/mdiluz/rove/pkg/objects" "github.com/ojrac/opensimplex-go" ) @@ -16,7 +15,7 @@ type chunk struct { // Objects represents the objects within the chunk // only one possible object per tile for now - Objects map[int]objects.Object `json:"objects"` + Objects map[int]Object `json:"objects"` } // chunkBasedAtlas represents a grid of Chunks @@ -71,14 +70,14 @@ func (a *chunkBasedAtlas) SetTile(v maths.Vector, tile Tile) { } // SetObject sets the object on a tile -func (a *chunkBasedAtlas) SetObject(v maths.Vector, obj objects.Object) { +func (a *chunkBasedAtlas) SetObject(v maths.Vector, obj Object) { c := a.worldSpaceToChunkWithGrow(v) local := a.worldSpaceToChunkLocal(v) a.setObject(c, local, obj) } // QueryPosition will return information for a specific position -func (a *chunkBasedAtlas) QueryPosition(v maths.Vector) (byte, objects.Object) { +func (a *chunkBasedAtlas) QueryPosition(v maths.Vector) (byte, Object) { c := a.worldSpaceToChunkWithGrow(v) local := a.worldSpaceToChunkLocal(v) a.populate(c) @@ -100,7 +99,7 @@ func (a *chunkBasedAtlas) populate(chunk int) { } c.Tiles = make([]byte, a.ChunkSize*a.ChunkSize) - c.Objects = make(map[int]objects.Object) + c.Objects = make(map[int]Object) origin := a.chunkOriginInWorldSpace(chunk) for i := 0; i < a.ChunkSize; i++ { @@ -121,15 +120,15 @@ func (a *chunkBasedAtlas) populate(chunk int) { // Get the object noise value for this location o := a.objectNoise.Eval2(float64(origin.X+i)/objectNoiseScale, float64(origin.Y+j)/objectNoiseScale) - var obj = objects.None + var obj = ObjectNone switch { case o > 0.6: - obj = objects.LargeRock + obj = ObjectLargeRock case o > 0.5: - obj = objects.SmallRock + obj = ObjectSmallRock } - if obj != objects.None { - c.Objects[j*a.ChunkSize+i] = objects.Object{Type: obj} + if obj != ObjectNone { + c.Objects[j*a.ChunkSize+i] = Object{Type: obj} } } } @@ -137,9 +136,9 @@ func (a *chunkBasedAtlas) populate(chunk int) { // Set up any objects for i := 0; i < len(c.Tiles); i++ { if rand.Intn(16) == 0 { - c.Objects[i] = objects.Object{Type: objects.LargeRock} + c.Objects[i] = Object{Type: ObjectLargeRock} } else if rand.Intn(32) == 0 { - c.Objects[i] = objects.Object{Type: objects.SmallRock} + c.Objects[i] = Object{Type: ObjectSmallRock} } } @@ -155,12 +154,12 @@ func (a *chunkBasedAtlas) setTile(chunk int, local maths.Vector, tile byte) { } // setObject sets an object in a specific chunk -func (a *chunkBasedAtlas) setObject(chunk int, local maths.Vector, object objects.Object) { +func (a *chunkBasedAtlas) setObject(chunk int, local maths.Vector, object Object) { a.populate(chunk) c := a.Chunks[chunk] i := a.chunkTileIndex(local) - if object.Type != objects.None { + if object.Type != ObjectNone { c.Objects[i] = object } else { delete(c.Objects, i) diff --git a/pkg/objects/objects.go b/pkg/atlas/objects.go similarity index 63% rename from pkg/objects/objects.go rename to pkg/atlas/objects.go index 9338b68..68b4ef8 100644 --- a/pkg/objects/objects.go +++ b/pkg/atlas/objects.go @@ -1,21 +1,21 @@ -package objects +package atlas // Type represents an object type type Type byte // Types of objects const ( - // None represents no object at all - None = Type(0) + // ObjectNone represents no object at all + ObjectNone = Type(0) - // Rover represents a live rover - Rover = Type('R') + // ObjectRover represents a live rover + ObjectRover = Type('R') - // SmallRock is a small stashable rock - SmallRock = Type('o') + // ObjectSmallRock is a small stashable rock + ObjectSmallRock = Type('o') - // LargeRock is a large blocking rock - LargeRock = Type('O') + // ObjectLargeRock is a large blocking rock + ObjectLargeRock = Type('O') ) // Object represents an object in the world @@ -26,8 +26,8 @@ type Object struct { // IsBlocking checks if an object is a blocking object func (o *Object) IsBlocking() bool { var blocking = [...]Type{ - Rover, - LargeRock, + ObjectRover, + ObjectLargeRock, } for _, t := range blocking { @@ -41,7 +41,7 @@ func (o *Object) IsBlocking() bool { // IsStashable checks if an object is stashable func (o *Object) IsStashable() bool { var stashable = [...]Type{ - SmallRock, + ObjectSmallRock, } for _, t := range stashable { diff --git a/pkg/rove/rover.go b/pkg/rove/rover.go index 45fb8f0..089b44a 100644 --- a/pkg/rove/rover.go +++ b/pkg/rove/rover.go @@ -5,8 +5,8 @@ import ( "log" "time" + "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/maths" - "github.com/mdiluz/rove/pkg/objects" ) // RoverLogEntry describes a single log entry for the rover @@ -30,7 +30,7 @@ type Rover struct { Range int `json:"range"` // Inventory represents any items the rover is carrying - Inventory []objects.Object `json:"inventory"` + Inventory []atlas.Object `json:"inventory"` // Capacity is the maximum number of inventory items Capacity int `json:"capacity"` diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 559073e..b0e796f 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -11,7 +11,6 @@ import ( "github.com/google/uuid" "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/maths" - "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/roveapi" ) @@ -241,7 +240,7 @@ func (w *World) SetRoverPosition(rover string, pos maths.Vector) error { } // RoverInventory returns the inventory of a requested rover -func (w *World) RoverInventory(rover string) ([]objects.Object, error) { +func (w *World) RoverInventory(rover string) ([]atlas.Object, error) { w.worldMutex.RLock() defer w.worldMutex.RUnlock() @@ -319,35 +318,35 @@ func (w *World) MoveRover(rover string, b maths.Bearing) (maths.Vector, error) { } // RoverStash will stash an item at the current rovers position -func (w *World) RoverStash(rover string) (objects.Type, error) { +func (w *World) RoverStash(rover string) (atlas.Type, error) { w.worldMutex.Lock() defer w.worldMutex.Unlock() r, ok := w.Rovers[rover] if !ok { - return objects.None, fmt.Errorf("no rover matching id") + return atlas.ObjectNone, fmt.Errorf("no rover matching id") } // Can't pick up when full if len(r.Inventory) >= r.Capacity { - return objects.None, nil + return atlas.ObjectNone, nil } // Ensure the rover has energy if r.Charge <= 0 { - return objects.None, nil + return atlas.ObjectNone, nil } r.Charge-- _, obj := w.Atlas.QueryPosition(r.Pos) if !obj.IsStashable() { - return objects.None, nil + return atlas.ObjectNone, nil } r.AddLogEntryf("stashed %c", obj.Type) r.Inventory = append(r.Inventory, obj) w.Rovers[rover] = r - w.Atlas.SetObject(r.Pos, objects.Object{Type: objects.None}) + w.Atlas.SetObject(r.Pos, atlas.Object{Type: atlas.ObjectNone}) return obj.Type, nil } @@ -402,7 +401,7 @@ func (w *World) RadarFromRover(rover string) (radar []byte, objs []byte, err err if dist.X <= r.Range && dist.Y <= r.Range { relative := r.Pos.Added(radarMin.Negated()) index := relative.X + relative.Y*radarSpan - objs[index] = byte(objects.Rover) + objs[index] = byte(atlas.ObjectRover) } } diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index 78e9160..ceaff43 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -5,7 +5,6 @@ import ( "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/maths" - "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/roveapi" "github.com/stretchr/testify/assert" ) @@ -91,7 +90,7 @@ func TestWorld_GetSetMovePosition(t *testing.T) { assert.Contains(t, rover.Logs[len(rover.Logs)-1].Text, "moved", "Rover logs should contain the move") // Place a tile in front of the rover - world.Atlas.SetObject(maths.Vector{X: 0, Y: 2}, objects.Object{Type: objects.LargeRock}) + world.Atlas.SetObject(maths.Vector{X: 0, Y: 2}, atlas.Object{Type: atlas.ObjectLargeRock}) newPos, err = world.MoveRover(a, b) assert.NoError(t, err, "Failed to move rover") assert.Equal(t, pos, newPos, "Failed to correctly not move position for rover into wall") @@ -121,8 +120,8 @@ func TestWorld_RadarFromRover(t *testing.T) { assert.Equal(t, fullRange*fullRange, len(objs), "Radar returned wrong length") // Test the expected values - assert.Equal(t, byte(objects.Rover), objs[1+fullRange]) - assert.Equal(t, byte(objects.Rover), objs[4+4*fullRange]) + assert.Equal(t, byte(atlas.ObjectRover), objs[1+fullRange]) + assert.Equal(t, byte(atlas.ObjectRover), objs[4+4*fullRange]) // Check the radar results are stable radar1, objs1, err := world.RadarFromRover(a) @@ -143,7 +142,7 @@ func TestWorld_RoverStash(t *testing.T) { Y: 0.0, } - world.Atlas.SetObject(pos, objects.Object{Type: objects.None}) + world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectNone}) err = world.WarpRover(a, pos) assert.NoError(t, err, "Failed to set position for rover") @@ -155,22 +154,22 @@ func TestWorld_RoverStash(t *testing.T) { for i := 0; i < rover.Capacity; i++ { // Place an object - world.Atlas.SetObject(pos, objects.Object{Type: objects.SmallRock}) + world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectSmallRock}) // Pick it up o, err := world.RoverStash(a) assert.NoError(t, err, "Failed to stash") - assert.Equal(t, objects.SmallRock, o, "Failed to get correct object") + assert.Equal(t, atlas.ObjectSmallRock, o, "Failed to get correct object") // Check it's gone _, obj := world.Atlas.QueryPosition(pos) - assert.Equal(t, objects.None, obj.Type, "Stash failed to remove object from atlas") + assert.Equal(t, atlas.ObjectNone, obj.Type, "Stash failed to remove object from atlas") // Check we have it inv, err := world.RoverInventory(a) assert.NoError(t, err, "Failed to get inventory") assert.Equal(t, i+1, len(inv)) - assert.Equal(t, objects.Object{Type: objects.SmallRock}, inv[i]) + assert.Equal(t, atlas.Object{Type: atlas.ObjectSmallRock}, inv[i]) // Check that this did reduce the charge info, err := world.GetRover(a) @@ -187,16 +186,16 @@ func TestWorld_RoverStash(t *testing.T) { } // Place an object - world.Atlas.SetObject(pos, objects.Object{Type: objects.SmallRock}) + world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectSmallRock}) // Try to pick it up o, err := world.RoverStash(a) assert.NoError(t, err, "Failed to stash") - assert.Equal(t, objects.None, o, "Failed to get correct object") + assert.Equal(t, atlas.ObjectNone, o, "Failed to get correct object") // Check it's still there _, obj := world.Atlas.QueryPosition(pos) - assert.Equal(t, objects.SmallRock, obj.Type, "Stash failed to remove object from atlas") + assert.Equal(t, atlas.ObjectSmallRock, obj.Type, "Stash failed to remove object from atlas") // Check we don't have it inv, err := world.RoverInventory(a) @@ -225,7 +224,7 @@ func TestWorld_RoverDamage(t *testing.T) { info, err := world.GetRover(a) assert.NoError(t, err, "couldn't get rover info") - world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, objects.Object{Type: objects.LargeRock}) + world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, atlas.Object{Type: atlas.ObjectLargeRock}) vec, err := world.MoveRover(a, maths.North) assert.NoError(t, err, "Failed to move rover") @@ -248,7 +247,7 @@ func TestWorld_RoverRepair(t *testing.T) { } world.Atlas.SetTile(pos, atlas.TileNone) - world.Atlas.SetObject(pos, objects.Object{Type: objects.None}) + world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectNone}) err = world.WarpRover(a, pos) assert.NoError(t, err, "Failed to set position for rover") @@ -257,12 +256,12 @@ func TestWorld_RoverRepair(t *testing.T) { assert.NoError(t, err, "couldn't get rover info") // Pick up something to repair with - world.Atlas.SetObject(pos, objects.Object{Type: objects.SmallRock}) + world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectSmallRock}) o, err := world.RoverStash(a) assert.NoError(t, err, "Failed to stash") - assert.Equal(t, objects.SmallRock, o, "Failed to get correct object") + assert.Equal(t, atlas.ObjectSmallRock, o, "Failed to get correct object") - world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, objects.Object{Type: objects.LargeRock}) + world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, atlas.Object{Type: atlas.ObjectLargeRock}) // Try and bump into the rock vec, err := world.MoveRover(a, maths.North) @@ -282,10 +281,10 @@ func TestWorld_RoverRepair(t *testing.T) { assert.Contains(t, newinfo.Logs[len(newinfo.Logs)-1].Text, "repair", "Rover logs should contain the repair") // Check again that it can't repair past the max - world.Atlas.SetObject(pos, objects.Object{Type: objects.SmallRock}) + world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectSmallRock}) o, err = world.RoverStash(a) assert.NoError(t, err, "Failed to stash") - assert.Equal(t, objects.SmallRock, o, "Failed to get correct object") + assert.Equal(t, atlas.ObjectSmallRock, o, "Failed to get correct object") err = world.ExecuteCommand(&Command{Command: roveapi.CommandType_repair}, a) assert.NoError(t, err, "Failed to repair rover") @@ -313,7 +312,7 @@ func TestWorld_Charge(t *testing.T) { // Ensure the path ahead is empty world.Atlas.SetTile(initialPos.Added(maths.North.Vector()), atlas.TileRock) - world.Atlas.SetObject(initialPos.Added(maths.North.Vector()), objects.Object{Type: objects.None}) + world.Atlas.SetObject(initialPos.Added(maths.North.Vector()), atlas.Object{Type: atlas.ObjectNone}) // Try and move north (along unblocked path) newPos, err := world.MoveRover(a, maths.North) @@ -395,7 +394,7 @@ func TestWorld_Broadcast(t *testing.T) { assert.Contains(t, rb.Logs[len(rb.Logs)-1].Text, "ABC", "Rover A should have logged it's broadcast") // Warp B outside of the range of A - world.Atlas.SetObject(maths.Vector{X: ra.Range, Y: 0}, objects.Object{Type: objects.None}) + world.Atlas.SetObject(maths.Vector{X: ra.Range, Y: 0}, atlas.Object{Type: atlas.ObjectNone}) assert.NoError(t, world.WarpRover(b, maths.Vector{X: ra.Range, Y: 0})) // Broadcast from a again @@ -412,7 +411,7 @@ func TestWorld_Broadcast(t *testing.T) { assert.Contains(t, rb.Logs[len(rb.Logs)-1].Text, "XYZ", "Rover A should have logged it's broadcast") // Warp B outside of the range of A - world.Atlas.SetObject(maths.Vector{X: ra.Range + 1, Y: 0}, objects.Object{Type: objects.None}) + world.Atlas.SetObject(maths.Vector{X: ra.Range + 1, Y: 0}, atlas.Object{Type: atlas.ObjectNone}) assert.NoError(t, world.WarpRover(b, maths.Vector{X: ra.Range + 1, Y: 0})) // Broadcast from a again From 9ccb7ac019189d2693f949a26019fc2b82f12005 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 18:48:03 +0100 Subject: [PATCH 114/228] Remove google proto files, no longer needed --- proto/google/README.grpc-gateway | 23 -- proto/google/api/annotations.proto | 31 --- proto/google/api/http.proto | 318 --------------------------- proto/google/api/httpbody.proto | 78 ------- proto/google/rpc/code.proto | 186 ---------------- proto/google/rpc/error_details.proto | 200 ----------------- proto/google/rpc/status.proto | 92 -------- 7 files changed, 928 deletions(-) delete mode 100644 proto/google/README.grpc-gateway delete mode 100644 proto/google/api/annotations.proto delete mode 100644 proto/google/api/http.proto delete mode 100644 proto/google/api/httpbody.proto delete mode 100644 proto/google/rpc/code.proto delete mode 100644 proto/google/rpc/error_details.proto delete mode 100644 proto/google/rpc/status.proto diff --git a/proto/google/README.grpc-gateway b/proto/google/README.grpc-gateway deleted file mode 100644 index b7d1bea..0000000 --- a/proto/google/README.grpc-gateway +++ /dev/null @@ -1,23 +0,0 @@ -Google APIs -============ - -Project: Google APIs -URL: https://github.com/google/googleapis -Revision: 3544ab16c3342d790b00764251e348705991ea4b -License: Apache License 2.0 - - -Imported Files ---------------- - -- google/api/annotations.proto -- google/api/http.proto -- google/api/httpbody.proto - - -Generated Files ----------------- - -They are generated from the .proto files by protoc-gen-go. -- google/api/annotations.pb.go -- google/api/http.pb.go diff --git a/proto/google/api/annotations.proto b/proto/google/api/annotations.proto deleted file mode 100644 index 85c361b..0000000 --- a/proto/google/api/annotations.proto +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2015, Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api; - -import "google/api/http.proto"; -import "google/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "AnnotationsProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -extend google.protobuf.MethodOptions { - // See `HttpRule`. - HttpRule http = 72295728; -} diff --git a/proto/google/api/http.proto b/proto/google/api/http.proto deleted file mode 100644 index 2bd3a19..0000000 --- a/proto/google/api/http.proto +++ /dev/null @@ -1,318 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "HttpProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - - -// Defines the HTTP configuration for an API service. It contains a list of -// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method -// to one or more HTTP REST API methods. -message Http { - // A list of HTTP configuration rules that apply to individual API methods. - // - // **NOTE:** All service configuration rules follow "last one wins" order. - repeated HttpRule rules = 1; - - // When set to true, URL path parmeters will be fully URI-decoded except in - // cases of single segment matches in reserved expansion, where "%2F" will be - // left encoded. - // - // The default behavior is to not decode RFC 6570 reserved characters in multi - // segment matches. - bool fully_decode_reserved_expansion = 2; -} - -// `HttpRule` defines the mapping of an RPC method to one or more HTTP -// REST API methods. The mapping specifies how different portions of the RPC -// request message are mapped to URL path, URL query parameters, and -// HTTP request body. The mapping is typically specified as an -// `google.api.http` annotation on the RPC method, -// see "google/api/annotations.proto" for details. -// -// The mapping consists of a field specifying the path template and -// method kind. The path template can refer to fields in the request -// message, as in the example below which describes a REST GET -// operation on a resource collection of messages: -// -// -// service Messaging { -// rpc GetMessage(GetMessageRequest) returns (Message) { -// option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; -// } -// } -// message GetMessageRequest { -// message SubMessage { -// string subfield = 1; -// } -// string message_id = 1; // mapped to the URL -// SubMessage sub = 2; // `sub.subfield` is url-mapped -// } -// message Message { -// string text = 1; // content of the resource -// } -// -// The same http annotation can alternatively be expressed inside the -// `GRPC API Configuration` YAML file. -// -// http: -// rules: -// - selector: .Messaging.GetMessage -// get: /v1/messages/{message_id}/{sub.subfield} -// -// This definition enables an automatic, bidrectional mapping of HTTP -// JSON to RPC. Example: -// -// HTTP | RPC -// -----|----- -// `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` -// -// In general, not only fields but also field paths can be referenced -// from a path pattern. Fields mapped to the path pattern cannot be -// repeated and must have a primitive (non-message) type. -// -// Any fields in the request message which are not bound by the path -// pattern automatically become (optional) HTTP query -// parameters. Assume the following definition of the request message: -// -// -// service Messaging { -// rpc GetMessage(GetMessageRequest) returns (Message) { -// option (google.api.http).get = "/v1/messages/{message_id}"; -// } -// } -// message GetMessageRequest { -// message SubMessage { -// string subfield = 1; -// } -// string message_id = 1; // mapped to the URL -// int64 revision = 2; // becomes a parameter -// SubMessage sub = 3; // `sub.subfield` becomes a parameter -// } -// -// -// This enables a HTTP JSON to RPC mapping as below: -// -// HTTP | RPC -// -----|----- -// `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` -// -// Note that fields which are mapped to HTTP parameters must have a -// primitive type or a repeated primitive type. Message types are not -// allowed. In the case of a repeated type, the parameter can be -// repeated in the URL, as in `...?param=A¶m=B`. -// -// For HTTP method kinds which allow a request body, the `body` field -// specifies the mapping. Consider a REST update method on the -// message resource collection: -// -// -// service Messaging { -// rpc UpdateMessage(UpdateMessageRequest) returns (Message) { -// option (google.api.http) = { -// put: "/v1/messages/{message_id}" -// body: "message" -// }; -// } -// } -// message UpdateMessageRequest { -// string message_id = 1; // mapped to the URL -// Message message = 2; // mapped to the body -// } -// -// -// The following HTTP JSON to RPC mapping is enabled, where the -// representation of the JSON in the request body is determined by -// protos JSON encoding: -// -// HTTP | RPC -// -----|----- -// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` -// -// The special name `*` can be used in the body mapping to define that -// every field not bound by the path template should be mapped to the -// request body. This enables the following alternative definition of -// the update method: -// -// service Messaging { -// rpc UpdateMessage(Message) returns (Message) { -// option (google.api.http) = { -// put: "/v1/messages/{message_id}" -// body: "*" -// }; -// } -// } -// message Message { -// string message_id = 1; -// string text = 2; -// } -// -// -// The following HTTP JSON to RPC mapping is enabled: -// -// HTTP | RPC -// -----|----- -// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` -// -// Note that when using `*` in the body mapping, it is not possible to -// have HTTP parameters, as all fields not bound by the path end in -// the body. This makes this option more rarely used in practice of -// defining REST APIs. The common usage of `*` is in custom methods -// which don't use the URL at all for transferring data. -// -// It is possible to define multiple HTTP methods for one RPC by using -// the `additional_bindings` option. Example: -// -// service Messaging { -// rpc GetMessage(GetMessageRequest) returns (Message) { -// option (google.api.http) = { -// get: "/v1/messages/{message_id}" -// additional_bindings { -// get: "/v1/users/{user_id}/messages/{message_id}" -// } -// }; -// } -// } -// message GetMessageRequest { -// string message_id = 1; -// string user_id = 2; -// } -// -// -// This enables the following two alternative HTTP JSON to RPC -// mappings: -// -// HTTP | RPC -// -----|----- -// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` -// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` -// -// # Rules for HTTP mapping -// -// The rules for mapping HTTP path, query parameters, and body fields -// to the request message are as follows: -// -// 1. The `body` field specifies either `*` or a field path, or is -// omitted. If omitted, it indicates there is no HTTP request body. -// 2. Leaf fields (recursive expansion of nested messages in the -// request) can be classified into three types: -// (a) Matched in the URL template. -// (b) Covered by body (if body is `*`, everything except (a) fields; -// else everything under the body field) -// (c) All other fields. -// 3. URL query parameters found in the HTTP request are mapped to (c) fields. -// 4. Any body sent with an HTTP request can contain only (b) fields. -// -// The syntax of the path template is as follows: -// -// Template = "/" Segments [ Verb ] ; -// Segments = Segment { "/" Segment } ; -// Segment = "*" | "**" | LITERAL | Variable ; -// Variable = "{" FieldPath [ "=" Segments ] "}" ; -// FieldPath = IDENT { "." IDENT } ; -// Verb = ":" LITERAL ; -// -// The syntax `*` matches a single path segment. The syntax `**` matches zero -// or more path segments, which must be the last part of the path except the -// `Verb`. The syntax `LITERAL` matches literal text in the path. -// -// The syntax `Variable` matches part of the URL path as specified by its -// template. A variable template must not contain other variables. If a variable -// matches a single path segment, its template may be omitted, e.g. `{var}` -// is equivalent to `{var=*}`. -// -// If a variable contains exactly one path segment, such as `"{var}"` or -// `"{var=*}"`, when such a variable is expanded into a URL path, all characters -// except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the -// Discovery Document as `{var}`. -// -// If a variable contains one or more path segments, such as `"{var=foo/*}"` -// or `"{var=**}"`, when such a variable is expanded into a URL path, all -// characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables -// show up in the Discovery Document as `{+var}`. -// -// NOTE: While the single segment variable matches the semantics of -// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 -// Simple String Expansion, the multi segment variable **does not** match -// RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion -// does not expand special characters like `?` and `#`, which would lead -// to invalid URLs. -// -// NOTE: the field paths in variables and in the `body` must not refer to -// repeated fields or map fields. -message HttpRule { - // Selects methods to which this rule applies. - // - // Refer to [selector][google.api.DocumentationRule.selector] for syntax details. - string selector = 1; - - // Determines the URL pattern is matched by this rules. This pattern can be - // used with any of the {get|put|post|delete|patch} methods. A custom method - // can be defined using the 'custom' field. - oneof pattern { - // Used for listing and getting information about resources. - string get = 2; - - // Used for updating a resource. - string put = 3; - - // Used for creating a resource. - string post = 4; - - // Used for deleting a resource. - string delete = 5; - - // Used for updating a resource. - string patch = 6; - - // The custom pattern is used for specifying an HTTP method that is not - // included in the `pattern` field, such as HEAD, or "*" to leave the - // HTTP method unspecified for this rule. The wild-card rule is useful - // for services that provide content to Web (HTML) clients. - CustomHttpPattern custom = 8; - } - - // The name of the request field whose value is mapped to the HTTP body, or - // `*` for mapping all fields not captured by the path pattern to the HTTP - // body. NOTE: the referred field must not be a repeated field and must be - // present at the top-level of request message type. - string body = 7; - - // Optional. The name of the response field whose value is mapped to the HTTP - // body of response. Other response fields are ignored. When - // not set, the response message will be used as HTTP body of response. - string response_body = 12; - - // Additional HTTP bindings for the selector. Nested bindings must - // not contain an `additional_bindings` field themselves (that is, - // the nesting may only be one level deep). - repeated HttpRule additional_bindings = 11; -} - -// A custom pattern is used for defining custom HTTP verb. -message CustomHttpPattern { - // The name of this custom HTTP verb. - string kind = 1; - - // The path matched by this custom verb. - string path = 2; -} diff --git a/proto/google/api/httpbody.proto b/proto/google/api/httpbody.proto deleted file mode 100644 index 4428515..0000000 --- a/proto/google/api/httpbody.proto +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2018 Google LLC. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -syntax = "proto3"; - -package google.api; - -import "google/protobuf/any.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/api/httpbody;httpbody"; -option java_multiple_files = true; -option java_outer_classname = "HttpBodyProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -// Message that represents an arbitrary HTTP body. It should only be used for -// payload formats that can't be represented as JSON, such as raw binary or -// an HTML page. -// -// -// This message can be used both in streaming and non-streaming API methods in -// the request as well as the response. -// -// It can be used as a top-level request field, which is convenient if one -// wants to extract parameters from either the URL or HTTP template into the -// request fields and also want access to the raw HTTP body. -// -// Example: -// -// message GetResourceRequest { -// // A unique request id. -// string request_id = 1; -// -// // The raw HTTP body is bound to this field. -// google.api.HttpBody http_body = 2; -// } -// -// service ResourceService { -// rpc GetResource(GetResourceRequest) returns (google.api.HttpBody); -// rpc UpdateResource(google.api.HttpBody) returns -// (google.protobuf.Empty); -// } -// -// Example with streaming methods: -// -// service CaldavService { -// rpc GetCalendar(stream google.api.HttpBody) -// returns (stream google.api.HttpBody); -// rpc UpdateCalendar(stream google.api.HttpBody) -// returns (stream google.api.HttpBody); -// } -// -// Use of this type only changes how the request and response bodies are -// handled, all other features will continue to work unchanged. -message HttpBody { - // The HTTP Content-Type header value specifying the content type of the body. - string content_type = 1; - - // The HTTP request/response body as raw binary. - bytes data = 2; - - // Application specific response metadata. Must be set in the first response - // for streaming APIs. - repeated google.protobuf.Any extensions = 3; -} \ No newline at end of file diff --git a/proto/google/rpc/code.proto b/proto/google/rpc/code.proto deleted file mode 100644 index 8fef411..0000000 --- a/proto/google/rpc/code.proto +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright 2017 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.rpc; - -option go_package = "google.golang.org/genproto/googleapis/rpc/code;code"; -option java_multiple_files = true; -option java_outer_classname = "CodeProto"; -option java_package = "com.google.rpc"; -option objc_class_prefix = "RPC"; - - -// The canonical error codes for Google APIs. -// -// -// Sometimes multiple error codes may apply. Services should return -// the most specific error code that applies. For example, prefer -// `OUT_OF_RANGE` over `FAILED_PRECONDITION` if both codes apply. -// Similarly prefer `NOT_FOUND` or `ALREADY_EXISTS` over `FAILED_PRECONDITION`. -enum Code { - // Not an error; returned on success - // - // HTTP Mapping: 200 OK - OK = 0; - - // The operation was cancelled, typically by the caller. - // - // HTTP Mapping: 499 Client Closed Request - CANCELLED = 1; - - // Unknown error. For example, this error may be returned when - // a `Status` value received from another address space belongs to - // an error space that is not known in this address space. Also - // errors raised by APIs that do not return enough error information - // may be converted to this error. - // - // HTTP Mapping: 500 Internal Server Error - UNKNOWN = 2; - - // The client specified an invalid argument. Note that this differs - // from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments - // that are problematic regardless of the state of the system - // (e.g., a malformed file name). - // - // HTTP Mapping: 400 Bad Request - INVALID_ARGUMENT = 3; - - // The deadline expired before the operation could complete. For operations - // that change the state of the system, this error may be returned - // even if the operation has completed successfully. For example, a - // successful response from a server could have been delayed long - // enough for the deadline to expire. - // - // HTTP Mapping: 504 Gateway Timeout - DEADLINE_EXCEEDED = 4; - - // Some requested entity (e.g., file or directory) was not found. - // - // Note to server developers: if a request is denied for an entire class - // of users, such as gradual feature rollout or undocumented whitelist, - // `NOT_FOUND` may be used. If a request is denied for some users within - // a class of users, such as user-based access control, `PERMISSION_DENIED` - // must be used. - // - // HTTP Mapping: 404 Not Found - NOT_FOUND = 5; - - // The entity that a client attempted to create (e.g., file or directory) - // already exists. - // - // HTTP Mapping: 409 Conflict - ALREADY_EXISTS = 6; - - // The caller does not have permission to execute the specified - // operation. `PERMISSION_DENIED` must not be used for rejections - // caused by exhausting some resource (use `RESOURCE_EXHAUSTED` - // instead for those errors). `PERMISSION_DENIED` must not be - // used if the caller can not be identified (use `UNAUTHENTICATED` - // instead for those errors). This error code does not imply the - // request is valid or the requested entity exists or satisfies - // other pre-conditions. - // - // HTTP Mapping: 403 Forbidden - PERMISSION_DENIED = 7; - - // The request does not have valid authentication credentials for the - // operation. - // - // HTTP Mapping: 401 Unauthorized - UNAUTHENTICATED = 16; - - // Some resource has been exhausted, perhaps a per-user quota, or - // perhaps the entire file system is out of space. - // - // HTTP Mapping: 429 Too Many Requests - RESOURCE_EXHAUSTED = 8; - - // The operation was rejected because the system is not in a state - // required for the operation's execution. For example, the directory - // to be deleted is non-empty, an rmdir operation is applied to - // a non-directory, etc. - // - // Service implementors can use the following guidelines to decide - // between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`: - // (a) Use `UNAVAILABLE` if the client can retry just the failing call. - // (b) Use `ABORTED` if the client should retry at a higher level - // (e.g., when a client-specified test-and-set fails, indicating the - // client should restart a read-modify-write sequence). - // (c) Use `FAILED_PRECONDITION` if the client should not retry until - // the system state has been explicitly fixed. E.g., if an "rmdir" - // fails because the directory is non-empty, `FAILED_PRECONDITION` - // should be returned since the client should not retry unless - // the files are deleted from the directory. - // - // HTTP Mapping: 400 Bad Request - FAILED_PRECONDITION = 9; - - // The operation was aborted, typically due to a concurrency issue such as - // a sequencer check failure or transaction abort. - // - // See the guidelines above for deciding between `FAILED_PRECONDITION`, - // `ABORTED`, and `UNAVAILABLE`. - // - // HTTP Mapping: 409 Conflict - ABORTED = 10; - - // The operation was attempted past the valid range. E.g., seeking or - // reading past end-of-file. - // - // Unlike `INVALID_ARGUMENT`, this error indicates a problem that may - // be fixed if the system state changes. For example, a 32-bit file - // system will generate `INVALID_ARGUMENT` if asked to read at an - // offset that is not in the range [0,2^32-1], but it will generate - // `OUT_OF_RANGE` if asked to read from an offset past the current - // file size. - // - // There is a fair bit of overlap between `FAILED_PRECONDITION` and - // `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific - // error) when it applies so that callers who are iterating through - // a space can easily look for an `OUT_OF_RANGE` error to detect when - // they are done. - // - // HTTP Mapping: 400 Bad Request - OUT_OF_RANGE = 11; - - // The operation is not implemented or is not supported/enabled in this - // service. - // - // HTTP Mapping: 501 Not Implemented - UNIMPLEMENTED = 12; - - // Internal errors. This means that some invariants expected by the - // underlying system have been broken. This error code is reserved - // for serious errors. - // - // HTTP Mapping: 500 Internal Server Error - INTERNAL = 13; - - // The service is currently unavailable. This is most likely a - // transient condition, which can be corrected by retrying with - // a backoff. - // - // See the guidelines above for deciding between `FAILED_PRECONDITION`, - // `ABORTED`, and `UNAVAILABLE`. - // - // HTTP Mapping: 503 Service Unavailable - UNAVAILABLE = 14; - - // Unrecoverable data loss or corruption. - // - // HTTP Mapping: 500 Internal Server Error - DATA_LOSS = 15; -} diff --git a/proto/google/rpc/error_details.proto b/proto/google/rpc/error_details.proto deleted file mode 100644 index f24ae00..0000000 --- a/proto/google/rpc/error_details.proto +++ /dev/null @@ -1,200 +0,0 @@ -// Copyright 2017 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.rpc; - -import "google/protobuf/duration.proto"; - -option go_package = "google.golang.org/genproto/googleapis/rpc/errdetails;errdetails"; -option java_multiple_files = true; -option java_outer_classname = "ErrorDetailsProto"; -option java_package = "com.google.rpc"; -option objc_class_prefix = "RPC"; - - -// Describes when the clients can retry a failed request. Clients could ignore -// the recommendation here or retry when this information is missing from error -// responses. -// -// It's always recommended that clients should use exponential backoff when -// retrying. -// -// Clients should wait until `retry_delay` amount of time has passed since -// receiving the error response before retrying. If retrying requests also -// fail, clients should use an exponential backoff scheme to gradually increase -// the delay between retries based on `retry_delay`, until either a maximum -// number of retires have been reached or a maximum retry delay cap has been -// reached. -message RetryInfo { - // Clients should wait at least this long between retrying the same request. - google.protobuf.Duration retry_delay = 1; -} - -// Describes additional debugging info. -message DebugInfo { - // The stack trace entries indicating where the error occurred. - repeated string stack_entries = 1; - - // Additional debugging information provided by the server. - string detail = 2; -} - -// Describes how a quota check failed. -// -// For example if a daily limit was exceeded for the calling project, -// a service could respond with a QuotaFailure detail containing the project -// id and the description of the quota limit that was exceeded. If the -// calling project hasn't enabled the service in the developer console, then -// a service could respond with the project id and set `service_disabled` -// to true. -// -// Also see RetryDetail and Help types for other details about handling a -// quota failure. -message QuotaFailure { - // A message type used to describe a single quota violation. For example, a - // daily quota or a custom quota that was exceeded. - message Violation { - // The subject on which the quota check failed. - // For example, "clientip:" or "project:". - string subject = 1; - - // A description of how the quota check failed. Clients can use this - // description to find more about the quota configuration in the service's - // public documentation, or find the relevant quota limit to adjust through - // developer console. - // - // For example: "Service disabled" or "Daily Limit for read operations - // exceeded". - string description = 2; - } - - // Describes all quota violations. - repeated Violation violations = 1; -} - -// Describes what preconditions have failed. -// -// For example, if an RPC failed because it required the Terms of Service to be -// acknowledged, it could list the terms of service violation in the -// PreconditionFailure message. -message PreconditionFailure { - // A message type used to describe a single precondition failure. - message Violation { - // The type of PreconditionFailure. We recommend using a service-specific - // enum type to define the supported precondition violation types. For - // example, "TOS" for "Terms of Service violation". - string type = 1; - - // The subject, relative to the type, that failed. - // For example, "google.com/cloud" relative to the "TOS" type would - // indicate which terms of service is being referenced. - string subject = 2; - - // A description of how the precondition failed. Developers can use this - // description to understand how to fix the failure. - // - // For example: "Terms of service not accepted". - string description = 3; - } - - // Describes all precondition violations. - repeated Violation violations = 1; -} - -// Describes violations in a client request. This error type focuses on the -// syntactic aspects of the request. -message BadRequest { - // A message type used to describe a single bad request field. - message FieldViolation { - // A path leading to a field in the request body. The value will be a - // sequence of dot-separated identifiers that identify a protocol buffer - // field. E.g., "field_violations.field" would identify this field. - string field = 1; - - // A description of why the request element is bad. - string description = 2; - } - - // Describes all violations in a client request. - repeated FieldViolation field_violations = 1; -} - -// Contains metadata about the request that clients can attach when filing a bug -// or providing other forms of feedback. -message RequestInfo { - // An opaque string that should only be interpreted by the service generating - // it. For example, it can be used to identify requests in the service's logs. - string request_id = 1; - - // Any data that was used to serve this request. For example, an encrypted - // stack trace that can be sent back to the service provider for debugging. - string serving_data = 2; -} - -// Describes the resource that is being accessed. -message ResourceInfo { - // A name for the type of resource being accessed, e.g. "sql table", - // "cloud storage bucket", "file", "Google calendar"; or the type URL - // of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic". - string resource_type = 1; - - // The name of the resource being accessed. For example, a shared calendar - // name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current - // error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED]. - string resource_name = 2; - - // The owner of the resource (optional). - // For example, "user:" or "project:". - string owner = 3; - - // Describes what error is encountered when accessing this resource. - // For example, updating a cloud project may require the `writer` permission - // on the developer console project. - string description = 4; -} - -// Provides links to documentation or for performing an out of band action. -// -// For example, if a quota check failed with an error indicating the calling -// project hasn't enabled the accessed service, this can contain a URL pointing -// directly to the right place in the developer console to flip the bit. -message Help { - // Describes a URL link. - message Link { - // Describes what the link offers. - string description = 1; - - // The URL of the link. - string url = 2; - } - - // URL(s) pointing to additional information on handling the current error. - repeated Link links = 1; -} - -// Provides a localized error message that is safe to return to the user -// which can be attached to an RPC error. -message LocalizedMessage { - // The locale used following the specification defined at - // http://www.rfc-editor.org/rfc/bcp/bcp47.txt. - // Examples are: "en-US", "fr-CH", "es-MX" - string locale = 1; - - // The localized error message in the above locale. - string message = 2; -} diff --git a/proto/google/rpc/status.proto b/proto/google/rpc/status.proto deleted file mode 100644 index 0839ee9..0000000 --- a/proto/google/rpc/status.proto +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2017 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.rpc; - -import "google/protobuf/any.proto"; - -option go_package = "google.golang.org/genproto/googleapis/rpc/status;status"; -option java_multiple_files = true; -option java_outer_classname = "StatusProto"; -option java_package = "com.google.rpc"; -option objc_class_prefix = "RPC"; - - -// The `Status` type defines a logical error model that is suitable for different -// programming environments, including REST APIs and RPC APIs. It is used by -// [gRPC](https://github.com/grpc). The error model is designed to be: -// -// - Simple to use and understand for most users -// - Flexible enough to meet unexpected needs -// -// # Overview -// -// The `Status` message contains three pieces of data: error code, error message, -// and error details. The error code should be an enum value of -// [google.rpc.Code][google.rpc.Code], but it may accept additional error codes if needed. The -// error message should be a developer-facing English message that helps -// developers *understand* and *resolve* the error. If a localized user-facing -// error message is needed, put the localized message in the error details or -// localize it in the client. The optional error details may contain arbitrary -// information about the error. There is a predefined set of error detail types -// in the package `google.rpc` that can be used for common error conditions. -// -// # Language mapping -// -// The `Status` message is the logical representation of the error model, but it -// is not necessarily the actual wire format. When the `Status` message is -// exposed in different client libraries and different wire protocols, it can be -// mapped differently. For example, it will likely be mapped to some exceptions -// in Java, but more likely mapped to some error codes in C. -// -// # Other uses -// -// The error model and the `Status` message can be used in a variety of -// environments, either with or without APIs, to provide a -// consistent developer experience across different environments. -// -// Example uses of this error model include: -// -// - Partial errors. If a service needs to return partial errors to the client, -// it may embed the `Status` in the normal response to indicate the partial -// errors. -// -// - Workflow errors. A typical workflow has multiple steps. Each step may -// have a `Status` message for error reporting. -// -// - Batch operations. If a client uses batch request and batch response, the -// `Status` message should be used directly inside batch response, one for -// each error sub-response. -// -// - Asynchronous operations. If an API call embeds asynchronous operation -// results in its response, the status of those operations should be -// represented directly using the `Status` message. -// -// - Logging. If some API errors are stored in logs, the message `Status` could -// be used directly after any stripping needed for security/privacy reasons. -message Status { - // The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - int32 code = 1; - - // A developer-facing error message, which should be in English. Any - // user-facing error message should be localized and sent in the - // [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - string message = 2; - - // A list of messages that carry the error details. There is a common set of - // message types for APIs to use. - repeated google.protobuf.Any details = 3; -} From 46f81abbd7bd72c3d5062e4d9b2e3231d80c45a0 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 18:57:57 +0100 Subject: [PATCH 115/228] Move accounts into rove-server.internal --- Makefile | 2 +- {pkg/accounts => cmd/rove-server/internal}/accounts.go | 2 +- {pkg/accounts => cmd/rove-server/internal}/accounts_test.go | 2 +- cmd/rove-server/internal/server.go | 5 ++--- .../rove-server/internal}/simpleAccountant.go | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) rename {pkg/accounts => cmd/rove-server/internal}/accounts.go (98%) rename {pkg/accounts => cmd/rove-server/internal}/accounts_test.go (98%) rename {pkg/accounts => cmd/rove-server/internal}/simpleAccountant.go (99%) diff --git a/Makefile b/Makefile index b28ac4f..b36c19a 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ VERSION := $(shell git describe --always --long --dirty --tags) build: @echo Running no-output build go mod download - go build -ldflags="-X 'github.com/mdiluz/rove/pkg/version.Version=${VERSION}'" ./... + go build -ldflags="-X 'github.com/mdiluz/rove/cmd/version.Version=${VERSION}'" ./... install: @echo Installing to GOPATH diff --git a/pkg/accounts/accounts.go b/cmd/rove-server/internal/accounts.go similarity index 98% rename from pkg/accounts/accounts.go rename to cmd/rove-server/internal/accounts.go index 69508c0..99362ad 100644 --- a/pkg/accounts/accounts.go +++ b/cmd/rove-server/internal/accounts.go @@ -1,4 +1,4 @@ -package accounts +package internal // Accountant decribes something that stores accounts and account values type Accountant interface { diff --git a/pkg/accounts/accounts_test.go b/cmd/rove-server/internal/accounts_test.go similarity index 98% rename from pkg/accounts/accounts_test.go rename to cmd/rove-server/internal/accounts_test.go index bd2416f..9e7891f 100644 --- a/pkg/accounts/accounts_test.go +++ b/cmd/rove-server/internal/accounts_test.go @@ -1,4 +1,4 @@ -package accounts +package internal import ( "testing" diff --git a/cmd/rove-server/internal/server.go b/cmd/rove-server/internal/server.go index f633601..ad0c315 100644 --- a/cmd/rove-server/internal/server.go +++ b/cmd/rove-server/internal/server.go @@ -6,7 +6,6 @@ import ( "net" "sync" - "github.com/mdiluz/rove/pkg/accounts" "github.com/mdiluz/rove/pkg/persistence" "github.com/mdiluz/rove/pkg/rove" "github.com/mdiluz/rove/pkg/roveapi" @@ -29,7 +28,7 @@ type Server struct { world *rove.World // Accountant - accountant accounts.Accountant + accountant Accountant // gRPC server netListener net.Listener @@ -81,7 +80,7 @@ func NewServer(opts ...ServerOption) *Server { persistence: EphemeralData, schedule: cron.New(), world: rove.NewWorld(32), - accountant: accounts.NewSimpleAccountant(), + accountant: NewSimpleAccountant(), } // Apply all options diff --git a/pkg/accounts/simpleAccountant.go b/cmd/rove-server/internal/simpleAccountant.go similarity index 99% rename from pkg/accounts/simpleAccountant.go rename to cmd/rove-server/internal/simpleAccountant.go index 023fe2f..3168f30 100644 --- a/pkg/accounts/simpleAccountant.go +++ b/cmd/rove-server/internal/simpleAccountant.go @@ -1,4 +1,4 @@ -package accounts +package internal import ( "fmt" From 737534f739a383b3b51fad3a90d148518019ffb5 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 19:00:31 +0100 Subject: [PATCH 116/228] Move roveapi into the proto dir --- Makefile | 10 +++------- cmd/rove-server/internal/routes.go | 2 +- cmd/rove-server/internal/server.go | 2 +- cmd/rove/main.go | 2 +- pkg/rove/command.go | 2 +- pkg/rove/command_test.go | 2 +- pkg/rove/world.go | 2 +- pkg/rove/world_test.go | 2 +- {pkg => proto}/roveapi/roveapi.pb.go | 6 +++--- proto/roveapi/roveapi.proto | 2 +- 10 files changed, 14 insertions(+), 18 deletions(-) rename {pkg => proto}/roveapi/roveapi.pb.go (99%) diff --git a/Makefile b/Makefile index b36c19a..b73faf0 100644 --- a/Makefile +++ b/Makefile @@ -12,14 +12,10 @@ install: gen: @echo Installing go dependencies - go install \ - github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway \ - github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger \ - github.com/golang/protobuf/protoc-gen-go + go install github.com/golang/protobuf/protoc-gen-go go mod download - @echo Generating rove server gRPC and gateway - protoc --proto_path proto --go_out=plugins=grpc,paths=source_relative:pkg/ proto/roveapi/roveapi.proto - protoc --proto_path proto --grpc-gateway_out=paths=source_relative:pkg/ proto/roveapi/roveapi.proto + @echo Generating rove server gRPC + protoc --proto_path proto --go_out=plugins=grpc,paths=source_relative:proto/ proto/roveapi/roveapi.proto test: @echo Unit tests diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 8e8706c..0fb41d8 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -6,8 +6,8 @@ import ( "log" "github.com/mdiluz/rove/pkg/rove" - "github.com/mdiluz/rove/pkg/roveapi" "github.com/mdiluz/rove/pkg/version" + "github.com/mdiluz/rove/proto/roveapi" ) // ServerStatus returns the status of the current server to a gRPC request diff --git a/cmd/rove-server/internal/server.go b/cmd/rove-server/internal/server.go index ad0c315..102c30d 100644 --- a/cmd/rove-server/internal/server.go +++ b/cmd/rove-server/internal/server.go @@ -8,7 +8,7 @@ import ( "github.com/mdiluz/rove/pkg/persistence" "github.com/mdiluz/rove/pkg/rove" - "github.com/mdiluz/rove/pkg/roveapi" + "github.com/mdiluz/rove/proto/roveapi" "github.com/robfig/cron" "google.golang.org/grpc" ) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 1ec0b24..8a19e68 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -12,8 +12,8 @@ import ( "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/maths" - "github.com/mdiluz/rove/pkg/roveapi" "github.com/mdiluz/rove/pkg/version" + "github.com/mdiluz/rove/proto/roveapi" "golang.org/x/net/context" "google.golang.org/grpc" ) diff --git a/pkg/rove/command.go b/pkg/rove/command.go index 6016555..86e9cad 100644 --- a/pkg/rove/command.go +++ b/pkg/rove/command.go @@ -1,6 +1,6 @@ package rove -import "github.com/mdiluz/rove/pkg/roveapi" +import "github.com/mdiluz/rove/proto/roveapi" // Command represends a single command to execute type Command struct { diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index e01a487..9150fde 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/mdiluz/rove/pkg/maths" - "github.com/mdiluz/rove/pkg/roveapi" + "github.com/mdiluz/rove/proto/roveapi" "github.com/stretchr/testify/assert" ) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index b0e796f..04cad81 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -11,7 +11,7 @@ import ( "github.com/google/uuid" "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/maths" - "github.com/mdiluz/rove/pkg/roveapi" + "github.com/mdiluz/rove/proto/roveapi" ) // World describes a self contained universe and everything in it diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index ceaff43..f3be5c0 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -5,7 +5,7 @@ import ( "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/maths" - "github.com/mdiluz/rove/pkg/roveapi" + "github.com/mdiluz/rove/proto/roveapi" "github.com/stretchr/testify/assert" ) diff --git a/pkg/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go similarity index 99% rename from pkg/roveapi/roveapi.pb.go rename to proto/roveapi/roveapi.pb.go index 491231d..1eeeabd 100644 --- a/pkg/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -1113,10 +1113,10 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x24, 0x5a, 0x22, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, - 0x65, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index f39d2a6..9dd2577 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -5,7 +5,7 @@ syntax = "proto3"; // Rove is an asychronous nomadic game about exploring a planet as part of a // loose community package roveapi; -option go_package = "github.com/mdiluz/rove/pkg/roveapi"; +option go_package = "github.com/mdiluz/rove/proto/roveapi"; // The Rove server hosts a single game session and world with multiple players service Rove { From 3bad9f012276309cfcf282e4e70e9c813af02a1f Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 20:59:26 +0100 Subject: [PATCH 117/228] Update README.md Fix proto link and amend text --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 445ecac..2aff518 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,4 @@ Rove Rove is an asynchronous nomadic game about exploring as part of a loose community. -This repository is a [living document](https://github.com/mdiluz/rove/tree/master/docs) of current game design, as well as source code for the `rove-server` deployment and the `rove` command line client. - -See [roveapi.proto](https://github.com/mdiluz/rove/blob/master/proto/rove/roveapi.proto) for the current server-client API. +This repository contains the source code for the `rove-server` deployment and the `rove` command line client. See [mdiluz.github.io/rove](https://mdiluz.github.io/rove/) for game details, and [roveapi.proto](https://github.com/mdiluz/rove/blob/master/proto/roveapi/roveapi.proto) for the current server-client API. From 5c4d7469bb0bf337a8915181e490ab2f0e842bde Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 21:30:15 +0100 Subject: [PATCH 118/228] Update the github page markdown --- docs/README.md | 72 +++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 39 deletions(-) diff --git a/docs/README.md b/docs/README.md index 21a14d0..41efc48 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,67 +1,61 @@ Rove ===== -An asynchronous nomadic game about exploring a planet as part of a loose community. +Rove is asynchronous nomadic game about exploring a planet as part of a loose community. ------------------------------------------- -## The Basics +## Core gameplay -### Core +Remotely explore the surface of a planet with an upgradable and customisable rover. Send commands to be executed asynchronously, view the rover's radar, and communicate and coordinate with other nearby rovers. -Control a rover on the surface of the planet using a remote control interface. +### Key Components -Commands are sent and happen asynchronously, and the rover feeds back information about position and surroundings, as well as photos. - -### General - -Movement is slow and sometimes dangerous. - -Resources can be collected, and rovers recharge power during the day. - -Hazards damage the rover. Resources can be spent to repair. - -Spend resources to create and spawn a new improved rover a significant distance away, leaving the current one dormant. - -"Dying" leaves the current rover dormant and assigns the users a new rover. - -Players can repair dormant rovers to gain control of them, taking on their improvements and inventory. - -### Multiplayer - -Players can see each other and use very rudimentary signals. - -Dormant rovers store full history of travel and owners, as well as their improvements and resources. +* Navigate an expansive world +* Collect resources to repair and upgrade +* Keep the rover batteries charged as you explore +* Help other players on their journey +* Explore north to discover more ------------------------------------------- -### Implementation +## Installing -* A server that receives the commands, sends out data, and handles interactions between players. +On Ubuntu: +``` +$ snap install rove +``` -* An app, or apps, that interface with the server to let you control and view rover information +Elsewhere (with [go](https://golang.org/doc/install) installed) +``` +go get github.com/mdiluz/rove +cd $GOPATH/src/github.com/mdiluz/rove/ +make install +``` ------------------------------------------- -### To Solve +### Implementation Details + +`rove-server` hosts the game world and a gRPC server to allow users to interact from any client. + +`rove` is a basic example command-line client that allows for simple play, to explore it's usage, see the output of `rove help` + +------------------------------------------- + +### "Find the fun" issues to solve * What kinds of progression/upgrades exist? - * How does the game encourage cooperation? - * How would the gameplay prevent griefing? - * What drives the exploration? ------------------------------------------- ### Key ideas left to integrate -Feeling “known for” something - the person who did X thing. Limit number of X things that can be done, possibly over time. - -A significant aspect of failure - failing must be a focus of the game. Winning the game might actually be failing in some specific way. - -A clear and well defined investment vs. payoff curve. - -Not an infinite game, let the game have a point where you’re done and can move on. +* Feeling “known for” something - the person who did X thing. Limit number of X things that can be done, possibly over time. +* A significant aspect of failure - failing must be a focus of the game. Winning the game might actually be failing in some specific way. +* A clear and well defined investment vs. payoff curve. +* Not an infinite game, let the game have a point where you’re done and can move on. From 427db95b5b05dea0d5ea380dff7c93ad72694ce2 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 21:32:02 +0100 Subject: [PATCH 119/228] Fix grammar --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 41efc48..2a0e6db 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,7 +1,7 @@ Rove ===== -Rove is asynchronous nomadic game about exploring a planet as part of a loose community. +Rove is an asynchronous nomadic game about exploring a planet as part of a loose community. ------------------------------------------- From 327c246c8e62c78f9475def05bfc2b39395ff9ac Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 21:37:19 +0100 Subject: [PATCH 120/228] Remove vscode viles --- .vscode/launch.json | 27 --------------------------- .vscode/settings.json | 5 ----- 2 files changed, 32 deletions(-) delete mode 100644 .vscode/launch.json delete mode 100644 .vscode/settings.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 57d654f..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "Launch Rove Server", - "type": "go", - "request": "launch", - "mode": "auto", - "program": "${workspaceFolder}/cmd/rove-server/main.go", - "cwd": "${workspaceFolder}", - "env": { - "WORDS_FILE": "${workspaceFolder}/data/words_alpha.txt", - }, - "args": [], - }, - { - "name": "Launch Rove", - "type": "go", - "request": "launch", - "mode": "auto", - "program": "${workspaceFolder}/cmd/rove/main.go", - "cwd": "${workspaceFolder}", - "env": {}, - "args": ["radar"], - } - ] -} diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index b3be4a5..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "gopls": { - "buildFlags": ["-tags=integration"] - }, -} \ No newline at end of file From 9593602dc5c7f898fc2c4c742990901b192954d0 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 10 Jul 2020 21:38:16 +0100 Subject: [PATCH 121/228] Move flatpak file to data --- {flatpak => data}/io.github.mdiluz.Rove.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {flatpak => data}/io.github.mdiluz.Rove.json (100%) diff --git a/flatpak/io.github.mdiluz.Rove.json b/data/io.github.mdiluz.Rove.json similarity index 100% rename from flatpak/io.github.mdiluz.Rove.json rename to data/io.github.mdiluz.Rove.json From 105d69bd7c19d9ca1eace739b9b81ca7b5499891 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 11 Jul 2020 17:25:38 +0100 Subject: [PATCH 122/228] Fix SW direction to go south rather than north --- pkg/maths/bearing.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/maths/bearing.go b/pkg/maths/bearing.go index 220855b..002b06a 100644 --- a/pkg/maths/bearing.go +++ b/pkg/maths/bearing.go @@ -66,14 +66,14 @@ func FromString(s string) (Bearing, error) { } var bearingVectors = []Vector{ - {X: 0, Y: 1}, // N - {X: 1, Y: 1}, // NE - {X: 1, Y: 0}, // E - {X: 1, Y: -1}, // SE - {X: 0, Y: -1}, // S - {X: -1, Y: 1}, // SW - {X: -1, Y: 0}, // W - {X: -1, Y: 1}, // NW + {X: 0, Y: 1}, // N + {X: 1, Y: 1}, // NE + {X: 1, Y: 0}, // E + {X: 1, Y: -1}, // SE + {X: 0, Y: -1}, // S + {X: -1, Y: -1}, // SW + {X: -1, Y: 0}, // W + {X: -1, Y: 1}, // NW } // Vector converts a Direction to a Vector From c2e3c9f0900df5b64088c822fe9541e016d5e0ea Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 11:26:08 +0100 Subject: [PATCH 123/228] Reject move commands in non-cardinal directions --- cmd/rove/main.go | 2 +- pkg/maths/bearing.go | 16 ++++++++++++++-- pkg/maths/bearing_test.go | 8 ++++---- pkg/rove/world.go | 6 ++++-- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 8a19e68..75d4e3a 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -215,7 +215,7 @@ func InnerMain(command string, args ...string) error { i++ if len(args) == i { return fmt.Errorf("move command must be passed bearing") - } else if _, err := maths.FromString(args[i]); err != nil { + } else if _, err := maths.BearingFromString(args[i]); err != nil { return err } commands = append(commands, diff --git a/pkg/maths/bearing.go b/pkg/maths/bearing.go index 002b06a..de4014d 100644 --- a/pkg/maths/bearing.go +++ b/pkg/maths/bearing.go @@ -55,8 +55,8 @@ func (d Bearing) ShortString() string { return bearingStrings[d].Short } -// FromString gets the Direction from a string -func FromString(s string) (Bearing, error) { +// BearingFromString gets the Direction from a string +func BearingFromString(s string) (Bearing, error) { for i, d := range bearingStrings { if strings.EqualFold(d.Long, s) || strings.EqualFold(d.Short, s) { return Bearing(i), nil @@ -80,3 +80,15 @@ var bearingVectors = []Vector{ func (d Bearing) Vector() Vector { return bearingVectors[d] } + +// IsCardinal returns if this is a cardinal (NESW) +func (d Bearing) IsCardinal() bool { + switch d { + case North: + case East: + case South: + case West: + return true + } + return false +} diff --git a/pkg/maths/bearing_test.go b/pkg/maths/bearing_test.go index bb97043..e0de345 100644 --- a/pkg/maths/bearing_test.go +++ b/pkg/maths/bearing_test.go @@ -13,19 +13,19 @@ func TestDirection(t *testing.T) { assert.Equal(t, "N", dir.ShortString()) assert.Equal(t, Vector{X: 0, Y: 1}, dir.Vector()) - dir, err := FromString("N") + dir, err := BearingFromString("N") assert.NoError(t, err) assert.Equal(t, North, dir) - dir, err = FromString("n") + dir, err = BearingFromString("n") assert.NoError(t, err) assert.Equal(t, North, dir) - dir, err = FromString("north") + dir, err = BearingFromString("north") assert.NoError(t, err) assert.Equal(t, North, dir) - dir, err = FromString("NorthWest") + dir, err = BearingFromString("NorthWest") assert.NoError(t, err) assert.Equal(t, NorthWest, dir) } diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 04cad81..157c636 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -426,8 +426,10 @@ func (w *World) Enqueue(rover string, commands ...Command) error { for _, c := range commands { switch c.Command { case roveapi.CommandType_move: - if _, err := maths.FromString(c.Bearing); err != nil { + if b, err := maths.BearingFromString(c.Bearing); err != nil { return fmt.Errorf("unknown bearing: %s", c.Bearing) + } else if !b.IsCardinal() { + return fmt.Errorf("bearing must be cardinal") } case roveapi.CommandType_broadcast: if len(c.Message) > 3 { @@ -505,7 +507,7 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { switch c.Command { case roveapi.CommandType_move: - if dir, err := maths.FromString(c.Bearing); err != nil { + if dir, err := maths.BearingFromString(c.Bearing); err != nil { return err } else if _, err := w.MoveRover(rover, dir); err != nil { return err From 5814ac95b87ed625baa1d7bf93735b04a2057be3 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 11:29:28 +0100 Subject: [PATCH 124/228] Make sure we fallthrough for the NES cases --- pkg/maths/bearing.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/maths/bearing.go b/pkg/maths/bearing.go index de4014d..e72148b 100644 --- a/pkg/maths/bearing.go +++ b/pkg/maths/bearing.go @@ -85,8 +85,11 @@ func (d Bearing) Vector() Vector { func (d Bearing) IsCardinal() bool { switch d { case North: + fallthrough case East: + fallthrough case South: + fallthrough case West: return true } From a0b811a659c81dca13b11ce5cc6122da52b9491c Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 11:46:37 +0100 Subject: [PATCH 125/228] Move glyph definitions into a central type --- pkg/atlas/atlas.go | 8 ++++---- pkg/atlas/glyph.go | 27 +++++++++++++++++++++++++++ pkg/atlas/objects.go | 6 +++--- 3 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 pkg/atlas/glyph.go diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index 1a2f3fb..73ea341 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -9,16 +9,16 @@ type Tile byte const ( // TileNone is a keyword for nothing - TileNone = Tile(0) + TileNone = Tile(GlyphNone) // TileRock is solid rock ground - TileRock = Tile('-') + TileRock = Tile(GlyphRock) // TileGravel is loose rocks - TileGravel = Tile(':') + TileGravel = Tile(GlyphGravel) // TileSand is sand - TileSand = Tile('~') + TileSand = Tile(GlyphSand) ) // Atlas represents a 2D world atlas of tiles and objects diff --git a/pkg/atlas/glyph.go b/pkg/atlas/glyph.go new file mode 100644 index 0000000..c39f1be --- /dev/null +++ b/pkg/atlas/glyph.go @@ -0,0 +1,27 @@ +package atlas + +// Glyph represents the text representation of something in the game +type Glyph byte + +const ( + // GlyphNone is a keyword for nothing + GlyphNone = Glyph(0) + + // GlyphRock is solid rock ground + GlyphRock = Glyph('-') + + // GlyphGravel is loose rocks + GlyphGravel = Glyph(':') + + // GlyphSand is sand + GlyphSand = Glyph('~') + + // GlyphRover represents a live rover + GlyphRover = Glyph('R') + + // GlyphSmallRock is a small stashable rock + GlyphSmallRock = Glyph('o') + + // GlyphLargeRock is a large blocking rock + GlyphLargeRock = Glyph('O') +) diff --git a/pkg/atlas/objects.go b/pkg/atlas/objects.go index 68b4ef8..c397ec1 100644 --- a/pkg/atlas/objects.go +++ b/pkg/atlas/objects.go @@ -6,13 +6,13 @@ type Type byte // Types of objects const ( // ObjectNone represents no object at all - ObjectNone = Type(0) + ObjectNone = Type(GlyphNone) // ObjectRover represents a live rover - ObjectRover = Type('R') + ObjectRover = Type(GlyphRover) // ObjectSmallRock is a small stashable rock - ObjectSmallRock = Type('o') + ObjectSmallRock = Type(GlyphSmallRock) // ObjectLargeRock is a large blocking rock ObjectLargeRock = Type('O') From 53d6ad08d965ca434de5f67b79e961942354de8f Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 11:47:19 +0100 Subject: [PATCH 126/228] Rename Type to ObjectType --- pkg/atlas/objects.go | 19 ++++++++++--------- pkg/rove/world.go | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pkg/atlas/objects.go b/pkg/atlas/objects.go index c397ec1..cb71229 100644 --- a/pkg/atlas/objects.go +++ b/pkg/atlas/objects.go @@ -1,31 +1,32 @@ package atlas -// Type represents an object type -type Type byte +// ObjectType represents an object type +type ObjectType byte // Types of objects const ( // ObjectNone represents no object at all - ObjectNone = Type(GlyphNone) + ObjectNone = ObjectType(GlyphNone) // ObjectRover represents a live rover - ObjectRover = Type(GlyphRover) + ObjectRover = ObjectType(GlyphRover) // ObjectSmallRock is a small stashable rock - ObjectSmallRock = Type(GlyphSmallRock) + ObjectSmallRock = ObjectType(GlyphSmallRock) // ObjectLargeRock is a large blocking rock - ObjectLargeRock = Type('O') + ObjectLargeRock = ObjectType(GlyphLargeRock) ) // Object represents an object in the world type Object struct { - Type Type `json:"type"` + // The type of the object + Type ObjectType `json:"type"` } // IsBlocking checks if an object is a blocking object func (o *Object) IsBlocking() bool { - var blocking = [...]Type{ + var blocking = [...]ObjectType{ ObjectRover, ObjectLargeRock, } @@ -40,7 +41,7 @@ func (o *Object) IsBlocking() bool { // IsStashable checks if an object is stashable func (o *Object) IsStashable() bool { - var stashable = [...]Type{ + var stashable = [...]ObjectType{ ObjectSmallRock, } diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 04cad81..177dbba 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -318,7 +318,7 @@ func (w *World) MoveRover(rover string, b maths.Bearing) (maths.Vector, error) { } // RoverStash will stash an item at the current rovers position -func (w *World) RoverStash(rover string) (atlas.Type, error) { +func (w *World) RoverStash(rover string) (atlas.ObjectType, error) { w.worldMutex.Lock() defer w.worldMutex.Unlock() From acdd01909315c4a6f6dbae7064540f3a21b36008 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 11:50:19 +0100 Subject: [PATCH 127/228] Add Glyph methods to convert to a glyph --- pkg/atlas/atlas.go | 19 +++++++++++++++++++ pkg/atlas/objects.go | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index 73ea341..aaa7fd8 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -1,6 +1,8 @@ package atlas import ( + "log" + "github.com/mdiluz/rove/pkg/maths" ) @@ -21,6 +23,23 @@ const ( TileSand = Tile(GlyphSand) ) +// Glyph returns the glyph for this tile type +func (t Tile) Glyph() Glyph { + switch t { + case TileNone: + return GlyphNone + case TileRock: + return GlyphRock + case TileGravel: + return GlyphGravel + case TileSand: + return GlyphSand + } + + log.Fatalf("Unknown tile type: %c", t) + return GlyphNone +} + // Atlas represents a 2D world atlas of tiles and objects type Atlas interface { // SetTile sets a location on the Atlas to a type of tile diff --git a/pkg/atlas/objects.go b/pkg/atlas/objects.go index cb71229..1b9eb87 100644 --- a/pkg/atlas/objects.go +++ b/pkg/atlas/objects.go @@ -1,5 +1,7 @@ package atlas +import "log" + // ObjectType represents an object type type ObjectType byte @@ -18,6 +20,23 @@ const ( ObjectLargeRock = ObjectType(GlyphLargeRock) ) +// Glyph returns the glyph for this object type +func (o ObjectType) Glyph() Glyph { + switch o { + case ObjectNone: + return GlyphNone + case ObjectRover: + return GlyphRover + case ObjectSmallRock: + return GlyphSmallRock + case ObjectLargeRock: + return GlyphLargeRock + } + + log.Fatalf("Unknown object type: %c", o) + return GlyphNone +} + // Object represents an object in the world type Object struct { // The type of the object From f6654360077cf4926a00915af7c3b59ae65a0e6f Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 11:54:11 +0100 Subject: [PATCH 128/228] Convert objects and tiles to base ints --- pkg/atlas/atlas.go | 8 ++++---- pkg/atlas/chunkAtlas.go | 2 +- pkg/atlas/objects.go | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index aaa7fd8..e681ff2 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -11,16 +11,16 @@ type Tile byte const ( // TileNone is a keyword for nothing - TileNone = Tile(GlyphNone) + TileNone = iota // TileRock is solid rock ground - TileRock = Tile(GlyphRock) + TileRock // TileGravel is loose rocks - TileGravel = Tile(GlyphGravel) + TileGravel // TileSand is sand - TileSand = Tile(GlyphSand) + TileSand ) // Glyph returns the glyph for this tile type diff --git a/pkg/atlas/chunkAtlas.go b/pkg/atlas/chunkAtlas.go index daee6e6..1d21741 100644 --- a/pkg/atlas/chunkAtlas.go +++ b/pkg/atlas/chunkAtlas.go @@ -128,7 +128,7 @@ func (a *chunkBasedAtlas) populate(chunk int) { obj = ObjectSmallRock } if obj != ObjectNone { - c.Objects[j*a.ChunkSize+i] = Object{Type: obj} + c.Objects[j*a.ChunkSize+i] = Object{Type: ObjectType(obj)} } } } diff --git a/pkg/atlas/objects.go b/pkg/atlas/objects.go index 1b9eb87..ac847fe 100644 --- a/pkg/atlas/objects.go +++ b/pkg/atlas/objects.go @@ -8,16 +8,16 @@ type ObjectType byte // Types of objects const ( // ObjectNone represents no object at all - ObjectNone = ObjectType(GlyphNone) + ObjectNone = iota // ObjectRover represents a live rover - ObjectRover = ObjectType(GlyphRover) + ObjectRover // ObjectSmallRock is a small stashable rock - ObjectSmallRock = ObjectType(GlyphSmallRock) + ObjectSmallRock // ObjectLargeRock is a large blocking rock - ObjectLargeRock = ObjectType(GlyphLargeRock) + ObjectLargeRock ) // Glyph returns the glyph for this object type From 7e41ac00286e5acafa2da750f05681d863fb3273 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 11:56:05 +0100 Subject: [PATCH 129/228] Rename the glyphs --- pkg/atlas/atlas.go | 6 +++--- pkg/atlas/atlas_test.go | 12 ++++++------ pkg/atlas/chunkAtlas.go | 8 ++++---- pkg/atlas/glyph.go | 24 ++++++++++++------------ pkg/atlas/objects.go | 24 ++++++++++++------------ pkg/rove/world.go | 2 +- pkg/rove/world_test.go | 28 ++++++++++++++-------------- 7 files changed, 52 insertions(+), 52 deletions(-) diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index e681ff2..305c355 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -29,11 +29,11 @@ func (t Tile) Glyph() Glyph { case TileNone: return GlyphNone case TileRock: - return GlyphRock + return GlyphGroundRock case TileGravel: - return GlyphGravel + return GlyphGroundGravel case TileSand: - return GlyphSand + return GlyphGroundSand } log.Fatalf("Unknown tile type: %c", t) diff --git a/pkg/atlas/atlas_test.go b/pkg/atlas/atlas_test.go index 9305b07..5141371 100644 --- a/pkg/atlas/atlas_test.go +++ b/pkg/atlas/atlas_test.go @@ -185,14 +185,14 @@ func TestAtlas_GetSetObject(t *testing.T) { assert.NotNil(t, a) // Set the origin tile to 1 and test it - a.SetObject(maths.Vector{X: 0, Y: 0}, Object{Type: ObjectLargeRock}) + a.SetObject(maths.Vector{X: 0, Y: 0}, Object{Type: ObjectRockLarge}) _, obj := a.QueryPosition(maths.Vector{X: 0, Y: 0}) - assert.Equal(t, Object{Type: ObjectLargeRock}, obj) + assert.Equal(t, Object{Type: ObjectRockLarge}, obj) // Set another tile to 1 and test it - a.SetObject(maths.Vector{X: 5, Y: -2}, Object{Type: ObjectSmallRock}) + a.SetObject(maths.Vector{X: 5, Y: -2}, Object{Type: ObjectRockSmall}) _, obj = a.QueryPosition(maths.Vector{X: 5, Y: -2}) - assert.Equal(t, Object{Type: ObjectSmallRock}, obj) + assert.Equal(t, Object{Type: ObjectRockSmall}, obj) } func TestAtlas_Grown(t *testing.T) { @@ -238,11 +238,11 @@ func TestAtlas_GetSetCorrect(t *testing.T) { pos := maths.Vector{X: x, Y: y} a.SetTile(pos, TileRock) - a.SetObject(pos, Object{Type: ObjectLargeRock}) + a.SetObject(pos, Object{Type: ObjectRockLarge}) tile, obj := a.QueryPosition(pos) assert.Equal(t, TileRock, Tile(tile)) - assert.Equal(t, Object{Type: ObjectLargeRock}, obj) + assert.Equal(t, Object{Type: ObjectRockLarge}, obj) } } diff --git a/pkg/atlas/chunkAtlas.go b/pkg/atlas/chunkAtlas.go index 1d21741..99d4668 100644 --- a/pkg/atlas/chunkAtlas.go +++ b/pkg/atlas/chunkAtlas.go @@ -123,9 +123,9 @@ func (a *chunkBasedAtlas) populate(chunk int) { var obj = ObjectNone switch { case o > 0.6: - obj = ObjectLargeRock + obj = ObjectRockLarge case o > 0.5: - obj = ObjectSmallRock + obj = ObjectRockSmall } if obj != ObjectNone { c.Objects[j*a.ChunkSize+i] = Object{Type: ObjectType(obj)} @@ -136,9 +136,9 @@ func (a *chunkBasedAtlas) populate(chunk int) { // Set up any objects for i := 0; i < len(c.Tiles); i++ { if rand.Intn(16) == 0 { - c.Objects[i] = Object{Type: ObjectLargeRock} + c.Objects[i] = Object{Type: ObjectRockLarge} } else if rand.Intn(32) == 0 { - c.Objects[i] = Object{Type: ObjectSmallRock} + c.Objects[i] = Object{Type: ObjectRockSmall} } } diff --git a/pkg/atlas/glyph.go b/pkg/atlas/glyph.go index c39f1be..c5c0ad7 100644 --- a/pkg/atlas/glyph.go +++ b/pkg/atlas/glyph.go @@ -7,21 +7,21 @@ const ( // GlyphNone is a keyword for nothing GlyphNone = Glyph(0) - // GlyphRock is solid rock ground - GlyphRock = Glyph('-') + // GlyphGroundRock is solid rock ground + GlyphGroundRock = Glyph('-') - // GlyphGravel is loose rocks - GlyphGravel = Glyph(':') + // GlyphGroundGravel is loose rocks + GlyphGroundGravel = Glyph(':') - // GlyphSand is sand - GlyphSand = Glyph('~') + // GlyphGroundSand is sand + GlyphGroundSand = Glyph('~') - // GlyphRover represents a live rover - GlyphRover = Glyph('R') + // GlyphRoverLive represents a live rover + GlyphRoverLive = Glyph('R') - // GlyphSmallRock is a small stashable rock - GlyphSmallRock = Glyph('o') + // GlyphRockSmall is a small stashable rock + GlyphRockSmall = Glyph('o') - // GlyphLargeRock is a large blocking rock - GlyphLargeRock = Glyph('O') + // GlyphRockLarge is a large blocking rock + GlyphRockLarge = Glyph('O') ) diff --git a/pkg/atlas/objects.go b/pkg/atlas/objects.go index ac847fe..032ca10 100644 --- a/pkg/atlas/objects.go +++ b/pkg/atlas/objects.go @@ -11,13 +11,13 @@ const ( ObjectNone = iota // ObjectRover represents a live rover - ObjectRover + ObjectRoverLive // ObjectSmallRock is a small stashable rock - ObjectSmallRock + ObjectRockSmall // ObjectLargeRock is a large blocking rock - ObjectLargeRock + ObjectRockLarge ) // Glyph returns the glyph for this object type @@ -25,12 +25,12 @@ func (o ObjectType) Glyph() Glyph { switch o { case ObjectNone: return GlyphNone - case ObjectRover: - return GlyphRover - case ObjectSmallRock: - return GlyphSmallRock - case ObjectLargeRock: - return GlyphLargeRock + case ObjectRoverLive: + return GlyphRoverLive + case ObjectRockSmall: + return GlyphRockSmall + case ObjectRockLarge: + return GlyphRockLarge } log.Fatalf("Unknown object type: %c", o) @@ -46,8 +46,8 @@ type Object struct { // IsBlocking checks if an object is a blocking object func (o *Object) IsBlocking() bool { var blocking = [...]ObjectType{ - ObjectRover, - ObjectLargeRock, + ObjectRoverLive, + ObjectRockLarge, } for _, t := range blocking { @@ -61,7 +61,7 @@ func (o *Object) IsBlocking() bool { // IsStashable checks if an object is stashable func (o *Object) IsStashable() bool { var stashable = [...]ObjectType{ - ObjectSmallRock, + ObjectRockSmall, } for _, t := range stashable { diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 177dbba..7375df1 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -401,7 +401,7 @@ func (w *World) RadarFromRover(rover string) (radar []byte, objs []byte, err err if dist.X <= r.Range && dist.Y <= r.Range { relative := r.Pos.Added(radarMin.Negated()) index := relative.X + relative.Y*radarSpan - objs[index] = byte(atlas.ObjectRover) + objs[index] = byte(atlas.ObjectRoverLive) } } diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index f3be5c0..5a3e34f 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -90,7 +90,7 @@ func TestWorld_GetSetMovePosition(t *testing.T) { assert.Contains(t, rover.Logs[len(rover.Logs)-1].Text, "moved", "Rover logs should contain the move") // Place a tile in front of the rover - world.Atlas.SetObject(maths.Vector{X: 0, Y: 2}, atlas.Object{Type: atlas.ObjectLargeRock}) + world.Atlas.SetObject(maths.Vector{X: 0, Y: 2}, atlas.Object{Type: atlas.ObjectRockLarge}) newPos, err = world.MoveRover(a, b) assert.NoError(t, err, "Failed to move rover") assert.Equal(t, pos, newPos, "Failed to correctly not move position for rover into wall") @@ -120,8 +120,8 @@ func TestWorld_RadarFromRover(t *testing.T) { assert.Equal(t, fullRange*fullRange, len(objs), "Radar returned wrong length") // Test the expected values - assert.Equal(t, byte(atlas.ObjectRover), objs[1+fullRange]) - assert.Equal(t, byte(atlas.ObjectRover), objs[4+4*fullRange]) + assert.Equal(t, byte(atlas.ObjectRoverLive), objs[1+fullRange]) + assert.Equal(t, byte(atlas.ObjectRoverLive), objs[4+4*fullRange]) // Check the radar results are stable radar1, objs1, err := world.RadarFromRover(a) @@ -154,12 +154,12 @@ func TestWorld_RoverStash(t *testing.T) { for i := 0; i < rover.Capacity; i++ { // Place an object - world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectSmallRock}) + world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectRockSmall}) // Pick it up o, err := world.RoverStash(a) assert.NoError(t, err, "Failed to stash") - assert.Equal(t, atlas.ObjectSmallRock, o, "Failed to get correct object") + assert.Equal(t, atlas.ObjectRockSmall, o, "Failed to get correct object") // Check it's gone _, obj := world.Atlas.QueryPosition(pos) @@ -169,7 +169,7 @@ func TestWorld_RoverStash(t *testing.T) { inv, err := world.RoverInventory(a) assert.NoError(t, err, "Failed to get inventory") assert.Equal(t, i+1, len(inv)) - assert.Equal(t, atlas.Object{Type: atlas.ObjectSmallRock}, inv[i]) + assert.Equal(t, atlas.Object{Type: atlas.ObjectRockSmall}, inv[i]) // Check that this did reduce the charge info, err := world.GetRover(a) @@ -186,7 +186,7 @@ func TestWorld_RoverStash(t *testing.T) { } // Place an object - world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectSmallRock}) + world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectRockSmall}) // Try to pick it up o, err := world.RoverStash(a) @@ -195,7 +195,7 @@ func TestWorld_RoverStash(t *testing.T) { // Check it's still there _, obj := world.Atlas.QueryPosition(pos) - assert.Equal(t, atlas.ObjectSmallRock, obj.Type, "Stash failed to remove object from atlas") + assert.Equal(t, atlas.ObjectRockSmall, obj.Type, "Stash failed to remove object from atlas") // Check we don't have it inv, err := world.RoverInventory(a) @@ -224,7 +224,7 @@ func TestWorld_RoverDamage(t *testing.T) { info, err := world.GetRover(a) assert.NoError(t, err, "couldn't get rover info") - world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, atlas.Object{Type: atlas.ObjectLargeRock}) + world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, atlas.Object{Type: atlas.ObjectRockLarge}) vec, err := world.MoveRover(a, maths.North) assert.NoError(t, err, "Failed to move rover") @@ -256,12 +256,12 @@ func TestWorld_RoverRepair(t *testing.T) { assert.NoError(t, err, "couldn't get rover info") // Pick up something to repair with - world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectSmallRock}) + world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectRockSmall}) o, err := world.RoverStash(a) assert.NoError(t, err, "Failed to stash") - assert.Equal(t, atlas.ObjectSmallRock, o, "Failed to get correct object") + assert.Equal(t, atlas.ObjectRockSmall, o, "Failed to get correct object") - world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, atlas.Object{Type: atlas.ObjectLargeRock}) + world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, atlas.Object{Type: atlas.ObjectRockLarge}) // Try and bump into the rock vec, err := world.MoveRover(a, maths.North) @@ -281,10 +281,10 @@ func TestWorld_RoverRepair(t *testing.T) { assert.Contains(t, newinfo.Logs[len(newinfo.Logs)-1].Text, "repair", "Rover logs should contain the repair") // Check again that it can't repair past the max - world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectSmallRock}) + world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectRockSmall}) o, err = world.RoverStash(a) assert.NoError(t, err, "Failed to stash") - assert.Equal(t, atlas.ObjectSmallRock, o, "Failed to get correct object") + assert.Equal(t, atlas.ObjectRockSmall, o, "Failed to get correct object") err = world.ExecuteCommand(&Command{Command: roveapi.CommandType_repair}, a) assert.NoError(t, err, "Failed to repair rover") From 24d4fe92734992b906aa5b19bb0a075ed06dd83b Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 11:59:14 +0100 Subject: [PATCH 130/228] Convert tiles and object types to typed consts --- pkg/atlas/atlas.go | 8 ++++---- pkg/atlas/objects.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index 305c355..700be09 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -11,16 +11,16 @@ type Tile byte const ( // TileNone is a keyword for nothing - TileNone = iota + TileNone = Tile(0) // TileRock is solid rock ground - TileRock + TileRock = Tile(1) // TileGravel is loose rocks - TileGravel + TileGravel = Tile(2) // TileSand is sand - TileSand + TileSand = Tile(3) ) // Glyph returns the glyph for this tile type diff --git a/pkg/atlas/objects.go b/pkg/atlas/objects.go index 032ca10..52d88df 100644 --- a/pkg/atlas/objects.go +++ b/pkg/atlas/objects.go @@ -8,16 +8,16 @@ type ObjectType byte // Types of objects const ( // ObjectNone represents no object at all - ObjectNone = iota + ObjectNone = ObjectType(0) // ObjectRover represents a live rover - ObjectRoverLive + ObjectRoverLive = ObjectType(1) // ObjectSmallRock is a small stashable rock - ObjectRockSmall + ObjectRockSmall = ObjectType(2) // ObjectLargeRock is a large blocking rock - ObjectRockLarge + ObjectRockLarge = ObjectType(3) ) // Glyph returns the glyph for this object type From 305f64ec38ecaa06c121f0fa33a3e43f890f8bdb Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 12:26:57 +0100 Subject: [PATCH 131/228] Large refactor, move object and tile types out into the proto --- cmd/rove/main.go | 8 +- pkg/atlas/atlas.go | 34 ++--- pkg/atlas/atlas_test.go | 55 ++++---- pkg/atlas/chunkAtlas.go | 31 ++-- pkg/atlas/objects.go | 44 ++---- pkg/rove/world.go | 22 +-- pkg/rove/world_test.go | 48 +++---- proto/roveapi/roveapi.pb.go | 273 ++++++++++++++++++++++++++---------- proto/roveapi/roveapi.proto | 33 ++++- 9 files changed, 338 insertions(+), 210 deletions(-) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 8a19e68..8e4f740 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -287,10 +287,10 @@ func InnerMain(command string, args ...string) error { for i := 0; i < num; i++ { t := response.Tiles[i+num*j] o := response.Objects[i+num*j] - if o != byte(atlas.ObjectNone) { - fmt.Printf("%c", o) - } else if t != byte(atlas.TileNone) { - fmt.Printf("%c", t) + if o != roveapi.Object_ObjectNone { + fmt.Printf("%c", atlas.ObjectGlyph(o)) + } else if t != roveapi.Tile_TileNone { + fmt.Printf("%c", atlas.TileGlyph(t)) } else { fmt.Printf(" ") } diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index 700be09..de83642 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -4,35 +4,19 @@ import ( "log" "github.com/mdiluz/rove/pkg/maths" + "github.com/mdiluz/rove/proto/roveapi" ) -// Tile describes the type of terrain -type Tile byte - -const ( - // TileNone is a keyword for nothing - TileNone = Tile(0) - - // TileRock is solid rock ground - TileRock = Tile(1) - - // TileGravel is loose rocks - TileGravel = Tile(2) - - // TileSand is sand - TileSand = Tile(3) -) - -// Glyph returns the glyph for this tile type -func (t Tile) Glyph() Glyph { +// TileGlyph returns the glyph for this tile type +func TileGlyph(t roveapi.Tile) Glyph { switch t { - case TileNone: + case roveapi.Tile_TileNone: return GlyphNone - case TileRock: + case roveapi.Tile_Rock: return GlyphGroundRock - case TileGravel: + case roveapi.Tile_Gravel: return GlyphGroundGravel - case TileSand: + case roveapi.Tile_Sand: return GlyphGroundSand } @@ -43,11 +27,11 @@ func (t Tile) Glyph() Glyph { // Atlas represents a 2D world atlas of tiles and objects type Atlas interface { // SetTile sets a location on the Atlas to a type of tile - SetTile(v maths.Vector, tile Tile) + SetTile(v maths.Vector, tile roveapi.Tile) // SetObject will set a location on the Atlas to contain an object SetObject(v maths.Vector, obj Object) // QueryPosition queries a position on the atlas - QueryPosition(v maths.Vector) (byte, Object) + QueryPosition(v maths.Vector) (roveapi.Tile, Object) } diff --git a/pkg/atlas/atlas_test.go b/pkg/atlas/atlas_test.go index 5141371..de8b7b9 100644 --- a/pkg/atlas/atlas_test.go +++ b/pkg/atlas/atlas_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/mdiluz/rove/pkg/maths" + "github.com/mdiluz/rove/proto/roveapi" "github.com/stretchr/testify/assert" ) @@ -169,15 +170,15 @@ func TestAtlas_GetSetTile(t *testing.T) { a := NewChunkAtlas(10) assert.NotNil(t, a) - // Set the origin tile to 1 and test it - a.SetTile(maths.Vector{X: 0, Y: 0}, 1) + // Set the origin tile and test it + a.SetTile(maths.Vector{X: 0, Y: 0}, roveapi.Tile_Gravel) tile, _ := a.QueryPosition(maths.Vector{X: 0, Y: 0}) - assert.Equal(t, byte(1), tile) + assert.Equal(t, roveapi.Tile_Gravel, tile) - // Set another tile to 1 and test it - a.SetTile(maths.Vector{X: 5, Y: -2}, 2) + // Set another tile and test it + a.SetTile(maths.Vector{X: 5, Y: -2}, roveapi.Tile_Rock) tile, _ = a.QueryPosition(maths.Vector{X: 5, Y: -2}) - assert.Equal(t, byte(2), tile) + assert.Equal(t, roveapi.Tile_Rock, tile) } func TestAtlas_GetSetObject(t *testing.T) { @@ -185,14 +186,14 @@ func TestAtlas_GetSetObject(t *testing.T) { assert.NotNil(t, a) // Set the origin tile to 1 and test it - a.SetObject(maths.Vector{X: 0, Y: 0}, Object{Type: ObjectRockLarge}) + a.SetObject(maths.Vector{X: 0, Y: 0}, Object{Type: roveapi.Object_RockLarge}) _, obj := a.QueryPosition(maths.Vector{X: 0, Y: 0}) - assert.Equal(t, Object{Type: ObjectRockLarge}, obj) + assert.Equal(t, Object{Type: roveapi.Object_RockLarge}, obj) // Set another tile to 1 and test it - a.SetObject(maths.Vector{X: 5, Y: -2}, Object{Type: ObjectRockSmall}) + a.SetObject(maths.Vector{X: 5, Y: -2}, Object{Type: roveapi.Object_RockSmall}) _, obj = a.QueryPosition(maths.Vector{X: 5, Y: -2}) - assert.Equal(t, Object{Type: ObjectRockSmall}, obj) + assert.Equal(t, Object{Type: roveapi.Object_RockSmall}, obj) } func TestAtlas_Grown(t *testing.T) { @@ -202,28 +203,28 @@ func TestAtlas_Grown(t *testing.T) { assert.Equal(t, 1, len(a.Chunks)) // Set a few tiles to values - a.SetTile(maths.Vector{X: 0, Y: 0}, 1) - a.SetTile(maths.Vector{X: -1, Y: -1}, 2) - a.SetTile(maths.Vector{X: 1, Y: -2}, 3) + a.SetTile(maths.Vector{X: 0, Y: 0}, roveapi.Tile_Gravel) + a.SetTile(maths.Vector{X: -1, Y: -1}, roveapi.Tile_Rock) + a.SetTile(maths.Vector{X: 1, Y: -2}, roveapi.Tile_Sand) // Check tile values tile, _ := a.QueryPosition(maths.Vector{X: 0, Y: 0}) - assert.Equal(t, byte(1), tile) + assert.Equal(t, roveapi.Tile_Gravel, tile) tile, _ = a.QueryPosition(maths.Vector{X: -1, Y: -1}) - assert.Equal(t, byte(2), tile) + assert.Equal(t, roveapi.Tile_Rock, tile) tile, _ = a.QueryPosition(maths.Vector{X: 1, Y: -2}) - assert.Equal(t, byte(3), tile) + assert.Equal(t, roveapi.Tile_Sand, tile) tile, _ = a.QueryPosition(maths.Vector{X: 0, Y: 0}) - assert.Equal(t, byte(1), tile) + assert.Equal(t, roveapi.Tile_Gravel, tile) tile, _ = a.QueryPosition(maths.Vector{X: -1, Y: -1}) - assert.Equal(t, byte(2), tile) + assert.Equal(t, roveapi.Tile_Rock, tile) tile, _ = a.QueryPosition(maths.Vector{X: 1, Y: -2}) - assert.Equal(t, byte(3), tile) + assert.Equal(t, roveapi.Tile_Sand, tile) } func TestAtlas_GetSetCorrect(t *testing.T) { @@ -237,12 +238,12 @@ func TestAtlas_GetSetCorrect(t *testing.T) { assert.Equal(t, 1, len(a.Chunks)) pos := maths.Vector{X: x, Y: y} - a.SetTile(pos, TileRock) - a.SetObject(pos, Object{Type: ObjectRockLarge}) + a.SetTile(pos, roveapi.Tile_Rock) + a.SetObject(pos, Object{Type: roveapi.Object_RockLarge}) tile, obj := a.QueryPosition(pos) - assert.Equal(t, TileRock, Tile(tile)) - assert.Equal(t, Object{Type: ObjectRockLarge}, obj) + assert.Equal(t, roveapi.Tile_Rock, roveapi.Tile(tile)) + assert.Equal(t, Object{Type: roveapi.Object_RockLarge}, obj) } } @@ -259,10 +260,10 @@ func TestAtlas_WorldGen(t *testing.T) { for j := num - 1; j >= 0; j-- { for i := 0; i < num; i++ { t, o := a.QueryPosition(maths.Vector{X: i, Y: j}) - if o.Type != ObjectNone { - fmt.Printf("%c", o.Type) - } else if t != byte(TileNone) { - fmt.Printf("%c", t) + if o.Type != roveapi.Object_ObjectNone { + fmt.Printf("%c", ObjectGlyph(o.Type)) + } else if t != roveapi.Tile_TileNone { + fmt.Printf("%c", TileGlyph(t)) } else { fmt.Printf(" ") } diff --git a/pkg/atlas/chunkAtlas.go b/pkg/atlas/chunkAtlas.go index 99d4668..43ca3af 100644 --- a/pkg/atlas/chunkAtlas.go +++ b/pkg/atlas/chunkAtlas.go @@ -5,6 +5,7 @@ import ( "math/rand" "github.com/mdiluz/rove/pkg/maths" + "github.com/mdiluz/rove/proto/roveapi" "github.com/ojrac/opensimplex-go" ) @@ -63,7 +64,7 @@ func NewChunkAtlas(chunkSize int) Atlas { } // SetTile sets an individual tile's kind -func (a *chunkBasedAtlas) SetTile(v maths.Vector, tile Tile) { +func (a *chunkBasedAtlas) SetTile(v maths.Vector, tile roveapi.Tile) { c := a.worldSpaceToChunkWithGrow(v) local := a.worldSpaceToChunkLocal(v) a.setTile(c, local, byte(tile)) @@ -77,13 +78,13 @@ func (a *chunkBasedAtlas) SetObject(v maths.Vector, obj Object) { } // QueryPosition will return information for a specific position -func (a *chunkBasedAtlas) QueryPosition(v maths.Vector) (byte, Object) { +func (a *chunkBasedAtlas) QueryPosition(v maths.Vector) (roveapi.Tile, Object) { c := a.worldSpaceToChunkWithGrow(v) local := a.worldSpaceToChunkLocal(v) a.populate(c) chunk := a.Chunks[c] i := a.chunkTileIndex(local) - return chunk.Tiles[i], chunk.Objects[i] + return roveapi.Tile(chunk.Tiles[i]), chunk.Objects[i] } // chunkTileID returns the tile index within a chunk @@ -107,28 +108,28 @@ func (a *chunkBasedAtlas) populate(chunk int) { // Get the terrain noise value for this location t := a.terrainNoise.Eval2(float64(origin.X+i)/terrainNoiseScale, float64(origin.Y+j)/terrainNoiseScale) - var tile Tile + var tile roveapi.Tile switch { case t > 0.5: - tile = TileGravel + tile = roveapi.Tile_Gravel case t > 0.05: - tile = TileSand + tile = roveapi.Tile_Sand default: - tile = TileRock + tile = roveapi.Tile_Rock } c.Tiles[j*a.ChunkSize+i] = byte(tile) // Get the object noise value for this location o := a.objectNoise.Eval2(float64(origin.X+i)/objectNoiseScale, float64(origin.Y+j)/objectNoiseScale) - var obj = ObjectNone + var obj = roveapi.Object_ObjectNone switch { case o > 0.6: - obj = ObjectRockLarge + obj = roveapi.Object_RockLarge case o > 0.5: - obj = ObjectRockSmall + obj = roveapi.Object_RockSmall } - if obj != ObjectNone { - c.Objects[j*a.ChunkSize+i] = Object{Type: ObjectType(obj)} + if obj != roveapi.Object_ObjectNone { + c.Objects[j*a.ChunkSize+i] = Object{Type: roveapi.Object(obj)} } } } @@ -136,9 +137,9 @@ func (a *chunkBasedAtlas) populate(chunk int) { // Set up any objects for i := 0; i < len(c.Tiles); i++ { if rand.Intn(16) == 0 { - c.Objects[i] = Object{Type: ObjectRockLarge} + c.Objects[i] = Object{Type: roveapi.Object_RockLarge} } else if rand.Intn(32) == 0 { - c.Objects[i] = Object{Type: ObjectRockSmall} + c.Objects[i] = Object{Type: roveapi.Object_RockSmall} } } @@ -159,7 +160,7 @@ func (a *chunkBasedAtlas) setObject(chunk int, local maths.Vector, object Object c := a.Chunks[chunk] i := a.chunkTileIndex(local) - if object.Type != ObjectNone { + if object.Type != roveapi.Object_ObjectNone { c.Objects[i] = object } else { delete(c.Objects, i) diff --git a/pkg/atlas/objects.go b/pkg/atlas/objects.go index 52d88df..ccbb69b 100644 --- a/pkg/atlas/objects.go +++ b/pkg/atlas/objects.go @@ -1,35 +1,21 @@ package atlas -import "log" +import ( + "log" -// ObjectType represents an object type -type ObjectType byte - -// Types of objects -const ( - // ObjectNone represents no object at all - ObjectNone = ObjectType(0) - - // ObjectRover represents a live rover - ObjectRoverLive = ObjectType(1) - - // ObjectSmallRock is a small stashable rock - ObjectRockSmall = ObjectType(2) - - // ObjectLargeRock is a large blocking rock - ObjectRockLarge = ObjectType(3) + "github.com/mdiluz/rove/proto/roveapi" ) -// Glyph returns the glyph for this object type -func (o ObjectType) Glyph() Glyph { +// ObjectGlyph returns the glyph for this object type +func ObjectGlyph(o roveapi.Object) Glyph { switch o { - case ObjectNone: + case roveapi.Object_ObjectNone: return GlyphNone - case ObjectRoverLive: + case roveapi.Object_RoverLive: return GlyphRoverLive - case ObjectRockSmall: + case roveapi.Object_RockSmall: return GlyphRockSmall - case ObjectRockLarge: + case roveapi.Object_RockLarge: return GlyphRockLarge } @@ -40,14 +26,14 @@ func (o ObjectType) Glyph() Glyph { // Object represents an object in the world type Object struct { // The type of the object - Type ObjectType `json:"type"` + Type roveapi.Object `json:"type"` } // IsBlocking checks if an object is a blocking object func (o *Object) IsBlocking() bool { - var blocking = [...]ObjectType{ - ObjectRoverLive, - ObjectRockLarge, + var blocking = [...]roveapi.Object{ + roveapi.Object_RoverLive, + roveapi.Object_RockLarge, } for _, t := range blocking { @@ -60,8 +46,8 @@ func (o *Object) IsBlocking() bool { // IsStashable checks if an object is stashable func (o *Object) IsStashable() bool { - var stashable = [...]ObjectType{ - ObjectRockSmall, + var stashable = [...]roveapi.Object{ + roveapi.Object_RockSmall, } for _, t := range stashable { diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 7375df1..51b81ef 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -318,40 +318,40 @@ func (w *World) MoveRover(rover string, b maths.Bearing) (maths.Vector, error) { } // RoverStash will stash an item at the current rovers position -func (w *World) RoverStash(rover string) (atlas.ObjectType, error) { +func (w *World) RoverStash(rover string) (roveapi.Object, error) { w.worldMutex.Lock() defer w.worldMutex.Unlock() r, ok := w.Rovers[rover] if !ok { - return atlas.ObjectNone, fmt.Errorf("no rover matching id") + return roveapi.Object_ObjectNone, fmt.Errorf("no rover matching id") } // Can't pick up when full if len(r.Inventory) >= r.Capacity { - return atlas.ObjectNone, nil + return roveapi.Object_ObjectNone, nil } // Ensure the rover has energy if r.Charge <= 0 { - return atlas.ObjectNone, nil + return roveapi.Object_ObjectNone, nil } r.Charge-- _, obj := w.Atlas.QueryPosition(r.Pos) if !obj.IsStashable() { - return atlas.ObjectNone, nil + return roveapi.Object_ObjectNone, nil } r.AddLogEntryf("stashed %c", obj.Type) r.Inventory = append(r.Inventory, obj) w.Rovers[rover] = r - w.Atlas.SetObject(r.Pos, atlas.Object{Type: atlas.ObjectNone}) + w.Atlas.SetObject(r.Pos, atlas.Object{Type: roveapi.Object_ObjectNone}) return obj.Type, nil } // RadarFromRover can be used to query what a rover can currently see -func (w *World) RadarFromRover(rover string) (radar []byte, objs []byte, err error) { +func (w *World) RadarFromRover(rover string) (radar []roveapi.Tile, objs []roveapi.Object, err error) { w.worldMutex.RLock() defer w.worldMutex.RUnlock() @@ -376,8 +376,8 @@ func (w *World) RadarFromRover(rover string) (radar []byte, objs []byte, err err } // Gather up all tiles within the range - radar = make([]byte, radarSpan*radarSpan) - objs = make([]byte, radarSpan*radarSpan) + radar = make([]roveapi.Tile, radarSpan*radarSpan) + objs = make([]roveapi.Object, radarSpan*radarSpan) for j := radarMin.Y; j <= radarMax.Y; j++ { for i := radarMin.X; i <= radarMax.X; i++ { q := maths.Vector{X: i, Y: j} @@ -388,7 +388,7 @@ func (w *World) RadarFromRover(rover string) (radar []byte, objs []byte, err err relative := q.Added(radarMin.Negated()) index := relative.X + relative.Y*radarSpan radar[index] = tile - objs[index] = byte(obj.Type) + objs[index] = obj.Type } } @@ -401,7 +401,7 @@ func (w *World) RadarFromRover(rover string) (radar []byte, objs []byte, err err if dist.X <= r.Range && dist.Y <= r.Range { relative := r.Pos.Added(radarMin.Negated()) index := relative.X + relative.Y*radarSpan - objs[index] = byte(atlas.ObjectRoverLive) + objs[index] = roveapi.Object_RoverLive } } diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index 5a3e34f..8142858 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -90,7 +90,7 @@ func TestWorld_GetSetMovePosition(t *testing.T) { assert.Contains(t, rover.Logs[len(rover.Logs)-1].Text, "moved", "Rover logs should contain the move") // Place a tile in front of the rover - world.Atlas.SetObject(maths.Vector{X: 0, Y: 2}, atlas.Object{Type: atlas.ObjectRockLarge}) + world.Atlas.SetObject(maths.Vector{X: 0, Y: 2}, atlas.Object{Type: roveapi.Object_RockLarge}) newPos, err = world.MoveRover(a, b) assert.NoError(t, err, "Failed to move rover") assert.Equal(t, pos, newPos, "Failed to correctly not move position for rover into wall") @@ -120,8 +120,8 @@ func TestWorld_RadarFromRover(t *testing.T) { assert.Equal(t, fullRange*fullRange, len(objs), "Radar returned wrong length") // Test the expected values - assert.Equal(t, byte(atlas.ObjectRoverLive), objs[1+fullRange]) - assert.Equal(t, byte(atlas.ObjectRoverLive), objs[4+4*fullRange]) + assert.Equal(t, roveapi.Object_RoverLive, objs[1+fullRange]) + assert.Equal(t, roveapi.Object_RoverLive, objs[4+4*fullRange]) // Check the radar results are stable radar1, objs1, err := world.RadarFromRover(a) @@ -142,34 +142,34 @@ func TestWorld_RoverStash(t *testing.T) { Y: 0.0, } - world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectNone}) + world.Atlas.SetObject(pos, atlas.Object{Type: roveapi.Object_ObjectNone}) err = world.WarpRover(a, pos) assert.NoError(t, err, "Failed to set position for rover") // Set to a traversible tile - world.Atlas.SetTile(pos, atlas.TileRock) + world.Atlas.SetTile(pos, roveapi.Tile_TileNone) rover, err := world.GetRover(a) assert.NoError(t, err, "Failed to get rover") for i := 0; i < rover.Capacity; i++ { // Place an object - world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectRockSmall}) + world.Atlas.SetObject(pos, atlas.Object{Type: roveapi.Object_RockSmall}) // Pick it up o, err := world.RoverStash(a) assert.NoError(t, err, "Failed to stash") - assert.Equal(t, atlas.ObjectRockSmall, o, "Failed to get correct object") + assert.Equal(t, roveapi.Object_RockSmall, o, "Failed to get correct object") // Check it's gone _, obj := world.Atlas.QueryPosition(pos) - assert.Equal(t, atlas.ObjectNone, obj.Type, "Stash failed to remove object from atlas") + assert.Equal(t, roveapi.Object_ObjectNone, obj.Type, "Stash failed to remove object from atlas") // Check we have it inv, err := world.RoverInventory(a) assert.NoError(t, err, "Failed to get inventory") assert.Equal(t, i+1, len(inv)) - assert.Equal(t, atlas.Object{Type: atlas.ObjectRockSmall}, inv[i]) + assert.Equal(t, atlas.Object{Type: roveapi.Object_RockSmall}, inv[i]) // Check that this did reduce the charge info, err := world.GetRover(a) @@ -186,16 +186,16 @@ func TestWorld_RoverStash(t *testing.T) { } // Place an object - world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectRockSmall}) + world.Atlas.SetObject(pos, atlas.Object{Type: roveapi.Object_RockSmall}) // Try to pick it up o, err := world.RoverStash(a) assert.NoError(t, err, "Failed to stash") - assert.Equal(t, atlas.ObjectNone, o, "Failed to get correct object") + assert.Equal(t, roveapi.Object_ObjectNone, o, "Failed to get correct object") // Check it's still there _, obj := world.Atlas.QueryPosition(pos) - assert.Equal(t, atlas.ObjectRockSmall, obj.Type, "Stash failed to remove object from atlas") + assert.Equal(t, roveapi.Object_RockSmall, obj.Type, "Stash failed to remove object from atlas") // Check we don't have it inv, err := world.RoverInventory(a) @@ -224,7 +224,7 @@ func TestWorld_RoverDamage(t *testing.T) { info, err := world.GetRover(a) assert.NoError(t, err, "couldn't get rover info") - world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, atlas.Object{Type: atlas.ObjectRockLarge}) + world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, atlas.Object{Type: roveapi.Object_RockLarge}) vec, err := world.MoveRover(a, maths.North) assert.NoError(t, err, "Failed to move rover") @@ -246,8 +246,8 @@ func TestWorld_RoverRepair(t *testing.T) { Y: 0.0, } - world.Atlas.SetTile(pos, atlas.TileNone) - world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectNone}) + world.Atlas.SetTile(pos, roveapi.Tile_TileNone) + world.Atlas.SetObject(pos, atlas.Object{Type: roveapi.Object_ObjectNone}) err = world.WarpRover(a, pos) assert.NoError(t, err, "Failed to set position for rover") @@ -256,12 +256,12 @@ func TestWorld_RoverRepair(t *testing.T) { assert.NoError(t, err, "couldn't get rover info") // Pick up something to repair with - world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectRockSmall}) + world.Atlas.SetObject(pos, atlas.Object{Type: roveapi.Object_RockSmall}) o, err := world.RoverStash(a) assert.NoError(t, err, "Failed to stash") - assert.Equal(t, atlas.ObjectRockSmall, o, "Failed to get correct object") + assert.Equal(t, roveapi.Object_RockSmall, o, "Failed to get correct object") - world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, atlas.Object{Type: atlas.ObjectRockLarge}) + world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, atlas.Object{Type: roveapi.Object_RockLarge}) // Try and bump into the rock vec, err := world.MoveRover(a, maths.North) @@ -281,10 +281,10 @@ func TestWorld_RoverRepair(t *testing.T) { assert.Contains(t, newinfo.Logs[len(newinfo.Logs)-1].Text, "repair", "Rover logs should contain the repair") // Check again that it can't repair past the max - world.Atlas.SetObject(pos, atlas.Object{Type: atlas.ObjectRockSmall}) + world.Atlas.SetObject(pos, atlas.Object{Type: roveapi.Object_RockSmall}) o, err = world.RoverStash(a) assert.NoError(t, err, "Failed to stash") - assert.Equal(t, atlas.ObjectRockSmall, o, "Failed to get correct object") + assert.Equal(t, roveapi.Object_RockSmall, o, "Failed to get correct object") err = world.ExecuteCommand(&Command{Command: roveapi.CommandType_repair}, a) assert.NoError(t, err, "Failed to repair rover") @@ -311,8 +311,8 @@ func TestWorld_Charge(t *testing.T) { assert.NoError(t, err, "Failed to get position for rover") // Ensure the path ahead is empty - world.Atlas.SetTile(initialPos.Added(maths.North.Vector()), atlas.TileRock) - world.Atlas.SetObject(initialPos.Added(maths.North.Vector()), atlas.Object{Type: atlas.ObjectNone}) + world.Atlas.SetTile(initialPos.Added(maths.North.Vector()), roveapi.Tile_Rock) + world.Atlas.SetObject(initialPos.Added(maths.North.Vector()), atlas.Object{Type: roveapi.Object_ObjectNone}) // Try and move north (along unblocked path) newPos, err := world.MoveRover(a, maths.North) @@ -394,7 +394,7 @@ func TestWorld_Broadcast(t *testing.T) { assert.Contains(t, rb.Logs[len(rb.Logs)-1].Text, "ABC", "Rover A should have logged it's broadcast") // Warp B outside of the range of A - world.Atlas.SetObject(maths.Vector{X: ra.Range, Y: 0}, atlas.Object{Type: atlas.ObjectNone}) + world.Atlas.SetObject(maths.Vector{X: ra.Range, Y: 0}, atlas.Object{Type: roveapi.Object_ObjectNone}) assert.NoError(t, world.WarpRover(b, maths.Vector{X: ra.Range, Y: 0})) // Broadcast from a again @@ -411,7 +411,7 @@ func TestWorld_Broadcast(t *testing.T) { assert.Contains(t, rb.Logs[len(rb.Logs)-1].Text, "XYZ", "Rover A should have logged it's broadcast") // Warp B outside of the range of A - world.Atlas.SetObject(maths.Vector{X: ra.Range + 1, Y: 0}, atlas.Object{Type: atlas.ObjectNone}) + world.Atlas.SetObject(maths.Vector{X: ra.Range + 1, Y: 0}, atlas.Object{Type: roveapi.Object_ObjectNone}) assert.NoError(t, world.WarpRover(b, maths.Vector{X: ra.Range + 1, Y: 0})) // Broadcast from a again diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index 1eeeabd..842d574 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -98,6 +98,119 @@ func (CommandType) EnumDescriptor() ([]byte, []int) { return file_roveapi_roveapi_proto_rawDescGZIP(), []int{0} } +// Types of objects +type Object int32 + +const ( + // ObjectNone represents no object at all + Object_ObjectNone Object = 0 + // RoverLive represents a live rover + Object_RoverLive Object = 1 + // RockSmall is a small stashable rock + Object_RockSmall Object = 2 + // RockLarge is a large blocking rock + Object_RockLarge Object = 3 +) + +// Enum value maps for Object. +var ( + Object_name = map[int32]string{ + 0: "ObjectNone", + 1: "RoverLive", + 2: "RockSmall", + 3: "RockLarge", + } + Object_value = map[string]int32{ + "ObjectNone": 0, + "RoverLive": 1, + "RockSmall": 2, + "RockLarge": 3, + } +) + +func (x Object) Enum() *Object { + p := new(Object) + *p = x + return p +} + +func (x Object) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Object) Descriptor() protoreflect.EnumDescriptor { + return file_roveapi_roveapi_proto_enumTypes[1].Descriptor() +} + +func (Object) Type() protoreflect.EnumType { + return &file_roveapi_roveapi_proto_enumTypes[1] +} + +func (x Object) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Object.Descriptor instead. +func (Object) EnumDescriptor() ([]byte, []int) { + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{1} +} + +type Tile int32 + +const ( + // TileNone is a keyword for nothing + Tile_TileNone Tile = 0 + // Rock is solid rock ground + Tile_Rock Tile = 1 + // Gravel is loose rocks + Tile_Gravel Tile = 2 + // Sand is sand + Tile_Sand Tile = 3 +) + +// Enum value maps for Tile. +var ( + Tile_name = map[int32]string{ + 0: "TileNone", + 1: "Rock", + 2: "Gravel", + 3: "Sand", + } + Tile_value = map[string]int32{ + "TileNone": 0, + "Rock": 1, + "Gravel": 2, + "Sand": 3, + } +) + +func (x Tile) Enum() *Tile { + p := new(Tile) + *p = x + return p +} + +func (x Tile) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Tile) Descriptor() protoreflect.EnumDescriptor { + return file_roveapi_roveapi_proto_enumTypes[2].Descriptor() +} + +func (Tile) Type() protoreflect.EnumType { + return &file_roveapi_roveapi_proto_enumTypes[2] +} + +func (x Tile) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Tile.Descriptor instead. +func (Tile) EnumDescriptor() ([]byte, []int) { + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{2} +} + // ServerStatusRequest is an empty placeholder type ServerStatusRequest struct { state protoimpl.MessageState @@ -629,9 +742,9 @@ type RadarResponse struct { Range int32 `protobuf:"varint,1,opt,name=range,proto3" json:"range,omitempty"` // A 1D array representing range*2 + 1 squared set of tiles, origin bottom // left and in row->column order - Tiles []byte `protobuf:"bytes,2,opt,name=tiles,proto3" json:"tiles,omitempty"` + Tiles []Tile `protobuf:"varint,2,rep,packed,name=tiles,proto3,enum=roveapi.Tile" json:"tiles,omitempty"` // A similar array to the tile array, but containing objects - Objects []byte `protobuf:"bytes,3,opt,name=objects,proto3" json:"objects,omitempty"` + Objects []Object `protobuf:"varint,3,rep,packed,name=objects,proto3,enum=roveapi.Object" json:"objects,omitempty"` } func (x *RadarResponse) Reset() { @@ -673,14 +786,14 @@ func (x *RadarResponse) GetRange() int32 { return 0 } -func (x *RadarResponse) GetTiles() []byte { +func (x *RadarResponse) GetTiles() []Tile { if x != nil { return x.Tiles } return nil } -func (x *RadarResponse) GetObjects() []byte { +func (x *RadarResponse) GetObjects() []Object { if x != nil { return x.Objects } @@ -1044,11 +1157,13 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, - 0x55, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x75, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, - 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, + 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x54, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x29, 0x0a, 0x07, 0x6f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0f, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, @@ -1092,31 +1207,39 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x01, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, - 0x61, 0x73, 0x74, 0x10, 0x05, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, - 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, - 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, - 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x73, 0x74, 0x10, 0x05, 0x2a, 0x45, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, + 0x0e, 0x0a, 0x0a, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, + 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x0d, + 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x02, 0x12, 0x0d, 0x0a, + 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x03, 0x2a, 0x34, 0x0a, 0x04, + 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x54, 0x69, 0x6c, 0x65, 0x4e, 0x6f, 0x6e, 0x65, + 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, + 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, + 0x10, 0x03, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, 0x52, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, + 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, + 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1131,51 +1254,55 @@ func file_roveapi_roveapi_proto_rawDescGZIP() []byte { return file_roveapi_roveapi_proto_rawDescData } -var file_roveapi_roveapi_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_roveapi_roveapi_proto_enumTypes = make([]protoimpl.EnumInfo, 3) var file_roveapi_roveapi_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_roveapi_roveapi_proto_goTypes = []interface{}{ (CommandType)(0), // 0: roveapi.CommandType - (*ServerStatusRequest)(nil), // 1: roveapi.ServerStatusRequest - (*ServerStatusResponse)(nil), // 2: roveapi.ServerStatusResponse - (*RegisterRequest)(nil), // 3: roveapi.RegisterRequest - (*Account)(nil), // 4: roveapi.Account - (*RegisterResponse)(nil), // 5: roveapi.RegisterResponse - (*Command)(nil), // 6: roveapi.Command - (*CommandRequest)(nil), // 7: roveapi.CommandRequest - (*CommandResponse)(nil), // 8: roveapi.CommandResponse - (*RadarRequest)(nil), // 9: roveapi.RadarRequest - (*RadarResponse)(nil), // 10: roveapi.RadarResponse - (*StatusRequest)(nil), // 11: roveapi.StatusRequest - (*Log)(nil), // 12: roveapi.Log - (*Vector)(nil), // 13: roveapi.Vector - (*StatusResponse)(nil), // 14: roveapi.StatusResponse + (Object)(0), // 1: roveapi.Object + (Tile)(0), // 2: roveapi.Tile + (*ServerStatusRequest)(nil), // 3: roveapi.ServerStatusRequest + (*ServerStatusResponse)(nil), // 4: roveapi.ServerStatusResponse + (*RegisterRequest)(nil), // 5: roveapi.RegisterRequest + (*Account)(nil), // 6: roveapi.Account + (*RegisterResponse)(nil), // 7: roveapi.RegisterResponse + (*Command)(nil), // 8: roveapi.Command + (*CommandRequest)(nil), // 9: roveapi.CommandRequest + (*CommandResponse)(nil), // 10: roveapi.CommandResponse + (*RadarRequest)(nil), // 11: roveapi.RadarRequest + (*RadarResponse)(nil), // 12: roveapi.RadarResponse + (*StatusRequest)(nil), // 13: roveapi.StatusRequest + (*Log)(nil), // 14: roveapi.Log + (*Vector)(nil), // 15: roveapi.Vector + (*StatusResponse)(nil), // 16: roveapi.StatusResponse } var file_roveapi_roveapi_proto_depIdxs = []int32{ - 4, // 0: roveapi.RegisterResponse.account:type_name -> roveapi.Account + 6, // 0: roveapi.RegisterResponse.account:type_name -> roveapi.Account 0, // 1: roveapi.Command.command:type_name -> roveapi.CommandType - 4, // 2: roveapi.CommandRequest.account:type_name -> roveapi.Account - 6, // 3: roveapi.CommandRequest.commands:type_name -> roveapi.Command - 4, // 4: roveapi.RadarRequest.account:type_name -> roveapi.Account - 4, // 5: roveapi.StatusRequest.account:type_name -> roveapi.Account - 13, // 6: roveapi.StatusResponse.position:type_name -> roveapi.Vector - 6, // 7: roveapi.StatusResponse.incomingCommands:type_name -> roveapi.Command - 6, // 8: roveapi.StatusResponse.queuedCommands:type_name -> roveapi.Command - 12, // 9: roveapi.StatusResponse.logs:type_name -> roveapi.Log - 1, // 10: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest - 3, // 11: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest - 7, // 12: roveapi.Rove.Command:input_type -> roveapi.CommandRequest - 9, // 13: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest - 11, // 14: roveapi.Rove.Status:input_type -> roveapi.StatusRequest - 2, // 15: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse - 5, // 16: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse - 8, // 17: roveapi.Rove.Command:output_type -> roveapi.CommandResponse - 10, // 18: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse - 14, // 19: roveapi.Rove.Status:output_type -> roveapi.StatusResponse - 15, // [15:20] is the sub-list for method output_type - 10, // [10:15] is the sub-list for method input_type - 10, // [10:10] is the sub-list for extension type_name - 10, // [10:10] is the sub-list for extension extendee - 0, // [0:10] is the sub-list for field type_name + 6, // 2: roveapi.CommandRequest.account:type_name -> roveapi.Account + 8, // 3: roveapi.CommandRequest.commands:type_name -> roveapi.Command + 6, // 4: roveapi.RadarRequest.account:type_name -> roveapi.Account + 2, // 5: roveapi.RadarResponse.tiles:type_name -> roveapi.Tile + 1, // 6: roveapi.RadarResponse.objects:type_name -> roveapi.Object + 6, // 7: roveapi.StatusRequest.account:type_name -> roveapi.Account + 15, // 8: roveapi.StatusResponse.position:type_name -> roveapi.Vector + 8, // 9: roveapi.StatusResponse.incomingCommands:type_name -> roveapi.Command + 8, // 10: roveapi.StatusResponse.queuedCommands:type_name -> roveapi.Command + 14, // 11: roveapi.StatusResponse.logs:type_name -> roveapi.Log + 3, // 12: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest + 5, // 13: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest + 9, // 14: roveapi.Rove.Command:input_type -> roveapi.CommandRequest + 11, // 15: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest + 13, // 16: roveapi.Rove.Status:input_type -> roveapi.StatusRequest + 4, // 17: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse + 7, // 18: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse + 10, // 19: roveapi.Rove.Command:output_type -> roveapi.CommandResponse + 12, // 20: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse + 16, // 21: roveapi.Rove.Status:output_type -> roveapi.StatusResponse + 17, // [17:22] is the sub-list for method output_type + 12, // [12:17] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name } func init() { file_roveapi_roveapi_proto_init() } @@ -1362,7 +1489,7 @@ func file_roveapi_roveapi_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_roveapi_roveapi_proto_rawDesc, - NumEnums: 1, + NumEnums: 3, NumMessages: 14, NumExtensions: 0, NumServices: 1, diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index 9dd2577..62dbc5a 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -134,6 +134,35 @@ message CommandResponse {} // Radar // +// Types of objects +enum Object { + // ObjectNone represents no object at all + ObjectNone = 0; + + // RoverLive represents a live rover + RoverLive = 1; + + // RockSmall is a small stashable rock + RockSmall = 2; + + // RockLarge is a large blocking rock + RockLarge = 3; +} + +enum Tile { + // TileNone is a keyword for nothing + TileNone = 0; + + // Rock is solid rock ground + Rock = 1; + + // Gravel is loose rocks + Gravel = 2; + + // Sand is sand + Sand = 3; +} + // RadarRequest is the data needed to request the radar for a rover message RadarRequest { // The account for this request @@ -147,10 +176,10 @@ message RadarResponse { // A 1D array representing range*2 + 1 squared set of tiles, origin bottom // left and in row->column order - bytes tiles = 2; + repeated Tile tiles = 2; // A similar array to the tile array, but containing objects - bytes objects = 3; + repeated Object objects = 3; } // From 7bdfa44fb60eda92eea042449af17a34fe2105be Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 12:33:11 +0100 Subject: [PATCH 132/228] Fix up the concept of "None" tiles and objects Replace with "Unknown" which is effectively an invalid value --- cmd/rove/main.go | 6 +-- pkg/atlas/atlas.go | 4 +- pkg/atlas/atlas_test.go | 6 +-- pkg/atlas/chunkAtlas.go | 6 +-- pkg/atlas/glyph.go | 3 -- pkg/atlas/objects.go | 4 +- pkg/rove/world.go | 10 ++-- pkg/rove/world_test.go | 18 +++---- proto/roveapi/roveapi.pb.go | 94 ++++++++++++++++++------------------- proto/roveapi/roveapi.proto | 8 ++-- 10 files changed, 72 insertions(+), 87 deletions(-) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 8e4f740..c782850 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -287,12 +287,10 @@ func InnerMain(command string, args ...string) error { for i := 0; i < num; i++ { t := response.Tiles[i+num*j] o := response.Objects[i+num*j] - if o != roveapi.Object_ObjectNone { + if o != roveapi.Object_ObjectUnknown { fmt.Printf("%c", atlas.ObjectGlyph(o)) - } else if t != roveapi.Tile_TileNone { - fmt.Printf("%c", atlas.TileGlyph(t)) } else { - fmt.Printf(" ") + fmt.Printf("%c", atlas.TileGlyph(t)) } } diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index de83642..dfdcb74 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -10,8 +10,6 @@ import ( // TileGlyph returns the glyph for this tile type func TileGlyph(t roveapi.Tile) Glyph { switch t { - case roveapi.Tile_TileNone: - return GlyphNone case roveapi.Tile_Rock: return GlyphGroundRock case roveapi.Tile_Gravel: @@ -21,7 +19,7 @@ func TileGlyph(t roveapi.Tile) Glyph { } log.Fatalf("Unknown tile type: %c", t) - return GlyphNone + return 0 } // Atlas represents a 2D world atlas of tiles and objects diff --git a/pkg/atlas/atlas_test.go b/pkg/atlas/atlas_test.go index de8b7b9..bc0467a 100644 --- a/pkg/atlas/atlas_test.go +++ b/pkg/atlas/atlas_test.go @@ -260,12 +260,10 @@ func TestAtlas_WorldGen(t *testing.T) { for j := num - 1; j >= 0; j-- { for i := 0; i < num; i++ { t, o := a.QueryPosition(maths.Vector{X: i, Y: j}) - if o.Type != roveapi.Object_ObjectNone { + if o.Type != roveapi.Object_ObjectUnknown { fmt.Printf("%c", ObjectGlyph(o.Type)) - } else if t != roveapi.Tile_TileNone { - fmt.Printf("%c", TileGlyph(t)) } else { - fmt.Printf(" ") + fmt.Printf("%c", TileGlyph(t)) } } diff --git a/pkg/atlas/chunkAtlas.go b/pkg/atlas/chunkAtlas.go index 43ca3af..3f19b07 100644 --- a/pkg/atlas/chunkAtlas.go +++ b/pkg/atlas/chunkAtlas.go @@ -121,14 +121,14 @@ func (a *chunkBasedAtlas) populate(chunk int) { // Get the object noise value for this location o := a.objectNoise.Eval2(float64(origin.X+i)/objectNoiseScale, float64(origin.Y+j)/objectNoiseScale) - var obj = roveapi.Object_ObjectNone + var obj = roveapi.Object_ObjectUnknown switch { case o > 0.6: obj = roveapi.Object_RockLarge case o > 0.5: obj = roveapi.Object_RockSmall } - if obj != roveapi.Object_ObjectNone { + if obj != roveapi.Object_ObjectUnknown { c.Objects[j*a.ChunkSize+i] = Object{Type: roveapi.Object(obj)} } } @@ -160,7 +160,7 @@ func (a *chunkBasedAtlas) setObject(chunk int, local maths.Vector, object Object c := a.Chunks[chunk] i := a.chunkTileIndex(local) - if object.Type != roveapi.Object_ObjectNone { + if object.Type != roveapi.Object_ObjectUnknown { c.Objects[i] = object } else { delete(c.Objects, i) diff --git a/pkg/atlas/glyph.go b/pkg/atlas/glyph.go index c5c0ad7..ff186e3 100644 --- a/pkg/atlas/glyph.go +++ b/pkg/atlas/glyph.go @@ -4,9 +4,6 @@ package atlas type Glyph byte const ( - // GlyphNone is a keyword for nothing - GlyphNone = Glyph(0) - // GlyphGroundRock is solid rock ground GlyphGroundRock = Glyph('-') diff --git a/pkg/atlas/objects.go b/pkg/atlas/objects.go index ccbb69b..269beb4 100644 --- a/pkg/atlas/objects.go +++ b/pkg/atlas/objects.go @@ -9,8 +9,6 @@ import ( // ObjectGlyph returns the glyph for this object type func ObjectGlyph(o roveapi.Object) Glyph { switch o { - case roveapi.Object_ObjectNone: - return GlyphNone case roveapi.Object_RoverLive: return GlyphRoverLive case roveapi.Object_RockSmall: @@ -20,7 +18,7 @@ func ObjectGlyph(o roveapi.Object) Glyph { } log.Fatalf("Unknown object type: %c", o) - return GlyphNone + return 0 } // Object represents an object in the world diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 51b81ef..b3b15a0 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -324,29 +324,29 @@ func (w *World) RoverStash(rover string) (roveapi.Object, error) { r, ok := w.Rovers[rover] if !ok { - return roveapi.Object_ObjectNone, fmt.Errorf("no rover matching id") + return roveapi.Object_ObjectUnknown, fmt.Errorf("no rover matching id") } // Can't pick up when full if len(r.Inventory) >= r.Capacity { - return roveapi.Object_ObjectNone, nil + return roveapi.Object_ObjectUnknown, nil } // Ensure the rover has energy if r.Charge <= 0 { - return roveapi.Object_ObjectNone, nil + return roveapi.Object_ObjectUnknown, nil } r.Charge-- _, obj := w.Atlas.QueryPosition(r.Pos) if !obj.IsStashable() { - return roveapi.Object_ObjectNone, nil + return roveapi.Object_ObjectUnknown, nil } r.AddLogEntryf("stashed %c", obj.Type) r.Inventory = append(r.Inventory, obj) w.Rovers[rover] = r - w.Atlas.SetObject(r.Pos, atlas.Object{Type: roveapi.Object_ObjectNone}) + w.Atlas.SetObject(r.Pos, atlas.Object{Type: roveapi.Object_ObjectUnknown}) return obj.Type, nil } diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index 8142858..6534d89 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -142,13 +142,10 @@ func TestWorld_RoverStash(t *testing.T) { Y: 0.0, } - world.Atlas.SetObject(pos, atlas.Object{Type: roveapi.Object_ObjectNone}) + world.Atlas.SetObject(pos, atlas.Object{Type: roveapi.Object_ObjectUnknown}) err = world.WarpRover(a, pos) assert.NoError(t, err, "Failed to set position for rover") - // Set to a traversible tile - world.Atlas.SetTile(pos, roveapi.Tile_TileNone) - rover, err := world.GetRover(a) assert.NoError(t, err, "Failed to get rover") @@ -163,7 +160,7 @@ func TestWorld_RoverStash(t *testing.T) { // Check it's gone _, obj := world.Atlas.QueryPosition(pos) - assert.Equal(t, roveapi.Object_ObjectNone, obj.Type, "Stash failed to remove object from atlas") + assert.Equal(t, roveapi.Object_ObjectUnknown, obj.Type, "Stash failed to remove object from atlas") // Check we have it inv, err := world.RoverInventory(a) @@ -191,7 +188,7 @@ func TestWorld_RoverStash(t *testing.T) { // Try to pick it up o, err := world.RoverStash(a) assert.NoError(t, err, "Failed to stash") - assert.Equal(t, roveapi.Object_ObjectNone, o, "Failed to get correct object") + assert.Equal(t, roveapi.Object_ObjectUnknown, o, "Failed to get correct object") // Check it's still there _, obj := world.Atlas.QueryPosition(pos) @@ -246,8 +243,7 @@ func TestWorld_RoverRepair(t *testing.T) { Y: 0.0, } - world.Atlas.SetTile(pos, roveapi.Tile_TileNone) - world.Atlas.SetObject(pos, atlas.Object{Type: roveapi.Object_ObjectNone}) + world.Atlas.SetObject(pos, atlas.Object{Type: roveapi.Object_ObjectUnknown}) err = world.WarpRover(a, pos) assert.NoError(t, err, "Failed to set position for rover") @@ -312,7 +308,7 @@ func TestWorld_Charge(t *testing.T) { // Ensure the path ahead is empty world.Atlas.SetTile(initialPos.Added(maths.North.Vector()), roveapi.Tile_Rock) - world.Atlas.SetObject(initialPos.Added(maths.North.Vector()), atlas.Object{Type: roveapi.Object_ObjectNone}) + world.Atlas.SetObject(initialPos.Added(maths.North.Vector()), atlas.Object{Type: roveapi.Object_ObjectUnknown}) // Try and move north (along unblocked path) newPos, err := world.MoveRover(a, maths.North) @@ -394,7 +390,7 @@ func TestWorld_Broadcast(t *testing.T) { assert.Contains(t, rb.Logs[len(rb.Logs)-1].Text, "ABC", "Rover A should have logged it's broadcast") // Warp B outside of the range of A - world.Atlas.SetObject(maths.Vector{X: ra.Range, Y: 0}, atlas.Object{Type: roveapi.Object_ObjectNone}) + world.Atlas.SetObject(maths.Vector{X: ra.Range, Y: 0}, atlas.Object{Type: roveapi.Object_ObjectUnknown}) assert.NoError(t, world.WarpRover(b, maths.Vector{X: ra.Range, Y: 0})) // Broadcast from a again @@ -411,7 +407,7 @@ func TestWorld_Broadcast(t *testing.T) { assert.Contains(t, rb.Logs[len(rb.Logs)-1].Text, "XYZ", "Rover A should have logged it's broadcast") // Warp B outside of the range of A - world.Atlas.SetObject(maths.Vector{X: ra.Range + 1, Y: 0}, atlas.Object{Type: roveapi.Object_ObjectNone}) + world.Atlas.SetObject(maths.Vector{X: ra.Range + 1, Y: 0}, atlas.Object{Type: roveapi.Object_ObjectUnknown}) assert.NoError(t, world.WarpRover(b, maths.Vector{X: ra.Range + 1, Y: 0})) // Broadcast from a again diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index 842d574..dd47ca9 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -102,8 +102,8 @@ func (CommandType) EnumDescriptor() ([]byte, []int) { type Object int32 const ( - // ObjectNone represents no object at all - Object_ObjectNone Object = 0 + // ObjectUnknown represents no object at all + Object_ObjectUnknown Object = 0 // RoverLive represents a live rover Object_RoverLive Object = 1 // RockSmall is a small stashable rock @@ -115,16 +115,16 @@ const ( // Enum value maps for Object. var ( Object_name = map[int32]string{ - 0: "ObjectNone", + 0: "ObjectUnknown", 1: "RoverLive", 2: "RockSmall", 3: "RockLarge", } Object_value = map[string]int32{ - "ObjectNone": 0, - "RoverLive": 1, - "RockSmall": 2, - "RockLarge": 3, + "ObjectUnknown": 0, + "RoverLive": 1, + "RockSmall": 2, + "RockLarge": 3, } ) @@ -158,8 +158,8 @@ func (Object) EnumDescriptor() ([]byte, []int) { type Tile int32 const ( - // TileNone is a keyword for nothing - Tile_TileNone Tile = 0 + // TileUnknown is a keyword for nothing + Tile_TileUnknown Tile = 0 // Rock is solid rock ground Tile_Rock Tile = 1 // Gravel is loose rocks @@ -171,16 +171,16 @@ const ( // Enum value maps for Tile. var ( Tile_name = map[int32]string{ - 0: "TileNone", + 0: "TileUnknown", 1: "Rock", 2: "Gravel", 3: "Sand", } Tile_value = map[string]int32{ - "TileNone": 0, - "Rock": 1, - "Gravel": 2, - "Sand": 3, + "TileUnknown": 0, + "Rock": 1, + "Gravel": 2, + "Sand": 3, } ) @@ -1207,39 +1207,39 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x01, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, - 0x61, 0x73, 0x74, 0x10, 0x05, 0x2a, 0x45, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, - 0x0e, 0x0a, 0x0a, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, - 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x0d, - 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x02, 0x12, 0x0d, 0x0a, - 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x03, 0x2a, 0x34, 0x0a, 0x04, - 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x54, 0x69, 0x6c, 0x65, 0x4e, 0x6f, 0x6e, 0x65, - 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, - 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, - 0x10, 0x03, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, 0x52, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, - 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, - 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, - 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x73, 0x74, 0x10, 0x05, 0x2a, 0x48, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, + 0x11, 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, + 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, + 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x02, + 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x03, 0x2a, + 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, + 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, + 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, + 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, + 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x1d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, + 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, + 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, + 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, + 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, + 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index 62dbc5a..0813533 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -136,8 +136,8 @@ message CommandResponse {} // Types of objects enum Object { - // ObjectNone represents no object at all - ObjectNone = 0; + // ObjectUnknown represents no object at all + ObjectUnknown = 0; // RoverLive represents a live rover RoverLive = 1; @@ -150,8 +150,8 @@ enum Object { } enum Tile { - // TileNone is a keyword for nothing - TileNone = 0; + // TileUnknown is a keyword for nothing + TileUnknown = 0; // Rock is solid rock ground Rock = 1; From 4a89cb9d6e76eb1a4a36dd84ec98d49343ab9c4d Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 12:34:54 +0100 Subject: [PATCH 133/228] Move glyph functions out to the glyph file --- pkg/atlas/atlas.go | 17 ----------------- pkg/atlas/glyph.go | 36 ++++++++++++++++++++++++++++++++++++ pkg/atlas/objects.go | 17 ----------------- 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/pkg/atlas/atlas.go b/pkg/atlas/atlas.go index dfdcb74..05012aa 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/atlas/atlas.go @@ -1,27 +1,10 @@ package atlas import ( - "log" - "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/proto/roveapi" ) -// TileGlyph returns the glyph for this tile type -func TileGlyph(t roveapi.Tile) Glyph { - switch t { - case roveapi.Tile_Rock: - return GlyphGroundRock - case roveapi.Tile_Gravel: - return GlyphGroundGravel - case roveapi.Tile_Sand: - return GlyphGroundSand - } - - log.Fatalf("Unknown tile type: %c", t) - return 0 -} - // Atlas represents a 2D world atlas of tiles and objects type Atlas interface { // SetTile sets a location on the Atlas to a type of tile diff --git a/pkg/atlas/glyph.go b/pkg/atlas/glyph.go index ff186e3..183f460 100644 --- a/pkg/atlas/glyph.go +++ b/pkg/atlas/glyph.go @@ -1,5 +1,11 @@ package atlas +import ( + "log" + + "github.com/mdiluz/rove/proto/roveapi" +) + // Glyph represents the text representation of something in the game type Glyph byte @@ -22,3 +28,33 @@ const ( // GlyphRockLarge is a large blocking rock GlyphRockLarge = Glyph('O') ) + +// TileGlyph returns the glyph for this tile type +func TileGlyph(t roveapi.Tile) Glyph { + switch t { + case roveapi.Tile_Rock: + return GlyphGroundRock + case roveapi.Tile_Gravel: + return GlyphGroundGravel + case roveapi.Tile_Sand: + return GlyphGroundSand + } + + log.Fatalf("Unknown tile type: %c", t) + return 0 +} + +// ObjectGlyph returns the glyph for this object type +func ObjectGlyph(o roveapi.Object) Glyph { + switch o { + case roveapi.Object_RoverLive: + return GlyphRoverLive + case roveapi.Object_RockSmall: + return GlyphRockSmall + case roveapi.Object_RockLarge: + return GlyphRockLarge + } + + log.Fatalf("Unknown object type: %c", o) + return 0 +} diff --git a/pkg/atlas/objects.go b/pkg/atlas/objects.go index 269beb4..e1b6730 100644 --- a/pkg/atlas/objects.go +++ b/pkg/atlas/objects.go @@ -1,26 +1,9 @@ package atlas import ( - "log" - "github.com/mdiluz/rove/proto/roveapi" ) -// ObjectGlyph returns the glyph for this object type -func ObjectGlyph(o roveapi.Object) Glyph { - switch o { - case roveapi.Object_RoverLive: - return GlyphRoverLive - case roveapi.Object_RockSmall: - return GlyphRockSmall - case roveapi.Object_RockLarge: - return GlyphRockLarge - } - - log.Fatalf("Unknown object type: %c", o) - return 0 -} - // Object represents an object in the world type Object struct { // The type of the object From da91d316491e9bf3ce063775cbb53631a3231083 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 12:36:48 +0100 Subject: [PATCH 134/228] MOve glyph code into client --- {pkg/atlas => cmd/rove}/glyph.go | 2 +- cmd/rove/main.go | 5 ++--- pkg/atlas/atlas_test.go | 17 +---------------- 3 files changed, 4 insertions(+), 20 deletions(-) rename {pkg/atlas => cmd/rove}/glyph.go (98%) diff --git a/pkg/atlas/glyph.go b/cmd/rove/glyph.go similarity index 98% rename from pkg/atlas/glyph.go rename to cmd/rove/glyph.go index 183f460..57f556d 100644 --- a/pkg/atlas/glyph.go +++ b/cmd/rove/glyph.go @@ -1,4 +1,4 @@ -package atlas +package main import ( "log" diff --git a/cmd/rove/main.go b/cmd/rove/main.go index c782850..e00fd9f 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -10,7 +10,6 @@ import ( "path/filepath" "time" - "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/pkg/version" "github.com/mdiluz/rove/proto/roveapi" @@ -288,9 +287,9 @@ func InnerMain(command string, args ...string) error { t := response.Tiles[i+num*j] o := response.Objects[i+num*j] if o != roveapi.Object_ObjectUnknown { - fmt.Printf("%c", atlas.ObjectGlyph(o)) + fmt.Printf("%c", ObjectGlyph(o)) } else { - fmt.Printf("%c", atlas.TileGlyph(t)) + fmt.Printf("%c", TileGlyph(t)) } } diff --git a/pkg/atlas/atlas_test.go b/pkg/atlas/atlas_test.go index bc0467a..3d715f1 100644 --- a/pkg/atlas/atlas_test.go +++ b/pkg/atlas/atlas_test.go @@ -1,7 +1,6 @@ package atlas import ( - "fmt" "testing" "github.com/mdiluz/rove/pkg/maths" @@ -252,21 +251,7 @@ func TestAtlas_GetSetCorrect(t *testing.T) { func TestAtlas_WorldGen(t *testing.T) { a := NewChunkAtlas(8) + // Spawn a large world _, _ = a.QueryPosition(maths.Vector{X: 20, Y: 20}) - - // Print out the world for manual evaluation - num := 20 - for j := num - 1; j >= 0; j-- { - for i := 0; i < num; i++ { - t, o := a.QueryPosition(maths.Vector{X: i, Y: j}) - if o.Type != roveapi.Object_ObjectUnknown { - fmt.Printf("%c", ObjectGlyph(o.Type)) - } else { - fmt.Printf("%c", TileGlyph(t)) - } - - } - fmt.Print("\n") - } } From e9188dbbf654bfa30a7f6611251b0d5b7bf13a94 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 12:37:36 +0100 Subject: [PATCH 135/228] Auto-format proto file --- proto/roveapi/roveapi.proto | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index 0813533..680aa9a 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -136,31 +136,31 @@ message CommandResponse {} // Types of objects enum Object { - // ObjectUnknown represents no object at all - ObjectUnknown = 0; + // ObjectUnknown represents no object at all + ObjectUnknown = 0; - // RoverLive represents a live rover - RoverLive = 1; + // RoverLive represents a live rover + RoverLive = 1; - // RockSmall is a small stashable rock - RockSmall = 2; + // RockSmall is a small stashable rock + RockSmall = 2; - // RockLarge is a large blocking rock - RockLarge = 3; + // RockLarge is a large blocking rock + RockLarge = 3; } enum Tile { - // TileUnknown is a keyword for nothing - TileUnknown = 0; + // TileUnknown is a keyword for nothing + TileUnknown = 0; - // Rock is solid rock ground - Rock = 1; + // Rock is solid rock ground + Rock = 1; - // Gravel is loose rocks - Gravel = 2; + // Gravel is loose rocks + Gravel = 2; - // Sand is sand - Sand = 3; + // Sand is sand + Sand = 3; } // RadarRequest is the data needed to request the radar for a rover From 4e0e55af8822b12a27ca05292fa3d0f5b8c4a560 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 12:54:41 +0100 Subject: [PATCH 136/228] Move bearing into proto file --- cmd/rove/main.go | 24 ++- pkg/maths/bearing.go | 97 ---------- pkg/maths/bearing_test.go | 31 --- pkg/maths/vector.go | 18 ++ pkg/rove/command.go | 2 +- pkg/rove/command_test.go | 4 +- pkg/rove/world.go | 12 +- pkg/rove/world_test.go | 14 +- proto/roveapi/roveapi.pb.go | 372 +++++++++++++++++++++--------------- proto/roveapi/roveapi.proto | 13 +- 10 files changed, 281 insertions(+), 306 deletions(-) delete mode 100644 pkg/maths/bearing.go delete mode 100644 pkg/maths/bearing_test.go diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 17d8dd4..dd8c39c 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -10,7 +10,6 @@ import ( "path/filepath" "time" - "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/pkg/version" "github.com/mdiluz/rove/proto/roveapi" "golang.org/x/net/context" @@ -123,6 +122,21 @@ func checkAccount(a Account) error { return nil } +// StringToBearing converts a string to a bearing +func StringToBearing(s string) roveapi.Bearing { + switch s { + case "N": + return roveapi.Bearing_North + case "E": + return roveapi.Bearing_East + case "S": + return roveapi.Bearing_South + case "W": + return roveapi.Bearing_West + } + return roveapi.Bearing_BearingUnknown +} + // InnerMain wraps the main function so we can test it func InnerMain(command string, args ...string) error { @@ -214,13 +228,15 @@ func InnerMain(command string, args ...string) error { i++ if len(args) == i { return fmt.Errorf("move command must be passed bearing") - } else if _, err := maths.BearingFromString(args[i]); err != nil { - return err + } + var b roveapi.Bearing + if b = StringToBearing(args[i]); b == roveapi.Bearing_BearingUnknown { + return fmt.Errorf("unrecognised bearing: %s", args[i]) } commands = append(commands, &roveapi.Command{ Command: roveapi.CommandType_move, - Data: &roveapi.Command_Bearing{Bearing: args[i]}, + Data: &roveapi.Command_Bearing{Bearing: b}, }, ) case "broadcast": diff --git a/pkg/maths/bearing.go b/pkg/maths/bearing.go deleted file mode 100644 index e72148b..0000000 --- a/pkg/maths/bearing.go +++ /dev/null @@ -1,97 +0,0 @@ -package maths - -import ( - "fmt" - "strings" -) - -// Bearing describes a compass direction -type Bearing int - -const ( - // North describes a 0,1 vector - North Bearing = iota - // NorthEast describes a 1,1 vector - NorthEast - // East describes a 1,0 vector - East - // SouthEast describes a 1,-1 vector - SouthEast - // South describes a 0,-1 vector - South - // SouthWest describes a -1,-1 vector - SouthWest - // West describes a -1,0 vector - West - // NorthWest describes a -1,1 vector - NorthWest -) - -// bearingString simply describes the strings associated with a direction -type bearingString struct { - Long string - Short string -} - -// bearingStrings is the set of strings for each direction -var bearingStrings = []bearingString{ - {"North", "N"}, - {"NorthEast", "NE"}, - {"East", "E"}, - {"SouthEast", "SE"}, - {"South", "S"}, - {"SouthWest", "SW"}, - {"West", "W"}, - {"NorthWest", "NW"}, -} - -// String converts a Direction to a String -func (d Bearing) String() string { - return bearingStrings[d].Long -} - -// ShortString converts a Direction to a short string version -func (d Bearing) ShortString() string { - return bearingStrings[d].Short -} - -// BearingFromString gets the Direction from a string -func BearingFromString(s string) (Bearing, error) { - for i, d := range bearingStrings { - if strings.EqualFold(d.Long, s) || strings.EqualFold(d.Short, s) { - return Bearing(i), nil - } - } - return -1, fmt.Errorf("unknown bearing: %s", s) -} - -var bearingVectors = []Vector{ - {X: 0, Y: 1}, // N - {X: 1, Y: 1}, // NE - {X: 1, Y: 0}, // E - {X: 1, Y: -1}, // SE - {X: 0, Y: -1}, // S - {X: -1, Y: -1}, // SW - {X: -1, Y: 0}, // W - {X: -1, Y: 1}, // NW -} - -// Vector converts a Direction to a Vector -func (d Bearing) Vector() Vector { - return bearingVectors[d] -} - -// IsCardinal returns if this is a cardinal (NESW) -func (d Bearing) IsCardinal() bool { - switch d { - case North: - fallthrough - case East: - fallthrough - case South: - fallthrough - case West: - return true - } - return false -} diff --git a/pkg/maths/bearing_test.go b/pkg/maths/bearing_test.go deleted file mode 100644 index e0de345..0000000 --- a/pkg/maths/bearing_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package maths - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestDirection(t *testing.T) { - dir := North - - assert.Equal(t, "North", dir.String()) - assert.Equal(t, "N", dir.ShortString()) - assert.Equal(t, Vector{X: 0, Y: 1}, dir.Vector()) - - dir, err := BearingFromString("N") - assert.NoError(t, err) - assert.Equal(t, North, dir) - - dir, err = BearingFromString("n") - assert.NoError(t, err) - assert.Equal(t, North, dir) - - dir, err = BearingFromString("north") - assert.NoError(t, err) - assert.Equal(t, North, dir) - - dir, err = BearingFromString("NorthWest") - assert.NoError(t, err) - assert.Equal(t, NorthWest, dir) -} diff --git a/pkg/maths/vector.go b/pkg/maths/vector.go index 2dd3bad..8a63708 100644 --- a/pkg/maths/vector.go +++ b/pkg/maths/vector.go @@ -2,6 +2,8 @@ package maths import ( "math" + + "github.com/mdiluz/rove/proto/roveapi" ) // Vector desribes a 3D vector @@ -81,3 +83,19 @@ func Min2(v1 Vector, v2 Vector) Vector { func Max2(v1 Vector, v2 Vector) Vector { return Vector{Max(v1.X, v2.X), Max(v1.Y, v2.Y)} } + +// BearingToVector converts a bearing to a vector +func BearingToVector(b roveapi.Bearing) Vector { + switch b { + case roveapi.Bearing_North: + return Vector{Y: 1} + case roveapi.Bearing_East: + return Vector{X: 1} + case roveapi.Bearing_South: + return Vector{Y: -1} + case roveapi.Bearing_West: + return Vector{X: -1} + } + + return Vector{} +} diff --git a/pkg/rove/command.go b/pkg/rove/command.go index 86e9cad..e64d646 100644 --- a/pkg/rove/command.go +++ b/pkg/rove/command.go @@ -7,7 +7,7 @@ type Command struct { Command roveapi.CommandType `json:"command"` // Used in the move command - Bearing string `json:"bearing,omitempty"` + Bearing roveapi.Bearing `json:"bearing,omitempty"` // Used in the broadcast command Message []byte `json:"message,omitempty"` diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index 9150fde..337782f 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -21,7 +21,7 @@ func TestCommand_Move(t *testing.T) { assert.NoError(t, err, "Failed to set position for rover") // Try the move command - moveCommand := Command{Command: roveapi.CommandType_move, Bearing: "N"} + moveCommand := Command{Command: roveapi.CommandType_move, Bearing: roveapi.Bearing_North} assert.NoError(t, world.Enqueue(a, moveCommand), "Failed to execute move command") // Tick the world @@ -47,7 +47,7 @@ func TestCommand_Recharge(t *testing.T) { assert.NoError(t, err, "Failed to set position for rover") // Move to use up some charge - moveCommand := Command{Command: roveapi.CommandType_move, Bearing: "N"} + moveCommand := Command{Command: roveapi.CommandType_move, Bearing: roveapi.Bearing_North} assert.NoError(t, world.Enqueue(a, moveCommand), "Failed to queue move command") // Tick the world diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 4693555..a5ab05f 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -277,7 +277,7 @@ func (w *World) WarpRover(rover string, pos maths.Vector) error { } // MoveRover attempts to move a rover in a specific direction -func (w *World) MoveRover(rover string, b maths.Bearing) (maths.Vector, error) { +func (w *World) MoveRover(rover string, b roveapi.Bearing) (maths.Vector, error) { w.worldMutex.Lock() defer w.worldMutex.Unlock() @@ -293,7 +293,7 @@ func (w *World) MoveRover(rover string, b maths.Bearing) (maths.Vector, error) { i.Charge-- // Try the new move position - newPos := i.Pos.Added(b.Vector()) + newPos := i.Pos.Added(maths.BearingToVector(b)) // Get the tile and verify it's empty _, obj := w.Atlas.QueryPosition(newPos) @@ -426,9 +426,7 @@ func (w *World) Enqueue(rover string, commands ...Command) error { for _, c := range commands { switch c.Command { case roveapi.CommandType_move: - if b, err := maths.BearingFromString(c.Bearing); err != nil { - return fmt.Errorf("unknown bearing: %s", c.Bearing) - } else if !b.IsCardinal() { + if c.Bearing == roveapi.Bearing_BearingUnknown { return fmt.Errorf("bearing must be cardinal") } case roveapi.CommandType_broadcast: @@ -507,9 +505,7 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { switch c.Command { case roveapi.CommandType_move: - if dir, err := maths.BearingFromString(c.Bearing); err != nil { - return err - } else if _, err := w.MoveRover(rover, dir); err != nil { + if _, err := w.MoveRover(rover, c.Bearing); err != nil { return err } diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index 6534d89..7cf2483 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -78,7 +78,7 @@ func TestWorld_GetSetMovePosition(t *testing.T) { assert.NoError(t, err, "Failed to set position for rover") assert.Equal(t, pos, newPos, "Failed to correctly set position for rover") - b := maths.North + b := roveapi.Bearing_North newPos, err = world.MoveRover(a, b) assert.NoError(t, err, "Failed to set position for rover") pos.Add(maths.Vector{X: 0, Y: 1}) @@ -223,7 +223,7 @@ func TestWorld_RoverDamage(t *testing.T) { world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, atlas.Object{Type: roveapi.Object_RockLarge}) - vec, err := world.MoveRover(a, maths.North) + vec, err := world.MoveRover(a, roveapi.Bearing_North) assert.NoError(t, err, "Failed to move rover") assert.Equal(t, pos, vec, "Rover managed to move into large rock") @@ -260,7 +260,7 @@ func TestWorld_RoverRepair(t *testing.T) { world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, atlas.Object{Type: roveapi.Object_RockLarge}) // Try and bump into the rock - vec, err := world.MoveRover(a, maths.North) + vec, err := world.MoveRover(a, roveapi.Bearing_North) assert.NoError(t, err, "Failed to move rover") assert.Equal(t, pos, vec, "Rover managed to move into large rock") @@ -307,13 +307,13 @@ func TestWorld_Charge(t *testing.T) { assert.NoError(t, err, "Failed to get position for rover") // Ensure the path ahead is empty - world.Atlas.SetTile(initialPos.Added(maths.North.Vector()), roveapi.Tile_Rock) - world.Atlas.SetObject(initialPos.Added(maths.North.Vector()), atlas.Object{Type: roveapi.Object_ObjectUnknown}) + world.Atlas.SetTile(initialPos.Added(maths.BearingToVector(roveapi.Bearing_North)), roveapi.Tile_Rock) + world.Atlas.SetObject(initialPos.Added(maths.BearingToVector(roveapi.Bearing_North)), atlas.Object{Type: roveapi.Object_ObjectUnknown}) // Try and move north (along unblocked path) - newPos, err := world.MoveRover(a, maths.North) + newPos, err := world.MoveRover(a, roveapi.Bearing_North) assert.NoError(t, err, "Failed to set position for rover") - assert.Equal(t, initialPos.Added(maths.North.Vector()), newPos, "Failed to correctly move position for rover") + assert.Equal(t, initialPos.Added(maths.BearingToVector(roveapi.Bearing_North)), newPos, "Failed to correctly move position for rover") // Ensure rover lost charge rover, err := world.GetRover(a) diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index dd47ca9..e35c863 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -98,6 +98,62 @@ func (CommandType) EnumDescriptor() ([]byte, []int) { return file_roveapi_roveapi_proto_rawDescGZIP(), []int{0} } +type Bearing int32 + +const ( + // BearingUnknown an unknown invalid bearing + Bearing_BearingUnknown Bearing = 0 + Bearing_North Bearing = 1 + Bearing_East Bearing = 2 + Bearing_South Bearing = 3 + Bearing_West Bearing = 4 +) + +// Enum value maps for Bearing. +var ( + Bearing_name = map[int32]string{ + 0: "BearingUnknown", + 1: "North", + 2: "East", + 3: "South", + 4: "West", + } + Bearing_value = map[string]int32{ + "BearingUnknown": 0, + "North": 1, + "East": 2, + "South": 3, + "West": 4, + } +) + +func (x Bearing) Enum() *Bearing { + p := new(Bearing) + *p = x + return p +} + +func (x Bearing) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Bearing) Descriptor() protoreflect.EnumDescriptor { + return file_roveapi_roveapi_proto_enumTypes[1].Descriptor() +} + +func (Bearing) Type() protoreflect.EnumType { + return &file_roveapi_roveapi_proto_enumTypes[1] +} + +func (x Bearing) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Bearing.Descriptor instead. +func (Bearing) EnumDescriptor() ([]byte, []int) { + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{1} +} + // Types of objects type Object int32 @@ -139,11 +195,11 @@ func (x Object) String() string { } func (Object) Descriptor() protoreflect.EnumDescriptor { - return file_roveapi_roveapi_proto_enumTypes[1].Descriptor() + return file_roveapi_roveapi_proto_enumTypes[2].Descriptor() } func (Object) Type() protoreflect.EnumType { - return &file_roveapi_roveapi_proto_enumTypes[1] + return &file_roveapi_roveapi_proto_enumTypes[2] } func (x Object) Number() protoreflect.EnumNumber { @@ -152,7 +208,7 @@ func (x Object) Number() protoreflect.EnumNumber { // Deprecated: Use Object.Descriptor instead. func (Object) EnumDescriptor() ([]byte, []int) { - return file_roveapi_roveapi_proto_rawDescGZIP(), []int{1} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{2} } type Tile int32 @@ -195,11 +251,11 @@ func (x Tile) String() string { } func (Tile) Descriptor() protoreflect.EnumDescriptor { - return file_roveapi_roveapi_proto_enumTypes[2].Descriptor() + return file_roveapi_roveapi_proto_enumTypes[3].Descriptor() } func (Tile) Type() protoreflect.EnumType { - return &file_roveapi_roveapi_proto_enumTypes[2] + return &file_roveapi_roveapi_proto_enumTypes[3] } func (x Tile) Number() protoreflect.EnumNumber { @@ -208,7 +264,7 @@ func (x Tile) Number() protoreflect.EnumNumber { // Deprecated: Use Tile.Descriptor instead. func (Tile) EnumDescriptor() ([]byte, []int) { - return file_roveapi_roveapi_proto_rawDescGZIP(), []int{2} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{3} } // ServerStatusRequest is an empty placeholder @@ -551,11 +607,11 @@ func (m *Command) GetData() isCommand_Data { return nil } -func (x *Command) GetBearing() string { +func (x *Command) GetBearing() Bearing { if x, ok := x.GetData().(*Command_Bearing); ok { return x.Bearing } - return "" + return Bearing_BearingUnknown } func (x *Command) GetMessage() []byte { @@ -570,9 +626,9 @@ type isCommand_Data interface { } type Command_Bearing struct { - // A bearing, example: NE + // A bearing // Used with MOVE - Bearing string `protobuf:"bytes,2,opt,name=bearing,proto3,oneof"` + Bearing Bearing `protobuf:"varint,2,opt,name=bearing,proto3,enum=roveapi.Bearing,oneof"` } type Command_Message struct { @@ -1137,109 +1193,115 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x79, 0x0a, 0x07, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1a, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, - 0x12, 0x1a, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0c, 0x48, 0x00, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x06, 0x0a, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x22, 0x6a, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, + 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x8b, 0x01, 0x0a, 0x07, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2c, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x48, 0x00, 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, + 0x69, 0x6e, 0x67, 0x12, 0x1a, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, + 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x6a, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, + 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, - 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, - 0x75, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, - 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x54, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x29, 0x0a, 0x07, 0x6f, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0f, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, 0x6f, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, - 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, - 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, - 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, - 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xc3, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, - 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x56, 0x65, 0x63, 0x74, - 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, - 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, - 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, - 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, - 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, - 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, - 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, - 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, - 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, - 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, - 0x61, 0x72, 0x67, 0x65, 0x12, 0x3c, 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x52, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x73, 0x12, 0x38, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, - 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x20, 0x0a, 0x04, - 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x2a, 0x55, - 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, - 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x6d, 0x6f, 0x76, 0x65, 0x10, - 0x01, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, - 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x68, - 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, - 0x61, 0x73, 0x74, 0x10, 0x05, 0x2a, 0x48, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, - 0x11, 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, - 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, - 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x02, - 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x03, 0x2a, - 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, - 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, - 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, - 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, - 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x1d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, - 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, - 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, - 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, - 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, - 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, - 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x74, 0x22, 0x75, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x74, 0x69, 0x6c, + 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x54, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x29, + 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0e, 0x32, + 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, 0x0a, + 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, + 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, + 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, + 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xc3, 0x03, 0x0a, 0x0e, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x56, + 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, + 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, + 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, + 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, + 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, + 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, + 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, + 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, + 0x72, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, + 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, + 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, + 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x3c, 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, + 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x38, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, + 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, + 0x20, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, + 0x73, 0x2a, 0x55, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x6d, 0x6f, + 0x76, 0x65, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x02, 0x12, + 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x72, + 0x65, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, + 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x05, 0x2a, 0x47, 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, + 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, + 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, + 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, + 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, 0x73, 0x74, 0x10, + 0x04, 0x2a, 0x48, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, + 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x0d, 0x0a, + 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, + 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x03, 0x2a, 0x37, 0x0a, 0x04, 0x54, + 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, + 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, 0x12, 0x0a, + 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x61, + 0x6e, 0x64, 0x10, 0x03, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, + 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1254,55 +1316,57 @@ func file_roveapi_roveapi_proto_rawDescGZIP() []byte { return file_roveapi_roveapi_proto_rawDescData } -var file_roveapi_roveapi_proto_enumTypes = make([]protoimpl.EnumInfo, 3) +var file_roveapi_roveapi_proto_enumTypes = make([]protoimpl.EnumInfo, 4) var file_roveapi_roveapi_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_roveapi_roveapi_proto_goTypes = []interface{}{ (CommandType)(0), // 0: roveapi.CommandType - (Object)(0), // 1: roveapi.Object - (Tile)(0), // 2: roveapi.Tile - (*ServerStatusRequest)(nil), // 3: roveapi.ServerStatusRequest - (*ServerStatusResponse)(nil), // 4: roveapi.ServerStatusResponse - (*RegisterRequest)(nil), // 5: roveapi.RegisterRequest - (*Account)(nil), // 6: roveapi.Account - (*RegisterResponse)(nil), // 7: roveapi.RegisterResponse - (*Command)(nil), // 8: roveapi.Command - (*CommandRequest)(nil), // 9: roveapi.CommandRequest - (*CommandResponse)(nil), // 10: roveapi.CommandResponse - (*RadarRequest)(nil), // 11: roveapi.RadarRequest - (*RadarResponse)(nil), // 12: roveapi.RadarResponse - (*StatusRequest)(nil), // 13: roveapi.StatusRequest - (*Log)(nil), // 14: roveapi.Log - (*Vector)(nil), // 15: roveapi.Vector - (*StatusResponse)(nil), // 16: roveapi.StatusResponse + (Bearing)(0), // 1: roveapi.Bearing + (Object)(0), // 2: roveapi.Object + (Tile)(0), // 3: roveapi.Tile + (*ServerStatusRequest)(nil), // 4: roveapi.ServerStatusRequest + (*ServerStatusResponse)(nil), // 5: roveapi.ServerStatusResponse + (*RegisterRequest)(nil), // 6: roveapi.RegisterRequest + (*Account)(nil), // 7: roveapi.Account + (*RegisterResponse)(nil), // 8: roveapi.RegisterResponse + (*Command)(nil), // 9: roveapi.Command + (*CommandRequest)(nil), // 10: roveapi.CommandRequest + (*CommandResponse)(nil), // 11: roveapi.CommandResponse + (*RadarRequest)(nil), // 12: roveapi.RadarRequest + (*RadarResponse)(nil), // 13: roveapi.RadarResponse + (*StatusRequest)(nil), // 14: roveapi.StatusRequest + (*Log)(nil), // 15: roveapi.Log + (*Vector)(nil), // 16: roveapi.Vector + (*StatusResponse)(nil), // 17: roveapi.StatusResponse } var file_roveapi_roveapi_proto_depIdxs = []int32{ - 6, // 0: roveapi.RegisterResponse.account:type_name -> roveapi.Account + 7, // 0: roveapi.RegisterResponse.account:type_name -> roveapi.Account 0, // 1: roveapi.Command.command:type_name -> roveapi.CommandType - 6, // 2: roveapi.CommandRequest.account:type_name -> roveapi.Account - 8, // 3: roveapi.CommandRequest.commands:type_name -> roveapi.Command - 6, // 4: roveapi.RadarRequest.account:type_name -> roveapi.Account - 2, // 5: roveapi.RadarResponse.tiles:type_name -> roveapi.Tile - 1, // 6: roveapi.RadarResponse.objects:type_name -> roveapi.Object - 6, // 7: roveapi.StatusRequest.account:type_name -> roveapi.Account - 15, // 8: roveapi.StatusResponse.position:type_name -> roveapi.Vector - 8, // 9: roveapi.StatusResponse.incomingCommands:type_name -> roveapi.Command - 8, // 10: roveapi.StatusResponse.queuedCommands:type_name -> roveapi.Command - 14, // 11: roveapi.StatusResponse.logs:type_name -> roveapi.Log - 3, // 12: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest - 5, // 13: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest - 9, // 14: roveapi.Rove.Command:input_type -> roveapi.CommandRequest - 11, // 15: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest - 13, // 16: roveapi.Rove.Status:input_type -> roveapi.StatusRequest - 4, // 17: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse - 7, // 18: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse - 10, // 19: roveapi.Rove.Command:output_type -> roveapi.CommandResponse - 12, // 20: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse - 16, // 21: roveapi.Rove.Status:output_type -> roveapi.StatusResponse - 17, // [17:22] is the sub-list for method output_type - 12, // [12:17] is the sub-list for method input_type - 12, // [12:12] is the sub-list for extension type_name - 12, // [12:12] is the sub-list for extension extendee - 0, // [0:12] is the sub-list for field type_name + 1, // 2: roveapi.Command.bearing:type_name -> roveapi.Bearing + 7, // 3: roveapi.CommandRequest.account:type_name -> roveapi.Account + 9, // 4: roveapi.CommandRequest.commands:type_name -> roveapi.Command + 7, // 5: roveapi.RadarRequest.account:type_name -> roveapi.Account + 3, // 6: roveapi.RadarResponse.tiles:type_name -> roveapi.Tile + 2, // 7: roveapi.RadarResponse.objects:type_name -> roveapi.Object + 7, // 8: roveapi.StatusRequest.account:type_name -> roveapi.Account + 16, // 9: roveapi.StatusResponse.position:type_name -> roveapi.Vector + 9, // 10: roveapi.StatusResponse.incomingCommands:type_name -> roveapi.Command + 9, // 11: roveapi.StatusResponse.queuedCommands:type_name -> roveapi.Command + 15, // 12: roveapi.StatusResponse.logs:type_name -> roveapi.Log + 4, // 13: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest + 6, // 14: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest + 10, // 15: roveapi.Rove.Command:input_type -> roveapi.CommandRequest + 12, // 16: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest + 14, // 17: roveapi.Rove.Status:input_type -> roveapi.StatusRequest + 5, // 18: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse + 8, // 19: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse + 11, // 20: roveapi.Rove.Command:output_type -> roveapi.CommandResponse + 13, // 21: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse + 17, // 22: roveapi.Rove.Status:output_type -> roveapi.StatusResponse + 18, // [18:23] is the sub-list for method output_type + 13, // [13:18] is the sub-list for method input_type + 13, // [13:13] is the sub-list for extension type_name + 13, // [13:13] is the sub-list for extension extendee + 0, // [0:13] is the sub-list for field type_name } func init() { file_roveapi_roveapi_proto_init() } @@ -1489,7 +1553,7 @@ func file_roveapi_roveapi_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_roveapi_roveapi_proto_rawDesc, - NumEnums: 3, + NumEnums: 4, NumMessages: 14, NumExtensions: 0, NumServices: 1, diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index 680aa9a..b43087b 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -101,15 +101,24 @@ enum CommandType { broadcast = 5; } +enum Bearing { + // BearingUnknown an unknown invalid bearing + BearingUnknown = 0; + North = 1; + East = 2; + South = 3; + West = 4; +} + // Command is a single command for a rover message Command { // The command type CommandType command = 1; oneof data { - // A bearing, example: NE + // A bearing // Used with MOVE - string bearing = 2; + Bearing bearing = 2; // A simple message, must be composed of printable ASCII glyphs (32-126) // maximum of three characters From cd6a275bb97a6800a774c859ddec1c30a50c4cda Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 12:59:36 +0100 Subject: [PATCH 137/228] Move code to internal cmd/main --- cmd/rove/{ => internal}/glyph.go | 2 +- cmd/rove/main.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) rename cmd/rove/{ => internal}/glyph.go (98%) diff --git a/cmd/rove/glyph.go b/cmd/rove/internal/glyph.go similarity index 98% rename from cmd/rove/glyph.go rename to cmd/rove/internal/glyph.go index 57f556d..1a26f5d 100644 --- a/cmd/rove/glyph.go +++ b/cmd/rove/internal/glyph.go @@ -1,4 +1,4 @@ -package main +package internal import ( "log" diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 17d8dd4..4e3a1d2 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -10,6 +10,7 @@ import ( "path/filepath" "time" + "github.com/mdiluz/rove/cmd/rove/internal" "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/pkg/version" "github.com/mdiluz/rove/proto/roveapi" @@ -287,9 +288,9 @@ func InnerMain(command string, args ...string) error { t := response.Tiles[i+num*j] o := response.Objects[i+num*j] if o != roveapi.Object_ObjectUnknown { - fmt.Printf("%c", ObjectGlyph(o)) + fmt.Printf("%c", internal.ObjectGlyph(o)) } else { - fmt.Printf("%c", TileGlyph(t)) + fmt.Printf("%c", internal.TileGlyph(t)) } } From 57f668ae548ab28745e11afec08df78820b7e42d Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 13:13:09 +0100 Subject: [PATCH 138/228] Reinstate BearingFromString function --- cmd/rove/main.go | 24 ++++++++++++++++++++---- pkg/rove/world.go | 2 +- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 4e3a1d2..bd98d52 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -11,7 +11,6 @@ import ( "time" "github.com/mdiluz/rove/cmd/rove/internal" - "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/pkg/version" "github.com/mdiluz/rove/proto/roveapi" "golang.org/x/net/context" @@ -124,6 +123,21 @@ func checkAccount(a Account) error { return nil } +// BearingFromString converts a string to a bearing +func BearingFromString(s string) roveapi.Bearing { + switch s { + case "N": + return roveapi.Bearing_North + case "E": + return roveapi.Bearing_East + case "S": + return roveapi.Bearing_South + case "W": + return roveapi.Bearing_West + } + return roveapi.Bearing_BearingUnknown +} + // InnerMain wraps the main function so we can test it func InnerMain(command string, args ...string) error { @@ -215,13 +229,15 @@ func InnerMain(command string, args ...string) error { i++ if len(args) == i { return fmt.Errorf("move command must be passed bearing") - } else if _, err := maths.BearingFromString(args[i]); err != nil { - return err + } + var b roveapi.Bearing + if b = BearingFromString(args[i]); b == roveapi.Bearing_BearingUnknown { + return fmt.Errorf("unrecognised bearing: %s", args[i]) } commands = append(commands, &roveapi.Command{ Command: roveapi.CommandType_move, - Data: &roveapi.Command_Bearing{Bearing: args[i]}, + Data: &roveapi.Command_Bearing{Bearing: b}, }, ) case "broadcast": diff --git a/pkg/rove/world.go b/pkg/rove/world.go index a5ab05f..7c313ba 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -427,7 +427,7 @@ func (w *World) Enqueue(rover string, commands ...Command) error { switch c.Command { case roveapi.CommandType_move: if c.Bearing == roveapi.Bearing_BearingUnknown { - return fmt.Errorf("bearing must be cardinal") + return fmt.Errorf("bearing must be valid") } case roveapi.CommandType_broadcast: if len(c.Message) > 3 { From fd0992353d282c1c7b0855afb8121bbf4d1a3b1b Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 13:27:29 +0100 Subject: [PATCH 139/228] Add data to objects --- pkg/atlas/objects.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/atlas/objects.go b/pkg/atlas/objects.go index e1b6730..69ce560 100644 --- a/pkg/atlas/objects.go +++ b/pkg/atlas/objects.go @@ -8,6 +8,9 @@ import ( type Object struct { // The type of the object Type roveapi.Object `json:"type"` + + // Data is an internal type used for certain types of object + Data []byte `json:"data"` } // IsBlocking checks if an object is a blocking object From 713699687f0d21f4047fba2f9ad528aa1b8c14f2 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 13:27:38 +0100 Subject: [PATCH 140/228] Add a dormat rover data type --- proto/roveapi/roveapi.pb.go | 67 ++++++++++++++++++++----------------- proto/roveapi/roveapi.proto | 3 ++ 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index e35c863..2f5e069 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -162,6 +162,8 @@ const ( Object_ObjectUnknown Object = 0 // RoverLive represents a live rover Object_RoverLive Object = 1 + // RoverDormant describes a dormant rover + Object_RoverDormant Object = 4 // RockSmall is a small stashable rock Object_RockSmall Object = 2 // RockLarge is a large blocking rock @@ -173,12 +175,14 @@ var ( Object_name = map[int32]string{ 0: "ObjectUnknown", 1: "RoverLive", + 4: "RoverDormant", 2: "RockSmall", 3: "RockLarge", } Object_value = map[string]int32{ "ObjectUnknown": 0, "RoverLive": 1, + "RoverDormant": 4, "RockSmall": 2, "RockLarge": 3, } @@ -1269,39 +1273,40 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, 0x73, 0x74, 0x10, - 0x04, 0x2a, 0x48, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, + 0x04, 0x2a, 0x5a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, - 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x0d, 0x0a, - 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, - 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x03, 0x2a, 0x37, 0x0a, 0x04, 0x54, - 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, - 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, 0x12, 0x0a, - 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x61, - 0x6e, 0x64, 0x10, 0x03, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, - 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, + 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x10, 0x0a, + 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, 0x04, 0x12, + 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x02, 0x12, 0x0d, + 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x03, 0x2a, 0x37, 0x0a, + 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, + 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, + 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, + 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, + 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, + 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, - 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, - 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, + 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, + 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, + 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index b43087b..7d227fb 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -151,6 +151,9 @@ enum Object { // RoverLive represents a live rover RoverLive = 1; + // RoverDormant describes a dormant rover + RoverDormant = 4; + // RockSmall is a small stashable rock RockSmall = 2; From 4f1a9c2c2b4b6f4a2de506982afc625927921830 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 13:27:59 +0100 Subject: [PATCH 141/228] Re-order object types --- proto/roveapi/roveapi.pb.go | 24 ++++++++++++------------ proto/roveapi/roveapi.proto | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index 2f5e069..783325f 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -163,11 +163,11 @@ const ( // RoverLive represents a live rover Object_RoverLive Object = 1 // RoverDormant describes a dormant rover - Object_RoverDormant Object = 4 + Object_RoverDormant Object = 2 // RockSmall is a small stashable rock - Object_RockSmall Object = 2 + Object_RockSmall Object = 3 // RockLarge is a large blocking rock - Object_RockLarge Object = 3 + Object_RockLarge Object = 4 ) // Enum value maps for Object. @@ -175,16 +175,16 @@ var ( Object_name = map[int32]string{ 0: "ObjectUnknown", 1: "RoverLive", - 4: "RoverDormant", - 2: "RockSmall", - 3: "RockLarge", + 2: "RoverDormant", + 3: "RockSmall", + 4: "RockLarge", } Object_value = map[string]int32{ "ObjectUnknown": 0, "RoverLive": 1, - "RoverDormant": 4, - "RockSmall": 2, - "RockLarge": 3, + "RoverDormant": 2, + "RockSmall": 3, + "RockLarge": 4, } ) @@ -1276,9 +1276,9 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x04, 0x2a, 0x5a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x10, 0x0a, - 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, 0x04, 0x12, - 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x02, 0x12, 0x0d, - 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x03, 0x2a, 0x37, 0x0a, + 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, 0x02, 0x12, + 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, 0x12, 0x0d, + 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x2a, 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index 7d227fb..566bcfd 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -152,13 +152,13 @@ enum Object { RoverLive = 1; // RoverDormant describes a dormant rover - RoverDormant = 4; + RoverDormant = 2; // RockSmall is a small stashable rock - RockSmall = 2; + RockSmall = 3; // RockLarge is a large blocking rock - RockLarge = 3; + RockLarge = 4; } enum Tile { From 1eba9a865279f0f4d28b714f7c42978935f8876e Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 13:41:47 +0100 Subject: [PATCH 142/228] Pull world gen out into interface --- pkg/atlas/chunkAtlas.go | 64 +++++++++++++---------------------------- pkg/atlas/worldgen.go | 64 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 44 deletions(-) create mode 100644 pkg/atlas/worldgen.go diff --git a/pkg/atlas/chunkAtlas.go b/pkg/atlas/chunkAtlas.go index 3f19b07..4abb0e8 100644 --- a/pkg/atlas/chunkAtlas.go +++ b/pkg/atlas/chunkAtlas.go @@ -6,7 +6,6 @@ import ( "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/proto/roveapi" - "github.com/ojrac/opensimplex-go" ) // chunk represents a fixed square grid of tiles @@ -34,29 +33,23 @@ type chunkBasedAtlas struct { // ChunkSize is the x/y dimensions of each square chunk ChunkSize int `json:"chunksize"` - // terrainNoise describes the noise function for the terrain - terrainNoise opensimplex.Noise - - // terrainNoise describes the noise function for the terrain - objectNoise opensimplex.Noise + // worldGen is the internal world generator + worldGen WorldGen } const ( - noiseSeed = 1024 - terrainNoiseScale = 6 - objectNoiseScale = 3 + noiseSeed = 1024 ) // NewChunkAtlas creates a new empty atlas func NewChunkAtlas(chunkSize int) Atlas { // Start up with one chunk a := chunkBasedAtlas{ - ChunkSize: chunkSize, - Chunks: make([]chunk, 1), - LowerBound: maths.Vector{X: 0, Y: 0}, - UpperBound: maths.Vector{X: chunkSize, Y: chunkSize}, - terrainNoise: opensimplex.New(noiseSeed), - objectNoise: opensimplex.New(noiseSeed), + ChunkSize: chunkSize, + Chunks: make([]chunk, 1), + LowerBound: maths.Vector{X: 0, Y: 0}, + UpperBound: maths.Vector{X: chunkSize, Y: chunkSize}, + worldGen: NewNoiseWorldGen(noiseSeed), } // Initialise the first chunk a.populate(0) @@ -105,31 +98,15 @@ func (a *chunkBasedAtlas) populate(chunk int) { origin := a.chunkOriginInWorldSpace(chunk) for i := 0; i < a.ChunkSize; i++ { for j := 0; j < a.ChunkSize; j++ { + loc := maths.Vector{X: origin.X + i, Y: origin.Y + j} - // Get the terrain noise value for this location - t := a.terrainNoise.Eval2(float64(origin.X+i)/terrainNoiseScale, float64(origin.Y+j)/terrainNoiseScale) - var tile roveapi.Tile - switch { - case t > 0.5: - tile = roveapi.Tile_Gravel - case t > 0.05: - tile = roveapi.Tile_Sand - default: - tile = roveapi.Tile_Rock - } - c.Tiles[j*a.ChunkSize+i] = byte(tile) + // Set the tile + c.Tiles[j*a.ChunkSize+i] = byte(a.worldGen.GetTile(loc)) - // Get the object noise value for this location - o := a.objectNoise.Eval2(float64(origin.X+i)/objectNoiseScale, float64(origin.Y+j)/objectNoiseScale) - var obj = roveapi.Object_ObjectUnknown - switch { - case o > 0.6: - obj = roveapi.Object_RockLarge - case o > 0.5: - obj = roveapi.Object_RockSmall - } - if obj != roveapi.Object_ObjectUnknown { - c.Objects[j*a.ChunkSize+i] = Object{Type: roveapi.Object(obj)} + // Set the object + obj := a.worldGen.GetObject(loc) + if obj.Type != roveapi.Object_ObjectUnknown { + c.Objects[j*a.ChunkSize+i] = obj } } } @@ -236,12 +213,11 @@ func (a *chunkBasedAtlas) worldSpaceToChunkWithGrow(v maths.Vector) int { // Create the new empty atlas newAtlas := chunkBasedAtlas{ - ChunkSize: a.ChunkSize, - LowerBound: lower, - UpperBound: upper, - Chunks: make([]chunk, size.X*size.Y), - terrainNoise: a.terrainNoise, - objectNoise: a.objectNoise, + ChunkSize: a.ChunkSize, + LowerBound: lower, + UpperBound: upper, + Chunks: make([]chunk, size.X*size.Y), + worldGen: a.worldGen, } // Log that we're resizing diff --git a/pkg/atlas/worldgen.go b/pkg/atlas/worldgen.go new file mode 100644 index 0000000..38bcd4f --- /dev/null +++ b/pkg/atlas/worldgen.go @@ -0,0 +1,64 @@ +package atlas + +import ( + "github.com/mdiluz/rove/pkg/maths" + "github.com/mdiluz/rove/proto/roveapi" + "github.com/ojrac/opensimplex-go" +) + +// WorldGen describes a world gen algorythm +type WorldGen interface { + // GetTile generates a tile for a location + GetTile(v maths.Vector) roveapi.Tile + + // GetObject generates an object for a location + GetObject(v maths.Vector) Object +} + +// NoiseWorldGen returns a noise based world generator +type NoiseWorldGen struct { + // terrainNoise describes the noise function for the terrain + terrainNoise opensimplex.Noise + + // terrainNoise describes the noise function for the terrain + objectNoise opensimplex.Noise +} + +// NewNoiseWorldGen creates a new noise based world generator +func NewNoiseWorldGen(seed int64) WorldGen { + return &NoiseWorldGen{ + terrainNoise: opensimplex.New(seed), + objectNoise: opensimplex.New(seed), + } +} + +const ( + terrainNoiseScale = 6 + objectNoiseScale = 3 +) + +// GetTile returns the chosen tile at a location +func (g *NoiseWorldGen) GetTile(v maths.Vector) roveapi.Tile { + t := g.terrainNoise.Eval2(float64(v.X)/terrainNoiseScale, float64(v.Y)/terrainNoiseScale) + switch { + case t > 0.5: + return roveapi.Tile_Gravel + case t > 0.05: + return roveapi.Tile_Sand + default: + return roveapi.Tile_Rock + } +} + +// GetObject returns the chosen object at a location +func (g *NoiseWorldGen) GetObject(v maths.Vector) Object { + o := g.objectNoise.Eval2(float64(v.X)/objectNoiseScale, float64(v.Y)/objectNoiseScale) + var obj = roveapi.Object_ObjectUnknown + switch { + case o > 0.6: + obj = roveapi.Object_RockLarge + case o > 0.5: + obj = roveapi.Object_RockSmall + } + return Object{Type: roveapi.Object(obj)} +} From 87a9abcd12d26bce54cf2281b006f764e379cb0f Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 13:49:34 +0100 Subject: [PATCH 143/228] Add a glyph for the dormant rover --- cmd/rove/internal/glyph.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/rove/internal/glyph.go b/cmd/rove/internal/glyph.go index 1a26f5d..eac12c0 100644 --- a/cmd/rove/internal/glyph.go +++ b/cmd/rove/internal/glyph.go @@ -22,6 +22,9 @@ const ( // GlyphRoverLive represents a live rover GlyphRoverLive = Glyph('R') + // GlyphRoverDormant represents a dormant rover + GlyphRoverDormant = Glyph('r') + // GlyphRockSmall is a small stashable rock GlyphRockSmall = Glyph('o') @@ -51,6 +54,8 @@ func ObjectGlyph(o roveapi.Object) Glyph { return GlyphRoverLive case roveapi.Object_RockSmall: return GlyphRockSmall + case roveapi.Object_RoverDormant: + return GlyphRoverDormant case roveapi.Object_RockLarge: return GlyphRockLarge } From c637ed37b93018a7c74e9fba90b7971fe17f3663 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 13:49:43 +0100 Subject: [PATCH 144/228] Make the dormat rover blocking --- pkg/atlas/objects.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/atlas/objects.go b/pkg/atlas/objects.go index 69ce560..cadfa4a 100644 --- a/pkg/atlas/objects.go +++ b/pkg/atlas/objects.go @@ -17,6 +17,7 @@ type Object struct { func (o *Object) IsBlocking() bool { var blocking = [...]roveapi.Object{ roveapi.Object_RoverLive, + roveapi.Object_RoverDormant, roveapi.Object_RockLarge, } From 959cbfa15a036a34a97d0ce55b0ec3b6b6a9fa45 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 13:51:49 +0100 Subject: [PATCH 145/228] Combine the two noise functions, we only need one --- pkg/atlas/worldgen.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pkg/atlas/worldgen.go b/pkg/atlas/worldgen.go index 38bcd4f..6c5f4b7 100644 --- a/pkg/atlas/worldgen.go +++ b/pkg/atlas/worldgen.go @@ -17,18 +17,14 @@ type WorldGen interface { // NoiseWorldGen returns a noise based world generator type NoiseWorldGen struct { - // terrainNoise describes the noise function for the terrain - terrainNoise opensimplex.Noise - - // terrainNoise describes the noise function for the terrain - objectNoise opensimplex.Noise + // noise describes the noise function + noise opensimplex.Noise } // NewNoiseWorldGen creates a new noise based world generator func NewNoiseWorldGen(seed int64) WorldGen { return &NoiseWorldGen{ - terrainNoise: opensimplex.New(seed), - objectNoise: opensimplex.New(seed), + noise: opensimplex.New(seed), } } @@ -39,7 +35,7 @@ const ( // GetTile returns the chosen tile at a location func (g *NoiseWorldGen) GetTile(v maths.Vector) roveapi.Tile { - t := g.terrainNoise.Eval2(float64(v.X)/terrainNoiseScale, float64(v.Y)/terrainNoiseScale) + t := g.noise.Eval2(float64(v.X)/terrainNoiseScale, float64(v.Y)/terrainNoiseScale) switch { case t > 0.5: return roveapi.Tile_Gravel @@ -52,7 +48,7 @@ func (g *NoiseWorldGen) GetTile(v maths.Vector) roveapi.Tile { // GetObject returns the chosen object at a location func (g *NoiseWorldGen) GetObject(v maths.Vector) Object { - o := g.objectNoise.Eval2(float64(v.X)/objectNoiseScale, float64(v.Y)/objectNoiseScale) + o := g.noise.Eval2(float64(v.X)/objectNoiseScale, float64(v.Y)/objectNoiseScale) var obj = roveapi.Object_ObjectUnknown switch { case o > 0.6: From 37d828c457966ba871f444b0eeb9ea377106c347 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 13:53:38 +0100 Subject: [PATCH 146/228] Rename the rock noise --- pkg/atlas/worldgen.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/atlas/worldgen.go b/pkg/atlas/worldgen.go index 6c5f4b7..590596a 100644 --- a/pkg/atlas/worldgen.go +++ b/pkg/atlas/worldgen.go @@ -30,7 +30,7 @@ func NewNoiseWorldGen(seed int64) WorldGen { const ( terrainNoiseScale = 6 - objectNoiseScale = 3 + rockNoiseScale = 3 ) // GetTile returns the chosen tile at a location @@ -48,7 +48,7 @@ func (g *NoiseWorldGen) GetTile(v maths.Vector) roveapi.Tile { // GetObject returns the chosen object at a location func (g *NoiseWorldGen) GetObject(v maths.Vector) Object { - o := g.noise.Eval2(float64(v.X)/objectNoiseScale, float64(v.Y)/objectNoiseScale) + o := g.noise.Eval2(float64(v.X)/rockNoiseScale, float64(v.Y)/rockNoiseScale) var obj = roveapi.Object_ObjectUnknown switch { case o > 0.6: From faa1271c5a01bb555ceb3fc9d678e333bd5a4691 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 13:57:45 +0100 Subject: [PATCH 147/228] Try and very rarely spawn a dormant rover --- pkg/atlas/worldgen.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/atlas/worldgen.go b/pkg/atlas/worldgen.go index 590596a..8ec8571 100644 --- a/pkg/atlas/worldgen.go +++ b/pkg/atlas/worldgen.go @@ -31,6 +31,7 @@ func NewNoiseWorldGen(seed int64) WorldGen { const ( terrainNoiseScale = 6 rockNoiseScale = 3 + dormantRoverScale = 25 ) // GetTile returns the chosen tile at a location @@ -56,5 +57,14 @@ func (g *NoiseWorldGen) GetObject(v maths.Vector) Object { case o > 0.5: obj = roveapi.Object_RockSmall } + + // Very rarely spawn a dormant rover + if obj == roveapi.Object_ObjectUnknown { + o = g.noise.Eval2(float64(v.X)/dormantRoverScale, float64(v.Y)/dormantRoverScale) + if o > 0.8 { + obj = roveapi.Object_RoverDormant + } + } + return Object{Type: roveapi.Object(obj)} } From ddbbdce1f8f835c9cd68fbe72c697935fdafb675 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 18:23:11 +0100 Subject: [PATCH 148/228] Move default rover params to function --- pkg/rove/rover.go | 14 ++++++++++++++ pkg/rove/world.go | 11 +---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/pkg/rove/rover.go b/pkg/rove/rover.go index 089b44a..ad2d76d 100644 --- a/pkg/rove/rover.go +++ b/pkg/rove/rover.go @@ -5,6 +5,7 @@ import ( "log" "time" + "github.com/google/uuid" "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/maths" ) @@ -51,6 +52,19 @@ type Rover struct { Logs []RoverLogEntry `json:"logs"` } +// DefaultRover returns a default rover object with default settings +func DefaultRover() Rover { + return Rover{ + Range: 4, + Integrity: 10, + MaximumIntegrity: 10, + Capacity: 10, + Charge: 10, + MaximumCharge: 10, + Name: uuid.New().String(), + } +} + // AddLogEntryf adds an entry to the rovers log func (r *Rover) AddLogEntryf(format string, args ...interface{}) { text := fmt.Sprintf(format, args...) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 7c313ba..2e26c4c 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -8,7 +8,6 @@ import ( "os" "sync" - "github.com/google/uuid" "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/proto/roveapi" @@ -78,15 +77,7 @@ func (w *World) SpawnRover() (string, error) { defer w.worldMutex.Unlock() // Initialise the rover - rover := Rover{ - Range: 4, - Integrity: 10, - MaximumIntegrity: 10, - Capacity: 10, - Charge: 10, - MaximumCharge: 10, - Name: uuid.New().String(), - } + rover := DefaultRover() // Assign a random name if we have words if len(w.words) > 0 { From c48274eb23281758c5178e5a7e6eab84ba3f35a2 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 18:27:58 +0100 Subject: [PATCH 149/228] Small refactor in GetObject --- pkg/atlas/worldgen.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/atlas/worldgen.go b/pkg/atlas/worldgen.go index 8ec8571..c2bd05d 100644 --- a/pkg/atlas/worldgen.go +++ b/pkg/atlas/worldgen.go @@ -48,23 +48,22 @@ func (g *NoiseWorldGen) GetTile(v maths.Vector) roveapi.Tile { } // GetObject returns the chosen object at a location -func (g *NoiseWorldGen) GetObject(v maths.Vector) Object { +func (g *NoiseWorldGen) GetObject(v maths.Vector) (obj Object) { o := g.noise.Eval2(float64(v.X)/rockNoiseScale, float64(v.Y)/rockNoiseScale) - var obj = roveapi.Object_ObjectUnknown switch { case o > 0.6: - obj = roveapi.Object_RockLarge + obj.Type = roveapi.Object_RockLarge case o > 0.5: - obj = roveapi.Object_RockSmall + obj.Type = roveapi.Object_RockSmall } // Very rarely spawn a dormant rover - if obj == roveapi.Object_ObjectUnknown { + if obj.Type == roveapi.Object_ObjectUnknown { o = g.noise.Eval2(float64(v.X)/dormantRoverScale, float64(v.Y)/dormantRoverScale) if o > 0.8 { - obj = roveapi.Object_RoverDormant + obj.Type = roveapi.Object_RoverDormant } } - return Object{Type: roveapi.Object(obj)} + return obj } From 9130cf2517722a55d53a362b9bb3ff0042b58c0b Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 18:30:07 +0100 Subject: [PATCH 150/228] Move atlas package into rove --- pkg/{atlas => rove}/atlas.go | 2 +- pkg/{atlas => rove}/atlas_test.go | 2 +- pkg/{atlas => rove}/chunkAtlas.go | 2 +- pkg/{atlas => rove}/objects.go | 2 +- pkg/rove/rover.go | 3 +-- pkg/rove/world.go | 9 ++++----- pkg/rove/world_test.go | 27 +++++++++++++-------------- pkg/{atlas => rove}/worldgen.go | 2 +- 8 files changed, 23 insertions(+), 26 deletions(-) rename pkg/{atlas => rove}/atlas.go (97%) rename pkg/{atlas => rove}/atlas_test.go (99%) rename pkg/{atlas => rove}/chunkAtlas.go (99%) rename pkg/{atlas => rove}/objects.go (98%) rename pkg/{atlas => rove}/worldgen.go (99%) diff --git a/pkg/atlas/atlas.go b/pkg/rove/atlas.go similarity index 97% rename from pkg/atlas/atlas.go rename to pkg/rove/atlas.go index 05012aa..ab09dba 100644 --- a/pkg/atlas/atlas.go +++ b/pkg/rove/atlas.go @@ -1,4 +1,4 @@ -package atlas +package rove import ( "github.com/mdiluz/rove/pkg/maths" diff --git a/pkg/atlas/atlas_test.go b/pkg/rove/atlas_test.go similarity index 99% rename from pkg/atlas/atlas_test.go rename to pkg/rove/atlas_test.go index 3d715f1..56e5d8d 100644 --- a/pkg/atlas/atlas_test.go +++ b/pkg/rove/atlas_test.go @@ -1,4 +1,4 @@ -package atlas +package rove import ( "testing" diff --git a/pkg/atlas/chunkAtlas.go b/pkg/rove/chunkAtlas.go similarity index 99% rename from pkg/atlas/chunkAtlas.go rename to pkg/rove/chunkAtlas.go index 4abb0e8..f7ea36c 100644 --- a/pkg/atlas/chunkAtlas.go +++ b/pkg/rove/chunkAtlas.go @@ -1,4 +1,4 @@ -package atlas +package rove import ( "log" diff --git a/pkg/atlas/objects.go b/pkg/rove/objects.go similarity index 98% rename from pkg/atlas/objects.go rename to pkg/rove/objects.go index cadfa4a..94595df 100644 --- a/pkg/atlas/objects.go +++ b/pkg/rove/objects.go @@ -1,4 +1,4 @@ -package atlas +package rove import ( "github.com/mdiluz/rove/proto/roveapi" diff --git a/pkg/rove/rover.go b/pkg/rove/rover.go index ad2d76d..fb898eb 100644 --- a/pkg/rove/rover.go +++ b/pkg/rove/rover.go @@ -6,7 +6,6 @@ import ( "time" "github.com/google/uuid" - "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/maths" ) @@ -31,7 +30,7 @@ type Rover struct { Range int `json:"range"` // Inventory represents any items the rover is carrying - Inventory []atlas.Object `json:"inventory"` + Inventory []Object `json:"inventory"` // Capacity is the maximum number of inventory items Capacity int `json:"capacity"` diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 2e26c4c..74d56b7 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -8,7 +8,6 @@ import ( "os" "sync" - "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/proto/roveapi" ) @@ -25,7 +24,7 @@ type World struct { Rovers map[string]Rover `json:"rovers"` // Atlas represends the world map of chunks and tiles - Atlas atlas.Atlas `json:"atlas"` + Atlas Atlas `json:"atlas"` // Commands is the set of currently executing command streams per rover CommandQueue map[string]CommandStream `json:"commands"` @@ -64,7 +63,7 @@ func NewWorld(chunkSize int) *World { Rovers: make(map[string]Rover), CommandQueue: make(map[string]CommandStream), CommandIncoming: make(map[string]CommandStream), - Atlas: atlas.NewChunkAtlas(chunkSize), + Atlas: NewChunkAtlas(chunkSize), words: lines, TicksPerDay: 24, CurrentTicks: 0, @@ -231,7 +230,7 @@ func (w *World) SetRoverPosition(rover string, pos maths.Vector) error { } // RoverInventory returns the inventory of a requested rover -func (w *World) RoverInventory(rover string) ([]atlas.Object, error) { +func (w *World) RoverInventory(rover string) ([]Object, error) { w.worldMutex.RLock() defer w.worldMutex.RUnlock() @@ -337,7 +336,7 @@ func (w *World) RoverStash(rover string) (roveapi.Object, error) { r.AddLogEntryf("stashed %c", obj.Type) r.Inventory = append(r.Inventory, obj) w.Rovers[rover] = r - w.Atlas.SetObject(r.Pos, atlas.Object{Type: roveapi.Object_ObjectUnknown}) + w.Atlas.SetObject(r.Pos, Object{Type: roveapi.Object_ObjectUnknown}) return obj.Type, nil } diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index 7cf2483..9af411c 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -3,7 +3,6 @@ package rove import ( "testing" - "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/proto/roveapi" "github.com/stretchr/testify/assert" @@ -90,7 +89,7 @@ func TestWorld_GetSetMovePosition(t *testing.T) { assert.Contains(t, rover.Logs[len(rover.Logs)-1].Text, "moved", "Rover logs should contain the move") // Place a tile in front of the rover - world.Atlas.SetObject(maths.Vector{X: 0, Y: 2}, atlas.Object{Type: roveapi.Object_RockLarge}) + world.Atlas.SetObject(maths.Vector{X: 0, Y: 2}, Object{Type: roveapi.Object_RockLarge}) newPos, err = world.MoveRover(a, b) assert.NoError(t, err, "Failed to move rover") assert.Equal(t, pos, newPos, "Failed to correctly not move position for rover into wall") @@ -142,7 +141,7 @@ func TestWorld_RoverStash(t *testing.T) { Y: 0.0, } - world.Atlas.SetObject(pos, atlas.Object{Type: roveapi.Object_ObjectUnknown}) + world.Atlas.SetObject(pos, Object{Type: roveapi.Object_ObjectUnknown}) err = world.WarpRover(a, pos) assert.NoError(t, err, "Failed to set position for rover") @@ -151,7 +150,7 @@ func TestWorld_RoverStash(t *testing.T) { for i := 0; i < rover.Capacity; i++ { // Place an object - world.Atlas.SetObject(pos, atlas.Object{Type: roveapi.Object_RockSmall}) + world.Atlas.SetObject(pos, Object{Type: roveapi.Object_RockSmall}) // Pick it up o, err := world.RoverStash(a) @@ -166,7 +165,7 @@ func TestWorld_RoverStash(t *testing.T) { inv, err := world.RoverInventory(a) assert.NoError(t, err, "Failed to get inventory") assert.Equal(t, i+1, len(inv)) - assert.Equal(t, atlas.Object{Type: roveapi.Object_RockSmall}, inv[i]) + assert.Equal(t, Object{Type: roveapi.Object_RockSmall}, inv[i]) // Check that this did reduce the charge info, err := world.GetRover(a) @@ -183,7 +182,7 @@ func TestWorld_RoverStash(t *testing.T) { } // Place an object - world.Atlas.SetObject(pos, atlas.Object{Type: roveapi.Object_RockSmall}) + world.Atlas.SetObject(pos, Object{Type: roveapi.Object_RockSmall}) // Try to pick it up o, err := world.RoverStash(a) @@ -221,7 +220,7 @@ func TestWorld_RoverDamage(t *testing.T) { info, err := world.GetRover(a) assert.NoError(t, err, "couldn't get rover info") - world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, atlas.Object{Type: roveapi.Object_RockLarge}) + world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, Object{Type: roveapi.Object_RockLarge}) vec, err := world.MoveRover(a, roveapi.Bearing_North) assert.NoError(t, err, "Failed to move rover") @@ -243,7 +242,7 @@ func TestWorld_RoverRepair(t *testing.T) { Y: 0.0, } - world.Atlas.SetObject(pos, atlas.Object{Type: roveapi.Object_ObjectUnknown}) + world.Atlas.SetObject(pos, Object{Type: roveapi.Object_ObjectUnknown}) err = world.WarpRover(a, pos) assert.NoError(t, err, "Failed to set position for rover") @@ -252,12 +251,12 @@ func TestWorld_RoverRepair(t *testing.T) { assert.NoError(t, err, "couldn't get rover info") // Pick up something to repair with - world.Atlas.SetObject(pos, atlas.Object{Type: roveapi.Object_RockSmall}) + world.Atlas.SetObject(pos, Object{Type: roveapi.Object_RockSmall}) o, err := world.RoverStash(a) assert.NoError(t, err, "Failed to stash") assert.Equal(t, roveapi.Object_RockSmall, o, "Failed to get correct object") - world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, atlas.Object{Type: roveapi.Object_RockLarge}) + world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, Object{Type: roveapi.Object_RockLarge}) // Try and bump into the rock vec, err := world.MoveRover(a, roveapi.Bearing_North) @@ -277,7 +276,7 @@ func TestWorld_RoverRepair(t *testing.T) { assert.Contains(t, newinfo.Logs[len(newinfo.Logs)-1].Text, "repair", "Rover logs should contain the repair") // Check again that it can't repair past the max - world.Atlas.SetObject(pos, atlas.Object{Type: roveapi.Object_RockSmall}) + world.Atlas.SetObject(pos, Object{Type: roveapi.Object_RockSmall}) o, err = world.RoverStash(a) assert.NoError(t, err, "Failed to stash") assert.Equal(t, roveapi.Object_RockSmall, o, "Failed to get correct object") @@ -308,7 +307,7 @@ func TestWorld_Charge(t *testing.T) { // Ensure the path ahead is empty world.Atlas.SetTile(initialPos.Added(maths.BearingToVector(roveapi.Bearing_North)), roveapi.Tile_Rock) - world.Atlas.SetObject(initialPos.Added(maths.BearingToVector(roveapi.Bearing_North)), atlas.Object{Type: roveapi.Object_ObjectUnknown}) + world.Atlas.SetObject(initialPos.Added(maths.BearingToVector(roveapi.Bearing_North)), Object{Type: roveapi.Object_ObjectUnknown}) // Try and move north (along unblocked path) newPos, err := world.MoveRover(a, roveapi.Bearing_North) @@ -390,7 +389,7 @@ func TestWorld_Broadcast(t *testing.T) { assert.Contains(t, rb.Logs[len(rb.Logs)-1].Text, "ABC", "Rover A should have logged it's broadcast") // Warp B outside of the range of A - world.Atlas.SetObject(maths.Vector{X: ra.Range, Y: 0}, atlas.Object{Type: roveapi.Object_ObjectUnknown}) + world.Atlas.SetObject(maths.Vector{X: ra.Range, Y: 0}, Object{Type: roveapi.Object_ObjectUnknown}) assert.NoError(t, world.WarpRover(b, maths.Vector{X: ra.Range, Y: 0})) // Broadcast from a again @@ -407,7 +406,7 @@ func TestWorld_Broadcast(t *testing.T) { assert.Contains(t, rb.Logs[len(rb.Logs)-1].Text, "XYZ", "Rover A should have logged it's broadcast") // Warp B outside of the range of A - world.Atlas.SetObject(maths.Vector{X: ra.Range + 1, Y: 0}, atlas.Object{Type: roveapi.Object_ObjectUnknown}) + world.Atlas.SetObject(maths.Vector{X: ra.Range + 1, Y: 0}, Object{Type: roveapi.Object_ObjectUnknown}) assert.NoError(t, world.WarpRover(b, maths.Vector{X: ra.Range + 1, Y: 0})) // Broadcast from a again diff --git a/pkg/atlas/worldgen.go b/pkg/rove/worldgen.go similarity index 99% rename from pkg/atlas/worldgen.go rename to pkg/rove/worldgen.go index c2bd05d..2fe3bad 100644 --- a/pkg/atlas/worldgen.go +++ b/pkg/rove/worldgen.go @@ -1,4 +1,4 @@ -package atlas +package rove import ( "github.com/mdiluz/rove/pkg/maths" From 128171321185106f557ec6e9552291782fefbaa6 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 18:35:12 +0100 Subject: [PATCH 151/228] Clear locations before warp in tests --- pkg/rove/world_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index 9af411c..f393f3d 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -109,7 +109,9 @@ func TestWorld_RadarFromRover(t *testing.T) { // Warp the rovers into position bpos := maths.Vector{X: -3, Y: -3} + world.Atlas.SetObject(bpos, Object{Type: roveapi.Object_ObjectUnknown}) assert.NoError(t, world.WarpRover(b, bpos), "Failed to warp rover") + world.Atlas.SetObject(maths.Vector{X: 0, Y: 0}, Object{Type: roveapi.Object_ObjectUnknown}) assert.NoError(t, world.WarpRover(a, maths.Vector{X: 0, Y: 0}), "Failed to warp rover") radar, objs, err := world.RadarFromRover(a) @@ -371,6 +373,8 @@ func TestWorld_Broadcast(t *testing.T) { assert.NoError(t, err) // Warp rovers near to eachother + world.Atlas.SetObject(maths.Vector{X: 0, Y: 0}, Object{Type: roveapi.Object_ObjectUnknown}) + world.Atlas.SetObject(maths.Vector{X: 1, Y: 0}, Object{Type: roveapi.Object_ObjectUnknown}) assert.NoError(t, world.WarpRover(a, maths.Vector{X: 0, Y: 0})) assert.NoError(t, world.WarpRover(b, maths.Vector{X: 1, Y: 0})) From d3c480cb049a629167d048b046ea12df974f26c9 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 18:39:16 +0100 Subject: [PATCH 152/228] Add dormant rover data marshalled into obj data --- pkg/rove/worldgen.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkg/rove/worldgen.go b/pkg/rove/worldgen.go index 2fe3bad..96ac669 100644 --- a/pkg/rove/worldgen.go +++ b/pkg/rove/worldgen.go @@ -1,6 +1,9 @@ package rove import ( + "encoding/json" + "log" + "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/proto/roveapi" "github.com/ojrac/opensimplex-go" @@ -65,5 +68,21 @@ func (g *NoiseWorldGen) GetObject(v maths.Vector) (obj Object) { } } + // Post process any spawned objects + switch obj.Type { + case roveapi.Object_RoverDormant: + // Create the rover + r := DefaultRover() + + // Set the rover variables + r.Pos = v + + // Marshal the rover data into the object data + obj.Data, err := json.Marshal(r) + if err == nil { + log.Fatalf("couldn't marshal rover, should never fail: %s", err) + } + } + return obj } From 211771121fe91cc7d8a4017279676c41bad9671b Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 18:47:44 +0100 Subject: [PATCH 153/228] Extract rover naming to rover.go --- pkg/rove/rover.go | 38 +++++++++++++++++++++++++++++++++++++- pkg/rove/world.go | 35 ----------------------------------- 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/pkg/rove/rover.go b/pkg/rove/rover.go index fb898eb..6968c57 100644 --- a/pkg/rove/rover.go +++ b/pkg/rove/rover.go @@ -1,8 +1,11 @@ package rove import ( + "bufio" "fmt" "log" + "math/rand" + "os" "time" "github.com/google/uuid" @@ -60,7 +63,7 @@ func DefaultRover() Rover { Capacity: 10, Charge: 10, MaximumCharge: 10, - Name: uuid.New().String(), + Name: GenerateRoverName(), } } @@ -75,3 +78,36 @@ func (r *Rover) AddLogEntryf(format string, args ...interface{}) { }, ) } + +var wordsFile = os.Getenv("WORDS_FILE") +var roverWords []string + +// GenerateRoverName generates a new rover name +func GenerateRoverName() string { + + // Try and load the rover words file + if len(roverWords) == 0 { + // Try and load the words file + if file, err := os.Open(wordsFile); err != nil { + log.Printf("Couldn't read words file [%s], running without words: %s\n", wordsFile, err) + } else { + defer file.Close() + scanner := bufio.NewScanner(file) + for scanner.Scan() { + roverWords = append(roverWords, scanner.Text()) + } + if scanner.Err() != nil { + log.Printf("Failure during word file scan: %s\n", scanner.Err()) + } + } + } + + // Assign a random name if we have words + if len(roverWords) > 0 { + // Loop until we find a unique name + return fmt.Sprintf("%s-%s", roverWords[rand.Intn(len(roverWords))], roverWords[rand.Intn(len(roverWords))]) + } + + // Default to a unique string + return uuid.New().String() +} diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 74d56b7..25aa933 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -1,11 +1,9 @@ package rove import ( - "bufio" "fmt" "log" "math/rand" - "os" "sync" "github.com/mdiluz/rove/pkg/maths" @@ -35,36 +33,15 @@ type World struct { worldMutex sync.RWMutex // Mutex to lock around command operations cmdMutex sync.RWMutex - // Set of possible words to use for names - words []string } -var wordsFile = os.Getenv("WORDS_FILE") - // NewWorld creates a new world object func NewWorld(chunkSize int) *World { - - // Try and load the words file - var lines []string - if file, err := os.Open(wordsFile); err != nil { - log.Printf("Couldn't read words file [%s], running without words: %s\n", wordsFile, err) - } else { - defer file.Close() - scanner := bufio.NewScanner(file) - for scanner.Scan() { - lines = append(lines, scanner.Text()) - } - if scanner.Err() != nil { - log.Printf("Failure during word file scan: %s\n", scanner.Err()) - } - } - return &World{ Rovers: make(map[string]Rover), CommandQueue: make(map[string]CommandStream), CommandIncoming: make(map[string]CommandStream), Atlas: NewChunkAtlas(chunkSize), - words: lines, TicksPerDay: 24, CurrentTicks: 0, } @@ -78,18 +55,6 @@ func (w *World) SpawnRover() (string, error) { // Initialise the rover rover := DefaultRover() - // Assign a random name if we have words - if len(w.words) > 0 { - for { - // Loop until we find a unique name - name := fmt.Sprintf("%s-%s", w.words[rand.Intn(len(w.words))], w.words[rand.Intn(len(w.words))]) - if _, ok := w.Rovers[name]; !ok { - rover.Name = name - break - } - } - } - // Spawn in a random place near the origin rover.Pos = maths.Vector{ X: 10 - rand.Intn(20), From 04d7a5a4ca7a5ea15a370764adf7847e1e09d682 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 18:47:54 +0100 Subject: [PATCH 154/228] Fill in the dormant rover log --- pkg/rove/worldgen.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/rove/worldgen.go b/pkg/rove/worldgen.go index 96ac669..3561768 100644 --- a/pkg/rove/worldgen.go +++ b/pkg/rove/worldgen.go @@ -77,11 +77,17 @@ func (g *NoiseWorldGen) GetObject(v maths.Vector) (obj Object) { // Set the rover variables r.Pos = v + // For now, mark the log as corrupted + r.AddLogEntryf("log corrupted") + // Marshal the rover data into the object data - obj.Data, err := json.Marshal(r) + b, err := json.Marshal(r) if err == nil { log.Fatalf("couldn't marshal rover, should never fail: %s", err) - } + } + + // Store the bytes + obj.Data = b } return obj From bffad84181974c6c2a0b9e0b7ab8e7af94ff6c31 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 18:57:12 +0100 Subject: [PATCH 155/228] Don't use noise for rover spawns for now --- pkg/rove/worldgen.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/rove/worldgen.go b/pkg/rove/worldgen.go index 3561768..af7660f 100644 --- a/pkg/rove/worldgen.go +++ b/pkg/rove/worldgen.go @@ -34,7 +34,6 @@ func NewNoiseWorldGen(seed int64) WorldGen { const ( terrainNoiseScale = 6 rockNoiseScale = 3 - dormantRoverScale = 25 ) // GetTile returns the chosen tile at a location @@ -62,8 +61,8 @@ func (g *NoiseWorldGen) GetObject(v maths.Vector) (obj Object) { // Very rarely spawn a dormant rover if obj.Type == roveapi.Object_ObjectUnknown { - o = g.noise.Eval2(float64(v.X)/dormantRoverScale, float64(v.Y)/dormantRoverScale) - if o > 0.8 { + // TODO: Make this better, ideally with noise + if v.X%25 == 0 && v.Y%25 == 0 && v.X != 0 && v.Y != 0 { obj.Type = roveapi.Object_RoverDormant } } From 77212c72584427262d459e96415304d850ff6218 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 19 Jul 2020 18:57:22 +0100 Subject: [PATCH 156/228] Fix logic for rover marshal test --- pkg/rove/worldgen.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/rove/worldgen.go b/pkg/rove/worldgen.go index af7660f..e36b7b6 100644 --- a/pkg/rove/worldgen.go +++ b/pkg/rove/worldgen.go @@ -81,7 +81,7 @@ func (g *NoiseWorldGen) GetObject(v maths.Vector) (obj Object) { // Marshal the rover data into the object data b, err := json.Marshal(r) - if err == nil { + if err != nil { log.Fatalf("couldn't marshal rover, should never fail: %s", err) } From 6c75f07aff6588b0000edc5085b51f4976f81298 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 21 Jul 2020 22:48:16 +0100 Subject: [PATCH 157/228] Remove move and recharge commands in favor of toggle command for the sails --- cmd/rove-server/internal/routes.go | 10 - cmd/rove/main.go | 18 +- cmd/rove/main_test.go | 4 +- pkg/rove/command.go | 3 - pkg/rove/command_test.go | 81 ++------ pkg/rove/world.go | 19 +- proto/roveapi/roveapi.pb.go | 300 +++++++++++++---------------- proto/roveapi/roveapi.proto | 14 +- 8 files changed, 169 insertions(+), 280 deletions(-) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 0fb41d8..393bf93 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -83,10 +83,6 @@ func (s *Server) Status(ctx context.Context, req *roveapi.StatusRequest) (respon Command: i.Command, } switch i.Command { - case roveapi.CommandType_move: - c.Data = &roveapi.Command_Bearing{ - Bearing: i.Bearing, - } case roveapi.CommandType_broadcast: c.Data = &roveapi.Command_Message{ Message: i.Message, @@ -99,10 +95,6 @@ func (s *Server) Status(ctx context.Context, req *roveapi.StatusRequest) (respon Command: q.Command, } switch q.Command { - case roveapi.CommandType_move: - c.Data = &roveapi.Command_Bearing{ - Bearing: q.Bearing, - } case roveapi.CommandType_broadcast: c.Data = &roveapi.Command_Message{ Message: q.Message, @@ -193,8 +185,6 @@ func (s *Server) Command(ctx context.Context, req *roveapi.CommandRequest) (*rov Command: c.Command, } switch c.Command { - case roveapi.CommandType_move: - n.Bearing = c.GetBearing() case roveapi.CommandType_broadcast: n.Message = c.GetMessage() } diff --git a/cmd/rove/main.go b/cmd/rove/main.go index bd98d52..8d94106 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -33,10 +33,9 @@ func printUsage() { fmt.Fprintln(os.Stderr, "\thelp outputs this usage information") fmt.Fprintln(os.Stderr, "\tversion outputs version info") fmt.Fprintln(os.Stderr, "\nRover commands:") - fmt.Fprintln(os.Stderr, "\tmove BEARING moves the rover in the chosen direction") + fmt.Fprintln(os.Stderr, "\ttoggle toggles the sails, either catching the wind, or charging from the sun") fmt.Fprintln(os.Stderr, "\tstash stores the object at the rover location in the inventory") fmt.Fprintln(os.Stderr, "\trepair uses an inventory object to repair the rover") - fmt.Fprintln(os.Stderr, "\trecharge wait a tick to recharge the rover") fmt.Fprintln(os.Stderr, "\tbroadcast MSG broadcast a simple ASCII triplet to nearby rovers") fmt.Fprintln(os.Stderr, "\nEnvironment") fmt.Fprintln(os.Stderr, "\tROVE_USER_DATA path to user data, defaults to "+defaultDataPath) @@ -225,21 +224,6 @@ func InnerMain(command string, args ...string) error { var commands []*roveapi.Command for i := 0; i < len(args); i++ { switch args[i] { - case "move": - i++ - if len(args) == i { - return fmt.Errorf("move command must be passed bearing") - } - var b roveapi.Bearing - if b = BearingFromString(args[i]); b == roveapi.Bearing_BearingUnknown { - return fmt.Errorf("unrecognised bearing: %s", args[i]) - } - commands = append(commands, - &roveapi.Command{ - Command: roveapi.CommandType_move, - Data: &roveapi.Command_Bearing{Bearing: b}, - }, - ) case "broadcast": i++ if len(args) == i { diff --git a/cmd/rove/main_test.go b/cmd/rove/main_test.go index dd588e1..2eb564c 100644 --- a/cmd/rove/main_test.go +++ b/cmd/rove/main_test.go @@ -50,12 +50,12 @@ func Test_InnerMain(t *testing.T) { assert.Error(t, InnerMain("command")) // Give it commands - assert.NoError(t, InnerMain("command", "move", "N")) + assert.NoError(t, InnerMain("command", "toggle")) assert.NoError(t, InnerMain("command", "stash")) assert.NoError(t, InnerMain("command", "repair")) assert.NoError(t, InnerMain("command", "broadcast", "abc")) // Give it malformed commands - assert.Error(t, InnerMain("command", "move", "stash")) + assert.Error(t, InnerMain("command", "unknown")) assert.Error(t, InnerMain("command", "broadcast")) } diff --git a/pkg/rove/command.go b/pkg/rove/command.go index e64d646..df49bea 100644 --- a/pkg/rove/command.go +++ b/pkg/rove/command.go @@ -6,9 +6,6 @@ import "github.com/mdiluz/rove/proto/roveapi" type Command struct { Command roveapi.CommandType `json:"command"` - // Used in the move command - Bearing roveapi.Bearing `json:"bearing,omitempty"` - // Used in the broadcast command Message []byte `json:"message,omitempty"` } diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index 337782f..7506cd6 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -2,69 +2,28 @@ package rove import ( "testing" - - "github.com/mdiluz/rove/pkg/maths" - "github.com/mdiluz/rove/proto/roveapi" - "github.com/stretchr/testify/assert" ) -func TestCommand_Move(t *testing.T) { - world := NewWorld(8) - a, err := world.SpawnRover() - assert.NoError(t, err) - pos := maths.Vector{ - X: 1.0, - Y: 2.0, - } - - err = world.WarpRover(a, pos) - assert.NoError(t, err, "Failed to set position for rover") - - // Try the move command - moveCommand := Command{Command: roveapi.CommandType_move, Bearing: roveapi.Bearing_North} - assert.NoError(t, world.Enqueue(a, moveCommand), "Failed to execute move command") - - // Tick the world - world.EnqueueAllIncoming() - world.ExecuteCommandQueues() - - newPos, err := world.RoverPosition(a) - assert.NoError(t, err, "Failed to set position for rover") - pos.Add(maths.Vector{X: 0.0, Y: 1}) - assert.Equal(t, pos, newPos, "Failed to correctly set position for rover") +func TestCommand_Raise(t *testing.T) { + // TODO: Test the raise command } -func TestCommand_Recharge(t *testing.T) { - world := NewWorld(8) - a, err := world.SpawnRover() - assert.NoError(t, err) - pos := maths.Vector{ - X: 1.0, - Y: 2.0, - } - - err = world.WarpRover(a, pos) - assert.NoError(t, err, "Failed to set position for rover") - - // Move to use up some charge - moveCommand := Command{Command: roveapi.CommandType_move, Bearing: roveapi.Bearing_North} - assert.NoError(t, world.Enqueue(a, moveCommand), "Failed to queue move command") - - // Tick the world - world.EnqueueAllIncoming() - world.ExecuteCommandQueues() - - rover, _ := world.GetRover(a) - assert.Equal(t, rover.MaximumCharge-1, rover.Charge) - - chargeCommand := Command{Command: roveapi.CommandType_recharge} - assert.NoError(t, world.Enqueue(a, chargeCommand), "Failed to queue recharge command") - - // Tick the world - world.EnqueueAllIncoming() - world.ExecuteCommandQueues() - - rover, _ = world.GetRover(a) - assert.Equal(t, rover.MaximumCharge, rover.Charge) - +func TestCommand_Lower(t *testing.T) { + // TODO: Test the lower command +} + +func TestCommand_Stash(t *testing.T) { + // TODO: Test the stash command +} + +func TestCommand_Repair(t *testing.T) { + // TODO: Test the repair command +} + +func TestCommand_Broadcast(t *testing.T) { + // TODO: Test the stash command +} + +func TestCommand_Invalid(t *testing.T) { + // TODO: Test the invalid command } diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 25aa933..6658417 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -380,10 +380,6 @@ func (w *World) Enqueue(rover string, commands ...Command) error { // First validate the commands for _, c := range commands { switch c.Command { - case roveapi.CommandType_move: - if c.Bearing == roveapi.Bearing_BearingUnknown { - return fmt.Errorf("bearing must be valid") - } case roveapi.CommandType_broadcast: if len(c.Message) > 3 { return fmt.Errorf("too many characters in message (limit 3): %d", len(c.Message)) @@ -393,9 +389,9 @@ func (w *World) Enqueue(rover string, commands ...Command) error { return fmt.Errorf("invalid message character: %c", b) } } + case roveapi.CommandType_toggle: case roveapi.CommandType_stash: case roveapi.CommandType_repair: - case roveapi.CommandType_recharge: // Nothing to verify default: return fmt.Errorf("unknown command: %s", c.Command) @@ -459,10 +455,8 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { log.Printf("Executing command: %+v for %s\n", *c, rover) switch c.Command { - case roveapi.CommandType_move: - if _, err := w.MoveRover(rover, c.Bearing); err != nil { - return err - } + case roveapi.CommandType_toggle: + // TODO: Toggle the sails case roveapi.CommandType_stash: if _, err := w.RoverStash(rover); err != nil { @@ -481,15 +475,12 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { r.AddLogEntryf("repaired self to %d", r.Integrity) w.Rovers[rover] = r } - case roveapi.CommandType_recharge: - _, err := w.RoverRecharge(rover) - if err != nil { - return err - } + case roveapi.CommandType_broadcast: if err := w.RoverBroadcast(rover, c.Message); err != nil { return err } + default: return fmt.Errorf("unknown command: %s", c.Command) } diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index 783325f..3bd9665 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -39,35 +39,31 @@ type CommandType int32 const ( CommandType_none CommandType = 0 - // Move the rover in a direction, requires bearing - CommandType_move CommandType = 1 + // Toggles the sails, either catching the wind, or charging from the sun + CommandType_toggle CommandType = 1 // Stashes item at current location in rover inventory CommandType_stash CommandType = 2 // Repairs the rover using an inventory object CommandType_repair CommandType = 3 - // Waits a tick to add more charge to the rover - CommandType_recharge CommandType = 4 // Broadcasts a message to nearby rovers - CommandType_broadcast CommandType = 5 + CommandType_broadcast CommandType = 4 ) // Enum value maps for CommandType. var ( CommandType_name = map[int32]string{ 0: "none", - 1: "move", + 1: "toggle", 2: "stash", 3: "repair", - 4: "recharge", - 5: "broadcast", + 4: "broadcast", } CommandType_value = map[string]int32{ "none": 0, - "move": 1, + "toggle": 1, "stash": 2, "repair": 3, - "recharge": 4, - "broadcast": 5, + "broadcast": 4, } ) @@ -560,7 +556,6 @@ type Command struct { // The command type Command CommandType `protobuf:"varint,1,opt,name=command,proto3,enum=roveapi.CommandType" json:"command,omitempty"` // Types that are assignable to Data: - // *Command_Bearing // *Command_Message Data isCommand_Data `protobuf_oneof:"data"` } @@ -611,13 +606,6 @@ func (m *Command) GetData() isCommand_Data { return nil } -func (x *Command) GetBearing() Bearing { - if x, ok := x.GetData().(*Command_Bearing); ok { - return x.Bearing - } - return Bearing_BearingUnknown -} - func (x *Command) GetMessage() []byte { if x, ok := x.GetData().(*Command_Message); ok { return x.Message @@ -629,21 +617,13 @@ type isCommand_Data interface { isCommand_Data() } -type Command_Bearing struct { - // A bearing - // Used with MOVE - Bearing Bearing `protobuf:"varint,2,opt,name=bearing,proto3,enum=roveapi.Bearing,oneof"` -} - type Command_Message struct { // A simple message, must be composed of printable ASCII glyphs (32-126) // maximum of three characters // Used with BROADCAST - Message []byte `protobuf:"bytes,3,opt,name=message,proto3,oneof"` + Message []byte `protobuf:"bytes,2,opt,name=message,proto3,oneof"` } -func (*Command_Bearing) isCommand_Data() {} - func (*Command_Message) isCommand_Data() {} // CommandRequest describes a set of commands to be requested for the rover @@ -1197,116 +1177,112 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x8b, 0x01, 0x0a, 0x07, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2c, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x48, 0x00, 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, - 0x69, 0x6e, 0x67, 0x12, 0x1a, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, - 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x6a, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, - 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, - 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x22, 0x75, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x74, 0x69, 0x6c, - 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, - 0x70, 0x69, 0x2e, 0x54, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x29, - 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0e, 0x32, - 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, - 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, + 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x5d, 0x0a, 0x07, 0x43, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1a, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x6a, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, 0x0a, - 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, - 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, - 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, - 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xc3, 0x03, 0x0a, 0x0e, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x56, - 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, - 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, - 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, - 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, - 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, - 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, - 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, - 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, - 0x72, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, - 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, - 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, - 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x3c, 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, - 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x38, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, - 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, - 0x20, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, - 0x73, 0x2a, 0x55, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, - 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x6d, 0x6f, - 0x76, 0x65, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x02, 0x12, - 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x72, - 0x65, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, - 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x05, 0x2a, 0x47, 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, - 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, - 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, - 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, - 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, 0x73, 0x74, 0x10, - 0x04, 0x2a, 0x5a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, - 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x10, 0x0a, - 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, 0x02, 0x12, - 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, 0x12, 0x0d, - 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x2a, 0x37, 0x0a, - 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, - 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, - 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, - 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, - 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, - 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, - 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, - 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, - 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x22, 0x75, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x74, 0x69, + 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x61, 0x70, 0x69, 0x2e, 0x54, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, + 0x29, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0e, + 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, + 0x74, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, + 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, + 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, + 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, + 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, + 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xc3, 0x03, 0x0a, + 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, + 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, + 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, + 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, + 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, + 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, + 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, + 0x61, 0x72, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, + 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, + 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, + 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x3c, 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6f, + 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0a, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x38, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, + 0x12, 0x20, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, + 0x67, 0x73, 0x2a, 0x49, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x74, + 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, + 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x03, 0x12, 0x0d, + 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x04, 0x2a, 0x47, 0x0a, + 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, 0x72, + 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, + 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, + 0x02, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, + 0x57, 0x65, 0x73, 0x74, 0x10, 0x04, 0x2a, 0x5a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x12, 0x11, 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, + 0x6e, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, + 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, + 0x6e, 0x74, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, + 0x6c, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, + 0x10, 0x04, 0x2a, 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, + 0x6c, 0x65, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, + 0x6f, 0x63, 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, + 0x02, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x32, 0xcf, 0x02, 0x0a, 0x04, + 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, + 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, + 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, + 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, + 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1346,32 +1322,31 @@ var file_roveapi_roveapi_proto_goTypes = []interface{}{ var file_roveapi_roveapi_proto_depIdxs = []int32{ 7, // 0: roveapi.RegisterResponse.account:type_name -> roveapi.Account 0, // 1: roveapi.Command.command:type_name -> roveapi.CommandType - 1, // 2: roveapi.Command.bearing:type_name -> roveapi.Bearing - 7, // 3: roveapi.CommandRequest.account:type_name -> roveapi.Account - 9, // 4: roveapi.CommandRequest.commands:type_name -> roveapi.Command - 7, // 5: roveapi.RadarRequest.account:type_name -> roveapi.Account - 3, // 6: roveapi.RadarResponse.tiles:type_name -> roveapi.Tile - 2, // 7: roveapi.RadarResponse.objects:type_name -> roveapi.Object - 7, // 8: roveapi.StatusRequest.account:type_name -> roveapi.Account - 16, // 9: roveapi.StatusResponse.position:type_name -> roveapi.Vector - 9, // 10: roveapi.StatusResponse.incomingCommands:type_name -> roveapi.Command - 9, // 11: roveapi.StatusResponse.queuedCommands:type_name -> roveapi.Command - 15, // 12: roveapi.StatusResponse.logs:type_name -> roveapi.Log - 4, // 13: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest - 6, // 14: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest - 10, // 15: roveapi.Rove.Command:input_type -> roveapi.CommandRequest - 12, // 16: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest - 14, // 17: roveapi.Rove.Status:input_type -> roveapi.StatusRequest - 5, // 18: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse - 8, // 19: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse - 11, // 20: roveapi.Rove.Command:output_type -> roveapi.CommandResponse - 13, // 21: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse - 17, // 22: roveapi.Rove.Status:output_type -> roveapi.StatusResponse - 18, // [18:23] is the sub-list for method output_type - 13, // [13:18] is the sub-list for method input_type - 13, // [13:13] is the sub-list for extension type_name - 13, // [13:13] is the sub-list for extension extendee - 0, // [0:13] is the sub-list for field type_name + 7, // 2: roveapi.CommandRequest.account:type_name -> roveapi.Account + 9, // 3: roveapi.CommandRequest.commands:type_name -> roveapi.Command + 7, // 4: roveapi.RadarRequest.account:type_name -> roveapi.Account + 3, // 5: roveapi.RadarResponse.tiles:type_name -> roveapi.Tile + 2, // 6: roveapi.RadarResponse.objects:type_name -> roveapi.Object + 7, // 7: roveapi.StatusRequest.account:type_name -> roveapi.Account + 16, // 8: roveapi.StatusResponse.position:type_name -> roveapi.Vector + 9, // 9: roveapi.StatusResponse.incomingCommands:type_name -> roveapi.Command + 9, // 10: roveapi.StatusResponse.queuedCommands:type_name -> roveapi.Command + 15, // 11: roveapi.StatusResponse.logs:type_name -> roveapi.Log + 4, // 12: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest + 6, // 13: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest + 10, // 14: roveapi.Rove.Command:input_type -> roveapi.CommandRequest + 12, // 15: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest + 14, // 16: roveapi.Rove.Status:input_type -> roveapi.StatusRequest + 5, // 17: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse + 8, // 18: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse + 11, // 19: roveapi.Rove.Command:output_type -> roveapi.CommandResponse + 13, // 20: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse + 17, // 21: roveapi.Rove.Status:output_type -> roveapi.StatusResponse + 17, // [17:22] is the sub-list for method output_type + 12, // [12:17] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name } func init() { file_roveapi_roveapi_proto_init() } @@ -1550,7 +1525,6 @@ func file_roveapi_roveapi_proto_init() { } } file_roveapi_roveapi_proto_msgTypes[5].OneofWrappers = []interface{}{ - (*Command_Bearing)(nil), (*Command_Message)(nil), } type x struct{} diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index 566bcfd..96c4609 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -89,16 +89,14 @@ message RegisterResponse { // CommandType defines the type of a command to give to the rover enum CommandType { none = 0; - // Move the rover in a direction, requires bearing - move = 1; + // Toggles the sails, either catching the wind, or charging from the sun + toggle = 1; // Stashes item at current location in rover inventory stash = 2; // Repairs the rover using an inventory object repair = 3; - // Waits a tick to add more charge to the rover - recharge = 4; // Broadcasts a message to nearby rovers - broadcast = 5; + broadcast = 4; } enum Bearing { @@ -116,14 +114,10 @@ message Command { CommandType command = 1; oneof data { - // A bearing - // Used with MOVE - Bearing bearing = 2; - // A simple message, must be composed of printable ASCII glyphs (32-126) // maximum of three characters // Used with BROADCAST - bytes message = 3; + bytes message = 2; } } From 6f30b665c746a87ac7a796e2938e1776263aee3d Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 21 Jul 2020 22:58:59 +0100 Subject: [PATCH 158/228] Make the bearings 8 directional --- proto/roveapi/roveapi.pb.go | 113 +++++++++++++++++++++--------------- proto/roveapi/roveapi.proto | 11 +++- 2 files changed, 73 insertions(+), 51 deletions(-) diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index 3bd9665..9717407 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -94,15 +94,20 @@ func (CommandType) EnumDescriptor() ([]byte, []int) { return file_roveapi_roveapi_proto_rawDescGZIP(), []int{0} } +// Bearing represents a compass direction type Bearing int32 const ( // BearingUnknown an unknown invalid bearing Bearing_BearingUnknown Bearing = 0 Bearing_North Bearing = 1 - Bearing_East Bearing = 2 - Bearing_South Bearing = 3 - Bearing_West Bearing = 4 + Bearing_NorthEast Bearing = 2 + Bearing_East Bearing = 3 + Bearing_SouthEast Bearing = 4 + Bearing_South Bearing = 5 + Bearing_SouthWest Bearing = 6 + Bearing_West Bearing = 7 + Bearing_NorthWest Bearing = 8 ) // Enum value maps for Bearing. @@ -110,16 +115,24 @@ var ( Bearing_name = map[int32]string{ 0: "BearingUnknown", 1: "North", - 2: "East", - 3: "South", - 4: "West", + 2: "NorthEast", + 3: "East", + 4: "SouthEast", + 5: "South", + 6: "SouthWest", + 7: "West", + 8: "NorthWest", } Bearing_value = map[string]int32{ "BearingUnknown": 0, "North": 1, - "East": 2, - "South": 3, - "West": 4, + "NorthEast": 2, + "East": 3, + "SouthEast": 4, + "South": 5, + "SouthWest": 6, + "West": 7, + "NorthWest": 8, } ) @@ -1244,45 +1257,49 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x03, 0x12, 0x0d, - 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x04, 0x2a, 0x47, 0x0a, - 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, 0x72, - 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, - 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, - 0x02, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, - 0x57, 0x65, 0x73, 0x74, 0x10, 0x04, 0x2a, 0x5a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, - 0x12, 0x11, 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, - 0x6e, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, - 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, - 0x6e, 0x74, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, - 0x6c, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, - 0x10, 0x04, 0x2a, 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, - 0x6c, 0x65, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, - 0x6f, 0x63, 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, - 0x02, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x32, 0xcf, 0x02, 0x0a, 0x04, - 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, - 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, - 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, - 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, - 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, - 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x04, 0x2a, 0x83, 0x01, + 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, + 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, + 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, + 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, + 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x04, + 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x53, + 0x6f, 0x75, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, + 0x73, 0x74, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, 0x73, + 0x74, 0x10, 0x08, 0x2a, 0x5a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, + 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, + 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, + 0x10, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, + 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, + 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x2a, + 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, + 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, + 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, + 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, + 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x1d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, + 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, + 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, + 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, + 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, + 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index 96c4609..033fcf3 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -99,13 +99,18 @@ enum CommandType { broadcast = 4; } +// Bearing represents a compass direction enum Bearing { // BearingUnknown an unknown invalid bearing BearingUnknown = 0; North = 1; - East = 2; - South = 3; - West = 4; + NorthEast = 2; + East = 3; + SouthEast = 4; + South = 5; + SouthWest = 6; + West = 7; + NorthWest = 8; } // Command is a single command for a rover From f78efd122384aea4da96915897ac466a8942017b Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 21 Jul 2020 23:12:50 +0100 Subject: [PATCH 159/228] Add SailPosition to the rover and implement toggle command This also converts the commands to use the proto type for simplicity --- cmd/rove-server/internal/routes.go | 45 +-- cmd/rove/main.go | 25 +- pkg/maths/vector.go | 8 + pkg/rove/command.go | 14 - pkg/rove/command_test.go | 43 ++- pkg/rove/rover.go | 11 +- pkg/rove/world.go | 92 +++++- pkg/rove/world_test.go | 4 +- proto/roveapi/roveapi.pb.go | 462 ++++++++++++++++++----------- proto/roveapi/roveapi.proto | 53 +++- 10 files changed, 490 insertions(+), 267 deletions(-) delete mode 100644 pkg/rove/command.go diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 393bf93..19a5fef 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -5,7 +5,6 @@ import ( "fmt" "log" - "github.com/mdiluz/rove/pkg/rove" "github.com/mdiluz/rove/pkg/version" "github.com/mdiluz/rove/proto/roveapi" ) @@ -76,31 +75,13 @@ func (s *Server) Status(ctx context.Context, req *roveapi.StatusRequest) (respon inv = append(inv, byte(i.Type)) } - i, q := s.world.RoverCommands(resp) + in, qu := s.world.RoverCommands(resp) var incoming, queued []*roveapi.Command - for _, i := range i { - c := &roveapi.Command{ - Command: i.Command, - } - switch i.Command { - case roveapi.CommandType_broadcast: - c.Data = &roveapi.Command_Message{ - Message: i.Message, - } - } - incoming = append(incoming, c) + for i := range in { + incoming = append(incoming, &in[i]) } - for _, q := range q { - c := &roveapi.Command{ - Command: q.Command, - } - switch q.Command { - case roveapi.CommandType_broadcast: - c.Data = &roveapi.Command_Message{ - Message: q.Message, - } - } - queued = append(queued, c) + for i := range qu { + queued = append(queued, &qu[i]) } var logs []*roveapi.Log for _, log := range rover.Logs { @@ -116,6 +97,7 @@ func (s *Server) Status(ctx context.Context, req *roveapi.StatusRequest) (respon X: int32(rover.Pos.X), Y: int32(rover.Pos.Y), }, + Bearing: rover.Bearing, Range: int32(rover.Range), Inventory: inv, Capacity: int32(rover.Capacity), @@ -125,6 +107,7 @@ func (s *Server) Status(ctx context.Context, req *roveapi.StatusRequest) (respon MaximumCharge: int32(rover.MaximumCharge), IncomingCommands: incoming, QueuedCommands: queued, + SailPosition: rover.SailPosition, Logs: logs, } } @@ -179,19 +162,7 @@ func (s *Server) Command(ctx context.Context, req *roveapi.CommandRequest) (*rov return nil, err } - var cmds []rove.Command - for _, c := range req.Commands { - n := rove.Command{ - Command: c.Command, - } - switch c.Command { - case roveapi.CommandType_broadcast: - n.Message = c.GetMessage() - } - cmds = append(cmds, n) - } - - if err := s.world.Enqueue(resp, cmds...); err != nil { + if err := s.world.Enqueue(resp, req.Commands...); err != nil { return nil, err } diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 8d94106..51038a7 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -127,12 +127,20 @@ func BearingFromString(s string) roveapi.Bearing { switch s { case "N": return roveapi.Bearing_North + case "NE": + return roveapi.Bearing_NorthEast case "E": return roveapi.Bearing_East + case "SE": + return roveapi.Bearing_SouthEast case "S": return roveapi.Bearing_South + case "SW": + return roveapi.Bearing_SouthWest case "W": return roveapi.Bearing_West + case "NW": + return roveapi.Bearing_NorthWest } return roveapi.Bearing_BearingUnknown } @@ -224,6 +232,21 @@ func InnerMain(command string, args ...string) error { var commands []*roveapi.Command for i := 0; i < len(args); i++ { switch args[i] { + case "turn": + i++ + if len(args) == i { + return fmt.Errorf("turn command must be passed a compass bearing") + } + b := BearingFromString(args[i]) + if b == roveapi.Bearing_BearingUnknown { + return fmt.Errorf("turn command must be given a valid bearing %s", args[i]) + } + commands = append(commands, + &roveapi.Command{ + Command: roveapi.CommandType_broadcast, + Data: &roveapi.Command_Broadcast{Broadcast: []byte(args[i])}, + }, + ) case "broadcast": i++ if len(args) == i { @@ -234,7 +257,7 @@ func InnerMain(command string, args ...string) error { commands = append(commands, &roveapi.Command{ Command: roveapi.CommandType_broadcast, - Data: &roveapi.Command_Message{Message: []byte(args[i])}, + Data: &roveapi.Command_Broadcast{Broadcast: []byte(args[i])}, }, ) default: diff --git a/pkg/maths/vector.go b/pkg/maths/vector.go index 8a63708..92305cc 100644 --- a/pkg/maths/vector.go +++ b/pkg/maths/vector.go @@ -89,12 +89,20 @@ func BearingToVector(b roveapi.Bearing) Vector { switch b { case roveapi.Bearing_North: return Vector{Y: 1} + case roveapi.Bearing_NorthEast: + return Vector{X: 1, Y: 1} case roveapi.Bearing_East: return Vector{X: 1} + case roveapi.Bearing_SouthEast: + return Vector{X: 1, Y: -1} case roveapi.Bearing_South: return Vector{Y: -1} + case roveapi.Bearing_SouthWest: + return Vector{X: -1, Y: -1} case roveapi.Bearing_West: return Vector{X: -1} + case roveapi.Bearing_NorthWest: + return Vector{X: -1, Y: 1} } return Vector{} diff --git a/pkg/rove/command.go b/pkg/rove/command.go deleted file mode 100644 index df49bea..0000000 --- a/pkg/rove/command.go +++ /dev/null @@ -1,14 +0,0 @@ -package rove - -import "github.com/mdiluz/rove/proto/roveapi" - -// Command represends a single command to execute -type Command struct { - Command roveapi.CommandType `json:"command"` - - // Used in the broadcast command - Message []byte `json:"message,omitempty"` -} - -// CommandStream is a list of commands to execute in order -type CommandStream []Command diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index 7506cd6..c7990d1 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -2,14 +2,49 @@ package rove import ( "testing" + + "github.com/mdiluz/rove/proto/roveapi" + "github.com/stretchr/testify/assert" ) -func TestCommand_Raise(t *testing.T) { - // TODO: Test the raise command +func TestCommand_Toggle(t *testing.T) { + w := NewWorld(8) + a, err := w.SpawnRover() + assert.NoError(t, err) + + r, err := w.GetRover(a) + assert.NoError(t, err) + assert.Equal(t, roveapi.SailPosition_SolarCharging, r.SailPosition) + + w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_toggle}) + w.EnqueueAllIncoming() + w.ExecuteCommandQueues() + + r, err = w.GetRover(a) + assert.NoError(t, err) + assert.Equal(t, roveapi.SailPosition_CatchingWind, r.SailPosition) + + w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_toggle}) + w.EnqueueAllIncoming() + w.ExecuteCommandQueues() + + r, err = w.GetRover(a) + assert.NoError(t, err) + assert.Equal(t, roveapi.SailPosition_SolarCharging, r.SailPosition) } -func TestCommand_Lower(t *testing.T) { - // TODO: Test the lower command +func TestCommand_Turn(t *testing.T) { + w := NewWorld(8) + a, err := w.SpawnRover() + assert.NoError(t, err) + + w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_turn, Data: &roveapi.Command_Turn{Turn: roveapi.Bearing_NorthWest}}) + w.EnqueueAllIncoming() + w.ExecuteCommandQueues() + + r, err := w.GetRover(a) + assert.NoError(t, err) + assert.Equal(t, roveapi.Bearing_NorthWest, r.Bearing) } func TestCommand_Stash(t *testing.T) { diff --git a/pkg/rove/rover.go b/pkg/rove/rover.go index 6968c57..36b875f 100644 --- a/pkg/rove/rover.go +++ b/pkg/rove/rover.go @@ -10,6 +10,7 @@ import ( "github.com/google/uuid" "github.com/mdiluz/rove/pkg/maths" + "github.com/mdiluz/rove/proto/roveapi" ) // RoverLogEntry describes a single log entry for the rover @@ -29,6 +30,9 @@ type Rover struct { // Pos represents where this rover is in the world Pos maths.Vector `json:"pos"` + // Bearing is the current direction the rover is facing + Bearing roveapi.Bearing `json:"bearing"` + // Range represents the distance the unit's radar can see Range int `json:"range"` @@ -48,7 +52,10 @@ type Rover struct { Charge int `json:"charge"` // MaximumCharge is the maximum charge able to be stored - MaximumCharge int `json:"maximum-Charge"` + MaximumCharge int `json:"maximum-charge"` + + // SailPosition is the current position of the sails + SailPosition roveapi.SailPosition `json:"sail-position"` // Logs Stores log of information Logs []RoverLogEntry `json:"logs"` @@ -63,6 +70,8 @@ func DefaultRover() Rover { Capacity: 10, Charge: 10, MaximumCharge: 10, + Bearing: roveapi.Bearing_North, + SailPosition: roveapi.SailPosition_SolarCharging, Name: GenerateRoverName(), } } diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 6658417..43fbe83 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -10,6 +10,9 @@ import ( "github.com/mdiluz/rove/proto/roveapi" ) +// CommandStream is a list of commands to execute in order +type CommandStream []roveapi.Command + // World describes a self contained universe and everything in it type World struct { // TicksPerDay is the amount of ticks in a single day @@ -305,6 +308,45 @@ func (w *World) RoverStash(rover string) (roveapi.Object, error) { return obj.Type, nil } +// RoverToggle will toggle the sail position +func (w *World) RoverToggle(rover string) (roveapi.SailPosition, error) { + w.worldMutex.Lock() + defer w.worldMutex.Unlock() + + r, ok := w.Rovers[rover] + if !ok { + return roveapi.SailPosition_UnknownSailPosition, fmt.Errorf("no rover matching id") + } + + // Swap the sail position + switch r.SailPosition { + case roveapi.SailPosition_CatchingWind: + r.SailPosition = roveapi.SailPosition_SolarCharging + case roveapi.SailPosition_SolarCharging: + r.SailPosition = roveapi.SailPosition_CatchingWind + } + + w.Rovers[rover] = r + return r.SailPosition, nil +} + +// RoverTurn will turn the rover +func (w *World) RoverTurn(rover string, bearing roveapi.Bearing) (roveapi.Bearing, error) { + w.worldMutex.Lock() + defer w.worldMutex.Unlock() + + r, ok := w.Rovers[rover] + if !ok { + return roveapi.Bearing_BearingUnknown, fmt.Errorf("no rover matching id") + } + + // Set the new bearing + r.Bearing = bearing + + w.Rovers[rover] = r + return r.Bearing, nil +} + // RadarFromRover can be used to query what a rover can currently see func (w *World) RadarFromRover(rover string) (radar []roveapi.Tile, objs []roveapi.Object, err error) { w.worldMutex.RLock() @@ -364,7 +406,7 @@ func (w *World) RadarFromRover(rover string) (radar []roveapi.Tile, objs []rovea } // RoverCommands returns current commands for the given rover -func (w *World) RoverCommands(rover string) (incoming []Command, queued []Command) { +func (w *World) RoverCommands(rover string) (incoming []roveapi.Command, queued []roveapi.Command) { if c, ok := w.CommandIncoming[rover]; ok { incoming = c } @@ -375,20 +417,24 @@ func (w *World) RoverCommands(rover string) (incoming []Command, queued []Comman } // Enqueue will queue the commands given -func (w *World) Enqueue(rover string, commands ...Command) error { +func (w *World) Enqueue(rover string, commands ...*roveapi.Command) error { // First validate the commands for _, c := range commands { switch c.Command { case roveapi.CommandType_broadcast: - if len(c.Message) > 3 { - return fmt.Errorf("too many characters in message (limit 3): %d", len(c.Message)) + if len(c.GetBroadcast()) > 3 { + return fmt.Errorf("too many characters in message (limit 3): %d", len(c.GetBroadcast())) } - for _, b := range c.Message { + for _, b := range c.GetBroadcast() { if b < 37 || b > 126 { return fmt.Errorf("invalid message character: %c", b) } } + case roveapi.CommandType_turn: + if c.GetTurn() == roveapi.Bearing_BearingUnknown { + return fmt.Errorf("turn command given unknown bearing") + } case roveapi.CommandType_toggle: case roveapi.CommandType_stash: case roveapi.CommandType_repair: @@ -403,7 +449,17 @@ func (w *World) Enqueue(rover string, commands ...Command) error { defer w.cmdMutex.Unlock() // Override the incoming command set - w.CommandIncoming[rover] = commands + var cmds []roveapi.Command + for _, c := range commands { + // Copy the command and data but none of the locks or internals + cmds = append(cmds, + roveapi.Command{ + Command: c.Command, + Data: c.Data, + }) + } + + w.CommandIncoming[rover] = cmds return nil } @@ -427,16 +483,16 @@ func (w *World) ExecuteCommandQueues() { // Iterate through all the current commands for rover, cmds := range w.CommandQueue { if len(cmds) != 0 { - // Extract the first command in the queue - c := cmds[0] - w.CommandQueue[rover] = cmds[1:] // Execute the command - if err := w.ExecuteCommand(&c, rover); err != nil { + if err := w.ExecuteCommand(&cmds[0], rover); err != nil { log.Println(err) // TODO: Report this error somehow } + // Extract the first command in the queue + w.CommandQueue[rover] = cmds[1:] + } else { // Clean out the empty entry delete(w.CommandQueue, rover) @@ -451,13 +507,14 @@ func (w *World) ExecuteCommandQueues() { } // ExecuteCommand will execute a single command -func (w *World) ExecuteCommand(c *Command, rover string) (err error) { - log.Printf("Executing command: %+v for %s\n", *c, rover) +func (w *World) ExecuteCommand(c *roveapi.Command, rover string) (err error) { + log.Printf("Executing command: %+v for %s\n", c.Command, rover) switch c.Command { case roveapi.CommandType_toggle: - // TODO: Toggle the sails - + if _, err := w.RoverToggle(rover); err != nil { + return err + } case roveapi.CommandType_stash: if _, err := w.RoverStash(rover); err != nil { return err @@ -477,7 +534,12 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { } case roveapi.CommandType_broadcast: - if err := w.RoverBroadcast(rover, c.Message); err != nil { + if err := w.RoverBroadcast(rover, c.GetBroadcast()); err != nil { + return err + } + + case roveapi.CommandType_turn: + if _, err := w.RoverTurn(rover, c.GetTurn()); err != nil { return err } diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index f393f3d..ffac1af 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -269,7 +269,7 @@ func TestWorld_RoverRepair(t *testing.T) { assert.NoError(t, err, "couldn't get rover info") assert.Equal(t, originalInfo.Integrity-1, newinfo.Integrity, "rover should have lost integrity") - err = world.ExecuteCommand(&Command{Command: roveapi.CommandType_repair}, a) + err = world.ExecuteCommand(&roveapi.Command{Command: roveapi.CommandType_repair}, a) assert.NoError(t, err, "Failed to repair rover") newinfo, err = world.GetRover(a) @@ -283,7 +283,7 @@ func TestWorld_RoverRepair(t *testing.T) { assert.NoError(t, err, "Failed to stash") assert.Equal(t, roveapi.Object_RockSmall, o, "Failed to get correct object") - err = world.ExecuteCommand(&Command{Command: roveapi.CommandType_repair}, a) + err = world.ExecuteCommand(&roveapi.Command{Command: roveapi.CommandType_repair}, a) assert.NoError(t, err, "Failed to repair rover") newinfo, err = world.GetRover(a) diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index 9717407..cee8615 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -41,12 +41,14 @@ const ( CommandType_none CommandType = 0 // Toggles the sails, either catching the wind, or charging from the sun CommandType_toggle CommandType = 1 + // Turns the rover in the specified bearing, requires data + CommandType_turn CommandType = 2 // Stashes item at current location in rover inventory - CommandType_stash CommandType = 2 + CommandType_stash CommandType = 3 // Repairs the rover using an inventory object - CommandType_repair CommandType = 3 - // Broadcasts a message to nearby rovers - CommandType_broadcast CommandType = 4 + CommandType_repair CommandType = 4 + // Broadcasts a message to nearby rovers, requires data + CommandType_broadcast CommandType = 5 ) // Enum value maps for CommandType. @@ -54,16 +56,18 @@ var ( CommandType_name = map[int32]string{ 0: "none", 1: "toggle", - 2: "stash", - 3: "repair", - 4: "broadcast", + 2: "turn", + 3: "stash", + 4: "repair", + 5: "broadcast", } CommandType_value = map[string]int32{ "none": 0, "toggle": 1, - "stash": 2, - "repair": 3, - "broadcast": 4, + "turn": 2, + "stash": 3, + "repair": 4, + "broadcast": 5, } ) @@ -280,6 +284,58 @@ func (Tile) EnumDescriptor() ([]byte, []int) { return file_roveapi_roveapi_proto_rawDescGZIP(), []int{3} } +// SailPosition represents the position of the sola sail +type SailPosition int32 + +const ( + SailPosition_UnknownSailPosition SailPosition = 0 + // CatchingWind means the sail is catching the wind and moving the rover + SailPosition_CatchingWind SailPosition = 1 + // SolarCharging means the sail is facing the sun and charging + SailPosition_SolarCharging SailPosition = 2 +) + +// Enum value maps for SailPosition. +var ( + SailPosition_name = map[int32]string{ + 0: "UnknownSailPosition", + 1: "CatchingWind", + 2: "SolarCharging", + } + SailPosition_value = map[string]int32{ + "UnknownSailPosition": 0, + "CatchingWind": 1, + "SolarCharging": 2, + } +) + +func (x SailPosition) Enum() *SailPosition { + p := new(SailPosition) + *p = x + return p +} + +func (x SailPosition) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (SailPosition) Descriptor() protoreflect.EnumDescriptor { + return file_roveapi_roveapi_proto_enumTypes[4].Descriptor() +} + +func (SailPosition) Type() protoreflect.EnumType { + return &file_roveapi_roveapi_proto_enumTypes[4] +} + +func (x SailPosition) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use SailPosition.Descriptor instead. +func (SailPosition) EnumDescriptor() ([]byte, []int) { + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{4} +} + // ServerStatusRequest is an empty placeholder type ServerStatusRequest struct { state protoimpl.MessageState @@ -569,7 +625,8 @@ type Command struct { // The command type Command CommandType `protobuf:"varint,1,opt,name=command,proto3,enum=roveapi.CommandType" json:"command,omitempty"` // Types that are assignable to Data: - // *Command_Message + // *Command_Broadcast + // *Command_Turn Data isCommand_Data `protobuf_oneof:"data"` } @@ -619,25 +676,38 @@ func (m *Command) GetData() isCommand_Data { return nil } -func (x *Command) GetMessage() []byte { - if x, ok := x.GetData().(*Command_Message); ok { - return x.Message +func (x *Command) GetBroadcast() []byte { + if x, ok := x.GetData().(*Command_Broadcast); ok { + return x.Broadcast } return nil } +func (x *Command) GetTurn() Bearing { + if x, ok := x.GetData().(*Command_Turn); ok { + return x.Turn + } + return Bearing_BearingUnknown +} + type isCommand_Data interface { isCommand_Data() } -type Command_Message struct { +type Command_Broadcast struct { // A simple message, must be composed of printable ASCII glyphs (32-126) // maximum of three characters - // Used with BROADCAST - Message []byte `protobuf:"bytes,2,opt,name=message,proto3,oneof"` + Broadcast []byte `protobuf:"bytes,2,opt,name=broadcast,proto3,oneof"` } -func (*Command_Message) isCommand_Data() {} +type Command_Turn struct { + // The bearing for the rover to turn to + Turn Bearing `protobuf:"varint,3,opt,name=turn,proto3,enum=roveapi.Bearing,oneof"` +} + +func (*Command_Broadcast) isCommand_Data() {} + +func (*Command_Turn) isCommand_Data() {} // CommandRequest describes a set of commands to be requested for the rover type CommandRequest struct { @@ -1026,26 +1096,30 @@ type StatusResponse struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // Position of the rover in world coordinates Position *Vector `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` + // The current direction of the rover + Bearing Bearing `protobuf:"varint,3,opt,name=bearing,proto3,enum=roveapi.Bearing" json:"bearing,omitempty"` // The range of this rover's radar and broadcasting - Range int32 `protobuf:"varint,3,opt,name=range,proto3" json:"range,omitempty"` + Range int32 `protobuf:"varint,4,opt,name=range,proto3" json:"range,omitempty"` // The items in the rover inventory - Inventory []byte `protobuf:"bytes,4,opt,name=inventory,proto3" json:"inventory,omitempty"` + Inventory []byte `protobuf:"bytes,5,opt,name=inventory,proto3" json:"inventory,omitempty"` // The capacity of the inventory - Capacity int32 `protobuf:"varint,5,opt,name=capacity,proto3" json:"capacity,omitempty"` + Capacity int32 `protobuf:"varint,6,opt,name=capacity,proto3" json:"capacity,omitempty"` // The current health of the rover - Integrity int32 `protobuf:"varint,6,opt,name=integrity,proto3" json:"integrity,omitempty"` + Integrity int32 `protobuf:"varint,7,opt,name=integrity,proto3" json:"integrity,omitempty"` // The maximum health of the rover - MaximumIntegrity int32 `protobuf:"varint,7,opt,name=maximumIntegrity,proto3" json:"maximumIntegrity,omitempty"` + MaximumIntegrity int32 `protobuf:"varint,8,opt,name=maximumIntegrity,proto3" json:"maximumIntegrity,omitempty"` // The energy stored in the rover - Charge int32 `protobuf:"varint,8,opt,name=charge,proto3" json:"charge,omitempty"` + Charge int32 `protobuf:"varint,9,opt,name=charge,proto3" json:"charge,omitempty"` // The max energy the rover can store - MaximumCharge int32 `protobuf:"varint,9,opt,name=maximumCharge,proto3" json:"maximumCharge,omitempty"` + MaximumCharge int32 `protobuf:"varint,10,opt,name=maximumCharge,proto3" json:"maximumCharge,omitempty"` + // The current position of the sails + SailPosition SailPosition `protobuf:"varint,11,opt,name=sailPosition,proto3,enum=roveapi.SailPosition" json:"sailPosition,omitempty"` // The set of currently incoming commands for this tick - IncomingCommands []*Command `protobuf:"bytes,10,rep,name=incomingCommands,proto3" json:"incomingCommands,omitempty"` + IncomingCommands []*Command `protobuf:"bytes,12,rep,name=incomingCommands,proto3" json:"incomingCommands,omitempty"` // The set of currently queued commands - QueuedCommands []*Command `protobuf:"bytes,11,rep,name=queuedCommands,proto3" json:"queuedCommands,omitempty"` + QueuedCommands []*Command `protobuf:"bytes,13,rep,name=queuedCommands,proto3" json:"queuedCommands,omitempty"` // The most recent logs - Logs []*Log `protobuf:"bytes,12,rep,name=logs,proto3" json:"logs,omitempty"` + Logs []*Log `protobuf:"bytes,14,rep,name=logs,proto3" json:"logs,omitempty"` } func (x *StatusResponse) Reset() { @@ -1094,6 +1168,13 @@ func (x *StatusResponse) GetPosition() *Vector { return nil } +func (x *StatusResponse) GetBearing() Bearing { + if x != nil { + return x.Bearing + } + return Bearing_BearingUnknown +} + func (x *StatusResponse) GetRange() int32 { if x != nil { return x.Range @@ -1143,6 +1224,13 @@ func (x *StatusResponse) GetMaximumCharge() int32 { return 0 } +func (x *StatusResponse) GetSailPosition() SailPosition { + if x != nil { + return x.SailPosition + } + return SailPosition_UnknownSailPosition +} + func (x *StatusResponse) GetIncomingCommands() []*Command { if x != nil { return x.IncomingCommands @@ -1190,116 +1278,131 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x5d, 0x0a, 0x07, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1a, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x6a, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, - 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, + 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x89, 0x01, 0x0a, 0x07, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1e, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, + 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x09, 0x62, 0x72, 0x6f, 0x61, + 0x64, 0x63, 0x61, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, + 0x61, 0x72, 0x69, 0x6e, 0x67, 0x48, 0x00, 0x52, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x42, 0x06, 0x0a, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x6a, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x22, 0x75, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x74, 0x69, - 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x61, 0x70, 0x69, 0x2e, 0x54, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, - 0x29, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0e, - 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, - 0x74, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, - 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, - 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, - 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, - 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, - 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xc3, 0x03, 0x0a, - 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, - 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, - 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, - 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, - 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, - 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, - 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, - 0x61, 0x72, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, - 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, - 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, - 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x3c, 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6f, - 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0a, 0x20, 0x03, + 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x22, 0x75, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x54, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x29, 0x0a, 0x07, + 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0f, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, + 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, + 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, + 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, + 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xaa, 0x04, 0x0a, 0x0e, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x56, 0x65, 0x63, + 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, + 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, + 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, + 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, + 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, + 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, + 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, + 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, + 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, + 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, + 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x0a, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, + 0x65, 0x12, 0x39, 0x0a, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, + 0x69, 0x2e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, + 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3c, 0x0a, 0x10, + 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, + 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, + 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x38, 0x0a, 0x0e, 0x71, 0x75, + 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x38, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, - 0x12, 0x20, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, - 0x67, 0x73, 0x2a, 0x49, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, - 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x74, - 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, - 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x03, 0x12, 0x0d, - 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x04, 0x2a, 0x83, 0x01, - 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, - 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, - 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, - 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, - 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x04, - 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x53, - 0x6f, 0x75, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, - 0x73, 0x74, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, 0x73, - 0x74, 0x10, 0x08, 0x2a, 0x5a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, - 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, - 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, - 0x10, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, - 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, - 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x2a, - 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, - 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, - 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, - 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, - 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x1d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, - 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, - 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, - 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, - 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, - 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, - 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x73, 0x12, 0x20, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x0e, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x6f, 0x67, + 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x2a, 0x53, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, + 0x0a, 0x0a, 0x06, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x74, + 0x75, 0x72, 0x6e, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x03, + 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, + 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x05, 0x2a, 0x83, 0x01, 0x0a, 0x07, + 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, 0x72, 0x69, + 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x4e, + 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x45, + 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, 0x03, 0x12, + 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x04, 0x12, 0x09, + 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, + 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, 0x73, 0x74, + 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, + 0x08, 0x2a, 0x5a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, + 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x10, 0x0a, + 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, 0x02, 0x12, + 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, 0x12, 0x0d, + 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x2a, 0x37, 0x0a, + 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, + 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, + 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, + 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x2a, 0x4c, 0x0a, 0x0c, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x13, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, + 0x6e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x00, 0x12, + 0x10, 0x0a, 0x0c, 0x43, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x10, + 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x6f, 0x6c, 0x61, 0x72, 0x43, 0x68, 0x61, 0x72, 0x67, 0x69, + 0x6e, 0x67, 0x10, 0x02, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, + 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1314,56 +1417,60 @@ func file_roveapi_roveapi_proto_rawDescGZIP() []byte { return file_roveapi_roveapi_proto_rawDescData } -var file_roveapi_roveapi_proto_enumTypes = make([]protoimpl.EnumInfo, 4) +var file_roveapi_roveapi_proto_enumTypes = make([]protoimpl.EnumInfo, 5) var file_roveapi_roveapi_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_roveapi_roveapi_proto_goTypes = []interface{}{ (CommandType)(0), // 0: roveapi.CommandType (Bearing)(0), // 1: roveapi.Bearing (Object)(0), // 2: roveapi.Object (Tile)(0), // 3: roveapi.Tile - (*ServerStatusRequest)(nil), // 4: roveapi.ServerStatusRequest - (*ServerStatusResponse)(nil), // 5: roveapi.ServerStatusResponse - (*RegisterRequest)(nil), // 6: roveapi.RegisterRequest - (*Account)(nil), // 7: roveapi.Account - (*RegisterResponse)(nil), // 8: roveapi.RegisterResponse - (*Command)(nil), // 9: roveapi.Command - (*CommandRequest)(nil), // 10: roveapi.CommandRequest - (*CommandResponse)(nil), // 11: roveapi.CommandResponse - (*RadarRequest)(nil), // 12: roveapi.RadarRequest - (*RadarResponse)(nil), // 13: roveapi.RadarResponse - (*StatusRequest)(nil), // 14: roveapi.StatusRequest - (*Log)(nil), // 15: roveapi.Log - (*Vector)(nil), // 16: roveapi.Vector - (*StatusResponse)(nil), // 17: roveapi.StatusResponse + (SailPosition)(0), // 4: roveapi.SailPosition + (*ServerStatusRequest)(nil), // 5: roveapi.ServerStatusRequest + (*ServerStatusResponse)(nil), // 6: roveapi.ServerStatusResponse + (*RegisterRequest)(nil), // 7: roveapi.RegisterRequest + (*Account)(nil), // 8: roveapi.Account + (*RegisterResponse)(nil), // 9: roveapi.RegisterResponse + (*Command)(nil), // 10: roveapi.Command + (*CommandRequest)(nil), // 11: roveapi.CommandRequest + (*CommandResponse)(nil), // 12: roveapi.CommandResponse + (*RadarRequest)(nil), // 13: roveapi.RadarRequest + (*RadarResponse)(nil), // 14: roveapi.RadarResponse + (*StatusRequest)(nil), // 15: roveapi.StatusRequest + (*Log)(nil), // 16: roveapi.Log + (*Vector)(nil), // 17: roveapi.Vector + (*StatusResponse)(nil), // 18: roveapi.StatusResponse } var file_roveapi_roveapi_proto_depIdxs = []int32{ - 7, // 0: roveapi.RegisterResponse.account:type_name -> roveapi.Account + 8, // 0: roveapi.RegisterResponse.account:type_name -> roveapi.Account 0, // 1: roveapi.Command.command:type_name -> roveapi.CommandType - 7, // 2: roveapi.CommandRequest.account:type_name -> roveapi.Account - 9, // 3: roveapi.CommandRequest.commands:type_name -> roveapi.Command - 7, // 4: roveapi.RadarRequest.account:type_name -> roveapi.Account - 3, // 5: roveapi.RadarResponse.tiles:type_name -> roveapi.Tile - 2, // 6: roveapi.RadarResponse.objects:type_name -> roveapi.Object - 7, // 7: roveapi.StatusRequest.account:type_name -> roveapi.Account - 16, // 8: roveapi.StatusResponse.position:type_name -> roveapi.Vector - 9, // 9: roveapi.StatusResponse.incomingCommands:type_name -> roveapi.Command - 9, // 10: roveapi.StatusResponse.queuedCommands:type_name -> roveapi.Command - 15, // 11: roveapi.StatusResponse.logs:type_name -> roveapi.Log - 4, // 12: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest - 6, // 13: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest - 10, // 14: roveapi.Rove.Command:input_type -> roveapi.CommandRequest - 12, // 15: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest - 14, // 16: roveapi.Rove.Status:input_type -> roveapi.StatusRequest - 5, // 17: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse - 8, // 18: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse - 11, // 19: roveapi.Rove.Command:output_type -> roveapi.CommandResponse - 13, // 20: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse - 17, // 21: roveapi.Rove.Status:output_type -> roveapi.StatusResponse - 17, // [17:22] is the sub-list for method output_type - 12, // [12:17] is the sub-list for method input_type - 12, // [12:12] is the sub-list for extension type_name - 12, // [12:12] is the sub-list for extension extendee - 0, // [0:12] is the sub-list for field type_name + 1, // 2: roveapi.Command.turn:type_name -> roveapi.Bearing + 8, // 3: roveapi.CommandRequest.account:type_name -> roveapi.Account + 10, // 4: roveapi.CommandRequest.commands:type_name -> roveapi.Command + 8, // 5: roveapi.RadarRequest.account:type_name -> roveapi.Account + 3, // 6: roveapi.RadarResponse.tiles:type_name -> roveapi.Tile + 2, // 7: roveapi.RadarResponse.objects:type_name -> roveapi.Object + 8, // 8: roveapi.StatusRequest.account:type_name -> roveapi.Account + 17, // 9: roveapi.StatusResponse.position:type_name -> roveapi.Vector + 1, // 10: roveapi.StatusResponse.bearing:type_name -> roveapi.Bearing + 4, // 11: roveapi.StatusResponse.sailPosition:type_name -> roveapi.SailPosition + 10, // 12: roveapi.StatusResponse.incomingCommands:type_name -> roveapi.Command + 10, // 13: roveapi.StatusResponse.queuedCommands:type_name -> roveapi.Command + 16, // 14: roveapi.StatusResponse.logs:type_name -> roveapi.Log + 5, // 15: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest + 7, // 16: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest + 11, // 17: roveapi.Rove.Command:input_type -> roveapi.CommandRequest + 13, // 18: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest + 15, // 19: roveapi.Rove.Status:input_type -> roveapi.StatusRequest + 6, // 20: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse + 9, // 21: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse + 12, // 22: roveapi.Rove.Command:output_type -> roveapi.CommandResponse + 14, // 23: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse + 18, // 24: roveapi.Rove.Status:output_type -> roveapi.StatusResponse + 20, // [20:25] is the sub-list for method output_type + 15, // [15:20] is the sub-list for method input_type + 15, // [15:15] is the sub-list for extension type_name + 15, // [15:15] is the sub-list for extension extendee + 0, // [0:15] is the sub-list for field type_name } func init() { file_roveapi_roveapi_proto_init() } @@ -1542,14 +1649,15 @@ func file_roveapi_roveapi_proto_init() { } } file_roveapi_roveapi_proto_msgTypes[5].OneofWrappers = []interface{}{ - (*Command_Message)(nil), + (*Command_Broadcast)(nil), + (*Command_Turn)(nil), } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_roveapi_roveapi_proto_rawDesc, - NumEnums: 4, + NumEnums: 5, NumMessages: 14, NumExtensions: 0, NumServices: 1, diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index 033fcf3..9f13a17 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -91,12 +91,14 @@ enum CommandType { none = 0; // Toggles the sails, either catching the wind, or charging from the sun toggle = 1; + // Turns the rover in the specified bearing, requires data + turn = 2; // Stashes item at current location in rover inventory - stash = 2; + stash = 3; // Repairs the rover using an inventory object - repair = 3; - // Broadcasts a message to nearby rovers - broadcast = 4; + repair = 4; + // Broadcasts a message to nearby rovers, requires data + broadcast = 5; } // Bearing represents a compass direction @@ -121,8 +123,10 @@ message Command { oneof data { // A simple message, must be composed of printable ASCII glyphs (32-126) // maximum of three characters - // Used with BROADCAST - bytes message = 2; + bytes broadcast = 2; + + // The bearing for the rover to turn to + Bearing turn = 3; } } @@ -218,6 +222,17 @@ message Vector { int32 y = 2; } +// SailPosition represents the position of the sola sail +enum SailPosition { + UnknownSailPosition = 0; + + // CatchingWind means the sail is catching the wind and moving the rover + CatchingWind = 1; + + // SolarCharging means the sail is facing the sun and charging + SolarCharging = 2; +} + // StatusResponse is the response given to a status request message StatusResponse { // The name of the rover @@ -226,33 +241,39 @@ message StatusResponse { // Position of the rover in world coordinates Vector position = 2; + // The current direction of the rover + Bearing bearing = 3; + // The range of this rover's radar and broadcasting - int32 range = 3; + int32 range = 4; // The items in the rover inventory - bytes inventory = 4; + bytes inventory = 5; // The capacity of the inventory - int32 capacity = 5; + int32 capacity = 6; // The current health of the rover - int32 integrity = 6; + int32 integrity = 7; // The maximum health of the rover - int32 maximumIntegrity = 7; + int32 maximumIntegrity = 8; // The energy stored in the rover - int32 charge = 8; + int32 charge = 9; // The max energy the rover can store - int32 maximumCharge = 9; + int32 maximumCharge = 10; + + // The current position of the sails + SailPosition sailPosition = 11; // The set of currently incoming commands for this tick - repeated Command incomingCommands = 10; + repeated Command incomingCommands = 12; // The set of currently queued commands - repeated Command queuedCommands = 11; + repeated Command queuedCommands = 13; // The most recent logs - repeated Log logs = 12; + repeated Log logs = 14; } \ No newline at end of file From 8667f551438cc66e8aa1b1dbbe1ec7f37c0dc8ff Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 21 Jul 2020 23:52:14 +0100 Subject: [PATCH 160/228] Simplify by making command streams pointer lists like in proto --- cmd/rove-server/internal/routes.go | 9 +- cmd/rove/main.go | 8 +- pkg/rove/command_test.go | 2 +- pkg/rove/world.go | 19 +- proto/roveapi/roveapi.pb.go | 286 +++++++++++++---------------- proto/roveapi/roveapi.proto | 12 +- 6 files changed, 143 insertions(+), 193 deletions(-) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 19a5fef..02a7483 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -75,14 +75,7 @@ func (s *Server) Status(ctx context.Context, req *roveapi.StatusRequest) (respon inv = append(inv, byte(i.Type)) } - in, qu := s.world.RoverCommands(resp) - var incoming, queued []*roveapi.Command - for i := range in { - incoming = append(incoming, &in[i]) - } - for i := range qu { - queued = append(queued, &qu[i]) - } + incoming, queued := s.world.RoverCommands(resp) var logs []*roveapi.Log for _, log := range rover.Logs { logs = append(logs, &roveapi.Log{ diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 51038a7..2977baa 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -243,8 +243,8 @@ func InnerMain(command string, args ...string) error { } commands = append(commands, &roveapi.Command{ - Command: roveapi.CommandType_broadcast, - Data: &roveapi.Command_Broadcast{Broadcast: []byte(args[i])}, + Command: roveapi.CommandType_broadcast, + Broadcast: []byte(args[i]), }, ) case "broadcast": @@ -256,8 +256,8 @@ func InnerMain(command string, args ...string) error { } commands = append(commands, &roveapi.Command{ - Command: roveapi.CommandType_broadcast, - Data: &roveapi.Command_Broadcast{Broadcast: []byte(args[i])}, + Command: roveapi.CommandType_broadcast, + Broadcast: []byte(args[i]), }, ) default: diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index c7990d1..26c5e56 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -38,7 +38,7 @@ func TestCommand_Turn(t *testing.T) { a, err := w.SpawnRover() assert.NoError(t, err) - w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_turn, Data: &roveapi.Command_Turn{Turn: roveapi.Bearing_NorthWest}}) + w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_turn, Turn: roveapi.Bearing_NorthWest}) w.EnqueueAllIncoming() w.ExecuteCommandQueues() diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 43fbe83..5e8483f 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -11,7 +11,7 @@ import ( ) // CommandStream is a list of commands to execute in order -type CommandStream []roveapi.Command +type CommandStream []*roveapi.Command // World describes a self contained universe and everything in it type World struct { @@ -406,7 +406,7 @@ func (w *World) RadarFromRover(rover string) (radar []roveapi.Tile, objs []rovea } // RoverCommands returns current commands for the given rover -func (w *World) RoverCommands(rover string) (incoming []roveapi.Command, queued []roveapi.Command) { +func (w *World) RoverCommands(rover string) (incoming CommandStream, queued CommandStream) { if c, ok := w.CommandIncoming[rover]; ok { incoming = c } @@ -448,18 +448,7 @@ func (w *World) Enqueue(rover string, commands ...*roveapi.Command) error { w.cmdMutex.Lock() defer w.cmdMutex.Unlock() - // Override the incoming command set - var cmds []roveapi.Command - for _, c := range commands { - // Copy the command and data but none of the locks or internals - cmds = append(cmds, - roveapi.Command{ - Command: c.Command, - Data: c.Data, - }) - } - - w.CommandIncoming[rover] = cmds + w.CommandIncoming[rover] = commands return nil } @@ -485,7 +474,7 @@ func (w *World) ExecuteCommandQueues() { if len(cmds) != 0 { // Execute the command - if err := w.ExecuteCommand(&cmds[0], rover); err != nil { + if err := w.ExecuteCommand(cmds[0], rover); err != nil { log.Println(err) // TODO: Report this error somehow } diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index cee8615..51a886f 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -624,10 +624,11 @@ type Command struct { // The command type Command CommandType `protobuf:"varint,1,opt,name=command,proto3,enum=roveapi.CommandType" json:"command,omitempty"` - // Types that are assignable to Data: - // *Command_Broadcast - // *Command_Turn - Data isCommand_Data `protobuf_oneof:"data"` + // A simple message, must be composed of printable ASCII glyphs (32-126) + // maximum of three characters + Broadcast []byte `protobuf:"bytes,2,opt,name=broadcast,proto3" json:"broadcast,omitempty"` + // The bearing for the rover to turn to + Turn Bearing `protobuf:"varint,3,opt,name=turn,proto3,enum=roveapi.Bearing" json:"turn,omitempty"` } func (x *Command) Reset() { @@ -669,46 +670,20 @@ func (x *Command) GetCommand() CommandType { return CommandType_none } -func (m *Command) GetData() isCommand_Data { - if m != nil { - return m.Data - } - return nil -} - func (x *Command) GetBroadcast() []byte { - if x, ok := x.GetData().(*Command_Broadcast); ok { + if x != nil { return x.Broadcast } return nil } func (x *Command) GetTurn() Bearing { - if x, ok := x.GetData().(*Command_Turn); ok { + if x != nil { return x.Turn } return Bearing_BearingUnknown } -type isCommand_Data interface { - isCommand_Data() -} - -type Command_Broadcast struct { - // A simple message, must be composed of printable ASCII glyphs (32-126) - // maximum of three characters - Broadcast []byte `protobuf:"bytes,2,opt,name=broadcast,proto3,oneof"` -} - -type Command_Turn struct { - // The bearing for the rover to turn to - Turn Bearing `protobuf:"varint,3,opt,name=turn,proto3,enum=roveapi.Bearing,oneof"` -} - -func (*Command_Broadcast) isCommand_Data() {} - -func (*Command_Turn) isCommand_Data() {} - // CommandRequest describes a set of commands to be requested for the rover type CommandRequest struct { state protoimpl.MessageState @@ -1278,131 +1253,130 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x89, 0x01, 0x0a, 0x07, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1e, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, - 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x09, 0x62, 0x72, 0x6f, 0x61, - 0x64, 0x63, 0x61, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, - 0x61, 0x72, 0x69, 0x6e, 0x67, 0x48, 0x00, 0x52, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x42, 0x06, 0x0a, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x6a, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x7d, 0x0a, 0x07, 0x43, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, + 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, + 0x73, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, + 0x6e, 0x67, 0x52, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x22, 0x6a, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, - 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x22, 0x75, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x54, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x29, 0x0a, 0x07, - 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0f, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, - 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, - 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, - 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, - 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xaa, 0x04, 0x0a, 0x0e, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x56, 0x65, 0x63, - 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, - 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, - 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, - 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, - 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, - 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, - 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, - 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, - 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, - 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x09, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, - 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x0a, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, - 0x65, 0x12, 0x39, 0x0a, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, - 0x69, 0x2e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, - 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3c, 0x0a, 0x10, - 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, - 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, - 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x38, 0x0a, 0x0e, 0x71, 0x75, - 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0d, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x73, 0x12, 0x20, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x0e, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x6f, 0x67, - 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x2a, 0x53, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, - 0x0a, 0x0a, 0x06, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x74, - 0x75, 0x72, 0x6e, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x03, - 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, - 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x05, 0x2a, 0x83, 0x01, 0x0a, 0x07, - 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, 0x72, 0x69, - 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x4e, - 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x45, - 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, 0x03, 0x12, - 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x04, 0x12, 0x09, - 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, - 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, 0x73, 0x74, - 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, - 0x08, 0x2a, 0x5a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, - 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x10, 0x0a, - 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, 0x02, 0x12, - 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, 0x12, 0x0d, - 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x2a, 0x37, 0x0a, - 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, - 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, - 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, - 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x2a, 0x4c, 0x0a, 0x0c, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, - 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x13, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, - 0x6e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x00, 0x12, - 0x10, 0x0a, 0x0c, 0x43, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x10, - 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x6f, 0x6c, 0x61, 0x72, 0x43, 0x68, 0x61, 0x72, 0x67, 0x69, - 0x6e, 0x67, 0x10, 0x02, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, - 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, - 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, - 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x75, 0x6e, 0x74, 0x22, 0x75, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x74, 0x69, + 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x61, 0x70, 0x69, 0x2e, 0x54, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, + 0x29, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0e, + 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, + 0x74, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, + 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, + 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, + 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, + 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, + 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xaa, 0x04, 0x0a, + 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, + 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x14, 0x0a, 0x05, + 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, + 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, + 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, + 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, + 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x08, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, + 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, + 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, + 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, + 0x61, 0x72, 0x67, 0x65, 0x12, 0x39, 0x0a, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x3c, 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, + 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x38, 0x0a, + 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, + 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x20, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, + 0x0e, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x2a, 0x53, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, + 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x08, + 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, + 0x68, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x04, 0x12, + 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x05, 0x2a, 0x83, + 0x01, 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, + 0x61, 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, + 0x0a, 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, + 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, + 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, + 0x04, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, + 0x53, 0x6f, 0x75, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, + 0x65, 0x73, 0x74, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, + 0x73, 0x74, 0x10, 0x08, 0x2a, 0x5a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, + 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, + 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, + 0x12, 0x10, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, + 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, + 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, + 0x2a, 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, + 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, + 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, + 0x08, 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x2a, 0x4c, 0x0a, 0x0c, 0x53, 0x61, 0x69, + 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x13, 0x55, 0x6e, 0x6b, + 0x6e, 0x6f, 0x77, 0x6e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x57, 0x69, + 0x6e, 0x64, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x6f, 0x6c, 0x61, 0x72, 0x43, 0x68, 0x61, + 0x72, 0x67, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, + 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, + 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, + 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, + 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1648,10 +1622,6 @@ func file_roveapi_roveapi_proto_init() { } } } - file_roveapi_roveapi_proto_msgTypes[5].OneofWrappers = []interface{}{ - (*Command_Broadcast)(nil), - (*Command_Turn)(nil), - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index 9f13a17..9ca09d8 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -120,14 +120,12 @@ message Command { // The command type CommandType command = 1; - oneof data { - // A simple message, must be composed of printable ASCII glyphs (32-126) - // maximum of three characters - bytes broadcast = 2; + // A simple message, must be composed of printable ASCII glyphs (32-126) + // maximum of three characters + bytes broadcast = 2; - // The bearing for the rover to turn to - Bearing turn = 3; - } + // The bearing for the rover to turn to + Bearing turn = 3; } // CommandRequest describes a set of commands to be requested for the rover From 6b5d5abea174039e17efe1de2ee26aaa897158f6 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 22 Jul 2020 19:24:36 +0100 Subject: [PATCH 161/228] Rename the world tick function and set the tick rate back to default --- cmd/rove-server/internal/server.go | 4 ++-- docker-compose.yml | 1 - pkg/rove/command_test.go | 6 +++--- pkg/rove/world.go | 4 ++-- pkg/rove/world_test.go | 4 ++-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cmd/rove-server/internal/server.go b/cmd/rove-server/internal/server.go index 102c30d..786eb00 100644 --- a/cmd/rove-server/internal/server.go +++ b/cmd/rove-server/internal/server.go @@ -131,8 +131,8 @@ func (s *Server) Run() { log.Println("Executing server tick") - // Run the command queues - s.world.ExecuteCommandQueues() + // Tick the world + s.world.Tick() // Save out the new world state if err := s.SaveWorld(); err != nil { diff --git a/docker-compose.yml b/docker-compose.yml index 71013b5..509af03 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,6 @@ services: - PORT=9090 - DATA_PATH=/mnt/rove-server - WORDS_FILE=data/words_alpha.txt - - TICK_RATE=5 volumes: - persistent-data:/mnt/rove-server:rw command: [ "./rove-server"] diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index 26c5e56..773b098 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -18,7 +18,7 @@ func TestCommand_Toggle(t *testing.T) { w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_toggle}) w.EnqueueAllIncoming() - w.ExecuteCommandQueues() + w.Tick() r, err = w.GetRover(a) assert.NoError(t, err) @@ -26,7 +26,7 @@ func TestCommand_Toggle(t *testing.T) { w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_toggle}) w.EnqueueAllIncoming() - w.ExecuteCommandQueues() + w.Tick() r, err = w.GetRover(a) assert.NoError(t, err) @@ -40,7 +40,7 @@ func TestCommand_Turn(t *testing.T) { w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_turn, Turn: roveapi.Bearing_NorthWest}) w.EnqueueAllIncoming() - w.ExecuteCommandQueues() + w.Tick() r, err := w.GetRover(a) assert.NoError(t, err) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 5e8483f..e50fa6f 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -464,8 +464,8 @@ func (w *World) EnqueueAllIncoming() { w.CommandIncoming = make(map[string]CommandStream) } -// ExecuteCommandQueues will execute any commands in the current command queue -func (w *World) ExecuteCommandQueues() { +// Tick will execute any commands in the current command queue and tick the world +func (w *World) Tick() { w.cmdMutex.Lock() defer w.cmdMutex.Unlock() diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index ffac1af..785baa2 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -343,7 +343,7 @@ func TestWorld_Daytime(t *testing.T) { // Loop for half the day for i := 0; i < world.TicksPerDay/2; i++ { assert.True(t, world.Daytime()) - world.ExecuteCommandQueues() + world.Tick() } // Remove rover charge again @@ -359,7 +359,7 @@ func TestWorld_Daytime(t *testing.T) { // Loop for half the day for i := 0; i < world.TicksPerDay/2; i++ { assert.False(t, world.Daytime()) - world.ExecuteCommandQueues() + world.Tick() } } From 447dbe358273d0a08b5ec8cbf354a8a0c9d66241 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 22 Jul 2020 19:24:55 +0100 Subject: [PATCH 162/228] Fix a test comment --- pkg/rove/command_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index 773b098..f22f797 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -60,5 +60,5 @@ func TestCommand_Broadcast(t *testing.T) { } func TestCommand_Invalid(t *testing.T) { - // TODO: Test the invalid command + // TODO: Test an invalid command } From 9e4276439841be819efe77b4b9ff877cad899a30 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 22 Jul 2020 19:25:32 +0100 Subject: [PATCH 163/228] Update the rover list to a list of pointers --- pkg/rove/rover.go | 4 ++-- pkg/rove/world.go | 15 +++------------ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/pkg/rove/rover.go b/pkg/rove/rover.go index 36b875f..f1e0972 100644 --- a/pkg/rove/rover.go +++ b/pkg/rove/rover.go @@ -62,8 +62,8 @@ type Rover struct { } // DefaultRover returns a default rover object with default settings -func DefaultRover() Rover { - return Rover{ +func DefaultRover() *Rover { + return &Rover{ Range: 4, Integrity: 10, MaximumIntegrity: 10, diff --git a/pkg/rove/world.go b/pkg/rove/world.go index e50fa6f..10fae64 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -22,7 +22,7 @@ type World struct { CurrentTicks int `json:"current-ticks"` // Rovers is a id->data map of all the rovers in the game - Rovers map[string]Rover `json:"rovers"` + Rovers map[string]*Rover `json:"rovers"` // Atlas represends the world map of chunks and tiles Atlas Atlas `json:"atlas"` @@ -41,7 +41,7 @@ type World struct { // NewWorld creates a new world object func NewWorld(chunkSize int) *World { return &World{ - Rovers: make(map[string]Rover), + Rovers: make(map[string]*Rover), CommandQueue: make(map[string]CommandStream), CommandIncoming: make(map[string]CommandStream), Atlas: NewChunkAtlas(chunkSize), @@ -94,7 +94,7 @@ func (w *World) GetRover(rover string) (Rover, error) { if !ok { return Rover{}, fmt.Errorf("Failed to find rover with name: %s", rover) } - return i, nil + return *i, nil } // RoverRecharge charges up a rover @@ -117,7 +117,6 @@ func (w *World) RoverRecharge(rover string) (int, error) { i.Charge++ i.AddLogEntryf("recharged to %d", i.Charge) } - w.Rovers[rover] = i return i.Charge, nil } @@ -152,7 +151,6 @@ func (w *World) RoverBroadcast(rover string, message []byte) (err error) { } i.AddLogEntryf("broadcasted %s", string(message)) - w.Rovers[rover] = i return } @@ -193,7 +191,6 @@ func (w *World) SetRoverPosition(rover string, pos maths.Vector) error { } i.Pos = pos - w.Rovers[rover] = i return nil } @@ -230,7 +227,6 @@ func (w *World) WarpRover(rover string, pos maths.Vector) error { } i.Pos = pos - w.Rovers[rover] = i return nil } @@ -259,7 +255,6 @@ func (w *World) MoveRover(rover string, b roveapi.Bearing) (maths.Vector, error) i.AddLogEntryf("moved %s to %+v", b.String(), newPos) // Perform the move i.Pos = newPos - w.Rovers[rover] = i } else { // If it is a blocking tile, reduce the rover integrity i.AddLogEntryf("tried to move %s to %+v", b.String(), newPos) @@ -267,8 +262,6 @@ func (w *World) MoveRover(rover string, b roveapi.Bearing) (maths.Vector, error) i.AddLogEntryf("had a collision, new integrity %d", i.Integrity) if i.Integrity == 0 { // TODO: The rover needs to be left dormant with the player - } else { - w.Rovers[rover] = i } } @@ -303,7 +296,6 @@ func (w *World) RoverStash(rover string) (roveapi.Object, error) { r.AddLogEntryf("stashed %c", obj.Type) r.Inventory = append(r.Inventory, obj) - w.Rovers[rover] = r w.Atlas.SetObject(r.Pos, Object{Type: roveapi.Object_ObjectUnknown}) return obj.Type, nil } @@ -343,7 +335,6 @@ func (w *World) RoverTurn(rover string, bearing roveapi.Bearing) (roveapi.Bearin // Set the new bearing r.Bearing = bearing - w.Rovers[rover] = r return r.Bearing, nil } From 075a502103f5725dabf17478eeff0ed9bd0175d0 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 22 Jul 2020 19:25:47 +0100 Subject: [PATCH 164/228] Pull the repair function out --- pkg/rove/world.go | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 10fae64..9d2e27c 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -338,6 +338,26 @@ func (w *World) RoverTurn(rover string, bearing roveapi.Bearing) (roveapi.Bearin return r.Bearing, nil } +// RoverRepair will turn the rover +func (w *World) RoverRepair(rover string) (int, error) { + w.worldMutex.Lock() + defer w.worldMutex.Unlock() + + r, ok := w.Rovers[rover] + if !ok { + return 0, fmt.Errorf("no rover matching id") + } + + // Consume an inventory item to repair if possible + if len(r.Inventory) > 0 && r.Integrity < r.MaximumIntegrity { + r.Inventory = r.Inventory[:len(r.Inventory)-1] + r.Integrity = r.Integrity + 1 + r.AddLogEntryf("repaired self to %d", r.Integrity) + } + + return r.Integrity, nil +} + // RadarFromRover can be used to query what a rover can currently see func (w *World) RadarFromRover(rover string) (radar []roveapi.Tile, objs []roveapi.Object, err error) { w.worldMutex.RLock() @@ -501,17 +521,9 @@ func (w *World) ExecuteCommand(c *roveapi.Command, rover string) (err error) { } case roveapi.CommandType_repair: - r, err := w.GetRover(rover) - if err != nil { + if _, err := w.RoverRepair(rover); err != nil { return err } - // Consume an inventory item to repair if possible - if len(r.Inventory) > 0 && r.Integrity < r.MaximumIntegrity { - r.Inventory = r.Inventory[:len(r.Inventory)-1] - r.Integrity = r.Integrity + 1 - r.AddLogEntryf("repaired self to %d", r.Integrity) - w.Rovers[rover] = r - } case roveapi.CommandType_broadcast: if err := w.RoverBroadcast(rover, c.GetBroadcast()); err != nil { From c94ac68f44cb1d86e9303545e6f38cec10c5daaf Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 22 Jul 2020 19:55:38 +0100 Subject: [PATCH 165/228] Remove all json tags, simply not needed --- cmd/rove-server/internal/accounts.go | 4 +-- cmd/rove-server/internal/simpleAccountant.go | 2 +- cmd/rove/main.go | 8 +++--- pkg/maths/vector.go | 4 +-- pkg/rove/chunkAtlas.go | 12 ++++----- pkg/rove/objects.go | 4 +-- pkg/rove/rover.go | 28 ++++++++++---------- pkg/rove/world.go | 12 ++++----- 8 files changed, 37 insertions(+), 37 deletions(-) diff --git a/cmd/rove-server/internal/accounts.go b/cmd/rove-server/internal/accounts.go index 99362ad..9ae6db9 100644 --- a/cmd/rove-server/internal/accounts.go +++ b/cmd/rove-server/internal/accounts.go @@ -21,8 +21,8 @@ type Accountant interface { // Account represents a registered user type Account struct { // Name simply describes the account and must be unique - Name string `json:"name"` + Name string // Data represents internal account data - Data map[string]string `json:"data"` + Data map[string]string } diff --git a/cmd/rove-server/internal/simpleAccountant.go b/cmd/rove-server/internal/simpleAccountant.go index 3168f30..611ff59 100644 --- a/cmd/rove-server/internal/simpleAccountant.go +++ b/cmd/rove-server/internal/simpleAccountant.go @@ -9,7 +9,7 @@ import ( // SimpleAccountant manages a set of accounts type SimpleAccountant struct { - Accounts map[string]Account `json:"accounts"` + Accounts map[string]Account } // NewSimpleAccountant creates a new accountant diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 2977baa..01e16ae 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -45,14 +45,14 @@ const gRPCport = 9090 // Account stores data for an account type Account struct { - Name string `json:"name"` - Secret string `json:"secret"` + Name string + Secret string } // Config is used to store internal data type Config struct { - Host string `json:"host,omitempty"` - Account Account `json:"account,omitempty"` + Host string + Account Account } // ConfigPath returns the configuration path diff --git a/pkg/maths/vector.go b/pkg/maths/vector.go index 92305cc..9b9d755 100644 --- a/pkg/maths/vector.go +++ b/pkg/maths/vector.go @@ -8,8 +8,8 @@ import ( // Vector desribes a 3D vector type Vector struct { - X int `json:"x"` - Y int `json:"y"` + X int + Y int } // Add adds one vector to another diff --git a/pkg/rove/chunkAtlas.go b/pkg/rove/chunkAtlas.go index f7ea36c..88f1102 100644 --- a/pkg/rove/chunkAtlas.go +++ b/pkg/rove/chunkAtlas.go @@ -11,27 +11,27 @@ import ( // chunk represents a fixed square grid of tiles type chunk struct { // Tiles represents the tiles within the chunk - Tiles []byte `json:"tiles"` + Tiles []byte // Objects represents the objects within the chunk // only one possible object per tile for now - Objects map[int]Object `json:"objects"` + Objects map[int]Object } // chunkBasedAtlas represents a grid of Chunks type chunkBasedAtlas struct { // Chunks represents all chunks in the world // This is intentionally not a 2D array so it can be expanded in all directions - Chunks []chunk `json:"chunks"` + Chunks []chunk // LowerBound is the origin of the bottom left corner of the current chunks in world space (current chunks cover >= this value) - LowerBound maths.Vector `json:"lowerBound"` + LowerBound maths.Vector // UpperBound is the top left corner of the current chunks (curent chunks cover < this value) - UpperBound maths.Vector `json:"upperBound"` + UpperBound maths.Vector // ChunkSize is the x/y dimensions of each square chunk - ChunkSize int `json:"chunksize"` + ChunkSize int // worldGen is the internal world generator worldGen WorldGen diff --git a/pkg/rove/objects.go b/pkg/rove/objects.go index 94595df..f1ce227 100644 --- a/pkg/rove/objects.go +++ b/pkg/rove/objects.go @@ -7,10 +7,10 @@ import ( // Object represents an object in the world type Object struct { // The type of the object - Type roveapi.Object `json:"type"` + Type roveapi.Object // Data is an internal type used for certain types of object - Data []byte `json:"data"` + Data []byte } // IsBlocking checks if an object is a blocking object diff --git a/pkg/rove/rover.go b/pkg/rove/rover.go index f1e0972..0bb9e4e 100644 --- a/pkg/rove/rover.go +++ b/pkg/rove/rover.go @@ -16,49 +16,49 @@ import ( // RoverLogEntry describes a single log entry for the rover type RoverLogEntry struct { // Time is the timestamp of the entry - Time time.Time `json:"time"` + Time time.Time // Text contains the information in this log entry - Text string `json:"text"` + Text string } // Rover describes a single rover in the world type Rover struct { // Unique name of this rover - Name string `json:"name"` + Name string // Pos represents where this rover is in the world - Pos maths.Vector `json:"pos"` + Pos maths.Vector // Bearing is the current direction the rover is facing - Bearing roveapi.Bearing `json:"bearing"` + Bearing roveapi.Bearing // Range represents the distance the unit's radar can see - Range int `json:"range"` + Range int // Inventory represents any items the rover is carrying - Inventory []Object `json:"inventory"` + Inventory []Object // Capacity is the maximum number of inventory items - Capacity int `json:"capacity"` + Capacity int // Integrity represents current rover health - Integrity int `json:"integrity"` + Integrity int // MaximumIntegrity is the full integrity of the rover - MaximumIntegrity int `json:"maximum-integrity"` + MaximumIntegrity int // Charge is the amount of energy the rover has - Charge int `json:"charge"` + Charge int // MaximumCharge is the maximum charge able to be stored - MaximumCharge int `json:"maximum-charge"` + MaximumCharge int // SailPosition is the current position of the sails - SailPosition roveapi.SailPosition `json:"sail-position"` + SailPosition roveapi.SailPosition // Logs Stores log of information - Logs []RoverLogEntry `json:"logs"` + Logs []RoverLogEntry } // DefaultRover returns a default rover object with default settings diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 9d2e27c..fa7a0e2 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -16,21 +16,21 @@ type CommandStream []*roveapi.Command // World describes a self contained universe and everything in it type World struct { // TicksPerDay is the amount of ticks in a single day - TicksPerDay int `json:"ticks-per-day"` + TicksPerDay int // Current number of ticks from the start - CurrentTicks int `json:"current-ticks"` + CurrentTicks int // Rovers is a id->data map of all the rovers in the game - Rovers map[string]*Rover `json:"rovers"` + Rovers map[string]*Rover // Atlas represends the world map of chunks and tiles - Atlas Atlas `json:"atlas"` + Atlas Atlas // Commands is the set of currently executing command streams per rover - CommandQueue map[string]CommandStream `json:"commands"` + CommandQueue map[string]CommandStream // Incoming represents the set of commands to add to the queue at the end of the current tick - CommandIncoming map[string]CommandStream `json:"incoming"` + CommandIncoming map[string]CommandStream // Mutex to lock around all world operations worldMutex sync.RWMutex From c89c5f6e74a3c87776108ec4765b36b976d72d45 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 22 Jul 2020 23:36:13 +0100 Subject: [PATCH 166/228] Implement current wind direction and rover wind movement --- cmd/rove-server/internal/routes.go | 1 + pkg/maths/vector.go | 10 ++ pkg/rove/rover.go | 3 + pkg/rove/world.go | 82 ++++++++++++++-- pkg/rove/world_test.go | 46 +-------- proto/roveapi/roveapi.pb.go | 148 ++++++++++++++++------------- proto/roveapi/roveapi.proto | 3 + 7 files changed, 174 insertions(+), 119 deletions(-) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 02a7483..6cb5a99 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -102,6 +102,7 @@ func (s *Server) Status(ctx context.Context, req *roveapi.StatusRequest) (respon QueuedCommands: queued, SailPosition: rover.SailPosition, Logs: logs, + Wind: s.world.Wind, } } return response, nil diff --git a/pkg/maths/vector.go b/pkg/maths/vector.go index 9b9d755..a74ff16 100644 --- a/pkg/maths/vector.go +++ b/pkg/maths/vector.go @@ -107,3 +107,13 @@ func BearingToVector(b roveapi.Bearing) Vector { return Vector{} } + +// Dot returns the dot product of two vectors +func Dot(a Vector, b Vector) int { + return a.X*b.X + a.Y*b.Y +} + +// AngleCos returns the cosine of the angle between two vectors +func AngleCos(a Vector, b Vector) float64 { + return float64(Dot(a, b)) / a.Length() * b.Length() +} diff --git a/pkg/rove/rover.go b/pkg/rove/rover.go index 0bb9e4e..fb13ddc 100644 --- a/pkg/rove/rover.go +++ b/pkg/rove/rover.go @@ -57,6 +57,9 @@ type Rover struct { // SailPosition is the current position of the sails SailPosition roveapi.SailPosition + // Current number of ticks in this move, used for sailing speeds + MoveTicks int + // Logs Stores log of information Logs []RoverLogEntry } diff --git a/pkg/rove/world.go b/pkg/rove/world.go index fa7a0e2..0265951 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -10,11 +10,16 @@ import ( "github.com/mdiluz/rove/proto/roveapi" ) +const ( + TicksPerNormalMove = 4 +) + // CommandStream is a list of commands to execute in order type CommandStream []*roveapi.Command // World describes a self contained universe and everything in it type World struct { + // TicksPerDay is the amount of ticks in a single day TicksPerDay int @@ -27,6 +32,9 @@ type World struct { // Atlas represends the world map of chunks and tiles Atlas Atlas + // Wind is the current wind direction + Wind roveapi.Bearing + // Commands is the set of currently executing command streams per rover CommandQueue map[string]CommandStream // Incoming represents the set of commands to add to the queue at the end of the current tick @@ -230,8 +238,8 @@ func (w *World) WarpRover(rover string, pos maths.Vector) error { return nil } -// MoveRover attempts to move a rover in a specific direction -func (w *World) MoveRover(rover string, b roveapi.Bearing) (maths.Vector, error) { +// TryMoveRover attempts to move a rover in a specific direction +func (w *World) TryMoveRover(rover string, b roveapi.Bearing) (maths.Vector, error) { w.worldMutex.Lock() defer w.worldMutex.Unlock() @@ -240,12 +248,6 @@ func (w *World) MoveRover(rover string, b roveapi.Bearing) (maths.Vector, error) return maths.Vector{}, fmt.Errorf("no rover matching id") } - // Ensure the rover has energy - if i.Charge <= 0 { - return i.Pos, nil - } - i.Charge-- - // Try the new move position newPos := i.Pos.Added(maths.BearingToVector(b)) @@ -318,7 +320,9 @@ func (w *World) RoverToggle(rover string) (roveapi.SailPosition, error) { r.SailPosition = roveapi.SailPosition_CatchingWind } - w.Rovers[rover] = r + // Reset the movement ticks + r.MoveTicks = 0 + return r.SailPosition, nil } @@ -334,6 +338,8 @@ func (w *World) RoverTurn(rover string, bearing roveapi.Bearing) (roveapi.Bearin // Set the new bearing r.Bearing = bearing + // Reset the movement ticks + r.MoveTicks = 0 return r.Bearing, nil } @@ -502,6 +508,64 @@ func (w *World) Tick() { // Add any incoming commands from this tick and clear that queue w.EnqueueAllIncoming() + // Change the wind every day + if (w.CurrentTicks % w.TicksPerDay) == 0 { + w.Wind = roveapi.Bearing((rand.Int() % 8) + 1) // Random cardinal bearing + } + + // Move all the rovers based on current wind and sails + for n, r := range w.Rovers { + // Skip if we're not catching the wind + if r.SailPosition != roveapi.SailPosition_CatchingWind { + continue + } + + // Increment the current move ticks + r.MoveTicks++ + + // Get the difference between the two bearings + // Normalise, we don't care about clockwise/anticlockwise + diff := maths.Abs(int(w.Wind - r.Bearing)) + if diff > 4 { + diff = 8 - diff + } + + // Calculate the travel "ticks" + var ticksToMove int + switch diff { + case 0: + // Going with the wind, travel at base speed of once every 4 ticks + ticksToMove = TicksPerNormalMove + case 1: + // At a slight angle, we can go a little faster + ticksToMove = TicksPerNormalMove / 2 + case 2: + // Perpendicular to wind, max speed + ticksToMove = 1 + case 3: + // Heading at 45 degrees into the wind, back to min speed + ticksToMove = TicksPerNormalMove + case 4: + // Heading durectly into the wind, no movement at all + default: + log.Fatalf("bearing difference of %d should be impossible", diff) + } + + // If we've incremented over the current move ticks on the rover, we can try and make the move + if r.MoveTicks >= ticksToMove { + _, err := w.TryMoveRover(n, r.Bearing) + if err != nil { + log.Println(err) + // TODO: Report this error somehow + } + + // Reset the move ticks + r.MoveTicks = 0 + } + + log.Print(ticksToMove) + } + // Increment the current tick count w.CurrentTicks++ } diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index 785baa2..2dbcc86 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -78,25 +78,20 @@ func TestWorld_GetSetMovePosition(t *testing.T) { assert.Equal(t, pos, newPos, "Failed to correctly set position for rover") b := roveapi.Bearing_North - newPos, err = world.MoveRover(a, b) + newPos, err = world.TryMoveRover(a, b) assert.NoError(t, err, "Failed to set position for rover") pos.Add(maths.Vector{X: 0, Y: 1}) assert.Equal(t, pos, newPos, "Failed to correctly move position for rover") rover, err := world.GetRover(a) assert.NoError(t, err, "Failed to get rover information") - assert.Equal(t, rover.MaximumCharge-1, rover.Charge, "Rover should have lost charge for moving") assert.Contains(t, rover.Logs[len(rover.Logs)-1].Text, "moved", "Rover logs should contain the move") // Place a tile in front of the rover world.Atlas.SetObject(maths.Vector{X: 0, Y: 2}, Object{Type: roveapi.Object_RockLarge}) - newPos, err = world.MoveRover(a, b) + newPos, err = world.TryMoveRover(a, b) assert.NoError(t, err, "Failed to move rover") assert.Equal(t, pos, newPos, "Failed to correctly not move position for rover into wall") - - rover, err = world.GetRover(a) - assert.NoError(t, err, "Failed to get rover information") - assert.Equal(t, rover.MaximumCharge-2, rover.Charge, "Rover should have lost charge for move attempt") } func TestWorld_RadarFromRover(t *testing.T) { @@ -224,7 +219,7 @@ func TestWorld_RoverDamage(t *testing.T) { world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, Object{Type: roveapi.Object_RockLarge}) - vec, err := world.MoveRover(a, roveapi.Bearing_North) + vec, err := world.TryMoveRover(a, roveapi.Bearing_North) assert.NoError(t, err, "Failed to move rover") assert.Equal(t, pos, vec, "Rover managed to move into large rock") @@ -261,7 +256,7 @@ func TestWorld_RoverRepair(t *testing.T) { world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, Object{Type: roveapi.Object_RockLarge}) // Try and bump into the rock - vec, err := world.MoveRover(a, roveapi.Bearing_North) + vec, err := world.TryMoveRover(a, roveapi.Bearing_North) assert.NoError(t, err, "Failed to move rover") assert.Equal(t, pos, vec, "Rover managed to move into large rock") @@ -291,39 +286,6 @@ func TestWorld_RoverRepair(t *testing.T) { assert.Equal(t, originalInfo.Integrity, newinfo.Integrity, "rover should have kept the same integrity") } -func TestWorld_Charge(t *testing.T) { - world := NewWorld(4) - a, err := world.SpawnRover() - assert.NoError(t, err) - - // Get the rover information - rover, err := world.GetRover(a) - assert.NoError(t, err, "Failed to get rover information") - assert.Equal(t, rover.MaximumCharge, rover.Charge, "Rover should start with maximum charge") - - // Use up all the charge - for i := 0; i < rover.MaximumCharge; i++ { - // Get the initial position - initialPos, err := world.RoverPosition(a) - assert.NoError(t, err, "Failed to get position for rover") - - // Ensure the path ahead is empty - world.Atlas.SetTile(initialPos.Added(maths.BearingToVector(roveapi.Bearing_North)), roveapi.Tile_Rock) - world.Atlas.SetObject(initialPos.Added(maths.BearingToVector(roveapi.Bearing_North)), Object{Type: roveapi.Object_ObjectUnknown}) - - // Try and move north (along unblocked path) - newPos, err := world.MoveRover(a, roveapi.Bearing_North) - assert.NoError(t, err, "Failed to set position for rover") - assert.Equal(t, initialPos.Added(maths.BearingToVector(roveapi.Bearing_North)), newPos, "Failed to correctly move position for rover") - - // Ensure rover lost charge - rover, err := world.GetRover(a) - assert.NoError(t, err, "Failed to get rover information") - assert.Equal(t, rover.MaximumCharge-(i+1), rover.Charge, "Rover should have lost charge") - } - -} - func TestWorld_Daytime(t *testing.T) { world := NewWorld(1) diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index 51a886f..a9bf133 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -1095,6 +1095,8 @@ type StatusResponse struct { QueuedCommands []*Command `protobuf:"bytes,13,rep,name=queuedCommands,proto3" json:"queuedCommands,omitempty"` // The most recent logs Logs []*Log `protobuf:"bytes,14,rep,name=logs,proto3" json:"logs,omitempty"` + // The current wind direction + Wind Bearing `protobuf:"varint,15,opt,name=wind,proto3,enum=roveapi.Bearing" json:"wind,omitempty"` } func (x *StatusResponse) Reset() { @@ -1227,6 +1229,13 @@ func (x *StatusResponse) GetLogs() []*Log { return nil } +func (x *StatusResponse) GetWind() Bearing { + if x != nil { + return x.Wind + } + return Bearing_BearingUnknown +} + var File_roveapi_roveapi_proto protoreflect.FileDescriptor var file_roveapi_roveapi_proto_rawDesc = []byte{ @@ -1289,7 +1298,7 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, - 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xaa, 0x04, 0x0a, + 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xd0, 0x04, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, @@ -1324,59 +1333,61 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x20, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x2a, 0x53, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, - 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x08, - 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, - 0x68, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x04, 0x12, - 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x05, 0x2a, 0x83, - 0x01, 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, - 0x61, 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, - 0x0a, 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, - 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, - 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, - 0x04, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, - 0x53, 0x6f, 0x75, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, - 0x65, 0x73, 0x74, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, - 0x73, 0x74, 0x10, 0x08, 0x2a, 0x5a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, - 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, - 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, - 0x12, 0x10, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, - 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, - 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, - 0x2a, 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, - 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, - 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, - 0x08, 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x2a, 0x4c, 0x0a, 0x0c, 0x53, 0x61, 0x69, - 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x13, 0x55, 0x6e, 0x6b, - 0x6e, 0x6f, 0x77, 0x6e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x57, 0x69, - 0x6e, 0x64, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x6f, 0x6c, 0x61, 0x72, 0x43, 0x68, 0x61, - 0x72, 0x67, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, - 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, + 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x12, 0x24, 0x0a, 0x04, 0x77, 0x69, 0x6e, + 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, + 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x04, 0x77, 0x69, 0x6e, 0x64, 0x2a, + 0x53, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, + 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x74, 0x6f, 0x67, 0x67, + 0x6c, 0x65, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x10, 0x02, 0x12, 0x09, + 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, + 0x61, 0x69, 0x72, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, + 0x73, 0x74, 0x10, 0x05, 0x2a, 0x83, 0x01, 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, + 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, + 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, + 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, + 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, + 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x04, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, + 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, + 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, 0x73, 0x74, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, + 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x08, 0x2a, 0x5a, 0x0a, 0x06, 0x4f, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, + 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, + 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, + 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, + 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, + 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x2a, 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, + 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, + 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, + 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x2a, + 0x4c, 0x0a, 0x0c, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x17, 0x0a, 0x13, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x61, 0x74, 0x63, + 0x68, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x6f, + 0x6c, 0x61, 0x72, 0x43, 0x68, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x32, 0xcf, 0x02, + 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, + 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, - 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, - 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, - 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, + 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, + 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, + 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, + 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1430,21 +1441,22 @@ var file_roveapi_roveapi_proto_depIdxs = []int32{ 10, // 12: roveapi.StatusResponse.incomingCommands:type_name -> roveapi.Command 10, // 13: roveapi.StatusResponse.queuedCommands:type_name -> roveapi.Command 16, // 14: roveapi.StatusResponse.logs:type_name -> roveapi.Log - 5, // 15: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest - 7, // 16: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest - 11, // 17: roveapi.Rove.Command:input_type -> roveapi.CommandRequest - 13, // 18: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest - 15, // 19: roveapi.Rove.Status:input_type -> roveapi.StatusRequest - 6, // 20: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse - 9, // 21: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse - 12, // 22: roveapi.Rove.Command:output_type -> roveapi.CommandResponse - 14, // 23: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse - 18, // 24: roveapi.Rove.Status:output_type -> roveapi.StatusResponse - 20, // [20:25] is the sub-list for method output_type - 15, // [15:20] is the sub-list for method input_type - 15, // [15:15] is the sub-list for extension type_name - 15, // [15:15] is the sub-list for extension extendee - 0, // [0:15] is the sub-list for field type_name + 1, // 15: roveapi.StatusResponse.wind:type_name -> roveapi.Bearing + 5, // 16: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest + 7, // 17: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest + 11, // 18: roveapi.Rove.Command:input_type -> roveapi.CommandRequest + 13, // 19: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest + 15, // 20: roveapi.Rove.Status:input_type -> roveapi.StatusRequest + 6, // 21: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse + 9, // 22: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse + 12, // 23: roveapi.Rove.Command:output_type -> roveapi.CommandResponse + 14, // 24: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse + 18, // 25: roveapi.Rove.Status:output_type -> roveapi.StatusResponse + 21, // [21:26] is the sub-list for method output_type + 16, // [16:21] is the sub-list for method input_type + 16, // [16:16] is the sub-list for extension type_name + 16, // [16:16] is the sub-list for extension extendee + 0, // [0:16] is the sub-list for field type_name } func init() { file_roveapi_roveapi_proto_init() } diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index 9ca09d8..c45f29c 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -274,4 +274,7 @@ message StatusResponse { // The most recent logs repeated Log logs = 14; + + // The current wind direction + Bearing wind = 15; } \ No newline at end of file From 5d80cb2596848ea6d745d33dfb5deae4b40bcf5c Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 22 Jul 2020 23:50:42 +0100 Subject: [PATCH 167/228] Implement sailing tests and fix into-the-wind bug --- pkg/rove/world.go | 2 +- pkg/rove/world_test.go | 78 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 0265951..b8464aa 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -552,7 +552,7 @@ func (w *World) Tick() { } // If we've incremented over the current move ticks on the rover, we can try and make the move - if r.MoveTicks >= ticksToMove { + if ticksToMove != 0 && r.MoveTicks >= ticksToMove { _, err := w.TryMoveRover(n, r.Bearing) if err != nil { log.Println(err) diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index 2dbcc86..a3c2f47 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -388,3 +388,81 @@ func TestWorld_Broadcast(t *testing.T) { assert.NoError(t, err) assert.Contains(t, rb.Logs[len(rb.Logs)-1].Text, "HJK", "Rover A should have logged it's broadcast") } + +func TestWorld_Sailing(t *testing.T) { + world := NewWorld(8) + world.Tick() // One initial tick to set the wind direction the first time + world.Wind = roveapi.Bearing_North // Set the wind direction to north + + name, err := world.SpawnRover() + assert.NoError(t, err) + + // Warp the rover to 0,0 after clearing it + world.Atlas.SetObject(maths.Vector{X: 0, Y: 0}, Object{Type: roveapi.Object_ObjectUnknown}) + assert.NoError(t, world.WarpRover(name, maths.Vector{X: 0, Y: 0})) + + s, err := world.RoverToggle(name) + assert.NoError(t, err) + assert.Equal(t, roveapi.SailPosition_CatchingWind, s) + + b, err := world.RoverTurn(name, roveapi.Bearing_North) + assert.NoError(t, err) + assert.Equal(t, roveapi.Bearing_North, b) + + // Clear the space to the north + world.Atlas.SetObject(maths.Vector{X: 0, Y: 1}, Object{Type: roveapi.Object_ObjectUnknown}) + + // Tick the world and check we've moved not moved + world.Tick() + info, err := world.GetRover(name) + assert.NoError(t, err) + assert.Equal(t, maths.Vector{Y: 0}, info.Pos) + + // Loop a few more times + for i := 0; i < TicksPerNormalMove-2; i++ { + world.Tick() + info, err := world.GetRover(name) + assert.NoError(t, err) + assert.Equal(t, maths.Vector{Y: 0}, info.Pos) + } + + // Now check we've moved (after the TicksPerNormalMove number of ticks) + world.Tick() + info, err = world.GetRover(name) + assert.NoError(t, err) + assert.Equal(t, maths.Vector{Y: 1}, info.Pos) + + // Reset the world ticks back to stop any wind changes etc. + world.CurrentTicks = 1 + + // Face the rover south, into the wind + b, err = world.RoverTurn(name, roveapi.Bearing_South) + assert.NoError(t, err) + assert.Equal(t, roveapi.Bearing_South, b) + + // Tick a bunch, we should never move + for i := 0; i < TicksPerNormalMove*2; i++ { + world.Tick() + info, err := world.GetRover(name) + assert.NoError(t, err) + assert.Equal(t, maths.Vector{Y: 1}, info.Pos) + } + + // Reset the world ticks back to stop any wind changes etc. + world.CurrentTicks = 1 + world.Wind = roveapi.Bearing_SouthEast // Set up a south easternly wind + + // Turn the rover perpendicular + b, err = world.RoverTurn(name, roveapi.Bearing_NorthEast) + assert.NoError(t, err) + assert.Equal(t, roveapi.Bearing_NorthEast, b) + + // Clear a space + world.Atlas.SetObject(maths.Vector{X: 1, Y: 2}, Object{Type: roveapi.Object_ObjectUnknown}) + + // Now check we've moved immediately + world.Tick() + info, err = world.GetRover(name) + assert.NoError(t, err) + assert.Equal(t, maths.Vector{X: 1, Y: 2}, info.Pos) +} From 1e18610c5c7322cd1ba13653e92d6d0efd40ae2a Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 22 Jul 2020 23:57:22 +0100 Subject: [PATCH 168/228] Set tick rate to 3 --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 509af03..f1962a9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,6 +15,7 @@ services: - PORT=9090 - DATA_PATH=/mnt/rove-server - WORDS_FILE=data/words_alpha.txt + - TICK_RATE=3 volumes: - persistent-data:/mnt/rove-server:rw command: [ "./rove-server"] From 6adc652cea8becdc6cebef2ba35a133857b2115f Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 22 Jul 2020 23:59:28 +0100 Subject: [PATCH 169/228] Fix lint errors --- pkg/rove/command_test.go | 9 ++++++--- pkg/rove/world.go | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index f22f797..536f656 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -16,7 +16,8 @@ func TestCommand_Toggle(t *testing.T) { assert.NoError(t, err) assert.Equal(t, roveapi.SailPosition_SolarCharging, r.SailPosition) - w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_toggle}) + err = w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_toggle}) + assert.NoError(t, err) w.EnqueueAllIncoming() w.Tick() @@ -24,7 +25,8 @@ func TestCommand_Toggle(t *testing.T) { assert.NoError(t, err) assert.Equal(t, roveapi.SailPosition_CatchingWind, r.SailPosition) - w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_toggle}) + err = w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_toggle}) + assert.NoError(t, err) w.EnqueueAllIncoming() w.Tick() @@ -38,7 +40,8 @@ func TestCommand_Turn(t *testing.T) { a, err := w.SpawnRover() assert.NoError(t, err) - w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_turn, Turn: roveapi.Bearing_NorthWest}) + err = w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_turn, Turn: roveapi.Bearing_NorthWest}) + assert.NoError(t, err) w.EnqueueAllIncoming() w.Tick() diff --git a/pkg/rove/world.go b/pkg/rove/world.go index b8464aa..1fa166d 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -262,9 +262,9 @@ func (w *World) TryMoveRover(rover string, b roveapi.Bearing) (maths.Vector, err i.AddLogEntryf("tried to move %s to %+v", b.String(), newPos) i.Integrity = i.Integrity - 1 i.AddLogEntryf("had a collision, new integrity %d", i.Integrity) - if i.Integrity == 0 { - // TODO: The rover needs to be left dormant with the player - } + // TODO: The rover needs to be left dormant with the player + //if i.Integrity == 0 { + //} } return i.Pos, nil From 2bc247712879e19b65187db6c80f3a61ee07bddb Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 23 Jul 2020 00:13:28 +0100 Subject: [PATCH 170/228] Remove the incoming command streams, de-scopes and simplifies --- cmd/rove-server/internal/routes.go | 3 +- pkg/rove/command_test.go | 3 - pkg/rove/world.go | 34 ++---- proto/roveapi/roveapi.pb.go | 179 +++++++++++++---------------- proto/roveapi/roveapi.proto | 9 +- 5 files changed, 94 insertions(+), 134 deletions(-) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 6cb5a99..7174c31 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -75,7 +75,7 @@ func (s *Server) Status(ctx context.Context, req *roveapi.StatusRequest) (respon inv = append(inv, byte(i.Type)) } - incoming, queued := s.world.RoverCommands(resp) + queued := s.world.RoverCommands(resp) var logs []*roveapi.Log for _, log := range rover.Logs { logs = append(logs, &roveapi.Log{ @@ -98,7 +98,6 @@ func (s *Server) Status(ctx context.Context, req *roveapi.StatusRequest) (respon MaximumIntegrity: int32(rover.MaximumIntegrity), Charge: int32(rover.Charge), MaximumCharge: int32(rover.MaximumCharge), - IncomingCommands: incoming, QueuedCommands: queued, SailPosition: rover.SailPosition, Logs: logs, diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index 536f656..f55c6cb 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -18,7 +18,6 @@ func TestCommand_Toggle(t *testing.T) { err = w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_toggle}) assert.NoError(t, err) - w.EnqueueAllIncoming() w.Tick() r, err = w.GetRover(a) @@ -27,7 +26,6 @@ func TestCommand_Toggle(t *testing.T) { err = w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_toggle}) assert.NoError(t, err) - w.EnqueueAllIncoming() w.Tick() r, err = w.GetRover(a) @@ -42,7 +40,6 @@ func TestCommand_Turn(t *testing.T) { err = w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_turn, Turn: roveapi.Bearing_NorthWest}) assert.NoError(t, err) - w.EnqueueAllIncoming() w.Tick() r, err := w.GetRover(a) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 1fa166d..591ba8e 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -37,8 +37,6 @@ type World struct { // Commands is the set of currently executing command streams per rover CommandQueue map[string]CommandStream - // Incoming represents the set of commands to add to the queue at the end of the current tick - CommandIncoming map[string]CommandStream // Mutex to lock around all world operations worldMutex sync.RWMutex @@ -49,12 +47,11 @@ type World struct { // NewWorld creates a new world object func NewWorld(chunkSize int) *World { return &World{ - Rovers: make(map[string]*Rover), - CommandQueue: make(map[string]CommandStream), - CommandIncoming: make(map[string]CommandStream), - Atlas: NewChunkAtlas(chunkSize), - TicksPerDay: 24, - CurrentTicks: 0, + Rovers: make(map[string]*Rover), + CommandQueue: make(map[string]CommandStream), + Atlas: NewChunkAtlas(chunkSize), + TicksPerDay: 24, + CurrentTicks: 0, } } @@ -423,10 +420,7 @@ func (w *World) RadarFromRover(rover string) (radar []roveapi.Tile, objs []rovea } // RoverCommands returns current commands for the given rover -func (w *World) RoverCommands(rover string) (incoming CommandStream, queued CommandStream) { - if c, ok := w.CommandIncoming[rover]; ok { - incoming = c - } +func (w *World) RoverCommands(rover string) (queued CommandStream) { if c, ok := w.CommandQueue[rover]; ok { queued = c } @@ -465,22 +459,11 @@ func (w *World) Enqueue(rover string, commands ...*roveapi.Command) error { w.cmdMutex.Lock() defer w.cmdMutex.Unlock() - w.CommandIncoming[rover] = commands + w.CommandQueue[rover] = commands return nil } -// EnqueueAllIncoming will enqueue the incoming commands -func (w *World) EnqueueAllIncoming() { - // Add any incoming commands from this tick and clear that queue - for id, incoming := range w.CommandIncoming { - commands := w.CommandQueue[id] - commands = append(commands, incoming...) - w.CommandQueue[id] = commands - } - w.CommandIncoming = make(map[string]CommandStream) -} - // Tick will execute any commands in the current command queue and tick the world func (w *World) Tick() { w.cmdMutex.Lock() @@ -505,9 +488,6 @@ func (w *World) Tick() { } } - // Add any incoming commands from this tick and clear that queue - w.EnqueueAllIncoming() - // Change the wind every day if (w.CurrentTicks % w.TicksPerDay) == 0 { w.Wind = roveapi.Bearing((rand.Int() % 8) + 1) // Random cardinal bearing diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index a9bf133..4fbea99 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -1089,14 +1089,12 @@ type StatusResponse struct { MaximumCharge int32 `protobuf:"varint,10,opt,name=maximumCharge,proto3" json:"maximumCharge,omitempty"` // The current position of the sails SailPosition SailPosition `protobuf:"varint,11,opt,name=sailPosition,proto3,enum=roveapi.SailPosition" json:"sailPosition,omitempty"` - // The set of currently incoming commands for this tick - IncomingCommands []*Command `protobuf:"bytes,12,rep,name=incomingCommands,proto3" json:"incomingCommands,omitempty"` // The set of currently queued commands - QueuedCommands []*Command `protobuf:"bytes,13,rep,name=queuedCommands,proto3" json:"queuedCommands,omitempty"` + QueuedCommands []*Command `protobuf:"bytes,12,rep,name=queuedCommands,proto3" json:"queuedCommands,omitempty"` // The most recent logs - Logs []*Log `protobuf:"bytes,14,rep,name=logs,proto3" json:"logs,omitempty"` + Logs []*Log `protobuf:"bytes,13,rep,name=logs,proto3" json:"logs,omitempty"` // The current wind direction - Wind Bearing `protobuf:"varint,15,opt,name=wind,proto3,enum=roveapi.Bearing" json:"wind,omitempty"` + Wind Bearing `protobuf:"varint,14,opt,name=wind,proto3,enum=roveapi.Bearing" json:"wind,omitempty"` } func (x *StatusResponse) Reset() { @@ -1208,13 +1206,6 @@ func (x *StatusResponse) GetSailPosition() SailPosition { return SailPosition_UnknownSailPosition } -func (x *StatusResponse) GetIncomingCommands() []*Command { - if x != nil { - return x.IncomingCommands - } - return nil -} - func (x *StatusResponse) GetQueuedCommands() []*Command { if x != nil { return x.QueuedCommands @@ -1298,7 +1289,7 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, - 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xd0, 0x04, 0x0a, + 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0x92, 0x04, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, @@ -1324,70 +1315,67 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x3c, 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, - 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x38, 0x0a, - 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, - 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x20, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, - 0x0e, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x12, 0x24, 0x0a, 0x04, 0x77, 0x69, 0x6e, - 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, - 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x04, 0x77, 0x69, 0x6e, 0x64, 0x2a, - 0x53, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, - 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x74, 0x6f, 0x67, 0x67, - 0x6c, 0x65, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x10, 0x02, 0x12, 0x09, - 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, - 0x61, 0x69, 0x72, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, - 0x73, 0x74, 0x10, 0x05, 0x2a, 0x83, 0x01, 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, - 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, - 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, - 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, - 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, - 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x04, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, - 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, - 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, 0x73, 0x74, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, - 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x08, 0x2a, 0x5a, 0x0a, 0x06, 0x4f, 0x62, - 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, - 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, - 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, - 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, - 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, - 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x2a, 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, - 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, - 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, - 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x2a, - 0x4c, 0x0a, 0x0c, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x17, 0x0a, 0x13, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, - 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x61, 0x74, 0x63, - 0x68, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x6f, - 0x6c, 0x61, 0x72, 0x43, 0x68, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x32, 0xcf, 0x02, - 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, - 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, - 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, - 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, - 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, - 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, - 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x38, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, + 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, + 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x20, 0x0a, 0x04, 0x6c, 0x6f, 0x67, + 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, + 0x69, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x12, 0x24, 0x0a, 0x04, 0x77, + 0x69, 0x6e, 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x04, 0x77, 0x69, 0x6e, + 0x64, 0x2a, 0x53, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x74, 0x6f, + 0x67, 0x67, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x10, 0x02, + 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x72, + 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, + 0x63, 0x61, 0x73, 0x74, 0x10, 0x05, 0x2a, 0x83, 0x01, 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, + 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, + 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, + 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, + 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, + 0x75, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x04, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, + 0x74, 0x68, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x57, 0x65, 0x73, + 0x74, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, 0x73, 0x74, 0x10, 0x07, 0x12, 0x0d, 0x0a, + 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x08, 0x2a, 0x5a, 0x0a, 0x06, + 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, + 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, + 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, + 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, + 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x2a, 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, + 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, + 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, + 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, + 0x03, 0x2a, 0x4c, 0x0a, 0x0c, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x17, 0x0a, 0x13, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x53, 0x61, 0x69, 0x6c, + 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x61, + 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, + 0x53, 0x6f, 0x6c, 0x61, 0x72, 0x43, 0x68, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x32, + 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, + 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, + 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -1438,25 +1426,24 @@ var file_roveapi_roveapi_proto_depIdxs = []int32{ 17, // 9: roveapi.StatusResponse.position:type_name -> roveapi.Vector 1, // 10: roveapi.StatusResponse.bearing:type_name -> roveapi.Bearing 4, // 11: roveapi.StatusResponse.sailPosition:type_name -> roveapi.SailPosition - 10, // 12: roveapi.StatusResponse.incomingCommands:type_name -> roveapi.Command - 10, // 13: roveapi.StatusResponse.queuedCommands:type_name -> roveapi.Command - 16, // 14: roveapi.StatusResponse.logs:type_name -> roveapi.Log - 1, // 15: roveapi.StatusResponse.wind:type_name -> roveapi.Bearing - 5, // 16: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest - 7, // 17: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest - 11, // 18: roveapi.Rove.Command:input_type -> roveapi.CommandRequest - 13, // 19: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest - 15, // 20: roveapi.Rove.Status:input_type -> roveapi.StatusRequest - 6, // 21: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse - 9, // 22: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse - 12, // 23: roveapi.Rove.Command:output_type -> roveapi.CommandResponse - 14, // 24: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse - 18, // 25: roveapi.Rove.Status:output_type -> roveapi.StatusResponse - 21, // [21:26] is the sub-list for method output_type - 16, // [16:21] is the sub-list for method input_type - 16, // [16:16] is the sub-list for extension type_name - 16, // [16:16] is the sub-list for extension extendee - 0, // [0:16] is the sub-list for field type_name + 10, // 12: roveapi.StatusResponse.queuedCommands:type_name -> roveapi.Command + 16, // 13: roveapi.StatusResponse.logs:type_name -> roveapi.Log + 1, // 14: roveapi.StatusResponse.wind:type_name -> roveapi.Bearing + 5, // 15: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest + 7, // 16: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest + 11, // 17: roveapi.Rove.Command:input_type -> roveapi.CommandRequest + 13, // 18: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest + 15, // 19: roveapi.Rove.Status:input_type -> roveapi.StatusRequest + 6, // 20: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse + 9, // 21: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse + 12, // 22: roveapi.Rove.Command:output_type -> roveapi.CommandResponse + 14, // 23: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse + 18, // 24: roveapi.Rove.Status:output_type -> roveapi.StatusResponse + 20, // [20:25] is the sub-list for method output_type + 15, // [15:20] is the sub-list for method input_type + 15, // [15:15] is the sub-list for extension type_name + 15, // [15:15] is the sub-list for extension extendee + 0, // [0:15] is the sub-list for field type_name } func init() { file_roveapi_roveapi_proto_init() } diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index c45f29c..33bbc25 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -266,15 +266,12 @@ message StatusResponse { // The current position of the sails SailPosition sailPosition = 11; - // The set of currently incoming commands for this tick - repeated Command incomingCommands = 12; - // The set of currently queued commands - repeated Command queuedCommands = 13; + repeated Command queuedCommands = 12; // The most recent logs - repeated Log logs = 14; + repeated Log logs = 13; // The current wind direction - Bearing wind = 15; + Bearing wind = 14; } \ No newline at end of file From f7192b39977d7c72c42d037cecacdfc9df2b653c Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 23 Jul 2020 00:32:19 +0100 Subject: [PATCH 171/228] Organise the status response into sub-sections --- cmd/rove-server/internal/routes.go | 38 +- proto/roveapi/roveapi.pb.go | 632 +++++++++++++++++++---------- proto/roveapi/roveapi.proto | 70 ++-- 3 files changed, 481 insertions(+), 259 deletions(-) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 7174c31..86becd7 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -85,23 +85,29 @@ func (s *Server) Status(ctx context.Context, req *roveapi.StatusRequest) (respon } response = &roveapi.StatusResponse{ - Name: rover.Name, - Position: &roveapi.Vector{ - X: int32(rover.Pos.X), - Y: int32(rover.Pos.Y), + Readings: &roveapi.RoverReadings{ + Position: &roveapi.Vector{ + X: int32(rover.Pos.X), + Y: int32(rover.Pos.Y), + }, + Logs: logs, + Wind: s.world.Wind, + }, + Spec: &roveapi.RoverSpecifications{ + Name: rover.Name, + Range: int32(rover.Range), + Capacity: int32(rover.Capacity), + MaximumIntegrity: int32(rover.MaximumIntegrity), + MaximumCharge: int32(rover.MaximumCharge), + }, + Status: &roveapi.RoverStatus{ + Bearing: rover.Bearing, + Inventory: inv, + Integrity: int32(rover.Integrity), + Charge: int32(rover.Charge), + QueuedCommands: queued, + SailPosition: rover.SailPosition, }, - Bearing: rover.Bearing, - Range: int32(rover.Range), - Inventory: inv, - Capacity: int32(rover.Capacity), - Integrity: int32(rover.Integrity), - MaximumIntegrity: int32(rover.MaximumIntegrity), - Charge: int32(rover.Charge), - MaximumCharge: int32(rover.MaximumCharge), - QueuedCommands: queued, - SailPosition: rover.SailPosition, - Logs: logs, - Wind: s.world.Wind, } } return response, nil diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index 4fbea99..d5f0a46 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -1061,46 +1061,267 @@ func (x *Vector) GetY() int32 { return 0 } -// StatusResponse is the response given to a status request -type StatusResponse struct { +type RoverSpecifications struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // The name of the rover Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - // Position of the rover in world coordinates - Position *Vector `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` - // The current direction of the rover - Bearing Bearing `protobuf:"varint,3,opt,name=bearing,proto3,enum=roveapi.Bearing" json:"bearing,omitempty"` // The range of this rover's radar and broadcasting - Range int32 `protobuf:"varint,4,opt,name=range,proto3" json:"range,omitempty"` - // The items in the rover inventory - Inventory []byte `protobuf:"bytes,5,opt,name=inventory,proto3" json:"inventory,omitempty"` + Range int32 `protobuf:"varint,2,opt,name=range,proto3" json:"range,omitempty"` // The capacity of the inventory - Capacity int32 `protobuf:"varint,6,opt,name=capacity,proto3" json:"capacity,omitempty"` - // The current health of the rover - Integrity int32 `protobuf:"varint,7,opt,name=integrity,proto3" json:"integrity,omitempty"` + Capacity int32 `protobuf:"varint,3,opt,name=capacity,proto3" json:"capacity,omitempty"` // The maximum health of the rover - MaximumIntegrity int32 `protobuf:"varint,8,opt,name=maximumIntegrity,proto3" json:"maximumIntegrity,omitempty"` - // The energy stored in the rover - Charge int32 `protobuf:"varint,9,opt,name=charge,proto3" json:"charge,omitempty"` + MaximumIntegrity int32 `protobuf:"varint,4,opt,name=maximumIntegrity,proto3" json:"maximumIntegrity,omitempty"` // The max energy the rover can store - MaximumCharge int32 `protobuf:"varint,10,opt,name=maximumCharge,proto3" json:"maximumCharge,omitempty"` + MaximumCharge int32 `protobuf:"varint,5,opt,name=maximumCharge,proto3" json:"maximumCharge,omitempty"` +} + +func (x *RoverSpecifications) Reset() { + *x = RoverSpecifications{} + if protoimpl.UnsafeEnabled { + mi := &file_roveapi_roveapi_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RoverSpecifications) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoverSpecifications) ProtoMessage() {} + +func (x *RoverSpecifications) ProtoReflect() protoreflect.Message { + mi := &file_roveapi_roveapi_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RoverSpecifications.ProtoReflect.Descriptor instead. +func (*RoverSpecifications) Descriptor() ([]byte, []int) { + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{13} +} + +func (x *RoverSpecifications) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *RoverSpecifications) GetRange() int32 { + if x != nil { + return x.Range + } + return 0 +} + +func (x *RoverSpecifications) GetCapacity() int32 { + if x != nil { + return x.Capacity + } + return 0 +} + +func (x *RoverSpecifications) GetMaximumIntegrity() int32 { + if x != nil { + return x.MaximumIntegrity + } + return 0 +} + +func (x *RoverSpecifications) GetMaximumCharge() int32 { + if x != nil { + return x.MaximumCharge + } + return 0 +} + +type RoverStatus struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The current direction of the rover + Bearing Bearing `protobuf:"varint,1,opt,name=bearing,proto3,enum=roveapi.Bearing" json:"bearing,omitempty"` // The current position of the sails - SailPosition SailPosition `protobuf:"varint,11,opt,name=sailPosition,proto3,enum=roveapi.SailPosition" json:"sailPosition,omitempty"` + SailPosition SailPosition `protobuf:"varint,2,opt,name=sailPosition,proto3,enum=roveapi.SailPosition" json:"sailPosition,omitempty"` + // The items in the rover inventory + Inventory []byte `protobuf:"bytes,3,opt,name=inventory,proto3" json:"inventory,omitempty"` + // The current health of the rover + Integrity int32 `protobuf:"varint,4,opt,name=integrity,proto3" json:"integrity,omitempty"` + // The energy stored in the rover + Charge int32 `protobuf:"varint,5,opt,name=charge,proto3" json:"charge,omitempty"` // The set of currently queued commands - QueuedCommands []*Command `protobuf:"bytes,12,rep,name=queuedCommands,proto3" json:"queuedCommands,omitempty"` - // The most recent logs - Logs []*Log `protobuf:"bytes,13,rep,name=logs,proto3" json:"logs,omitempty"` + QueuedCommands []*Command `protobuf:"bytes,6,rep,name=queuedCommands,proto3" json:"queuedCommands,omitempty"` +} + +func (x *RoverStatus) Reset() { + *x = RoverStatus{} + if protoimpl.UnsafeEnabled { + mi := &file_roveapi_roveapi_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RoverStatus) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoverStatus) ProtoMessage() {} + +func (x *RoverStatus) ProtoReflect() protoreflect.Message { + mi := &file_roveapi_roveapi_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RoverStatus.ProtoReflect.Descriptor instead. +func (*RoverStatus) Descriptor() ([]byte, []int) { + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{14} +} + +func (x *RoverStatus) GetBearing() Bearing { + if x != nil { + return x.Bearing + } + return Bearing_BearingUnknown +} + +func (x *RoverStatus) GetSailPosition() SailPosition { + if x != nil { + return x.SailPosition + } + return SailPosition_UnknownSailPosition +} + +func (x *RoverStatus) GetInventory() []byte { + if x != nil { + return x.Inventory + } + return nil +} + +func (x *RoverStatus) GetIntegrity() int32 { + if x != nil { + return x.Integrity + } + return 0 +} + +func (x *RoverStatus) GetCharge() int32 { + if x != nil { + return x.Charge + } + return 0 +} + +func (x *RoverStatus) GetQueuedCommands() []*Command { + if x != nil { + return x.QueuedCommands + } + return nil +} + +type RoverReadings struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Position of the rover in world coordinates + Position *Vector `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` // The current wind direction - Wind Bearing `protobuf:"varint,14,opt,name=wind,proto3,enum=roveapi.Bearing" json:"wind,omitempty"` + Wind Bearing `protobuf:"varint,2,opt,name=wind,proto3,enum=roveapi.Bearing" json:"wind,omitempty"` + // The most recent logs + Logs []*Log `protobuf:"bytes,3,rep,name=logs,proto3" json:"logs,omitempty"` +} + +func (x *RoverReadings) Reset() { + *x = RoverReadings{} + if protoimpl.UnsafeEnabled { + mi := &file_roveapi_roveapi_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RoverReadings) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoverReadings) ProtoMessage() {} + +func (x *RoverReadings) ProtoReflect() protoreflect.Message { + mi := &file_roveapi_roveapi_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RoverReadings.ProtoReflect.Descriptor instead. +func (*RoverReadings) Descriptor() ([]byte, []int) { + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{15} +} + +func (x *RoverReadings) GetPosition() *Vector { + if x != nil { + return x.Position + } + return nil +} + +func (x *RoverReadings) GetWind() Bearing { + if x != nil { + return x.Wind + } + return Bearing_BearingUnknown +} + +func (x *RoverReadings) GetLogs() []*Log { + if x != nil { + return x.Logs + } + return nil +} + +// StatusResponse is the response given to a status request +type StatusResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The static rover information + Spec *RoverSpecifications `protobuf:"bytes,1,opt,name=spec,proto3" json:"spec,omitempty"` + // Current rover status + Status *RoverStatus `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"` + // Current rover readings + Readings *RoverReadings `protobuf:"bytes,3,opt,name=readings,proto3" json:"readings,omitempty"` } func (x *StatusResponse) Reset() { *x = StatusResponse{} if protoimpl.UnsafeEnabled { - mi := &file_roveapi_roveapi_proto_msgTypes[13] + mi := &file_roveapi_roveapi_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1113,7 +1334,7 @@ func (x *StatusResponse) String() string { func (*StatusResponse) ProtoMessage() {} func (x *StatusResponse) ProtoReflect() protoreflect.Message { - mi := &file_roveapi_roveapi_proto_msgTypes[13] + mi := &file_roveapi_roveapi_proto_msgTypes[16] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1126,107 +1347,30 @@ func (x *StatusResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use StatusResponse.ProtoReflect.Descriptor instead. func (*StatusResponse) Descriptor() ([]byte, []int) { - return file_roveapi_roveapi_proto_rawDescGZIP(), []int{13} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{16} } -func (x *StatusResponse) GetName() string { +func (x *StatusResponse) GetSpec() *RoverSpecifications { if x != nil { - return x.Name - } - return "" -} - -func (x *StatusResponse) GetPosition() *Vector { - if x != nil { - return x.Position + return x.Spec } return nil } -func (x *StatusResponse) GetBearing() Bearing { +func (x *StatusResponse) GetStatus() *RoverStatus { if x != nil { - return x.Bearing - } - return Bearing_BearingUnknown -} - -func (x *StatusResponse) GetRange() int32 { - if x != nil { - return x.Range - } - return 0 -} - -func (x *StatusResponse) GetInventory() []byte { - if x != nil { - return x.Inventory + return x.Status } return nil } -func (x *StatusResponse) GetCapacity() int32 { +func (x *StatusResponse) GetReadings() *RoverReadings { if x != nil { - return x.Capacity - } - return 0 -} - -func (x *StatusResponse) GetIntegrity() int32 { - if x != nil { - return x.Integrity - } - return 0 -} - -func (x *StatusResponse) GetMaximumIntegrity() int32 { - if x != nil { - return x.MaximumIntegrity - } - return 0 -} - -func (x *StatusResponse) GetCharge() int32 { - if x != nil { - return x.Charge - } - return 0 -} - -func (x *StatusResponse) GetMaximumCharge() int32 { - if x != nil { - return x.MaximumCharge - } - return 0 -} - -func (x *StatusResponse) GetSailPosition() SailPosition { - if x != nil { - return x.SailPosition - } - return SailPosition_UnknownSailPosition -} - -func (x *StatusResponse) GetQueuedCommands() []*Command { - if x != nil { - return x.QueuedCommands + return x.Readings } return nil } -func (x *StatusResponse) GetLogs() []*Log { - if x != nil { - return x.Logs - } - return nil -} - -func (x *StatusResponse) GetWind() Bearing { - if x != nil { - return x.Wind - } - return Bearing_BearingUnknown -} - var File_roveapi_roveapi_proto protoreflect.FileDescriptor var file_roveapi_roveapi_proto_rawDesc = []byte{ @@ -1289,93 +1433,105 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, - 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0x92, 0x04, 0x0a, - 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, - 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x14, 0x0a, 0x05, - 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, - 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, - 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, - 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, - 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x08, + 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xad, 0x01, 0x0a, + 0x13, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1a, + 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, + 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, - 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, - 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, - 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, - 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, - 0x61, 0x72, 0x67, 0x65, 0x12, 0x39, 0x0a, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x52, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x38, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, - 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, - 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x20, 0x0a, 0x04, 0x6c, 0x6f, 0x67, - 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, - 0x69, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x12, 0x24, 0x0a, 0x04, 0x77, - 0x69, 0x6e, 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x04, 0x77, 0x69, 0x6e, - 0x64, 0x2a, 0x53, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, - 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x74, 0x6f, - 0x67, 0x67, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x10, 0x02, - 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x72, - 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, - 0x63, 0x61, 0x73, 0x74, 0x10, 0x05, 0x2a, 0x83, 0x01, 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, - 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, - 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, - 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, - 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, - 0x75, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x04, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, - 0x74, 0x68, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x57, 0x65, 0x73, - 0x74, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, 0x73, 0x74, 0x10, 0x07, 0x12, 0x0d, 0x0a, - 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x08, 0x2a, 0x5a, 0x0a, 0x06, - 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, - 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, - 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, - 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, - 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, - 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x2a, 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, - 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, - 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, - 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, - 0x03, 0x2a, 0x4c, 0x0a, 0x0c, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x12, 0x17, 0x0a, 0x13, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x53, 0x61, 0x69, 0x6c, - 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x61, - 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, - 0x53, 0x6f, 0x6c, 0x61, 0x72, 0x43, 0x68, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x32, - 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, - 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, - 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, - 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, + 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, + 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x22, 0x82, 0x02, 0x0a, + 0x0b, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2a, 0x0a, 0x07, + 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, + 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x39, 0x0a, 0x0c, 0x73, 0x61, 0x69, 0x6c, + 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, + 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, + 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x38, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, + 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x73, 0x22, 0x84, 0x01, 0x0a, 0x0d, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x69, + 0x6e, 0x67, 0x73, 0x12, 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x24, 0x0a, 0x04, 0x77, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, + 0x52, 0x04, 0x77, 0x69, 0x6e, 0x64, 0x12, 0x20, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x03, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4c, + 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x22, 0xa4, 0x01, 0x0a, 0x0e, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x73, + 0x70, 0x65, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, 0x12, 0x2c, 0x0a, + 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x32, 0x0a, 0x08, 0x72, + 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x61, + 0x64, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x2a, + 0x53, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, + 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x74, 0x6f, 0x67, 0x67, + 0x6c, 0x65, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x10, 0x02, 0x12, 0x09, + 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, + 0x61, 0x69, 0x72, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, + 0x73, 0x74, 0x10, 0x05, 0x2a, 0x83, 0x01, 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, + 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, + 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, + 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, + 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, + 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x04, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, + 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, + 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, 0x73, 0x74, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, + 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x08, 0x2a, 0x5a, 0x0a, 0x06, 0x4f, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, + 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, + 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, + 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, + 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, + 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x2a, 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, + 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, + 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, + 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x2a, + 0x4c, 0x0a, 0x0c, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x17, 0x0a, 0x13, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x61, 0x74, 0x63, + 0x68, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x6f, + 0x6c, 0x61, 0x72, 0x43, 0x68, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x32, 0xcf, 0x02, + 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, + 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, + 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, + 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, + 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, + 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1391,7 +1547,7 @@ func file_roveapi_roveapi_proto_rawDescGZIP() []byte { } var file_roveapi_roveapi_proto_enumTypes = make([]protoimpl.EnumInfo, 5) -var file_roveapi_roveapi_proto_msgTypes = make([]protoimpl.MessageInfo, 14) +var file_roveapi_roveapi_proto_msgTypes = make([]protoimpl.MessageInfo, 17) var file_roveapi_roveapi_proto_goTypes = []interface{}{ (CommandType)(0), // 0: roveapi.CommandType (Bearing)(0), // 1: roveapi.Bearing @@ -1411,7 +1567,10 @@ var file_roveapi_roveapi_proto_goTypes = []interface{}{ (*StatusRequest)(nil), // 15: roveapi.StatusRequest (*Log)(nil), // 16: roveapi.Log (*Vector)(nil), // 17: roveapi.Vector - (*StatusResponse)(nil), // 18: roveapi.StatusResponse + (*RoverSpecifications)(nil), // 18: roveapi.RoverSpecifications + (*RoverStatus)(nil), // 19: roveapi.RoverStatus + (*RoverReadings)(nil), // 20: roveapi.RoverReadings + (*StatusResponse)(nil), // 21: roveapi.StatusResponse } var file_roveapi_roveapi_proto_depIdxs = []int32{ 8, // 0: roveapi.RegisterResponse.account:type_name -> roveapi.Account @@ -1423,27 +1582,30 @@ var file_roveapi_roveapi_proto_depIdxs = []int32{ 3, // 6: roveapi.RadarResponse.tiles:type_name -> roveapi.Tile 2, // 7: roveapi.RadarResponse.objects:type_name -> roveapi.Object 8, // 8: roveapi.StatusRequest.account:type_name -> roveapi.Account - 17, // 9: roveapi.StatusResponse.position:type_name -> roveapi.Vector - 1, // 10: roveapi.StatusResponse.bearing:type_name -> roveapi.Bearing - 4, // 11: roveapi.StatusResponse.sailPosition:type_name -> roveapi.SailPosition - 10, // 12: roveapi.StatusResponse.queuedCommands:type_name -> roveapi.Command - 16, // 13: roveapi.StatusResponse.logs:type_name -> roveapi.Log - 1, // 14: roveapi.StatusResponse.wind:type_name -> roveapi.Bearing - 5, // 15: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest - 7, // 16: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest - 11, // 17: roveapi.Rove.Command:input_type -> roveapi.CommandRequest - 13, // 18: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest - 15, // 19: roveapi.Rove.Status:input_type -> roveapi.StatusRequest - 6, // 20: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse - 9, // 21: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse - 12, // 22: roveapi.Rove.Command:output_type -> roveapi.CommandResponse - 14, // 23: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse - 18, // 24: roveapi.Rove.Status:output_type -> roveapi.StatusResponse - 20, // [20:25] is the sub-list for method output_type - 15, // [15:20] is the sub-list for method input_type - 15, // [15:15] is the sub-list for extension type_name - 15, // [15:15] is the sub-list for extension extendee - 0, // [0:15] is the sub-list for field type_name + 1, // 9: roveapi.RoverStatus.bearing:type_name -> roveapi.Bearing + 4, // 10: roveapi.RoverStatus.sailPosition:type_name -> roveapi.SailPosition + 10, // 11: roveapi.RoverStatus.queuedCommands:type_name -> roveapi.Command + 17, // 12: roveapi.RoverReadings.position:type_name -> roveapi.Vector + 1, // 13: roveapi.RoverReadings.wind:type_name -> roveapi.Bearing + 16, // 14: roveapi.RoverReadings.logs:type_name -> roveapi.Log + 18, // 15: roveapi.StatusResponse.spec:type_name -> roveapi.RoverSpecifications + 19, // 16: roveapi.StatusResponse.status:type_name -> roveapi.RoverStatus + 20, // 17: roveapi.StatusResponse.readings:type_name -> roveapi.RoverReadings + 5, // 18: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest + 7, // 19: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest + 11, // 20: roveapi.Rove.Command:input_type -> roveapi.CommandRequest + 13, // 21: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest + 15, // 22: roveapi.Rove.Status:input_type -> roveapi.StatusRequest + 6, // 23: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse + 9, // 24: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse + 12, // 25: roveapi.Rove.Command:output_type -> roveapi.CommandResponse + 14, // 26: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse + 21, // 27: roveapi.Rove.Status:output_type -> roveapi.StatusResponse + 23, // [23:28] is the sub-list for method output_type + 18, // [18:23] is the sub-list for method input_type + 18, // [18:18] is the sub-list for extension type_name + 18, // [18:18] is the sub-list for extension extendee + 0, // [0:18] is the sub-list for field type_name } func init() { file_roveapi_roveapi_proto_init() } @@ -1609,6 +1771,42 @@ func file_roveapi_roveapi_proto_init() { } } file_roveapi_roveapi_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RoverSpecifications); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_roveapi_roveapi_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RoverStatus); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_roveapi_roveapi_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RoverReadings); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_roveapi_roveapi_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*StatusResponse); i { case 0: return &v.state @@ -1627,7 +1825,7 @@ func file_roveapi_roveapi_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_roveapi_roveapi_proto_rawDesc, NumEnums: 5, - NumMessages: 14, + NumMessages: 17, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index 33bbc25..cc7826a 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -231,47 +231,65 @@ enum SailPosition { SolarCharging = 2; } -// StatusResponse is the response given to a status request -message StatusResponse { +message RoverSpecifications { + // The name of the rover string name = 1; - // Position of the rover in world coordinates - Vector position = 2; - - // The current direction of the rover - Bearing bearing = 3; - // The range of this rover's radar and broadcasting - int32 range = 4; - - // The items in the rover inventory - bytes inventory = 5; + int32 range = 2; // The capacity of the inventory - int32 capacity = 6; - - // The current health of the rover - int32 integrity = 7; + int32 capacity = 3; // The maximum health of the rover - int32 maximumIntegrity = 8; - - // The energy stored in the rover - int32 charge = 9; + int32 maximumIntegrity = 4; // The max energy the rover can store - int32 maximumCharge = 10; + int32 maximumCharge = 5; +} + +message RoverStatus { + + // The current direction of the rover + Bearing bearing = 1; // The current position of the sails - SailPosition sailPosition = 11; + SailPosition sailPosition = 2; + + // The items in the rover inventory + bytes inventory = 3; + + // The current health of the rover + int32 integrity = 4; + + // The energy stored in the rover + int32 charge = 5; // The set of currently queued commands - repeated Command queuedCommands = 12; + repeated Command queuedCommands = 6; +} - // The most recent logs - repeated Log logs = 13; +message RoverReadings { + // Position of the rover in world coordinates + Vector position = 1; // The current wind direction - Bearing wind = 14; + Bearing wind = 2; + + // The most recent logs + repeated Log logs = 3; +} + +// StatusResponse is the response given to a status request +message StatusResponse { + + // The static rover information + RoverSpecifications spec = 1; + + // Current rover status + RoverStatus status = 2; + + // Current rover readings + RoverReadings readings = 3; } \ No newline at end of file From 13e4d6a5e609bac7452bc928107e9155e946f648 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 23 Jul 2020 00:34:57 +0100 Subject: [PATCH 172/228] Remove an old log left in --- pkg/rove/world.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 591ba8e..ea91fbc 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -542,8 +542,6 @@ func (w *World) Tick() { // Reset the move ticks r.MoveTicks = 0 } - - log.Print(ticksToMove) } // Increment the current tick count From 46d904acc6889cf7b1335ce2df371f70d653acd8 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 23 Jul 2020 16:41:08 +0100 Subject: [PATCH 173/228] Rename and comment ticksPerNormalMove --- pkg/rove/world.go | 9 +++++---- pkg/rove/world_test.go | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index ea91fbc..a81cf05 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -11,7 +11,8 @@ import ( ) const ( - TicksPerNormalMove = 4 + // ticksPerNormalMove defines the number of ticks it should take for a "normal" speed move + ticksPerNormalMove = 4 ) // CommandStream is a list of commands to execute in order @@ -515,16 +516,16 @@ func (w *World) Tick() { switch diff { case 0: // Going with the wind, travel at base speed of once every 4 ticks - ticksToMove = TicksPerNormalMove + ticksToMove = ticksPerNormalMove case 1: // At a slight angle, we can go a little faster - ticksToMove = TicksPerNormalMove / 2 + ticksToMove = ticksPerNormalMove / 2 case 2: // Perpendicular to wind, max speed ticksToMove = 1 case 3: // Heading at 45 degrees into the wind, back to min speed - ticksToMove = TicksPerNormalMove + ticksToMove = ticksPerNormalMove case 4: // Heading durectly into the wind, no movement at all default: diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index a3c2f47..db9fcb6 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -419,7 +419,7 @@ func TestWorld_Sailing(t *testing.T) { assert.Equal(t, maths.Vector{Y: 0}, info.Pos) // Loop a few more times - for i := 0; i < TicksPerNormalMove-2; i++ { + for i := 0; i < ticksPerNormalMove-2; i++ { world.Tick() info, err := world.GetRover(name) assert.NoError(t, err) @@ -441,7 +441,7 @@ func TestWorld_Sailing(t *testing.T) { assert.Equal(t, roveapi.Bearing_South, b) // Tick a bunch, we should never move - for i := 0; i < TicksPerNormalMove*2; i++ { + for i := 0; i < ticksPerNormalMove*2; i++ { world.Tick() info, err := world.GetRover(name) assert.NoError(t, err) From 8279a08a376edc93e53bcff552aede6a2398ff28 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 23 Jul 2020 16:47:39 +0100 Subject: [PATCH 174/228] Limit the log entries to a max number --- pkg/rove/rover.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/rove/rover.go b/pkg/rove/rover.go index fb13ddc..ce0edcd 100644 --- a/pkg/rove/rover.go +++ b/pkg/rove/rover.go @@ -13,6 +13,10 @@ import ( "github.com/mdiluz/rove/proto/roveapi" ) +const ( + maxLogEntries = 16 +) + // RoverLogEntry describes a single log entry for the rover type RoverLogEntry struct { // Time is the timestamp of the entry @@ -89,6 +93,11 @@ func (r *Rover) AddLogEntryf(format string, args ...interface{}) { Text: text, }, ) + + // Limit the number of logs + if len(r.Logs) > maxLogEntries { + r.Logs = r.Logs[len(r.Logs)-maxLogEntries:] + } } var wordsFile = os.Getenv("WORDS_FILE") From 3bfc91b8f6352e9d5a88766119e15f8072d2b47e Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 23 Jul 2020 16:56:28 +0100 Subject: [PATCH 175/228] Add command test for stashing --- pkg/rove/command_test.go | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index f55c6cb..0dc2f11 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -48,7 +48,31 @@ func TestCommand_Turn(t *testing.T) { } func TestCommand_Stash(t *testing.T) { - // TODO: Test the stash command + w := NewWorld(8) + name, err := w.SpawnRover() + assert.NoError(t, err) + + info, err := w.GetRover(name) + assert.NoError(t, err) + assert.Empty(t, info.Inventory) + + // Drop a pickup below us + w.Atlas.SetObject(info.Pos, Object{Type: roveapi.Object_RockSmall}) + + // Try and stash it + err = w.Enqueue(name, &roveapi.Command{Command: roveapi.CommandType_stash}) + assert.NoError(t, err) + w.Tick() + + // Check we now have it in the inventory + info, err = w.GetRover(name) + assert.NoError(t, err) + assert.Equal(t, 1, len(info.Inventory)) + assert.Equal(t, Object{Type: roveapi.Object_RockSmall}, info.Inventory[0]) + + // Check it's no longer on the atlas + _, obj := w.Atlas.QueryPosition(info.Pos) + assert.Equal(t, Object{Type: roveapi.Object_ObjectUnknown}, obj) } func TestCommand_Repair(t *testing.T) { From 8a8a27ab47713ec568190a62eaa379f7bb3857e6 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 23 Jul 2020 18:37:54 +0100 Subject: [PATCH 176/228] Add a test for the repair command --- pkg/rove/command_test.go | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index 0dc2f11..ec9c1b5 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -3,6 +3,7 @@ package rove import ( "testing" + "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/proto/roveapi" "github.com/stretchr/testify/assert" ) @@ -76,7 +77,43 @@ func TestCommand_Stash(t *testing.T) { } func TestCommand_Repair(t *testing.T) { - // TODO: Test the repair command + w := NewWorld(8) + name, err := w.SpawnRover() + assert.NoError(t, err) + + info, err := w.GetRover(name) + assert.NoError(t, err) + assert.Equal(t, info.MaximumIntegrity, info.Integrity) + + // Put a blocking rock to the north + w.Atlas.SetObject(info.Pos.Added(maths.Vector{X: 0, Y: 1}), Object{Type: roveapi.Object_RockLarge}) + + // Try and move and make sure we're blocked + newpos, err := w.TryMoveRover(name, roveapi.Bearing_North) + assert.NoError(t, err) + assert.Equal(t, info.Pos, newpos) + + // Check we're damaged + info, err = w.GetRover(name) + assert.NoError(t, err) + assert.Equal(t, info.MaximumIntegrity-1, info.Integrity) + + // Stash a repair object + w.Atlas.SetObject(info.Pos, Object{Type: roveapi.Object_RockSmall}) + obj, err := w.RoverStash(name) + assert.NoError(t, err) + assert.Equal(t, roveapi.Object_RockSmall, obj) + + // Enqueue the repair and tick + err = w.Enqueue(name, &roveapi.Command{Command: roveapi.CommandType_repair}) + assert.NoError(t, err) + w.Tick() + + // Check we're repaired + info, err = w.GetRover(name) + assert.NoError(t, err) + assert.Equal(t, info.MaximumIntegrity, info.Integrity) + assert.Equal(t, 0, len(info.Inventory)) } func TestCommand_Broadcast(t *testing.T) { From 8cc3b9155ec66ff1087b74fd46e86923b24426ab Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 23 Jul 2020 18:40:32 +0100 Subject: [PATCH 177/228] Implement broadcast command test --- pkg/rove/command_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index ec9c1b5..b0f2336 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -117,7 +117,18 @@ func TestCommand_Repair(t *testing.T) { } func TestCommand_Broadcast(t *testing.T) { - // TODO: Test the stash command + w := NewWorld(8) + name, err := w.SpawnRover() + assert.NoError(t, err) + + // Enqueue the broadcast and tick + err = w.Enqueue(name, &roveapi.Command{Command: roveapi.CommandType_broadcast, Broadcast: []byte("ABC")}) + assert.NoError(t, err) + w.Tick() + + info, err := w.GetRover(name) + assert.NoError(t, err) + assert.Contains(t, info.Logs[len(info.Logs)-1].Text, "ABC") } func TestCommand_Invalid(t *testing.T) { From 41cd93e9866287a421f02a740e557e62170f4378 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 23 Jul 2020 18:41:12 +0100 Subject: [PATCH 178/228] Add command test for no command as error --- pkg/rove/command_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index b0f2336..d73b25c 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -132,5 +132,10 @@ func TestCommand_Broadcast(t *testing.T) { } func TestCommand_Invalid(t *testing.T) { - // TODO: Test an invalid command + w := NewWorld(8) + name, err := w.SpawnRover() + assert.NoError(t, err) + + err = w.Enqueue(name, &roveapi.Command{Command: roveapi.CommandType_none}) + assert.Error(t, err) } From 2c1bb8077931bc75b678d0b08aa25240d3b6e1a5 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 23 Jul 2020 19:01:16 +0100 Subject: [PATCH 179/228] Add salvage command Slight refactor to re-use command variables Also fixes the cmdline client turn command --- cmd/rove/main.go | 8 +- pkg/rove/command_test.go | 4 +- pkg/rove/world.go | 12 +- proto/roveapi/roveapi.pb.go | 481 +++++++++++++++++++++--------------- proto/roveapi/roveapi.proto | 26 +- 5 files changed, 306 insertions(+), 225 deletions(-) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 01e16ae..97a7a24 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -243,8 +243,8 @@ func InnerMain(command string, args ...string) error { } commands = append(commands, &roveapi.Command{ - Command: roveapi.CommandType_broadcast, - Broadcast: []byte(args[i]), + Command: roveapi.CommandType_turn, + Bearing: b, }, ) case "broadcast": @@ -256,8 +256,8 @@ func InnerMain(command string, args ...string) error { } commands = append(commands, &roveapi.Command{ - Command: roveapi.CommandType_broadcast, - Broadcast: []byte(args[i]), + Command: roveapi.CommandType_broadcast, + Data: []byte(args[i]), }, ) default: diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index d73b25c..8f4dd36 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -39,7 +39,7 @@ func TestCommand_Turn(t *testing.T) { a, err := w.SpawnRover() assert.NoError(t, err) - err = w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_turn, Turn: roveapi.Bearing_NorthWest}) + err = w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_turn, Bearing: roveapi.Bearing_NorthWest}) assert.NoError(t, err) w.Tick() @@ -122,7 +122,7 @@ func TestCommand_Broadcast(t *testing.T) { assert.NoError(t, err) // Enqueue the broadcast and tick - err = w.Enqueue(name, &roveapi.Command{Command: roveapi.CommandType_broadcast, Broadcast: []byte("ABC")}) + err = w.Enqueue(name, &roveapi.Command{Command: roveapi.CommandType_broadcast, Data: []byte("ABC")}) assert.NoError(t, err) w.Tick() diff --git a/pkg/rove/world.go b/pkg/rove/world.go index a81cf05..50348dc 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -435,16 +435,16 @@ func (w *World) Enqueue(rover string, commands ...*roveapi.Command) error { for _, c := range commands { switch c.Command { case roveapi.CommandType_broadcast: - if len(c.GetBroadcast()) > 3 { - return fmt.Errorf("too many characters in message (limit 3): %d", len(c.GetBroadcast())) + if len(c.GetData()) > 3 { + return fmt.Errorf("too many characters in message (limit 3): %d", len(c.GetData())) } - for _, b := range c.GetBroadcast() { + for _, b := range c.GetData() { if b < 37 || b > 126 { return fmt.Errorf("invalid message character: %c", b) } } case roveapi.CommandType_turn: - if c.GetTurn() == roveapi.Bearing_BearingUnknown { + if c.GetBearing() == roveapi.Bearing_BearingUnknown { return fmt.Errorf("turn command given unknown bearing") } case roveapi.CommandType_toggle: @@ -569,12 +569,12 @@ func (w *World) ExecuteCommand(c *roveapi.Command, rover string) (err error) { } case roveapi.CommandType_broadcast: - if err := w.RoverBroadcast(rover, c.GetBroadcast()); err != nil { + if err := w.RoverBroadcast(rover, c.GetData()); err != nil { return err } case roveapi.CommandType_turn: - if _, err := w.RoverTurn(rover, c.GetTurn()); err != nil { + if _, err := w.RoverTurn(rover, c.GetBearing()); err != nil { return err } diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index d5f0a46..c5e458c 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -41,14 +41,16 @@ const ( CommandType_none CommandType = 0 // Toggles the sails, either catching the wind, or charging from the sun CommandType_toggle CommandType = 1 - // Turns the rover in the specified bearing, requires data + // Turns the rover in the specified bearing (requires bearing) CommandType_turn CommandType = 2 // Stashes item at current location in rover inventory CommandType_stash CommandType = 3 // Repairs the rover using an inventory object CommandType_repair CommandType = 4 - // Broadcasts a message to nearby rovers, requires data + // Broadcasts a message to nearby rovers (requires data) CommandType_broadcast CommandType = 5 + // Salvages a neighboring dormant rover for parts (requres bearing and salvage) + CommandType_salvage CommandType = 6 ) // Enum value maps for CommandType. @@ -60,6 +62,7 @@ var ( 3: "stash", 4: "repair", 5: "broadcast", + 6: "salvage", } CommandType_value = map[string]int32{ "none": 0, @@ -68,6 +71,7 @@ var ( "stash": 3, "repair": 4, "broadcast": 5, + "salvage": 6, } ) @@ -167,6 +171,53 @@ func (Bearing) EnumDescriptor() ([]byte, []int) { return file_roveapi_roveapi_proto_rawDescGZIP(), []int{1} } +type SalvageType int32 + +const ( + SalvageType_SalvageUnknown SalvageType = 0 + // Salvage a nearby rover for parts + SalvageType_SalvageParts SalvageType = 1 +) + +// Enum value maps for SalvageType. +var ( + SalvageType_name = map[int32]string{ + 0: "SalvageUnknown", + 1: "SalvageParts", + } + SalvageType_value = map[string]int32{ + "SalvageUnknown": 0, + "SalvageParts": 1, + } +) + +func (x SalvageType) Enum() *SalvageType { + p := new(SalvageType) + *p = x + return p +} + +func (x SalvageType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (SalvageType) Descriptor() protoreflect.EnumDescriptor { + return file_roveapi_roveapi_proto_enumTypes[2].Descriptor() +} + +func (SalvageType) Type() protoreflect.EnumType { + return &file_roveapi_roveapi_proto_enumTypes[2] +} + +func (x SalvageType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use SalvageType.Descriptor instead. +func (SalvageType) EnumDescriptor() ([]byte, []int) { + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{2} +} + // Types of objects type Object int32 @@ -212,11 +263,11 @@ func (x Object) String() string { } func (Object) Descriptor() protoreflect.EnumDescriptor { - return file_roveapi_roveapi_proto_enumTypes[2].Descriptor() + return file_roveapi_roveapi_proto_enumTypes[3].Descriptor() } func (Object) Type() protoreflect.EnumType { - return &file_roveapi_roveapi_proto_enumTypes[2] + return &file_roveapi_roveapi_proto_enumTypes[3] } func (x Object) Number() protoreflect.EnumNumber { @@ -225,7 +276,7 @@ func (x Object) Number() protoreflect.EnumNumber { // Deprecated: Use Object.Descriptor instead. func (Object) EnumDescriptor() ([]byte, []int) { - return file_roveapi_roveapi_proto_rawDescGZIP(), []int{2} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{3} } type Tile int32 @@ -268,11 +319,11 @@ func (x Tile) String() string { } func (Tile) Descriptor() protoreflect.EnumDescriptor { - return file_roveapi_roveapi_proto_enumTypes[3].Descriptor() + return file_roveapi_roveapi_proto_enumTypes[4].Descriptor() } func (Tile) Type() protoreflect.EnumType { - return &file_roveapi_roveapi_proto_enumTypes[3] + return &file_roveapi_roveapi_proto_enumTypes[4] } func (x Tile) Number() protoreflect.EnumNumber { @@ -281,7 +332,7 @@ func (x Tile) Number() protoreflect.EnumNumber { // Deprecated: Use Tile.Descriptor instead. func (Tile) EnumDescriptor() ([]byte, []int) { - return file_roveapi_roveapi_proto_rawDescGZIP(), []int{3} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{4} } // SailPosition represents the position of the sola sail @@ -320,11 +371,11 @@ func (x SailPosition) String() string { } func (SailPosition) Descriptor() protoreflect.EnumDescriptor { - return file_roveapi_roveapi_proto_enumTypes[4].Descriptor() + return file_roveapi_roveapi_proto_enumTypes[5].Descriptor() } func (SailPosition) Type() protoreflect.EnumType { - return &file_roveapi_roveapi_proto_enumTypes[4] + return &file_roveapi_roveapi_proto_enumTypes[5] } func (x SailPosition) Number() protoreflect.EnumNumber { @@ -333,7 +384,7 @@ func (x SailPosition) Number() protoreflect.EnumNumber { // Deprecated: Use SailPosition.Descriptor instead. func (SailPosition) EnumDescriptor() ([]byte, []int) { - return file_roveapi_roveapi_proto_rawDescGZIP(), []int{4} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{5} } // ServerStatusRequest is an empty placeholder @@ -624,11 +675,13 @@ type Command struct { // The command type Command CommandType `protobuf:"varint,1,opt,name=command,proto3,enum=roveapi.CommandType" json:"command,omitempty"` - // A simple message, must be composed of printable ASCII glyphs (32-126) - // maximum of three characters - Broadcast []byte `protobuf:"bytes,2,opt,name=broadcast,proto3" json:"broadcast,omitempty"` - // The bearing for the rover to turn to - Turn Bearing `protobuf:"varint,3,opt,name=turn,proto3,enum=roveapi.Bearing" json:"turn,omitempty"` + // broadcast - a simple message, must be composed of up to 3 printable ASCII glyphs (32-126) + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + // move - the bearing for the rover to turn to + // salvage - the direction of the rover + Bearing Bearing `protobuf:"varint,3,opt,name=bearing,proto3,enum=roveapi.Bearing" json:"bearing,omitempty"` + // salvage - the type of salvage to execute + Salvage SalvageType `protobuf:"varint,4,opt,name=salvage,proto3,enum=roveapi.SalvageType" json:"salvage,omitempty"` } func (x *Command) Reset() { @@ -670,20 +723,27 @@ func (x *Command) GetCommand() CommandType { return CommandType_none } -func (x *Command) GetBroadcast() []byte { +func (x *Command) GetData() []byte { if x != nil { - return x.Broadcast + return x.Data } return nil } -func (x *Command) GetTurn() Bearing { +func (x *Command) GetBearing() Bearing { if x != nil { - return x.Turn + return x.Bearing } return Bearing_BearingUnknown } +func (x *Command) GetSalvage() SalvageType { + if x != nil { + return x.Salvage + } + return SalvageType_SalvageUnknown +} + // CommandRequest describes a set of commands to be requested for the rover type CommandRequest struct { state protoimpl.MessageState @@ -1397,141 +1457,148 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x7d, 0x0a, 0x07, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, - 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, - 0x73, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, - 0x6e, 0x67, 0x52, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x22, 0x6a, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, - 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, + 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xa9, 0x01, 0x0a, 0x07, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x65, 0x61, + 0x72, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x65, + 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x2e, 0x0a, 0x07, 0x73, 0x61, 0x6c, 0x76, 0x61, 0x67, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x53, 0x61, 0x6c, 0x76, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x73, 0x61, + 0x6c, 0x76, 0x61, 0x67, 0x65, 0x22, 0x6a, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x22, 0x75, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x74, 0x69, - 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x61, 0x70, 0x69, 0x2e, 0x54, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, - 0x29, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0e, - 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, - 0x74, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, - 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, - 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, - 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, - 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, - 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xad, 0x01, 0x0a, - 0x13, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1a, - 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, - 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, - 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, - 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, - 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x22, 0x82, 0x02, 0x0a, - 0x0b, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2a, 0x0a, 0x07, - 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, - 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x39, 0x0a, 0x0c, 0x73, 0x61, 0x69, 0x6c, - 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, - 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, - 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x38, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, - 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x73, 0x22, 0x84, 0x01, 0x0a, 0x0d, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x69, - 0x6e, 0x67, 0x73, 0x12, 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x24, 0x0a, 0x04, 0x77, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, - 0x52, 0x04, 0x77, 0x69, 0x6e, 0x64, 0x12, 0x20, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4c, - 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x22, 0xa4, 0x01, 0x0a, 0x0e, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x73, - 0x70, 0x65, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, 0x12, 0x2c, 0x0a, - 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x32, 0x0a, 0x08, 0x72, - 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x61, - 0x64, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x2a, - 0x53, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, - 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x74, 0x6f, 0x67, 0x67, - 0x6c, 0x65, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x10, 0x02, 0x12, 0x09, - 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, - 0x61, 0x69, 0x72, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, - 0x73, 0x74, 0x10, 0x05, 0x2a, 0x83, 0x01, 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, - 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, - 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, - 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, - 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, - 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x04, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, - 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, - 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, 0x73, 0x74, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, - 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x08, 0x2a, 0x5a, 0x0a, 0x06, 0x4f, 0x62, - 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, - 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, - 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, - 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, - 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, - 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x2a, 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, - 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, - 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, - 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x2a, - 0x4c, 0x0a, 0x0c, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x17, 0x0a, 0x13, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, - 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x61, 0x74, 0x63, - 0x68, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x6f, - 0x6c, 0x61, 0x72, 0x43, 0x68, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x32, 0xcf, 0x02, - 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, - 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, - 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, - 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, - 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, - 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, - 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x22, 0x75, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x54, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x29, 0x0a, 0x07, + 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0f, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, + 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, + 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, + 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, + 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xad, 0x01, 0x0a, 0x13, 0x52, 0x6f, + 0x76, 0x65, 0x72, 0x53, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, + 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, + 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, + 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, + 0x69, 0x74, 0x79, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, + 0x61, 0x72, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, + 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x22, 0x82, 0x02, 0x0a, 0x0b, 0x52, 0x6f, + 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x65, 0x61, + 0x72, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x65, + 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x39, 0x0a, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1c, + 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, + 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, + 0x61, 0x72, 0x67, 0x65, 0x12, 0x38, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, + 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x84, + 0x01, 0x0a, 0x0d, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, + 0x12, 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x56, 0x65, 0x63, + 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x24, 0x0a, + 0x04, 0x77, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x04, 0x77, + 0x69, 0x6e, 0x64, 0x12, 0x20, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x6f, 0x67, 0x52, + 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x22, 0xa4, 0x01, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x73, 0x70, 0x65, 0x63, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x61, 0x64, + 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, + 0x67, 0x73, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x2a, 0x60, 0x0a, 0x0b, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, + 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x10, + 0x01, 0x12, 0x08, 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x73, + 0x74, 0x61, 0x73, 0x68, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, + 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, + 0x05, 0x12, 0x0b, 0x0a, 0x07, 0x73, 0x61, 0x6c, 0x76, 0x61, 0x67, 0x65, 0x10, 0x06, 0x2a, 0x83, + 0x01, 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, + 0x61, 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, + 0x0a, 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, + 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, + 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, + 0x04, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, + 0x53, 0x6f, 0x75, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, + 0x65, 0x73, 0x74, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, + 0x73, 0x74, 0x10, 0x08, 0x2a, 0x33, 0x0a, 0x0b, 0x53, 0x61, 0x6c, 0x76, 0x61, 0x67, 0x65, 0x54, + 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x61, 0x6c, 0x76, 0x61, 0x67, 0x65, 0x55, 0x6e, + 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x61, 0x6c, 0x76, 0x61, + 0x67, 0x65, 0x50, 0x61, 0x72, 0x74, 0x73, 0x10, 0x01, 0x2a, 0x5a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, + 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, + 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, + 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, + 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, + 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, + 0x72, 0x67, 0x65, 0x10, 0x04, 0x2a, 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, + 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, + 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, + 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x2a, 0x4c, + 0x0a, 0x0c, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, + 0x0a, 0x13, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x61, 0x74, 0x63, 0x68, + 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x6f, 0x6c, + 0x61, 0x72, 0x43, 0x68, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x32, 0xcf, 0x02, 0x0a, + 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, + 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, + 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, + 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, + 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, + 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1546,66 +1613,68 @@ func file_roveapi_roveapi_proto_rawDescGZIP() []byte { return file_roveapi_roveapi_proto_rawDescData } -var file_roveapi_roveapi_proto_enumTypes = make([]protoimpl.EnumInfo, 5) +var file_roveapi_roveapi_proto_enumTypes = make([]protoimpl.EnumInfo, 6) var file_roveapi_roveapi_proto_msgTypes = make([]protoimpl.MessageInfo, 17) var file_roveapi_roveapi_proto_goTypes = []interface{}{ (CommandType)(0), // 0: roveapi.CommandType (Bearing)(0), // 1: roveapi.Bearing - (Object)(0), // 2: roveapi.Object - (Tile)(0), // 3: roveapi.Tile - (SailPosition)(0), // 4: roveapi.SailPosition - (*ServerStatusRequest)(nil), // 5: roveapi.ServerStatusRequest - (*ServerStatusResponse)(nil), // 6: roveapi.ServerStatusResponse - (*RegisterRequest)(nil), // 7: roveapi.RegisterRequest - (*Account)(nil), // 8: roveapi.Account - (*RegisterResponse)(nil), // 9: roveapi.RegisterResponse - (*Command)(nil), // 10: roveapi.Command - (*CommandRequest)(nil), // 11: roveapi.CommandRequest - (*CommandResponse)(nil), // 12: roveapi.CommandResponse - (*RadarRequest)(nil), // 13: roveapi.RadarRequest - (*RadarResponse)(nil), // 14: roveapi.RadarResponse - (*StatusRequest)(nil), // 15: roveapi.StatusRequest - (*Log)(nil), // 16: roveapi.Log - (*Vector)(nil), // 17: roveapi.Vector - (*RoverSpecifications)(nil), // 18: roveapi.RoverSpecifications - (*RoverStatus)(nil), // 19: roveapi.RoverStatus - (*RoverReadings)(nil), // 20: roveapi.RoverReadings - (*StatusResponse)(nil), // 21: roveapi.StatusResponse + (SalvageType)(0), // 2: roveapi.SalvageType + (Object)(0), // 3: roveapi.Object + (Tile)(0), // 4: roveapi.Tile + (SailPosition)(0), // 5: roveapi.SailPosition + (*ServerStatusRequest)(nil), // 6: roveapi.ServerStatusRequest + (*ServerStatusResponse)(nil), // 7: roveapi.ServerStatusResponse + (*RegisterRequest)(nil), // 8: roveapi.RegisterRequest + (*Account)(nil), // 9: roveapi.Account + (*RegisterResponse)(nil), // 10: roveapi.RegisterResponse + (*Command)(nil), // 11: roveapi.Command + (*CommandRequest)(nil), // 12: roveapi.CommandRequest + (*CommandResponse)(nil), // 13: roveapi.CommandResponse + (*RadarRequest)(nil), // 14: roveapi.RadarRequest + (*RadarResponse)(nil), // 15: roveapi.RadarResponse + (*StatusRequest)(nil), // 16: roveapi.StatusRequest + (*Log)(nil), // 17: roveapi.Log + (*Vector)(nil), // 18: roveapi.Vector + (*RoverSpecifications)(nil), // 19: roveapi.RoverSpecifications + (*RoverStatus)(nil), // 20: roveapi.RoverStatus + (*RoverReadings)(nil), // 21: roveapi.RoverReadings + (*StatusResponse)(nil), // 22: roveapi.StatusResponse } var file_roveapi_roveapi_proto_depIdxs = []int32{ - 8, // 0: roveapi.RegisterResponse.account:type_name -> roveapi.Account + 9, // 0: roveapi.RegisterResponse.account:type_name -> roveapi.Account 0, // 1: roveapi.Command.command:type_name -> roveapi.CommandType - 1, // 2: roveapi.Command.turn:type_name -> roveapi.Bearing - 8, // 3: roveapi.CommandRequest.account:type_name -> roveapi.Account - 10, // 4: roveapi.CommandRequest.commands:type_name -> roveapi.Command - 8, // 5: roveapi.RadarRequest.account:type_name -> roveapi.Account - 3, // 6: roveapi.RadarResponse.tiles:type_name -> roveapi.Tile - 2, // 7: roveapi.RadarResponse.objects:type_name -> roveapi.Object - 8, // 8: roveapi.StatusRequest.account:type_name -> roveapi.Account - 1, // 9: roveapi.RoverStatus.bearing:type_name -> roveapi.Bearing - 4, // 10: roveapi.RoverStatus.sailPosition:type_name -> roveapi.SailPosition - 10, // 11: roveapi.RoverStatus.queuedCommands:type_name -> roveapi.Command - 17, // 12: roveapi.RoverReadings.position:type_name -> roveapi.Vector - 1, // 13: roveapi.RoverReadings.wind:type_name -> roveapi.Bearing - 16, // 14: roveapi.RoverReadings.logs:type_name -> roveapi.Log - 18, // 15: roveapi.StatusResponse.spec:type_name -> roveapi.RoverSpecifications - 19, // 16: roveapi.StatusResponse.status:type_name -> roveapi.RoverStatus - 20, // 17: roveapi.StatusResponse.readings:type_name -> roveapi.RoverReadings - 5, // 18: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest - 7, // 19: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest - 11, // 20: roveapi.Rove.Command:input_type -> roveapi.CommandRequest - 13, // 21: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest - 15, // 22: roveapi.Rove.Status:input_type -> roveapi.StatusRequest - 6, // 23: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse - 9, // 24: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse - 12, // 25: roveapi.Rove.Command:output_type -> roveapi.CommandResponse - 14, // 26: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse - 21, // 27: roveapi.Rove.Status:output_type -> roveapi.StatusResponse - 23, // [23:28] is the sub-list for method output_type - 18, // [18:23] is the sub-list for method input_type - 18, // [18:18] is the sub-list for extension type_name - 18, // [18:18] is the sub-list for extension extendee - 0, // [0:18] is the sub-list for field type_name + 1, // 2: roveapi.Command.bearing:type_name -> roveapi.Bearing + 2, // 3: roveapi.Command.salvage:type_name -> roveapi.SalvageType + 9, // 4: roveapi.CommandRequest.account:type_name -> roveapi.Account + 11, // 5: roveapi.CommandRequest.commands:type_name -> roveapi.Command + 9, // 6: roveapi.RadarRequest.account:type_name -> roveapi.Account + 4, // 7: roveapi.RadarResponse.tiles:type_name -> roveapi.Tile + 3, // 8: roveapi.RadarResponse.objects:type_name -> roveapi.Object + 9, // 9: roveapi.StatusRequest.account:type_name -> roveapi.Account + 1, // 10: roveapi.RoverStatus.bearing:type_name -> roveapi.Bearing + 5, // 11: roveapi.RoverStatus.sailPosition:type_name -> roveapi.SailPosition + 11, // 12: roveapi.RoverStatus.queuedCommands:type_name -> roveapi.Command + 18, // 13: roveapi.RoverReadings.position:type_name -> roveapi.Vector + 1, // 14: roveapi.RoverReadings.wind:type_name -> roveapi.Bearing + 17, // 15: roveapi.RoverReadings.logs:type_name -> roveapi.Log + 19, // 16: roveapi.StatusResponse.spec:type_name -> roveapi.RoverSpecifications + 20, // 17: roveapi.StatusResponse.status:type_name -> roveapi.RoverStatus + 21, // 18: roveapi.StatusResponse.readings:type_name -> roveapi.RoverReadings + 6, // 19: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest + 8, // 20: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest + 12, // 21: roveapi.Rove.Command:input_type -> roveapi.CommandRequest + 14, // 22: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest + 16, // 23: roveapi.Rove.Status:input_type -> roveapi.StatusRequest + 7, // 24: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse + 10, // 25: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse + 13, // 26: roveapi.Rove.Command:output_type -> roveapi.CommandResponse + 15, // 27: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse + 22, // 28: roveapi.Rove.Status:output_type -> roveapi.StatusResponse + 24, // [24:29] is the sub-list for method output_type + 19, // [19:24] is the sub-list for method input_type + 19, // [19:19] is the sub-list for extension type_name + 19, // [19:19] is the sub-list for extension extendee + 0, // [0:19] is the sub-list for field type_name } func init() { file_roveapi_roveapi_proto_init() } @@ -1824,7 +1893,7 @@ func file_roveapi_roveapi_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_roveapi_roveapi_proto_rawDesc, - NumEnums: 5, + NumEnums: 6, NumMessages: 17, NumExtensions: 0, NumServices: 1, diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index cc7826a..2d8917e 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -91,14 +91,16 @@ enum CommandType { none = 0; // Toggles the sails, either catching the wind, or charging from the sun toggle = 1; - // Turns the rover in the specified bearing, requires data + // Turns the rover in the specified bearing (requires bearing) turn = 2; // Stashes item at current location in rover inventory stash = 3; // Repairs the rover using an inventory object repair = 4; - // Broadcasts a message to nearby rovers, requires data + // Broadcasts a message to nearby rovers (requires data) broadcast = 5; + // Salvages a neighboring dormant rover for parts (requres bearing and salvage) + salvage = 6; } // Bearing represents a compass direction @@ -115,17 +117,27 @@ enum Bearing { NorthWest = 8; } +enum SalvageType { + SalvageUnknown = 0; + + // Salvage a nearby rover for parts + SalvageParts = 1; +} + // Command is a single command for a rover message Command { // The command type CommandType command = 1; - // A simple message, must be composed of printable ASCII glyphs (32-126) - // maximum of three characters - bytes broadcast = 2; + // broadcast - a simple message, must be composed of up to 3 printable ASCII glyphs (32-126) + bytes data = 2; - // The bearing for the rover to turn to - Bearing turn = 3; + // move - the bearing for the rover to turn to + // salvage - the direction of the rover + Bearing bearing = 3; + + // salvage - the type of salvage to execute + SalvageType salvage = 4; } // CommandRequest describes a set of commands to be requested for the rover From ce6e10afbb0deb73601b07ff5640a23453d7abe0 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 24 Jul 2020 19:08:03 +0100 Subject: [PATCH 180/228] Add salvage command to main.go man page --- cmd/rove/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 97a7a24..aaca561 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -37,6 +37,7 @@ func printUsage() { fmt.Fprintln(os.Stderr, "\tstash stores the object at the rover location in the inventory") fmt.Fprintln(os.Stderr, "\trepair uses an inventory object to repair the rover") fmt.Fprintln(os.Stderr, "\tbroadcast MSG broadcast a simple ASCII triplet to nearby rovers") + fmt.Fprintln(os.Stderr, "\tsalvage uses an inventory object to repair the rover") fmt.Fprintln(os.Stderr, "\nEnvironment") fmt.Fprintln(os.Stderr, "\tROVE_USER_DATA path to user data, defaults to "+defaultDataPath) } From 2f1ccdfdb91fa2676e417e376b127afae0946a18 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 24 Jul 2020 19:08:39 +0100 Subject: [PATCH 181/228] Make repair require rover parts --- pkg/rove/command_test.go | 4 +- pkg/rove/objects.go | 1 + pkg/rove/world.go | 23 +- pkg/rove/world_test.go | 8 +- proto/roveapi/roveapi.pb.go | 461 ++++++++++++++++-------------------- proto/roveapi/roveapi.proto | 15 +- 6 files changed, 230 insertions(+), 282 deletions(-) diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index 8f4dd36..9ca2748 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -99,10 +99,10 @@ func TestCommand_Repair(t *testing.T) { assert.Equal(t, info.MaximumIntegrity-1, info.Integrity) // Stash a repair object - w.Atlas.SetObject(info.Pos, Object{Type: roveapi.Object_RockSmall}) + w.Atlas.SetObject(info.Pos, Object{Type: roveapi.Object_RoverParts}) obj, err := w.RoverStash(name) assert.NoError(t, err) - assert.Equal(t, roveapi.Object_RockSmall, obj) + assert.Equal(t, roveapi.Object_RoverParts, obj) // Enqueue the repair and tick err = w.Enqueue(name, &roveapi.Command{Command: roveapi.CommandType_repair}) diff --git a/pkg/rove/objects.go b/pkg/rove/objects.go index f1ce227..d5fd237 100644 --- a/pkg/rove/objects.go +++ b/pkg/rove/objects.go @@ -33,6 +33,7 @@ func (o *Object) IsBlocking() bool { func (o *Object) IsStashable() bool { var stashable = [...]roveapi.Object{ roveapi.Object_RockSmall, + roveapi.Object_RoverParts, } for _, t := range stashable { diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 50348dc..de0bcae 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -352,11 +352,24 @@ func (w *World) RoverRepair(rover string) (int, error) { return 0, fmt.Errorf("no rover matching id") } - // Consume an inventory item to repair if possible - if len(r.Inventory) > 0 && r.Integrity < r.MaximumIntegrity { - r.Inventory = r.Inventory[:len(r.Inventory)-1] - r.Integrity = r.Integrity + 1 - r.AddLogEntryf("repaired self to %d", r.Integrity) + // Can't repair past max + if r.Integrity >= r.MaximumIntegrity { + return r.Integrity, nil + } + + // Find rover parts in inventory + for i, o := range r.Inventory { + if o.Type == roveapi.Object_RoverParts { + + // Copy-erase from slice + r.Inventory[i] = r.Inventory[len(r.Inventory)-1] + r.Inventory = r.Inventory[:len(r.Inventory)-1] + + // Repair + r.Integrity = r.Integrity + 1 + r.AddLogEntryf("repaired self to %d", r.Integrity) + break + } } return r.Integrity, nil diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index db9fcb6..53be582 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -248,10 +248,10 @@ func TestWorld_RoverRepair(t *testing.T) { assert.NoError(t, err, "couldn't get rover info") // Pick up something to repair with - world.Atlas.SetObject(pos, Object{Type: roveapi.Object_RockSmall}) + world.Atlas.SetObject(pos, Object{Type: roveapi.Object_RoverParts}) o, err := world.RoverStash(a) assert.NoError(t, err, "Failed to stash") - assert.Equal(t, roveapi.Object_RockSmall, o, "Failed to get correct object") + assert.Equal(t, roveapi.Object_RoverParts, o, "Failed to get correct object") world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, Object{Type: roveapi.Object_RockLarge}) @@ -273,10 +273,10 @@ func TestWorld_RoverRepair(t *testing.T) { assert.Contains(t, newinfo.Logs[len(newinfo.Logs)-1].Text, "repair", "Rover logs should contain the repair") // Check again that it can't repair past the max - world.Atlas.SetObject(pos, Object{Type: roveapi.Object_RockSmall}) + world.Atlas.SetObject(pos, Object{Type: roveapi.Object_RoverParts}) o, err = world.RoverStash(a) assert.NoError(t, err, "Failed to stash") - assert.Equal(t, roveapi.Object_RockSmall, o, "Failed to get correct object") + assert.Equal(t, roveapi.Object_RoverParts, o, "Failed to get correct object") err = world.ExecuteCommand(&roveapi.Command{Command: roveapi.CommandType_repair}, a) assert.NoError(t, err, "Failed to repair rover") diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index c5e458c..e86ab46 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -49,7 +49,7 @@ const ( CommandType_repair CommandType = 4 // Broadcasts a message to nearby rovers (requires data) CommandType_broadcast CommandType = 5 - // Salvages a neighboring dormant rover for parts (requres bearing and salvage) + // Salvages a neighboring dormant rover for parts CommandType_salvage CommandType = 6 ) @@ -171,53 +171,6 @@ func (Bearing) EnumDescriptor() ([]byte, []int) { return file_roveapi_roveapi_proto_rawDescGZIP(), []int{1} } -type SalvageType int32 - -const ( - SalvageType_SalvageUnknown SalvageType = 0 - // Salvage a nearby rover for parts - SalvageType_SalvageParts SalvageType = 1 -) - -// Enum value maps for SalvageType. -var ( - SalvageType_name = map[int32]string{ - 0: "SalvageUnknown", - 1: "SalvageParts", - } - SalvageType_value = map[string]int32{ - "SalvageUnknown": 0, - "SalvageParts": 1, - } -) - -func (x SalvageType) Enum() *SalvageType { - p := new(SalvageType) - *p = x - return p -} - -func (x SalvageType) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (SalvageType) Descriptor() protoreflect.EnumDescriptor { - return file_roveapi_roveapi_proto_enumTypes[2].Descriptor() -} - -func (SalvageType) Type() protoreflect.EnumType { - return &file_roveapi_roveapi_proto_enumTypes[2] -} - -func (x SalvageType) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use SalvageType.Descriptor instead. -func (SalvageType) EnumDescriptor() ([]byte, []int) { - return file_roveapi_roveapi_proto_rawDescGZIP(), []int{2} -} - // Types of objects type Object int32 @@ -232,6 +185,8 @@ const ( Object_RockSmall Object = 3 // RockLarge is a large blocking rock Object_RockLarge Object = 4 + // RoverParts is one unit of rover parts, used for repairing and fixing the rover + Object_RoverParts Object = 5 ) // Enum value maps for Object. @@ -242,6 +197,7 @@ var ( 2: "RoverDormant", 3: "RockSmall", 4: "RockLarge", + 5: "RoverParts", } Object_value = map[string]int32{ "ObjectUnknown": 0, @@ -249,6 +205,7 @@ var ( "RoverDormant": 2, "RockSmall": 3, "RockLarge": 4, + "RoverParts": 5, } ) @@ -263,11 +220,11 @@ func (x Object) String() string { } func (Object) Descriptor() protoreflect.EnumDescriptor { - return file_roveapi_roveapi_proto_enumTypes[3].Descriptor() + return file_roveapi_roveapi_proto_enumTypes[2].Descriptor() } func (Object) Type() protoreflect.EnumType { - return &file_roveapi_roveapi_proto_enumTypes[3] + return &file_roveapi_roveapi_proto_enumTypes[2] } func (x Object) Number() protoreflect.EnumNumber { @@ -276,7 +233,7 @@ func (x Object) Number() protoreflect.EnumNumber { // Deprecated: Use Object.Descriptor instead. func (Object) EnumDescriptor() ([]byte, []int) { - return file_roveapi_roveapi_proto_rawDescGZIP(), []int{3} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{2} } type Tile int32 @@ -319,11 +276,11 @@ func (x Tile) String() string { } func (Tile) Descriptor() protoreflect.EnumDescriptor { - return file_roveapi_roveapi_proto_enumTypes[4].Descriptor() + return file_roveapi_roveapi_proto_enumTypes[3].Descriptor() } func (Tile) Type() protoreflect.EnumType { - return &file_roveapi_roveapi_proto_enumTypes[4] + return &file_roveapi_roveapi_proto_enumTypes[3] } func (x Tile) Number() protoreflect.EnumNumber { @@ -332,7 +289,7 @@ func (x Tile) Number() protoreflect.EnumNumber { // Deprecated: Use Tile.Descriptor instead. func (Tile) EnumDescriptor() ([]byte, []int) { - return file_roveapi_roveapi_proto_rawDescGZIP(), []int{4} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{3} } // SailPosition represents the position of the sola sail @@ -371,11 +328,11 @@ func (x SailPosition) String() string { } func (SailPosition) Descriptor() protoreflect.EnumDescriptor { - return file_roveapi_roveapi_proto_enumTypes[5].Descriptor() + return file_roveapi_roveapi_proto_enumTypes[4].Descriptor() } func (SailPosition) Type() protoreflect.EnumType { - return &file_roveapi_roveapi_proto_enumTypes[5] + return &file_roveapi_roveapi_proto_enumTypes[4] } func (x SailPosition) Number() protoreflect.EnumNumber { @@ -384,7 +341,7 @@ func (x SailPosition) Number() protoreflect.EnumNumber { // Deprecated: Use SailPosition.Descriptor instead. func (SailPosition) EnumDescriptor() ([]byte, []int) { - return file_roveapi_roveapi_proto_rawDescGZIP(), []int{5} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{4} } // ServerStatusRequest is an empty placeholder @@ -680,8 +637,6 @@ type Command struct { // move - the bearing for the rover to turn to // salvage - the direction of the rover Bearing Bearing `protobuf:"varint,3,opt,name=bearing,proto3,enum=roveapi.Bearing" json:"bearing,omitempty"` - // salvage - the type of salvage to execute - Salvage SalvageType `protobuf:"varint,4,opt,name=salvage,proto3,enum=roveapi.SalvageType" json:"salvage,omitempty"` } func (x *Command) Reset() { @@ -737,13 +692,6 @@ func (x *Command) GetBearing() Bearing { return Bearing_BearingUnknown } -func (x *Command) GetSalvage() SalvageType { - if x != nil { - return x.Salvage - } - return SalvageType_SalvageUnknown -} - // CommandRequest describes a set of commands to be requested for the rover type CommandRequest struct { state protoimpl.MessageState @@ -1457,148 +1405,143 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xa9, 0x01, 0x0a, 0x07, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x65, 0x61, - 0x72, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x65, - 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x2e, 0x0a, 0x07, 0x73, 0x61, 0x6c, 0x76, 0x61, 0x67, 0x65, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x53, 0x61, 0x6c, 0x76, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x73, 0x61, - 0x6c, 0x76, 0x61, 0x67, 0x65, 0x22, 0x6a, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x79, 0x0a, 0x07, 0x43, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, + 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x65, 0x61, + 0x72, 0x69, 0x6e, 0x67, 0x22, 0x6a, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, + 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, + 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, + 0x75, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x54, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x29, 0x0a, 0x07, 0x6f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0f, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, 0x6f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, - 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x22, 0x75, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x54, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x29, 0x0a, 0x07, - 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0f, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, - 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, - 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, - 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, - 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xad, 0x01, 0x0a, 0x13, 0x52, 0x6f, - 0x76, 0x65, 0x72, 0x53, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, - 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, - 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, - 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, - 0x69, 0x74, 0x79, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, - 0x61, 0x72, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, - 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x22, 0x82, 0x02, 0x0a, 0x0b, 0x52, 0x6f, - 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x65, 0x61, - 0x72, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x65, - 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x39, 0x0a, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x52, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1c, - 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, - 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, - 0x61, 0x72, 0x67, 0x65, 0x12, 0x38, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, - 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x84, - 0x01, 0x0a, 0x0d, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, - 0x12, 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x56, 0x65, 0x63, - 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x24, 0x0a, - 0x04, 0x77, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x04, 0x77, - 0x69, 0x6e, 0x64, 0x12, 0x20, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x6f, 0x67, 0x52, - 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x22, 0xa4, 0x01, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x73, 0x70, 0x65, 0x63, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x61, 0x64, - 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, - 0x67, 0x73, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x2a, 0x60, 0x0a, 0x0b, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, - 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x10, - 0x01, 0x12, 0x08, 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x73, - 0x74, 0x61, 0x73, 0x68, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, - 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, - 0x05, 0x12, 0x0b, 0x0a, 0x07, 0x73, 0x61, 0x6c, 0x76, 0x61, 0x67, 0x65, 0x10, 0x06, 0x2a, 0x83, - 0x01, 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, - 0x61, 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, - 0x0a, 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, - 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, - 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, - 0x04, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, - 0x53, 0x6f, 0x75, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, - 0x65, 0x73, 0x74, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, - 0x73, 0x74, 0x10, 0x08, 0x2a, 0x33, 0x0a, 0x0b, 0x53, 0x61, 0x6c, 0x76, 0x61, 0x67, 0x65, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x61, 0x6c, 0x76, 0x61, 0x67, 0x65, 0x55, 0x6e, - 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x61, 0x6c, 0x76, 0x61, - 0x67, 0x65, 0x50, 0x61, 0x72, 0x74, 0x73, 0x10, 0x01, 0x2a, 0x5a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, - 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, - 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, - 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, - 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, - 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, - 0x72, 0x67, 0x65, 0x10, 0x04, 0x2a, 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, - 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, - 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, - 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x2a, 0x4c, - 0x0a, 0x0c, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, - 0x0a, 0x13, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x61, 0x74, 0x63, 0x68, - 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x6f, 0x6c, - 0x61, 0x72, 0x43, 0x68, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x32, 0xcf, 0x02, 0x0a, - 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, - 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, - 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, - 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, - 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, - 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, - 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, + 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, + 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xad, 0x01, 0x0a, 0x13, 0x52, 0x6f, 0x76, + 0x65, 0x72, 0x53, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, + 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, + 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, + 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, + 0x74, 0x79, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, + 0x72, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, + 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x22, 0x82, 0x02, 0x0a, 0x0b, 0x52, 0x6f, 0x76, + 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, + 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x65, 0x61, + 0x72, 0x69, 0x6e, 0x67, 0x12, 0x39, 0x0a, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1c, 0x0a, + 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, + 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, + 0x72, 0x67, 0x65, 0x12, 0x38, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, + 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x84, 0x01, + 0x0a, 0x0d, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x12, + 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x56, 0x65, 0x63, 0x74, + 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x24, 0x0a, 0x04, + 0x77, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x04, 0x77, 0x69, + 0x6e, 0x64, 0x12, 0x20, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, + 0x6c, 0x6f, 0x67, 0x73, 0x22, 0xa4, 0x01, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x73, 0x70, 0x65, 0x63, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x61, 0x64, 0x69, + 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, + 0x73, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x2a, 0x60, 0x0a, 0x0b, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, + 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x10, 0x01, + 0x12, 0x08, 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, + 0x61, 0x73, 0x68, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, + 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x05, + 0x12, 0x0b, 0x0a, 0x07, 0x73, 0x61, 0x6c, 0x76, 0x61, 0x67, 0x65, 0x10, 0x06, 0x2a, 0x83, 0x01, + 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, + 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, + 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, + 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, + 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x04, + 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x53, + 0x6f, 0x75, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, + 0x73, 0x74, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, 0x73, + 0x74, 0x10, 0x08, 0x2a, 0x6a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, + 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, + 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, + 0x10, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, + 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, + 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x12, + 0x0e, 0x0a, 0x0a, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x50, 0x61, 0x72, 0x74, 0x73, 0x10, 0x05, 0x2a, + 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, + 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, + 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, + 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x2a, 0x4c, 0x0a, 0x0c, 0x53, 0x61, 0x69, 0x6c, + 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x13, 0x55, 0x6e, 0x6b, 0x6e, + 0x6f, 0x77, 0x6e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x10, + 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, + 0x64, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x6f, 0x6c, 0x61, 0x72, 0x43, 0x68, 0x61, 0x72, + 0x67, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, + 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, + 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, + 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, + 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, + 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1613,68 +1556,66 @@ func file_roveapi_roveapi_proto_rawDescGZIP() []byte { return file_roveapi_roveapi_proto_rawDescData } -var file_roveapi_roveapi_proto_enumTypes = make([]protoimpl.EnumInfo, 6) +var file_roveapi_roveapi_proto_enumTypes = make([]protoimpl.EnumInfo, 5) var file_roveapi_roveapi_proto_msgTypes = make([]protoimpl.MessageInfo, 17) var file_roveapi_roveapi_proto_goTypes = []interface{}{ (CommandType)(0), // 0: roveapi.CommandType (Bearing)(0), // 1: roveapi.Bearing - (SalvageType)(0), // 2: roveapi.SalvageType - (Object)(0), // 3: roveapi.Object - (Tile)(0), // 4: roveapi.Tile - (SailPosition)(0), // 5: roveapi.SailPosition - (*ServerStatusRequest)(nil), // 6: roveapi.ServerStatusRequest - (*ServerStatusResponse)(nil), // 7: roveapi.ServerStatusResponse - (*RegisterRequest)(nil), // 8: roveapi.RegisterRequest - (*Account)(nil), // 9: roveapi.Account - (*RegisterResponse)(nil), // 10: roveapi.RegisterResponse - (*Command)(nil), // 11: roveapi.Command - (*CommandRequest)(nil), // 12: roveapi.CommandRequest - (*CommandResponse)(nil), // 13: roveapi.CommandResponse - (*RadarRequest)(nil), // 14: roveapi.RadarRequest - (*RadarResponse)(nil), // 15: roveapi.RadarResponse - (*StatusRequest)(nil), // 16: roveapi.StatusRequest - (*Log)(nil), // 17: roveapi.Log - (*Vector)(nil), // 18: roveapi.Vector - (*RoverSpecifications)(nil), // 19: roveapi.RoverSpecifications - (*RoverStatus)(nil), // 20: roveapi.RoverStatus - (*RoverReadings)(nil), // 21: roveapi.RoverReadings - (*StatusResponse)(nil), // 22: roveapi.StatusResponse + (Object)(0), // 2: roveapi.Object + (Tile)(0), // 3: roveapi.Tile + (SailPosition)(0), // 4: roveapi.SailPosition + (*ServerStatusRequest)(nil), // 5: roveapi.ServerStatusRequest + (*ServerStatusResponse)(nil), // 6: roveapi.ServerStatusResponse + (*RegisterRequest)(nil), // 7: roveapi.RegisterRequest + (*Account)(nil), // 8: roveapi.Account + (*RegisterResponse)(nil), // 9: roveapi.RegisterResponse + (*Command)(nil), // 10: roveapi.Command + (*CommandRequest)(nil), // 11: roveapi.CommandRequest + (*CommandResponse)(nil), // 12: roveapi.CommandResponse + (*RadarRequest)(nil), // 13: roveapi.RadarRequest + (*RadarResponse)(nil), // 14: roveapi.RadarResponse + (*StatusRequest)(nil), // 15: roveapi.StatusRequest + (*Log)(nil), // 16: roveapi.Log + (*Vector)(nil), // 17: roveapi.Vector + (*RoverSpecifications)(nil), // 18: roveapi.RoverSpecifications + (*RoverStatus)(nil), // 19: roveapi.RoverStatus + (*RoverReadings)(nil), // 20: roveapi.RoverReadings + (*StatusResponse)(nil), // 21: roveapi.StatusResponse } var file_roveapi_roveapi_proto_depIdxs = []int32{ - 9, // 0: roveapi.RegisterResponse.account:type_name -> roveapi.Account + 8, // 0: roveapi.RegisterResponse.account:type_name -> roveapi.Account 0, // 1: roveapi.Command.command:type_name -> roveapi.CommandType 1, // 2: roveapi.Command.bearing:type_name -> roveapi.Bearing - 2, // 3: roveapi.Command.salvage:type_name -> roveapi.SalvageType - 9, // 4: roveapi.CommandRequest.account:type_name -> roveapi.Account - 11, // 5: roveapi.CommandRequest.commands:type_name -> roveapi.Command - 9, // 6: roveapi.RadarRequest.account:type_name -> roveapi.Account - 4, // 7: roveapi.RadarResponse.tiles:type_name -> roveapi.Tile - 3, // 8: roveapi.RadarResponse.objects:type_name -> roveapi.Object - 9, // 9: roveapi.StatusRequest.account:type_name -> roveapi.Account - 1, // 10: roveapi.RoverStatus.bearing:type_name -> roveapi.Bearing - 5, // 11: roveapi.RoverStatus.sailPosition:type_name -> roveapi.SailPosition - 11, // 12: roveapi.RoverStatus.queuedCommands:type_name -> roveapi.Command - 18, // 13: roveapi.RoverReadings.position:type_name -> roveapi.Vector - 1, // 14: roveapi.RoverReadings.wind:type_name -> roveapi.Bearing - 17, // 15: roveapi.RoverReadings.logs:type_name -> roveapi.Log - 19, // 16: roveapi.StatusResponse.spec:type_name -> roveapi.RoverSpecifications - 20, // 17: roveapi.StatusResponse.status:type_name -> roveapi.RoverStatus - 21, // 18: roveapi.StatusResponse.readings:type_name -> roveapi.RoverReadings - 6, // 19: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest - 8, // 20: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest - 12, // 21: roveapi.Rove.Command:input_type -> roveapi.CommandRequest - 14, // 22: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest - 16, // 23: roveapi.Rove.Status:input_type -> roveapi.StatusRequest - 7, // 24: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse - 10, // 25: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse - 13, // 26: roveapi.Rove.Command:output_type -> roveapi.CommandResponse - 15, // 27: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse - 22, // 28: roveapi.Rove.Status:output_type -> roveapi.StatusResponse - 24, // [24:29] is the sub-list for method output_type - 19, // [19:24] is the sub-list for method input_type - 19, // [19:19] is the sub-list for extension type_name - 19, // [19:19] is the sub-list for extension extendee - 0, // [0:19] is the sub-list for field type_name + 8, // 3: roveapi.CommandRequest.account:type_name -> roveapi.Account + 10, // 4: roveapi.CommandRequest.commands:type_name -> roveapi.Command + 8, // 5: roveapi.RadarRequest.account:type_name -> roveapi.Account + 3, // 6: roveapi.RadarResponse.tiles:type_name -> roveapi.Tile + 2, // 7: roveapi.RadarResponse.objects:type_name -> roveapi.Object + 8, // 8: roveapi.StatusRequest.account:type_name -> roveapi.Account + 1, // 9: roveapi.RoverStatus.bearing:type_name -> roveapi.Bearing + 4, // 10: roveapi.RoverStatus.sailPosition:type_name -> roveapi.SailPosition + 10, // 11: roveapi.RoverStatus.queuedCommands:type_name -> roveapi.Command + 17, // 12: roveapi.RoverReadings.position:type_name -> roveapi.Vector + 1, // 13: roveapi.RoverReadings.wind:type_name -> roveapi.Bearing + 16, // 14: roveapi.RoverReadings.logs:type_name -> roveapi.Log + 18, // 15: roveapi.StatusResponse.spec:type_name -> roveapi.RoverSpecifications + 19, // 16: roveapi.StatusResponse.status:type_name -> roveapi.RoverStatus + 20, // 17: roveapi.StatusResponse.readings:type_name -> roveapi.RoverReadings + 5, // 18: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest + 7, // 19: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest + 11, // 20: roveapi.Rove.Command:input_type -> roveapi.CommandRequest + 13, // 21: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest + 15, // 22: roveapi.Rove.Status:input_type -> roveapi.StatusRequest + 6, // 23: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse + 9, // 24: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse + 12, // 25: roveapi.Rove.Command:output_type -> roveapi.CommandResponse + 14, // 26: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse + 21, // 27: roveapi.Rove.Status:output_type -> roveapi.StatusResponse + 23, // [23:28] is the sub-list for method output_type + 18, // [18:23] is the sub-list for method input_type + 18, // [18:18] is the sub-list for extension type_name + 18, // [18:18] is the sub-list for extension extendee + 0, // [0:18] is the sub-list for field type_name } func init() { file_roveapi_roveapi_proto_init() } @@ -1893,7 +1834,7 @@ func file_roveapi_roveapi_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_roveapi_roveapi_proto_rawDesc, - NumEnums: 6, + NumEnums: 5, NumMessages: 17, NumExtensions: 0, NumServices: 1, diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index 2d8917e..6b9515c 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -99,7 +99,7 @@ enum CommandType { repair = 4; // Broadcasts a message to nearby rovers (requires data) broadcast = 5; - // Salvages a neighboring dormant rover for parts (requres bearing and salvage) + // Salvages a neighboring dormant rover for parts salvage = 6; } @@ -117,13 +117,6 @@ enum Bearing { NorthWest = 8; } -enum SalvageType { - SalvageUnknown = 0; - - // Salvage a nearby rover for parts - SalvageParts = 1; -} - // Command is a single command for a rover message Command { // The command type @@ -135,9 +128,6 @@ message Command { // move - the bearing for the rover to turn to // salvage - the direction of the rover Bearing bearing = 3; - - // salvage - the type of salvage to execute - SalvageType salvage = 4; } // CommandRequest describes a set of commands to be requested for the rover @@ -172,6 +162,9 @@ enum Object { // RockLarge is a large blocking rock RockLarge = 4; + + // RoverParts is one unit of rover parts, used for repairing and fixing the rover + RoverParts = 5; } enum Tile { From 524487ce149ddffb4ec39fb95950acf764e8f84c Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 24 Jul 2020 19:27:54 +0100 Subject: [PATCH 182/228] Stop the dormant rover from being a blocking object --- pkg/rove/objects.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/rove/objects.go b/pkg/rove/objects.go index d5fd237..df10453 100644 --- a/pkg/rove/objects.go +++ b/pkg/rove/objects.go @@ -17,7 +17,6 @@ type Object struct { func (o *Object) IsBlocking() bool { var blocking = [...]roveapi.Object{ roveapi.Object_RoverLive, - roveapi.Object_RoverDormant, roveapi.Object_RockLarge, } From 7cccb4394f7eb0583ba603d34e1097e002149156 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 24 Jul 2020 19:28:44 +0100 Subject: [PATCH 183/228] Fix the help text comment --- cmd/rove/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index aaca561..b3a7ed6 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -37,7 +37,7 @@ func printUsage() { fmt.Fprintln(os.Stderr, "\tstash stores the object at the rover location in the inventory") fmt.Fprintln(os.Stderr, "\trepair uses an inventory object to repair the rover") fmt.Fprintln(os.Stderr, "\tbroadcast MSG broadcast a simple ASCII triplet to nearby rovers") - fmt.Fprintln(os.Stderr, "\tsalvage uses an inventory object to repair the rover") + fmt.Fprintln(os.Stderr, "\tsalvage salvages a dormant rover for parts") fmt.Fprintln(os.Stderr, "\nEnvironment") fmt.Fprintln(os.Stderr, "\tROVE_USER_DATA path to user data, defaults to "+defaultDataPath) } From c321f88d962fcdba8de9a9e8950f6c31f8f702b5 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 24 Jul 2020 19:39:14 +0100 Subject: [PATCH 184/228] Add code for salvage command --- pkg/rove/command_test.go | 28 ++++++++++++++++++++++++ pkg/rove/world.go | 46 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index 9ca2748..9a8a35a 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -131,6 +131,34 @@ func TestCommand_Broadcast(t *testing.T) { assert.Contains(t, info.Logs[len(info.Logs)-1].Text, "ABC") } +func TestCommand_Salvage(t *testing.T) { + w := NewWorld(8) + name, err := w.SpawnRover() + assert.NoError(t, err) + + info, err := w.GetRover(name) + assert.NoError(t, err) + + w.Atlas.SetObject(info.Pos, Object{Type: roveapi.Object_RoverDormant}) + + // Enqueue the broadcast and tick + err = w.Enqueue(name, &roveapi.Command{Command: roveapi.CommandType_salvage}) + assert.NoError(t, err) + w.Tick() + + // Check we now have some rover parts + info, err = w.GetRover(name) + assert.NoError(t, err) + assert.NotEmpty(t, info.Inventory) + for _, i := range info.Inventory { + assert.Equal(t, roveapi.Object_RoverParts, i.Type) + } + + // Check the dormant rover is gone + _, obj := w.Atlas.QueryPosition(info.Pos) + assert.Equal(t, roveapi.Object_ObjectUnknown, obj.Type) +} + func TestCommand_Invalid(t *testing.T) { w := NewWorld(8) name, err := w.SpawnRover() diff --git a/pkg/rove/world.go b/pkg/rove/world.go index de0bcae..b18f23e 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -300,6 +300,46 @@ func (w *World) RoverStash(rover string) (roveapi.Object, error) { return obj.Type, nil } +// RoverSalvage will salvage a rover for parts +func (w *World) RoverSalvage(rover string) (roveapi.Object, error) { + w.worldMutex.Lock() + defer w.worldMutex.Unlock() + + r, ok := w.Rovers[rover] + if !ok { + return roveapi.Object_ObjectUnknown, fmt.Errorf("no rover matching id") + } + + // Can't pick up when full + if len(r.Inventory) >= r.Capacity { + r.AddLogEntryf("tried to salvage dormant rover but inventory was full") + return roveapi.Object_ObjectUnknown, nil + } + + // Ensure the rover has energy + if r.Charge <= 0 { + r.AddLogEntryf("tried to salvage dormant rover but had no charge") + return roveapi.Object_ObjectUnknown, nil + } + r.Charge-- + + _, obj := w.Atlas.QueryPosition(r.Pos) + if obj.Type != roveapi.Object_RoverDormant { + r.AddLogEntryf("tried to salvage dormant rover but found no rover to salvage") + return roveapi.Object_ObjectUnknown, nil + } + + r.AddLogEntryf("salvaged dormant rover") + for i := 0; i < 5; i++ { + if len(r.Inventory) == r.Capacity { + break + } + r.Inventory = append(r.Inventory, Object{Type: roveapi.Object_RoverParts}) + } + w.Atlas.SetObject(r.Pos, Object{Type: roveapi.Object_ObjectUnknown}) + return obj.Type, nil +} + // RoverToggle will toggle the sail position func (w *World) RoverToggle(rover string) (roveapi.SailPosition, error) { w.worldMutex.Lock() @@ -463,6 +503,7 @@ func (w *World) Enqueue(rover string, commands ...*roveapi.Command) error { case roveapi.CommandType_toggle: case roveapi.CommandType_stash: case roveapi.CommandType_repair: + case roveapi.CommandType_salvage: // Nothing to verify default: return fmt.Errorf("unknown command: %s", c.Command) @@ -591,6 +632,11 @@ func (w *World) ExecuteCommand(c *roveapi.Command, rover string) (err error) { return err } + case roveapi.CommandType_salvage: + if _, err := w.RoverSalvage(rover); err != nil { + return err + } + default: return fmt.Errorf("unknown command: %s", c.Command) } From be36f0631b830f849ef0148e21ef38576e196da8 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 24 Jul 2020 19:39:25 +0100 Subject: [PATCH 185/228] Add logs for failed stashes --- pkg/rove/world.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index b18f23e..a500287 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -280,11 +280,13 @@ func (w *World) RoverStash(rover string) (roveapi.Object, error) { // Can't pick up when full if len(r.Inventory) >= r.Capacity { + r.AddLogEntryf("tried to stash object but inventory was full") return roveapi.Object_ObjectUnknown, nil } // Ensure the rover has energy if r.Charge <= 0 { + r.AddLogEntryf("tried to stash object but had no charge") return roveapi.Object_ObjectUnknown, nil } r.Charge-- From b0ff3eb6ea58201a657a493be7dd36c4a00a4182 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 24 Jul 2020 19:39:33 +0100 Subject: [PATCH 186/228] Remove redundant tests (covered in command_tests) --- pkg/rove/world_test.go | 130 ----------------------------------------- 1 file changed, 130 deletions(-) diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index 53be582..430d571 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -128,79 +128,6 @@ func TestWorld_RadarFromRover(t *testing.T) { assert.Equal(t, objs1, objs2) } -func TestWorld_RoverStash(t *testing.T) { - world := NewWorld(2) - a, err := world.SpawnRover() - assert.NoError(t, err) - - pos := maths.Vector{ - X: 0.0, - Y: 0.0, - } - - world.Atlas.SetObject(pos, Object{Type: roveapi.Object_ObjectUnknown}) - err = world.WarpRover(a, pos) - assert.NoError(t, err, "Failed to set position for rover") - - rover, err := world.GetRover(a) - assert.NoError(t, err, "Failed to get rover") - - for i := 0; i < rover.Capacity; i++ { - // Place an object - world.Atlas.SetObject(pos, Object{Type: roveapi.Object_RockSmall}) - - // Pick it up - o, err := world.RoverStash(a) - assert.NoError(t, err, "Failed to stash") - assert.Equal(t, roveapi.Object_RockSmall, o, "Failed to get correct object") - - // Check it's gone - _, obj := world.Atlas.QueryPosition(pos) - assert.Equal(t, roveapi.Object_ObjectUnknown, obj.Type, "Stash failed to remove object from atlas") - - // Check we have it - inv, err := world.RoverInventory(a) - assert.NoError(t, err, "Failed to get inventory") - assert.Equal(t, i+1, len(inv)) - assert.Equal(t, Object{Type: roveapi.Object_RockSmall}, inv[i]) - - // Check that this did reduce the charge - info, err := world.GetRover(a) - assert.NoError(t, err, "Failed to get rover") - assert.Equal(t, info.MaximumCharge-(i+1), info.Charge, "Rover lost charge for stash") - assert.Contains(t, info.Logs[len(info.Logs)-1].Text, "stashed", "Rover logs should contain the move") - } - - // Recharge the rover - for i := 0; i < rover.MaximumCharge; i++ { - _, err = world.RoverRecharge(a) - assert.NoError(t, err) - - } - - // Place an object - world.Atlas.SetObject(pos, Object{Type: roveapi.Object_RockSmall}) - - // Try to pick it up - o, err := world.RoverStash(a) - assert.NoError(t, err, "Failed to stash") - assert.Equal(t, roveapi.Object_ObjectUnknown, o, "Failed to get correct object") - - // Check it's still there - _, obj := world.Atlas.QueryPosition(pos) - assert.Equal(t, roveapi.Object_RockSmall, obj.Type, "Stash failed to remove object from atlas") - - // Check we don't have it - inv, err := world.RoverInventory(a) - assert.NoError(t, err, "Failed to get inventory") - assert.Equal(t, rover.Capacity, len(inv)) - - // Check that this didn't reduce the charge - info, err := world.GetRover(a) - assert.NoError(t, err, "Failed to get rover") - assert.Equal(t, info.MaximumCharge, info.Charge, "Rover lost charge for non-stash") -} - func TestWorld_RoverDamage(t *testing.T) { world := NewWorld(2) a, err := world.SpawnRover() @@ -229,63 +156,6 @@ func TestWorld_RoverDamage(t *testing.T) { assert.Contains(t, newinfo.Logs[len(newinfo.Logs)-1].Text, "collision", "Rover logs should contain the collision") } -func TestWorld_RoverRepair(t *testing.T) { - world := NewWorld(2) - a, err := world.SpawnRover() - assert.NoError(t, err) - - pos := maths.Vector{ - X: 0.0, - Y: 0.0, - } - - world.Atlas.SetObject(pos, Object{Type: roveapi.Object_ObjectUnknown}) - - err = world.WarpRover(a, pos) - assert.NoError(t, err, "Failed to set position for rover") - - originalInfo, err := world.GetRover(a) - assert.NoError(t, err, "couldn't get rover info") - - // Pick up something to repair with - world.Atlas.SetObject(pos, Object{Type: roveapi.Object_RoverParts}) - o, err := world.RoverStash(a) - assert.NoError(t, err, "Failed to stash") - assert.Equal(t, roveapi.Object_RoverParts, o, "Failed to get correct object") - - world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, Object{Type: roveapi.Object_RockLarge}) - - // Try and bump into the rock - vec, err := world.TryMoveRover(a, roveapi.Bearing_North) - assert.NoError(t, err, "Failed to move rover") - assert.Equal(t, pos, vec, "Rover managed to move into large rock") - - newinfo, err := world.GetRover(a) - assert.NoError(t, err, "couldn't get rover info") - assert.Equal(t, originalInfo.Integrity-1, newinfo.Integrity, "rover should have lost integrity") - - err = world.ExecuteCommand(&roveapi.Command{Command: roveapi.CommandType_repair}, a) - assert.NoError(t, err, "Failed to repair rover") - - newinfo, err = world.GetRover(a) - assert.NoError(t, err, "couldn't get rover info") - assert.Equal(t, originalInfo.Integrity, newinfo.Integrity, "rover should have gained integrity") - assert.Contains(t, newinfo.Logs[len(newinfo.Logs)-1].Text, "repair", "Rover logs should contain the repair") - - // Check again that it can't repair past the max - world.Atlas.SetObject(pos, Object{Type: roveapi.Object_RoverParts}) - o, err = world.RoverStash(a) - assert.NoError(t, err, "Failed to stash") - assert.Equal(t, roveapi.Object_RoverParts, o, "Failed to get correct object") - - err = world.ExecuteCommand(&roveapi.Command{Command: roveapi.CommandType_repair}, a) - assert.NoError(t, err, "Failed to repair rover") - - newinfo, err = world.GetRover(a) - assert.NoError(t, err, "couldn't get rover info") - assert.Equal(t, originalInfo.Integrity, newinfo.Integrity, "rover should have kept the same integrity") -} - func TestWorld_Daytime(t *testing.T) { world := NewWorld(1) From edd3e5a6cbc3855ecd089c950e964ab3c70fce41 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 24 Jul 2020 19:42:34 +0100 Subject: [PATCH 187/228] Fix test by removing object before warping rover --- pkg/rove/world_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index 430d571..e1fa700 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -138,6 +138,7 @@ func TestWorld_RoverDamage(t *testing.T) { Y: 0.0, } + world.Atlas.SetObject(pos, Object{Type: roveapi.Object_ObjectUnknown}) err = world.WarpRover(a, pos) assert.NoError(t, err, "Failed to set position for rover") From 5b2ea533f41081564724025b7fe7c8891d1e5819 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 24 Jul 2020 19:46:32 +0100 Subject: [PATCH 188/228] Remove incorrect proto comment --- proto/roveapi/roveapi.proto | 1 - 1 file changed, 1 deletion(-) diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index 6b9515c..7acedac 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -126,7 +126,6 @@ message Command { bytes data = 2; // move - the bearing for the rover to turn to - // salvage - the direction of the rover Bearing bearing = 3; } From 1e4d642038660ceda198bc769c22d688efe5b7a1 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 24 Jul 2020 20:01:35 +0100 Subject: [PATCH 189/228] Add rover transfer command and implementation Need to swap the accounts --- pkg/rove/world.go | 54 +++++++++++++++++++ proto/roveapi/roveapi.pb.go | 104 +++++++++++++++++++----------------- proto/roveapi/roveapi.proto | 2 + 3 files changed, 110 insertions(+), 50 deletions(-) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index a500287..afe7605 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -1,6 +1,7 @@ package rove import ( + "encoding/json" "fmt" "log" "math/rand" @@ -342,6 +343,53 @@ func (w *World) RoverSalvage(rover string) (roveapi.Object, error) { return obj.Type, nil } +// RoverTransfer will transfer rover control to dormant rover +func (w *World) RoverTransfer(rover string) (string, error) { + w.worldMutex.Lock() + defer w.worldMutex.Unlock() + + oldRover, ok := w.Rovers[rover] + if !ok { + return "", fmt.Errorf("no rover matching id") + } + + _, obj := w.Atlas.QueryPosition(oldRover.Pos) + if obj.Type != roveapi.Object_RoverDormant { + oldRover.AddLogEntryf("tried to transfer to dormant rover but found no rover") + return "", nil + } + + // Unmarshal the dormant rover + var newRover Rover + err := json.Unmarshal(obj.Data, &newRover) + if err != nil { + return "", err + } + + // Add logs + oldRover.AddLogEntryf("transferring to dormant rover %s", newRover.Name) + newRover.AddLogEntryf("transferred from rover %s", oldRover.Name) + + // Marshal old rover + oldRoverData, err := json.Marshal(oldRover) + if err != nil { + return "", err + } + + // Add this new rover to tracking + w.Rovers[newRover.Name] = &newRover + + // TODO: Swap account rover to the dormant one + + // Place the old rover into the world + w.Atlas.SetObject(oldRover.Pos, Object{Type: roveapi.Object_RoverDormant, Data: oldRoverData}) + + // Remove old rover from current tracking + delete(w.Rovers, oldRover.Name) + + return newRover.Name, nil +} + // RoverToggle will toggle the sail position func (w *World) RoverToggle(rover string) (roveapi.SailPosition, error) { w.worldMutex.Lock() @@ -506,6 +554,7 @@ func (w *World) Enqueue(rover string, commands ...*roveapi.Command) error { case roveapi.CommandType_stash: case roveapi.CommandType_repair: case roveapi.CommandType_salvage: + case roveapi.CommandType_transfer: // Nothing to verify default: return fmt.Errorf("unknown command: %s", c.Command) @@ -639,6 +688,11 @@ func (w *World) ExecuteCommand(c *roveapi.Command, rover string) (err error) { return err } + case roveapi.CommandType_transfer: + if _, err := w.RoverTransfer(rover); err != nil { + return err + } + default: return fmt.Errorf("unknown command: %s", c.Command) } diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index e86ab46..cc6fe07 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -51,6 +51,8 @@ const ( CommandType_broadcast CommandType = 5 // Salvages a neighboring dormant rover for parts CommandType_salvage CommandType = 6 + // Transfers remote control into dormant rover + CommandType_transfer CommandType = 7 ) // Enum value maps for CommandType. @@ -63,6 +65,7 @@ var ( 4: "repair", 5: "broadcast", 6: "salvage", + 7: "transfer", } CommandType_value = map[string]int32{ "none": 0, @@ -72,6 +75,7 @@ var ( "repair": 4, "broadcast": 5, "salvage": 6, + "transfer": 7, } ) @@ -635,7 +639,6 @@ type Command struct { // broadcast - a simple message, must be composed of up to 3 printable ASCII glyphs (32-126) Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` // move - the bearing for the rover to turn to - // salvage - the direction of the rover Bearing Bearing `protobuf:"varint,3,opt,name=bearing,proto3,enum=roveapi.Bearing" json:"bearing,omitempty"` } @@ -1487,61 +1490,62 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, - 0x73, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x2a, 0x60, 0x0a, 0x0b, 0x43, + 0x73, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x2a, 0x6e, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x05, - 0x12, 0x0b, 0x0a, 0x07, 0x73, 0x61, 0x6c, 0x76, 0x61, 0x67, 0x65, 0x10, 0x06, 0x2a, 0x83, 0x01, - 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, - 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, - 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, - 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, - 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x04, - 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x53, - 0x6f, 0x75, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, - 0x73, 0x74, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, 0x73, - 0x74, 0x10, 0x08, 0x2a, 0x6a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, - 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, - 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, - 0x10, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, - 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, - 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x12, - 0x0e, 0x0a, 0x0a, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x50, 0x61, 0x72, 0x74, 0x73, 0x10, 0x05, 0x2a, - 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, - 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, - 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, - 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x2a, 0x4c, 0x0a, 0x0c, 0x53, 0x61, 0x69, 0x6c, - 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x13, 0x55, 0x6e, 0x6b, 0x6e, - 0x6f, 0x77, 0x6e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x10, - 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, - 0x64, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x6f, 0x6c, 0x61, 0x72, 0x43, 0x68, 0x61, 0x72, - 0x67, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, - 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, - 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, + 0x12, 0x0b, 0x0a, 0x07, 0x73, 0x61, 0x6c, 0x76, 0x61, 0x67, 0x65, 0x10, 0x06, 0x12, 0x0c, 0x0a, + 0x08, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x10, 0x07, 0x2a, 0x83, 0x01, 0x0a, 0x07, + 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, 0x72, 0x69, + 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x4e, + 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x45, + 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, 0x03, 0x12, + 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x04, 0x12, 0x09, + 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, + 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, 0x73, 0x74, + 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, + 0x08, 0x2a, 0x6a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, + 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x10, 0x0a, + 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, 0x02, 0x12, + 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, 0x12, 0x0d, + 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x12, 0x0e, 0x0a, + 0x0a, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x50, 0x61, 0x72, 0x74, 0x73, 0x10, 0x05, 0x2a, 0x37, 0x0a, + 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, + 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, + 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, + 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x2a, 0x4c, 0x0a, 0x0c, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x13, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, + 0x6e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x00, 0x12, + 0x10, 0x0a, 0x0c, 0x43, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x10, + 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x6f, 0x6c, 0x61, 0x72, 0x43, 0x68, 0x61, 0x72, 0x67, 0x69, + 0x6e, 0x67, 0x10, 0x02, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, + 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, - 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, - 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, - 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index 7acedac..5470e19 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -101,6 +101,8 @@ enum CommandType { broadcast = 5; // Salvages a neighboring dormant rover for parts salvage = 6; + // Transfers remote control into dormant rover + transfer = 7; } // Bearing represents a compass direction From e840b3e47bc09e4e105aa2e89aae3fe62f15ed43 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 24 Jul 2020 20:06:06 +0100 Subject: [PATCH 190/228] Move accountant into world --- cmd/rove-server/internal/routes.go | 14 +++++++------- cmd/rove-server/internal/server.go | 10 +++------- .../internal => pkg/accounts}/accounts.go | 2 +- .../internal => pkg/accounts}/accounts_test.go | 2 +- .../internal => pkg/accounts}/simpleAccountant.go | 2 +- pkg/rove/world.go | 5 +++++ 6 files changed, 18 insertions(+), 17 deletions(-) rename {cmd/rove-server/internal => pkg/accounts}/accounts.go (98%) rename {cmd/rove-server/internal => pkg/accounts}/accounts_test.go (98%) rename {cmd/rove-server/internal => pkg/accounts}/simpleAccountant.go (99%) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 86becd7..69dd820 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -34,7 +34,7 @@ func (s *Server) Register(ctx context.Context, req *roveapi.RegisterRequest) (*r return nil, fmt.Errorf("empty account name") } - if acc, err := s.accountant.RegisterAccount(req.Name); err != nil { + if acc, err := s.world.Accountant.RegisterAccount(req.Name); err != nil { return nil, err } else if _, err := s.SpawnRoverForAccount(req.Name); err != nil { @@ -57,13 +57,13 @@ func (s *Server) Register(ctx context.Context, req *roveapi.RegisterRequest) (*r func (s *Server) Status(ctx context.Context, req *roveapi.StatusRequest) (response *roveapi.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.world.Accountant.VerifySecret(req.Account.Name, req.Account.Secret); err != nil { return nil, err } else if !valid { return nil, fmt.Errorf("Secret incorrect for account %s", req.Account.Name) - } else if resp, err := s.accountant.GetValue(req.Account.Name, "rover"); err != nil { + } else if resp, err := s.world.Accountant.GetValue(req.Account.Name, "rover"); err != nil { return nil, err } else if rover, err := s.world.GetRover(resp); err != nil { @@ -117,7 +117,7 @@ func (s *Server) Status(ctx context.Context, req *roveapi.StatusRequest) (respon func (s *Server) Radar(ctx context.Context, req *roveapi.RadarRequest) (*roveapi.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.world.Accountant.VerifySecret(req.Account.Name, req.Account.Secret); err != nil { return nil, err } else if !valid { @@ -126,7 +126,7 @@ func (s *Server) Radar(ctx context.Context, req *roveapi.RadarRequest) (*roveapi response := &roveapi.RadarResponse{} - resp, err := s.accountant.GetValue(req.Account.Name, "rover") + resp, err := s.world.Accountant.GetValue(req.Account.Name, "rover") if err != nil { return nil, err @@ -149,14 +149,14 @@ func (s *Server) Radar(ctx context.Context, req *roveapi.RadarRequest) (*roveapi func (s *Server) Command(ctx context.Context, req *roveapi.CommandRequest) (*roveapi.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.world.Accountant.VerifySecret(req.Account.Name, req.Account.Secret); err != nil { return nil, err } else if !valid { return nil, fmt.Errorf("Secret incorrect for account %s", req.Account.Name) } - resp, err := s.accountant.GetValue(req.Account.Name, "rover") + resp, err := s.world.Accountant.GetValue(req.Account.Name, "rover") if err != nil { return nil, err } diff --git a/cmd/rove-server/internal/server.go b/cmd/rove-server/internal/server.go index 786eb00..564656e 100644 --- a/cmd/rove-server/internal/server.go +++ b/cmd/rove-server/internal/server.go @@ -27,9 +27,6 @@ type Server struct { // Internal state world *rove.World - // Accountant - accountant Accountant - // gRPC server netListener net.Listener grpcServ *grpc.Server @@ -80,7 +77,6 @@ func NewServer(opts ...ServerOption) *Server { persistence: EphemeralData, schedule: cron.New(), world: rove.NewWorld(32), - accountant: NewSimpleAccountant(), } // Apply all options @@ -188,7 +184,7 @@ func (s *Server) SaveWorld() error { if s.persistence == PersistentData { s.world.RLock() defer s.world.RUnlock() - if err := persistence.SaveAll("world", s.world, "accounts", s.accountant); err != nil { + if err := persistence.SaveAll("world", s.world); err != nil { return fmt.Errorf("failed to save out persistent data: %s", err) } } @@ -200,7 +196,7 @@ func (s *Server) LoadWorld() error { if s.persistence == PersistentData { s.world.Lock() defer s.world.Unlock() - if err := persistence.LoadAll("world", &s.world, "accounts", &s.accountant); err != nil { + if err := persistence.LoadAll("world", &s.world); err != nil { return err } } @@ -214,7 +210,7 @@ func (s *Server) SpawnRoverForAccount(account string) (string, error) { return "", err } - err = s.accountant.AssignData(account, "rover", inst) + err = s.world.Accountant.AssignData(account, "rover", inst) if err != nil { log.Printf("Failed to assign rover to account, %s", err) diff --git a/cmd/rove-server/internal/accounts.go b/pkg/accounts/accounts.go similarity index 98% rename from cmd/rove-server/internal/accounts.go rename to pkg/accounts/accounts.go index 9ae6db9..eb8637d 100644 --- a/cmd/rove-server/internal/accounts.go +++ b/pkg/accounts/accounts.go @@ -1,4 +1,4 @@ -package internal +package accounts // Accountant decribes something that stores accounts and account values type Accountant interface { diff --git a/cmd/rove-server/internal/accounts_test.go b/pkg/accounts/accounts_test.go similarity index 98% rename from cmd/rove-server/internal/accounts_test.go rename to pkg/accounts/accounts_test.go index 9e7891f..bd2416f 100644 --- a/cmd/rove-server/internal/accounts_test.go +++ b/pkg/accounts/accounts_test.go @@ -1,4 +1,4 @@ -package internal +package accounts import ( "testing" diff --git a/cmd/rove-server/internal/simpleAccountant.go b/pkg/accounts/simpleAccountant.go similarity index 99% rename from cmd/rove-server/internal/simpleAccountant.go rename to pkg/accounts/simpleAccountant.go index 611ff59..9d6c43f 100644 --- a/cmd/rove-server/internal/simpleAccountant.go +++ b/pkg/accounts/simpleAccountant.go @@ -1,4 +1,4 @@ -package internal +package accounts import ( "fmt" diff --git a/pkg/rove/world.go b/pkg/rove/world.go index afe7605..0d828ae 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -7,6 +7,7 @@ import ( "math/rand" "sync" + "github.com/mdiluz/rove/pkg/accounts" "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/proto/roveapi" ) @@ -40,6 +41,9 @@ type World struct { // Commands is the set of currently executing command streams per rover CommandQueue map[string]CommandStream + // Accountant + Accountant accounts.Accountant + // Mutex to lock around all world operations worldMutex sync.RWMutex // Mutex to lock around command operations @@ -54,6 +58,7 @@ func NewWorld(chunkSize int) *World { Atlas: NewChunkAtlas(chunkSize), TicksPerDay: 24, CurrentTicks: 0, + Accountant: accounts.NewSimpleAccountant(), } } From 6f2d67bd7c14e312cc5b44acef62addd2a8aa93e Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 24 Jul 2020 22:22:32 +0100 Subject: [PATCH 191/228] Tag rovers by the controlling account --- cmd/rove-server/internal/server.go | 2 +- pkg/rove/command_test.go | 14 +++++++------- pkg/rove/rover.go | 3 +++ pkg/rove/world.go | 12 ++++++++++-- pkg/rove/world_test.go | 26 +++++++++++++------------- 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/cmd/rove-server/internal/server.go b/cmd/rove-server/internal/server.go index 564656e..42392f3 100644 --- a/cmd/rove-server/internal/server.go +++ b/cmd/rove-server/internal/server.go @@ -205,7 +205,7 @@ func (s *Server) LoadWorld() error { // SpawnRoverForAccount spawns the rover rover for an account func (s *Server) SpawnRoverForAccount(account string) (string, error) { - inst, err := s.world.SpawnRover() + inst, err := s.world.SpawnRover(account) if err != nil { return "", err } diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index 9a8a35a..6560e53 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -10,7 +10,7 @@ import ( func TestCommand_Toggle(t *testing.T) { w := NewWorld(8) - a, err := w.SpawnRover() + a, err := w.SpawnRover("tmp") assert.NoError(t, err) r, err := w.GetRover(a) @@ -36,7 +36,7 @@ func TestCommand_Toggle(t *testing.T) { func TestCommand_Turn(t *testing.T) { w := NewWorld(8) - a, err := w.SpawnRover() + a, err := w.SpawnRover("tmp") assert.NoError(t, err) err = w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_turn, Bearing: roveapi.Bearing_NorthWest}) @@ -50,7 +50,7 @@ func TestCommand_Turn(t *testing.T) { func TestCommand_Stash(t *testing.T) { w := NewWorld(8) - name, err := w.SpawnRover() + name, err := w.SpawnRover("tmp") assert.NoError(t, err) info, err := w.GetRover(name) @@ -78,7 +78,7 @@ func TestCommand_Stash(t *testing.T) { func TestCommand_Repair(t *testing.T) { w := NewWorld(8) - name, err := w.SpawnRover() + name, err := w.SpawnRover("tmp") assert.NoError(t, err) info, err := w.GetRover(name) @@ -118,7 +118,7 @@ func TestCommand_Repair(t *testing.T) { func TestCommand_Broadcast(t *testing.T) { w := NewWorld(8) - name, err := w.SpawnRover() + name, err := w.SpawnRover("tmp") assert.NoError(t, err) // Enqueue the broadcast and tick @@ -133,7 +133,7 @@ func TestCommand_Broadcast(t *testing.T) { func TestCommand_Salvage(t *testing.T) { w := NewWorld(8) - name, err := w.SpawnRover() + name, err := w.SpawnRover("tmp") assert.NoError(t, err) info, err := w.GetRover(name) @@ -161,7 +161,7 @@ func TestCommand_Salvage(t *testing.T) { func TestCommand_Invalid(t *testing.T) { w := NewWorld(8) - name, err := w.SpawnRover() + name, err := w.SpawnRover("tmp") assert.NoError(t, err) err = w.Enqueue(name, &roveapi.Command{Command: roveapi.CommandType_none}) diff --git a/pkg/rove/rover.go b/pkg/rove/rover.go index ce0edcd..d0fb9cb 100644 --- a/pkg/rove/rover.go +++ b/pkg/rove/rover.go @@ -66,6 +66,9 @@ type Rover struct { // Logs Stores log of information Logs []RoverLogEntry + + // The account that owns this rover + Owner string } // DefaultRover returns a default rover object with default settings diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 0d828ae..922ab70 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -63,13 +63,16 @@ func NewWorld(chunkSize int) *World { } // SpawnRover adds an rover to the game -func (w *World) SpawnRover() (string, error) { +func (w *World) SpawnRover(account string) (string, error) { w.worldMutex.Lock() defer w.worldMutex.Unlock() // Initialise the rover rover := DefaultRover() + // Assign the owner + rover.Owner = account + // Spawn in a random place near the origin rover.Pos = maths.Vector{ X: 10 - rand.Intn(20), @@ -375,6 +378,9 @@ func (w *World) RoverTransfer(rover string) (string, error) { oldRover.AddLogEntryf("transferring to dormant rover %s", newRover.Name) newRover.AddLogEntryf("transferred from rover %s", oldRover.Name) + // Clear the old owner + oldRover.Owner = "" + // Marshal old rover oldRoverData, err := json.Marshal(oldRover) if err != nil { @@ -384,7 +390,9 @@ func (w *World) RoverTransfer(rover string) (string, error) { // Add this new rover to tracking w.Rovers[newRover.Name] = &newRover - // TODO: Swap account rover to the dormant one + // Swap account rover to the dormant one + newRover.Owner = oldRover.Owner + w.Accountant.AssignData(oldRover.Owner, "rover", newRover.Name) // Place the old rover into the world w.Atlas.SetObject(oldRover.Pos, Object{Type: roveapi.Object_RoverDormant, Data: oldRoverData}) diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index e1fa700..d0c4c01 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -18,9 +18,9 @@ func TestNewWorld(t *testing.T) { func TestWorld_CreateRover(t *testing.T) { world := NewWorld(8) - a, err := world.SpawnRover() + a, err := world.SpawnRover("tmp") assert.NoError(t, err) - b, err := world.SpawnRover() + b, err := world.SpawnRover("tmp") assert.NoError(t, err) // Basic duplicate check @@ -33,7 +33,7 @@ func TestWorld_CreateRover(t *testing.T) { func TestWorld_GetRover(t *testing.T) { world := NewWorld(4) - a, err := world.SpawnRover() + a, err := world.SpawnRover("tmp") assert.NoError(t, err) rover, err := world.GetRover(a) @@ -44,9 +44,9 @@ func TestWorld_GetRover(t *testing.T) { func TestWorld_DestroyRover(t *testing.T) { world := NewWorld(1) - a, err := world.SpawnRover() + a, err := world.SpawnRover("tmp") assert.NoError(t, err) - b, err := world.SpawnRover() + b, err := world.SpawnRover("tmp") assert.NoError(t, err) err = world.DestroyRover(a) @@ -62,7 +62,7 @@ func TestWorld_DestroyRover(t *testing.T) { func TestWorld_GetSetMovePosition(t *testing.T) { world := NewWorld(4) - a, err := world.SpawnRover() + a, err := world.SpawnRover("tmp") assert.NoError(t, err) pos := maths.Vector{ @@ -97,9 +97,9 @@ func TestWorld_GetSetMovePosition(t *testing.T) { func TestWorld_RadarFromRover(t *testing.T) { // Create world that should have visible walls on the radar world := NewWorld(2) - a, err := world.SpawnRover() + a, err := world.SpawnRover("tmp") assert.NoError(t, err) - b, err := world.SpawnRover() + b, err := world.SpawnRover("tmp") assert.NoError(t, err) // Warp the rovers into position @@ -130,7 +130,7 @@ func TestWorld_RadarFromRover(t *testing.T) { func TestWorld_RoverDamage(t *testing.T) { world := NewWorld(2) - a, err := world.SpawnRover() + a, err := world.SpawnRover("tmp") assert.NoError(t, err) pos := maths.Vector{ @@ -160,7 +160,7 @@ func TestWorld_RoverDamage(t *testing.T) { func TestWorld_Daytime(t *testing.T) { world := NewWorld(1) - a, err := world.SpawnRover() + a, err := world.SpawnRover("tmp") assert.NoError(t, err) // Remove rover charge @@ -199,10 +199,10 @@ func TestWorld_Daytime(t *testing.T) { func TestWorld_Broadcast(t *testing.T) { world := NewWorld(8) - a, err := world.SpawnRover() + a, err := world.SpawnRover("tmp") assert.NoError(t, err) - b, err := world.SpawnRover() + b, err := world.SpawnRover("tmp") assert.NoError(t, err) // Warp rovers near to eachother @@ -265,7 +265,7 @@ func TestWorld_Sailing(t *testing.T) { world.Tick() // One initial tick to set the wind direction the first time world.Wind = roveapi.Bearing_North // Set the wind direction to north - name, err := world.SpawnRover() + name, err := world.SpawnRover("tmp") assert.NoError(t, err) // Warp the rover to 0,0 after clearing it From fdfcc88540587ead99d016ebf9e0e69c5e78ddb6 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 24 Jul 2020 22:50:35 +0100 Subject: [PATCH 192/228] Move the account registration into the world --- cmd/rove-server/internal/server.go | 12 ------------ pkg/rove/world.go | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/cmd/rove-server/internal/server.go b/cmd/rove-server/internal/server.go index 42392f3..7debe0a 100644 --- a/cmd/rove-server/internal/server.go +++ b/cmd/rove-server/internal/server.go @@ -210,17 +210,5 @@ func (s *Server) SpawnRoverForAccount(account string) (string, error) { return "", err } - err = s.world.Accountant.AssignData(account, "rover", inst) - if err != nil { - log.Printf("Failed to assign rover to account, %s", err) - - // Try and clear up the rover - if err := s.world.DestroyRover(inst); err != nil { - log.Printf("Failed to destroy rover after failed rover assign: %s", err) - } - - return "", err - } - return inst, nil } diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 922ab70..09d271a 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -97,7 +97,7 @@ func (w *World) SpawnRover(account string) (string, error) { // Append the rover to the list w.Rovers[rover.Name] = rover - return rover.Name, nil + return rover.Name, w.Accountant.AssignData(account, "rover", rover.Name) } // GetRover gets a specific rover by name From 57621d169aaa0669484eef832f9ee8f3678f5176 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 24 Jul 2020 22:50:47 +0100 Subject: [PATCH 193/228] Implement a test for transfer and fix bugs --- pkg/rove/command_test.go | 52 ++++++++++++++++++++++++++++++++++++++++ pkg/rove/world.go | 27 +++++++++++---------- 2 files changed, 66 insertions(+), 13 deletions(-) diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index 6560e53..13b95bf 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -1,6 +1,7 @@ package rove import ( + "encoding/json" "testing" "github.com/mdiluz/rove/pkg/maths" @@ -159,6 +160,57 @@ func TestCommand_Salvage(t *testing.T) { assert.Equal(t, roveapi.Object_ObjectUnknown, obj.Type) } +func TestCommand_Transfer(t *testing.T) { + w := NewWorld(8) + acc, err := w.Accountant.RegisterAccount("tmp") + assert.NoError(t, err) + nameA, err := w.SpawnRover(acc.Name) + assert.NoError(t, err) + + infoA, err := w.GetRover(nameA) + assert.NoError(t, err) + + // Drop a dormant rover on the current position + infoB := DefaultRover() + infoB.Name = "abc" + infoB.Pos = infoA.Pos + data, err := json.Marshal(infoB) + assert.NoError(t, err) + w.Atlas.SetObject(infoA.Pos, Object{Type: roveapi.Object_RoverDormant, Data: data}) + + // Enqueue a transfer as well as a dud command + err = w.Enqueue(nameA, + &roveapi.Command{Command: roveapi.CommandType_transfer}, + &roveapi.Command{Command: roveapi.CommandType_broadcast, Data: []byte("xyz")}) + assert.NoError(t, err) + w.Tick() + + // Ensure both command queues are empty + assert.Empty(t, w.CommandQueue[nameA]) + assert.Empty(t, w.CommandQueue[infoB.Name]) + + // Verify the account now controls the new rover + accountRover, err := w.Accountant.GetValue(acc.Name, "rover") + assert.NoError(t, err) + assert.Equal(t, infoB.Name, accountRover) + + // Verify the position now has a dormant rover + _, obj := w.Atlas.QueryPosition(infoA.Pos) + assert.Equal(t, roveapi.Object_RoverDormant, obj.Type) + + // Verify the stored data matches + var stored Rover + err = json.Unmarshal(obj.Data, &stored) + assert.NoError(t, err) + assert.Equal(t, infoA.Name, stored.Name) + + // Verify the new rover data matches what we put in + infoB2, err := w.GetRover(infoB.Name) + assert.NoError(t, err) + assert.Equal(t, infoB.Name, infoB2.Name) + +} + func TestCommand_Invalid(t *testing.T) { w := NewWorld(8) name, err := w.SpawnRover("tmp") diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 09d271a..bf68395 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -378,28 +378,26 @@ func (w *World) RoverTransfer(rover string) (string, error) { oldRover.AddLogEntryf("transferring to dormant rover %s", newRover.Name) newRover.AddLogEntryf("transferred from rover %s", oldRover.Name) - // Clear the old owner + // Transfer the ownership + w.Accountant.AssignData(oldRover.Owner, "rover", newRover.Name) + newRover.Owner = oldRover.Owner oldRover.Owner = "" - // Marshal old rover + // Place the old rover in the world oldRoverData, err := json.Marshal(oldRover) if err != nil { return "", err } - - // Add this new rover to tracking - w.Rovers[newRover.Name] = &newRover - - // Swap account rover to the dormant one - newRover.Owner = oldRover.Owner - w.Accountant.AssignData(oldRover.Owner, "rover", newRover.Name) - - // Place the old rover into the world w.Atlas.SetObject(oldRover.Pos, Object{Type: roveapi.Object_RoverDormant, Data: oldRoverData}) - // Remove old rover from current tracking + // Swap the rovers in the tracking + w.Rovers[newRover.Name] = &newRover delete(w.Rovers, oldRover.Name) + // Clear the command queues for both rovers + delete(w.CommandQueue, oldRover.Name) + delete(w.CommandQueue, newRover.Name) + return newRover.Name, nil } @@ -599,7 +597,10 @@ func (w *World) Tick() { } // Extract the first command in the queue - w.CommandQueue[rover] = cmds[1:] + // Only if the command queue still has entries + if _, ok := w.CommandQueue[rover]; ok { + w.CommandQueue[rover] = cmds[1:] + } } else { // Clean out the empty entry From a93ce97b0bcfe4e21331e6d0d31f3b00a5e3805b Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 24 Jul 2020 22:54:06 +0100 Subject: [PATCH 194/228] Only assign rovers to accounts if given an account --- pkg/rove/command_test.go | 14 +++++++------- pkg/rove/world.go | 8 +++++++- pkg/rove/world_test.go | 26 +++++++++++++------------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index 13b95bf..935e35d 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -11,7 +11,7 @@ import ( func TestCommand_Toggle(t *testing.T) { w := NewWorld(8) - a, err := w.SpawnRover("tmp") + a, err := w.SpawnRover("") assert.NoError(t, err) r, err := w.GetRover(a) @@ -37,7 +37,7 @@ func TestCommand_Toggle(t *testing.T) { func TestCommand_Turn(t *testing.T) { w := NewWorld(8) - a, err := w.SpawnRover("tmp") + a, err := w.SpawnRover("") assert.NoError(t, err) err = w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_turn, Bearing: roveapi.Bearing_NorthWest}) @@ -51,7 +51,7 @@ func TestCommand_Turn(t *testing.T) { func TestCommand_Stash(t *testing.T) { w := NewWorld(8) - name, err := w.SpawnRover("tmp") + name, err := w.SpawnRover("") assert.NoError(t, err) info, err := w.GetRover(name) @@ -79,7 +79,7 @@ func TestCommand_Stash(t *testing.T) { func TestCommand_Repair(t *testing.T) { w := NewWorld(8) - name, err := w.SpawnRover("tmp") + name, err := w.SpawnRover("") assert.NoError(t, err) info, err := w.GetRover(name) @@ -119,7 +119,7 @@ func TestCommand_Repair(t *testing.T) { func TestCommand_Broadcast(t *testing.T) { w := NewWorld(8) - name, err := w.SpawnRover("tmp") + name, err := w.SpawnRover("") assert.NoError(t, err) // Enqueue the broadcast and tick @@ -134,7 +134,7 @@ func TestCommand_Broadcast(t *testing.T) { func TestCommand_Salvage(t *testing.T) { w := NewWorld(8) - name, err := w.SpawnRover("tmp") + name, err := w.SpawnRover("") assert.NoError(t, err) info, err := w.GetRover(name) @@ -213,7 +213,7 @@ func TestCommand_Transfer(t *testing.T) { func TestCommand_Invalid(t *testing.T) { w := NewWorld(8) - name, err := w.SpawnRover("tmp") + name, err := w.SpawnRover("") assert.NoError(t, err) err = w.Enqueue(name, &roveapi.Command{Command: roveapi.CommandType_none}) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index bf68395..3d651da 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -97,7 +97,13 @@ func (w *World) SpawnRover(account string) (string, error) { // Append the rover to the list w.Rovers[rover.Name] = rover - return rover.Name, w.Accountant.AssignData(account, "rover", rover.Name) + var err error + // Only assign if we've been given an account + if len(account) > 0 { + err = w.Accountant.AssignData(account, "rover", rover.Name) + } + + return rover.Name, err } // GetRover gets a specific rover by name diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index d0c4c01..747a891 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -18,9 +18,9 @@ func TestNewWorld(t *testing.T) { func TestWorld_CreateRover(t *testing.T) { world := NewWorld(8) - a, err := world.SpawnRover("tmp") + a, err := world.SpawnRover("") assert.NoError(t, err) - b, err := world.SpawnRover("tmp") + b, err := world.SpawnRover("") assert.NoError(t, err) // Basic duplicate check @@ -33,7 +33,7 @@ func TestWorld_CreateRover(t *testing.T) { func TestWorld_GetRover(t *testing.T) { world := NewWorld(4) - a, err := world.SpawnRover("tmp") + a, err := world.SpawnRover("") assert.NoError(t, err) rover, err := world.GetRover(a) @@ -44,9 +44,9 @@ func TestWorld_GetRover(t *testing.T) { func TestWorld_DestroyRover(t *testing.T) { world := NewWorld(1) - a, err := world.SpawnRover("tmp") + a, err := world.SpawnRover("") assert.NoError(t, err) - b, err := world.SpawnRover("tmp") + b, err := world.SpawnRover("") assert.NoError(t, err) err = world.DestroyRover(a) @@ -62,7 +62,7 @@ func TestWorld_DestroyRover(t *testing.T) { func TestWorld_GetSetMovePosition(t *testing.T) { world := NewWorld(4) - a, err := world.SpawnRover("tmp") + a, err := world.SpawnRover("") assert.NoError(t, err) pos := maths.Vector{ @@ -97,9 +97,9 @@ func TestWorld_GetSetMovePosition(t *testing.T) { func TestWorld_RadarFromRover(t *testing.T) { // Create world that should have visible walls on the radar world := NewWorld(2) - a, err := world.SpawnRover("tmp") + a, err := world.SpawnRover("") assert.NoError(t, err) - b, err := world.SpawnRover("tmp") + b, err := world.SpawnRover("") assert.NoError(t, err) // Warp the rovers into position @@ -130,7 +130,7 @@ func TestWorld_RadarFromRover(t *testing.T) { func TestWorld_RoverDamage(t *testing.T) { world := NewWorld(2) - a, err := world.SpawnRover("tmp") + a, err := world.SpawnRover("") assert.NoError(t, err) pos := maths.Vector{ @@ -160,7 +160,7 @@ func TestWorld_RoverDamage(t *testing.T) { func TestWorld_Daytime(t *testing.T) { world := NewWorld(1) - a, err := world.SpawnRover("tmp") + a, err := world.SpawnRover("") assert.NoError(t, err) // Remove rover charge @@ -199,10 +199,10 @@ func TestWorld_Daytime(t *testing.T) { func TestWorld_Broadcast(t *testing.T) { world := NewWorld(8) - a, err := world.SpawnRover("tmp") + a, err := world.SpawnRover("") assert.NoError(t, err) - b, err := world.SpawnRover("tmp") + b, err := world.SpawnRover("") assert.NoError(t, err) // Warp rovers near to eachother @@ -265,7 +265,7 @@ func TestWorld_Sailing(t *testing.T) { world.Tick() // One initial tick to set the wind direction the first time world.Wind = roveapi.Bearing_North // Set the wind direction to north - name, err := world.SpawnRover("tmp") + name, err := world.SpawnRover("") assert.NoError(t, err) // Warp the rover to 0,0 after clearing it From a0e04b7e3a287ee842d9240edd57f18e7e4271d3 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 24 Jul 2020 22:56:35 +0100 Subject: [PATCH 195/228] Placed dormant world rovers randomly have better base stats --- pkg/rove/worldgen.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/rove/worldgen.go b/pkg/rove/worldgen.go index e36b7b6..724837d 100644 --- a/pkg/rove/worldgen.go +++ b/pkg/rove/worldgen.go @@ -3,6 +3,7 @@ package rove import ( "encoding/json" "log" + "math/rand" "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/proto/roveapi" @@ -76,6 +77,12 @@ func (g *NoiseWorldGen) GetObject(v maths.Vector) (obj Object) { // Set the rover variables r.Pos = v + // Upgrade this rover randomly + r.MaximumCharge += rand.Int() % 3 + r.MaximumIntegrity += rand.Int() % 3 + r.Capacity += rand.Int() % 3 + r.Range += rand.Int() % 3 + // For now, mark the log as corrupted r.AddLogEntryf("log corrupted") From 7be0f83c5ea64bdcaf3635bc747e664fb54eaf20 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 24 Jul 2020 22:58:59 +0100 Subject: [PATCH 196/228] Fix golanglint missing error check --- pkg/rove/world.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 3d651da..27ded3b 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -385,7 +385,10 @@ func (w *World) RoverTransfer(rover string) (string, error) { newRover.AddLogEntryf("transferred from rover %s", oldRover.Name) // Transfer the ownership - w.Accountant.AssignData(oldRover.Owner, "rover", newRover.Name) + err = w.Accountant.AssignData(oldRover.Owner, "rover", newRover.Name) + if err != nil { + return "", err + } newRover.Owner = oldRover.Owner oldRover.Owner = "" From 5d4fd801c108607b07979eaade39dc05333a9bab Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 24 Jul 2020 23:22:46 +0100 Subject: [PATCH 197/228] Add the starting wind as north and ensure it's only updated the next day --- pkg/rove/world.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 27ded3b..7e22323 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -59,6 +59,7 @@ func NewWorld(chunkSize int) *World { TicksPerDay: 24, CurrentTicks: 0, Accountant: accounts.NewSimpleAccountant(), + Wind: roveapi.Bearing_North, } } @@ -617,11 +618,6 @@ func (w *World) Tick() { } } - // Change the wind every day - if (w.CurrentTicks % w.TicksPerDay) == 0 { - w.Wind = roveapi.Bearing((rand.Int() % 8) + 1) // Random cardinal bearing - } - // Move all the rovers based on current wind and sails for n, r := range w.Rovers { // Skip if we're not catching the wind @@ -675,6 +671,11 @@ func (w *World) Tick() { // Increment the current tick count w.CurrentTicks++ + + // Change the wind every day + if (w.CurrentTicks % w.TicksPerDay) == 0 { + w.Wind = roveapi.Bearing((rand.Int() % 8) + 1) // Random cardinal bearing + } } // ExecuteCommand will execute a single command From f9b3ce3edbd6087987c1b79dae97568f33f973db Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 25 Jul 2020 23:13:05 +0100 Subject: [PATCH 198/228] Destroy the rover when it has 0 integrity --- pkg/rove/world.go | 44 +++++++++++++++++++++++++++++++++--------- pkg/rove/world_test.go | 20 +++++++++++++++++-- 2 files changed, 53 insertions(+), 11 deletions(-) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 7e22323..ea1fdd3 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -67,7 +67,11 @@ func NewWorld(chunkSize int) *World { func (w *World) SpawnRover(account string) (string, error) { w.worldMutex.Lock() defer w.worldMutex.Unlock() + return w.spawnRover(account) +} +// spawnRover adds an rover to the game (without lock) +func (w *World) spawnRover(account string) (string, error) { // Initialise the rover rover := DefaultRover() @@ -176,17 +180,28 @@ func (w *World) RoverBroadcast(rover string, message []byte) (err error) { return } -// DestroyRover Removes an rover from the game -func (w *World) DestroyRover(rover string) error { - w.worldMutex.Lock() - defer w.worldMutex.Unlock() - - _, ok := w.Rovers[rover] +// destroyRover Removes an rover from the game +func (w *World) destroyRover(rover string) error { + r, ok := w.Rovers[rover] if !ok { return fmt.Errorf("no rover matching id") } + // Remove this rover from tracked rovers delete(w.Rovers, rover) + + r.Owner = "" + r.AddLogEntryf("rover destroyed") + + // Marshal the rover data + data, err := json.Marshal(r) + if err != nil { + return err + } + + // Place the dormant rover down + w.Atlas.SetObject(r.Pos, Object{Type: roveapi.Object_RoverDormant, Data: data}) + return nil } @@ -276,9 +291,20 @@ func (w *World) TryMoveRover(rover string, b roveapi.Bearing) (maths.Vector, err i.AddLogEntryf("tried to move %s to %+v", b.String(), newPos) i.Integrity = i.Integrity - 1 i.AddLogEntryf("had a collision, new integrity %d", i.Integrity) - // TODO: The rover needs to be left dormant with the player - //if i.Integrity == 0 { - //} + + if i.Integrity == 0 { + // The rover has died destroy it + err := w.destroyRover(rover) + if err != nil { + return maths.Vector{}, err + } + + // Spawn a new one for this account + _, err = w.spawnRover(i.Owner) + if err != nil { + return maths.Vector{}, err + } + } } return i.Pos, nil diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index 747a891..8363c0b 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -49,7 +49,7 @@ func TestWorld_DestroyRover(t *testing.T) { b, err := world.SpawnRover("") assert.NoError(t, err) - err = world.DestroyRover(a) + err = world.destroyRover(a) assert.NoError(t, err, "Error returned from rover destroy") // Basic duplicate check @@ -130,7 +130,9 @@ func TestWorld_RadarFromRover(t *testing.T) { func TestWorld_RoverDamage(t *testing.T) { world := NewWorld(2) - a, err := world.SpawnRover("") + acc, err := world.Accountant.RegisterAccount("tmp") + assert.NoError(t, err) + a, err := world.SpawnRover(acc.Name) assert.NoError(t, err) pos := maths.Vector{ @@ -155,6 +157,20 @@ func TestWorld_RoverDamage(t *testing.T) { assert.NoError(t, err, "couldn't get rover info") assert.Equal(t, info.Integrity-1, newinfo.Integrity, "rover should have lost integrity") assert.Contains(t, newinfo.Logs[len(newinfo.Logs)-1].Text, "collision", "Rover logs should contain the collision") + + // Keep moving to damage the rover + for i := 0; i < info.Integrity-1; i++ { + vec, err := world.TryMoveRover(a, roveapi.Bearing_North) + assert.NoError(t, err, "Failed to move rover") + assert.Equal(t, pos, vec, "Rover managed to move into large rock") + } + + // Rover should have been destroyed now + _, err = world.GetRover(a) + assert.Error(t, err) + + _, obj := world.Atlas.QueryPosition(info.Pos) + assert.Equal(t, roveapi.Object_RoverDormant, obj.Type) } func TestWorld_Daytime(t *testing.T) { From cd97220a11969c3219fa8f9ea965d6d4631d3295 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 25 Jul 2020 23:18:21 +0100 Subject: [PATCH 199/228] Perform rover destruction during the main server tick --- pkg/rove/world.go | 46 +++++++++++++++++++++++------------------- pkg/rove/world_test.go | 5 ++++- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index ea1fdd3..dc163f3 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -63,15 +63,11 @@ func NewWorld(chunkSize int) *World { } } -// SpawnRover adds an rover to the game +// SpawnRover adds an rover to the game (without lock) func (w *World) SpawnRover(account string) (string, error) { w.worldMutex.Lock() defer w.worldMutex.Unlock() - return w.spawnRover(account) -} -// spawnRover adds an rover to the game (without lock) -func (w *World) spawnRover(account string) (string, error) { // Initialise the rover rover := DefaultRover() @@ -180,8 +176,11 @@ func (w *World) RoverBroadcast(rover string, message []byte) (err error) { return } -// destroyRover Removes an rover from the game -func (w *World) destroyRover(rover string) error { +// DestroyRover Removes an rover from the game +func (w *World) DestroyRover(rover string) error { + w.worldMutex.Lock() + defer w.worldMutex.Unlock() + r, ok := w.Rovers[rover] if !ok { return fmt.Errorf("no rover matching id") @@ -291,20 +290,6 @@ func (w *World) TryMoveRover(rover string, b roveapi.Bearing) (maths.Vector, err i.AddLogEntryf("tried to move %s to %+v", b.String(), newPos) i.Integrity = i.Integrity - 1 i.AddLogEntryf("had a collision, new integrity %d", i.Integrity) - - if i.Integrity == 0 { - // The rover has died destroy it - err := w.destroyRover(rover) - if err != nil { - return maths.Vector{}, err - } - - // Spawn a new one for this account - _, err = w.spawnRover(i.Owner) - if err != nil { - return maths.Vector{}, err - } - } } return i.Pos, nil @@ -695,6 +680,25 @@ func (w *World) Tick() { } } + // Check all rover integrities + for _, r := range w.Rovers { + if r.Integrity <= 0 { + // The rover has died destroy it + err := w.DestroyRover(r.Name) + if err != nil { + log.Println(err) + // TODO: Report this error somehow + } + + // Spawn a new one for this account + _, err = w.SpawnRover(r.Owner) + if err != nil { + log.Println(err) + // TODO: Report this error somehow + } + } + } + // Increment the current tick count w.CurrentTicks++ diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index 8363c0b..afc8f53 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -49,7 +49,7 @@ func TestWorld_DestroyRover(t *testing.T) { b, err := world.SpawnRover("") assert.NoError(t, err) - err = world.destroyRover(a) + err = world.DestroyRover(a) assert.NoError(t, err, "Error returned from rover destroy") // Basic duplicate check @@ -165,6 +165,9 @@ func TestWorld_RoverDamage(t *testing.T) { assert.Equal(t, pos, vec, "Rover managed to move into large rock") } + // Tick the world to check for rover deaths + world.Tick() + // Rover should have been destroyed now _, err = world.GetRover(a) assert.Error(t, err) From 113090fbcb5b041d46709804a8ea1a89566f76ab Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 25 Jul 2020 23:39:13 +0100 Subject: [PATCH 200/228] Fix bug where we were still placing psuedo-random objects down --- pkg/rove/chunkAtlas.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pkg/rove/chunkAtlas.go b/pkg/rove/chunkAtlas.go index 88f1102..1903c7b 100644 --- a/pkg/rove/chunkAtlas.go +++ b/pkg/rove/chunkAtlas.go @@ -2,7 +2,6 @@ package rove import ( "log" - "math/rand" "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/proto/roveapi" @@ -111,15 +110,6 @@ func (a *chunkBasedAtlas) populate(chunk int) { } } - // Set up any objects - for i := 0; i < len(c.Tiles); i++ { - if rand.Intn(16) == 0 { - c.Objects[i] = Object{Type: roveapi.Object_RockLarge} - } else if rand.Intn(32) == 0 { - c.Objects[i] = Object{Type: roveapi.Object_RockSmall} - } - } - a.Chunks[chunk] = c } From 6891ec843968022f51180a9a6069f8001e0e760f Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 25 Jul 2020 23:39:32 +0100 Subject: [PATCH 201/228] Adjust the terrain scale to be much larger --- pkg/rove/worldgen.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/rove/worldgen.go b/pkg/rove/worldgen.go index 724837d..dd864b8 100644 --- a/pkg/rove/worldgen.go +++ b/pkg/rove/worldgen.go @@ -33,7 +33,7 @@ func NewNoiseWorldGen(seed int64) WorldGen { } const ( - terrainNoiseScale = 6 + terrainNoiseScale = 15 rockNoiseScale = 3 ) From cec61a9db75c02e4f0b9c258ea3bb4df42f0052c Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 26 Jul 2020 16:57:43 +0100 Subject: [PATCH 202/228] Big update to help text and add a simple description --- cmd/rove/main.go | 49 ++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index b3a7ed6..2340d0d 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -22,24 +22,28 @@ var defaultDataPath = path.Join(home, ".local/share/") // Command usage func printUsage() { - fmt.Fprintf(os.Stderr, "Usage: rove COMMAND [ARGS...]\n") - fmt.Fprintln(os.Stderr, "\nCommands") - fmt.Fprintln(os.Stderr, "\tserver-status prints the server status") - fmt.Fprintln(os.Stderr, "\tregister NAME registers an account and stores it (use with -name)") - fmt.Fprintln(os.Stderr, "\tcommand COMMAND [VAL...] issue commands to rover, accepts multiple, see below") - fmt.Fprintln(os.Stderr, "\tradar gathers radar data for the current rover") - fmt.Fprintln(os.Stderr, "\tstatus gets status info for current rover") - fmt.Fprintln(os.Stderr, "\tconfig [HOST] outputs the local config info, optionally sets host") - fmt.Fprintln(os.Stderr, "\thelp outputs this usage information") - fmt.Fprintln(os.Stderr, "\tversion outputs version info") - fmt.Fprintln(os.Stderr, "\nRover commands:") - fmt.Fprintln(os.Stderr, "\ttoggle toggles the sails, either catching the wind, or charging from the sun") - fmt.Fprintln(os.Stderr, "\tstash stores the object at the rover location in the inventory") - fmt.Fprintln(os.Stderr, "\trepair uses an inventory object to repair the rover") - fmt.Fprintln(os.Stderr, "\tbroadcast MSG broadcast a simple ASCII triplet to nearby rovers") - fmt.Fprintln(os.Stderr, "\tsalvage salvages a dormant rover for parts") - fmt.Fprintln(os.Stderr, "\nEnvironment") - fmt.Fprintln(os.Stderr, "\tROVE_USER_DATA path to user data, defaults to "+defaultDataPath) + fmt.Fprintln(os.Stderr, "Usage: rove ARG [OPT...]") + fmt.Fprintf(os.Stderr, "\n") + fmt.Fprintln(os.Stderr, "Arguments:") + fmt.Fprintln(os.Stderr, "\tversion outputs version") + fmt.Fprintln(os.Stderr, "\thelp outputs this usage text") + fmt.Fprintln(os.Stderr, "\tconfig [HOST] outputs the local config, optionally sets host") + fmt.Fprintln(os.Stderr, "\tserver-status prints the server status") + fmt.Fprintln(os.Stderr, "\tregister NAME registers an account and spawns a rover") + fmt.Fprintln(os.Stderr, "\tradar prints radar data in ASCII form") + fmt.Fprintln(os.Stderr, "\tstatus gets rover status") + fmt.Fprintln(os.Stderr, "\tcommand CMD [VAL...] queues commands, accepts multiple, see below") + fmt.Fprintf(os.Stderr, "\n") + fmt.Fprintln(os.Stderr, "Rover commands:") + fmt.Fprintln(os.Stderr, "\ttoggle toggles the current sail mode") + fmt.Fprintln(os.Stderr, "\tstash stores the object at the rover location in the inventory") + fmt.Fprintln(os.Stderr, "\trepair repairs the rover using inventory item") + fmt.Fprintln(os.Stderr, "\tbroadcast MSG broadcast a simple ASCII triplet to nearby rovers") + fmt.Fprintln(os.Stderr, "\tsalvage salvages a dormant rover for parts") + fmt.Fprintln(os.Stderr, "\ttransfer transfer's control into a dormant rover") + fmt.Fprintf(os.Stderr, "\n") + fmt.Fprintln(os.Stderr, "Environment") + fmt.Fprintln(os.Stderr, "\tROVE_USER_DATA path to user data, defaults to "+defaultDataPath) } const gRPCport = 9090 @@ -356,6 +360,15 @@ func InnerMain(command string, args ...string) error { func main() { // Bail without any args if len(os.Args) == 1 { + fmt.Fprintf(os.Stderr, "\n") + fmt.Fprintln(os.Stderr, "m mm mmm m m mmm") + fmt.Fprintln(os.Stderr, "#\" \" #\" \"# \"m m\" #\" #") + fmt.Fprintln(os.Stderr, "# # # #m# #\"\"\"\"") + fmt.Fprintln(os.Stderr, "# \"#m#\" # \"#mm\"") + fmt.Fprintf(os.Stderr, "\n") + fmt.Fprintln(os.Stderr, "Rove is an asychronous nomadic game about exploring a planet as part of a loose community.") + fmt.Fprintln(os.Stderr, "Visit https://mdiluz.github.io/rove/ for more information.") + fmt.Fprintf(os.Stderr, "\n") printUsage() os.Exit(1) } From bcf71f0bf9991f25f5f177f0d3d92cf16cbb47c9 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 26 Jul 2020 17:09:47 +0100 Subject: [PATCH 203/228] Add a "wait" command with a number --- pkg/rove/command_test.go | 37 ++++- pkg/rove/world.go | 39 +++-- proto/roveapi/roveapi.pb.go | 289 +++++++++++++++++++----------------- proto/roveapi/roveapi.proto | 11 +- 4 files changed, 218 insertions(+), 158 deletions(-) diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index 935e35d..592b40c 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -9,6 +9,15 @@ import ( "github.com/stretchr/testify/assert" ) +func TestCommand_Invalid(t *testing.T) { + w := NewWorld(8) + name, err := w.SpawnRover("") + assert.NoError(t, err) + + err = w.Enqueue(name, &roveapi.Command{Command: roveapi.CommandType_none}) + assert.Error(t, err) +} + func TestCommand_Toggle(t *testing.T) { w := NewWorld(8) a, err := w.SpawnRover("") @@ -211,11 +220,31 @@ func TestCommand_Transfer(t *testing.T) { } -func TestCommand_Invalid(t *testing.T) { +func TestCommand_Wait(t *testing.T) { w := NewWorld(8) - name, err := w.SpawnRover("") + a, err := w.SpawnRover("") assert.NoError(t, err) - err = w.Enqueue(name, &roveapi.Command{Command: roveapi.CommandType_none}) - assert.Error(t, err) + r, err := w.GetRover(a) + assert.NoError(t, err) + assert.Equal(t, roveapi.SailPosition_SolarCharging, r.SailPosition) + + err = w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_wait, Number: 5}, &roveapi.Command{Command: roveapi.CommandType_toggle}) + assert.NoError(t, err) + + // Tick 5 times during the wait + for i := 0; i < 5; i++ { + w.Tick() + + r, err = w.GetRover(a) + assert.NoError(t, err) + assert.Equal(t, roveapi.SailPosition_SolarCharging, r.SailPosition) + } + + // One last tick to do the toggle + w.Tick() + + r, err = w.GetRover(a) + assert.NoError(t, err) + assert.Equal(t, roveapi.SailPosition_CatchingWind, r.SailPosition) } diff --git a/pkg/rove/world.go b/pkg/rove/world.go index dc163f3..07e8e5e 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -582,6 +582,10 @@ func (w *World) Enqueue(rover string, commands ...*roveapi.Command) error { if c.GetBearing() == roveapi.Bearing_BearingUnknown { return fmt.Errorf("turn command given unknown bearing") } + case roveapi.CommandType_wait: + if c.GetNumber() <= 0 { + return fmt.Errorf("wait command must be given positie number of ticks to wait") + } case roveapi.CommandType_toggle: case roveapi.CommandType_stash: case roveapi.CommandType_repair: @@ -612,15 +616,16 @@ func (w *World) Tick() { if len(cmds) != 0 { // Execute the command - if err := w.ExecuteCommand(cmds[0], rover); err != nil { + if done, err := w.ExecuteCommand(cmds[0], rover); err != nil { log.Println(err) // TODO: Report this error somehow - } - // Extract the first command in the queue - // Only if the command queue still has entries - if _, ok := w.CommandQueue[rover]; ok { - w.CommandQueue[rover] = cmds[1:] + } else if done { + // Extract the first command in the queue + // Only if the command queue still has entries (the command may have modified this queue) + if _, ok := w.CommandQueue[rover]; ok { + w.CommandQueue[rover] = cmds[1:] + } } } else { @@ -709,46 +714,50 @@ func (w *World) Tick() { } // ExecuteCommand will execute a single command -func (w *World) ExecuteCommand(c *roveapi.Command, rover string) (err error) { +func (w *World) ExecuteCommand(c *roveapi.Command, rover string) (done bool, err error) { log.Printf("Executing command: %+v for %s\n", c.Command, rover) switch c.Command { case roveapi.CommandType_toggle: if _, err := w.RoverToggle(rover); err != nil { - return err + return true, err } case roveapi.CommandType_stash: if _, err := w.RoverStash(rover); err != nil { - return err + return true, err } case roveapi.CommandType_repair: if _, err := w.RoverRepair(rover); err != nil { - return err + return true, err } case roveapi.CommandType_broadcast: if err := w.RoverBroadcast(rover, c.GetData()); err != nil { - return err + return true, err } case roveapi.CommandType_turn: if _, err := w.RoverTurn(rover, c.GetBearing()); err != nil { - return err + return true, err } case roveapi.CommandType_salvage: if _, err := w.RoverSalvage(rover); err != nil { - return err + return true, err } case roveapi.CommandType_transfer: if _, err := w.RoverTransfer(rover); err != nil { - return err + return true, err } + case roveapi.CommandType_wait: + c.Number-- + return c.Number == 0, nil + default: - return fmt.Errorf("unknown command: %s", c.Command) + return true, fmt.Errorf("unknown command: %s", c.Command) } return diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index cc6fe07..2b4df0b 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -53,6 +53,8 @@ const ( CommandType_salvage CommandType = 6 // Transfers remote control into dormant rover CommandType_transfer CommandType = 7 + // Waits for the specified number of server ticks (requires number) + CommandType_wait CommandType = 8 ) // Enum value maps for CommandType. @@ -66,6 +68,7 @@ var ( 5: "broadcast", 6: "salvage", 7: "transfer", + 8: "wait", } CommandType_value = map[string]int32{ "none": 0, @@ -76,6 +79,7 @@ var ( "broadcast": 5, "salvage": 6, "transfer": 7, + "wait": 8, } ) @@ -640,6 +644,8 @@ type Command struct { Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` // move - the bearing for the rover to turn to Bearing Bearing `protobuf:"varint,3,opt,name=bearing,proto3,enum=roveapi.Bearing" json:"bearing,omitempty"` + // wait - the number of server ticks to wait + Number int32 `protobuf:"varint,4,opt,name=number,proto3" json:"number,omitempty"` } func (x *Command) Reset() { @@ -695,6 +701,13 @@ func (x *Command) GetBearing() Bearing { return Bearing_BearingUnknown } +func (x *Command) GetNumber() int32 { + if x != nil { + return x.Number + } + return 0 +} + // CommandRequest describes a set of commands to be requested for the rover type CommandRequest struct { state protoimpl.MessageState @@ -1408,144 +1421,146 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x79, 0x0a, 0x07, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, - 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x65, 0x61, - 0x72, 0x69, 0x6e, 0x67, 0x22, 0x6a, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, - 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, + 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x91, 0x01, 0x0a, 0x07, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x65, 0x61, + 0x72, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x65, + 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x6a, 0x0a, + 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, + 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x0c, + 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, + 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, + 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x75, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, + 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, + 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, + 0x23, 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0d, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x54, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x74, + 0x69, 0x6c, 0x65, 0x73, 0x12, 0x29, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, + 0x03, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, + 0x3b, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, + 0x4c, 0x6f, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, + 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, + 0x79, 0x22, 0xad, 0x01, 0x0a, 0x13, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x70, 0x65, 0x63, 0x69, + 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, + 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, + 0x6e, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, + 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, + 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, + 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x24, 0x0a, 0x0d, 0x6d, + 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, + 0x65, 0x22, 0x82, 0x02, 0x0a, 0x0b, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, + 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x39, 0x0a, + 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x61, + 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x73, 0x61, 0x69, 0x6c, + 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, + 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, + 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, + 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, + 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x38, 0x0a, 0x0e, + 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, - 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, - 0x75, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, - 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x54, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x29, 0x0a, 0x07, 0x6f, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0f, 0x2e, 0x72, - 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, 0x6f, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, - 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, - 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, - 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, - 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xad, 0x01, 0x0a, 0x13, 0x52, 0x6f, 0x76, - 0x65, 0x72, 0x53, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, - 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, - 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, - 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, - 0x74, 0x79, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, - 0x72, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, - 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x22, 0x82, 0x02, 0x0a, 0x0b, 0x52, 0x6f, 0x76, - 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, - 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x65, 0x61, - 0x72, 0x69, 0x6e, 0x67, 0x12, 0x39, 0x0a, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x52, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1c, 0x0a, - 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, - 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, - 0x72, 0x67, 0x65, 0x12, 0x38, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, - 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x84, 0x01, - 0x0a, 0x0d, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x12, - 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x56, 0x65, 0x63, 0x74, - 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x24, 0x0a, 0x04, - 0x77, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x04, 0x77, 0x69, - 0x6e, 0x64, 0x12, 0x20, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, - 0x6c, 0x6f, 0x67, 0x73, 0x22, 0xa4, 0x01, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x73, 0x70, 0x65, 0x63, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x61, 0x64, 0x69, - 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, - 0x73, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x2a, 0x6e, 0x0a, 0x0b, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, - 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x10, 0x01, - 0x12, 0x08, 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, - 0x61, 0x73, 0x68, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, - 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x05, - 0x12, 0x0b, 0x0a, 0x07, 0x73, 0x61, 0x6c, 0x76, 0x61, 0x67, 0x65, 0x10, 0x06, 0x12, 0x0c, 0x0a, - 0x08, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x10, 0x07, 0x2a, 0x83, 0x01, 0x0a, 0x07, - 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, 0x72, 0x69, - 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x4e, - 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x45, - 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, 0x03, 0x12, - 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x04, 0x12, 0x09, - 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, - 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, 0x73, 0x74, - 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, - 0x08, 0x2a, 0x6a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, - 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x10, 0x0a, - 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, 0x02, 0x12, - 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, 0x12, 0x0d, - 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x12, 0x0e, 0x0a, - 0x0a, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x50, 0x61, 0x72, 0x74, 0x73, 0x10, 0x05, 0x2a, 0x37, 0x0a, - 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, - 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, - 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, - 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x2a, 0x4c, 0x0a, 0x0c, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, - 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x13, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, - 0x6e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x00, 0x12, - 0x10, 0x0a, 0x0c, 0x43, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x10, - 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x6f, 0x6c, 0x61, 0x72, 0x43, 0x68, 0x61, 0x72, 0x67, 0x69, - 0x6e, 0x67, 0x10, 0x02, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, - 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, - 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, - 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x84, 0x01, 0x0a, 0x0d, 0x52, 0x6f, 0x76, 0x65, 0x72, + 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x24, 0x0a, 0x04, 0x77, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, + 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x04, 0x77, 0x69, 0x6e, 0x64, 0x12, 0x20, 0x0a, 0x04, 0x6c, + 0x6f, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x22, 0xa4, 0x01, + 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x30, 0x0a, 0x04, 0x73, 0x70, 0x65, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x70, + 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x04, 0x73, 0x70, + 0x65, 0x63, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, + 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, + 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, + 0x69, 0x6e, 0x67, 0x73, 0x2a, 0x78, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, + 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0a, 0x0a, + 0x06, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x74, 0x75, 0x72, + 0x6e, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x03, 0x12, 0x0a, + 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, + 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x05, 0x12, 0x0b, 0x0a, 0x07, 0x73, 0x61, 0x6c, + 0x76, 0x61, 0x67, 0x65, 0x10, 0x06, 0x12, 0x0c, 0x0a, 0x08, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, + 0x65, 0x72, 0x10, 0x07, 0x12, 0x08, 0x0a, 0x04, 0x77, 0x61, 0x69, 0x74, 0x10, 0x08, 0x2a, 0x83, + 0x01, 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, + 0x61, 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, + 0x0a, 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, + 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, + 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, + 0x04, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, + 0x53, 0x6f, 0x75, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, + 0x65, 0x73, 0x74, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, + 0x73, 0x74, 0x10, 0x08, 0x2a, 0x6a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, + 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, + 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, + 0x12, 0x10, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, + 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, + 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, + 0x12, 0x0e, 0x0a, 0x0a, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x50, 0x61, 0x72, 0x74, 0x73, 0x10, 0x05, + 0x2a, 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, + 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, + 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, + 0x08, 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x2a, 0x4c, 0x0a, 0x0c, 0x53, 0x61, 0x69, + 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x13, 0x55, 0x6e, 0x6b, + 0x6e, 0x6f, 0x77, 0x6e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x57, 0x69, + 0x6e, 0x64, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x6f, 0x6c, 0x61, 0x72, 0x43, 0x68, 0x61, + 0x72, 0x67, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, + 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, + 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, + 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, + 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index 5470e19..46cb858 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -103,6 +103,8 @@ enum CommandType { salvage = 6; // Transfers remote control into dormant rover transfer = 7; + // Waits for the specified number of server ticks (requires number) + wait = 8; } // Bearing represents a compass direction @@ -124,11 +126,15 @@ message Command { // The command type CommandType command = 1; - // broadcast - a simple message, must be composed of up to 3 printable ASCII glyphs (32-126) + // broadcast - a simple message, must be composed of up to 3 printable ASCII + // glyphs (32-126) bytes data = 2; // move - the bearing for the rover to turn to Bearing bearing = 3; + + // wait - the number of server ticks to wait + int32 number = 4; } // CommandRequest describes a set of commands to be requested for the rover @@ -164,7 +170,8 @@ enum Object { // RockLarge is a large blocking rock RockLarge = 4; - // RoverParts is one unit of rover parts, used for repairing and fixing the rover + // RoverParts is one unit of rover parts, used for repairing and fixing the + // rover RoverParts = 5; } From 15146035177e6ba8da33bb26861beb70b905a1bb Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 26 Jul 2020 17:19:04 +0100 Subject: [PATCH 204/228] Allow number to be used in all commands --- pkg/rove/world.go | 43 +++++++++++-------------------------- proto/roveapi/roveapi.pb.go | 42 +++++++++++++++++++----------------- proto/roveapi/roveapi.proto | 12 +++++------ 3 files changed, 40 insertions(+), 57 deletions(-) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 07e8e5e..4d08c7a 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -717,50 +717,31 @@ func (w *World) Tick() { func (w *World) ExecuteCommand(c *roveapi.Command, rover string) (done bool, err error) { log.Printf("Executing command: %+v for %s\n", c.Command, rover) + // Decrement the number of the command + c.Number-- + switch c.Command { case roveapi.CommandType_toggle: - if _, err := w.RoverToggle(rover); err != nil { - return true, err - } + _, err = w.RoverToggle(rover) case roveapi.CommandType_stash: - if _, err := w.RoverStash(rover); err != nil { - return true, err - } - + _, err = w.RoverStash(rover) case roveapi.CommandType_repair: - if _, err := w.RoverRepair(rover); err != nil { - return true, err - } - + _, err = w.RoverRepair(rover) case roveapi.CommandType_broadcast: - if err := w.RoverBroadcast(rover, c.GetData()); err != nil { - return true, err - } - + err = w.RoverBroadcast(rover, c.GetData()) case roveapi.CommandType_turn: - if _, err := w.RoverTurn(rover, c.GetBearing()); err != nil { - return true, err - } - + _, err = w.RoverTurn(rover, c.GetBearing()) case roveapi.CommandType_salvage: - if _, err := w.RoverSalvage(rover); err != nil { - return true, err - } - + _, err = w.RoverSalvage(rover) case roveapi.CommandType_transfer: - if _, err := w.RoverTransfer(rover); err != nil { - return true, err - } - + _, err = w.RoverTransfer(rover) case roveapi.CommandType_wait: - c.Number-- - return c.Number == 0, nil - + // Nothing to do default: return true, fmt.Errorf("unknown command: %s", c.Command) } - return + return c.Number <= 0, err } // Daytime returns if it's currently daytime diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index 2b4df0b..4c0178e 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -53,7 +53,7 @@ const ( CommandType_salvage CommandType = 6 // Transfers remote control into dormant rover CommandType_transfer CommandType = 7 - // Waits for the specified number of server ticks (requires number) + // Waits before performing the next command CommandType_wait CommandType = 8 ) @@ -193,7 +193,8 @@ const ( Object_RockSmall Object = 3 // RockLarge is a large blocking rock Object_RockLarge Object = 4 - // RoverParts is one unit of rover parts, used for repairing and fixing the rover + // RoverParts is one unit of rover parts, used for repairing and fixing the + // rover Object_RoverParts Object = 5 ) @@ -640,12 +641,13 @@ type Command struct { // The command type Command CommandType `protobuf:"varint,1,opt,name=command,proto3,enum=roveapi.CommandType" json:"command,omitempty"` - // broadcast - a simple message, must be composed of up to 3 printable ASCII glyphs (32-126) - Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + // The number of times to execute the command (assumes 1 if not present or 0) + Number int32 `protobuf:"varint,2,opt,name=number,proto3" json:"number,omitempty"` + // broadcast - a simple message, must be composed of up to 3 printable ASCII + // glyphs (32-126) + Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` // move - the bearing for the rover to turn to - Bearing Bearing `protobuf:"varint,3,opt,name=bearing,proto3,enum=roveapi.Bearing" json:"bearing,omitempty"` - // wait - the number of server ticks to wait - Number int32 `protobuf:"varint,4,opt,name=number,proto3" json:"number,omitempty"` + Bearing Bearing `protobuf:"varint,4,opt,name=bearing,proto3,enum=roveapi.Bearing" json:"bearing,omitempty"` } func (x *Command) Reset() { @@ -687,6 +689,13 @@ func (x *Command) GetCommand() CommandType { return CommandType_none } +func (x *Command) GetNumber() int32 { + if x != nil { + return x.Number + } + return 0 +} + func (x *Command) GetData() []byte { if x != nil { return x.Data @@ -701,13 +710,6 @@ func (x *Command) GetBearing() Bearing { return Bearing_BearingUnknown } -func (x *Command) GetNumber() int32 { - if x != nil { - return x.Number - } - return 0 -} - // CommandRequest describes a set of commands to be requested for the rover type CommandRequest struct { state protoimpl.MessageState @@ -1425,12 +1427,12 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x65, 0x61, - 0x72, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x65, - 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x6a, 0x0a, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x12, 0x0a, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, + 0x61, 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, + 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x22, 0x6a, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index 46cb858..21c992b 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -103,7 +103,7 @@ enum CommandType { salvage = 6; // Transfers remote control into dormant rover transfer = 7; - // Waits for the specified number of server ticks (requires number) + // Waits before performing the next command wait = 8; } @@ -126,15 +126,15 @@ message Command { // The command type CommandType command = 1; + // The number of times to execute the command (assumes 1 if not present or 0) + int32 number = 2; + // broadcast - a simple message, must be composed of up to 3 printable ASCII // glyphs (32-126) - bytes data = 2; + bytes data = 3; // move - the bearing for the rover to turn to - Bearing bearing = 3; - - // wait - the number of server ticks to wait - int32 number = 4; + Bearing bearing = 4; } // CommandRequest describes a set of commands to be requested for the rover From c0d4a809c9f88d61a84ad1b23a207adbafd101a6 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 26 Jul 2020 17:31:09 +0100 Subject: [PATCH 205/228] Update command line client to allow specifying command number --- cmd/rove/main.go | 43 +++++++++++++++++++++++++++++-------------- cmd/rove/main_test.go | 4 ++++ 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 2340d0d..6613121 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -8,6 +8,7 @@ import ( "os" "path" "path/filepath" + "strconv" "time" "github.com/mdiluz/rove/cmd/rove/internal" @@ -25,22 +26,23 @@ func printUsage() { fmt.Fprintln(os.Stderr, "Usage: rove ARG [OPT...]") fmt.Fprintf(os.Stderr, "\n") fmt.Fprintln(os.Stderr, "Arguments:") - fmt.Fprintln(os.Stderr, "\tversion outputs version") - fmt.Fprintln(os.Stderr, "\thelp outputs this usage text") - fmt.Fprintln(os.Stderr, "\tconfig [HOST] outputs the local config, optionally sets host") - fmt.Fprintln(os.Stderr, "\tserver-status prints the server status") - fmt.Fprintln(os.Stderr, "\tregister NAME registers an account and spawns a rover") - fmt.Fprintln(os.Stderr, "\tradar prints radar data in ASCII form") - fmt.Fprintln(os.Stderr, "\tstatus gets rover status") - fmt.Fprintln(os.Stderr, "\tcommand CMD [VAL...] queues commands, accepts multiple, see below") + fmt.Fprintln(os.Stderr, "\tversion outputs version") + fmt.Fprintln(os.Stderr, "\thelp outputs this usage text") + fmt.Fprintln(os.Stderr, "\tconfig [HOST] outputs the local config, optionally sets host") + fmt.Fprintln(os.Stderr, "\tserver-status prints the server status") + fmt.Fprintln(os.Stderr, "\tregister NAME registers an account and spawns a rover") + fmt.Fprintln(os.Stderr, "\tradar prints radar data in ASCII form") + fmt.Fprintln(os.Stderr, "\tstatus gets rover status") + fmt.Fprintln(os.Stderr, "\tcommand [NUM] CMD [VAL...] queues commands, accepts multiple, see below") fmt.Fprintf(os.Stderr, "\n") fmt.Fprintln(os.Stderr, "Rover commands:") - fmt.Fprintln(os.Stderr, "\ttoggle toggles the current sail mode") - fmt.Fprintln(os.Stderr, "\tstash stores the object at the rover location in the inventory") - fmt.Fprintln(os.Stderr, "\trepair repairs the rover using inventory item") - fmt.Fprintln(os.Stderr, "\tbroadcast MSG broadcast a simple ASCII triplet to nearby rovers") - fmt.Fprintln(os.Stderr, "\tsalvage salvages a dormant rover for parts") - fmt.Fprintln(os.Stderr, "\ttransfer transfer's control into a dormant rover") + fmt.Fprintln(os.Stderr, "\ttoggle toggles the current sail mode") + fmt.Fprintln(os.Stderr, "\tstash stores the object at the rover location in the inventory") + fmt.Fprintln(os.Stderr, "\trepair repairs the rover using inventory item") + fmt.Fprintln(os.Stderr, "\tbroadcast MSG broadcast a simple ASCII triplet to nearby rovers") + fmt.Fprintln(os.Stderr, "\tsalvage salvages a dormant rover for parts") + fmt.Fprintln(os.Stderr, "\ttransfer transfer's control into a dormant rover") + fmt.Fprintln(os.Stderr, "\twait waits before performing the next command") fmt.Fprintf(os.Stderr, "\n") fmt.Fprintln(os.Stderr, "Environment") fmt.Fprintln(os.Stderr, "\tROVE_USER_DATA path to user data, defaults to "+defaultDataPath) @@ -236,6 +238,16 @@ func InnerMain(command string, args ...string) error { // Iterate through each command var commands []*roveapi.Command for i := 0; i < len(args); i++ { + number := 0 + num, err := strconv.Atoi(args[i]) + if err == nil { + number = num + i++ + if i >= len(args) { + return fmt.Errorf("must pass command after number") + } + } + switch args[i] { case "turn": i++ @@ -250,6 +262,7 @@ func InnerMain(command string, args ...string) error { &roveapi.Command{ Command: roveapi.CommandType_turn, Bearing: b, + Number: int32(number), }, ) case "broadcast": @@ -263,6 +276,7 @@ func InnerMain(command string, args ...string) error { &roveapi.Command{ Command: roveapi.CommandType_broadcast, Data: []byte(args[i]), + Number: int32(number), }, ) default: @@ -270,6 +284,7 @@ func InnerMain(command string, args ...string) error { commands = append(commands, &roveapi.Command{ Command: roveapi.CommandType(roveapi.CommandType_value[args[i]]), + Number: int32(number), }, ) } diff --git a/cmd/rove/main_test.go b/cmd/rove/main_test.go index 2eb564c..50fdf98 100644 --- a/cmd/rove/main_test.go +++ b/cmd/rove/main_test.go @@ -54,8 +54,12 @@ func Test_InnerMain(t *testing.T) { assert.NoError(t, InnerMain("command", "stash")) assert.NoError(t, InnerMain("command", "repair")) assert.NoError(t, InnerMain("command", "broadcast", "abc")) + assert.NoError(t, InnerMain("command", "10", "wait")) + assert.NoError(t, InnerMain("command", "1", "wait", "turn", "NW", "toggle", "broadcast", "zyx")) // Give it malformed commands assert.Error(t, InnerMain("command", "unknown")) assert.Error(t, InnerMain("command", "broadcast")) + assert.Error(t, InnerMain("command", "0", "wait")) + assert.Error(t, InnerMain("command", "1")) } From 74e1cd4564eae3ba165ba3b6f187fd4a2394ecd0 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 26 Jul 2020 18:02:06 +0100 Subject: [PATCH 206/228] Convert number to repeat to avoid confusion --- cmd/rove/main.go | 24 ++++++++++++------------ cmd/rove/main_test.go | 1 - pkg/rove/command_test.go | 4 ++-- pkg/rove/world.go | 10 +++------- proto/roveapi/roveapi.pb.go | 12 ++++++------ proto/roveapi/roveapi.proto | 4 ++-- 6 files changed, 25 insertions(+), 30 deletions(-) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 6613121..9fc853a 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -26,14 +26,14 @@ func printUsage() { fmt.Fprintln(os.Stderr, "Usage: rove ARG [OPT...]") fmt.Fprintf(os.Stderr, "\n") fmt.Fprintln(os.Stderr, "Arguments:") - fmt.Fprintln(os.Stderr, "\tversion outputs version") - fmt.Fprintln(os.Stderr, "\thelp outputs this usage text") - fmt.Fprintln(os.Stderr, "\tconfig [HOST] outputs the local config, optionally sets host") - fmt.Fprintln(os.Stderr, "\tserver-status prints the server status") - fmt.Fprintln(os.Stderr, "\tregister NAME registers an account and spawns a rover") - fmt.Fprintln(os.Stderr, "\tradar prints radar data in ASCII form") - fmt.Fprintln(os.Stderr, "\tstatus gets rover status") - fmt.Fprintln(os.Stderr, "\tcommand [NUM] CMD [VAL...] queues commands, accepts multiple, see below") + fmt.Fprintln(os.Stderr, "\tversion outputs version") + fmt.Fprintln(os.Stderr, "\thelp outputs this usage text") + fmt.Fprintln(os.Stderr, "\tconfig [HOST] outputs the local config, optionally sets host") + fmt.Fprintln(os.Stderr, "\tserver-status prints the server status") + fmt.Fprintln(os.Stderr, "\tregister NAME registers an account and spawns a rover") + fmt.Fprintln(os.Stderr, "\tradar prints radar data in ASCII form") + fmt.Fprintln(os.Stderr, "\tstatus gets rover status") + fmt.Fprintln(os.Stderr, "\tcommand [REPEAT] CMD [VAL...] queues commands, accepts multiple in sequence for command values see below") fmt.Fprintf(os.Stderr, "\n") fmt.Fprintln(os.Stderr, "Rover commands:") fmt.Fprintln(os.Stderr, "\ttoggle toggles the current sail mode") @@ -244,7 +244,7 @@ func InnerMain(command string, args ...string) error { number = num i++ if i >= len(args) { - return fmt.Errorf("must pass command after number") + return fmt.Errorf("must pass command after repeat number") } } @@ -262,7 +262,7 @@ func InnerMain(command string, args ...string) error { &roveapi.Command{ Command: roveapi.CommandType_turn, Bearing: b, - Number: int32(number), + Repeat: int32(number), }, ) case "broadcast": @@ -276,7 +276,7 @@ func InnerMain(command string, args ...string) error { &roveapi.Command{ Command: roveapi.CommandType_broadcast, Data: []byte(args[i]), - Number: int32(number), + Repeat: int32(number), }, ) default: @@ -284,7 +284,7 @@ func InnerMain(command string, args ...string) error { commands = append(commands, &roveapi.Command{ Command: roveapi.CommandType(roveapi.CommandType_value[args[i]]), - Number: int32(number), + Repeat: int32(number), }, ) } diff --git a/cmd/rove/main_test.go b/cmd/rove/main_test.go index 50fdf98..d0e12d6 100644 --- a/cmd/rove/main_test.go +++ b/cmd/rove/main_test.go @@ -60,6 +60,5 @@ func Test_InnerMain(t *testing.T) { // Give it malformed commands assert.Error(t, InnerMain("command", "unknown")) assert.Error(t, InnerMain("command", "broadcast")) - assert.Error(t, InnerMain("command", "0", "wait")) assert.Error(t, InnerMain("command", "1")) } diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index 592b40c..dde7070 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -229,10 +229,10 @@ func TestCommand_Wait(t *testing.T) { assert.NoError(t, err) assert.Equal(t, roveapi.SailPosition_SolarCharging, r.SailPosition) - err = w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_wait, Number: 5}, &roveapi.Command{Command: roveapi.CommandType_toggle}) + err = w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_wait, Repeat: 4}, &roveapi.Command{Command: roveapi.CommandType_toggle}) assert.NoError(t, err) - // Tick 5 times during the wait + // Tick 5 times during the wait (1 normal execute + 4) for i := 0; i < 5; i++ { w.Tick() diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 4d08c7a..d2483b5 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -583,9 +583,6 @@ func (w *World) Enqueue(rover string, commands ...*roveapi.Command) error { return fmt.Errorf("turn command given unknown bearing") } case roveapi.CommandType_wait: - if c.GetNumber() <= 0 { - return fmt.Errorf("wait command must be given positie number of ticks to wait") - } case roveapi.CommandType_toggle: case roveapi.CommandType_stash: case roveapi.CommandType_repair: @@ -717,9 +714,6 @@ func (w *World) Tick() { func (w *World) ExecuteCommand(c *roveapi.Command, rover string) (done bool, err error) { log.Printf("Executing command: %+v for %s\n", c.Command, rover) - // Decrement the number of the command - c.Number-- - switch c.Command { case roveapi.CommandType_toggle: _, err = w.RoverToggle(rover) @@ -741,7 +735,9 @@ func (w *World) ExecuteCommand(c *roveapi.Command, rover string) (done bool, err return true, fmt.Errorf("unknown command: %s", c.Command) } - return c.Number <= 0, err + // Decrement the repeat number + c.Repeat-- + return c.Repeat < 0, err } // Daytime returns if it's currently daytime diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index 4c0178e..753c058 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -641,8 +641,8 @@ type Command struct { // The command type Command CommandType `protobuf:"varint,1,opt,name=command,proto3,enum=roveapi.CommandType" json:"command,omitempty"` - // The number of times to execute the command (assumes 1 if not present or 0) - Number int32 `protobuf:"varint,2,opt,name=number,proto3" json:"number,omitempty"` + // The number of times to repeat the command after the first + Repeat int32 `protobuf:"varint,2,opt,name=repeat,proto3" json:"repeat,omitempty"` // broadcast - a simple message, must be composed of up to 3 printable ASCII // glyphs (32-126) Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` @@ -689,9 +689,9 @@ func (x *Command) GetCommand() CommandType { return CommandType_none } -func (x *Command) GetNumber() int32 { +func (x *Command) GetRepeat() int32 { if x != nil { - return x.Number + return x.Repeat } return 0 } @@ -1427,8 +1427,8 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x12, 0x0a, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index 21c992b..9aad682 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -126,8 +126,8 @@ message Command { // The command type CommandType command = 1; - // The number of times to execute the command (assumes 1 if not present or 0) - int32 number = 2; + // The number of times to repeat the command after the first + int32 repeat = 2; // broadcast - a simple message, must be composed of up to 3 printable ASCII // glyphs (32-126) From e542999b91e167d8b90c63c131ccfed2d0cb6f4b Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 26 Jul 2020 18:10:55 +0100 Subject: [PATCH 207/228] Move test deployment out to it's own file --- Makefile | 4 ++-- docker-compose-test.yml | 31 +++++++++++++++++++++++++++++++ docker-compose.yml | 13 ------------- 3 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 docker-compose-test.yml diff --git a/Makefile b/Makefile index b73faf0..be0edcb 100644 --- a/Makefile +++ b/Makefile @@ -22,8 +22,8 @@ test: go test -v ./... @echo Integration tests - docker-compose up --build --exit-code-from=rove-tests --abort-on-container-exit rove-tests - docker-compose down + docker-compose -f docker-compose-test.yml up --build --exit-code-from=rove-tests --abort-on-container-exit rove-tests + docker-compose -f docker-compose-test.yml down go tool cover -html=/tmp/coverage-data/c.out -o /tmp/coverage.html @echo Done, coverage data can be found in /tmp/coverage.html diff --git a/docker-compose-test.yml b/docker-compose-test.yml new file mode 100644 index 0000000..64a71a8 --- /dev/null +++ b/docker-compose-test.yml @@ -0,0 +1,31 @@ +version: '3' + +services: + rove-test-server: + build: + context: . + dockerfile: Dockerfile + image: rove:latest + ports: + - "9090:9090" + environment: + - PORT=9090 + - DATA_PATH=/tmp/ + - WORDS_FILE=data/words_alpha.txt + - TICK_RATE=10 + command: [ "./rove-server"] + + rove-tests: + depends_on: [ rove-test-server ] + build: + context: . + dockerfile: Dockerfile + image: rove:latest + environment: + - ROVE_GRPC=rove-test-server + command: [ "./script/wait-for-it.sh", "rove-test-server:9090", "--", "go", "test", "-v", "./...", "--tags=integration", "-cover", "-coverprofile=/mnt/coverage-data/c.out", "-count", "1" ] + volumes: + - /tmp/coverage-data:/mnt/coverage-data:rw + + + diff --git a/docker-compose.yml b/docker-compose.yml index f1962a9..f84d876 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,17 +20,4 @@ services: - persistent-data:/mnt/rove-server:rw command: [ "./rove-server"] - rove-tests: - depends_on: [ rove-server ] - build: - context: . - dockerfile: Dockerfile - image: rove:latest - environment: - - ROVE_GRPC=rove-server - command: [ "./script/wait-for-it.sh", "rove-server:9090", "--", "go", "test", "-v", "./...", "--tags=integration", "-cover", "-coverprofile=/mnt/coverage-data/c.out", "-count", "1" ] - volumes: - - /tmp/coverage-data:/mnt/coverage-data:rw - - From a321e5d72f3a3356a6ec6621321c50173b372be7 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 26 Jul 2020 22:48:48 +0100 Subject: [PATCH 208/228] Add gRPC reflection to the server --- cmd/rove-server/internal/server.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/rove-server/internal/server.go b/cmd/rove-server/internal/server.go index 7debe0a..e32f64a 100644 --- a/cmd/rove-server/internal/server.go +++ b/cmd/rove-server/internal/server.go @@ -11,6 +11,7 @@ import ( "github.com/mdiluz/rove/proto/roveapi" "github.com/robfig/cron" "google.golang.org/grpc" + "google.golang.org/grpc/reflection" ) const ( @@ -105,6 +106,7 @@ func (s *Server) Initialise(fillWorld bool) (err error) { } s.grpcServ = grpc.NewServer() roveapi.RegisterRoveServer(s.grpcServ, s) + reflection.Register(s.grpcServ) return nil } From 70d92c2d5ee06c221fdaa3c1df44e03530322b8b Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 26 Jul 2020 23:10:39 +0100 Subject: [PATCH 209/228] Add TLS to gRPC --- cmd/rove-server/internal/server.go | 20 +++++++++++++++++++- cmd/rove-server/internal/server_test.go | 3 +++ docker-compose-test.yml | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/cmd/rove-server/internal/server.go b/cmd/rove-server/internal/server.go index e32f64a..4969687 100644 --- a/cmd/rove-server/internal/server.go +++ b/cmd/rove-server/internal/server.go @@ -4,6 +4,8 @@ import ( "fmt" "log" "net" + "os" + "path" "sync" "github.com/mdiluz/rove/pkg/persistence" @@ -11,9 +13,12 @@ import ( "github.com/mdiluz/rove/proto/roveapi" "github.com/robfig/cron" "google.golang.org/grpc" + "google.golang.org/grpc/credentials" "google.golang.org/grpc/reflection" ) +var cert = os.Getenv("CERT_NAME") + const ( // PersistentData will allow the server to load and save it's state PersistentData = iota @@ -104,7 +109,20 @@ func (s *Server) Initialise(fillWorld bool) (err error) { if err != nil { log.Fatalf("failed to listen: %v", err) } - s.grpcServ = grpc.NewServer() + + // Load TLS + var opts []grpc.ServerOption + if len(os.Getenv("NO_TLS")) == 0 { + pem := path.Join("/etc/letsencrypt/live/", cert, "cert.pem") + key := path.Join("/etc/letsencrypt/live/", cert, "privkey.pem") + creds, err := credentials.NewServerTLSFromFile(pem, key) + if err != nil { + log.Fatalf("failed to setup TLS: %v", err) + } + opts = append(opts, grpc.Creds(creds)) + } + + s.grpcServ = grpc.NewServer(opts...) roveapi.RegisterRoveServer(s.grpcServ, s) reflection.Register(s.grpcServ) diff --git a/cmd/rove-server/internal/server_test.go b/cmd/rove-server/internal/server_test.go index 36db679..40d4b80 100644 --- a/cmd/rove-server/internal/server_test.go +++ b/cmd/rove-server/internal/server_test.go @@ -1,6 +1,7 @@ package internal import ( + "os" "testing" ) @@ -30,6 +31,7 @@ func TestNewServer_OptionPersistentData(t *testing.T) { } func TestServer_Run(t *testing.T) { + os.Setenv("NO_TLS", "1") server := NewServer() if server == nil { t.Error("Failed to create server") @@ -45,6 +47,7 @@ func TestServer_Run(t *testing.T) { } func TestServer_RunPersistentData(t *testing.T) { + os.Setenv("NO_TLS", "1") server := NewServer(OptionPersistentData()) if server == nil { t.Error("Failed to create server") diff --git a/docker-compose-test.yml b/docker-compose-test.yml index 64a71a8..aec8cee 100644 --- a/docker-compose-test.yml +++ b/docker-compose-test.yml @@ -13,6 +13,7 @@ services: - DATA_PATH=/tmp/ - WORDS_FILE=data/words_alpha.txt - TICK_RATE=10 + - NO_TLS=1 command: [ "./rove-server"] rove-tests: From ac3844fe7af5da3fb1d685ed8cd081d1fc141c88 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 26 Jul 2020 23:26:36 +0100 Subject: [PATCH 210/228] Mount letsencrypt in the docker to read the certs --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index f84d876..05dd68f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,6 +18,7 @@ services: - TICK_RATE=3 volumes: - persistent-data:/mnt/rove-server:rw + - /etc/letsencrypt/:/etc/letsencrypt/ command: [ "./rove-server"] From 4821a901434ef4072afe62c728083b20dc31abcf Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 26 Jul 2020 23:29:58 +0100 Subject: [PATCH 211/228] Pass the cert name into the docker deployment --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 05dd68f..d5606f7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,7 @@ services: - DATA_PATH=/mnt/rove-server - WORDS_FILE=data/words_alpha.txt - TICK_RATE=3 + - CERT_NAME=${CERT_NAME} volumes: - persistent-data:/mnt/rove-server:rw - /etc/letsencrypt/:/etc/letsencrypt/ From 9b03ffb7f1a0cf4cb41d7f40fd4917dd86483971 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 26 Jul 2020 23:30:09 +0100 Subject: [PATCH 212/228] Add skip verify on the client for now --- cmd/rove/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 9fc853a..99a1f77 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -1,6 +1,7 @@ package main import ( + "crypto/tls" "encoding/json" "fmt" "io/ioutil" @@ -16,6 +17,7 @@ import ( "github.com/mdiluz/rove/proto/roveapi" "golang.org/x/net/context" "google.golang.org/grpc" + "google.golang.org/grpc/credentials" ) var home = os.Getenv("HOME") @@ -185,8 +187,12 @@ func InnerMain(command string, args ...string) error { return fmt.Errorf("no host set in %s, set one with '%s config {HOST}'", ConfigPath(), os.Args[0]) } + tls := &tls.Config{ + InsecureSkipVerify: true, + } + // Set up the server - clientConn, err := grpc.Dial(fmt.Sprintf("%s:%d", config.Host, gRPCport), grpc.WithInsecure()) + clientConn, err := grpc.Dial(fmt.Sprintf("%s:%d", config.Host, gRPCport), grpc.WithTransportCredentials(credentials.NewTLS(tls))) if err != nil { return err } From 71a0ef9920ac06845013d03ef24e6ceae3c3563f Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 26 Jul 2020 23:36:34 +0100 Subject: [PATCH 213/228] Use the fullchain.pem not the cert.pem as explained by letsencrypt --- cmd/rove-server/internal/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/rove-server/internal/server.go b/cmd/rove-server/internal/server.go index 4969687..e2b7e16 100644 --- a/cmd/rove-server/internal/server.go +++ b/cmd/rove-server/internal/server.go @@ -113,7 +113,7 @@ func (s *Server) Initialise(fillWorld bool) (err error) { // Load TLS var opts []grpc.ServerOption if len(os.Getenv("NO_TLS")) == 0 { - pem := path.Join("/etc/letsencrypt/live/", cert, "cert.pem") + pem := path.Join("/etc/letsencrypt/live/", cert, "fullchain.pem") key := path.Join("/etc/letsencrypt/live/", cert, "privkey.pem") creds, err := credentials.NewServerTLSFromFile(pem, key) if err != nil { From cf1dff2814586b04855230735552e81d3e0727f9 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 26 Jul 2020 23:41:52 +0100 Subject: [PATCH 214/228] Make sure the client verifies the TLS --- cmd/rove/main.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 99a1f77..4ea6a45 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -187,9 +187,7 @@ func InnerMain(command string, args ...string) error { return fmt.Errorf("no host set in %s, set one with '%s config {HOST}'", ConfigPath(), os.Args[0]) } - tls := &tls.Config{ - InsecureSkipVerify: true, - } + tls := &tls.Config{} // Set up the server clientConn, err := grpc.Dial(fmt.Sprintf("%s:%d", config.Host, gRPCport), grpc.WithTransportCredentials(credentials.NewTLS(tls))) From 4f2a7edeb1828bdbd6ac8aed00d214b640022cca Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 26 Jul 2020 23:42:23 +0100 Subject: [PATCH 215/228] Skip local tests, removing duplicate test runs --- Makefile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Makefile b/Makefile index be0edcb..3aedd83 100644 --- a/Makefile +++ b/Makefile @@ -18,10 +18,7 @@ gen: protoc --proto_path proto --go_out=plugins=grpc,paths=source_relative:proto/ proto/roveapi/roveapi.proto test: - @echo Unit tests - go test -v ./... - - @echo Integration tests + @echo Run unit and integration tests docker-compose -f docker-compose-test.yml up --build --exit-code-from=rove-tests --abort-on-container-exit rove-tests docker-compose -f docker-compose-test.yml down go tool cover -html=/tmp/coverage-data/c.out -o /tmp/coverage.html From 500e0f9557571f96a6b8b45e7ad971e47c574f23 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 26 Jul 2020 23:46:42 +0100 Subject: [PATCH 216/228] Skip the tls verify on the client side for now --- cmd/rove/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 4ea6a45..99a1f77 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -187,7 +187,9 @@ func InnerMain(command string, args ...string) error { return fmt.Errorf("no host set in %s, set one with '%s config {HOST}'", ConfigPath(), os.Args[0]) } - tls := &tls.Config{} + tls := &tls.Config{ + InsecureSkipVerify: true, + } // Set up the server clientConn, err := grpc.Dial(fmt.Sprintf("%s:%d", config.Host, gRPCport), grpc.WithTransportCredentials(credentials.NewTLS(tls))) From 94767f06d3c4c7e4c4f2dd23e4b1da9165ba2f74 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 26 Jul 2020 23:53:29 +0100 Subject: [PATCH 217/228] Fix to disable TLS in tests --- cmd/rove/main.go | 9 ++++++--- cmd/rove/main_test.go | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 99a1f77..06999d3 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -187,12 +187,15 @@ func InnerMain(command string, args ...string) error { return fmt.Errorf("no host set in %s, set one with '%s config {HOST}'", ConfigPath(), os.Args[0]) } - tls := &tls.Config{ - InsecureSkipVerify: true, + var opts []grpc.DialOption + if len(os.Getenv("NO_TLS")) == 0 { + opts = append(opts, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{}))) + } else { + opts = append(opts, grpc.WithInsecure()) } // Set up the server - clientConn, err := grpc.Dial(fmt.Sprintf("%s:%d", config.Host, gRPCport), grpc.WithTransportCredentials(credentials.NewTLS(tls))) + clientConn, err := grpc.Dial(fmt.Sprintf("%s:%d", config.Host, gRPCport), opts...) if err != nil { return err } diff --git a/cmd/rove/main_test.go b/cmd/rove/main_test.go index d0e12d6..25e08ae 100644 --- a/cmd/rove/main_test.go +++ b/cmd/rove/main_test.go @@ -13,6 +13,7 @@ import ( ) func Test_InnerMain(t *testing.T) { + os.Setenv("NO_TLS", "1") // Use temporary local user data tmp, err := ioutil.TempDir(os.TempDir(), "rove-") From 70f041ae5d16686b65ffb77c9528b216d19c4310 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 1 Aug 2020 11:09:15 +0100 Subject: [PATCH 218/228] Spawn rover parts in the world --- pkg/rove/worldgen.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkg/rove/worldgen.go b/pkg/rove/worldgen.go index dd864b8..a1593c6 100644 --- a/pkg/rove/worldgen.go +++ b/pkg/rove/worldgen.go @@ -35,6 +35,7 @@ func NewNoiseWorldGen(seed int64) WorldGen { const ( terrainNoiseScale = 15 rockNoiseScale = 3 + partsNoiseScale = 2 ) // GetTile returns the chosen tile at a location @@ -52,12 +53,21 @@ func (g *NoiseWorldGen) GetTile(v maths.Vector) roveapi.Tile { // GetObject returns the chosen object at a location func (g *NoiseWorldGen) GetObject(v maths.Vector) (obj Object) { - o := g.noise.Eval2(float64(v.X)/rockNoiseScale, float64(v.Y)/rockNoiseScale) + r := g.noise.Eval2(float64(v.X)/rockNoiseScale, float64(v.Y)/rockNoiseScale) switch { - case o > 0.6: + // Prioritise rocks + case r > 0.6: obj.Type = roveapi.Object_RockLarge - case o > 0.5: + case r > 0.5: obj.Type = roveapi.Object_RockSmall + + default: + // Otherwise, try some rover parts + p := g.noise.Eval2(float64(v.X)/partsNoiseScale, float64(v.Y)/partsNoiseScale) + switch { + case p > 0.8: + obj.Type = roveapi.Object_RoverParts + } } // Very rarely spawn a dormant rover From e66b899e2aef8ce5299dc01b589da760a8e9e6fb Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 1 Aug 2020 11:09:41 +0100 Subject: [PATCH 219/228] Increase the base rover range to 10 --- pkg/rove/rover.go | 2 +- pkg/rove/world_test.go | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/rove/rover.go b/pkg/rove/rover.go index d0fb9cb..bebde50 100644 --- a/pkg/rove/rover.go +++ b/pkg/rove/rover.go @@ -74,7 +74,7 @@ type Rover struct { // DefaultRover returns a default rover object with default settings func DefaultRover() *Rover { return &Rover{ - Range: 4, + Range: 10, Integrity: 10, MaximumIntegrity: 10, Capacity: 10, diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index afc8f53..f085d89 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -109,15 +109,16 @@ func TestWorld_RadarFromRover(t *testing.T) { world.Atlas.SetObject(maths.Vector{X: 0, Y: 0}, Object{Type: roveapi.Object_ObjectUnknown}) assert.NoError(t, world.WarpRover(a, maths.Vector{X: 0, Y: 0}), "Failed to warp rover") + r, err := world.GetRover(a) + assert.NoError(t, err) + radar, objs, err := world.RadarFromRover(a) assert.NoError(t, err, "Failed to get radar from rover") - fullRange := 4 + 4 + 1 + fullRange := r.Range + r.Range + 1 assert.Equal(t, fullRange*fullRange, len(radar), "Radar returned wrong length") assert.Equal(t, fullRange*fullRange, len(objs), "Radar returned wrong length") - // Test the expected values - assert.Equal(t, roveapi.Object_RoverLive, objs[1+fullRange]) - assert.Equal(t, roveapi.Object_RoverLive, objs[4+4*fullRange]) + // TODO: Verify the other rover is on the radar // Check the radar results are stable radar1, objs1, err := world.RadarFromRover(a) From 018c122861f7a1536b3fe8ee754dfd1c2207a477 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 1 Aug 2020 11:24:53 +0100 Subject: [PATCH 220/228] Stop spawning dormant rovers in the world --- pkg/rove/worldgen.go | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/pkg/rove/worldgen.go b/pkg/rove/worldgen.go index a1593c6..2abb447 100644 --- a/pkg/rove/worldgen.go +++ b/pkg/rove/worldgen.go @@ -1,10 +1,6 @@ package rove import ( - "encoding/json" - "log" - "math/rand" - "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/proto/roveapi" "github.com/ojrac/opensimplex-go" @@ -70,41 +66,5 @@ func (g *NoiseWorldGen) GetObject(v maths.Vector) (obj Object) { } } - // Very rarely spawn a dormant rover - if obj.Type == roveapi.Object_ObjectUnknown { - // TODO: Make this better, ideally with noise - if v.X%25 == 0 && v.Y%25 == 0 && v.X != 0 && v.Y != 0 { - obj.Type = roveapi.Object_RoverDormant - } - } - - // Post process any spawned objects - switch obj.Type { - case roveapi.Object_RoverDormant: - // Create the rover - r := DefaultRover() - - // Set the rover variables - r.Pos = v - - // Upgrade this rover randomly - r.MaximumCharge += rand.Int() % 3 - r.MaximumIntegrity += rand.Int() % 3 - r.Capacity += rand.Int() % 3 - r.Range += rand.Int() % 3 - - // For now, mark the log as corrupted - r.AddLogEntryf("log corrupted") - - // Marshal the rover data into the object data - b, err := json.Marshal(r) - if err != nil { - log.Fatalf("couldn't marshal rover, should never fail: %s", err) - } - - // Store the bytes - obj.Data = b - } - return obj } From 636f0ed7734cc3642eac9b9bda9e807c00a91ede Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 1 Aug 2020 11:26:10 +0100 Subject: [PATCH 221/228] Spawn rover parts a little more frequently --- pkg/rove/worldgen.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/rove/worldgen.go b/pkg/rove/worldgen.go index 2abb447..6cb425f 100644 --- a/pkg/rove/worldgen.go +++ b/pkg/rove/worldgen.go @@ -61,7 +61,7 @@ func (g *NoiseWorldGen) GetObject(v maths.Vector) (obj Object) { // Otherwise, try some rover parts p := g.noise.Eval2(float64(v.X)/partsNoiseScale, float64(v.Y)/partsNoiseScale) switch { - case p > 0.8: + case p > 0.7: obj.Type = roveapi.Object_RoverParts } } From 6a44633d40ae92c0c66e2baecae387ec9a9762ab Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 2 Aug 2020 11:28:14 +0100 Subject: [PATCH 222/228] Add rover parts to the cmdline pretty printer --- cmd/rove/internal/glyph.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/rove/internal/glyph.go b/cmd/rove/internal/glyph.go index eac12c0..4a774e7 100644 --- a/cmd/rove/internal/glyph.go +++ b/cmd/rove/internal/glyph.go @@ -25,6 +25,9 @@ const ( // GlyphRoverDormant represents a dormant rover GlyphRoverDormant = Glyph('r') + // GlyphRoverParts represents spare rover parts + GlyphRoverParts = Glyph('*') + // GlyphRockSmall is a small stashable rock GlyphRockSmall = Glyph('o') @@ -58,6 +61,8 @@ func ObjectGlyph(o roveapi.Object) Glyph { return GlyphRoverDormant case roveapi.Object_RockLarge: return GlyphRockLarge + case roveapi.Object_RoverParts: + return GlyphRoverParts } log.Fatalf("Unknown object type: %c", o) From 1200b0a2a2361e6ea26ff036367796b33c910868 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 2 Aug 2020 11:39:28 +0100 Subject: [PATCH 223/228] Add "upgrade" command to use the rover parts --- proto/roveapi/roveapi.pb.go | 526 +++++++++++++++++++++--------------- proto/roveapi/roveapi.proto | 44 ++- 2 files changed, 333 insertions(+), 237 deletions(-) diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index 753c058..81a6cb5 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -39,47 +39,51 @@ type CommandType int32 const ( CommandType_none CommandType = 0 - // Toggles the sails, either catching the wind, or charging from the sun - CommandType_toggle CommandType = 1 - // Turns the rover in the specified bearing (requires bearing) - CommandType_turn CommandType = 2 - // Stashes item at current location in rover inventory - CommandType_stash CommandType = 3 - // Repairs the rover using an inventory object - CommandType_repair CommandType = 4 - // Broadcasts a message to nearby rovers (requires data) - CommandType_broadcast CommandType = 5 - // Salvages a neighboring dormant rover for parts - CommandType_salvage CommandType = 6 - // Transfers remote control into dormant rover - CommandType_transfer CommandType = 7 // Waits before performing the next command - CommandType_wait CommandType = 8 + CommandType_wait CommandType = 1 + // Toggles the sails, either catching the wind, or charging from the sun + CommandType_toggle CommandType = 2 + // Turns the rover in the specified bearing (requires bearing) + CommandType_turn CommandType = 3 + // Stashes item at current location in rover inventory + CommandType_stash CommandType = 4 + // Repairs the rover using an inventory object + CommandType_repair CommandType = 5 + // Broadcasts a message to nearby rovers (requires data) + CommandType_broadcast CommandType = 6 + // Salvages a neighboring dormant rover for parts + CommandType_salvage CommandType = 7 + // Transfers remote control into dormant rover + CommandType_transfer CommandType = 8 + // Upgrades a chosen rover specification using 5 rover parts + CommandType_upgrade CommandType = 9 ) // Enum value maps for CommandType. var ( CommandType_name = map[int32]string{ 0: "none", - 1: "toggle", - 2: "turn", - 3: "stash", - 4: "repair", - 5: "broadcast", - 6: "salvage", - 7: "transfer", - 8: "wait", + 1: "wait", + 2: "toggle", + 3: "turn", + 4: "stash", + 5: "repair", + 6: "broadcast", + 7: "salvage", + 8: "transfer", + 9: "upgrade", } CommandType_value = map[string]int32{ "none": 0, - "toggle": 1, - "turn": 2, - "stash": 3, - "repair": 4, - "broadcast": 5, - "salvage": 6, - "transfer": 7, - "wait": 8, + "wait": 1, + "toggle": 2, + "turn": 3, + "stash": 4, + "repair": 5, + "broadcast": 6, + "salvage": 7, + "transfer": 8, + "upgrade": 9, } ) @@ -179,6 +183,62 @@ func (Bearing) EnumDescriptor() ([]byte, []int) { return file_roveapi_roveapi_proto_rawDescGZIP(), []int{1} } +// Describes the type of upgrade +type RoverUpgrade int32 + +const ( + RoverUpgrade_RoverUpgradeUnknown RoverUpgrade = 0 + RoverUpgrade_Range RoverUpgrade = 1 + RoverUpgrade_Capacity RoverUpgrade = 2 + RoverUpgrade_MaximumIntegrity RoverUpgrade = 3 + RoverUpgrade_MaximumCharge RoverUpgrade = 4 +) + +// Enum value maps for RoverUpgrade. +var ( + RoverUpgrade_name = map[int32]string{ + 0: "RoverUpgradeUnknown", + 1: "Range", + 2: "Capacity", + 3: "MaximumIntegrity", + 4: "MaximumCharge", + } + RoverUpgrade_value = map[string]int32{ + "RoverUpgradeUnknown": 0, + "Range": 1, + "Capacity": 2, + "MaximumIntegrity": 3, + "MaximumCharge": 4, + } +) + +func (x RoverUpgrade) Enum() *RoverUpgrade { + p := new(RoverUpgrade) + *p = x + return p +} + +func (x RoverUpgrade) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (RoverUpgrade) Descriptor() protoreflect.EnumDescriptor { + return file_roveapi_roveapi_proto_enumTypes[2].Descriptor() +} + +func (RoverUpgrade) Type() protoreflect.EnumType { + return &file_roveapi_roveapi_proto_enumTypes[2] +} + +func (x RoverUpgrade) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use RoverUpgrade.Descriptor instead. +func (RoverUpgrade) EnumDescriptor() ([]byte, []int) { + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{2} +} + // Types of objects type Object int32 @@ -229,11 +289,11 @@ func (x Object) String() string { } func (Object) Descriptor() protoreflect.EnumDescriptor { - return file_roveapi_roveapi_proto_enumTypes[2].Descriptor() + return file_roveapi_roveapi_proto_enumTypes[3].Descriptor() } func (Object) Type() protoreflect.EnumType { - return &file_roveapi_roveapi_proto_enumTypes[2] + return &file_roveapi_roveapi_proto_enumTypes[3] } func (x Object) Number() protoreflect.EnumNumber { @@ -242,7 +302,7 @@ func (x Object) Number() protoreflect.EnumNumber { // Deprecated: Use Object.Descriptor instead. func (Object) EnumDescriptor() ([]byte, []int) { - return file_roveapi_roveapi_proto_rawDescGZIP(), []int{2} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{3} } type Tile int32 @@ -285,11 +345,11 @@ func (x Tile) String() string { } func (Tile) Descriptor() protoreflect.EnumDescriptor { - return file_roveapi_roveapi_proto_enumTypes[3].Descriptor() + return file_roveapi_roveapi_proto_enumTypes[4].Descriptor() } func (Tile) Type() protoreflect.EnumType { - return &file_roveapi_roveapi_proto_enumTypes[3] + return &file_roveapi_roveapi_proto_enumTypes[4] } func (x Tile) Number() protoreflect.EnumNumber { @@ -298,7 +358,7 @@ func (x Tile) Number() protoreflect.EnumNumber { // Deprecated: Use Tile.Descriptor instead. func (Tile) EnumDescriptor() ([]byte, []int) { - return file_roveapi_roveapi_proto_rawDescGZIP(), []int{3} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{4} } // SailPosition represents the position of the sola sail @@ -337,11 +397,11 @@ func (x SailPosition) String() string { } func (SailPosition) Descriptor() protoreflect.EnumDescriptor { - return file_roveapi_roveapi_proto_enumTypes[4].Descriptor() + return file_roveapi_roveapi_proto_enumTypes[5].Descriptor() } func (SailPosition) Type() protoreflect.EnumType { - return &file_roveapi_roveapi_proto_enumTypes[4] + return &file_roveapi_roveapi_proto_enumTypes[5] } func (x SailPosition) Number() protoreflect.EnumNumber { @@ -350,7 +410,7 @@ func (x SailPosition) Number() protoreflect.EnumNumber { // Deprecated: Use SailPosition.Descriptor instead. func (SailPosition) EnumDescriptor() ([]byte, []int) { - return file_roveapi_roveapi_proto_rawDescGZIP(), []int{4} + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{5} } // ServerStatusRequest is an empty placeholder @@ -648,6 +708,8 @@ type Command struct { Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` // move - the bearing for the rover to turn to Bearing Bearing `protobuf:"varint,4,opt,name=bearing,proto3,enum=roveapi.Bearing" json:"bearing,omitempty"` + // upgrade - the upgrade to apply to the rover + Upgrade RoverUpgrade `protobuf:"varint,5,opt,name=upgrade,proto3,enum=roveapi.RoverUpgrade" json:"upgrade,omitempty"` } func (x *Command) Reset() { @@ -710,6 +772,13 @@ func (x *Command) GetBearing() Bearing { return Bearing_BearingUnknown } +func (x *Command) GetUpgrade() RoverUpgrade { + if x != nil { + return x.Upgrade + } + return RoverUpgrade_RoverUpgradeUnknown +} + // CommandRequest describes a set of commands to be requested for the rover type CommandRequest struct { state protoimpl.MessageState @@ -1423,7 +1492,7 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x91, 0x01, 0x0a, 0x07, 0x43, 0x6f, + 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xc2, 0x01, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, @@ -1432,137 +1501,148 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, - 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x22, 0x6a, 0x0a, - 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x63, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, - 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x0c, - 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, - 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, - 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x75, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, - 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, - 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, - 0x23, 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0d, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x54, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x74, - 0x69, 0x6c, 0x65, 0x73, 0x12, 0x29, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, - 0x03, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, - 0x3b, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x2f, 0x0a, + 0x07, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x55, 0x70, + 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x07, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x22, 0x6a, + 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, - 0x4c, 0x6f, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, - 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, - 0x79, 0x22, 0xad, 0x01, 0x0a, 0x13, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x70, 0x65, 0x63, 0x69, - 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, - 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, - 0x6e, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, - 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, - 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, - 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x24, 0x0a, 0x0d, 0x6d, - 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, - 0x65, 0x22, 0x82, 0x02, 0x0a, 0x0b, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, - 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x39, 0x0a, - 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x61, - 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x73, 0x61, 0x69, 0x6c, - 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, - 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, - 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, - 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, - 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x38, 0x0a, 0x0e, - 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x06, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x84, 0x01, 0x0a, 0x0d, 0x52, 0x6f, 0x76, 0x65, 0x72, - 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x24, 0x0a, 0x04, 0x77, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, + 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x08, + 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, + 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, + 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, + 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x75, 0x0a, 0x0d, 0x52, 0x61, 0x64, + 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, + 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, + 0x12, 0x23, 0x0a, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, + 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x54, 0x69, 0x6c, 0x65, 0x52, 0x05, + 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x29, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, + 0x18, 0x03, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, + 0x22, 0x3b, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, + 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, + 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x01, 0x79, 0x22, 0xad, 0x01, 0x0a, 0x13, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x70, 0x65, 0x63, + 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, + 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, + 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, + 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, + 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, + 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x24, 0x0a, 0x0d, + 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, + 0x67, 0x65, 0x22, 0x82, 0x02, 0x0a, 0x0b, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, - 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x04, 0x77, 0x69, 0x6e, 0x64, 0x12, 0x20, 0x0a, 0x04, 0x6c, - 0x6f, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, - 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x22, 0xa4, 0x01, - 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x30, 0x0a, 0x04, 0x73, 0x70, 0x65, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x70, - 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x04, 0x73, 0x70, - 0x65, 0x63, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, - 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, - 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, - 0x69, 0x6e, 0x67, 0x73, 0x2a, 0x78, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0a, 0x0a, - 0x06, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x74, 0x75, 0x72, - 0x6e, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x03, 0x12, 0x0a, - 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, - 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x05, 0x12, 0x0b, 0x0a, 0x07, 0x73, 0x61, 0x6c, - 0x76, 0x61, 0x67, 0x65, 0x10, 0x06, 0x12, 0x0c, 0x0a, 0x08, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, - 0x65, 0x72, 0x10, 0x07, 0x12, 0x08, 0x0a, 0x04, 0x77, 0x61, 0x69, 0x74, 0x10, 0x08, 0x2a, 0x83, - 0x01, 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, - 0x61, 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, - 0x0a, 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, - 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, - 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, - 0x04, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, - 0x53, 0x6f, 0x75, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, - 0x65, 0x73, 0x74, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, - 0x73, 0x74, 0x10, 0x08, 0x2a, 0x6a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, - 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, - 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, - 0x12, 0x10, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, - 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, - 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, - 0x12, 0x0e, 0x0a, 0x0a, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x50, 0x61, 0x72, 0x74, 0x73, 0x10, 0x05, - 0x2a, 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, - 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, - 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, - 0x08, 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x2a, 0x4c, 0x0a, 0x0c, 0x53, 0x61, 0x69, - 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x13, 0x55, 0x6e, 0x6b, - 0x6e, 0x6f, 0x77, 0x6e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x57, 0x69, - 0x6e, 0x64, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x6f, 0x6c, 0x61, 0x72, 0x43, 0x68, 0x61, - 0x72, 0x67, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, - 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, - 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, - 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, - 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, - 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, - 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x39, + 0x0a, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, + 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x73, 0x61, 0x69, + 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, + 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, + 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, + 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, + 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x38, 0x0a, + 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, + 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x84, 0x01, 0x0a, 0x0d, 0x52, 0x6f, 0x76, 0x65, + 0x72, 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x24, 0x0a, 0x04, 0x77, 0x69, 0x6e, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, + 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x04, 0x77, 0x69, 0x6e, 0x64, 0x12, 0x20, 0x0a, 0x04, + 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x22, 0xa4, + 0x01, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x30, 0x0a, 0x04, 0x73, 0x70, 0x65, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x53, + 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x04, 0x73, + 0x70, 0x65, 0x63, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, + 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, + 0x76, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x08, 0x72, 0x65, 0x61, + 0x64, 0x69, 0x6e, 0x67, 0x73, 0x2a, 0x85, 0x01, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, + 0x08, 0x0a, 0x04, 0x77, 0x61, 0x69, 0x74, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x74, 0x6f, 0x67, + 0x67, 0x6c, 0x65, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x10, 0x03, 0x12, + 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x04, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, + 0x70, 0x61, 0x69, 0x72, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, + 0x61, 0x73, 0x74, 0x10, 0x06, 0x12, 0x0b, 0x0a, 0x07, 0x73, 0x61, 0x6c, 0x76, 0x61, 0x67, 0x65, + 0x10, 0x07, 0x12, 0x0c, 0x0a, 0x08, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x10, 0x08, + 0x12, 0x0b, 0x0a, 0x07, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x10, 0x09, 0x2a, 0x83, 0x01, + 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, + 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, + 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, + 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, + 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x04, + 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x53, + 0x6f, 0x75, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, + 0x73, 0x74, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, 0x73, + 0x74, 0x10, 0x08, 0x2a, 0x69, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x55, 0x70, 0x67, 0x72, + 0x61, 0x64, 0x65, 0x12, 0x17, 0x0a, 0x13, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x55, 0x70, 0x67, 0x72, + 0x61, 0x64, 0x65, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, + 0x52, 0x61, 0x6e, 0x67, 0x65, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x61, 0x70, 0x61, 0x63, + 0x69, 0x74, 0x79, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x4d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, + 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x10, 0x03, 0x12, 0x11, 0x0a, 0x0d, 0x4d, + 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x2a, 0x6a, + 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, + 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, + 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x52, 0x6f, + 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, + 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x52, + 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x12, 0x0e, 0x0a, 0x0a, 0x52, 0x6f, + 0x76, 0x65, 0x72, 0x50, 0x61, 0x72, 0x74, 0x73, 0x10, 0x05, 0x2a, 0x37, 0x0a, 0x04, 0x54, 0x69, + 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, + 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, + 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x61, 0x6e, + 0x64, 0x10, 0x03, 0x2a, 0x4c, 0x0a, 0x0c, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x13, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x53, 0x61, + 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, + 0x43, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x10, 0x01, 0x12, 0x11, + 0x0a, 0x0d, 0x53, 0x6f, 0x6c, 0x61, 0x72, 0x43, 0x68, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x67, 0x10, + 0x02, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, + 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, + 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -1577,66 +1657,68 @@ func file_roveapi_roveapi_proto_rawDescGZIP() []byte { return file_roveapi_roveapi_proto_rawDescData } -var file_roveapi_roveapi_proto_enumTypes = make([]protoimpl.EnumInfo, 5) +var file_roveapi_roveapi_proto_enumTypes = make([]protoimpl.EnumInfo, 6) var file_roveapi_roveapi_proto_msgTypes = make([]protoimpl.MessageInfo, 17) var file_roveapi_roveapi_proto_goTypes = []interface{}{ (CommandType)(0), // 0: roveapi.CommandType (Bearing)(0), // 1: roveapi.Bearing - (Object)(0), // 2: roveapi.Object - (Tile)(0), // 3: roveapi.Tile - (SailPosition)(0), // 4: roveapi.SailPosition - (*ServerStatusRequest)(nil), // 5: roveapi.ServerStatusRequest - (*ServerStatusResponse)(nil), // 6: roveapi.ServerStatusResponse - (*RegisterRequest)(nil), // 7: roveapi.RegisterRequest - (*Account)(nil), // 8: roveapi.Account - (*RegisterResponse)(nil), // 9: roveapi.RegisterResponse - (*Command)(nil), // 10: roveapi.Command - (*CommandRequest)(nil), // 11: roveapi.CommandRequest - (*CommandResponse)(nil), // 12: roveapi.CommandResponse - (*RadarRequest)(nil), // 13: roveapi.RadarRequest - (*RadarResponse)(nil), // 14: roveapi.RadarResponse - (*StatusRequest)(nil), // 15: roveapi.StatusRequest - (*Log)(nil), // 16: roveapi.Log - (*Vector)(nil), // 17: roveapi.Vector - (*RoverSpecifications)(nil), // 18: roveapi.RoverSpecifications - (*RoverStatus)(nil), // 19: roveapi.RoverStatus - (*RoverReadings)(nil), // 20: roveapi.RoverReadings - (*StatusResponse)(nil), // 21: roveapi.StatusResponse + (RoverUpgrade)(0), // 2: roveapi.RoverUpgrade + (Object)(0), // 3: roveapi.Object + (Tile)(0), // 4: roveapi.Tile + (SailPosition)(0), // 5: roveapi.SailPosition + (*ServerStatusRequest)(nil), // 6: roveapi.ServerStatusRequest + (*ServerStatusResponse)(nil), // 7: roveapi.ServerStatusResponse + (*RegisterRequest)(nil), // 8: roveapi.RegisterRequest + (*Account)(nil), // 9: roveapi.Account + (*RegisterResponse)(nil), // 10: roveapi.RegisterResponse + (*Command)(nil), // 11: roveapi.Command + (*CommandRequest)(nil), // 12: roveapi.CommandRequest + (*CommandResponse)(nil), // 13: roveapi.CommandResponse + (*RadarRequest)(nil), // 14: roveapi.RadarRequest + (*RadarResponse)(nil), // 15: roveapi.RadarResponse + (*StatusRequest)(nil), // 16: roveapi.StatusRequest + (*Log)(nil), // 17: roveapi.Log + (*Vector)(nil), // 18: roveapi.Vector + (*RoverSpecifications)(nil), // 19: roveapi.RoverSpecifications + (*RoverStatus)(nil), // 20: roveapi.RoverStatus + (*RoverReadings)(nil), // 21: roveapi.RoverReadings + (*StatusResponse)(nil), // 22: roveapi.StatusResponse } var file_roveapi_roveapi_proto_depIdxs = []int32{ - 8, // 0: roveapi.RegisterResponse.account:type_name -> roveapi.Account + 9, // 0: roveapi.RegisterResponse.account:type_name -> roveapi.Account 0, // 1: roveapi.Command.command:type_name -> roveapi.CommandType 1, // 2: roveapi.Command.bearing:type_name -> roveapi.Bearing - 8, // 3: roveapi.CommandRequest.account:type_name -> roveapi.Account - 10, // 4: roveapi.CommandRequest.commands:type_name -> roveapi.Command - 8, // 5: roveapi.RadarRequest.account:type_name -> roveapi.Account - 3, // 6: roveapi.RadarResponse.tiles:type_name -> roveapi.Tile - 2, // 7: roveapi.RadarResponse.objects:type_name -> roveapi.Object - 8, // 8: roveapi.StatusRequest.account:type_name -> roveapi.Account - 1, // 9: roveapi.RoverStatus.bearing:type_name -> roveapi.Bearing - 4, // 10: roveapi.RoverStatus.sailPosition:type_name -> roveapi.SailPosition - 10, // 11: roveapi.RoverStatus.queuedCommands:type_name -> roveapi.Command - 17, // 12: roveapi.RoverReadings.position:type_name -> roveapi.Vector - 1, // 13: roveapi.RoverReadings.wind:type_name -> roveapi.Bearing - 16, // 14: roveapi.RoverReadings.logs:type_name -> roveapi.Log - 18, // 15: roveapi.StatusResponse.spec:type_name -> roveapi.RoverSpecifications - 19, // 16: roveapi.StatusResponse.status:type_name -> roveapi.RoverStatus - 20, // 17: roveapi.StatusResponse.readings:type_name -> roveapi.RoverReadings - 5, // 18: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest - 7, // 19: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest - 11, // 20: roveapi.Rove.Command:input_type -> roveapi.CommandRequest - 13, // 21: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest - 15, // 22: roveapi.Rove.Status:input_type -> roveapi.StatusRequest - 6, // 23: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse - 9, // 24: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse - 12, // 25: roveapi.Rove.Command:output_type -> roveapi.CommandResponse - 14, // 26: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse - 21, // 27: roveapi.Rove.Status:output_type -> roveapi.StatusResponse - 23, // [23:28] is the sub-list for method output_type - 18, // [18:23] is the sub-list for method input_type - 18, // [18:18] is the sub-list for extension type_name - 18, // [18:18] is the sub-list for extension extendee - 0, // [0:18] is the sub-list for field type_name + 2, // 3: roveapi.Command.upgrade:type_name -> roveapi.RoverUpgrade + 9, // 4: roveapi.CommandRequest.account:type_name -> roveapi.Account + 11, // 5: roveapi.CommandRequest.commands:type_name -> roveapi.Command + 9, // 6: roveapi.RadarRequest.account:type_name -> roveapi.Account + 4, // 7: roveapi.RadarResponse.tiles:type_name -> roveapi.Tile + 3, // 8: roveapi.RadarResponse.objects:type_name -> roveapi.Object + 9, // 9: roveapi.StatusRequest.account:type_name -> roveapi.Account + 1, // 10: roveapi.RoverStatus.bearing:type_name -> roveapi.Bearing + 5, // 11: roveapi.RoverStatus.sailPosition:type_name -> roveapi.SailPosition + 11, // 12: roveapi.RoverStatus.queuedCommands:type_name -> roveapi.Command + 18, // 13: roveapi.RoverReadings.position:type_name -> roveapi.Vector + 1, // 14: roveapi.RoverReadings.wind:type_name -> roveapi.Bearing + 17, // 15: roveapi.RoverReadings.logs:type_name -> roveapi.Log + 19, // 16: roveapi.StatusResponse.spec:type_name -> roveapi.RoverSpecifications + 20, // 17: roveapi.StatusResponse.status:type_name -> roveapi.RoverStatus + 21, // 18: roveapi.StatusResponse.readings:type_name -> roveapi.RoverReadings + 6, // 19: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest + 8, // 20: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest + 12, // 21: roveapi.Rove.Command:input_type -> roveapi.CommandRequest + 14, // 22: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest + 16, // 23: roveapi.Rove.Status:input_type -> roveapi.StatusRequest + 7, // 24: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse + 10, // 25: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse + 13, // 26: roveapi.Rove.Command:output_type -> roveapi.CommandResponse + 15, // 27: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse + 22, // 28: roveapi.Rove.Status:output_type -> roveapi.StatusResponse + 24, // [24:29] is the sub-list for method output_type + 19, // [19:24] is the sub-list for method input_type + 19, // [19:19] is the sub-list for extension type_name + 19, // [19:19] is the sub-list for extension extendee + 0, // [0:19] is the sub-list for field type_name } func init() { file_roveapi_roveapi_proto_init() } @@ -1855,7 +1937,7 @@ func file_roveapi_roveapi_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_roveapi_roveapi_proto_rawDesc, - NumEnums: 5, + NumEnums: 6, NumMessages: 17, NumExtensions: 0, NumServices: 1, diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index 9aad682..72a1fc2 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -89,22 +89,24 @@ message RegisterResponse { // CommandType defines the type of a command to give to the rover enum CommandType { none = 0; - // Toggles the sails, either catching the wind, or charging from the sun - toggle = 1; - // Turns the rover in the specified bearing (requires bearing) - turn = 2; - // Stashes item at current location in rover inventory - stash = 3; - // Repairs the rover using an inventory object - repair = 4; - // Broadcasts a message to nearby rovers (requires data) - broadcast = 5; - // Salvages a neighboring dormant rover for parts - salvage = 6; - // Transfers remote control into dormant rover - transfer = 7; // Waits before performing the next command - wait = 8; + wait = 1; + // Toggles the sails, either catching the wind, or charging from the sun + toggle = 2; + // Turns the rover in the specified bearing (requires bearing) + turn = 3; + // Stashes item at current location in rover inventory + stash = 4; + // Repairs the rover using an inventory object + repair = 5; + // Broadcasts a message to nearby rovers (requires data) + broadcast = 6; + // Salvages a neighboring dormant rover for parts + salvage = 7; + // Transfers remote control into dormant rover + transfer = 8; + // Upgrades a chosen rover specification using 5 rover parts + upgrade = 9; } // Bearing represents a compass direction @@ -121,6 +123,15 @@ enum Bearing { NorthWest = 8; } +// Describes the type of upgrade +enum RoverUpgrade { + RoverUpgradeUnknown = 0; + Range = 1; + Capacity = 2; + MaximumIntegrity = 3; + MaximumCharge = 4; +} + // Command is a single command for a rover message Command { // The command type @@ -135,6 +146,9 @@ message Command { // move - the bearing for the rover to turn to Bearing bearing = 4; + + // upgrade - the upgrade to apply to the rover + RoverUpgrade upgrade = 5; } // CommandRequest describes a set of commands to be requested for the rover From b114b68ff751aae8f153da53bd34804f14794d73 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 2 Aug 2020 12:03:12 +0100 Subject: [PATCH 224/228] Add upgrade command code --- pkg/rove/world.go | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index d2483b5..64e3982 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -15,6 +15,9 @@ import ( const ( // ticksPerNormalMove defines the number of ticks it should take for a "normal" speed move ticksPerNormalMove = 4 + + // upgradeCost is the cost in rover parts needed to upgrade a rover specification + upgradeCost = 5 ) // CommandStream is a list of commands to execute in order @@ -446,6 +449,63 @@ func (w *World) RoverToggle(rover string) (roveapi.SailPosition, error) { return r.SailPosition, nil } +// RoverUpgrade will try to upgrade the rover +func (w *World) RoverUpgrade(rover string, upgrade roveapi.RoverUpgrade) (int, error) { + w.worldMutex.Lock() + defer w.worldMutex.Unlock() + + r, ok := w.Rovers[rover] + if !ok { + return 0, fmt.Errorf("no rover matching id") + } + + cost := upgradeCost + num := 0 + for i := range r.Inventory { + if r.Inventory[i].Type == roveapi.Object_RoverParts { + num++ + } + } + + if num < cost { + r.AddLogEntryf("tried to upgrade but lacked rover parts") + return 0, nil + } + + // Apply the upgrade + var ret int + switch upgrade { + case roveapi.RoverUpgrade_Capacity: + r.Capacity++ + ret = r.Capacity + case roveapi.RoverUpgrade_Range: + r.Range++ + ret = r.Range + case roveapi.RoverUpgrade_MaximumCharge: + r.MaximumCharge++ + ret = r.MaximumCharge + case roveapi.RoverUpgrade_MaximumIntegrity: + r.MaximumIntegrity++ + ret = r.MaximumIntegrity + default: + return 0, fmt.Errorf("unknown upgrade: %s", upgrade) + } + + // Remove the cost in rover parts + var n []Object + for _, o := range r.Inventory { + if o.Type == roveapi.Object_RoverParts && cost > 0 { + cost-- + } else { + n = append(n, o) + } + } + // Assign back the inventory + r.Inventory = n + + return ret, nil +} + // RoverTurn will turn the rover func (w *World) RoverTurn(rover string, bearing roveapi.Bearing) (roveapi.Bearing, error) { w.worldMutex.Lock() @@ -582,6 +642,10 @@ func (w *World) Enqueue(rover string, commands ...*roveapi.Command) error { if c.GetBearing() == roveapi.Bearing_BearingUnknown { return fmt.Errorf("turn command given unknown bearing") } + case roveapi.CommandType_upgrade: + if c.GetUpgrade() == roveapi.RoverUpgrade_RoverUpgradeUnknown { + return fmt.Errorf("upgrade command given unknown upgrade") + } case roveapi.CommandType_wait: case roveapi.CommandType_toggle: case roveapi.CommandType_stash: @@ -729,6 +793,8 @@ func (w *World) ExecuteCommand(c *roveapi.Command, rover string) (done bool, err _, err = w.RoverSalvage(rover) case roveapi.CommandType_transfer: _, err = w.RoverTransfer(rover) + case roveapi.CommandType_upgrade: + _, err = w.RoverUpgrade(rover, c.GetUpgrade()) case roveapi.CommandType_wait: // Nothing to do default: From 4e4af1a1beeaf042b9fad985a99f14a7fb9323eb Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 2 Aug 2020 12:15:49 +0100 Subject: [PATCH 225/228] Add a test for the upgrade command --- pkg/rove/command_test.go | 55 ++++++++++++++++++++++++++++++++++++++++ pkg/rove/world.go | 2 ++ 2 files changed, 57 insertions(+) diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index dde7070..bf1eed6 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -248,3 +248,58 @@ func TestCommand_Wait(t *testing.T) { assert.NoError(t, err) assert.Equal(t, roveapi.SailPosition_CatchingWind, r.SailPosition) } + +func TestCommand_Upgrade(t *testing.T) { + w := NewWorld(8) + name, err := w.SpawnRover("") + assert.NoError(t, err) + rover, ok := w.Rovers[name] + assert.True(t, ok) + + // Try an invalid upgrade + err = w.Enqueue(name, &roveapi.Command{Command: roveapi.CommandType_upgrade}) + assert.Error(t, err) + + // Try a valid command but without the parts + err = w.Enqueue(name, &roveapi.Command{Command: roveapi.CommandType_upgrade, Upgrade: roveapi.RoverUpgrade_Capacity}) + assert.NoError(t, err) + + // Ensure nothing changed and we logged the attempt + pre := rover.Capacity + w.Tick() + assert.Equal(t, pre, rover.Capacity) + assert.Contains(t, rover.Logs[len(rover.Logs)-1].Text, "tried") + + // One non-part item + rover.Inventory = []Object{ + { + Type: roveapi.Object_RoverParts, + }, + { + Type: roveapi.Object_RoverParts, + }, + { + Type: roveapi.Object_RockSmall, + }, + { + Type: roveapi.Object_RoverParts, + }, + { + Type: roveapi.Object_RoverParts, + }, + { + Type: roveapi.Object_RoverParts, + }, + } + + // Try a valid command again + err = w.Enqueue(name, &roveapi.Command{Command: roveapi.CommandType_upgrade, Upgrade: roveapi.RoverUpgrade_Capacity}) + assert.NoError(t, err) + + // Check that the capacity increases on the tick and all the parts are used + pre = rover.Capacity + w.Tick() + assert.Equal(t, pre+1, rover.Capacity) + assert.Equal(t, 1, len(rover.Inventory)) + assert.Equal(t, roveapi.Object_RockSmall, rover.Inventory[0].Type) +} diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 64e3982..d509d8d 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -503,6 +503,8 @@ func (w *World) RoverUpgrade(rover string, upgrade roveapi.RoverUpgrade) (int, e // Assign back the inventory r.Inventory = n + r.AddLogEntryf("upgraded %s to %d", upgrade, ret) + return ret, nil } From 804f82dd2015121222d758bbcb74d41a14d0ae4e Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 2 Aug 2020 12:43:44 +0100 Subject: [PATCH 226/228] Fix up commandline interface for repeat commands to go after the command --- cmd/rove/main.go | 56 ++++++++++++++++++++----------------------- cmd/rove/main_test.go | 4 ++-- 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 06999d3..551cda1 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -35,7 +35,7 @@ func printUsage() { fmt.Fprintln(os.Stderr, "\tregister NAME registers an account and spawns a rover") fmt.Fprintln(os.Stderr, "\tradar prints radar data in ASCII form") fmt.Fprintln(os.Stderr, "\tstatus gets rover status") - fmt.Fprintln(os.Stderr, "\tcommand [REPEAT] CMD [VAL...] queues commands, accepts multiple in sequence for command values see below") + fmt.Fprintln(os.Stderr, "\tcommand CMD [VAL...] [REPEAT] sets the command queue, accepts multiple in sequence") fmt.Fprintf(os.Stderr, "\n") fmt.Fprintln(os.Stderr, "Rover commands:") fmt.Fprintln(os.Stderr, "\ttoggle toggles the current sail mode") @@ -247,16 +247,8 @@ func InnerMain(command string, args ...string) error { // Iterate through each command var commands []*roveapi.Command for i := 0; i < len(args); i++ { - number := 0 - num, err := strconv.Atoi(args[i]) - if err == nil { - number = num - i++ - if i >= len(args) { - return fmt.Errorf("must pass command after repeat number") - } - } + var cmd *roveapi.Command switch args[i] { case "turn": i++ @@ -267,13 +259,10 @@ func InnerMain(command string, args ...string) error { if b == roveapi.Bearing_BearingUnknown { return fmt.Errorf("turn command must be given a valid bearing %s", args[i]) } - commands = append(commands, - &roveapi.Command{ - Command: roveapi.CommandType_turn, - Bearing: b, - Repeat: int32(number), - }, - ) + cmd = &roveapi.Command{ + Command: roveapi.CommandType_turn, + Bearing: b, + } case "broadcast": i++ if len(args) == i { @@ -281,22 +270,29 @@ func InnerMain(command string, args ...string) error { } else if len(args[i]) > 3 { return fmt.Errorf("broadcast command must be given ASCII triplet of 3 or less: %s", args[i]) } - commands = append(commands, - &roveapi.Command{ - Command: roveapi.CommandType_broadcast, - Data: []byte(args[i]), - Repeat: int32(number), - }, - ) + cmd = &roveapi.Command{ + Command: roveapi.CommandType_broadcast, + Data: []byte(args[i]), + } default: // By default just use the command literally - commands = append(commands, - &roveapi.Command{ - Command: roveapi.CommandType(roveapi.CommandType_value[args[i]]), - Repeat: int32(number), - }, - ) + cmd = &roveapi.Command{ + Command: roveapi.CommandType(roveapi.CommandType_value[args[i]]), + } } + + // Try and convert the next command to a number + number := 0 + if len(args) > i+1 { + num, err := strconv.Atoi(args[i+1]) + if err == nil { + number = num + i++ + } + } + cmd.Repeat = int32(number) + + commands = append(commands, cmd) } _, err := client.Command(ctx, &roveapi.CommandRequest{ diff --git a/cmd/rove/main_test.go b/cmd/rove/main_test.go index 25e08ae..ca83947 100644 --- a/cmd/rove/main_test.go +++ b/cmd/rove/main_test.go @@ -55,8 +55,8 @@ func Test_InnerMain(t *testing.T) { assert.NoError(t, InnerMain("command", "stash")) assert.NoError(t, InnerMain("command", "repair")) assert.NoError(t, InnerMain("command", "broadcast", "abc")) - assert.NoError(t, InnerMain("command", "10", "wait")) - assert.NoError(t, InnerMain("command", "1", "wait", "turn", "NW", "toggle", "broadcast", "zyx")) + assert.NoError(t, InnerMain("command", "wait", "10")) + assert.NoError(t, InnerMain("command", "wait", "1", "turn", "NW", "toggle", "broadcast", "zyx")) // Give it malformed commands assert.Error(t, InnerMain("command", "unknown")) From 35b25dde9880436fe4a2394fc2bdf47e5733f271 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 2 Aug 2020 12:49:15 +0100 Subject: [PATCH 227/228] Add the upgrade command to the cmdline client --- cmd/rove/main.go | 23 +++++++++++++++++++++++ cmd/rove/main_test.go | 2 ++ 2 files changed, 25 insertions(+) diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 551cda1..f1e993d 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -44,6 +44,7 @@ func printUsage() { fmt.Fprintln(os.Stderr, "\tbroadcast MSG broadcast a simple ASCII triplet to nearby rovers") fmt.Fprintln(os.Stderr, "\tsalvage salvages a dormant rover for parts") fmt.Fprintln(os.Stderr, "\ttransfer transfer's control into a dormant rover") + fmt.Fprintln(os.Stderr, "\tupgrade SPEC spends rover parts to upgrade one rover spec (capacity, range, integrity, charge") fmt.Fprintln(os.Stderr, "\twait waits before performing the next command") fmt.Fprintf(os.Stderr, "\n") fmt.Fprintln(os.Stderr, "Environment") @@ -274,6 +275,28 @@ func InnerMain(command string, args ...string) error { Command: roveapi.CommandType_broadcast, Data: []byte(args[i]), } + case "upgrade": + i++ + if len(args) == i { + return fmt.Errorf("upgrade command must be passed a spec to upgrade") + } + var u roveapi.RoverUpgrade + switch args[i] { + case "capacity": + u = roveapi.RoverUpgrade_Capacity + case "range": + u = roveapi.RoverUpgrade_Range + case "integrity": + u = roveapi.RoverUpgrade_MaximumIntegrity + case "charge": + u = roveapi.RoverUpgrade_MaximumCharge + default: + return fmt.Errorf("upgrade command must be passed a known upgrade spec") + } + cmd = &roveapi.Command{ + Command: roveapi.CommandType_upgrade, + Upgrade: u, + } default: // By default just use the command literally cmd = &roveapi.Command{ diff --git a/cmd/rove/main_test.go b/cmd/rove/main_test.go index ca83947..250988a 100644 --- a/cmd/rove/main_test.go +++ b/cmd/rove/main_test.go @@ -54,6 +54,7 @@ func Test_InnerMain(t *testing.T) { assert.NoError(t, InnerMain("command", "toggle")) assert.NoError(t, InnerMain("command", "stash")) assert.NoError(t, InnerMain("command", "repair")) + assert.NoError(t, InnerMain("command", "upgrade", "capacity")) assert.NoError(t, InnerMain("command", "broadcast", "abc")) assert.NoError(t, InnerMain("command", "wait", "10")) assert.NoError(t, InnerMain("command", "wait", "1", "turn", "NW", "toggle", "broadcast", "zyx")) @@ -61,5 +62,6 @@ func Test_InnerMain(t *testing.T) { // Give it malformed commands assert.Error(t, InnerMain("command", "unknown")) assert.Error(t, InnerMain("command", "broadcast")) + assert.Error(t, InnerMain("command", "upgrade")) assert.Error(t, InnerMain("command", "1")) } From f29b189a4252986a5a0a2b820f96219828e46db3 Mon Sep 17 00:00:00 2001 From: mdiluz Date: Fri, 27 Sep 2024 10:43:28 +0100 Subject: [PATCH 228/228] Update README.md --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2aff518..aad1a6f 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ Rove ==== -![Tests](https://github.com/mdiluz/rove/workflows/Tests/badge.svg) ![Docker](https://github.com/mdiluz/rove/workflows/Docker/badge.svg) [![rove](https://snapcraft.io//rove/badge.svg)](https://snapcraft.io/rove) -![Rove](https://github.com/mdiluz/rove/blob/master/data/icon.svg) +![Rove](data/icon.svg) Rove is an asynchronous nomadic game about exploring as part of a loose community. -This repository contains the source code for the `rove-server` deployment and the `rove` command line client. See [mdiluz.github.io/rove](https://mdiluz.github.io/rove/) for game details, and [roveapi.proto](https://github.com/mdiluz/rove/blob/master/proto/roveapi/roveapi.proto) for the current server-client API. +This repository contains the source code for the `rove-server` deployment and the `rove` command line client. See [mdiluz.github.io/rove](https://mdiluz.github.io/rove/) for game details, and [roveapi.proto](proto/roveapi/roveapi.proto) for the current server-client API.