diff --git a/build-windows-visual-studio/sm64ex.vcxproj b/build-windows-visual-studio/sm64ex.vcxproj
index db836c36..d925fbdf 100644
--- a/build-windows-visual-studio/sm64ex.vcxproj
+++ b/build-windows-visual-studio/sm64ex.vcxproj
@@ -3985,6 +3985,7 @@
+
@@ -4342,6 +4343,7 @@
+
diff --git a/build-windows-visual-studio/sm64ex.vcxproj.filters b/build-windows-visual-studio/sm64ex.vcxproj.filters
index 26133b01..844a2f38 100644
--- a/build-windows-visual-studio/sm64ex.vcxproj.filters
+++ b/build-windows-visual-studio/sm64ex.vcxproj.filters
@@ -15081,6 +15081,9 @@
Source Files\src\pc\network\packets
+
+ Source Files\src\pc\network
+
@@ -16039,5 +16042,8 @@
Source Files\src\game
+
+ Header Files\src\pc\network
+
\ No newline at end of file
diff --git a/src/menu/custom_menu.c b/src/menu/custom_menu.c
index ccac5aac..e5206b4e 100644
--- a/src/menu/custom_menu.c
+++ b/src/menu/custom_menu.c
@@ -17,6 +17,8 @@
#include "behavior_data.h"
#include "audio_defines.h"
#include "audio/external.h"
+#include "config.h"
+#include "pc/network/version.h"
#define MAIN_MENU_HEADER_TEXT "SM64 COOP"
@@ -27,11 +29,14 @@ u8 gOpenConnectMenu = FALSE;
s8 sGotoGame = 0;
static void menu_main_draw_strings(void) {
- print_generic_ascii_string(98, 150, "Still in early development.");
- u8 red = (gGlobalTimer % 20 > 10) ? 0 : 222;
- if (gGlobalTimer > 200) { red = 222; }
- gDPSetEnvColor(gDisplayListHead++, 222, red, red, gMenuStringAlpha);
- print_generic_ascii_string(21, 55, "For now, levels after the 50 star door are unsupported.");
+ char* subtitle = "Still in development.";
+ s16 subtitleX = (SCREEN_WIDTH - get_generic_ascii_string_width(subtitle)) / 2;
+ print_generic_ascii_string(subtitleX, 150, subtitle);
+
+ char* versionString = get_version();
+ gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, 120);
+ print_generic_ascii_string(25, 25, versionString);
+
}
static void host_menu_draw_strings(void) {
diff --git a/src/pc/network/discord/activity.c b/src/pc/network/discord/activity.c
index e4fd58b2..5f9a3a83 100644
--- a/src/pc/network/discord/activity.c
+++ b/src/pc/network/discord/activity.c
@@ -3,6 +3,7 @@
#include "discord_network.h"
#include "pc/debuglog.h"
#include "menu/custom_menu.h"
+#include "pc/network/version.h"
#define HASH_LENGTH 8
struct DiscordActivity gCurActivity = { 0 };
@@ -63,9 +64,8 @@ void discord_activity_update(bool hosting) {
gCurActivity.party.size.max_size = 1;
}
- char hash[HASH_LENGTH] = GIT_HASH;
- strcpy(gCurActivity.details, "version ");
- strncat(gCurActivity.details, GIT_HASH, 127);
+ char* version = get_version();
+ snprintf(gCurActivity.details, MAX_VERSION_LENGTH, "%s", get_version());
app.activities->update_activity(app.activities, &gCurActivity, NULL, on_activity_update_callback);
LOG_INFO("set activity");
diff --git a/src/pc/network/packets/packet_join.c b/src/pc/network/packets/packet_join.c
index a51ce6a1..0cc85cee 100644
--- a/src/pc/network/packets/packet_join.c
+++ b/src/pc/network/packets/packet_join.c
@@ -10,9 +10,9 @@
#include "src/menu/custom_menu.h"
#include "src/pc/fs/fs.h"
#include "PR/os_eeprom.h"
+#include "pc/network/version.h"
#include "pc/debuglog.h"
-#define HASH_LENGTH 8
extern u8* gOverrideEeprom;
static u8 eeprom[512] = { 0 };
@@ -49,11 +49,13 @@ void network_send_join(struct Packet* joinRequestPacket) {
return;
}
- char hash[HASH_LENGTH] = GIT_HASH;
+ char version[MAX_VERSION_LENGTH] = { 0 };
+ snprintf(version, MAX_VERSION_LENGTH, "%s", get_version());
+ LOG_INFO("sending version: %s", version);
struct Packet p;
packet_init(&p, PACKET_JOIN, true, false);
- packet_write(&p, &hash, sizeof(u8) * HASH_LENGTH);
+ packet_write(&p, &version, sizeof(u8) * MAX_VERSION_LENGTH);
packet_write(&p, &joinRequestPacket->localIndex, sizeof(u8));
packet_write(&p, &gCurrSaveFileNum, sizeof(s16));
packet_write(&p, &gServerSettings.playerInteractions, sizeof(u8));
@@ -85,8 +87,12 @@ void network_receive_join(struct Packet* p) {
LOG_INFO("received join packet");
gOverrideEeprom = eeprom;
- char hash[HASH_LENGTH] = GIT_HASH;
- char remoteHash[HASH_LENGTH] = { 0 };
+
+ char version[MAX_VERSION_LENGTH] = { 0 };
+ snprintf(version, MAX_VERSION_LENGTH, "%s", get_version());
+ LOG_INFO("client has version: %s", version);
+
+ char remoteVersion[MAX_VERSION_LENGTH] = { 0 };
u8 myGlobalIndex = UNKNOWN_GLOBAL_INDEX;
u8 modCount = 0;
@@ -96,8 +102,10 @@ void network_receive_join(struct Packet* p) {
}
// verify version
- packet_read(p, &remoteHash, sizeof(u8) * HASH_LENGTH);
- if (memcmp(hash, remoteHash, HASH_LENGTH) != 0) {
+ packet_read(p, &remoteVersion, sizeof(u8) * MAX_VERSION_LENGTH);
+ 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!");
return;
}
diff --git a/src/pc/network/version.c b/src/pc/network/version.c
new file mode 100644
index 00000000..e0affbd3
--- /dev/null
+++ b/src/pc/network/version.c
@@ -0,0 +1,12 @@
+#include
+#include "version.h"
+#include "types.h"
+
+static u16 sVersionInteger = 1;
+static char sVersionString[MAX_VERSION_LENGTH] = { 0 };
+#define VERSION_TEXT "beta "
+
+char* get_version(void) {
+ snprintf(sVersionString, MAX_VERSION_LENGTH, "%s%d", VERSION_TEXT, sVersionInteger);
+ return sVersionString;
+}
\ No newline at end of file
diff --git a/src/pc/network/version.h b/src/pc/network/version.h
new file mode 100644
index 00000000..f5eb3996
--- /dev/null
+++ b/src/pc/network/version.h
@@ -0,0 +1,7 @@
+#ifndef VERSION_H
+#define VERSION_H
+
+#define MAX_VERSION_LENGTH 10
+char* get_version(void);
+
+#endif
diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c
index c5a252ba..c6548f93 100644
--- a/src/pc/pc_main.c
+++ b/src/pc/pc_main.c
@@ -1,5 +1,6 @@
#include
#include
+#include
#ifdef TARGET_WEB
#include
@@ -40,6 +41,7 @@
#ifdef DISCORDRPC
#include "pc/discord/discordrpc.h"
#endif
+#include "pc/network/version.h"
OSMesg D_80339BEC;
OSMesgQueue gSIEventMesgQueue;
@@ -242,12 +244,13 @@ void main_func(void) {
#error No rendering API!
#endif
- char window_title[96] =
- "Super Mario 64 EX coop (" RAPI_NAME ")"
- #ifdef GIT_HASH
- " [" GIT_HASH "]"
- #endif
- ;
+ char* version = get_version();
+ char window_title[96] = { 0 };
+#ifdef GIT_HASH
+ snprintf(window_title, 96, "sm64ex-coop: %s [%s]", version, GIT_HASH);
+#else
+ snprintf(window_title, 96, "sm64ex-coop: %s", version);
+#endif
gfx_init(wm_api, rendering_api, window_title);
wm_api->set_keyboard_callbacks(keyboard_on_key_down, keyboard_on_key_up, keyboard_on_all_keys_up, keyboard_on_text_input);