Fix broken feedback display logic and broken error handling from ccb534259d
. Additionally, streamline logic in prelobby.js and remove an unexplained check in lobby.js added by 76a1a84a58
.
This was SVN commit r17584.
This commit is contained in:
parent
ccb534259d
commit
9f9db45a03
@ -99,8 +99,6 @@ var g_NetMessageTypes = {
|
||||
// Three cases are handled in prelobby.js
|
||||
"registered": msg => {
|
||||
},
|
||||
"login-failed": msg => {
|
||||
},
|
||||
"connected": msg => {
|
||||
},
|
||||
"disconnected": msg => {
|
||||
@ -108,10 +106,10 @@ var g_NetMessageTypes = {
|
||||
updateLeaderboard();
|
||||
updatePlayerList();
|
||||
Engine.GetGUIObjectByName("hostButton").enabled = false;
|
||||
addChatMessage({ "from": "system", "text": translate("Disconnected."), "color": g_SystemColor });
|
||||
addChatMessage({ "from": "system", "text": translate("Disconnected.") + msg.text, "color": g_SystemColor });
|
||||
},
|
||||
"error": msg => {
|
||||
addChatMessage({ "from": "system", "text": escapeText(msg.text), "color": g_SystemColor });
|
||||
addChatMessage({ "from": "system", "text": msg.text, "color": g_SystemColor });
|
||||
}
|
||||
},
|
||||
"chat": {
|
||||
@ -218,17 +216,17 @@ function initGameFilters()
|
||||
resetFilters();
|
||||
}
|
||||
|
||||
function resetFilters()
|
||||
{
|
||||
function resetFilters()
|
||||
{
|
||||
Engine.GetGUIObjectByName("mapSizeFilter").selected = 0;
|
||||
Engine.GetGUIObjectByName("playersNumberFilter").selected = 0;
|
||||
Engine.GetGUIObjectByName("mapTypeFilter").selected = g_MapTypes.Default;
|
||||
Engine.GetGUIObjectByName("showFullFilter").checked = false;
|
||||
|
||||
applyFilters();
|
||||
}
|
||||
|
||||
function applyFilters()
|
||||
Engine.GetGUIObjectByName("mapTypeFilter").selected = g_MapTypes.Default;
|
||||
Engine.GetGUIObjectByName("showFullFilter").checked = false;
|
||||
|
||||
applyFilters();
|
||||
}
|
||||
|
||||
function applyFilters()
|
||||
{
|
||||
updateGameList();
|
||||
updateGameSelection();
|
||||
@ -282,11 +280,11 @@ function updateSubject(newSubject)
|
||||
subjectBox.hidden = false;
|
||||
logo.size = "50%-110 40 50%+110 140";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do a full update of the player listing, including ratings from cached C++ information.
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Do a full update of the player listing, including ratings from cached C++ information.
|
||||
*/
|
||||
function updatePlayerList()
|
||||
{
|
||||
var playersBox = Engine.GetGUIObjectByName("playersBox");
|
||||
|
@ -3,40 +3,7 @@ var g_EncrytedPassword = "";
|
||||
var g_PasswordInputIsHidden = false;
|
||||
var g_TermsOfServiceRead = false;
|
||||
var g_TermsOfUseRead = false;
|
||||
var g_HasSystemMessage = false;
|
||||
|
||||
/**
|
||||
* Notifications sent by XmppClient.cpp
|
||||
* Other types are handled in lobby.js
|
||||
*/
|
||||
var g_SystemMessageTypes = {
|
||||
"error": (message, username, password) => {
|
||||
Engine.GetGUIObjectByName("feedback").caption = message.text;
|
||||
Engine.StopXmppClient();
|
||||
},
|
||||
"login-failed": (message, username, password) => {
|
||||
Engine.GetGUIObjectByName("feedback").caption = translate("Authentication failed");
|
||||
Engine.StopXmppClient();
|
||||
},
|
||||
"registered": (message, username, password) => {
|
||||
Engine.GetGUIObjectByName("feedback").caption = translate("Registered");
|
||||
Engine.GetGUIObjectByName("connectUsername").caption = username;
|
||||
Engine.GetGUIObjectByName("connectPassword").caption = password;
|
||||
Engine.StopXmppClient();
|
||||
switchPage("connect");
|
||||
},
|
||||
"connected": (message, username, password) => {
|
||||
Engine.PopGuiPage();
|
||||
Engine.SwitchGuiPage("page_lobby.xml");
|
||||
|
||||
Engine.ConfigDB_CreateValue("user", "playername", sanitizePlayerName(username, true, true));
|
||||
Engine.ConfigDB_CreateValue("user", "lobby.login", username);
|
||||
if (password != g_EncrytedPassword.substring(0, 10))
|
||||
g_EncrytedPassword = Engine.EncryptPassword(password, username);
|
||||
Engine.ConfigDB_CreateValue("user", "lobby.password", g_EncrytedPassword);
|
||||
Engine.ConfigDB_WriteFile("user", "config/user.cfg");
|
||||
}
|
||||
};
|
||||
var g_DisplayingSystemMessage = false;
|
||||
|
||||
function init()
|
||||
{
|
||||
@ -49,7 +16,7 @@ function lobbyStop()
|
||||
{
|
||||
Engine.GetGUIObjectByName("feedback").caption = "";
|
||||
|
||||
if (g_LobbyIsConnecting == false)
|
||||
if (!g_LobbyIsConnecting)
|
||||
return;
|
||||
|
||||
g_LobbyIsConnecting = false;
|
||||
@ -116,6 +83,7 @@ function onTick()
|
||||
else if (!Engine.GetGUIObjectByName("pageWelcome").hidden)
|
||||
{
|
||||
feedback.caption = "";
|
||||
g_DisplayingSystemMessage = false;
|
||||
}
|
||||
// Check that they entered a username.
|
||||
else if (!username)
|
||||
@ -138,7 +106,7 @@ function onTick()
|
||||
// Allow them to connect if tests pass up to this point.
|
||||
else if (pageRegisterHidden)
|
||||
{
|
||||
if (!g_HasSystemMessage)
|
||||
if (!g_DisplayingSystemMessage)
|
||||
feedback.caption = "";
|
||||
continueButton.enabled = true;
|
||||
}
|
||||
@ -175,31 +143,52 @@ function onTick()
|
||||
// Allow them to register.
|
||||
else
|
||||
{
|
||||
if (!g_HasSystemMessage)
|
||||
if (!g_DisplayingSystemMessage)
|
||||
feedback.caption = "";
|
||||
continueButton.enabled = true;
|
||||
}
|
||||
|
||||
if (!g_LobbyIsConnecting)
|
||||
// The Xmpp Client has not been created
|
||||
return;
|
||||
|
||||
// The XmppClient has been created, we are waiting
|
||||
// to be connected or to receive an error.
|
||||
while (true)
|
||||
// Handle queued messages from the XMPP client (if running and if any)
|
||||
var message;
|
||||
while ((message = Engine.LobbyGuiPollMessage()) != undefined)
|
||||
{
|
||||
let message = Engine.LobbyGuiPollMessage();
|
||||
if (!message)
|
||||
break;
|
||||
|
||||
if (message.type != "system")
|
||||
// TODO: Properly deal with unrecognized messages
|
||||
if (message.type != "system" || !message.level)
|
||||
continue;
|
||||
|
||||
g_HasSystemMessage = true;
|
||||
g_LobbyIsConnecting = false;
|
||||
|
||||
if (g_SystemMessageTypes[message.level])
|
||||
g_SystemMessageTypes[message.level](message, username, password);
|
||||
switch(message.level) {
|
||||
case "error":
|
||||
case "disconnected":
|
||||
{
|
||||
Engine.GetGUIObjectByName("feedback").caption = message.text;
|
||||
g_DisplayingSystemMessage = true;
|
||||
Engine.StopXmppClient();
|
||||
break;
|
||||
}
|
||||
case "registered":
|
||||
Engine.GetGUIObjectByName("feedback").caption = translate("Registered");
|
||||
g_DisplayingSystemMessage = true;
|
||||
Engine.GetGUIObjectByName("connectUsername").caption = username;
|
||||
Engine.GetGUIObjectByName("connectPassword").caption = password;
|
||||
Engine.StopXmppClient();
|
||||
switchPage("connect");
|
||||
break;
|
||||
case "connected":
|
||||
{
|
||||
Engine.PopGuiPage();
|
||||
Engine.SwitchGuiPage("page_lobby.xml");
|
||||
Engine.ConfigDB_CreateValue("user", "playername", sanitizePlayerName(username, true, true));
|
||||
Engine.ConfigDB_CreateValue("user", "lobby.login", username);
|
||||
// We only store the encrypted password, so make sure to re-encrypt it if changed before saving.
|
||||
if (password != g_EncrytedPassword.substring(0, 10))
|
||||
g_EncrytedPassword = Engine.EncryptPassword(password, username);
|
||||
Engine.ConfigDB_CreateValue("user", "lobby.password", g_EncrytedPassword);
|
||||
Engine.ConfigDB_WriteFile("user", "config/user.cfg");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,10 +219,7 @@ void XmppClient::onDisconnect(gloox::ConnectionError error)
|
||||
m_PlayerMap.clear();
|
||||
m_Profile.clear();
|
||||
|
||||
if (error == gloox::ConnAuthenticationFailed)
|
||||
CreateGUIMessage("system", "login-failed");
|
||||
else
|
||||
CreateGUIMessage("system", "disconnected");
|
||||
CreateGUIMessage("system", "disconnected", ConnectionErrorToString(error));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1051,3 +1048,41 @@ std::string XmppClient::StanzaErrorToString(gloox::StanzaError err)
|
||||
}
|
||||
#undef CASE
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a gloox connection error enum to string
|
||||
* Keep in sync with Gloox documentation
|
||||
*
|
||||
* @param err Error to be converted
|
||||
* @return Converted error string
|
||||
*/
|
||||
std::string XmppClient::ConnectionErrorToString(gloox::ConnectionError err)
|
||||
{
|
||||
std::string msg;
|
||||
#define CASE(X, Y) case gloox::X: return Y
|
||||
switch (err)
|
||||
{
|
||||
CASE(ConnNoError, g_L10n.Translate("No error"));
|
||||
CASE(ConnStreamError, g_L10n.Translate("Stream error"));
|
||||
CASE(ConnStreamVersionError, g_L10n.Translate("The incoming stream version is unsupported"));
|
||||
CASE(ConnStreamClosed, g_L10n.Translate("The stream has been closed by the server"));
|
||||
CASE(ConnProxyAuthRequired, g_L10n.Translate("The HTTP/SOCKS5 proxy requires authentication"));
|
||||
CASE(ConnProxyAuthFailed, g_L10n.Translate("HTTP/SOCKS5 proxy authentication failed"));
|
||||
CASE(ConnProxyNoSupportedAuth, g_L10n.Translate("The HTTP/SOCKS5 proxy requires an unsupported authentication mechanism"));
|
||||
CASE(ConnIoError, g_L10n.Translate("An I/O error occured"));
|
||||
CASE(ConnParseError, g_L10n.Translate("An XML parse error occured"));
|
||||
CASE(ConnConnectionRefused, g_L10n.Translate("The connection was refused by the server"));
|
||||
CASE(ConnDnsError, g_L10n.Translate("Resolving the server's hostname failed"));
|
||||
CASE(ConnOutOfMemory, g_L10n.Translate("This system is out of memory"));
|
||||
CASE(ConnNoSupportedAuth, g_L10n.Translate("The authentication mechanisms the server offered are not supported or no authentication mechanisms were available"));
|
||||
CASE(ConnTlsFailed, g_L10n.Translate("The server's certificate could not be verified or the TLS handshake did not complete successfully"));
|
||||
CASE(ConnTlsNotAvailable, g_L10n.Translate("The server did not offer required TLS encrytption"));
|
||||
CASE(ConnCompressionFailed, g_L10n.Translate("Negotiation/initializing compression failed"));
|
||||
CASE(ConnAuthenticationFailed, g_L10n.Translate("Authentication failed. Incorrect password or account does not exist"));
|
||||
CASE(ConnUserDisconnected, g_L10n.Translate("The user or system requested a disconnect"));
|
||||
CASE(ConnNotConnected, g_L10n.Translate("There is no active connection"));
|
||||
default:
|
||||
return g_L10n.Translate("Error undefined");
|
||||
}
|
||||
#undef CASE
|
||||
}
|
||||
|
@ -125,6 +125,7 @@ protected:
|
||||
void GetPresenceString(const gloox::Presence::PresenceType p, std::string& presence) const;
|
||||
void GetRoleString(const gloox::MUCRoomRole r, std::string& role) const;
|
||||
std::string StanzaErrorToString(gloox::StanzaError err);
|
||||
std::string ConnectionErrorToString(gloox::ConnectionError err);
|
||||
|
||||
public:
|
||||
/* Messages */
|
||||
|
Loading…
Reference in New Issue
Block a user