diff --git a/developer/discord.sh b/developer/discord.sh index fadf1ca3..e6a1a6a7 100644 --- a/developer/discord.sh +++ b/developer/discord.sh @@ -16,3 +16,8 @@ fi $FILE --discord 2 --configfile sm64config_server.txt & $FILE --discord 1 --configfile sm64config_client.txt & exit + + +#debug discord client +$FILE --discord 2 --configfile sm64config_server.txt & +winpty cgdb ./build/us_pc/sm64.us.f3dex2e.exe -ex 'break debug_breakpoint_here' -ex 'r --discord 1 --configfile sm64config_client.txt' diff --git a/src/pc/djui/djui_inputbox.c b/src/pc/djui/djui_inputbox.c index 595d353e..03bbf6bc 100644 --- a/src/pc/djui/djui_inputbox.c +++ b/src/pc/djui/djui_inputbox.c @@ -310,7 +310,7 @@ static void djui_inputbox_on_text_input(struct DjuiBase *base, char* text) { // make sure we're not just printing garbage characters bool containsValidAscii = false; char* tinput = text; - while (*tinput != NULL) { + while (*tinput != '\0') { if (*tinput >= '!' && *tinput <= '~') { containsValidAscii = true; break; diff --git a/src/pc/network/discord/activity.c b/src/pc/network/discord/activity.c index 3ed46251..b41f625c 100644 --- a/src/pc/network/discord/activity.c +++ b/src/pc/network/discord/activity.c @@ -33,6 +33,11 @@ static void on_activity_join_callback(UNUSED void* data, enum EDiscordResult res discord_network_init(lobby->id); discord_activity_update(false); + if (gNetworkType == NT_CLIENT) { + ns_discord_save_id(gNetworkPlayerServer->localIndex, lobby->owner_id); + network_send_join_request(); + } + gNetworkUserIds[0] = lobby->owner_id; } diff --git a/src/pc/network/discord/discord.c b/src/pc/network/discord/discord.c index 735f7f82..8f6529b9 100644 --- a/src/pc/network/discord/discord.c +++ b/src/pc/network/discord/discord.c @@ -131,12 +131,6 @@ static bool ns_discord_initialize(enum NetworkType networkType) { #ifdef DEBUG set_instance_env_variable(); #endif -#ifdef UNSTABLE_BRANCH - if (networkType != NT_NONE) { - // refuse to host on discord for unstable branch - exit(1); - } -#endif if (!gDiscordInitialized) { // set up discord params diff --git a/src/pc/network/network.c b/src/pc/network/network.c index d044f167..7c54c830 100644 --- a/src/pc/network/network.c +++ b/src/pc/network/network.c @@ -86,7 +86,6 @@ bool network_init(enum NetworkType inNetworkType) { djui_chat_box_create(); } else if (gNetworkType == NT_CLIENT) { network_player_connected(NPT_SERVER, 0); - network_send_join_request(); } LOG_INFO("initialized"); diff --git a/src/pc/network/packets/packet.c b/src/pc/network/packets/packet.c index bf883515..076a927d 100644 --- a/src/pc/network/packets/packet.c +++ b/src/pc/network/packets/packet.c @@ -80,6 +80,7 @@ void packet_receive(struct Packet* p) { LOG_INFO("closing connection for packetType: %d", packetType); network_send_kick(EKT_CLOSE_CONNECTION); } + LOG_INFO("refusing packet from unknown player, packetType: %d", packetType); return; } @@ -112,6 +113,8 @@ void packet_receive(struct Packet* p) { // process the packet packet_process(p); } + } else { + LOG_INFO("packet initial read failed, packetType: %d", packetType); } // broadcast packet diff --git a/src/pc/network/packets/packet_join.c b/src/pc/network/packets/packet_join.c index 966e0afe..e0c366e5 100644 --- a/src/pc/network/packets/packet_join.c +++ b/src/pc/network/packets/packet_join.c @@ -13,7 +13,7 @@ #include "pc/djui/djui.h" #include "pc/cheats.h" #include "pc/utils/string_builder.h" -#define DISABLE_MODULE_LOG 1 +//#define DISABLE_MODULE_LOG 1 #include "pc/debuglog.h" extern u8* gOverrideEeprom; @@ -26,7 +26,7 @@ void network_send_join_request(void) { struct Packet p; packet_init(&p, PACKET_JOIN_REQUEST, true, false); - network_send_to(gNetworkPlayerServer->localIndex, &p); + network_send_to((gNetworkPlayerServer != NULL) ? gNetworkPlayerServer->localIndex : 0, &p); LOG_INFO("sending join request"); } diff --git a/src/pc/network/socket/socket.c b/src/pc/network/socket/socket.c index e43956fe..7303aff5 100644 --- a/src/pc/network/socket/socket.c +++ b/src/pc/network/socket/socket.c @@ -93,6 +93,10 @@ static bool ns_socket_initialize(enum NetworkType networkType) { LOG_INFO("initialized"); + if (networkType == NT_CLIENT) { + network_send_join_request(); + } + // success return true; }