From ecd511b7f05629ff09765cd397ad2e15a69854de Mon Sep 17 00:00:00 2001 From: Yauhen Pahrabniak Date: Tue, 6 Aug 2024 14:55:49 +0200 Subject: [PATCH] Merge Simplify game build handling + ros fix (mr-370) This reverts commit 8986403bf530411e5a41761f308354e8932389c9. --- code/client/launcher/StdInc.h | 45 -- code/client/launcher/premake5.lua | 111 ++--- code/client/shared/CrossBuildRuntime.h | 46 -- .../rage-scripting-five/src/TableBuilder.cpp | 14 +- .../ros-patches-five/src/ros/Entitlements.cpp | 439 +++--------------- code/premake5.lua | 20 +- code/premake5_builds.lua | 24 + code/tools/ci/psm1/cfxVersions.psm1 | 1 + 8 files changed, 156 insertions(+), 544 deletions(-) create mode 100644 code/premake5_builds.lua diff --git a/code/client/launcher/StdInc.h b/code/client/launcher/StdInc.h index c864d318ae..baa48849a0 100644 --- a/code/client/launcher/StdInc.h +++ b/code/client/launcher/StdInc.h @@ -103,51 +103,6 @@ bool CheckFileOutdatedWithUI(const wchar_t* fileName, const std::vector #include -#ifdef GTA_FIVE -#define GAME_BUILDS \ - (3258) \ - (3095) \ - (2944) \ - (2802) \ - (2699) \ - (2612) \ - (2545) \ - (2372) \ - (2189) \ - (2060) \ - (1604) -#elif defined(IS_RDR3) -#define GAME_BUILDS \ - (1491) \ - (1436) \ - (1355) \ - (1311) -#elif defined(GTA_NY) -#define GAME_BUILDS \ - (43) -#else -#define GAME_BUILDS \ - (0) -#endif - namespace xbr { // @@ -136,25 +109,6 @@ inline std::string_view GetCurrentGameBuildString() #endif } -#define EXPAND2(_, __, x) \ - inline bool BOOST_PP_CAT(Is, x)() \ - { \ - static bool retval; \ - static bool inited = false; \ - \ - if (!inited) \ - { \ - retval = xbr::GetGameBuild() == x; \ - inited = true; \ - } \ - \ - return retval; \ - } - -BOOST_PP_SEQ_FOR_EACH(EXPAND2, , GAME_BUILDS) - -#undef EXPAND2 - namespace xbr { template diff --git a/code/components/rage-scripting-five/src/TableBuilder.cpp b/code/components/rage-scripting-five/src/TableBuilder.cpp index 57456decf0..2e89924da2 100644 --- a/code/components/rage-scripting-five/src/TableBuilder.cpp +++ b/code/components/rage-scripting-five/src/TableBuilder.cpp @@ -192,31 +192,31 @@ static void DoMapping() } } - if (Is1604()) + if (xbr::IsGameBuild<1604>()) { assert(maxVersion == 19); } - else if (Is2060()) + else if (xbr::IsGameBuild<2060>()) { assert(maxVersion == 22); } - else if (Is2189()) + else if (xbr::IsGameBuild<2189>()) { assert(maxVersion == 23); } - else if (Is2372()) + else if (xbr::IsGameBuild<2372>()) { assert(maxVersion == 24); } - else if (Is2545() || Is2612() || Is2699()) + else if (xbr::IsGameBuild<2545>() || xbr::IsGameBuild<2612>() || xbr::IsGameBuild<2699>()) { assert(maxVersion == 25); } - else if (Is2802()) + else if (xbr::IsGameBuild<2802>()) { assert(maxVersion == 26); } - else if (Is2944() || Is3095() || Is3258()) + else if (xbr::IsGameBuildOrGreater<2944>()) { assert(maxVersion == 27); } diff --git a/code/components/ros-patches-five/src/ros/Entitlements.cpp b/code/components/ros-patches-five/src/ros/Entitlements.cpp index 7058cc05f9..13c3679362 100644 --- a/code/components/ros-patches-five/src/ros/Entitlements.cpp +++ b/code/components/ros-patches-five/src/ros/Entitlements.cpp @@ -25,6 +25,45 @@ #include #include "CnlEndpoint.h" +#include +#include +#include +#include + +#include +#include + +#include +#include + +struct BuildData +{ + std::string version; + size_t size; + int build; + std::string sha256; +}; + +std::unordered_map buildInfoRDR3 = { + { 1491, { "1.0.1491.50", 89562608, 89, "b56c9548f670654a9b73bf25def3cd73af12e269f6e47dba28a34079adaf465e" } }, + { 1436, { "1.0.1436.31", 89104336, 84, "1ed4b36caad567acbed0cc3b3c917cb46843e82a88097cc8015efadeeb88b097" } }, + { 1355, { "1.0.1355.18", 84664448, 80, "e80698b7f53395912d34bbbf15ac852b452126e7315b3a5115a6d9a30ad33d4c" } }, + { 1311, { "1.0.1311.20", 91439232, 79, "2fa69ba127e8c43b06bbec8e65a5fb94359194d961e8067466ca9c7fb6ffba90" } }, +}; + +std::unordered_map buildInfoGTA5 = { + { 3258, { "1.0.3258.0", 56066032, 104, "9ec3afccec172a55712bede2dd41d2c330b6d803f9b61b723c8914616ef25aea" } }, + { 3095, { "1.0.3095.0", 49634800, 103, "4c663c738e184ea60b3c3208147c3815605d98d1802ec08107b2c22ac5f2c46d" } }, + { 2944, { "1.0.2944.0", 49828848, 101, "eb0125ab36004ccdba7bfa918dee37035fb9e23448b850256fd6141ffe194466" } }, + { 2802, { "1.0.2802.0", 46709592, 98, "3af30164562e302f249c32b5cf4159793ee2c408749ee6cdea8adafbfc466c03" } }, + { 2699, { "1.0.2699.0", 61111680, 96, "7dc4a3a7516522e4a4b5869f2b09053da6b6829ab333ca0aa14a43aa45fd1e17" } }, + { 2612, { "1.0.2612.0", 60351952, 95, "06b59a02747c3d9f74c6c3621756387f4d85b148a882f4a6735a03383875c1f9" } }, + { 2545, { "1.0.2545.0", 59988376, 94, "964a8c25af4f622aedcd0de13717d261a07ccfcc734f5885bcfd5f173330cd06" } }, + { 2372, { "1.0.2372.0", 59716912, 92, "7e9009bce1aa47b4fc0e216c8d11ec8aaae2a83ba8140463f6f38b98a8a1492e" } }, + { 2189, { "1.0.2189.0", 63124096, 88, "3f83e88b7ac80b4cf4a1f60a8ac8241b1c6c7235b897db315778c2f31a98cdeb" } }, + { 2060, { "1.0.2060.0", 60589184, 83, "b21d443583b432ee4333bcd1179f4336f63071d90d55b6177c7588b21dbf61f0" } }, + { 1604, { "1.0.1604.1", 72484280, 80, "f5912107843d200a91c7c59e8cf6f504acfbd0a527cc69558b3710a6ef8c9c33" } }, +}; using json = nlohmann::json; @@ -35,9 +74,6 @@ extern std::string g_entitlementSource; bool LoadOwnershipTicket(); std::string GetRockstarTicketXml(); -#include -#include - std::string GetFilePath(const std::string& str) { PWSTR appDataPath; @@ -55,9 +91,6 @@ std::string GetFilePath(const std::string& str) return ""; } -#include - -#include std::string GetOwnershipPath(); @@ -156,12 +189,6 @@ std::string GetEntitlementBlock(uint64_t accountId, const std::string& machineHa return outStr; } -#include -#include - -#include -#include - class LambdaHttpHandler : public net::HttpHandler { public: @@ -691,330 +718,39 @@ mapper->AddGameService("ugc.asmx/Publish", [](const std::string& body) { auto postData = ParsePOSTString(body); + std::unordered_map buildInfo{}; + std::string gameExe; + if (postData["branchAccessToken"].find("RDR2") != std::string::npos) { - std::stringstream rss; - rss << ""; - - auto rs = rss.str(); - rs = ""; - - if (xbr::IsGameBuild<1491>()) - { - return fmt::sprintf(R"( - - - 1 - - - - RDR2.exe - b56c9548f670654a9b73bf25def3cd73af12e269f6e47dba28a34079adaf465e - - - - -%s - - false - -)", - rs); - } - else if (xbr::IsGameBuild<1436>()) - { - return fmt::sprintf(R"( - - - 1 - - - - RDR2.exe - 1ed4b36caad567acbed0cc3b3c917cb46843e82a88097cc8015efadeeb88b097 - - - - -%s - - false - -)", - rs); - } - else if (xbr::IsGameBuild<1355>()) - { - return fmt::sprintf(R"( - - - 1 - - - - RDR2.exe - e80698b7f53395912d34bbbf15ac852b452126e7315b3a5115a6d9a30ad33d4c - - - - -%s - - false - -)", rs); - } - else - { - return fmt::sprintf(R"( - - - 1 - - - - RDR2.exe - 2fa69ba127e8c43b06bbec8e65a5fb94359194d961e8067466ca9c7fb6ffba90 - - - - -%s - - false - -)", rs); - } + buildInfo = buildInfoRDR3; + gameExe = "RDR2.exe"; } else if (postData["branchAccessToken"].find("GTA5") != std::string::npos) { - if (xbr::IsGameBuild<3258>()) - { - return fmt::sprintf(R"( - - - 1 - - - - GTA5.exe - 9ec3afccec172a55712bede2dd41d2c330b6d803f9b61b723c8914616ef25aea - - - - - - false - -)"); - } - else if (xbr::IsGameBuild<3095>()) - { - return fmt::sprintf(R"( - - - 1 - - - - GTA5.exe - 4c663c738e184ea60b3c3208147c3815605d98d1802ec08107b2c22ac5f2c46d - - - - - - false - -)"); - } - else if (xbr::IsGameBuild<2944>()) - { - return fmt::sprintf(R"( - - - 1 - - - - GTA5.exe - eb0125ab36004ccdba7bfa918dee37035fb9e23448b850256fd6141ffe194466 - - - - - - false - -)"); - } - else if (xbr::IsGameBuild<2802>()) - { - return fmt::sprintf(R"( - - - 1 - - - - GTA5.exe - 3af30164562e302f249c32b5cf4159793ee2c408749ee6cdea8adafbfc466c03 - - - - - - false - -)"); - } - else if (xbr::IsGameBuild<2699>()) - { - return fmt::sprintf(R"( - - - 1 - - - - GTA5.exe - 7dc4a3a7516522e4a4b5869f2b09053da6b6829ab333ca0aa14a43aa45fd1e17 - - - - - - false - -)"); - } - else if (xbr::IsGameBuild<2612>()) - { - return fmt::sprintf(R"( - - - 1 - - - - GTA5.exe - 06b59a02747c3d9f74c6c3621756387f4d85b148a882f4a6735a03383875c1f9 - - - - - - false - -)"); - } - else if (xbr::IsGameBuild<2545>()) - { - return fmt::sprintf(R"( - - - 1 - - - - GTA5.exe - 964a8c25af4f622aedcd0de13717d261a07ccfcc734f5885bcfd5f173330cd06 - - - - - - false - -)"); - } - else if (xbr::IsGameBuild<2372>()) - { - return fmt::sprintf(R"( - - - 1 - - - - GTA5.exe - 7e9009bce1aa47b4fc0e216c8d11ec8aaae2a83ba8140463f6f38b98a8a1492e - - - - - - false - -)"); - } - else if (xbr::IsGameBuild<2189>()) - { - return fmt::sprintf(R"( - - - 1 - - - - GTA5.exe - 3f83e88b7ac80b4cf4a1f60a8ac8241b1c6c7235b897db315778c2f31a98cdeb - - - - - - false - -)"); - } - else if (xbr::IsGameBuild<2060>()) - { - return fmt::sprintf(R"( - - - 1 - - - - GTA5.exe - b21d443583b432ee4333bcd1179f4336f63071d90d55b6177c7588b21dbf61f0 - - - - - - false - -)"); - } - else - { - return fmt::sprintf(R"( + buildInfo = buildInfoGTA5; + gameExe = "GTA5.exe"; + } + + if (const auto& info = buildInfo.find(xbr::GetGameBuild()); info != buildInfo.end()) + { + return fmt::sprintf(R"( 1 - + - - GTA5.exe - f5912107843d200a91c7c59e8cf6f504acfbd0a527cc69558b3710a6ef8c9c33 + + %s + %s - + false -)"); - } +)", info->second.build, info->second.version, info->second.size, gameExe, info->second.sha256, info->second.sha256, info->second.size); } return std::string{ R"( @@ -1078,27 +814,6 @@ mapper->AddGameService("ugc.asmx/Publish", [](const std::string& body) mapper->AddGameService("app.asmx/GetApps", [](const std::string& body) { - static std::map fiveBuildsToVersions{ - { 1604, 80 }, - { 2060, 83 }, - { 2189, 88 }, - { 2372, 92 }, - { 2545, 94 }, - { 2612, 95 }, - { 2699, 96 }, - { 2802, 98 }, - { 2944, 101 }, - { 3095, 103 }, - { 3258, 104 }, - }; - - static std::map rdrBuildsToVersions{ - { 1311, 79 }, - { 1355, 80 }, - { 1436, 84 }, - { 1491, 89 }, - }; - return fmt::sprintf(R"( 1 @@ -1172,43 +887,7 @@ mapper->AddGameService("ugc.asmx/Publish", [](const std::string& body) )", - fiveBuildsToVersions[xbr::GetGameBuild()], - rdrBuildsToVersions[xbr::GetGameBuild()]); + buildInfoGTA5[xbr::GetGameBuild()].build, + buildInfoRDR3[xbr::GetGameBuild()].build); }); - - - /*mapper->AddGameService("Telemetry.asmx/SubmitCompressed", [](const std::string& body) - { - size_t dataStart = body.find("data="); - - // decompress the json buffer - std::vector tempBytes(65535); - - size_t destLength = tempBytes.size(); - - { - z_stream stream; - int err; - - stream.next_in = (z_const Bytef *)body.c_str() + dataStart; - stream.avail_in = (uInt)body.length() - dataStart; - - stream.next_out = &tempBytes[0]; - stream.avail_out = (uInt)destLength; - - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - - err = inflateInit2(&stream, -15); - if (err = Z_OK) - { - err = inflate(&stream, Z_FINISH); - destLength = stream.total_out; - - err = inflateEnd(&stream); - } - } - - return "1"; - });*/ }); diff --git a/code/premake5.lua b/code/premake5.lua index 72a7aa43ed..de04e774b4 100644 --- a/code/premake5.lua +++ b/code/premake5.lua @@ -1,3 +1,5 @@ +local gameBuilds = require("premake5_builds") + -- to work around slow init times due to packagesrv.com being down premake.downloadModule = function() return false @@ -225,6 +227,18 @@ workspace "CitizenMP" defines "NDEBUG" optimize "Speed" + + local buildsDef = "GAME_BUILDS=" + local builds = gameBuilds[_OPTIONS["game"]] + if builds ~= nil then + for key, _ in pairs(builds) do + buildsDef = buildsDef .. "(" .. string.sub(key, string.len("game_") + 1) .. ")" + end + + filter 'language:C or language:C++' + defines(buildsDef) + end + filter {} if _OPTIONS["game"] == "ny" then @@ -247,9 +261,13 @@ workspace "CitizenMP" architecture 'x64' elseif _OPTIONS["game"] == "launcher" then defines "IS_LAUNCHER" - + filter 'language:C or language:C++ or language:C#' architecture 'x64' + defines(buildsDef .. "(0)") + else + filter 'language:C or language:C++' + defines(buildsDef .. "(0)") end filter { "system:windows", 'language:C or language:C++' } diff --git a/code/premake5_builds.lua b/code/premake5_builds.lua new file mode 100644 index 0000000000..a7a5279e62 --- /dev/null +++ b/code/premake5_builds.lua @@ -0,0 +1,24 @@ +return { + five = { + game_3258 = "3258_0", + game_3095 = "3095_0", + game_2944 = "2944_0", + game_2802 = "2802_0", + game_2699 = "2699_0", + game_2612 = "2612_1", + game_2545 = "2545_0", + game_2372 = "2372_0", + game_2189 = "2189_0", + game_2060 = "2060_2", + game_1604 = "1604_0", + }, + rdr3 = { + game_1491 = "1491_50", + game_1436 = "1436_31", + game_1355 = "1355_18", + game_1311 = "1311_20", + }, + ny = { + game_43 = "43_0", + } +} \ No newline at end of file diff --git a/code/tools/ci/psm1/cfxVersions.psm1 b/code/tools/ci/psm1/cfxVersions.psm1 index a0f751a9f6..74279e4275 100644 --- a/code/tools/ci/psm1/cfxVersions.psm1 +++ b/code/tools/ci/psm1/cfxVersions.psm1 @@ -71,6 +71,7 @@ function Get-CfxVersions { $LauncherPaths = @( "code/premake5.lua" + "code/premake5_builds.lua" "code/shared/" "code/tools/dbg/" "code/client/launcher/"