mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-08-15 14:43:32 -07:00
Since #7786, the GUI tick completed normally after calling `closePageCallback` instead of being cancelled like previously. Since `Engine.EndGame` deletes the internal `g_Game` pointer, every Engine call after it that tried to access `g_Game` caused a segfault. This patch solves it by moving `Engine.EndGame` to the very end, right before closing the session page. In order to follow the convention that only functions directly closing the page are called `closePageCallback`, that function is in turn renamed to `closeSession`. Additionally, this allows only resolving the promise with a bool (`showSummary`) and then only calling `getNextPageOpenRequest` at the end of `init` for reasons of simplicity.
47 lines
1.7 KiB
JavaScript
47 lines
1.7 KiB
JavaScript
/**
|
|
* This class shows an overlay if the game is stalled due to some clients not being
|
|
* ready to simulate yet, and in that case provides specifics to that reason.
|
|
*/
|
|
class NetworkStatusOverlay
|
|
{
|
|
constructor(closeSession)
|
|
{
|
|
this.netStatus = Engine.GetGUIObjectByName("netStatus");
|
|
this.loadingClientsText = Engine.GetGUIObjectByName("loadingClientsText");
|
|
|
|
Engine.GetGUIObjectByName("disconnectedExitButton").onPress = () => { closeSession(true); };
|
|
|
|
registerNetworkStatusChangeHandler(this.onNetStatusMessage.bind(this));
|
|
registerClientsLoadingHandler(this.onClientsLoadingMessage.bind(this));
|
|
}
|
|
|
|
onNetStatusMessage(message)
|
|
{
|
|
if (!this.StatusCaption[message.status])
|
|
{
|
|
error("Unrecognized netstatus type '" + message.status + "'");
|
|
return;
|
|
}
|
|
|
|
this.netStatus.caption = this.StatusCaption[message.status](message);
|
|
this.netStatus.hidden = message.status == "active";
|
|
this.loadingClientsText.hidden = message.status != "waiting_for_players";
|
|
}
|
|
|
|
onClientsLoadingMessage(guids)
|
|
{
|
|
this.loadingClientsText.caption = guids.map(guid => colorizePlayernameByGUID(guid)).join(this.Comma);
|
|
}
|
|
}
|
|
|
|
NetworkStatusOverlay.prototype.StatusCaption = {
|
|
"authenticated": msg => translate("Connection to the server has been authenticated."),
|
|
"connected": msg => translate("Connected to the server."),
|
|
"disconnected": msg => translate("Connection to the server has been lost.") + "\n" +
|
|
getDisconnectReason(msg.reason),
|
|
"waiting_for_players": msg => translate("Waiting for players to connect:"),
|
|
"join_syncing": msg => translate("Synchronizing gameplay with other players…"),
|
|
"active": msg => ""
|
|
};
|
|
|
|
NetworkStatusOverlay.prototype.Comma = translateWithContext("Separator for a list of client loading messages", ", ");
|