Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/lobby/lobby.js
Show All 23 Lines | |||||
const g_ModeratorPrefix = "@"; | const g_ModeratorPrefix = "@"; | ||||
/** | /** | ||||
* Current username. Cannot contain whitespace. | * Current username. Cannot contain whitespace. | ||||
*/ | */ | ||||
const g_Username = Engine.LobbyGetNick(); | const g_Username = Engine.LobbyGetNick(); | ||||
/** | /** | ||||
* If STUN is enabled for both host and client, we are using it | |||||
* to discovered NAT-mapped host endpoint | |||||
*/ | |||||
const g_StunEnabled = Engine.ConfigDB_GetValue("user", "stun.enabled") == "true"; | |||||
/** | |||||
* Lobby server address to construct host JID | |||||
*/ | |||||
const g_LobbyServer = Engine.ConfigDB_GetValue("user", "lobby.server"); | |||||
/** | |||||
* Current games will be listed in these colors. | * Current games will be listed in these colors. | ||||
*/ | */ | ||||
const g_GameColors = { | const g_GameColors = { | ||||
"init": "0 219 0", | "init": "0 219 0", | ||||
"waiting": "255 127 0", | "waiting": "255 127 0", | ||||
"running": "219 0 0" | "running": "219 0 0" | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 943 Lines • ▼ Show 20 Lines | |||||
* Attempt to join the selected game without asking for confirmation. | * Attempt to join the selected game without asking for confirmation. | ||||
*/ | */ | ||||
function joinSelectedGame() | function joinSelectedGame() | ||||
{ | { | ||||
let game = selectedGame(); | let game = selectedGame(); | ||||
if (!game) | if (!game) | ||||
return; | return; | ||||
if (game.ip.split('.').length != 4) | let ip; | ||||
let port; | |||||
if (g_StunEnabled && game.stunIP) | |||||
{ | |||||
ip = game.stunIP; | |||||
port = game.stunPort; | |||||
} | |||||
else | |||||
{ | |||||
ip = game.ip; | |||||
port = game.port; | |||||
} | |||||
if (ip.split('.').length != 4) | |||||
{ | { | ||||
addChatMessage({ | addChatMessage({ | ||||
"from": "system", | "from": "system", | ||||
"text": sprintf( | "text": sprintf( | ||||
translate("This game's address '%(ip)s' does not appear to be valid."), | translate("This game's address '%(ip)s' does not appear to be valid."), | ||||
{ "ip": game.ip } | { "ip": game.ip } | ||||
) | ) | ||||
}); | }); | ||||
return; | return; | ||||
} | } | ||||
let hostJID = game.hostUsername + "@" + g_LobbyServer + "/0ad"; | |||||
Engine.PushGuiPage("page_gamesetup_mp.xml", { | Engine.PushGuiPage("page_gamesetup_mp.xml", { | ||||
"multiplayerGameType": "join", | "multiplayerGameType": "join", | ||||
"ip": game.ip, | "ip": ip, | ||||
"port": game.port, | "port": port, | ||||
"name": g_Username, | "name": g_Username, | ||||
elexis: `removeRatingFromNick(hostPlayerName)` | |||||
"rating": g_UserRating | "rating": g_UserRating, | ||||
"hostJID": hostJID | |||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Open the dialog box to enter the game name. | * Open the dialog box to enter the game name. | ||||
*/ | */ | ||||
function hostGame() | function hostGame() | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 411 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
removeRatingFromNick(hostPlayerName)