diff --git a/code/components/font-renderer/src/GtaGameInterface.cpp b/code/components/font-renderer/src/GtaGameInterface.cpp index 4e89653de3..d17c954aed 100644 --- a/code/components/font-renderer/src/GtaGameInterface.cpp +++ b/code/components/font-renderer/src/GtaGameInterface.cpp @@ -15,7 +15,8 @@ #include #include #include -#include +#include +#include #include "memdbgon.h" @@ -453,27 +454,7 @@ static InitFunction initFunction([] () } else // (!inGame), i.e. menu { - static auto version = ([]() - { - FILE* f = _wfopen(MakeRelativeCitPath(L"citizen/release.txt").c_str(), L"r"); - int version = -1; - - if (f) - { - char ver[128]; - - fgets(ver, sizeof(ver), f); - fclose(f); - - version = atoi(ver); - } - else - { - version = 0; - } - - return version; - })(); + static auto version = cfx::GetPlatformRelease(); static auto updateChannelTag = ([]() -> std::wstring { diff --git a/code/components/ros-patches-five/src/AccountID.cpp b/code/components/ros-patches-five/src/AccountID.cpp index 2781489c24..fbbaa70d8d 100644 --- a/code/components/ros-patches-five/src/AccountID.cpp +++ b/code/components/ros-patches-five/src/AccountID.cpp @@ -36,6 +36,21 @@ #include "ROSErrors.h" #include +#include "CfxReleaseInfo.h" + +template +static auto PostAutoLogin(Ts&&... args) +{ + return cpr::Post( + cpr::Header{ + { "Content-Type", "application/json; charset=utf-8" }, + { "Accept", "application/json" }, + { "X-Requested-With", "XMLHttpRequest" } }, + cpr::UserAgent{ fmt::sprintf("CitizenFX/1 (rel. %d)") }, + std::forward(args)... + ); +} + static bool TryFindError(const std::string& errorString, std::string* outMessage) { if (auto it = g_rosErrors.find("Errors_" + errorString); it != g_rosErrors.end()) @@ -705,15 +720,10 @@ void ValidateEpic(int parentPid) j["tpaTokens"] = GetTpaTokens(); - r = cpr::Post( + r = PostAutoLogin( cpr::Url{ "https://rgl.rockstargames.com/api/launcher/autologinepic" }, - cpr::Header{ - { { "Content-Type", "application/json; charset=utf-8" }, - { "Accept", "application/json" }, - { "X-Requested-With", "XMLHttpRequest" } } }, cpr::Body{ - j.dump() }, - cpr::VerifySsl{ false }); + j.dump() }); if (r.error) { @@ -792,18 +802,14 @@ void ValidateEpic(int parentPid) { "version", 11 }, }); - r = cpr::Post( + r = PostAutoLogin( cpr::Url{ "https://rgl.rockstargames.com/api/launcher/bindepicaccount" }, cpr::Header{ { - { "Content-Type", "application/json; charset=utf-8" }, - { "Accept", "application/json" }, - { "X-Requested-With", "XMLHttpRequest" }, - { "Authorization", fmt::sprintf("SCAUTH val=\"%s\"", tick) }, + { "Authorization", fmt::sprintf("SCAUTH val=\"%s\"", tick) }, } }, cpr::Body{ - j.dump() }, - cpr::VerifySsl{ false }); + j.dump() }); if (r.error) { @@ -894,17 +900,11 @@ void ValidateSteam(int parentPid) j["tpaTokens"] = GetTpaTokens(); - r = cpr::Post( + r = PostAutoLogin( cpr::Url{ "https://rgl.rockstargames.com/api/launcher/autologinsteam" }, - cpr::Header{ - {"Content-Type", "application/json; charset=utf-8"}, - {"Accept", "application/json"}, - {"X-Requested-With", "XMLHttpRequest"} - }, cpr::Body{ j.dump() - }, - cpr::VerifySsl{ false }); + }); if (r.error) { @@ -973,18 +973,14 @@ void ValidateSteam(int parentPid) { "version", 11 }, }); - r = cpr::Post( + r = PostAutoLogin( cpr::Url{ "https://rgl.rockstargames.com/api/launcher/bindsteamaccount" }, cpr::Header{ - {"Content-Type", "application/json; charset=utf-8"}, - {"Accept", "application/json"}, - {"X-Requested-With", "XMLHttpRequest"}, {"Authorization", fmt::sprintf("SCAUTH val=\"%s\"", tick) }, }, cpr::Body{ j.dump() - }, - cpr::VerifySsl{ false }); + }); if (r.error) { diff --git a/code/shared/CfxReleaseInfo.h b/code/shared/CfxReleaseInfo.h new file mode 100644 index 0000000000..92c7dac8a4 --- /dev/null +++ b/code/shared/CfxReleaseInfo.h @@ -0,0 +1,33 @@ +#pragma once + +#ifndef IS_FXSERVER +namespace cfx +{ +inline auto GetPlatformRelease() +{ + static auto version = ([]() + { + FILE* f = _wfopen(MakeRelativeCitPath(L"citizen/release.txt").c_str(), L"r"); + int version = -1; + + if (f) + { + char ver[128]; + + fgets(ver, sizeof(ver), f); + fclose(f); + + version = atoi(ver); + } + else + { + version = 0; + } + + return version; + })(); + + return version; +} +} +#endif