commit 2bd18e2ab4d3458b4234e8fd54278a9be634eabb
parent 3e323456d1b504026a584fdf0941a45f39133891
Author: anon <anon@example.com>
Date: Sat, 7 Nov 2026 03:21:47 +0000
Keep initial population checkpoint at the listener startup boundary
Diffstat:
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/server/checkpoint_test.go b/server/checkpoint_test.go
@@ -136,12 +136,15 @@ func TestWorldCheckpointsRespectPlayerSimulationCadence(t *testing.T) {
func TestWorldCheckpointInitialPopulationCommitsOnlyOnce(t *testing.T) {
useNPCData(t, testNPCData())
world := newTestServer(t)
+ now := time.Now()
+ if err := world.checkpointWorld(now); err != nil {
+ t.Fatal(err)
+ }
var initialized bool
if err := world.db.QueryRow("SELECT npcs_initialized FROM world WHERE id=1").Scan(&initialized); err != nil || !initialized {
- t.Fatal("server returned before initial population was durable", initialized, err)
+ t.Fatal("startup checkpoint returned before initial population was durable", initialized, err)
}
auditCheckpointWrites(t, world)
- now := time.Now()
if err := world.checkpointWorld(now); err != nil {
t.Fatal(err)
diff --git a/server/main.go b/server/main.go
@@ -59,6 +59,10 @@ func runServer() {
log.Fatal(err)
}
server := newServer()
+ // Persist initial population before any listener admits game traffic.
+ if err := server.checkpointWorld(time.Now()); err != nil {
+ log.Fatal(err)
+ }
server.loginPort, server.worldPort, server.httpPort = *loginPort, *worldPort, *httpPort
server.baseURL = *baseURL
httpAddress := fmt.Sprintf(":%d", server.httpPort)
diff --git a/server/state.go b/server/state.go
@@ -139,7 +139,6 @@ type server struct {
httpPort int
baseURL string
mutex simulationMutex
-
// Order entity-state packet batches; acquire before mutex.
updateMutex simulationMutex
identities *worldIdentities
@@ -242,10 +241,6 @@ func newServer() *server {
if err := server.loadPets(); err != nil {
panic(err)
}
- // Persist initial population before any listener admits game traffic.
- if err := server.checkpointWorld(time.Now()); err != nil {
- panic(err)
- }
return server
}