diff --git a/2DFXDataGrabber/2DFXDataGrabber.vcxproj b/2DFXDataGrabber/2DFXDataGrabber.vcxproj index f361026..702178d 100644 --- a/2DFXDataGrabber/2DFXDataGrabber.vcxproj +++ b/2DFXDataGrabber/2DFXDataGrabber.vcxproj @@ -14,6 +14,7 @@ {8862820A-5A13-49D6-A4D1-0E44F1AA1C49} Win32Proj My2DFXDataGrabber + 8.1 @@ -25,7 +26,7 @@ Application false - v120 + v140 true MultiByte diff --git a/IIILodLights/IIILodLights.vcxproj b/IIILodLights/IIILodLights.vcxproj index 93326c8..fdc4990 100644 --- a/IIILodLights/IIILodLights.vcxproj +++ b/IIILodLights/IIILodLights.vcxproj @@ -14,6 +14,7 @@ {B42AC8DF-B9B8-4B39-852B-259C71EFDA35} Win32Proj IIILodLights + 8.1 @@ -25,7 +26,7 @@ DynamicLibrary false - v120 + v140 true MultiByte @@ -75,6 +76,10 @@ true true + + cd $(TargetDir) +del *.iobj + diff --git a/IIILodLights/dllmain.cpp b/IIILodLights/dllmain.cpp index 6286f0c..81e8144 100644 --- a/IIILodLights/dllmain.cpp +++ b/IIILodLights/dllmain.cpp @@ -124,8 +124,8 @@ void CLODLightManager::III::RegisterCustomCoronas() template void CExplosionAddModifiedExplosion() { - using printstr_hook = injector::function_hooker; - injector::make_static_hook([](printstr_hook::func_type AddExplosion, int a1, int a2, int eExplosionType, int a4, int a5) + using func_hook = injector::function_hooker; + injector::make_static_hook([](func_hook::func_type AddExplosion, int a1, int a2, int eExplosionType, int a4, int a5) { std::random_shuffle(ExplosionTypes.begin(), ExplosionTypes.end()); injector::MakeNOP(0x559FD3, 5, true); @@ -144,8 +144,8 @@ void CExplosionAddModifiedExplosion() template void CBulletTracesAddTrace() { - using printstr_hook = injector::function_hooker; - injector::make_static_hook([](printstr_hook::func_type AddTrace, CVector* start, CVector* end) + using func_hook = injector::function_hooker; + injector::make_static_hook([](func_hook::func_type AddTrace, CVector* start, CVector* end) { injector::MakeNOP(0x563B56, 5); // sub_50D140 injector::MakeNOP(0x563BBB, 5); // sub_510790 @@ -334,7 +334,7 @@ void CLODLightManager::III::ApplyMemoryPatches() CExplosionAddModifiedExplosion<(0x54CC04)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) //CExplosionAddModifiedExplosion<(0x55B743)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) molotov/grenade expl CExplosionAddModifiedExplosion<(0x55B7A9)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) - CExplosionAddModifiedExplosion<(0x564ADE)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) + //CExplosionAddModifiedExplosion<(0x564ADE)>(); // = 0x5591C0 + 0x0 -> call AddExplosion__10CExplosionFP7CEntityP7CEntity14eExplosionTypeRC7CVectorUi; CExplosion::AddExplosion((CEntity *,CEntity *,eExplosionType,CVector const &,uint)) barrels } if (bReplaceSmokeTrailWithBulletTrail) @@ -360,7 +360,7 @@ void CLODLightManager::III::LoadDatFile() if (FILE* hFile = CFileMgr::OpenFile(DataFilePath, "r")) { unsigned short nModel = 0xFFFF, nCurIndexForModel = 0; - pFileContent = new std::map; + pFileContent = new std::map; while (const char* pLine = CFileMgr::LoadLine(hFile)) { @@ -387,7 +387,7 @@ void CLODLightManager::III::LoadDatFile() } } - m_pLampposts = new std::vector; + m_pLampposts = new std::vector; CFileMgr::CloseFile(hFile); } @@ -446,23 +446,6 @@ void __declspec(naked) CLODLightManager::III::GenericIDEHook() //MessageBox(0, buffer, "0", 0); } } - if (bPreloadLODs) - { - if (modelID == 404 || modelID == 405 || modelID == 416 || modelID == 402 || modelID == 403) - { - if (IDEDrawDistance == 3000) - { - sprintf(sIDEDrawDistance, "%d", IDEDrawDistance); - tempptr = strstr(buffer + 10, sIDEDrawDistance); - - strncpy(Flags2, tempptr + 5, 15); - - strncpy(tempptr, "0 ", 5); - strncpy(tempptr + 6, Flags2, 15); - //MessageBox(0, buffer, "0", 0); - } - } - } } else { @@ -496,7 +479,7 @@ void __declspec(naked) CLODLightManager::III::IPLDataHook1() call eax mov eax, _EAX push ebp - mov EntityIII, ebp + mov EntityIII, ebp } VecEntities.push_back(*EntityIII); @@ -508,9 +491,15 @@ void __declspec(naked) CLODLightManager::III::IPLDataHook2() _asm { push ebp - mov EntityIII, ebp + mov EntityIII, ebp + } + if (bPreloadLODs) + { + if (EntityIII->m_nModelIndex == 404 || EntityIII->m_nModelIndex == 405 || EntityIII->m_nModelIndex == 416 || EntityIII->m_nModelIndex == 402 || EntityIII->m_nModelIndex == 403) + { + EntityIII->m_bIsVisible = 0; + } } - VecEntities.push_back(*EntityIII); _asm { @@ -589,7 +578,7 @@ BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD reason, LPVOID /*lpReserved*/) injector::MakeCALL(0x48C09F, CLODLightManager::III::Init); CIniReader iniReader(""); - if (bPreloadLODs = iniReader.ReadInteger("DistanceLimits", "PreloadLODs", 0) == 1) + if ((bPreloadLODs = iniReader.ReadInteger("DistanceLimits", "PreloadLODs", 0)) == 1) { /*injector::WriteMemory(0x591E0B, &nLevelPortland, true); injector::WriteMemory(0x591E16, &nLevelPortland, true); diff --git a/IVLodLights/IVLodLights.vcxproj b/IVLodLights/IVLodLights.vcxproj index ae86894..efb415f 100644 --- a/IVLodLights/IVLodLights.vcxproj +++ b/IVLodLights/IVLodLights.vcxproj @@ -14,6 +14,7 @@ {586D45F0-B4A6-4EEA-9AC5-15B2C2AAFE4D} Win32Proj IVLodLights + 8.1 @@ -25,7 +26,7 @@ DynamicLibrary false - v120 + v140 true MultiByte diff --git a/SALodLights/SALodLights.vcxproj b/SALodLights/SALodLights.vcxproj index 6a5417d..96ed064 100644 --- a/SALodLights/SALodLights.vcxproj +++ b/SALodLights/SALodLights.vcxproj @@ -14,6 +14,7 @@ {32E8A22B-F9D9-4A3C-B524-9632BEC56A51} Win32Proj SALodLights + 8.1 @@ -25,7 +26,7 @@ DynamicLibrary false - v120 + v140 true MultiByte diff --git a/SALodLights/dllmain.cpp b/SALodLights/dllmain.cpp index 3b93389..4a722e3 100644 --- a/SALodLights/dllmain.cpp +++ b/SALodLights/dllmain.cpp @@ -183,7 +183,7 @@ void CLODLightManager::SA::LoadDatFile() if (FILE* hFile = CFileMgr::OpenFile(DataFilePath, "r")) { unsigned short nModel = 0xFFFF, nCurIndexForModel = 0; - pFileContent = new std::map; + pFileContent = new std::map; while (const char* pLine = CFileMgr::LoadLine(hFile)) { @@ -210,7 +210,7 @@ void CLODLightManager::SA::LoadDatFile() } } - m_pLampposts = new std::vector; + m_pLampposts = new std::vector; m_bCatchLamppostsNow = true; CFileMgr::CloseFile(hFile); diff --git a/VCLodLights/VCLodLights.vcxproj b/VCLodLights/VCLodLights.vcxproj index 6d35e3b..913be50 100644 --- a/VCLodLights/VCLodLights.vcxproj +++ b/VCLodLights/VCLodLights.vcxproj @@ -14,6 +14,7 @@ {4304D8B7-2551-42BA-B62F-B898C42EABF2} Win32Proj VCLodLights + 8.1 @@ -25,7 +26,7 @@ DynamicLibrary false - v120 + v140 true MultiByte @@ -75,6 +76,10 @@ true true + + cd $(TargetDir) +del *.iobj + diff --git a/VCLodLights/dllmain.cpp b/VCLodLights/dllmain.cpp index 1b5c7c0..1995133 100644 --- a/VCLodLights/dllmain.cpp +++ b/VCLodLights/dllmain.cpp @@ -1,4 +1,5 @@ -#include "stdafx.h" +//#include "stdafx.h" +#include #include "..\includes\CLODLightManager.h" #include "SearchlightsVC.h" @@ -127,7 +128,7 @@ void RenderSirenParticles() injector::make_static_hook([](func_hook::func_type RegisterCorona, int id, char r, char g, char b, char alpha, RwV3D *pos, float radius, float farClp, char a9, char lensflare, char a11, char see_through_effect, char trace, float a14, char a15, float a16) { RegisterCorona(id, r, g, b, alpha, pos, radius, farClp, a9, lensflare, a11, see_through_effect, trace, a14, a15, a16); - CLODLightManager::VC::CShadowsStoreStaticShadow(id, 2, *(RwTexture **)0x978DB4, (CVector*)pos, 8.0f, 0.0f, 0.0f, -8.0f, 80, r != 0 ? 25 : 0, 0, b != 0 ? 25 : 0, 15.0f, 1.0f, farClp, false, 8.0f); + CLODLightManager::VC::CShadowsStoreStaticShadow(id, 2, *(RwTexture **)0x978DB4, (CVector*)pos, 8.0f, 0.0f, 0.0f, -8.0f, 80, r != 0 ? 25 : 0, g != 0 ? 25 : 0, b != 0 ? 25 : 0, 15.0f, 1.0f, farClp, false, 8.0f); return; }); } @@ -355,7 +356,7 @@ void CLODLightManager::VC::LoadDatFile() if (FILE* hFile = CFileMgr::OpenFile(DataFilePath, "r")) { unsigned short nModel = 0xFFFF, nCurIndexForModel = 0; - pFileContent = new std::map; + pFileContent = new std::map; while (const char* pLine = CFileMgr::LoadLine(hFile)) { @@ -382,7 +383,7 @@ void CLODLightManager::VC::LoadDatFile() } } - m_pLampposts = new std::vector; + m_pLampposts = new std::vector; CFileMgr::CloseFile(hFile); } @@ -545,6 +546,7 @@ void CLODLightManager::VC::Init() RegisterAllLampposts(); RegisterCustomCoronas(); } + ApplyMemoryPatches(); //delete pFileContent; @@ -566,7 +568,7 @@ BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD reason, LPVOID /*lpReserved*/) injector::MakeCALL(0x4A4D10, CLODLightManager::VC::Init); CIniReader iniReader(""); - if (bPreloadLODs = iniReader.ReadInteger("DistanceLimits", "PreloadLODs", 0) == 1) + if ((bPreloadLODs = iniReader.ReadInteger("DistanceLimits", "PreloadLODs", 0)) == 1) { injector::WriteMemory(0x4DE4A7, nLevelPortland, true); @@ -576,6 +578,8 @@ BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD reason, LPVOID /*lpReserved*/) { }); injector::WriteMemory(0x691538, 0x4DDDDD, true); //CFileLoader::LoadMapZones((char const *)) + + injector::WriteMemory(0x4C7946, 0xEB, true); //Lods in the interiors } } } diff --git a/includes/CLODLightManager.h b/includes/CLODLightManager.h index 63bccad..05531d4 100644 --- a/includes/CLODLightManager.h +++ b/includes/CLODLightManager.h @@ -88,8 +88,8 @@ class CLamppostInfo class CLODLightManager { private: - static std::vector* m_pLampposts; - static std::map* pFileContent; + static std::vector* m_pLampposts; + static std::map* pFileContent; static bool m_bCatchLamppostsNow; static bool IsModelALamppost(unsigned short nModel); @@ -122,7 +122,7 @@ class CLODLightManager::III : public CLODLightManager static char* CurrentTimeMinutes; static float** fCurrentFarClip; static char* DataFilePath; - static std::vector VecEntities; + static std::vector VecEntities; public: static void Init(); @@ -173,7 +173,7 @@ class CLODLightManager::VC : public CLODLightManager static char* CurrentTimeMinutes; static float** fCurrentFarClip; static char* DataFilePath; - static std::vector VecEntities; + static std::vector VecEntities; public: static void Init(); @@ -392,10 +392,10 @@ class CLODLightManager::EFLC : public CLODLightManager::IV static void RenderLODLights(); }; -std::map* CLODLightManager::pFileContent; -std::vector* CLODLightManager::m_pLampposts = nullptr; -std::vector CLODLightManager::VC::VecEntities; -std::vector CLODLightManager::III::VecEntities; +std::map* CLODLightManager::pFileContent; +std::vector* CLODLightManager::m_pLampposts = nullptr; +std::vector CLODLightManager::VC::VecEntities; +std::vector CLODLightManager::III::VecEntities; bool CLODLightManager::m_bCatchLamppostsNow = false; bool CLODLightManager::IsModelALamppost(unsigned short nModel) @@ -640,7 +640,7 @@ void CLODLightManager::IV::LoadDatFile() if (FILE* hFile = CFileMgr::OpenFile(DataFilePath, "r")) { DWORD nModel = 0xFFFFFFFF; unsigned short nCurIndexForModel = 0; - pFileContent = new std::map; + pFileContent = new std::map; while (const char* pLine = CFileMgr::LoadLine(hFile)) { @@ -668,7 +668,7 @@ void CLODLightManager::IV::LoadDatFile() } } - m_pLampposts = new std::vector; + m_pLampposts = new std::vector; m_bCatchLamppostsNow = true; CFileMgr::CloseFile(hFile); diff --git a/includes/injector/assembly.hpp b/includes/injector/assembly.hpp index 622f57e..9854a34 100644 --- a/includes/injector/assembly.hpp +++ b/includes/injector/assembly.hpp @@ -34,6 +34,7 @@ #endif // +#include #include "injector.hpp" namespace injector @@ -152,14 +153,14 @@ namespace injector template void MakeInline(FuncT func) { - static FuncT static_func = func; // Stores the func object - static_func = func; // + static std::unique_ptr static_func; + static_func.reset(new FuncT(std::move(func))); // Encapsulates the call to static_func struct Caps { void operator()(reg_pack& regs) - { static_func(regs); } + { (*static_func)(regs); } }; // Does the actual MakeInline