mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-21 19:45:10 +00:00
Added version checking to clients
This commit is contained in:
parent
163527401e
commit
04c21d91bc
5 changed files with 28 additions and 5 deletions
4
Makefile
4
Makefile
|
@ -147,11 +147,11 @@ VERSION_ASFLAGS := --defsym $(VERSION_DEF)=1
|
||||||
|
|
||||||
# Stuff for showing the git hash in the intro on nightly builds
|
# Stuff for showing the git hash in the intro on nightly builds
|
||||||
# From https://stackoverflow.com/questions/44038428/include-git-commit-hash-and-or-branch-name-in-c-c-source
|
# From https://stackoverflow.com/questions/44038428/include-git-commit-hash-and-or-branch-name-in-c-c-source
|
||||||
ifeq ($(shell git rev-parse --abbrev-ref HEAD),nightly)
|
#ifeq ($(shell git rev-parse --abbrev-ref HEAD),nightly)
|
||||||
GIT_HASH=`git rev-parse --short HEAD`
|
GIT_HASH=`git rev-parse --short HEAD`
|
||||||
COMPILE_TIME=`date -u +'%Y-%m-%d %H:%M:%S UTC'`
|
COMPILE_TIME=`date -u +'%Y-%m-%d %H:%M:%S UTC'`
|
||||||
VERSION_CFLAGS += -DNIGHTLY -DGIT_HASH="\"$(GIT_HASH)\"" -DCOMPILE_TIME="\"$(COMPILE_TIME)\""
|
VERSION_CFLAGS += -DNIGHTLY -DGIT_HASH="\"$(GIT_HASH)\"" -DCOMPILE_TIME="\"$(COMPILE_TIME)\""
|
||||||
endif
|
#endif
|
||||||
|
|
||||||
# Microcode
|
# Microcode
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,8 @@
|
||||||
* special menu messages and phases, button states and button clicked checks.
|
* special menu messages and phases, button states and button clicked checks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static u8 joinVersionMismatch = FALSE;
|
||||||
|
|
||||||
#ifdef VERSION_US
|
#ifdef VERSION_US
|
||||||
// The current sound mode is automatically centered on US due to
|
// The current sound mode is automatically centered on US due to
|
||||||
// the large length difference between options.
|
// the large length difference between options.
|
||||||
|
@ -437,6 +439,7 @@ void join_server_as_client(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
keyboard_stop_text_input();
|
keyboard_stop_text_input();
|
||||||
|
joinVersionMismatch = FALSE;
|
||||||
network_init(NT_CLIENT, configJoinIp, configJoinPort);
|
network_init(NT_CLIENT, configJoinIp, configJoinPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,6 +448,11 @@ void joined_server_as_client(s16 fileIndex) {
|
||||||
sSelectedFileNum = fileIndex;
|
sSelectedFileNum = fileIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void joined_server_version_mismatch(void) {
|
||||||
|
if (gNetworkType != NT_CLIENT) { return; }
|
||||||
|
joinVersionMismatch = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
void render_network_mode_menu_buttons(struct Object* soundModeButton) {
|
void render_network_mode_menu_buttons(struct Object* soundModeButton) {
|
||||||
#define NETWORK_BUTTON_Y 0
|
#define NETWORK_BUTTON_Y 0
|
||||||
// Host option button
|
// Host option button
|
||||||
|
@ -561,7 +569,9 @@ void print_join_mode_menu_strings(void) {
|
||||||
print_generic_ascii_string(JOIN_LEVEL_NAME_X, 191 - (12 * 2), gTextInput);
|
print_generic_ascii_string(JOIN_LEVEL_NAME_X, 191 - (12 * 2), gTextInput);
|
||||||
|
|
||||||
// Print status
|
// Print status
|
||||||
if (gNetworkType == NT_CLIENT) {
|
if (joinVersionMismatch) {
|
||||||
|
print_generic_ascii_string(JOIN_LEVEL_NAME_X, 191 - (12 * 14), "Error - versions don't match. Both should rebuild!");
|
||||||
|
} else if (gNetworkType == NT_CLIENT) {
|
||||||
print_generic_ascii_string(JOIN_LEVEL_NAME_X, 191 - (12 * 14), "Connecting...");
|
print_generic_ascii_string(JOIN_LEVEL_NAME_X, 191 - (12 * 14), "Connecting...");
|
||||||
} else if (strlen(gTextInput) > 0) {
|
} else if (strlen(gTextInput) > 0) {
|
||||||
print_generic_ascii_string(JOIN_LEVEL_NAME_X, 191 - (12 * 14), "Press (ENTER) to join.");
|
print_generic_ascii_string(JOIN_LEVEL_NAME_X, 191 - (12 * 14), "Press (ENTER) to join.");
|
||||||
|
|
|
@ -144,5 +144,6 @@ Gfx *geo_file_select_strings_and_menu_cursor(s32 callContext, UNUSED struct Grap
|
||||||
s32 lvl_init_menu_values_and_cursor_pos(UNUSED s32 arg, UNUSED s32 unused);
|
s32 lvl_init_menu_values_and_cursor_pos(UNUSED s32 arg, UNUSED s32 unused);
|
||||||
s32 lvl_update_obj_and_load_file_selected(UNUSED s32 arg, UNUSED s32 unused);
|
s32 lvl_update_obj_and_load_file_selected(UNUSED s32 arg, UNUSED s32 unused);
|
||||||
void joined_server_as_client(s16 fileIndex);
|
void joined_server_as_client(s16 fileIndex);
|
||||||
|
void joined_server_version_mismatch(void);
|
||||||
|
|
||||||
#endif // FILE_SELECT_H
|
#endif // FILE_SELECT_H
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "src/pc/fs/fs.h"
|
#include "src/pc/fs/fs.h"
|
||||||
#include "PR/os_eeprom.h"
|
#include "PR/os_eeprom.h"
|
||||||
|
|
||||||
|
#define HASH_LENGTH 8
|
||||||
extern u8* gOverrideEeprom;
|
extern u8* gOverrideEeprom;
|
||||||
static u8 eeprom[512] = { 0 };
|
static u8 eeprom[512] = { 0 };
|
||||||
|
|
||||||
|
@ -38,8 +39,11 @@ void network_send_save_file(void) {
|
||||||
fs_close(fp);
|
fs_close(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char hash[HASH_LENGTH] = GIT_HASH;
|
||||||
|
|
||||||
struct Packet p;
|
struct Packet p;
|
||||||
packet_init(&p, PACKET_SAVE_FILE, true);
|
packet_init(&p, PACKET_SAVE_FILE, true);
|
||||||
|
packet_write(&p, &hash, sizeof(u8) * HASH_LENGTH);
|
||||||
packet_write(&p, &gCurrSaveFileNum, sizeof(s16));
|
packet_write(&p, &gCurrSaveFileNum, sizeof(s16));
|
||||||
packet_write(&p, &gServerSettings.playerInteractions, sizeof(u8));
|
packet_write(&p, &gServerSettings.playerInteractions, sizeof(u8));
|
||||||
packet_write(&p, &gServerSettings.playerKnockbackStrength, sizeof(u8));
|
packet_write(&p, &gServerSettings.playerKnockbackStrength, sizeof(u8));
|
||||||
|
@ -52,8 +56,11 @@ void network_receive_save_file(struct Packet* p) {
|
||||||
assert(gNetworkType == NT_CLIENT);
|
assert(gNetworkType == NT_CLIENT);
|
||||||
|
|
||||||
gOverrideEeprom = eeprom;
|
gOverrideEeprom = eeprom;
|
||||||
|
char hash[HASH_LENGTH] = GIT_HASH;
|
||||||
|
char remoteHash[HASH_LENGTH] = { 0 };
|
||||||
|
|
||||||
// find all reserved objects
|
// find all reserved objects
|
||||||
|
packet_read(p, &remoteHash, sizeof(u8) * HASH_LENGTH);
|
||||||
packet_read(p, &gCurrSaveFileNum, sizeof(s16));
|
packet_read(p, &gCurrSaveFileNum, sizeof(s16));
|
||||||
packet_read(p, &gServerSettings.playerInteractions, sizeof(u8));
|
packet_read(p, &gServerSettings.playerInteractions, sizeof(u8));
|
||||||
packet_read(p, &gServerSettings.playerKnockbackStrength, sizeof(u8));
|
packet_read(p, &gServerSettings.playerKnockbackStrength, sizeof(u8));
|
||||||
|
@ -61,5 +68,10 @@ void network_receive_save_file(struct Packet* p) {
|
||||||
packet_read(p, eeprom, sizeof(u8) * 512);
|
packet_read(p, eeprom, sizeof(u8) * 512);
|
||||||
|
|
||||||
save_file_load_all(TRUE);
|
save_file_load_all(TRUE);
|
||||||
|
if (memcmp(hash, remoteHash, HASH_LENGTH) != 0) {
|
||||||
|
joined_server_version_mismatch();
|
||||||
|
network_shutdown();
|
||||||
|
return;
|
||||||
|
}
|
||||||
joined_server_as_client(gCurrSaveFileNum);
|
joined_server_as_client(gCurrSaveFileNum);
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,8 +244,8 @@ void main_func(void) {
|
||||||
|
|
||||||
char window_title[96] =
|
char window_title[96] =
|
||||||
"Super Mario 64 EX coop (" RAPI_NAME ")"
|
"Super Mario 64 EX coop (" RAPI_NAME ")"
|
||||||
#ifdef NIGHTLY
|
#ifdef GIT_HASH
|
||||||
" nightly " GIT_HASH
|
" [" GIT_HASH "]"
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue