Added nullguards insode addPlayer() to prevent server errors when profile not found or inraid object not found

This commit is contained in:
Dev 2024-04-20 09:58:47 +01:00
parent e2f3191212
commit 34466735ef

View File

@ -96,7 +96,21 @@ export class InraidController
public addPlayer(sessionID: string, info: IRegisterPlayerRequestData): void
{
this.applicationContext.addValue(ContextVariableType.REGISTER_PLAYER_REQUEST, info);
this.saveServer.getProfile(sessionID).inraid.location = info.locationId;
const profile = this.saveServer.getProfile(sessionID);
if (!profile)
{
this.logger.error(`No profile found with Id of: ${sessionID}`);
return;
}
if (!profile.inraid)
{
profile.inraid = { character: sessionID, location: info.locationId };
}
else
{
profile.inraid.location;
}
}
/**