Fix custom lobby player IDs not being set correctly when rejoining a lobby

main
peshomir 2025-02-15 11:02:28 +02:00
parent 2688e86b9d
commit 92980649eb
2 changed files with 6 additions and 5 deletions

View File

@ -193,7 +193,7 @@ function isCustomMessage(raw) {
if (playerIsHost) optionsContainer.classList.remove("disabled"); if (playerIsHost) optionsContainer.classList.remove("disabled");
else optionsContainer.classList.add("disabled"); else optionsContainer.classList.add("disabled");
Object.entries(data.options).forEach(([option, value]) => updateOption(option, value)); Object.entries(data.options).forEach(([option, value]) => updateOption(option, value));
displayPlayers(data.players); displayPlayers(data.players, data.id);
} else if (type === "addPlayer") { } else if (type === "addPlayer") {
addPlayer({ name: data.name, inGame: false, isHost: false }); addPlayer({ name: data.name, inGame: false, isHost: false });
updatePlayerCount(); updatePlayerCount();
@ -204,6 +204,7 @@ function isCustomMessage(raw) {
updatePlayerCount(); updatePlayerCount();
} else if (type === "inLobby") { } else if (type === "inLobby") {
const index = data; const index = data;
playerList[index].inGame = false;
playerList[index].inGameBadge.className = "d-none"; playerList[index].inGameBadge.className = "d-none";
} else if (type === "options") { } else if (type === "options") {
const [option, value] = data; const [option, value] = data;
@ -260,11 +261,11 @@ function kickButtonHandler(event) {
} }
} }
/** @param {PlayerInfo[]} players */ /** @param {PlayerInfo[]} players */
function displayPlayers(players) { function displayPlayers(players, thisPlayerId) {
playerList = []; playerList = [];
playerListDiv.innerHTML = ""; playerListDiv.innerHTML = "";
players.forEach(addPlayer); players.forEach(addPlayer);
thisPlayer = playerList[playerList.length - 1]; thisPlayer = playerList[thisPlayerId];
updatePlayerCount(); updatePlayerCount();
} }
function updatePlayerCount() { function updatePlayerCount() {

View File

@ -1,5 +1,5 @@
const fx_version = '0.6.7'; // FX Client Version const fx_version = '0.6.7.1'; // FX Client Version
const fx_update = 'Feb 8'; // FX Client Last Updated const fx_update = 'Feb 15'; // FX Client Last Updated
if ("serviceWorker" in navigator) { if ("serviceWorker" in navigator) {
navigator.serviceWorker.addEventListener("message", (e) => { navigator.serviceWorker.addEventListener("message", (e) => {