From e2568250ecc52b6ec286fef6faba55372d7f60b8 Mon Sep 17 00:00:00 2001 From: Lorenzo Ferrillo Date: Sun, 18 Feb 2024 15:59:32 +0100 Subject: [PATCH] C++ compliance, reallow NVR --- .../NewVegasReloaded.dll.manifest | 11 +++++++++ NewVegasReloaded/NewVegasReloaded.vcxproj | 24 +++++++++++++++++-- TESReloaded/Core/Hooks/NewVegas/FlyCam.cpp | 2 +- TESReloaded/Core/Hooks/NewVegas/Hooks.cpp | 10 ++++---- TESReloaded/Core/Hooks/NewVegas/Render.cpp | 20 ++++++++-------- TESReloaded/Core/Hooks/NewVegas/Render.h | 4 ++-- TESReloaded/Core/Hooks/NewVegas/Settings.cpp | 6 ++--- TESReloaded/Core/Hooks/NewVegas/Shadows.cpp | 2 +- TESReloaded/Core/RenderManager.cpp | 4 ---- TESReloaded/Core/ShadowManager.cpp | 2 +- TESReloaded/Framework/NewVegas/Defines.h | 2 +- TESReloaded/Framework/NewVegas/GameNi.h | 6 ++--- 12 files changed, 60 insertions(+), 33 deletions(-) create mode 100644 NewVegasReloaded/NewVegasReloaded.dll.manifest diff --git a/NewVegasReloaded/NewVegasReloaded.dll.manifest b/NewVegasReloaded/NewVegasReloaded.dll.manifest new file mode 100644 index 00000000..2d65863d --- /dev/null +++ b/NewVegasReloaded/NewVegasReloaded.dll.manifest @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/NewVegasReloaded/NewVegasReloaded.vcxproj b/NewVegasReloaded/NewVegasReloaded.vcxproj index 15c8fdfb..75f66f92 100644 --- a/NewVegasReloaded/NewVegasReloaded.vcxproj +++ b/NewVegasReloaded/NewVegasReloaded.vcxproj @@ -55,6 +55,7 @@ $(IncludePath) $(LibraryPath) $(SolutionDir)$(ProjectName)\$(Configuration)\ + true @@ -68,14 +69,22 @@ $(SolutionDir)TESReloaded\Core;%(AdditionalIncludeDirectories) $(SolutionDir)TESReloaded\Framework\NewVegas\Framework.h + stdcpp17 + stdc17 + true + MultiThreadedDLL Windows true false Exports.def - dxguid.lib;version.lib;$(SolutionDir)TESReloaded\Framework\Common\Lib\Nvidia\x86\nvapi.lib;$(SolutionDir)TESReloaded\Framework\Common\Lib\Bink\binkw32.lib;%(AdditionalDependencies) + dxguid.lib;version.lib;$(SolutionDir)TESReloaded\Framework\Common\Lib\Nvidia\x86\nvapi.lib;$(SolutionDir)TESReloaded\Framework\Common\Lib\Bink\binkw32.lib;$(SolutionDir)Configurator\target\release\Configurator.dll.lib;%(AdditionalDependencies) + + NewVegasReloaded + $(MSBuildProjectDirectory)/NewVegasReloaded.dll.manifest %(AdditionalManifestFiles) + @@ -91,6 +100,12 @@ $(SolutionDir)TESReloaded\Core;%(AdditionalIncludeDirectories) $(SolutionDir)TESReloaded\Framework\NewVegas\Framework.h + stdcpp20 + stdc17 + true + false + EditAndContinue + false Windows @@ -99,8 +114,13 @@ DebugFull false Exports.def - dxguid.lib;version.lib;$(SolutionDir)TESReloaded\Framework\Common\Lib\Nvidia\x86\nvapi.lib;$(SolutionDir)TESReloaded\Framework\Common\Lib\Bink\binkw32.lib;%(AdditionalDependencies) + dxguid.lib;version.lib;$(SolutionDir)TESReloaded\Framework\Common\Lib\Nvidia\x86\nvapi.lib;$(SolutionDir)TESReloaded\Framework\Common\Lib\Bink\binkw32.lib;$(SolutionDir)Configurator\target\release\Configurator.dll.lib;%(AdditionalDependencies) + + NewVegasReloaded + true + $(MSBuildProjectDirectory)/NewVegasReloaded.dll.manifest %(AdditionalManifestFiles) + diff --git a/TESReloaded/Core/Hooks/NewVegas/FlyCam.cpp b/TESReloaded/Core/Hooks/NewVegas/FlyCam.cpp index f9d80217..630f6d02 100644 --- a/TESReloaded/Core/Hooks/NewVegas/FlyCam.cpp +++ b/TESReloaded/Core/Hooks/NewVegas/FlyCam.cpp @@ -7,7 +7,7 @@ static float Scroll = 0.0f; void (__thiscall* UpdateFlyCam)(PlayerCharacter*) = (void (__thiscall*)(PlayerCharacter*))Hooks::UpdateFlyCam; void __fastcall UpdateFlyCamHook(PlayerCharacter* This, UInt32 edx) { - SettingsMainStruct::FlyCamStruct* FlyCam = &TheSettingManager->SettingsMain.FlyCam; + ffi::FlyCamStruct* FlyCam = &TheSettingManager->Config->FlyCam; float ScrollMultiplier = FlyCam->ScrollMultiplier; if (Global->OnKeyDown(FlyCam->KeyAdd)) FlyCam->ScrollMultiplier += FlyCam->StepValue; diff --git a/TESReloaded/Core/Hooks/NewVegas/Hooks.cpp b/TESReloaded/Core/Hooks/NewVegas/Hooks.cpp index e86cb1cc..6bc3ec31 100644 --- a/TESReloaded/Core/Hooks/NewVegas/Hooks.cpp +++ b/TESReloaded/Core/Hooks/NewVegas/Hooks.cpp @@ -2,7 +2,7 @@ void AttachHooks() { - SettingsMainStruct* SettingsMain = &TheSettingManager->SettingsMain; + ffi::MainStruct* SettingsMain = &TheSettingManager->Config->Main; DetourTransactionBegin(); DetourUpdateThread(GetCurrentThread()); @@ -32,7 +32,7 @@ void AttachHooks() { DetourAttach(&(PVOID&)ShowDetectorWindow, &ShowDetectorWindowHook); DetourAttach(&(PVOID&)LoadForm, &LoadFormHook); DetourAttach(&(PVOID&)GetWaterHeightLOD, &GetWaterHeightLODHook); - if (SettingsMain->FlyCam.Enabled) DetourAttach(&(PVOID&)UpdateFlyCam, &UpdateFlyCamHook); + if (TheSettingManager->Config->FlyCam.Enabled) DetourAttach(&(PVOID&)UpdateFlyCam, &UpdateFlyCamHook); DetourTransactionCommit(); @@ -73,14 +73,14 @@ void AttachHooks() { SafeWriteCall(Jumpers::MultiBoundWaterHeight::Fix2, (UInt32)MultiBoundWaterHeightFix); //} - if (TheSettingManager->SettingsMain.Main.ReplaceIntro) SafeWriteJump(Jumpers::SetTileShaderConstants::Hook, (UInt32)SetTileShaderConstantsHook); + if (TheSettingManager->Config->Main.ReplaceIntro) SafeWriteJump(Jumpers::SetTileShaderConstants::Hook, (UInt32)SetTileShaderConstantsHook); - if (TheSettingManager->SettingsMain.Main.RemovePrecipitations) { + if (TheSettingManager->Config->Main.RemovePrecipitations) { SafeWriteJump(0x0063AFC4, 0x0063AFD8); SafeWriteJump(0x0063A5CB, 0x0063A5DE); } - if (SettingsMain->FlyCam.Enabled) { + if (TheSettingManager->Config->FlyCam.Enabled) { SafeWriteJump(Jumpers::FlyCam::UpdateForwardFlyCamHook, (UInt32)UpdateForwardFlyCamHook); SafeWriteJump(Jumpers::FlyCam::UpdateBackwardFlyCamHook, (UInt32)UpdateBackwardFlyCamHook); SafeWriteJump(Jumpers::FlyCam::UpdateRightFlyCamHook, (UInt32)UpdateRightFlyCamHook); diff --git a/TESReloaded/Core/Hooks/NewVegas/Render.cpp b/TESReloaded/Core/Hooks/NewVegas/Render.cpp index ee83126c..46de5724 100644 --- a/TESReloaded/Core/Hooks/NewVegas/Render.cpp +++ b/TESReloaded/Core/Hooks/NewVegas/Render.cpp @@ -3,7 +3,7 @@ void (__thiscall* Render)(Main*, BSRenderedTexture*, int, int) = (void (__thiscall*)(Main*, BSRenderedTexture*, int, int))Hooks::Render; void __fastcall RenderHook(Main* This, UInt32 edx, BSRenderedTexture* RenderedTexture, int Arg2, int Arg3) { - SettingsMainStruct* SettingsMain = &TheSettingManager->SettingsMain; + ffi::Config* SettingsMain = TheSettingManager->Config; TheFrameRateManager->UpdatePerformance(); TheCameraManager->SetSceneGraph(); @@ -24,7 +24,7 @@ void __fastcall SetShadersHook(BSShader* This, UInt32 edx, UInt32 PassIndex) { if (VertexShader && PixelShader) { VertexShader->SetupShader(TheRenderManager->renderState->GetVertexShader()); PixelShader->SetupShader(TheRenderManager->renderState->GetPixelShader()); - if (TheSettingManager->SettingsMain.Develop.DebugMode && Global->OnKeyDown(0x17)) { + if (TheSettingManager->Config->Develop.DebugMode && Global->OnKeyDown(0x17)) { char Name[256]; sprintf(Name, "Pass %i %s, %s (%s %s)", PassIndex, Pointers::Functions::GetPassDescription(PassIndex), Geometry->m_pcName, VertexShader->ShaderName, PixelShader->ShaderName); if (VertexShader->ShaderHandle == VertexShader->ShaderHandleBackup) strcat(Name, " - Vertex: vanilla"); @@ -133,30 +133,30 @@ void __fastcall RenderReflectionsHook(WaterManager* This, UInt32 edx, NiCamera* } */ BSRenderedTexture** boh = (BSRenderedTexture**) 0x011C7C2C; /*BOH*/ - if (*boh && TheSettingManager->SettingsMain.Develop.DebugMode && Global->OnKeyDown(0x17)) { + if (*boh && TheSettingManager->Config->Develop.DebugMode && Global->OnKeyDown(0x17)) { D3DXSaveSurfaceToFileA(".\\Test\\011C7C2C.jpg", D3DXIFF_JPG, (*boh)->RenderedTexture->buffer->data->Surface, NULL, NULL); } boh = (BSRenderedTexture**) 0x011C7AD4; /*Relfections*/ - if (*boh && TheSettingManager->SettingsMain.Develop.DebugMode && Global->OnKeyDown(0x17)) { + if (*boh && TheSettingManager->Config->Develop.DebugMode && Global->OnKeyDown(0x17)) { D3DXSaveSurfaceToFileA(".\\Test\\011C7AD4.jpg", D3DXIFF_JPG, (*boh)->RenderedTexture->buffer->data->Surface, NULL, NULL); } boh = (BSRenderedTexture**) 0x011C7B68; /*Depth*/ - if (*boh && TheSettingManager->SettingsMain.Develop.DebugMode && Global->OnKeyDown(0x17)) { + if (*boh && TheSettingManager->Config->Develop.DebugMode && Global->OnKeyDown(0x17)) { D3DXSaveSurfaceToFileA(".\\Test\\011C7B68.jpg", D3DXIFF_JPG, (*boh)->RenderedTexture->buffer->data->Surface, NULL, NULL); } boh = (BSRenderedTexture**) 0x011C7B64; /*dispalcmeent*/ - if (*boh && TheSettingManager->SettingsMain.Develop.DebugMode && Global->OnKeyDown(0x17)) { + if (*boh && TheSettingManager->Config->Develop.DebugMode && Global->OnKeyDown(0x17)) { D3DXSaveSurfaceToFileA(".\\Test\\011C7B64.jpg", D3DXIFF_JPG, (*boh)->RenderedTexture->buffer->data->Surface, NULL, NULL); } boh = (BSRenderedTexture**) 0x011C7B44; - if (*boh && TheSettingManager->SettingsMain.Develop.DebugMode && Global->OnKeyDown(0x17)) { + if (*boh && TheSettingManager->Config->Develop.DebugMode && Global->OnKeyDown(0x17)) { D3DXSaveSurfaceToFileA(".\\Test\\011C7B44.jpg", D3DXIFF_JPG, (*boh)->RenderedTexture->buffer->data->Surface, NULL, NULL); } @@ -192,7 +192,7 @@ void __cdecl ProcessImageSpaceShadersHook(NiDX9Renderer* Renderer, BSRenderedTex static void RenderMainMenuMovie() { - if (TheSettingManager->SettingsMain.Main.ReplaceIntro && InterfaceManager->IsActive(Menu::MenuType::kMenuType_Main)) + if (TheSettingManager->Config->Main.ReplaceIntro && InterfaceManager->IsActive(Menu::MenuType::kMenuType_Main)) TheBinkManager->Render(MainMenuMovie); else TheBinkManager->Close(); @@ -245,8 +245,8 @@ float MultiBoundWaterHeightFix() { } -void* (__thiscall* ShowDetectorWindow)(DetectorWindow*, HWND, HINSTANCE, NiNode*, char*, int, int, int, int) = (void* (__thiscall*)(DetectorWindow*, HWND, HINSTANCE, NiNode*, char*, int, int, int, int))::Hooks::ShowDetectorWindow; -void* __fastcall ShowDetectorWindowHook(DetectorWindow* This, UInt32 edx, HWND Handle, HINSTANCE Instance, NiNode* RootNode, char* FormCaption, int X, int Y, int Width, int Height) { +void* (__thiscall* ShowDetectorWindow)(DetectorWindow*, HWND, HINSTANCE, NiNode*, const char*, int, int, int, int) = (void* (__thiscall*)(DetectorWindow*, HWND, HINSTANCE, NiNode*, const char*, int, int, int, int))::Hooks::ShowDetectorWindow; +void* __fastcall ShowDetectorWindowHook(DetectorWindow* This, UInt32 edx, HWND Handle, HINSTANCE Instance, NiNode* RootNode, const char* FormCaption, int X, int Y, int Width, int Height) { NiAVObject* Object = NULL; void* r = NULL; diff --git a/TESReloaded/Core/Hooks/NewVegas/Render.h b/TESReloaded/Core/Hooks/NewVegas/Render.h index 57d9db4c..e2da8ef9 100644 --- a/TESReloaded/Core/Hooks/NewVegas/Render.h +++ b/TESReloaded/Core/Hooks/NewVegas/Render.h @@ -26,8 +26,8 @@ float __fastcall GetWaterHeightLODHook(TESWorldSpace* This, UInt32 edx); extern void(__cdecl* ProcessImageSpaceShaders)(NiDX9Renderer*, BSRenderedTexture*, BSRenderedTexture*); void __cdecl ProcessImageSpaceShadersHook(NiDX9Renderer* Renderer, BSRenderedTexture* RenderedTexture1, BSRenderedTexture* RenderedTexture2); -extern void* (__thiscall* ShowDetectorWindow)(DetectorWindow*, HWND, HINSTANCE, NiNode*, char*, int, int, int, int); -void* __fastcall ShowDetectorWindowHook(DetectorWindow* This, UInt32 edx, HWND Handle, HINSTANCE Instance, NiNode* RootNode, char* FormCaption, int X, int Y, int Width, int Height); +extern void* (__thiscall* ShowDetectorWindow)(DetectorWindow*, HWND, HINSTANCE, NiNode*, const char*, int, int, int, int); +void* __fastcall ShowDetectorWindowHook(DetectorWindow* This, UInt32 edx, HWND Handle, HINSTANCE Instance, NiNode* RootNode, const char* FormCaption, int X, int Y, int Width, int Height); extern int (__thiscall* WaterManager_4E8EC0)(WaterManager*); int __fastcall WaterManager_4E8EC0Hook(WaterManager* This); diff --git a/TESReloaded/Core/Hooks/NewVegas/Settings.cpp b/TESReloaded/Core/Hooks/NewVegas/Settings.cpp index ea4cfa2d..f0dafbc4 100644 --- a/TESReloaded/Core/Hooks/NewVegas/Settings.cpp +++ b/TESReloaded/Core/Hooks/NewVegas/Settings.cpp @@ -9,11 +9,11 @@ bool __fastcall ReadSettingHook(INISettingCollection* This, UInt32 edx, GameSett Setting->iValue = 0; else if (!strcmp(Setting->Name, "bFull Screen:Display")) TheSettingManager->SetWindowedMode(Setting->iValue); - else if (!strcmp(Setting->Name, "SIntroSequence:General") && TheSettingManager->SettingsMain.Main.ReplaceIntro) + else if (!strcmp(Setting->Name, "SIntroSequence:General") && TheSettingManager->Config->Main.ReplaceIntro) Setting->pValue = (char*)IntroMovie; - else if (!strcmp(Setting->Name, "SMainMenuMovie:General") && TheSettingManager->SettingsMain.Main.ReplaceIntro) + else if (!strcmp(Setting->Name, "SMainMenuMovie:General") && TheSettingManager->Config->Main.ReplaceIntro) Setting->pValue = (char*)MainMenuMovie; - else if ((!strcmp(Setting->Name, "SMainMenuMusic:General") || !strcmp(Setting->Name, "STitleMusic:Loading")) && TheSettingManager->SettingsMain.Main.ReplaceIntro) + else if ((!strcmp(Setting->Name, "SMainMenuMusic:General") || !strcmp(Setting->Name, "STitleMusic:Loading")) && TheSettingManager->Config->Main.ReplaceIntro) Setting->pValue = (char*)MainMenuMusic; else if (!strcmp(Setting->Name, "bDoCanopyShadowPass:Display") || !strcmp(Setting->Name, "bDoActorShadows:Display") || !strcmp(Setting->Name, "iActorShadowCountExt:Display") || !strcmp(Setting->Name, "iActorShadowCountInt:Display")) Setting->iValue = 0; diff --git a/TESReloaded/Core/Hooks/NewVegas/Shadows.cpp b/TESReloaded/Core/Hooks/NewVegas/Shadows.cpp index e40167db..9cc76f90 100644 --- a/TESReloaded/Core/Hooks/NewVegas/Shadows.cpp +++ b/TESReloaded/Core/Hooks/NewVegas/Shadows.cpp @@ -13,7 +13,7 @@ __declspec(naked) void RenderShadowMapHook() { static void AddCastShadowFlag(TESObjectREFR* Ref, TESObjectLIGH* Light, NiPointLight* LightPoint) { - SettingsShadowStruct::InteriorsStruct* ShadowsInteriors = &TheSettingManager->SettingsShadows.Interiors; + ffi::ShadowsInteriorStruct* ShadowsInteriors = &TheSettingManager->Config->ShadowsInterior; if (Light->lightFlags & TESObjectLIGH::LightFlags::kLightFlags_CanCarry) { LightPoint->CastShadows = ShadowsInteriors->TorchesCastShadows; diff --git a/TESReloaded/Core/RenderManager.cpp b/TESReloaded/Core/RenderManager.cpp index 60e96e41..5516f8e3 100644 --- a/TESReloaded/Core/RenderManager.cpp +++ b/TESReloaded/Core/RenderManager.cpp @@ -331,10 +331,6 @@ void RenderManager::CheckAndTakeScreenShot(IDirect3DSurface9* RenderTarget){ if (Global->OnKeyDown(0x17) && TheSettingManager->Config->Develop.DebugMode) { char Filename[MAX_PATH]; char Filename2[MAX_PATH]; - char Filename3[MAX_PATH]; - char Filename4[MAX_PATH]; - char Filename5[MAX_PATH]; - char Filename6[MAX_PATH]; char Name[80]; time_t CurrentTime = time(NULL); diff --git a/TESReloaded/Core/ShadowManager.cpp b/TESReloaded/Core/ShadowManager.cpp index fca7df41..aac3e7ad 100644 --- a/TESReloaded/Core/ShadowManager.cpp +++ b/TESReloaded/Core/ShadowManager.cpp @@ -434,7 +434,7 @@ D3DXMATRIX ShadowManager::GetCascadeViewProj(ShadowMapTypeEnum ShadowMapType, ff float ar = h / w; - //Logger::Log("fov %f %f %f", WorldSceneGraph->cameraFOV, Player->GetFoV(false), Player->GetFoV(true)); + Logger::Log("fov %f %f %f", WorldSceneGraph->cameraFOV, Player->GetFoV(false), Player->GetFoV(true)); float fov = TheRenderManager->FOVData.z; float fovY = TheRenderManager->FOVData.w; diff --git a/TESReloaded/Framework/NewVegas/Defines.h b/TESReloaded/Framework/NewVegas/Defines.h index 53dbb1b3..ddc941b9 100644 --- a/TESReloaded/Framework/NewVegas/Defines.h +++ b/TESReloaded/Framework/NewVegas/Defines.h @@ -10,7 +10,7 @@ static const char* IntroMovie = "NVRGameStudios.bik"; static const char* MainMenuMovie = "\\Data\\Video\\NVRMainMenu.bik"; static const char* MainMenuMusic = "NVRMainMenu"; -static char* TitleMenu = "New Vegas Reloaded - Settings"; +static const char* TitleMenu = "New Vegas Reloaded - Settings"; // to review static const char* WeatherColorTypes[TESWeather::kNumColorTypes] = { "SkyUpper", "Fog", "CloudsLower", "Ambient", "Sunlight", "Sun", "Stars", "SkyLower", "Horizon", "CloudsUpper" }; diff --git a/TESReloaded/Framework/NewVegas/GameNi.h b/TESReloaded/Framework/NewVegas/GameNi.h index 4797e194..d2bf91a2 100644 --- a/TESReloaded/Framework/NewVegas/GameNi.h +++ b/TESReloaded/Framework/NewVegas/GameNi.h @@ -76,7 +76,7 @@ assert(sizeof(NiPoint2) == 0x008); class NiPoint3 { public: - float NiPoint3::operator * (const NiPoint3 pt) const { return x * pt.x + y * pt.y + z * pt.z; } + float operator * (const NiPoint3 pt) const { return x * pt.x + y * pt.y + z * pt.z; } void GetLookAt(NiPoint3* LookAt, NiPoint3* Rotation); @@ -99,14 +99,14 @@ assert(sizeof(NiVector4) == 0x010); class NiMatrix33 { public: - NiPoint3 NiMatrix33::operator * (const NiPoint3 pt) const { + NiPoint3 operator * (const NiPoint3 pt) const { return { data[0][0] * pt.x + data[0][1] * pt.y + data[0][2] * pt.z, data[1][0] * pt.x + data[1][1] * pt.y + data[1][2] * pt.z, data[2][0] * pt.x + data[2][1] * pt.y + data[2][2] * pt.z }; } - NiMatrix33 NiMatrix33::operator * (const NiMatrix33 mat) const { + NiMatrix33 operator * (const NiMatrix33 mat) const { NiMatrix33 prd; prd.data[0][0] =