mirror of
https://github.com/AndrioCelos/TableturfBattleApp.git
synced 2026-04-24 15:27:00 -05:00
Fix a bug where a player rejoining triggered a join message and desyncs
This commit is contained in:
parent
ada0c9f150
commit
59dc677077
|
|
@ -123,9 +123,12 @@ function getGameInfo(gameID: string, myPlayerIndex: number | null) {
|
|||
if (s) {
|
||||
let payload = JSON.parse(s);
|
||||
if (payload.event == 'join') {
|
||||
currentGame.players.push(payload.data.player);
|
||||
playerListItems[payload.data.playerIndex].innerText = payload.data.player.name;
|
||||
updatePlayerListItem(payload.data.playerIndex);
|
||||
if (payload.data.playerIndex == currentGame.players.length) {
|
||||
currentGame.players.push(payload.data.player);
|
||||
playerListItems[payload.data.playerIndex].innerText = payload.data.player.name;
|
||||
updatePlayerListItem(payload.data.playerIndex);
|
||||
} else
|
||||
communicationError();
|
||||
} else if (payload.event == 'playerReady') {
|
||||
currentGame.players[payload.data.playerIndex].isReady = true;
|
||||
updatePlayerListItem(payload.data.playerIndex);
|
||||
|
|
|
|||
|
|
@ -69,6 +69,10 @@ function onGameStateChange(game: any, playerData: any) {
|
|||
}
|
||||
}
|
||||
|
||||
function communicationError() {
|
||||
document.getElementById('errorModal')!.hidden = false;
|
||||
}
|
||||
|
||||
showSection('preGame');
|
||||
|
||||
function isInternetExplorer() {
|
||||
|
|
|
|||
|
|
@ -162,10 +162,11 @@ internal class Program {
|
|||
SetErrorResponse(e.Response, error.Code == "GameAlreadyStarted" ? (int) HttpStatusCode.Gone : 422, error);
|
||||
return;
|
||||
}
|
||||
|
||||
game.SendEvent("join", new { playerIndex, player }, false);
|
||||
}
|
||||
// If they're already in the game, resend the original join response instead of an error.
|
||||
SetResponse(e.Response, (int) HttpStatusCode.OK, "application/json", JsonConvert.SerializeObject(new { playerIndex, clientToken }));
|
||||
game.SendEvent("join", new { playerIndex, player }, false);
|
||||
timer.Start();
|
||||
} catch (ArgumentException) {
|
||||
e.Response.StatusCode = (int) HttpStatusCode.BadRequest;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user