From d4cc6560461e21a913fd6df9f9ef88a40c095369 Mon Sep 17 00:00:00 2001 From: Cooliokid956 <68075390+Cooliokid956@users.noreply.github.com> Date: Fri, 2 Jan 2026 21:37:43 -0600 Subject: [PATCH] Fix special case (min=0,fix=!0) --- autogen/convert_constants.py | 2 +- lang/Czech.ini | 1 - lang/Dutch.ini | 1 - lang/English.ini | 1 - lang/French.ini | 1 - lang/German.ini | 1 - lang/Italian.ini | 1 - lang/Japanese.ini | 1 - lang/Polish.ini | 1 - lang/Portuguese.ini | 1 - lang/Russian.ini | 1 - lang/Spanish.ini | 1 - src/pc/network/version.c | 6 ++++- src/pc/network/version.h | 3 --- src/pc/update_checker.c | 49 +++++++++++++++++++++++++----------- 15 files changed, 40 insertions(+), 31 deletions(-) diff --git a/autogen/convert_constants.py b/autogen/convert_constants.py index cadd4b0ca..a2c5668b7 100644 --- a/autogen/convert_constants.py +++ b/autogen/convert_constants.py @@ -68,7 +68,7 @@ exclude_constants = { "src/pc/lua/smlua_hooks.h": [ "MAX_HOOKED_MOD_MENU_ELEMENTS", "^HOOK_RETURN_.*", "^ACTION_HOOK_.*", "^MOD_MENU_ELEMENT_.*" ], "src/pc/djui/djui_panel_menu.h": [ "RAINBOW_TEXT_LEN" ], "src/pc/mods/mod_fs.h": [ "INT_TYPE_MAX", "FLOAT_TYPE_MAX", "FILE_SEEK_MAX" ], - "src/pc/network/version.h": [ "VERSION_OFFSET", "EX_VERSION", "EX_WINDOW_NAME" ], + "src/pc/network/version.h": [ "VERSION_OFFSET", "EX_WINDOW_NAME" ], } include_constants = { diff --git a/lang/Czech.ini b/lang/Czech.ini index ddf7ae547..d967f9678 100644 --- a/lang/Czech.ini +++ b/lang/Czech.ini @@ -324,7 +324,6 @@ MENU_OPTIONS = "Nastavení hlavního menu" INFORMATION = "Informace" DEBUG = "Debug" LANGUAGE = "Jazyk" -COOP_COMPATIBILITY = "Povolit kompatibilitu sm64ex-coop" R_BUTTON = "Tlačítko R - Možnosti" L_BUTTON = "Tlačítko L - Znovu načíst aktivní mody" diff --git a/lang/Dutch.ini b/lang/Dutch.ini index a06530f8b..a93256985 100644 --- a/lang/Dutch.ini +++ b/lang/Dutch.ini @@ -324,7 +324,6 @@ MENU_OPTIONS = "Menu Instellingen" INFORMATION = "Informatie" DEBUG = "Debug" LANGUAGE = "Taal" -COOP_COMPATIBILITY = "Schakel sm64ex-coop compatibiliteit in" R_BUTTON = "R-knop - Opties" L_BUTTON = "L-knop - Actieve mods opnieuw laden" diff --git a/lang/English.ini b/lang/English.ini index 14ec1d462..e234ab76e 100644 --- a/lang/English.ini +++ b/lang/English.ini @@ -324,7 +324,6 @@ MENU_OPTIONS = "Menu Options" INFORMATION = "Info" DEBUG = "Debug" LANGUAGE = "Language" -COOP_COMPATIBILITY = "Enable sm64ex-coop Compatibility" R_BUTTON = "R Button - Options" L_BUTTON = "L Button - Reload Active Mods" diff --git a/lang/French.ini b/lang/French.ini index b0dfe3be2..cf7f9b0f4 100644 --- a/lang/French.ini +++ b/lang/French.ini @@ -324,7 +324,6 @@ MENU_OPTIONS = "Options du menu" INFORMATION = "Information" DEBUG = "Débogage" LANGUAGE = "Langue" -COOP_COMPATIBILITY = "Activer la compatibilité sm64ex-coop" R_BUTTON = "Bouton R - Options" L_BUTTON = "Bouton L - Recharger les mods actifs" diff --git a/lang/German.ini b/lang/German.ini index e44e5c718..951d0e517 100644 --- a/lang/German.ini +++ b/lang/German.ini @@ -324,7 +324,6 @@ MENU_OPTIONS = "Menüoptionen" INFORMATION = "Info" DEBUG = "Debug" LANGUAGE = "Sprache" -COOP_COMPATIBILITY = "Aktiviere sm64ex-coop Kompatibilität" R_BUTTON = "R-Taste - Optionen" L_BUTTON = "L-Taste - Aktive Mods neu laden" diff --git a/lang/Italian.ini b/lang/Italian.ini index e0827a2f6..eb48d000b 100644 --- a/lang/Italian.ini +++ b/lang/Italian.ini @@ -322,7 +322,6 @@ MENU_OPTIONS = "Opzioni Menù" INFORMATION = "Informazione" DEBUG = "Debug" LANGUAGE = "Lingua" -COOP_COMPATIBILITY = "Abilita la compatibilità con sm64ex-coop" R_BUTTON = "Pulsante R - Opzioni" L_BUTTON = "Pulsante L - Ricarica Mod Attive" diff --git a/lang/Japanese.ini b/lang/Japanese.ini index a15f74b3a..0f50fb020 100644 --- a/lang/Japanese.ini +++ b/lang/Japanese.ini @@ -324,7 +324,6 @@ MENU_OPTIONS = "メニューの設定" INFORMATION = "情報" DEBUG = "デバッグ" LANGUAGE = "言語" -COOP_COMPATIBILITY = "sm64ex-coopとの互換性を有効にする" R_BUTTON = "Rボタン - 設定" L_BUTTON = "Lボタン - 有効化されたMODを再読み込み" diff --git a/lang/Polish.ini b/lang/Polish.ini index 9781c549e..df84139d4 100644 --- a/lang/Polish.ini +++ b/lang/Polish.ini @@ -324,7 +324,6 @@ MENU_OPTIONS = "Opcje Menu" INFORMATION = "Informacja" DEBUG = "Debugowanie" LANGUAGE = "Język" -COOP_COMPATIBILITY = "Włącz kompatybilność z sm64ex-coop" R_BUTTON = "Przycisk R - Opcje" L_BUTTON = "Przycisk L - Przeładuj aktywne mody" diff --git a/lang/Portuguese.ini b/lang/Portuguese.ini index e935499a6..db2615124 100644 --- a/lang/Portuguese.ini +++ b/lang/Portuguese.ini @@ -324,7 +324,6 @@ MENU_OPTIONS = "Opções de menu" INFORMATION = "Informações" DEBUG = "Debug" LANGUAGE = "Idioma" -COOP_COMPATIBILITY = "Ativar a compatibilidade com sm64ex-coop" R_BUTTON = "Botão R - Opções" L_BUTTON = "Botão L - Recarregar mods ativos" diff --git a/lang/Russian.ini b/lang/Russian.ini index 52861a4cf..851107795 100644 --- a/lang/Russian.ini +++ b/lang/Russian.ini @@ -323,7 +323,6 @@ MENU_OPTIONS = "Параметры меню" INFORMATION = "Информация" DEBUG = "Отладка" LANGUAGE = "Язык" -COOP_COMPATIBILITY = "Включить совместимость sm64ex-coop" R_BUTTON = "Кнопка R - Опции" L_BUTTON = "Кнопка L - Перезагрузить активные моды" diff --git a/lang/Spanish.ini b/lang/Spanish.ini index f083c8ba2..ef82d277f 100644 --- a/lang/Spanish.ini +++ b/lang/Spanish.ini @@ -324,7 +324,6 @@ MENU_OPTIONS = "Opciones del menú" INFORMATION = "Información" DEBUG = "Depuración" LANGUAGE = "Idioma" -COOP_COMPATIBILITY = "Habilitar la compatibilidad con sm64ex-coop" R_BUTTON = "Botón R - Opciones" L_BUTTON = "Botón L - Recargar mods activos" diff --git a/src/pc/network/version.c b/src/pc/network/version.c index 73041f093..a9083483b 100644 --- a/src/pc/network/version.c +++ b/src/pc/network/version.c @@ -16,7 +16,11 @@ const char* get_version_online(void) { return sVersionString; } -const char* get_version(void) { return configExCoopTheme ? EX_VERSION : get_version_online(); } +const char* get_version(void) { + get_version_online(); + extern void exify_version_str(char* str); + if (configExCoopTheme) { exify_version_str(sVersionString); } + return sVersionString; } #ifdef COMPILE_TIME const char* get_version_with_build_date(void) { diff --git a/src/pc/network/version.h b/src/pc/network/version.h index 27d57ced8..80fd1303a 100644 --- a/src/pc/network/version.h +++ b/src/pc/network/version.h @@ -9,9 +9,6 @@ #define MINOR_VERSION_NUMBER 1 #define VERSION_OFFSET 37 -#define STR(x) #x -#define _EX_VERSION(major, minor) STR(major) "." STR(minor) -#define EX_VERSION VERSION_TEXT _EX_VERSION(VERSION_NUMBER, MINOR_VERSION_NUMBER) #if defined(VERSION_JP) #define VERSION_REGION "JP" diff --git a/src/pc/update_checker.c b/src/pc/update_checker.c index 2f99f92b3..4f95517eb 100644 --- a/src/pc/update_checker.c +++ b/src/pc/update_checker.c @@ -29,10 +29,10 @@ struct Version { int maj, min, fix; }; -bool is_version_newer(struct Version old, struct Version new) { - if (new.maj != old.maj) return new.maj > old.maj; - if (new.min != old.min) return new.min > old.min; - return new.fix > old.fix; +bool is_version_newer(struct Version client, struct Version remote) { + if (remote.maj != client.maj) return remote.maj > client.maj; + if (remote.min != client.min) return remote.min > client.min; + return remote.fix > client.fix; } static struct Version sClientVersion = { 0 }; @@ -64,13 +64,39 @@ size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userdata) { } #endif -void parse_to_version(const char *str, struct Version *ver) { +void strtov(const char *str, struct Version *ver) { char* end; ver->maj = strtol(str+1, &end, 10); if (end) ver->min = strtol(end+1, &end, 10); if (end) ver->fix = strtol(end+1, &end, 10); } +void vtostr(struct Version ver, char* str) { + int len; + snprintf(str, 8, "v%i", ver.maj); + if (ver.min || ver.fix) { + len = strlen(str); + snprintf(str + len, 8 - len, ".%i", ver.min); + if (ver.fix) { + len = strlen(str); + snprintf(str + len, 8 - len, ".%i", ver.fix); + } + } +} + +void exify_version(struct Version *ver) { + ver->maj = ver->min + VERSION_OFFSET; + ver->min = ver->fix; + ver->fix = 0; +} + +void exify_version_str(char* str) { + struct Version ver; + strtov(str, &ver); + exify_version(&ver); + vtostr(ver, str); +} + void parse_version(const char *data) { const char *version = strstr(data, VERSION_IDENTIFIER); if (version == NULL) { return; } @@ -82,8 +108,8 @@ void parse_version(const char *data) { memcpy(sRemoteVersionStr, version, versionLength); sRemoteVersionStr[versionLength] = '\0'; - parse_to_version(sRemoteVersionStr, &sRemoteVersion); - parse_to_version(SM64COOPDX_VERSION, &sClientVersion); + strtov(sRemoteVersionStr, &sRemoteVersion); + strtov(get_version_online(), &sClientVersion); } // function to download a text file from the internet @@ -169,14 +195,7 @@ void check_for_updates(void) { get_version_remote(); if (sRemoteVersionStr[0] == 'v' && is_version_newer(sClientVersion, sRemoteVersion)) { - if (configExCoopTheme) { - snprintf( - sRemoteVersionStr, 10, - "v%i.%i", - sRemoteVersion.min + VERSION_OFFSET, - sRemoteVersion.fix - ); - } + if (configExCoopTheme) { exify_version_str(sRemoteVersionStr); } snprintf( sVersionUpdateTextBuffer, 256, "\\#ffffa0\\%s\n\\#dcdcdc\\%s: %s\n%s: %s",