1
0
forked from noxious/server

Saving teleports works again

This commit is contained in:
Dennis Postma 2025-02-14 03:16:30 +01:00
parent 606328dbef
commit fc91eb9873

View File

@ -21,7 +21,7 @@ interface IPayload {
positionX: number
positionY: number
teleport?: {
toMap: Map
toMapId: string
toPositionX: number
toPositionY: number
toRotation: number
@ -82,10 +82,12 @@ export default class MapUpdateEvent extends BaseEvent {
// Create and add new map event tiles
for (const tile of data.mapEventTiles) {
const mapEventTile = new MapEventTile().setType(tile.type).setPositionX(tile.positionX).setPositionY(tile.positionY).setMap(map)
if (tile.teleport) {
const toMap = await mapRepository.getById(tile.teleport.toMapId as UUID)
if (!toMap) continue
const teleport = new MapEventTileTeleport()
.setToMap(await mapRepository.getById(tile.teleport.toMap.id))
.setMapEventTile(mapEventTile)
.setToMap(toMap)
.setToPositionX(tile.teleport.toPositionX)
.setToPositionY(tile.teleport.toPositionY)
.setToRotation(tile.teleport.toRotation)
@ -115,7 +117,7 @@ export default class MapUpdateEvent extends BaseEvent {
// Reload map from database to get fresh data
map = await mapRepository.getById(data.mapId)
await mapRepository.getEntityManager().populate(map, mapRepository.POPULATE_MAP_EDITOR as any)
await mapRepository.getEntityManager().populate(map!, mapRepository.POPULATE_MAP_EDITOR as any)
if (!map) {
this.logger.info(`User ${character!.getId()} tried to update map ${data.mapId} but it does not exist after update.`)