Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/lobby/lobby.js
Show First 20 Lines • Show All 664 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
function selectGameFromPlayername() | function selectGameFromPlayername() | ||||
{ | { | ||||
if (!g_SelectedPlayer) | if (!g_SelectedPlayer) | ||||
return; | return; | ||||
let gameList = Engine.GetGUIObjectByName("gamesBox"); | let gameList = Engine.GetGUIObjectByName("gamesBox"); | ||||
let foundAsObserver = false; | let foundAsObserver = false; | ||||
let selected = -1; | |||||
for (let i = 0; i < g_GameList.length; ++i) | for (let i = 0; i < g_GameList.length; ++i) | ||||
for (let player of stringifiedTeamListToPlayerData(g_GameList[i].players)) | for (let player of stringifiedTeamListToPlayerData(g_GameList[i].players)) | ||||
{ | { | ||||
let nick = splitRatingFromNick(player.Name)[0]; | let nick = splitRatingFromNick(player.Name)[0]; | ||||
if (g_SelectedPlayer != nick) | if (g_SelectedPlayer != nick) | ||||
continue; | continue; | ||||
if (player.Team == "observer") | if (player.Team == "observer") | ||||
{ | { | ||||
foundAsObserver = true; | foundAsObserver = true; | ||||
gameList.selected = i; | selected = i; | ||||
} | } | ||||
else if (!player.Offline) | else if (!player.Offline) | ||||
{ | { | ||||
gameList.selected = i; | selected = i; | ||||
return; | break; | ||||
} | } | ||||
else if (!foundAsObserver) | else if (!foundAsObserver) | ||||
elexis: no else after break or return | |||||
gameList.selected = i; | selected = i; | ||||
elexisUnsubmitted Not Done Inline ActionsDo I see this correctly that foundAsObserver can be deleted and the last if-statement removed, the return kept and a break added after the end because a player can't occur twice in a stringifiedTeamList? elexis: Do I see this correctly that `foundAsObserver` can be deleted and the last if-statement… | |||||
ffffffffAuthorUnsubmitted Not Done Inline Actionscome online ffffffff: come online | |||||
bbUnsubmitted Not Done Inline ActionsWhat the code seems to want to achieve is find one of the following in this order:
So during the loop we need to know whether the current value can be overwritten by an "Offline" game, so we need to have some identifier I suppose. However the return should indeed be kept and the break got to be added. bb: What the code seems to want to achieve is find one of the following in this order:
- a game the… | |||||
} | } | ||||
gameList.selected = selected; | |||||
} | } | ||||
function onPlayerListSelection() | function onPlayerListSelection() | ||||
{ | { | ||||
let playerList = Engine.GetGUIObjectByName("playersBox"); | let playerList = Engine.GetGUIObjectByName("playersBox"); | ||||
if (playerList.selected == playerList.list.indexOf(g_SelectedPlayer)) | if (playerList.selected == playerList.list.indexOf(g_SelectedPlayer)) | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 720 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
no else after break or return