diff options
author | GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> | 2022-04-27 22:56:13 +0200 |
---|---|---|
committer | GeckoEidechse <gecko.eidechse+git@pm.me> | 2022-04-27 23:02:33 +0200 |
commit | 04ac23d2040c807a4e90038ca3a30d461006bf99 (patch) | |
tree | 521f122657b55f08969227b8960f5b1989502f3e /NorthstarDedicatedTest | |
parent | f6dc6a51dd9769ea52f67e104816827cdb31466d (diff) | |
download | NorthstarLauncher-1.6.4-rc2.tar.gz NorthstarLauncher-1.6.4-rc2.zip |
Hardcode version number (#152)v1.7.0-rc1v1.7.0v1.6.4-rc2v1.6.4-rc1v1.6.41.6.X
* Hardcode version number
This way, we don't get the wrong version number when launching
Titanfall2.exe via `-northstar`
The hardcoded value should be overwritten by CI on release
Fixes #129
* Set Northstar version in separate header file
* Make `northstar_version` array a constant
* Fix formatting
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r-- | NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj | 1 | ||||
-rw-r--r-- | NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters | 3 | ||||
-rw-r--r-- | NorthstarDedicatedTest/ns_version.h | 7 | ||||
-rw-r--r-- | NorthstarDedicatedTest/version.cpp | 67 |
4 files changed, 25 insertions, 53 deletions
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj index e9a27ad9..1d065006 100644 --- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj +++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj @@ -116,6 +116,7 @@ <ClInclude Include="clientchathooks.h" /> <ClInclude Include="clientvideooverrides.h" /> <ClInclude Include="localchatwriter.h" /> + <ClInclude Include="ns_version.h" /> <ClInclude Include="plugins.h" /> <ClInclude Include="plugin_abi.h" /> <ClInclude Include="serverchathooks.h" /> diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters index 3cc20b58..c6815227 100644 --- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters +++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters @@ -1503,6 +1503,9 @@ <ClInclude Include="version.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="ns_version.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="dllmain.cpp"> diff --git a/NorthstarDedicatedTest/ns_version.h b/NorthstarDedicatedTest/ns_version.h new file mode 100644 index 00000000..d30594fb --- /dev/null +++ b/NorthstarDedicatedTest/ns_version.h @@ -0,0 +1,7 @@ +#pragma once +#ifndef NORTHSTAR_VERSION +// Turning off clang-format here so it doesn't mess with style as it needs to be this way for regex-ing with CI +// clang-format off +#define NORTHSTAR_VERSION 0,0,0,1 +// clang-format on +#endif diff --git a/NorthstarDedicatedTest/version.cpp b/NorthstarDedicatedTest/version.cpp index a0bcee20..3755e4c4 100644 --- a/NorthstarDedicatedTest/version.cpp +++ b/NorthstarDedicatedTest/version.cpp @@ -1,65 +1,26 @@ #include "version.h" #include "pch.h" +#include "ns_version.h" char version[16]; char NSUserAgent[32]; void InitialiseVersion() { - HRSRC hResInfo; - DWORD dwSize; - HGLOBAL hResData; - LPVOID pRes, pResCopy; - UINT uLen = 0; - VS_FIXEDFILEINFO* lpFfi = NULL; - HINSTANCE hInst = ::GetModuleHandle(NULL); + constexpr int northstar_version[4] {NORTHSTAR_VERSION}; - hResInfo = FindResourceW(hInst, MAKEINTRESOURCE(1), RT_VERSION); - if (hResInfo != NULL) + // We actually use the rightmost integer do determine whether or not we're a debug/dev build + // If it is set to 1, we are a dev build + // On github CI, we set this 1 to a 0 automatically as we replace the 0,0,0,1 with the real version number + if (northstar_version[3] == 1) { - dwSize = SizeofResource(hInst, hResInfo); - hResData = LoadResource(hInst, hResInfo); - if (hResData != NULL) - { - pRes = LockResource(hResData); - pResCopy = LocalAlloc(LMEM_FIXED, dwSize); - if (pResCopy != 0) - { - CopyMemory(pResCopy, pRes, dwSize); - VerQueryValueW(pResCopy, L"\\", (LPVOID*)&lpFfi, &uLen); - - DWORD dwFileVersionMS = lpFfi->dwFileVersionMS; - DWORD dwFileVersionLS = lpFfi->dwFileVersionLS; - - DWORD dwLeftMost = HIWORD(dwFileVersionMS); - DWORD dwSecondLeft = LOWORD(dwFileVersionMS); - DWORD dwSecondRight = HIWORD(dwFileVersionLS); - DWORD dwRightMost = LOWORD(dwFileVersionLS); - - // We actually use the rightmost integer do determine whether or not we're a debug/dev build - // If it is set to 1 (as in resources.rc), we are a dev build - // On github CI, we set this 1 to a 0 automatically as we replace the 0.0.0.1 with the real version number - if (dwRightMost == 1) - { - sprintf(version, "%d.%d.%d.%d+dev", dwLeftMost, dwSecondLeft, dwSecondRight, dwRightMost); - sprintf(NSUserAgent, "R2Northstar/%d.%d.%d+dev", dwLeftMost, dwSecondLeft, dwSecondRight); - } - else - { - sprintf(version, "%d.%d.%d.%d", dwLeftMost, dwSecondLeft, dwSecondRight, dwRightMost); - sprintf(NSUserAgent, "R2Northstar/%d.%d.%d", dwLeftMost, dwSecondLeft, dwSecondRight); - } - UnlockResource(hResData); - FreeResource(hResData); - LocalFree(pResCopy); - return; - } - UnlockResource(hResData); - FreeResource(hResData); - LocalFree(pResCopy); - } + sprintf(version, "%d.%d.%d.%d+dev", northstar_version[0], northstar_version[1], northstar_version[2], northstar_version[3]); + sprintf(NSUserAgent, "R2Northstar/%d.%d.%d+dev", northstar_version[0], northstar_version[1], northstar_version[2]); + } + else + { + sprintf(version, "%d.%d.%d.%d", northstar_version[0], northstar_version[1], northstar_version[2], northstar_version[3]); + sprintf(NSUserAgent, "R2Northstar/%d.%d.%d", northstar_version[0], northstar_version[1], northstar_version[2]); } - // Could not locate version info for whatever reason - spdlog::error("Failed to load version info:\n{}", std::system_category().message(GetLastError())); - sprintf(NSUserAgent, "R2Northstar/0.0.0"); + return; } |