aboutsummaryrefslogtreecommitdiff
path: root/internal/game/room_reconcile.go
blob: 31b66f67696ab4a1e483783852381b77b32386d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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)
	// Guard-watch cycle timers are keyed by room:object; an object edit can
	// remove the object the timer belonged to, so drop the room's timers.
	g.clearGuardWatchRoom(roomID)
	if g.MobStore != nil {
		g.MobStore.RemoveMobsInRoom(roomID)
		g.MobStore.SeedMobs(roomID, room.Mobs)
	}
}