Fix Discord connections on unstable

This commit is contained in:
MysterD 2021-07-31 17:24:13 -07:00
parent 7757a69145
commit 9699d79dd7
8 changed files with 20 additions and 10 deletions

View file

@ -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'

View file

@ -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;

View file

@ -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;
}

View file

@ -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

View file

@ -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");

View file

@ -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

View file

@ -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");
}

View file

@ -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;
}