From 9638ff9f07a0839237faee0c0dfb0c95f09014b3 Mon Sep 17 00:00:00 2001 From: William Roy Date: Sun, 22 Sep 2024 11:18:39 -0400 Subject: [PATCH 1/4] Fix case-sensitive headers The file systems on Windows are case-insensitive, but that's not the case if you compile on Linux using, for example, the MinGW cross-compiler. In particular, MinGW distributes such headers in lowercase. --- src/Resource.rc | 8 ++++---- src/STDInclude.hpp | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Resource.rc b/src/Resource.rc index fddc1f89..6abf780d 100644 --- a/src/Resource.rc +++ b/src/Resource.rc @@ -10,7 +10,7 @@ // // Generated from the TEXTINCLUDE 2 resource. // -#include "Windows.h" +#include "windows.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -27,13 +27,13 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // TEXTINCLUDE // -1 TEXTINCLUDE +1 TEXTINCLUDE BEGIN - "#include ""Windows.h""\r\n" + "#include ""windows.h""\r\n" "\0" END -2 TEXTINCLUDE +2 TEXTINCLUDE BEGIN "\r\n" "\0" diff --git a/src/STDInclude.hpp b/src/STDInclude.hpp index 0f88816d..2a80464b 100644 --- a/src/STDInclude.hpp +++ b/src/STDInclude.hpp @@ -7,19 +7,19 @@ #define _WINSOCK_DEPRECATED_NO_WARNINGS #define _USE_MATH_DEFINES -#include -#include -#include +#include +#include +#include #include #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include #include #include From b620c5c987c749c16b686b2004d35159619274d9 Mon Sep 17 00:00:00 2001 From: mxve <68632137+mxve@users.noreply.github.com> Date: Sun, 22 Sep 2024 18:21:08 +0200 Subject: [PATCH 2/4] add Content-Type application/json and allow status 304 --- src/Utils/WebIO.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Utils/WebIO.cpp b/src/Utils/WebIO.cpp index 852971c4..0cfa9ab3 100644 --- a/src/Utils/WebIO.cpp +++ b/src/Utils/WebIO.cpp @@ -259,7 +259,7 @@ namespace Utils if (success) *success = false; if (!this->openConnection()) return {}; - static const char* acceptTypes[] = { "application/x-www-form-urlencoded", nullptr }; + static const char* acceptTypes[] = { "application/x-www-form-urlencoded", "application/json", nullptr }; DWORD dwFlag = INTERNET_FLAG_RELOAD | (this->isSecuredConnection() ? INTERNET_FLAG_SECURE : 0); @@ -298,7 +298,7 @@ namespace Utils DWORD statusCode = 404; DWORD length = sizeof(statusCode); - if (HttpQueryInfoA(this->hFile_, HTTP_QUERY_FLAG_NUMBER | HTTP_QUERY_STATUS_CODE, &statusCode, &length, nullptr) == FALSE || (statusCode != 200 && statusCode != 201)) + if (HttpQueryInfoA(this->hFile_, HTTP_QUERY_FLAG_NUMBER | HTTP_QUERY_STATUS_CODE, &statusCode, &length, nullptr) == FALSE || (statusCode != 200 && statusCode != 201 && statusCode != 304)) { this->closeConnection(); return {}; From 24d3d294a89b7f60093b5b4cdded58d31f82c96a Mon Sep 17 00:00:00 2001 From: mxve <68632137+mxve@users.noreply.github.com> Date: Sun, 22 Sep 2024 18:58:08 +0200 Subject: [PATCH 3/4] use REVISION_STR instead of .iw4xrevision file --- src/Components/Modules/Updater.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/Components/Modules/Updater.cpp b/src/Components/Modules/Updater.cpp index 134a74b7..711d4cac 100644 --- a/src/Components/Modules/Updater.cpp +++ b/src/Components/Modules/Updater.cpp @@ -2,6 +2,7 @@ #include "Updater.hpp" #include "Scheduler.hpp" +#include "version.hpp" #include @@ -13,21 +14,11 @@ namespace Components { const Game::dvar_t* cl_updateAvailable; - // If they use the alterware-launcher once to install they will have this file - // If they don't, what are they waiting for? - constexpr auto* REVISION_FILE = ".iw4xrevision"; constexpr auto* GITHUB_REMOTE_URL = "https://api.github.com/repos/iw4x/iw4x-client/releases/latest"; constexpr auto* INSTALL_GUIDE_REMOTE_URL = "https://forum.alterware.dev/t/how-to-install-the-alterware-launcher/56"; void CheckForUpdate() { - std::string revision; - if (!Utils::IO::ReadFile(REVISION_FILE, &revision) || revision.empty()) - { - Logger::Print("{} does not exist. Notifying the user an update is available\n", REVISION_FILE); - Game::Dvar_SetBool(cl_updateAvailable, true); - } - const auto result = Utils::WebIO("IW4x", GITHUB_REMOTE_URL).setTimeout(5000)->get(); if (result.empty()) { @@ -52,8 +43,8 @@ namespace Components return; } - const auto* tag = doc["tag_name"].GetString(); - if (revision != tag) + const std::string tag = doc["tag_name"].GetString(); + if (REVISION_STR != tag) { // A new version came out! Game::Dvar_SetBool(cl_updateAvailable, true); From c324268cca224f904b967bb211ea91dd74174dd6 Mon Sep 17 00:00:00 2001 From: mxve <68632137+mxve@users.noreply.github.com> Date: Sun, 22 Sep 2024 22:22:19 +0200 Subject: [PATCH 4/4] Unify versioning --- src/Components/Modules/Exception.cpp | 2 +- src/Components/Modules/Singleton.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Components/Modules/Exception.cpp b/src/Components/Modules/Exception.cpp index 0bb0db17..b8e3f366 100644 --- a/src/Components/Modules/Exception.cpp +++ b/src/Components/Modules/Exception.cpp @@ -136,7 +136,7 @@ namespace Components // Combine with queued MinidumpsFolder char filename[MAX_PATH]{}; CreateDirectoryA("minidumps", nullptr); - PathCombineA(filename, "minidumps\\", Utils::String::VA("%s-" VERSION "-%s.dmp", exeFileName, filenameFriendlyTime)); + PathCombineA(filename, "minidumps\\", Utils::String::VA("%s-" REVISION_STR "-%s.dmp", exeFileName, filenameFriendlyTime)); constexpr auto fileShare = FILE_SHARE_READ | FILE_SHARE_WRITE; HANDLE hFile = CreateFileA(filename, GENERIC_WRITE | GENERIC_READ, fileShare, nullptr, (fileShare & FILE_SHARE_WRITE) > 0 ? OPEN_ALWAYS : OPEN_EXISTING, NULL, nullptr); diff --git a/src/Components/Modules/Singleton.cpp b/src/Components/Modules/Singleton.cpp index 60c7e520..9886ca60 100644 --- a/src/Components/Modules/Singleton.cpp +++ b/src/Components/Modules/Singleton.cpp @@ -27,11 +27,10 @@ namespace Components { if (Flags::HasFlag("version")) { - printf("%s", "IW4x " VERSION " (built " __DATE__ " " __TIME__ ")\n"); #ifdef EXPERIMENTAL_BUILD - printf("Revision: %i - develop\n", REVISION); + printf("%s", "IW4x " REVISION_STR "-develop (built " __DATE__ " " __TIME__ ")\n"); #else - printf("Revision: %i\n", REVISION); + printf("%s", "IW4x " REVISION_STR " (built " __DATE__ " " __TIME__ ")\n"); #endif ExitProcess(EXIT_SUCCESS);