aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKawe Mazidjatari <48657826+Mauler125@users.noreply.github.com>2022-05-05 15:12:45 +0200
committerGitHub <noreply@github.com>2022-05-05 15:12:45 +0200
commitf14a920802fb80dec0f87d94bf72363db7c2c27a (patch)
tree295af16d46eadab4f23f37edaaa3b3a1b454279b
parentb2f3001e1687332ea150c693d4e8cb6566ef5687 (diff)
parent6c8112a6c368dd36d21fd94689e9682bc3b012a5 (diff)
downloadNorthstarLauncher-f14a920802fb80dec0f87d94bf72363db7c2c27a.tar.gz
NorthstarLauncher-f14a920802fb80dec0f87d94bf72363db7c2c27a.zip
Merge branch 'main' into NetCon
-rw-r--r--LauncherInjector/resources.rc5
-rw-r--r--NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj1
-rw-r--r--NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters3
-rw-r--r--NorthstarDedicatedTest/dllmain.cpp4
-rw-r--r--NorthstarDedicatedTest/ns_version.h7
-rw-r--r--NorthstarDedicatedTest/version.cpp67
6 files changed, 32 insertions, 55 deletions
diff --git a/LauncherInjector/resources.rc b/LauncherInjector/resources.rc
index 99fcc41e..de16250b 100644
--- a/LauncherInjector/resources.rc
+++ b/LauncherInjector/resources.rc
@@ -1,6 +1,7 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource1.h"
+#include "../NorthstarDedicatedTest/ns_version.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
@@ -61,8 +62,8 @@ IDI_ICON1 ICON "ns_icon.ico"
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 0,0,0,1
- PRODUCTVERSION 0,0,0,1
+ FILEVERSION NORTHSTAR_VERSION
+ PRODUCTVERSION NORTHSTAR_VERSION
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
index b8860040..4151a7e5 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
@@ -122,6 +122,7 @@
<ClInclude Include="clientruihooks.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="net.h" />
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
index 22865847..19d60e62 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
@@ -1542,6 +1542,9 @@
<ClInclude Include="clientruihooks.h">
<Filter>Header Files\Client</Filter>
</ClInclude>
+ <ClInclude Include="ns_version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
diff --git a/NorthstarDedicatedTest/dllmain.cpp b/NorthstarDedicatedTest/dllmain.cpp
index 76293a89..733e2fd6 100644
--- a/NorthstarDedicatedTest/dllmain.cpp
+++ b/NorthstarDedicatedTest/dllmain.cpp
@@ -205,6 +205,10 @@ bool InitialiseNorthstar()
InitialiseLogging();
InstallInitialHooks();
CreateLogFiles();
+
+ // Write launcher version to log
+ spdlog::info("NorthstarLauncher version: {}", version);
+
InitialiseInterfaceCreationHooks();
AddDllLoadCallback("tier0.dll", InitialiseTier0GameUtilFunctions);
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;
}