From 7bf2ebd7e83b7363c22be4c8d1c9ee077a8963ec Mon Sep 17 00:00:00 2001 From: MysterD Date: Sun, 11 Oct 2020 18:26:10 -0700 Subject: [PATCH] Made version mismatch screen more descriptive --- src/menu/custom_menu.c | 4 +++- src/pc/network/packets/packet_join.c | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/menu/custom_menu.c b/src/menu/custom_menu.c index e5206b4e..e51fda71 100644 --- a/src/menu/custom_menu.c +++ b/src/menu/custom_menu.c @@ -146,7 +146,9 @@ static void connect_menu_draw_strings(void) { if (*sConnectionJoinError) { f32 red = (f32)fabs(sin(gGlobalTimer / 20.0f)); gDPSetEnvColor(gDisplayListHead++, 222, 222 * red, 222 * red, gMenuStringAlpha); - print_generic_ascii_string(30, 130, sConnectionJoinError); + f32 messageX = (SCREEN_WIDTH - get_generic_ascii_string_width(sConnectionJoinError)) / 2.0; + f32 messageY = (SCREEN_HEIGHT + get_generic_ascii_string_height(sConnectionJoinError)) / 2.0; + print_generic_ascii_string(messageX, messageY, sConnectionJoinError); return; } diff --git a/src/pc/network/packets/packet_join.c b/src/pc/network/packets/packet_join.c index 0cc85cee..fbc4aa48 100644 --- a/src/pc/network/packets/packet_join.c +++ b/src/pc/network/packets/packet_join.c @@ -106,7 +106,16 @@ void network_receive_join(struct Packet* p) { LOG_INFO("server has version: %s", version); if (memcmp(version, remoteVersion, MAX_VERSION_LENGTH) != 0) { LOG_ERROR("version mismatch"); - custom_menu_connection_error("Your versions don't match, both should rebuild!"); + + // todo: hack: remove me in the future + // needed because the old style only had 8 characters for the version + if (strcmp("beta", remoteVersion) != 0) { + remoteVersion[8] = '\0'; + } + + char mismatchMessage[128] = { 0 }; + snprintf(mismatchMessage, 128, "Version mismatch.\n\nYour version - %s\nTheir version - %s\n\nSomeone is out of date!\n", version, remoteVersion); + custom_menu_connection_error(mismatchMessage); return; }