diff --git a/CMakeLists.txt b/CMakeLists.txt index 153ab7ba0..bfc83a1bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,13 +2,11 @@ cmake_minimum_required(VERSION 3.7) include(CMake/out_of_tree.cmake) -set(PROJECT_VERSION 0.5.0) - -project(devilutionX - VERSION ${PROJECT_VERSION} +project(DevilutionX + VERSION 0.5.0 LANGUAGES C CXX) -list(APPEND CMAKE_MODULE_PATH "${devilutionX_SOURCE_DIR}/CMake") +list(APPEND CMAKE_MODULE_PATH "${DevilutionX_SOURCE_DIR}/CMake") if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Debug") @@ -212,7 +210,8 @@ add_executable(devilutionx MACOSX_BUNDLE ./Packaging/macOS/AppIcon.icns ./Packaging/resources/CharisSILB.ttf) -target_include_directories(devilution PUBLIC Source SourceS) +configure_file(SourceS/config.h.in config.h @ONLY) +target_include_directories(devilution PUBLIC Source SourceS ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(devilutionx PRIVATE SourceX 3rdParty/asio/include diff --git a/Source/init.cpp b/Source/init.cpp index efac211da..ef16a4eb3 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -3,6 +3,7 @@ #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" #include +#include DEVILUTION_BEGIN_NAMESPACE @@ -130,29 +131,8 @@ HANDLE init_test_access(char *mpq_path, char *mpq_name, char *reg_loc, int flags void init_get_file_info() { - DWORD dwLen; - void *pBlock; - unsigned int uBytes; - DWORD dwHandle; - VS_FIXEDFILEINFO *lpBuffer; - - if (GetModuleFileName(ghInst, diablo_exe_path, sizeof(diablo_exe_path))) { - dwLen = GetFileVersionInfoSize(diablo_exe_path, &dwHandle); - if (dwLen) { - pBlock = DiabloAllocPtr(dwLen); - if (GetFileVersionInfo(diablo_exe_path, 0, dwLen, pBlock)) { - if (VerQueryValue(pBlock, "\\", (LPVOID *)&lpBuffer, &uBytes)) - sprintf( - gszVersionNumber, - "version %d.%d.%d.%d", - lpBuffer->dwProductVersionMS >> 16, - lpBuffer->dwProductVersionMS & 0xFFFF, - lpBuffer->dwProductVersionLS >> 16, - lpBuffer->dwProductVersionLS & 0xFFFF); - } - mem_free_dbg(pBlock); - } - } + snprintf(gszProductName, MAX_PATH, "%s v%s", PROJECT_NAME, PROJECT_VERSION); + snprintf(gszVersionNumber, MAX_PATH, "version %s", PROJECT_VERSION); } LRESULT __stdcall MainWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) diff --git a/SourceS/config.h.in b/SourceS/config.h.in new file mode 100644 index 000000000..210efaad1 --- /dev/null +++ b/SourceS/config.h.in @@ -0,0 +1,4 @@ +#pragma once + +#define PROJECT_NAME "@PROJECT_NAME@" +#define PROJECT_VERSION "@PROJECT_VERSION@" diff --git a/SourceS/miniwin/misc.h b/SourceS/miniwin/misc.h index 8c5bc3140..db68dabc4 100644 --- a/SourceS/miniwin/misc.h +++ b/SourceS/miniwin/misc.h @@ -114,22 +114,6 @@ typedef struct tagSIZE { LONG cy; } SIZE; -typedef struct tagVS_FIXEDFILEINFO { - DWORD dwSignature; - DWORD dwStrucVersion; - DWORD dwFileVersionMS; - DWORD dwFileVersionLS; - DWORD dwProductVersionMS; - DWORD dwProductVersionLS; - DWORD dwFileFlagsMask; - DWORD dwFileFlags; - DWORD dwFileOS; - DWORD dwFileType; - DWORD dwFileSubtype; - DWORD dwFileDateMS; - DWORD dwFileDateLS; -} VS_FIXEDFILEINFO; - typedef struct tagMSG { HWND hwnd; UINT message; @@ -435,9 +419,6 @@ WINBOOL WINAPI GetDiskFreeSpaceA(LPCSTR lpRootPathName, LPDWORD lpSectorsPerClus LPDWORD lpNumberOfFreeClusters, LPDWORD lpTotalNumberOfClusters); DWORD WINAPI GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize); WINBOOL WINAPI GetComputerNameA(LPSTR lpBuffer, LPDWORD nSize); -DWORD GetFileVersionInfoSizeA(LPCSTR lptstrFilename, LPDWORD lpdwHandle); -BOOL GetFileVersionInfoA(LPCSTR lptstrFilename, DWORD dwHandle, DWORD dwLen, LPVOID lpData); -BOOL VerQueryValueA(LPCVOID pBlock, LPCSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen); WINBOOL WINAPI DeleteFileA(LPCSTR lpFileName); WINBOOL WINAPI CopyFileA(LPCSTR lpExistingFileName, LPCSTR lpNewFileName, WINBOOL bFailIfExists); HFILE WINAPI OpenFile(LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, UINT uStyle); diff --git a/SourceS/miniwin/misc_macro.h b/SourceS/miniwin/misc_macro.h index 12ba7c82c..1fd2c4aa4 100644 --- a/SourceS/miniwin/misc_macro.h +++ b/SourceS/miniwin/misc_macro.h @@ -118,9 +118,6 @@ #define GetDiskFreeSpace GetDiskFreeSpaceA #define GetModuleFileName GetModuleFileNameA #define GetComputerName GetComputerNameA -#define GetFileVersionInfoSize GetFileVersionInfoSizeA -#define GetFileVersionInfo GetFileVersionInfoA -#define VerQueryValue VerQueryValueA #define DeleteFile DeleteFileA #define CopyFile CopyFileA diff --git a/SourceX/miniwin/misc.cpp b/SourceX/miniwin/misc.cpp index 38b88c5da..5e0231484 100644 --- a/SourceX/miniwin/misc.cpp +++ b/SourceX/miniwin/misc.cpp @@ -147,39 +147,6 @@ WINBOOL GetComputerNameA(LPSTR lpBuffer, LPDWORD nSize) return true; } -DWORD GetFileVersionInfoSizeA(LPCSTR lptstrFilename, LPDWORD lpdwHandle) -{ - DUMMY(); - *lpdwHandle = 0; - - return 1532; -} - -BOOL GetFileVersionInfoA(LPCSTR lptstrFilename, DWORD dwHandle, DWORD dwLen, LPVOID lpData) -{ - DUMMY(); - *(int *)lpData = 16711836; // TODO use actual version from .rc - - return true; -} - -BOOL VerQueryValueA(LPCVOID pBlock, LPCSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen) -{ - DUMMY(); - static VS_FIXEDFILEINFO lpBuffer; - - // Set internal version, TODO use actual version from .rc - lpBuffer.dwProductVersionMS = 1; - lpBuffer.dwProductVersionMS <<= 16; - lpBuffer.dwProductVersionMS |= 0 & 0xFFFF; - lpBuffer.dwProductVersionLS = 9; - lpBuffer.dwProductVersionLS <<= 16; - lpBuffer.dwProductVersionLS |= 2 & 0xFFFF; - *lplpBuffer = (LPVOID *)&lpBuffer; - - return true; -} - DWORD GetCurrentDirectory(DWORD nBufferLength, LPTSTR lpBuffer) { char *base_path = SDL_GetBasePath();