1
0
forked from noxious/server

More improvements

This commit is contained in:
2025-01-04 19:05:54 +01:00
parent 067976c54a
commit 9a448542d3
11 changed files with 38 additions and 184 deletions

View File

@ -25,13 +25,16 @@ export default class CharacterConnectEvent extends BaseEvent {
return
}
const character = await this.characterRepository.getByUserAndId(this.socket.userId!, data.characterId, ['characterType', 'characterHair'])
const character = await this.characterRepository.getByUserAndId(this.socket.userId!, data.characterId)
if (!character) {
this.emitError('Character not found or does not belong to this user')
return
}
// Populate character with characterType and characterHair
await this.characterRepository.getEntityManager().populate(character, ['characterType', 'characterHair'])
// Set character id
this.socket.characterId = character.id
@ -45,7 +48,7 @@ export default class CharacterConnectEvent extends BaseEvent {
callback({ character })
// wait 300 ms, @TODO: Find a better way to do this, race condition
await new Promise((resolve) => setTimeout(resolve, 500))
await new Promise((resolve) => setTimeout(resolve, 1000))
await TeleportService.teleportCharacter(character.id, {
targetMapId: character.map.id,