Attempt to fix performance :(((

This commit is contained in:
2025-01-05 07:22:23 +01:00
parent d7982493e1
commit cc1dbe5179
7 changed files with 31 additions and 35 deletions

View File

@ -25,15 +25,13 @@ export default class MapRequestEvent extends BaseEvent {
const mapRepository = new MapRepository()
const map = await mapRepository.getById(data.mapId)
await mapRepository.getEntityManager().populate(map!, mapRepository.POPULATE_MAP_EDITOR as any)
if (!map) {
this.logger.info(`User ${(await this.getCharacter())!.getId()} tried to request map ${data.mapId} but it does not exist.`)
return callback(null)
}
// Populate map with mapEventTiles and placedMapObjects
await mapRepository.getEntityManager().populate(map, ['mapEffects', 'mapEventTiles', 'placedMapObjects', 'placedMapObjects.mapObject'])
return callback(map)
} catch (error: any) {
this.logger.error('gm:map:request error', error.message)

View File

@ -32,7 +32,6 @@ interface IPayload {
}
export default class MapUpdateEvent extends BaseEvent {
private readonly populateOptions = ['mapEventTiles', 'placedMapObjects', 'mapEffects'];
public listen(): void {
this.socket.on('gm:map:update', this.handleEvent.bind(this))
}
@ -57,8 +56,7 @@ export default class MapUpdateEvent extends BaseEvent {
return callback(null)
}
// @ts-ignore
await mapRepository.getEntityManager().populate(map, this.populateOptions)
await mapRepository.getEntityManager().populate(map, mapRepository.POPULATE_MAP_EDITOR as any)
// Validation logic remains the same
if (data.tiles.length > data.height) {
@ -122,9 +120,7 @@ export default class MapUpdateEvent extends BaseEvent {
// Reload map from database to get fresh data
map = await mapRepository.getById(data.mapId)
// @ts-ignore
await mapRepository.getEntityManager().populate(map!, this.populateOptions)
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.`)