finally fix laptop build

This commit is contained in:
Till Wübbers
2025-03-16 01:01:29 +01:00
parent a0af22cea6
commit 442fd23a0b
3 changed files with 33 additions and 20 deletions

View File

@@ -25,6 +25,7 @@ add_subdirectory("${CMAKE_SOURCE_DIR}/dependency/minidef")
# Engine
file(GLOB_RECURSE sources_engine engine/*.cpp engine/*.h)
add_executable(PuzGameEngine ${sources_engine})
target_compile_definitions(PuzGameEngine PUBLIC "_AMD64_")
set_property(TARGET PuzGameEngine PROPERTY CXX_STANDARD 17)
target_include_directories(PuzGameEngine PUBLIC dependency/tracy/public/)

View File

@@ -1,3 +1,4 @@
#include "bx/filepath.h"
#include <cstdlib>
#include <cwchar>
#include <fstream>
@@ -14,9 +15,7 @@
#include "Shared.h"
#include "Window.h"
// #define VISUAL_STUDIO
#ifdef VISUAL_STUDIO
#ifdef _MSC_VER
constexpr const char* DLLPath = "PuzGame.dll";
constexpr const wchar_t* DLLWatch = L"PuzGame2.dll";
#else
@@ -180,40 +179,52 @@ bool ReloadDLL()
{
FreeLibrary(DevData.GameLib);
}
#ifdef VISUAL_STUDIO
if (!CopyFile("PuzGame2.dll", "PuzGame.dll", false))
{
printf("Failed to copy game DLL!\n");
return false;
}
char exePath[1024];
GetModuleFileName(nullptr, exePath, BX_COUNTOF(exePath));
bx::FilePath exeFilePath{exePath};
bx::FilePath exeDir{exeFilePath.getPath()};
bx::FilePath libPath = exeDir;
#ifdef _MSC_VER
libPath.join("PuzGame.dll");
#else
if (!CopyFile("cmake-build\\libPuzGame2.dll", "cmake-build\\libPuzGame.dll", false))
libPath.join("libPuzGame.dll");
#endif
bx::FilePath lib2Path = exeDir;
#ifdef _MSC_VER
lib2Path.join("PuzGame2.dll");
#else
lib2Path.join("libPuzGame2.dll");
#endif
if (!CopyFile(lib2Path.getCPtr(), libPath.getCPtr(), false))
{
printf("Failed to copy game DLL!\n");
DWORD err = GetLastError();
printf("[%lu] Failed to copy game DLL from %s to %s!\n", err, libPath.getCPtr(), lib2Path.getCPtr());
return false;
}
#endif
HMODULE gameLibReloaded = LoadLibraryEx(DLLPath, NULL, 0);
if (gameLibReloaded == NULL)
{
printf("Failed to load game DLL from %s!\n", DLLPath);
DWORD err = GetLastError();
printf("[%lu] Failed to load game DLL from %s!\n", err, DLLPath);
return false;
}
DevData.GameLib = gameLibReloaded;
#ifdef VISUAL_STUDIO
Startup StartupReloaded = (Startup)GetProcAddress(DevData.GameLib, "?Setup@Game@@YAXPEAX@Z");
#ifdef _MSC_VER
Startup StartupReloaded = (Startup)GetProcAddress(DevData.GameLib, "?Setup@Game@@YAXAEAUSharedData@@@Z");
#else
Startup StartupReloaded = (Startup)GetProcAddress(DevData.GameLib, "_ZN4Game5SetupER10SharedData");
#endif
if (StartupReloaded == NULL)
{
printf("Failed to load startup function from game DLL!\n");
DWORD err = GetLastError();
printf("[%lu] Failed to load startup function from game DLL!\n", err);
return false;
}
#ifdef VISUAL_STUDIO
#ifdef _MSC_VER
Update UpdateReloaded = (Update)GetProcAddress(DevData.GameLib, "?Update@Game@@YAXXZ");
#else
Update UpdateReloaded = (Update)GetProcAddress(DevData.GameLib, "_ZN4Game6UpdateEv");
@@ -224,7 +235,7 @@ bool ReloadDLL()
return false;
}
#ifdef VISUAL_STUDIO
#ifdef _MSC_VER
Shutdown ShutdownReloaded = (Shutdown)GetProcAddress(DevData.GameLib, "?Shutdown@Game@@YAXXZ");
#else
Shutdown ShutdownReloaded = (Shutdown)GetProcAddress(DevData.GameLib, "_ZN4Game8ShutdownEv");

View File

@@ -49,8 +49,9 @@ namespace Game
long fileSize = ftell(file);
fseek(file, 0, SEEK_SET);
void* rawMem = AllocateScratch(fileSize + 1);
const bgfx::Memory* mem = bgfx::makeRef(rawMem, fileSize + 1);
long fileSizeX = appendZero ? fileSize + 1 : fileSize;
void* rawMem = AllocateScratch(fileSizeX);
const bgfx::Memory* mem = bgfx::makeRef(rawMem, fileSizeX);
fread(mem->data, 1, fileSize, file);
if (appendZero)
{