Add peering failure notification
This commit is contained in:
parent
f4ab060a05
commit
af04df0f26
|
@ -26,6 +26,7 @@ LOBBY_JOIN_FULL = "\\#ffa0a0\\The lobby is full!"
|
|||
LOBBY_JOIN_FAILED = "\\#ffa0a0\\Failed to join the lobby!"
|
||||
LOBBY_PASSWORD_INCORRECT = "\\#ffa0a0\\Entered the wrong lobby password!"
|
||||
COOPNET_VERSION = "\\#ffa0a0\\Your version is no longer compatible with CoopNet. Update the game!"
|
||||
PEER_FAILED = "\\#ffa0a0\\Failed to connect to player '@'"
|
||||
|
||||
[CHAT]
|
||||
KICKING = "Kicking '@'!"
|
||||
|
|
|
@ -22,6 +22,7 @@ enum MPacketErrorNumber {
|
|||
MERR_LOBBY_JOIN_FAILED,
|
||||
MERR_LOBBY_PASSWORD_INCORRECT,
|
||||
MERR_COOPNET_VERSION,
|
||||
MERR_PEER_FAILED,
|
||||
MERR_MAX,
|
||||
};
|
||||
|
||||
|
@ -34,7 +35,7 @@ typedef struct {
|
|||
void (*OnLobbyListGot)(uint64_t aLobbyId, uint64_t aOwnerId, uint16_t aConnections, uint16_t aMaxConnections, const char* aGame, const char* aVersion, const char* aHostName, const char* aMode, const char* aDescription);
|
||||
void (*OnLobbyListFinish)(void);
|
||||
void (*OnReceive)(uint64_t aFromUserId, const uint8_t* aData, uint64_t aSize);
|
||||
void (*OnError)(enum MPacketErrorNumber aErrorNumber);
|
||||
void (*OnError)(enum MPacketErrorNumber aErrorNumber, uint64_t tag);
|
||||
void (*OnPeerConnected)(uint64_t aPeerId);
|
||||
void (*OnPeerDisconnected)(uint64_t aPeerId);
|
||||
} CoopNetCallbacks;
|
||||
|
|
|
@ -90,12 +90,24 @@ static void coopnet_on_lobby_left(uint64_t lobbyId, uint64_t userId) {
|
|||
}
|
||||
}
|
||||
|
||||
static void coopnet_on_error(enum MPacketErrorNumber error) {
|
||||
static void coopnet_on_error(enum MPacketErrorNumber error, uint64_t tag) {
|
||||
switch (error) {
|
||||
case MERR_COOPNET_VERSION:
|
||||
djui_popup_create(DLANG(NOTIF, COOPNET_VERSION), 2);
|
||||
network_shutdown(false, false, false, false);
|
||||
break;
|
||||
case MERR_PEER_FAILED:
|
||||
{
|
||||
char built[256] = { 0 };
|
||||
u8 localIndex = coopnet_user_id_to_local_index(tag);
|
||||
if (localIndex == UNKNOWN_LOCAL_INDEX || gNetworkPlayers[localIndex].name[0] == '\0') {
|
||||
snprintf(built, 256, "%s", "unknown");
|
||||
} else {
|
||||
djui_language_replace(DLANG(NOTIF, IMPORT_MOD_SUCCESS), built, 256, '@', gNetworkPlayers[localIndex].name);
|
||||
}
|
||||
djui_popup_create(built, 2);
|
||||
}
|
||||
break;
|
||||
case MERR_LOBBY_NOT_FOUND:
|
||||
djui_popup_create(DLANG(NOTIF, LOBBY_NOT_FOUND), 2);
|
||||
network_shutdown(false, false, false, false);
|
||||
|
@ -112,7 +124,8 @@ static void coopnet_on_error(enum MPacketErrorNumber error) {
|
|||
djui_popup_create(DLANG(NOTIF, LOBBY_PASSWORD_INCORRECT), 2);
|
||||
network_shutdown(false, false, false, false);
|
||||
break;
|
||||
default:
|
||||
case MERR_NONE:
|
||||
case MERR_MAX:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -241,7 +254,6 @@ static void ns_coopnet_shutdown(bool reconnecting) {
|
|||
}
|
||||
|
||||
static CoopNetRc coopnet_initialize(void) {
|
||||
|
||||
gCoopNetCallbacks.OnConnected = coopnet_on_connected;
|
||||
gCoopNetCallbacks.OnDisconnected = coopnet_on_disconnected;
|
||||
gCoopNetCallbacks.OnReceive = coopnet_on_receive;
|
||||
|
|
Loading…
Reference in New Issue