aboutsummaryrefslogtreecommitdiff
path: root/internal/game/room_reconcile.go
blob: 74917766fb1089f95f267a484c4d9d0dfc6a8fc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package game

// ReconcileRoom refreshes a room's live runtime state from its on-disk
// definition after a content edit, without a restart. Object instances and
// item-spawn ground entries are reconciled by World; mob instances are dropped
// and reseeded here because MobStore is owned by the game layer. Player-dropped
// ground items and live reservations are preserved.
//
// It runs on the owner goroutine (the admin callbacks that call it already do)
// and must not redispatch.
func (g *Game) ReconcileRoom(roomID int) {
	room, err := g.World.LoadRoom(roomID)
	if err != nil {
		return
	}
	g.World.ReconcileRoomState(roomID, room)
	if g.MobStore != nil {
		g.MobStore.RemoveMobsInRoom(roomID)
		g.MobStore.SeedMobs(roomID, room.Mobs)
	}
}