diff --git a/buildsettings.h b/buildsettings.h index c29f387..06fa1b5 100644 --- a/buildsettings.h +++ b/buildsettings.h @@ -5,6 +5,8 @@ #endif #define SERVER_PORT 2551 +// must be unsigned integer +#define GIT_RELEASE_TAG 22 #ifdef DEBUG @@ -12,18 +14,20 @@ #define ASSERT_DO_POPUP_AND_CRASH // #define SERVER_ADDRESS "207.246.80.160" -//#define PROFILING +// #define PROFILING #define DEBUG_RENDERING -//#define DEBUG_WORLD -//#define UNLOCK_ALL -//#define INFINITE_RESOURCES -//#define NO_GRAVITY -//#define NO_SUNS +// #define DEBUG_WORLD +// #define UNLOCK_ALL +// #define INFINITE_RESOURCES +// #define NO_GRAVITY +// #define NO_SUNS #else #ifdef RELEASE +// DANGER modifying these, make sure to change them back before releasing + // #define PROFILING // #define SERVER_ADDRESS "127.0.0.1" #define SERVER_ADDRESS "207.246.80.160" diff --git a/gamestate.c b/gamestate.c index a8b65a3..18f723b 100644 --- a/gamestate.c +++ b/gamestate.c @@ -60,6 +60,29 @@ enum FILE *log_file = NULL; +void quit_with_popup(const char *message_utf8, const char *title_utf8) +{ +#ifdef WIN32 + size_t message_out_len = 0; + size_t title_out_len = 0; + wchar_t *message_wchar = fromUTF8(message_utf8, strlen(message_utf8), &message_out_len); + wchar_t *title_wchar = fromUTF8(title_utf8, strlen(title_utf8), &title_out_len); + int msgboxID = MessageBox( + NULL, + message_wchar, + title_wchar, + MB_ICONEXCLAMATION | MB_OK); + (void)msgboxID; + + free(message_wchar); + free(title_wchar); + + PostQuitMessage(1); + (void)message_out_len; + (void)title_out_len; +#endif +} + void __flight_assert(bool cond, const char *file, int line, const char *cond_string) { if (!cond) @@ -74,19 +97,9 @@ void __flight_assert(bool cond, const char *file, int line, const char *cond_str fprintf(log_file, "%s", message_buffer); } #ifdef ASSERT_DO_POPUP_AND_CRASH - size_t out_len = 0; - wchar_t *output = fromUTF8(message_buffer, strlen(message_buffer), &out_len); - wchar_t dialogbox_message[MESSAGE_BUFFER_SIZE] = {0}; - _snwprintf_s(dialogbox_message, MESSAGE_BUFFER_SIZE, MESSAGE_BUFFER_SIZE, L"Critical error! Please report this in #bug-reports with a screenshot, description of what you were doing, and the file 'atris.log' located next to the executable\n%s\nClosing now.\n", output); - int msgboxID = MessageBox( - NULL, - dialogbox_message, - L"Assertion Failed", - MB_ICONEXCLAMATION | MB_OK); - (void)msgboxID; - - free(output); - PostQuitMessage(1); + char dialogbox_message[MESSAGE_BUFFER_SIZE] = {0}; + snprintf(dialogbox_message, MESSAGE_BUFFER_SIZE, "Critical error! Please report this in #bug-reports with a screenshot, description of what you were doing, and the file 'atris.log' located next to the executable\n%s\nClosing now.\n", message_buffer); + quit_with_popup(dialogbox_message, "Assertion Failed"); #endif } } @@ -982,6 +995,7 @@ typedef struct SerState // output uint32_t version; + uint32_t git_release_tag; } SerState; typedef struct SerMaybeFailure @@ -1412,6 +1426,15 @@ SerMaybeFailure ser_server_to_client(SerState *ser, ServerToClient *s) SER_VAR(&ser->version); SER_ASSERT(ser->version >= 0); SER_ASSERT(ser->version < VMax); + SER_VAR(&ser->git_release_tag); + + if (ser->git_release_tag > GIT_RELEASE_TAG) + { + char msg[2048] = {0}; + snprintf(msg, 2048, "Current game build %d is old, download the server's build %d! The most recent one in discord!\n", GIT_RELEASE_TAG, ser->git_release_tag); + quit_with_popup(msg, "Old Game Build"); + SER_ASSERT(ser->git_release_tag <= GIT_RELEASE_TAG); + } if (!ser->save_or_load_from_disk) SER_MAYBE_RETURN(ser_opus_packets(ser, s->audio_playback_buffer)); diff --git a/release_all.bat b/release_all.bat index b5cc4ff..e44f3a6 100644 --- a/release_all.bat +++ b/release_all.bat @@ -6,4 +6,4 @@ echo "Now test flight-nonumber and make sure it works. Once everything is confir echo "1. Increment the GIT_RELEASE_TAG in buildsettings.h" echo "2. Add everything to git and commit" echo "3. Tag the new commit the _exact same_ as the previously mentioned GIT_RELEASE_TAG" -echo "4. Push everything, then update all the servers (@TODO make this a script)" \ No newline at end of file +echo "4. Push everything, then update all the servers (@TODO make this a script that works for multiple servers)" \ No newline at end of file