Improve peer failure notification

This commit is contained in:
MysterD 2023-04-17 20:58:57 -07:00
parent af04df0f26
commit fd9c59f0d9
3 changed files with 8 additions and 4 deletions

View File

@ -27,6 +27,8 @@ LOBBY_JOIN_FAILED = "\\#ffa0a0\\Failed to join the lobby!"
LOBBY_PASSWORD_INCORRECT = "\\#ffa0a0\\Entered the wrong lobby password!" LOBBY_PASSWORD_INCORRECT = "\\#ffa0a0\\Entered the wrong lobby password!"
COOPNET_VERSION = "\\#ffa0a0\\Your version is no longer compatible with CoopNet. Update the game!" COOPNET_VERSION = "\\#ffa0a0\\Your version is no longer compatible with CoopNet. Update the game!"
PEER_FAILED = "\\#ffa0a0\\Failed to connect to player '@'" PEER_FAILED = "\\#ffa0a0\\Failed to connect to player '@'"
UNKNOWN = "unknown"
LOBBY_HOST = "the lobby's host"
[CHAT] [CHAT]
KICKING = "Kicking '@'!" KICKING = "Kicking '@'!"

Binary file not shown.

View File

@ -100,11 +100,13 @@ static void coopnet_on_error(enum MPacketErrorNumber error, uint64_t tag) {
{ {
char built[256] = { 0 }; char built[256] = { 0 };
u8 localIndex = coopnet_user_id_to_local_index(tag); u8 localIndex = coopnet_user_id_to_local_index(tag);
if (localIndex == UNKNOWN_LOCAL_INDEX || gNetworkPlayers[localIndex].name[0] == '\0') { char* name = DLANG(NOTIF, UNKNOWN);
snprintf(built, 256, "%s", "unknown"); if (localIndex == 0) {
} else { name = DLANG(NOTIF, LOBBY_HOST);
djui_language_replace(DLANG(NOTIF, IMPORT_MOD_SUCCESS), built, 256, '@', gNetworkPlayers[localIndex].name); } else if (localIndex != UNKNOWN_LOCAL_INDEX && gNetworkPlayers[localIndex].connected) {
name = gNetworkPlayers[localIndex].name;
} }
djui_language_replace(DLANG(NOTIF, IMPORT_MOD_SUCCESS), built, 256, '@', name);
djui_popup_create(built, 2); djui_popup_create(built, 2);
} }
break; break;