Differential D3184 Diff 15163 binaries/data/mods/public/gui/gamesetup/NetMessages/GameRegisterStanza.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/NetMessages/GameRegisterStanza.js
/** | /** | ||||
* If there is an XmppClient, this class informs the XPartaMuPP lobby bot that | * If there is an XmppClient, this class informs the XPartaMuPP lobby bot that | ||||
* this match is being setup so that others can join. | * this match is being setup so that others can join. | ||||
* It informs of the lobby of some setting values and the participating clients. | * It informs of the lobby of some setting values and the participating clients. | ||||
*/ | */ | ||||
class GameRegisterStanza | class GameRegisterStanza | ||||
{ | { | ||||
constructor(initData, setupWindow, netMessages, gameSettingsControl, playerAssignmentsControl, mapCache) | constructor(initData, setupWindow, netMessages, gameSettingsControl, playerAssignmentsControl, mapCache) | ||||
{ | { | ||||
this.mapCache = mapCache; | this.mapCache = mapCache; | ||||
this.serverName = initData.serverName; | this.serverName = initData.serverName; | ||||
this.serverPort = initData.serverPort; | this.password = initData.password; | ||||
this.stunEndpoint = initData.stunEndpoint; | |||||
this.mods = JSON.stringify(Engine.GetEngineInfo().mods); | this.mods = JSON.stringify(Engine.GetEngineInfo().mods); | ||||
this.timer = undefined; | this.timer = undefined; | ||||
// Only send a lobby update when its data changed | // Only send a lobby update when its data changed | ||||
this.lastStanza = undefined; | this.lastStanza = undefined; | ||||
// Events | // Events | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | if (this.timer !== undefined) | ||||
clearTimeout(this.timer); | clearTimeout(this.timer); | ||||
this.timer = undefined; | this.timer = undefined; | ||||
} | } | ||||
let clients = this.formatClientsForStanza(); | let clients = this.formatClientsForStanza(); | ||||
let stanza = { | let stanza = { | ||||
"name": this.serverName, | "name": this.serverName, | ||||
"port": this.serverPort, | |||||
"hostUsername": Engine.LobbyGetNick(), | "hostUsername": Engine.LobbyGetNick(), | ||||
"mapName": g_GameAttributes.map, | "mapName": g_GameAttributes.map, | ||||
"niceMapName": this.mapCache.getTranslatableMapName(g_GameAttributes.mapType, g_GameAttributes.map), | "niceMapName": this.mapCache.getTranslatableMapName(g_GameAttributes.mapType, g_GameAttributes.map), | ||||
"mapSize": g_GameAttributes.mapType == "random" ? g_GameAttributes.settings.Size : "Default", | "mapSize": g_GameAttributes.mapType == "random" ? g_GameAttributes.settings.Size : "Default", | ||||
"mapType": g_GameAttributes.mapType, | "mapType": g_GameAttributes.mapType, | ||||
"victoryConditions": g_GameAttributes.settings.VictoryConditions.join(","), | "victoryConditions": g_GameAttributes.settings.VictoryConditions.join(","), | ||||
"nbp": clients.connectedPlayers, | "nbp": clients.connectedPlayers, | ||||
"maxnbp": g_GameAttributes.settings.PlayerData.length, | "maxnbp": g_GameAttributes.settings.PlayerData.length, | ||||
"players": clients.list, | "players": clients.list, | ||||
"stunIP": this.stunEndpoint ? this.stunEndpoint.ip : "", | "mods": this.mods, | ||||
"stunPort": this.stunEndpoint ? this.stunEndpoint.port : "", | "password": this.password || "" | ||||
Stan: Maybe other places. | |||||
Not Done Inline ActionsShould "" be getDefaultPassword? Stan: Should "" be getDefaultPassword? | |||||
Done Inline Actionsit is not related to default password, it is there to send empty string Silier: it is not related to default password, it is there to send empty string | |||||
"mods": this.mods | |||||
}; | }; | ||||
// Only send the stanza if one of these properties changed | // Only send the stanza if one of these properties changed | ||||
if (this.lastStanza && Object.keys(stanza).every(prop => this.lastStanza[prop] == stanza[prop])) | if (this.lastStanza && Object.keys(stanza).every(prop => this.lastStanza[prop] == stanza[prop])) | ||||
return; | return; | ||||
this.lastStanza = stanza; | this.lastStanza = stanza; | ||||
Engine.SendRegisterGame(stanza); | Engine.SendRegisterGame(stanza); | ||||
Show All 36 Lines |
Wildfire Games · Phabricator
Maybe other places.