Fix terrain streaming and surface spawning
This commit is contained in:
parent
f0279cdb65
commit
2b07d6be20
17 changed files with 424 additions and 111 deletions
|
|
@ -1,14 +1,17 @@
|
|||
package network
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"testing"
|
||||
|
||||
"regionio/internal/protocol"
|
||||
"regionio/internal/server"
|
||||
"regionio/internal/world"
|
||||
)
|
||||
|
||||
func TestSendDefaultSpawnPositionLayout(t *testing.T) {
|
||||
recorder := &recordingConn{}
|
||||
h := &handler{conn: NewConn(recorder)}
|
||||
h := &handler{conn: NewConn(recorder), spawnY: 100}
|
||||
|
||||
if err := h.sendDefaultSpawnPosition(); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -38,3 +41,17 @@ func TestSendDefaultSpawnPositionLayout(t *testing.T) {
|
|||
t.Fatalf("remaining bytes = %d, want 0", remaining)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVisibilityRadiusUsesServerLimit(t *testing.T) {
|
||||
cfg := server.DefaultConfig()
|
||||
cfg.WorldDir = ""
|
||||
cfg.MaxViewDistance = 2
|
||||
srv, err := server.NewWithCache(cfg, world.NewCache(-1, world.GenerateFlat))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
h := &handler{srv: srv, log: slog.Default(), viewDistance: 16}
|
||||
if got := h.visibilityRadius(); got != 2 {
|
||||
t.Fatalf("visibility radius = %d, want server limit 2", got)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue