Fix special case (min=0,fix=!0)

This commit is contained in:
Cooliokid956 2026-01-02 21:37:43 -06:00
parent 1bb5e2fe8d
commit d4cc656046
15 changed files with 40 additions and 31 deletions

View file

@ -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 = {

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -324,7 +324,6 @@ MENU_OPTIONS = "メニューの設定"
INFORMATION = "情報"
DEBUG = "デバッグ"
LANGUAGE = "言語"
COOP_COMPATIBILITY = "sm64ex-coopとの互換性を有効にする"
R_BUTTON = "Rボタン - 設定"
L_BUTTON = "Lボタン - 有効化されたMODを再読み込み"

View file

@ -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"

View file

@ -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"

View file

@ -323,7 +323,6 @@ MENU_OPTIONS = "Параметры меню"
INFORMATION = "Информация"
DEBUG = "Отладка"
LANGUAGE = "Язык"
COOP_COMPATIBILITY = "Включить совместимость sm64ex-coop"
R_BUTTON = "Кнопка R - Опции"
L_BUTTON = "Кнопка L - Перезагрузить активные моды"

View file

@ -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"

View file

@ -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) {

View file

@ -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"

View file

@ -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",