mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-12-06 08:02:47 +00:00
Make version checking slightly better (#992)
Currently version checking throws false positives constantly. This change will set uninitialized variables and require parsing a version number that starts with v in order to display the pop-up Co-authored-by: MysterD <myster@d>
This commit is contained in:
parent
9a3d3a7640
commit
c2a6110223
1 changed files with 12 additions and 3 deletions
|
|
@ -14,6 +14,14 @@
|
||||||
#define URL "https://raw.githubusercontent.com/coop-deluxe/sm64coopdx/refs/heads/main/src/pc/network/version.h"
|
#define URL "https://raw.githubusercontent.com/coop-deluxe/sm64coopdx/refs/heads/main/src/pc/network/version.h"
|
||||||
#define VERSION_IDENTIFIER "#define SM64COOPDX_VERSION \""
|
#define VERSION_IDENTIFIER "#define SM64COOPDX_VERSION \""
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
NOTE: This entire update checker process should be replaced with one that uses GitHub's API
|
||||||
|
to check for the latest release version. This would be more reliable and efficient than
|
||||||
|
downloading and parsing a source file.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
static char sVersionUpdateTextBuffer[256] = { 0 };
|
static char sVersionUpdateTextBuffer[256] = { 0 };
|
||||||
static char sRemoteVersion[8] = { 0 };
|
static char sRemoteVersion[8] = { 0 };
|
||||||
|
|
||||||
|
|
@ -57,8 +65,10 @@ void parse_version(const char *data) {
|
||||||
|
|
||||||
// function to download a text file from the internet
|
// function to download a text file from the internet
|
||||||
void get_version_remote(void) {
|
void get_version_remote(void) {
|
||||||
|
sRemoteVersion[0] = '\0';
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
char buffer[0xFF];
|
char buffer[0xFF] = { 0 };
|
||||||
|
|
||||||
// initialize WinINet
|
// initialize WinINet
|
||||||
HINTERNET hInternet = InternetOpenA("sm64coopdx", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
|
HINTERNET hInternet = InternetOpenA("sm64coopdx", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
|
||||||
|
|
@ -92,7 +102,6 @@ void get_version_remote(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer[bytesRead] = '\0';
|
buffer[bytesRead] = '\0';
|
||||||
snprintf(sRemoteVersion, 8, "%s", buffer);
|
|
||||||
|
|
||||||
// close handles
|
// close handles
|
||||||
InternetCloseHandle(hUrl);
|
InternetCloseHandle(hUrl);
|
||||||
|
|
@ -136,7 +145,7 @@ void check_for_updates(void) {
|
||||||
LOADING_SCREEN_MUTEX(loading_screen_set_segment_text("Checking For Updates"));
|
LOADING_SCREEN_MUTEX(loading_screen_set_segment_text("Checking For Updates"));
|
||||||
|
|
||||||
get_version_remote();
|
get_version_remote();
|
||||||
if (sRemoteVersion[0] != '\0' && strcmp(sRemoteVersion, get_version())) {
|
if (sRemoteVersion[0] == 'v' && strcmp(sRemoteVersion, get_version())) {
|
||||||
snprintf(
|
snprintf(
|
||||||
sVersionUpdateTextBuffer, 256,
|
sVersionUpdateTextBuffer, 256,
|
||||||
"\\#ffffa0\\%s\n\\#dcdcdc\\%s: %s\n%s: %s",
|
"\\#ffffa0\\%s\n\\#dcdcdc\\%s: %s\n%s: %s",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue