Code cleanup and removing exception in favor of console error

This commit is contained in:
David Négrier 2020-06-22 18:42:54 +02:00
parent 407c6db070
commit a5514ce78a
3 changed files with 20 additions and 113 deletions

View file

@ -647,7 +647,7 @@ export class GameScene extends Phaser.Scene {
* Put all the players on the map on map load.
*/
private doInitUsersPosition(usersPosition: MessageUserPositionInterface[]): void {
const currentPlayerId = this.connection.userId;
const currentPlayerId = this.connection.getUserId();
// clean map
this.MapPlayersByKey.forEach((player: RemotePlayer) => {
@ -740,7 +740,9 @@ export class GameScene extends Phaser.Scene {
private doUpdatePlayerPosition(message: MessageUserMovedInterface): void {
const player : RemotePlayer | undefined = this.MapPlayersByKey.get(message.userId);
if (player === undefined) {
throw new Error('Cannot find player with ID "' + message.userId +'"');
//throw new Error('Cannot find player with ID "' + message.userId +'"');
console.error('Cannot update position of player with ID "' + message.userId +'": player not found');
return;
}
// We do not update the player position directly (because it is sent only every 200ms).