Skip to content

Commit 82d1b2e

Browse files
authored
Adding ephemeral detail string to Room GMCP, focing mapper to use lowest roomId as 0,0,0 (#372)
# Description This forces the mapper to use the lowest RoomId in the set as the 0,0,0 origin. This solves the issue of drifting coordinates depending on what gets mapped first. ## Changes - Added `x`, `y`, `z` offsets based on lowest room in mapper. - Added `ephemeral` to Room GMCP payload (Details) when a room is ephemeral. ## Examples without changes (Force to generate dark forest first): ``` Room.Info { "num": 1, "name": "Town Square", "area": "Frostfang", "environment": "City", "coords": "Frostfang, -18, 1, 0", "exits": { "east": 54, "north": 2, "south": 12, "west": 7 }, ``` With changes (Still forced to generate dark forest first): ``` Room.Info { "num": 1, "name": "Town Square", "area": "Frostfang", "environment": "City", "coords": "Frostfang, 0, 0, 0", "exits": { "east": 54, "north": 2, "south": 12, "west": 7 }, ```
1 parent 4da6e5a commit 82d1b2e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

internal/mapper/mapper.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,17 @@ func (r *mapper) Start() {
223223

224224
r.crawlQueue = make([]crawlRoom, 0, 100) // pre-allocate 100 capacity
225225

226+
lowestRoomId := 0
226227
//var lastNode *mapNode = nil
227228
r.crawlQueue = append(r.crawlQueue, crawlRoom{RoomId: r.rootRoomId, Pos: positionDelta{}})
228229
for len(r.crawlQueue) > 0 {
229230

230231
roomNow := r.crawlQueue[0]
231232

233+
if lowestRoomId == 0 || roomNow.RoomId < lowestRoomId {
234+
lowestRoomId = roomNow.RoomId
235+
}
236+
232237
r.crawlQueue = r.crawlQueue[1:]
233238

234239
if _, ok := r.crawledRooms[roomNow.RoomId]; ok {
@@ -280,11 +285,21 @@ func (r *mapper) Start() {
280285

281286
r.crawlQueue = nil
282287

288+
var xOffset, yOffset, zOffset = 0, 0, 0
289+
lowestRoom := r.crawledRooms[lowestRoomId]
290+
if lowestRoom != nil {
291+
xOffset, yOffset, zOffset = lowestRoom.Pos.x, lowestRoom.Pos.y, lowestRoom.Pos.z
292+
}
293+
283294
// calculate the final array length.
284295

296+
minX, minY, minZ = minX-xOffset, minY-yOffset, minZ-zOffset
297+
maxX, maxY, maxZ = maxX-xOffset, maxY-yOffset, maxZ-zOffset
298+
285299
r.roomGrid.initialize(minX, maxX, minY, maxY, minZ, maxZ)
286300

287301
for _, node := range r.crawledRooms {
302+
node.Pos.x, node.Pos.y, node.Pos.z = node.Pos.x-xOffset, node.Pos.y-yOffset, node.Pos.z-zOffset
288303
r.roomGrid.addNode(node)
289304
}
290305
}

modules/gmcp/gmcp.Room.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,11 @@ func (g *GMCPRoomModule) GetRoomNode(user *users.UserRecord, gmcpModule string)
439439
if room.IsCharacterRoom {
440440
payload.Details = append(payload.Details, `character`)
441441
}
442+
443+
// Indicate if this is an ephemeral room
444+
if rooms.IsEphemeralRoomId(room.RoomId) {
445+
payload.Details = append(payload.Details, `ephemeral`)
446+
}
442447
// end room details
443448

444449
}

0 commit comments

Comments
 (0)