Improve the "Error: network shutdown" popup (#170)
It now only appears when someone stops hosting and you are disconnected from their lobby, I also changed the text to "Disconnected: server closed" in case it wasn't obvious
This commit is contained in:
parent
4c429c17a7
commit
b5789a7c54
|
@ -16,7 +16,7 @@ void djui_panel_join_message_error(char* message) {
|
|||
}
|
||||
|
||||
void djui_panel_join_message_cancel(struct DjuiBase* caller) {
|
||||
network_shutdown(true, false);
|
||||
network_shutdown(true, false, false);
|
||||
djui_panel_menu_back(caller);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ static void djui_panel_pause_resume(UNUSED struct DjuiBase* caller) {
|
|||
}
|
||||
|
||||
static void djui_panel_pause_quit_yes(UNUSED struct DjuiBase* caller) {
|
||||
network_shutdown(true, false);
|
||||
network_shutdown(true, false, false);
|
||||
}
|
||||
|
||||
static void djui_panel_pause_quit(struct DjuiBase* caller) {
|
||||
|
|
|
@ -483,7 +483,7 @@ void network_register_mod(char* modName) {
|
|||
string_linked_list_append(&gRegisteredMods, modName);
|
||||
}
|
||||
|
||||
void network_shutdown(bool sendLeaving, bool exiting) {
|
||||
void network_shutdown(bool sendLeaving, bool exiting, bool popup) {
|
||||
if (gDjuiChatBox != NULL) {
|
||||
djui_base_destroy(&gDjuiChatBox->base);
|
||||
gDjuiChatBox = NULL;
|
||||
|
@ -496,7 +496,7 @@ void network_shutdown(bool sendLeaving, bool exiting) {
|
|||
if (gNetworkSystem == NULL) { LOG_ERROR("no network system attached"); return; }
|
||||
|
||||
if (gNetworkPlayerLocal != NULL && sendLeaving) { network_send_leaving(gNetworkPlayerLocal->globalIndex); }
|
||||
network_player_shutdown();
|
||||
network_player_shutdown(popup);
|
||||
gNetworkSystem->shutdown();
|
||||
|
||||
if (gNetworkServerAddr != NULL) {
|
||||
|
|
|
@ -99,6 +99,6 @@ void network_receive(u8 localIndex, void* addr, u8* data, u16 dataLength);
|
|||
void* network_duplicate_address(u8 localIndex);
|
||||
void network_update(void);
|
||||
void network_register_mod(char* modName);
|
||||
void network_shutdown(bool sendLeaving, bool exiting);
|
||||
void network_shutdown(bool sendLeaving, bool exiting, bool popup);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -158,7 +158,7 @@ void network_player_update(void) {
|
|||
#ifndef DEVELOPMENT
|
||||
if (elapsed > NETWORK_PLAYER_TIMEOUT * 1.5f) {
|
||||
LOG_INFO("dropping due to no server connectivity");
|
||||
network_shutdown(false, false);
|
||||
network_shutdown(false, false, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -284,7 +284,7 @@ u8 network_player_disconnected(u8 globalIndex) {
|
|||
LOG_ERROR("player disconnected, but it's local.. this shouldn't happen!");
|
||||
return UNKNOWN_GLOBAL_INDEX;
|
||||
} else {
|
||||
network_shutdown(true, false);
|
||||
network_shutdown(true, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -402,7 +402,7 @@ void network_player_update_course_level(struct NetworkPlayer* np, s16 courseNum,
|
|||
}
|
||||
}
|
||||
|
||||
void network_player_shutdown(void) {
|
||||
void network_player_shutdown(bool popup) {
|
||||
gNetworkPlayerLocal = NULL;
|
||||
gNetworkPlayerServer = NULL;
|
||||
for (s32 i = 0; i < MAX_PLAYERS; i++) {
|
||||
|
@ -412,6 +412,6 @@ void network_player_shutdown(void) {
|
|||
gNetworkSystem->clear_id(i);
|
||||
}
|
||||
|
||||
djui_popup_create("\\#ffa0a0\\Error:\\#dcdcdc\\ network shutdown", 1);
|
||||
if (popup) { djui_popup_create("\\#ffa0a0\\Disconnected:\\#dcdcdc\\ server closed", 1); }
|
||||
LOG_INFO("cleared all network players");
|
||||
}
|
||||
|
|
|
@ -79,6 +79,6 @@ u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 mode
|
|||
u8 network_player_disconnected(u8 globalIndex);
|
||||
|
||||
void network_player_update_course_level(struct NetworkPlayer* np, s16 courseNum, s16 actNum, s16 levelNum, s16 areaIndex);
|
||||
void network_player_shutdown(void);
|
||||
void network_player_shutdown(bool popup);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -153,7 +153,7 @@ void network_receive_join(struct Packet* p) {
|
|||
packet_read(p, &remoteVersion, sizeof(u8) * MAX_VERSION_LENGTH);
|
||||
LOG_INFO("server has version: %s", version);
|
||||
if (memcmp(version, remoteVersion, MAX_VERSION_LENGTH) != 0) {
|
||||
network_shutdown(true, false);
|
||||
network_shutdown(true, false, false);
|
||||
LOG_ERROR("version mismatch");
|
||||
char mismatchMessage[256] = { 0 };
|
||||
snprintf(mismatchMessage, 256, "\\#ffa0a0\\Error:\\#c8c8c8\\ Version mismatch.\n\nYour version: \\#a0a0ff\\%s\\#c8c8c8\\\nTheir version: \\#a0a0ff\\%s\\#c8c8c8\\\n\nSomeone is out of date!\n", version, remoteVersion);
|
||||
|
@ -186,7 +186,7 @@ void network_receive_join(struct Packet* p) {
|
|||
}
|
||||
|
||||
if (string_linked_list_mismatch(&gRegisteredMods, &head)) {
|
||||
network_shutdown(true, false);
|
||||
network_shutdown(true, false, false);
|
||||
|
||||
struct StringBuilder* builder = string_builder_create(512);
|
||||
string_builder_append(builder, "\\#ffa0a0\\Error:\\#c8c8c8\\ mods don't match.\n\n");
|
||||
|
|
|
@ -32,5 +32,5 @@ void network_receive_kick(struct Packet* p) {
|
|||
case EKT_BANNED: djui_panel_join_message_error("\\#ffa0a0\\Error:\\#c8c8c8\\ The server banned you."); break;
|
||||
default: djui_panel_join_message_error("\\#ffa0a0\\Error:\\#c8c8c8\\ Host has closed the connection."); break;
|
||||
}
|
||||
network_shutdown(false, false);
|
||||
network_shutdown(false, false, false);
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ void network_receive_mod_list(struct Packet* p) {
|
|||
packet_read(p, &remoteVersion, sizeof(u8) * MAX_VERSION_LENGTH);
|
||||
LOG_INFO("server has version: %s", version);
|
||||
if (memcmp(version, remoteVersion, MAX_VERSION_LENGTH) != 0) {
|
||||
network_shutdown(true, false);
|
||||
network_shutdown(true, false, false);
|
||||
LOG_ERROR("version mismatch");
|
||||
char mismatchMessage[256] = { 0 };
|
||||
snprintf(mismatchMessage, 256, "\\#ffa0a0\\Error:\\#c8c8c8\\ Version mismatch.\n\nYour version: \\#a0a0ff\\%s\\#c8c8c8\\\nTheir version: \\#a0a0ff\\%s\\#c8c8c8\\\n\nSomeone is out of date!\n", version, remoteVersion);
|
||||
|
@ -205,7 +205,7 @@ void network_receive_mod_list_entry(struct Packet* p) {
|
|||
// sanity check mod size
|
||||
if (mod->size >= MAX_MOD_SIZE) {
|
||||
djui_popup_create("Server had too large of a mod.\nQuitting.", 4);
|
||||
network_shutdown(false, false);
|
||||
network_shutdown(false, false, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ void game_deinit(void) {
|
|||
audio_custom_shutdown();
|
||||
audio_shutdown();
|
||||
gfx_shutdown();
|
||||
network_shutdown(true, true);
|
||||
network_shutdown(true, true, false);
|
||||
smlua_shutdown();
|
||||
mods_shutdown();
|
||||
inited = false;
|
||||
|
|
Loading…
Reference in New Issue