Changeset View
Standalone View
binaries/data/mods/public/gui/gamesetup_mp/gamesetup_mp.js
/** | /** | |||||||||||||||||||||||||||||||||||||
* Whether we are attempting to join or host a game. | * Whether we are attempting to join or host a game. | |||||||||||||||||||||||||||||||||||||
*/ | */ | |||||||||||||||||||||||||||||||||||||
var g_IsConnecting = false; | var g_IsConnecting = false; | |||||||||||||||||||||||||||||||||||||
/** | /** | |||||||||||||||||||||||||||||||||||||
* "server" or "client" | * "server" or "client" | |||||||||||||||||||||||||||||||||||||
*/ | */ | |||||||||||||||||||||||||||||||||||||
var g_GameType; | var g_GameType; | |||||||||||||||||||||||||||||||||||||
/** | /** | |||||||||||||||||||||||||||||||||||||
* Server title shown in the lobby gamelist. | * Server title shown in the lobby gamelist. | |||||||||||||||||||||||||||||||||||||
*/ | */ | |||||||||||||||||||||||||||||||||||||
var g_ServerName = ""; | var g_ServerName = ""; | |||||||||||||||||||||||||||||||||||||
/** | /** | |||||||||||||||||||||||||||||||||||||
* Cached to pass it to the gamesetup of the controller to report the game to the lobby. | * Cached to pass it to the gamesetup of the controller to report the game to the lobby. | |||||||||||||||||||||||||||||||||||||
Stan: Typo | ||||||||||||||||||||||||||||||||||||||
*/ | */ | |||||||||||||||||||||||||||||||||||||
var g_ServerPort; | var g_ServerPort; | |||||||||||||||||||||||||||||||||||||
Done Inline Actionsg_ServerRequiresPassword maybe? Stan: g_ServerRequiresPassword maybe? | ||||||||||||||||||||||||||||||||||||||
Not Done Inline ActionsMight be ServerHasPassword for consistency or the other way around Stan: Might be ServerHasPassword for consistency or the other way around | ||||||||||||||||||||||||||||||||||||||
Done Inline ActionsI wanted other way around, but requires is long word for stanza, has is a lot shorter :) Silier: I wanted other way around, but `requires` is long word for stanza, `has` is a lot shorter :) | ||||||||||||||||||||||||||||||||||||||
var g_IsRejoining = false; | var g_IsRejoining = false; | |||||||||||||||||||||||||||||||||||||
var g_GameAttributes; // used when rejoining | var g_GameAttributes; // used when rejoining | |||||||||||||||||||||||||||||||||||||
var g_PlayerAssignments; // used when rejoining | var g_PlayerAssignments; // used when rejoining | |||||||||||||||||||||||||||||||||||||
var g_UserRating; | var g_UserRating; | |||||||||||||||||||||||||||||||||||||
/** | /** | |||||||||||||||||||||||||||||||||||||
* Object containing the IP address and port of the STUN server. | * Object containing the IP address and port of the STUN server. | |||||||||||||||||||||||||||||||||||||
*/ | */ | |||||||||||||||||||||||||||||||||||||
var g_StunEndpoint; | var g_StunEndpoint; | |||||||||||||||||||||||||||||||||||||
function init(attribs) | function init(attribs) | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
g_UserRating = attribs.rating; | g_UserRating = attribs.rating; | |||||||||||||||||||||||||||||||||||||
switch (attribs.multiplayerGameType) | switch (attribs.multiplayerGameType) | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
case "join": | case "join": | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
if (Engine.HasXmppClient()) | if (Engine.HasXmppClient()) | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
if (startJoin(attribs.name, attribs.ip, getValidPort(attribs.port), attribs.useSTUN, attribs.hostJID)) | if (startJoinFromLobby(attribs.name, getValidPort(attribs.port), attribs.useSTUN, attribs.hostJID)) | |||||||||||||||||||||||||||||||||||||
Done Inline Actionsremove port Silier: remove port | ||||||||||||||||||||||||||||||||||||||
switchSetupPage("pageConnecting"); | switchSetupPage("pageConnecting"); | |||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
else | else | |||||||||||||||||||||||||||||||||||||
switchSetupPage("pageJoin"); | switchSetupPage("pageJoin"); | |||||||||||||||||||||||||||||||||||||
break; | break; | |||||||||||||||||||||||||||||||||||||
Not Done Inline Actions
Stan: | ||||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
case "host": | case "host": | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
Engine.GetGUIObjectByName("hostSTUNWrapper").hidden = !Engine.HasXmppClient(); | Engine.GetGUIObjectByName("hostSTUNWrapper").hidden = !Engine.HasXmppClient(); | |||||||||||||||||||||||||||||||||||||
if (Engine.HasXmppClient()) | if (Engine.HasXmppClient()) | |||||||||||||||||||||||||||||||||||||
Done Inline ActionsCould early break. Stan: Could early break. | ||||||||||||||||||||||||||||||||||||||
Done Inline Actionscould but i would need to duplicate code after this anyway Silier: could but i would need to duplicate code after this anyway | ||||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
Engine.GetGUIObjectByName("hostPlayerName").caption = attribs.name; | Engine.GetGUIObjectByName("hostPlayerName").caption = attribs.name; | |||||||||||||||||||||||||||||||||||||
Engine.GetGUIObjectByName("hostServerName").caption = | Engine.GetGUIObjectByName("hostServerName").caption = | |||||||||||||||||||||||||||||||||||||
sprintf(translate("%(name)s's game"), { "name": attribs.name }); | sprintf(translate("%(name)s's game"), { "name": attribs.name }); | |||||||||||||||||||||||||||||||||||||
Engine.GetGUIObjectByName("useSTUN").checked = Engine.ConfigDB_GetValue("user", "lobby.stun.enabled") == "true"; | Engine.GetGUIObjectByName("useSTUN").checked = Engine.ConfigDB_GetValue("user", "lobby.stun.enabled") == "true"; | |||||||||||||||||||||||||||||||||||||
Not Done Inline ActionsNuke Stan: Nuke | ||||||||||||||||||||||||||||||||||||||
Done Inline Actionsno, it is setting for host Silier: no, it is setting for host | ||||||||||||||||||||||||||||||||||||||
Not Done Inline Actions
I meant the removal of thz line abovz Stan: > no, it is setting for host
I meant the removal of thz line abovz | ||||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
switchSetupPage("pageHost"); | switchSetupPage("pageHost"); | |||||||||||||||||||||||||||||||||||||
break; | break; | |||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
default: | default: | |||||||||||||||||||||||||||||||||||||
error("Unrecognised multiplayer game type: " + attribs.multiplayerGameType); | error("Unrecognised multiplayer game type: " + attribs.multiplayerGameType); | |||||||||||||||||||||||||||||||||||||
break; | break; | |||||||||||||||||||||||||||||||||||||
Show All 23 Lines | function cancelSetup() | |||||||||||||||||||||||||||||||||||||
else if (g_GameType == "server") | else if (g_GameType == "server") | |||||||||||||||||||||||||||||||||||||
switchSetupPage("pageHost"); | switchSetupPage("pageHost"); | |||||||||||||||||||||||||||||||||||||
else | else | |||||||||||||||||||||||||||||||||||||
error("cancelSetup: Unrecognised multiplayer game type: " + g_GameType); | error("cancelSetup: Unrecognised multiplayer game type: " + g_GameType); | |||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
function confirmSetup() | function confirmSetup() | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
if (!Engine.GetGUIObjectByName("pageJoin").hidden) | if (!Engine.GetGUIObjectByName("pageJoin").hidden) | |||||||||||||||||||||||||||||||||||||
Done Inline ActionsEarly return? Stan: Early return? | ||||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
let joinPlayerName = Engine.GetGUIObjectByName("joinPlayerName").caption; | let joinPlayerName = Engine.GetGUIObjectByName("joinPlayerName").caption; | |||||||||||||||||||||||||||||||||||||
Done Inline ActionsInline? Stan: Inline? | ||||||||||||||||||||||||||||||||||||||
let joinServer = Engine.GetGUIObjectByName("joinServer").caption; | let joinServer = Engine.GetGUIObjectByName("joinServer").caption; | |||||||||||||||||||||||||||||||||||||
let joinPort = Engine.GetGUIObjectByName("joinPort").caption; | let joinPort = Engine.GetGUIObjectByName("joinPort").caption; | |||||||||||||||||||||||||||||||||||||
if (startJoin(joinPlayerName, joinServer, getValidPort(joinPort), false, "")) | if (startJoin(joinPlayerName, joinServer, getValidPort(joinPort), false, "")) | |||||||||||||||||||||||||||||||||||||
switchSetupPage("pageConnecting"); | switchSetupPage("pageConnecting"); | |||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
else if (!Engine.GetGUIObjectByName("pageHost").hidden) | else if (!Engine.GetGUIObjectByName("pageHost").hidden) | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
let hostPlayerName = Engine.GetGUIObjectByName("hostPlayerName").caption; | let hostPlayerName = Engine.GetGUIObjectByName("hostPlayerName").caption; | |||||||||||||||||||||||||||||||||||||
let hostServerName = Engine.GetGUIObjectByName("hostServerName").caption; | let hostServerName = Engine.GetGUIObjectByName("hostServerName").caption; | |||||||||||||||||||||||||||||||||||||
let hostPort = Engine.GetGUIObjectByName("hostPort").caption; | let hostPort = Engine.GetGUIObjectByName("hostPort").caption; | |||||||||||||||||||||||||||||||||||||
if (!hostServerName) | if (!hostServerName) | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
Engine.GetGUIObjectByName("hostFeedback").caption = translate("Please enter a valid server name."); | Engine.GetGUIObjectByName("hostFeedback").caption = translate("Please enter a valid server name."); | |||||||||||||||||||||||||||||||||||||
return; | return; | |||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
if (getValidPort(hostPort) != +hostPort) | if (getValidPort(hostPort) != +hostPort) | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
Engine.GetGUIObjectByName("hostFeedback").caption = sprintf( | Engine.GetGUIObjectByName("hostFeedback").caption = sprintf( | |||||||||||||||||||||||||||||||||||||
translate("Server port number must be between %(min)s and %(max)s."), { | translate("Server port number must be between %(min)s and %(max)s."), { | |||||||||||||||||||||||||||||||||||||
"min": g_ValidPorts.min, | "min": g_ValidPorts.min, | |||||||||||||||||||||||||||||||||||||
"max": g_ValidPorts.max | "max": g_ValidPorts.max | |||||||||||||||||||||||||||||||||||||
}); | }); | |||||||||||||||||||||||||||||||||||||
return; | return; | |||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
if (startHost(hostPlayerName, hostServerName, getValidPort(hostPort))) | if (startHost(hostPlayerName, hostServerName, getValidPort(hostPort))) | |||||||||||||||||||||||||||||||||||||
switchSetupPage("pageConnecting"); | switchSetupPage("pageConnecting"); | |||||||||||||||||||||||||||||||||||||
Done Inline Actions
Stan: | ||||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
function startConnectionStatus(type) | function startConnectionStatus(type) | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
g_GameType = type; | g_GameType = type; | |||||||||||||||||||||||||||||||||||||
g_IsConnecting = true; | g_IsConnecting = true; | |||||||||||||||||||||||||||||||||||||
g_IsRejoining = false; | g_IsRejoining = false; | |||||||||||||||||||||||||||||||||||||
Engine.GetGUIObjectByName("connectionStatus").caption = translate("Connecting to server..."); | Engine.GetGUIObjectByName("connectionStatus").caption = translate("Connecting to server..."); | |||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
function onTick() | function onTick() | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
if (!g_IsConnecting) | if (!g_IsConnecting) | |||||||||||||||||||||||||||||||||||||
return; | return; | |||||||||||||||||||||||||||||||||||||
pollAndHandleNetworkClient(); | pollAndHandleNetworkClient(); | |||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
function pollAndHandleNetworkClient() | function pollAndHandleNetworkClient() | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
while (true) | while (true) | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
var message = Engine.PollNetworkClient(); | var message = Engine.PollNetworkClient(); | |||||||||||||||||||||||||||||||||||||
Done Inline ActionsDo we use the weird indentation for js as well? Linter doesn't seem to complain Stan: Do we use the weird indentation for js as well? Linter doesn't seem to complain | ||||||||||||||||||||||||||||||||||||||
Done Inline Actionshave you seen bunch of switches in this file ? Silier: have you seen bunch of switches in this file ? | ||||||||||||||||||||||||||||||||||||||
if (!message) | if (!message) | |||||||||||||||||||||||||||||||||||||
break; | break; | |||||||||||||||||||||||||||||||||||||
log(sprintf(translate("Net message: %(message)s"), { "message": uneval(message) })); | log(sprintf(translate("Net message: %(message)s"), { "message": uneval(message) })); | |||||||||||||||||||||||||||||||||||||
Not Done Inline ActionsI assume we can't reuse the translated message for the error? Why not reportConnectionFail(reason) Stan: I assume we can't reuse the translated message for the error? Why not reportConnectionFail… | ||||||||||||||||||||||||||||||||||||||
// If we're rejoining an active game, we don't want to actually display | // If we're rejoining an active game, we don't want to actually display | |||||||||||||||||||||||||||||||||||||
// the game setup screen, so perform similar processing to gamesetup.js | // the game setup screen, so perform similar processing to gamesetup.js | |||||||||||||||||||||||||||||||||||||
// in this screen | // in this screen | |||||||||||||||||||||||||||||||||||||
if (g_IsRejoining) | if (g_IsRejoining) | |||||||||||||||||||||||||||||||||||||
switch (message.type) | switch (message.type) | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
case "netstatus": | case "netstatus": | |||||||||||||||||||||||||||||||||||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | if (g_IsRejoining) | |||||||||||||||||||||||||||||||||||||
case "netwarn": | case "netwarn": | |||||||||||||||||||||||||||||||||||||
break; | break; | |||||||||||||||||||||||||||||||||||||
default: | default: | |||||||||||||||||||||||||||||||||||||
error("Unrecognised net message type: " + message.type); | error("Unrecognised net message type: " + message.type); | |||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
else | else | |||||||||||||||||||||||||||||||||||||
// Not rejoining - just trying to connect to server | // Not rejoining - just trying to connect to server | |||||||||||||||||||||||||||||||||||||
Lint: ESLintBear (indent) Expected indentation of 2 tabs but found 3. Lint: ESLintBear (indent): `Expected indentation of 2 tabs but found 3.` | ||||||||||||||||||||||||||||||||||||||
Not Done Inline ActionsCan you fix ? + Final dot Stan: Can you fix ? + Final dot | ||||||||||||||||||||||||||||||||||||||
switch (message.type) | switch (message.type) | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
case "netstatus": | case "netstatus": | |||||||||||||||||||||||||||||||||||||
switch (message.status) | switch (message.status) | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
case "connected": | case "connected": | |||||||||||||||||||||||||||||||||||||
Engine.GetGUIObjectByName("connectionStatus").caption = translate("Registering with server..."); | Engine.GetGUIObjectByName("connectionStatus").caption = translate("Registering with server..."); | |||||||||||||||||||||||||||||||||||||
break; | break; | |||||||||||||||||||||||||||||||||||||
case "authenticated": | case "authenticated": | |||||||||||||||||||||||||||||||||||||
if (message.rejoining) | if (message.rejoining) | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
Engine.GetGUIObjectByName("connectionStatus").caption = translate("Game has already started, rejoining..."); | Engine.GetGUIObjectByName("connectionStatus").caption = translate("Game has already started, rejoining..."); | |||||||||||||||||||||||||||||||||||||
g_IsRejoining = true; | g_IsRejoining = true; | |||||||||||||||||||||||||||||||||||||
return; // we'll process the game setup messages in the next tick | return; // we'll process the game setup messages in the next tick | |||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
Engine.SwitchGuiPage("page_gamesetup.xml", { | Engine.SwitchGuiPage("page_gamesetup.xml", { | |||||||||||||||||||||||||||||||||||||
"serverName": g_ServerName, | "serverName": g_ServerName, | |||||||||||||||||||||||||||||||||||||
"serverPort": g_ServerPort, | "serverPort": g_ServerPort, | |||||||||||||||||||||||||||||||||||||
"stunEndpoint": g_StunEndpoint | "stunEndpoint": g_StunEndpoint | |||||||||||||||||||||||||||||||||||||
Done Inline Actionscheck if can remove port Silier: check if can remove port | ||||||||||||||||||||||||||||||||||||||
Done Inline ActionsMaybe the name should make it clear it's a boolean? Stan: Maybe the name should make it clear it's a boolean? | ||||||||||||||||||||||||||||||||||||||
}); | }); | |||||||||||||||||||||||||||||||||||||
return; // don't process any more messages - leave them for the game GUI loop | return; // don't process any more messages - leave them for the game GUI loop | |||||||||||||||||||||||||||||||||||||
case "disconnected": | case "disconnected": | |||||||||||||||||||||||||||||||||||||
cancelSetup(); | cancelSetup(); | |||||||||||||||||||||||||||||||||||||
reportDisconnect(message.reason, false); | reportDisconnect(message.reason, false); | |||||||||||||||||||||||||||||||||||||
return; | return; | |||||||||||||||||||||||||||||||||||||
Show All 32 Lines | function switchSetupPage(newPage) | |||||||||||||||||||||||||||||||||||||
Engine.GetGUIObjectByName(newPage).hidden = false; | Engine.GetGUIObjectByName(newPage).hidden = false; | |||||||||||||||||||||||||||||||||||||
Engine.GetGUIObjectByName("hostPlayerNameWrapper").hidden = Engine.HasXmppClient(); | Engine.GetGUIObjectByName("hostPlayerNameWrapper").hidden = Engine.HasXmppClient(); | |||||||||||||||||||||||||||||||||||||
Engine.GetGUIObjectByName("hostServerNameWrapper").hidden = !Engine.HasXmppClient(); | Engine.GetGUIObjectByName("hostServerNameWrapper").hidden = !Engine.HasXmppClient(); | |||||||||||||||||||||||||||||||||||||
Engine.GetGUIObjectByName("continueButton").hidden = newPage == "pageConnecting"; | Engine.GetGUIObjectByName("continueButton").hidden = newPage == "pageConnecting"; | |||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
function startHost(playername, servername, port) | function startHost(playername, servername, port) | |||||||||||||||||||||||||||||||||||||
Not Done Inline ActionsIs it hasPassword? Could have default value to false so the check below is simpler. Stan: Is it hasPassword? Could have default value to false so the check below is simpler. | ||||||||||||||||||||||||||||||||||||||
Done Inline Actionsno, this is actual password Silier: no, this is actual password | ||||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
startConnectionStatus("server"); | startConnectionStatus("server"); | |||||||||||||||||||||||||||||||||||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", "playername.multiplayer", playername, "config/user.cfg"); | Engine.ConfigDB_CreateAndWriteValueToFile("user", "playername.multiplayer", playername, "config/user.cfg"); | |||||||||||||||||||||||||||||||||||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", "multiplayerhosting.port", port, "config/user.cfg"); | Engine.ConfigDB_CreateAndWriteValueToFile("user", "multiplayerhosting.port", port, "config/user.cfg"); | |||||||||||||||||||||||||||||||||||||
let hostFeedback = Engine.GetGUIObjectByName("hostFeedback"); | let hostFeedback = Engine.GetGUIObjectByName("hostFeedback"); | |||||||||||||||||||||||||||||||||||||
// Disallow identically named games in the multiplayer lobby | // Disallow identically named games in the multiplayer lobby | |||||||||||||||||||||||||||||||||||||
if (Engine.HasXmppClient() && | if (Engine.HasXmppClient() && | |||||||||||||||||||||||||||||||||||||
Engine.GetGameList().some(game => game.name == servername)) | Engine.GetGameList().some(game => game.name == servername)) | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
cancelSetup(); | cancelSetup(); | |||||||||||||||||||||||||||||||||||||
hostFeedback.caption = translate("Game name already in use."); | hostFeedback.caption = translate("Game name already in use."); | |||||||||||||||||||||||||||||||||||||
return false; | return false; | |||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
if (Engine.HasXmppClient() && Engine.GetGUIObjectByName("useSTUN").checked) | if (Engine.HasXmppClient() && Engine.GetGUIObjectByName("useSTUN").checked) | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
g_StunEndpoint = Engine.FindStunEndpoint(port); | g_StunEndpoint = Engine.FindStunEndpoint(port); | |||||||||||||||||||||||||||||||||||||
Not Done Inline Actionsthis has global somewhere Silier: this has global somewhere | ||||||||||||||||||||||||||||||||||||||
if (!g_StunEndpoint) | if (!g_StunEndpoint) | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
cancelSetup(); | cancelSetup(); | |||||||||||||||||||||||||||||||||||||
hostFeedback.caption = translate("Failed to host via STUN."); | hostFeedback.caption = translate("Failed to host via STUN."); | |||||||||||||||||||||||||||||||||||||
return false; | return false; | |||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | else | |||||||||||||||||||||||||||||||||||||
// Only save the player name and host address if they're valid and we're not in the lobby | // Only save the player name and host address if they're valid and we're not in the lobby | |||||||||||||||||||||||||||||||||||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", "playername.multiplayer", playername, "config/user.cfg"); | Engine.ConfigDB_CreateAndWriteValueToFile("user", "playername.multiplayer", playername, "config/user.cfg"); | |||||||||||||||||||||||||||||||||||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", "multiplayerserver", ip, "config/user.cfg"); | Engine.ConfigDB_CreateAndWriteValueToFile("user", "multiplayerserver", ip, "config/user.cfg"); | |||||||||||||||||||||||||||||||||||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", "multiplayerjoining.port", port, "config/user.cfg"); | Engine.ConfigDB_CreateAndWriteValueToFile("user", "multiplayerjoining.port", port, "config/user.cfg"); | |||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
return true; | return true; | |||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||
function startJoinFromLobby(playername, port, useSTUN, hostJID) | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
if (!Engine.HasXmppClient()) | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
cancelSetup(); | ||||||||||||||||||||||||||||||||||||||
messageBox( | ||||||||||||||||||||||||||||||||||||||
400, 200, | ||||||||||||||||||||||||||||||||||||||
sprintf("You are not in lobby. Wrong function was called."), | ||||||||||||||||||||||||||||||||||||||
Done Inline ActionsMaybe "You cannot join a lobby game without logging in to the lobby"? Stan: Maybe "You cannot join a lobby game without logging in to the lobby"? | ||||||||||||||||||||||||||||||||||||||
translate("Error") | ||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||
return false; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
try | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
Engine.StartNetworkJoinSafe(playername + (g_UserRating ? " (" + g_UserRating + ")" : ""), port, useSTUN, hostJID); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
catch (e) | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
cancelSetup(); | ||||||||||||||||||||||||||||||||||||||
messageBox( | ||||||||||||||||||||||||||||||||||||||
400, 200, | ||||||||||||||||||||||||||||||||||||||
sprintf(translate("Cannot join game: %(message)s."), { "message": e.message }), | ||||||||||||||||||||||||||||||||||||||
translate("Error") | ||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||
return false; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
startConnectionStatus("client"); | ||||||||||||||||||||||||||||||||||||||
Engine.LobbySetPlayerPresence("playing"); | ||||||||||||||||||||||||||||||||||||||
Lint: ESLintBear (no-trailing-spaces) Trailing spaces not allowed. Lint: ESLintBear (no-trailing-spaces): `Trailing spaces not allowed.` | ||||||||||||||||||||||||||||||||||||||
return true; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
function getDefaultGameName() | function getDefaultGameName() | |||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||
return sprintf(translate("%(playername)s's game"), { | return sprintf(translate("%(playername)s's game"), { | |||||||||||||||||||||||||||||||||||||
"playername": multiplayerName() | "playername": multiplayerName() | |||||||||||||||||||||||||||||||||||||
}); | }); | |||||||||||||||||||||||||||||||||||||
} | } |
Typo