Rename the world tick function and set the tick rate back to default
This commit is contained in:
parent
8667f55143
commit
6b5d5abea1
5 changed files with 9 additions and 10 deletions
|
@ -131,8 +131,8 @@ func (s *Server) Run() {
|
||||||
|
|
||||||
log.Println("Executing server tick")
|
log.Println("Executing server tick")
|
||||||
|
|
||||||
// Run the command queues
|
// Tick the world
|
||||||
s.world.ExecuteCommandQueues()
|
s.world.Tick()
|
||||||
|
|
||||||
// Save out the new world state
|
// Save out the new world state
|
||||||
if err := s.SaveWorld(); err != nil {
|
if err := s.SaveWorld(); err != nil {
|
||||||
|
|
|
@ -15,7 +15,6 @@ services:
|
||||||
- PORT=9090
|
- PORT=9090
|
||||||
- DATA_PATH=/mnt/rove-server
|
- DATA_PATH=/mnt/rove-server
|
||||||
- WORDS_FILE=data/words_alpha.txt
|
- WORDS_FILE=data/words_alpha.txt
|
||||||
- TICK_RATE=5
|
|
||||||
volumes:
|
volumes:
|
||||||
- persistent-data:/mnt/rove-server:rw
|
- persistent-data:/mnt/rove-server:rw
|
||||||
command: [ "./rove-server"]
|
command: [ "./rove-server"]
|
||||||
|
|
|
@ -18,7 +18,7 @@ func TestCommand_Toggle(t *testing.T) {
|
||||||
|
|
||||||
w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_toggle})
|
w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_toggle})
|
||||||
w.EnqueueAllIncoming()
|
w.EnqueueAllIncoming()
|
||||||
w.ExecuteCommandQueues()
|
w.Tick()
|
||||||
|
|
||||||
r, err = w.GetRover(a)
|
r, err = w.GetRover(a)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
@ -26,7 +26,7 @@ func TestCommand_Toggle(t *testing.T) {
|
||||||
|
|
||||||
w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_toggle})
|
w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_toggle})
|
||||||
w.EnqueueAllIncoming()
|
w.EnqueueAllIncoming()
|
||||||
w.ExecuteCommandQueues()
|
w.Tick()
|
||||||
|
|
||||||
r, err = w.GetRover(a)
|
r, err = w.GetRover(a)
|
||||||
assert.NoError(t, err)
|
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.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_turn, Turn: roveapi.Bearing_NorthWest})
|
||||||
w.EnqueueAllIncoming()
|
w.EnqueueAllIncoming()
|
||||||
w.ExecuteCommandQueues()
|
w.Tick()
|
||||||
|
|
||||||
r, err := w.GetRover(a)
|
r, err := w.GetRover(a)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
|
@ -464,8 +464,8 @@ func (w *World) EnqueueAllIncoming() {
|
||||||
w.CommandIncoming = make(map[string]CommandStream)
|
w.CommandIncoming = make(map[string]CommandStream)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExecuteCommandQueues will execute any commands in the current command queue
|
// Tick will execute any commands in the current command queue and tick the world
|
||||||
func (w *World) ExecuteCommandQueues() {
|
func (w *World) Tick() {
|
||||||
w.cmdMutex.Lock()
|
w.cmdMutex.Lock()
|
||||||
defer w.cmdMutex.Unlock()
|
defer w.cmdMutex.Unlock()
|
||||||
|
|
||||||
|
|
|
@ -343,7 +343,7 @@ func TestWorld_Daytime(t *testing.T) {
|
||||||
// Loop for half the day
|
// Loop for half the day
|
||||||
for i := 0; i < world.TicksPerDay/2; i++ {
|
for i := 0; i < world.TicksPerDay/2; i++ {
|
||||||
assert.True(t, world.Daytime())
|
assert.True(t, world.Daytime())
|
||||||
world.ExecuteCommandQueues()
|
world.Tick()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove rover charge again
|
// Remove rover charge again
|
||||||
|
@ -359,7 +359,7 @@ func TestWorld_Daytime(t *testing.T) {
|
||||||
// Loop for half the day
|
// Loop for half the day
|
||||||
for i := 0; i < world.TicksPerDay/2; i++ {
|
for i := 0; i < world.TicksPerDay/2; i++ {
|
||||||
assert.False(t, world.Daytime())
|
assert.False(t, world.Daytime())
|
||||||
world.ExecuteCommandQueues()
|
world.Tick()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue