diff --git a/2DFXDataGrabber/2DFXDataGrabber.cpp b/2DFXDataGrabber/2DFXDataGrabber.cpp index c13b68d..aaef8e5 100644 --- a/2DFXDataGrabber/2DFXDataGrabber.cpp +++ b/2DFXDataGrabber/2DFXDataGrabber.cpp @@ -399,19 +399,31 @@ int _tmain(int argc, _TCHAR* argv[]) line2.find("mtraffic4") != std::string::npos || line2.find("trafficlight1") != std::string::npos) { Size = 0.45f; - LodLights << R << " " << G << " " << B << " " << offsetX << " " << offsetY << " " << offsetZ << " " << std::fixed << std::setprecision(2) << Size << std::setprecision(-1) << endl; + LodLights << R << " " << G << " " << B << " " << offsetX << " " << offsetY << " " << offsetZ << " " << std::fixed << std::setprecision(2) << Size << std::setprecision(-1); PrevID = ID; continue; } - LodLights << R << " " << G << " " << B << " " << offsetX << " " << offsetY << " " << offsetZ << " " << std::fixed << std::setprecision(2) << Size << std::setprecision(-1) << endl; + LodLights << R << " " << G << " " << B << " " << offsetX << " " << offsetY << " " << offsetZ << " " << std::fixed << std::setprecision(2) << Size << std::setprecision(-1); PrevID = ID; } else { + std::transform(line2.begin(), line2.end(), line2.begin(), ::tolower); if (!(line2.find("mtraffic1") != std::string::npos || line2.find("mtraffic2") != std::string::npos || line2.find("mtraffic4") != std::string::npos || line2.find("trafficlight1") != std::string::npos)) - LodLights << R << " " << G << " " << B << " " << offsetX << " " << offsetY << " " << offsetZ << " " << std::fixed << std::setprecision(2) << Size << std::setprecision(-1) << endl; + LodLights << R << " " << G << " " << B << " " << offsetX << " " << offsetY << " " << offsetZ << " " << std::fixed << std::setprecision(2) << Size << std::setprecision(-1); + } + if (line2.find("lamppost1") != std::string::npos || line2.find("lamppost2") != std::string::npos || + line2.find("lamppost3") != std::string::npos || line2.find("sub_floodlite") != std::string::npos || + line2.find("mlamppost") != std::string::npos || line2.find("doublestreetlght1") != std::string::npos || + line2.find("bollardlight") != std::string::npos || line2.find("lampost_coast") != std::string::npos) + { + LodLights << " " << "0" << " " << "1" << endl; + } + else + { + LodLights << endl; } } } diff --git a/IIILodLights/SearchlightsIII.h b/IIILodLights/SearchlightsIII.h index 9c59e18..31e03dc 100644 --- a/IIILodLights/SearchlightsIII.h +++ b/IIILodLights/SearchlightsIII.h @@ -289,7 +289,7 @@ void CLODLightManager::III::RenderSearchLights() } } } while (nObjectPoolSize); - RenderHeliSearchLights(); + true ? RenderHeliSearchLights() : nullptr; RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, 1); RwRenderStateSet(rwRENDERSTATEZTESTENABLE, 1); RwRenderStateSet(rwRENDERSTATESRCBLEND, 5); diff --git a/IIILodLights/dllmain.cpp b/IIILodLights/dllmain.cpp index 3db1a81..4a3209d 100644 --- a/IIILodLights/dllmain.cpp +++ b/IIILodLights/dllmain.cpp @@ -242,6 +242,7 @@ void CLODLightManager::III::LoadDatFile() } else { + RenderSearchlightEffects = 0; bRenderLodLights = 0; } @@ -294,6 +295,23 @@ void __declspec(naked) CLODLightManager::III::GenericIDEHook() //MessageBox(0, buffer, "0", 0); } } + if (bPreloadLODs) + { + if (modelID == 404 || modelID == 405 || modelID == 416 || modelID == 402 || modelID == 403 || modelID == 1177 || modelID == 1179) + { + 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 { @@ -364,9 +382,6 @@ void CLODLightManager::III::Init() else autoFarClip = true; - DrawDistance = iniReader.ReadFloat("DistanceLimits", "DrawDistance", 0.0f); - MaxDrawDistanceForNormalObjects = iniReader.ReadFloat("DistanceLimits", "MaxDrawDistanceForNormalObjects", 0.0f); - RenderStaticShadowsForLODs = iniReader.ReadInteger("StaticShadows", "RenderStaticShadowsForLODs", 0); IncreasePedsCarsShadowsDrawDistance = iniReader.ReadInteger("StaticShadows", "IncreasePedsCarsShadowsDrawDistance", 0); StaticShadowsIntensity = iniReader.ReadFloat("StaticShadows", "StaticShadowsIntensity", 0.0f); @@ -389,7 +404,12 @@ void CLODLightManager::III::Init() MaxFPSValue = iniReader.ReadInteger("AdaptiveDrawDistance", "MaxFPSValue", 0); MaxPossibleDrawDistance = iniReader.ReadFloat("AdaptiveDrawDistance", "MaxPossibleDrawDistance", 0.0f); + MaxDrawDistanceForNormalObjects = iniReader.ReadFloat("DistanceLimits", "MaxDrawDistanceForNormalObjects", 0.0f); + DrawDistance = iniReader.ReadFloat("DistanceLimits", "DrawDistance", 0.0f); + bPreloadLODs = iniReader.ReadInteger("DistanceLimits", "PreloadLODs", 0) == 1; + LoadDatFile(); + if (bRenderLodLights) { RegisterAllLampposts(); @@ -413,6 +433,29 @@ BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD reason, LPVOID /*lpReserved*/) injector::MakeJMP(0x4787F8, CLODLightManager::III::IPLDataHook1); injector::MakeJMP(0x47899B, CLODLightManager::III::IPLDataHook2); injector::MakeCALL(0x48C09F, CLODLightManager::III::Init); + + CIniReader iniReader(""); + if (iniReader.ReadInteger("DistanceLimits", "PreloadLODs", 0) == 1) + { + injector::WriteMemory(0x591E0B, &nLevelPortland, true); + injector::WriteMemory(0x591E16, &nLevelPortland, true); + injector::WriteMemory(0x591E28, &nLevelPortland, true); + injector::WriteMemory(0x591E3B, &nLevelPortland, true); + + injector::WriteMemory(0x4A8F79 + 0x1, &nLevelPortland, true); + + injector::WriteMemory(0x4B61BC, nLevelPortland, true); + + injector::MakeInline<0x40B7DA, 0x40B8F4>([](injector::reg_pack& regs) + { + CPopulationDealWithZoneChange(0x8F6250, *(char*)0x941514, 0); + LoadCollisionFile1(*(char*)0x941514); + *(DWORD*)0x8F6250 = *(char*)0x941514; + sub_595BD0(); + }); + + injector::MakeNOP(0x4764AF, 5, true); //CFileLoader::LoadMapZones((char const *)) + } } } } diff --git a/SALodLights/SearchlightsSA.h b/SALodLights/SearchlightsSA.h index dbcbdb3..08c297c 100644 --- a/SALodLights/SearchlightsSA.h +++ b/SALodLights/SearchlightsSA.h @@ -1,5 +1,4 @@ - void CLODLightManager::SA::RenderSearchLights() { static CPool **pObjectPool = (CPool **)0xB7449C; @@ -31,7 +30,7 @@ void CLODLightManager::SA::RenderSearchLights() //{ if (!(C2dfxData->color.r == 255 && C2dfxData->color.g == 0 && C2dfxData->color.b == 0) && !(C2dfxData->color.r == 0 && C2dfxData->color.g == 255 && C2dfxData->color.b == 0) - && !(C2dfxData->color.r == 255 && (C2dfxData->color.g == 128 || C2dfxData->color.g == 142) && C2dfxData->color.b == 0 && (ObjectInst->m_nModelIndex == GetModelInfoUInt16("CJ_TRAFFIC_LIGHT4") || ObjectInst->m_nModelIndex == GetModelInfoUInt16("GAY_TRAFFIC_LIGHT"))) + && !(C2dfxData->color.r == 255 && (C2dfxData->color.g == 128 || C2dfxData->color.g == 142) && C2dfxData->color.b == 0 && (ObjectInst->m_nModelIndex == CJ_TRAFFIC_LIGHT4 || ObjectInst->m_nModelIndex == GAY_TRAFFIC_LIGHT)) && !(C2dfxData->coronaSize == 0.0f)) { RwV3D StartPoint; @@ -46,14 +45,14 @@ void CLODLightManager::SA::RenderSearchLights() float grZ = FindGroundZFor3DCoord(StartPoint.x, StartPoint.y, StartPoint.z, 0, 0); EndPoint.z = grZ; - if (ObjectInst->m_nModelIndex != GetModelInfoUInt16("Streetlamp1") && ObjectInst->m_nModelIndex != GetModelInfoUInt16("Streetlamp2") - && ObjectInst->m_nModelIndex != GetModelInfoUInt16("bollardlight") && ObjectInst->m_nModelIndex != GetModelInfoUInt16("Gay_lamppost")) + if (ObjectInst->m_nModelIndex != Streetlamp1 && ObjectInst->m_nModelIndex != Streetlamp2 + && ObjectInst->m_nModelIndex != bollardlight && ObjectInst->m_nModelIndex != Gay_lamppost) { //yellow drawCustomSpotLight(StartPoint, EndPoint, 8.0f * (StartPoint.z - grZ), C2dfxData->coronaSize / 6.0f, 5.0f, 8, fSearchlightEffectVisibilityFactor); } - else if (ObjectInst->m_nModelIndex != GetModelInfoUInt16("Gay_lamppost")) + else if (ObjectInst->m_nModelIndex != Gay_lamppost) { //white drawCustomSpotLight(StartPoint, EndPoint, 8.0f * (StartPoint.z - grZ), C2dfxData->coronaSize / 6.0f, 255.0f, 8, fSearchlightEffectVisibilityFactor); diff --git a/SALodLights/dllmain.cpp b/SALodLights/dllmain.cpp index d6a62e6..dda4cd8 100644 --- a/SALodLights/dllmain.cpp +++ b/SALodLights/dllmain.cpp @@ -217,6 +217,7 @@ void CLODLightManager::SA::LoadDatFile() } else { + //RenderSearchlightEffects = 0; bRenderLodLights = 0; injector::MakeNOP(0x53C131, 5); } @@ -456,11 +457,12 @@ void __cdecl CIplStoreLoadAll() } } -void LoadAllBinaryIPLs() +char LoadAllBinaryIPLs() { static auto CIplStoreLoad = (char *(__cdecl *)()) 0x5D54A0; CIplStoreLoad(); CIplStoreLoadAll(); + return 1; } static std::vector lods; // CEntity* @@ -509,8 +511,6 @@ void CLODLightManager::SA::ApplyMemoryPatches() injector::MakeCALL(0x53E184, RenderSearchLights, true); } - injector::WriteMemory(0x6FC051 + 0x2, 0x7080 * 0xA, true); // sun reflection - /*if (SmoothEffect) { SmoothEffect = 1; @@ -528,6 +528,7 @@ void CLODLightManager::SA::ApplyMemoryPatches() injector::MakeNOP(0x6FAE1F, 6, true); } + injector::WriteMemory(0x6FC051 + 0x2, 0x7080 * 0xA, true); // sun reflection injector::WriteMemory(0x49DCF4, 550.0f, true); //Traffic lights corona draw distance injector::MakeJMP(0x6FCFC4, LamppostsCoronaFarclpHook, true); @@ -555,8 +556,12 @@ void CLODLightManager::SA::ApplyMemoryPatches() injector::MakeJMP(0x5B3F43, asm_IncreaseDrawDistanceForTimedObjects); if ((TimedObjectsDrawDistance > 2.0f && TimedObjectsDrawDistance <= 10.0f) || (TimedObjectsDrawDistance > 300.0f)) { - injector::WriteMemory(0x5D95B0, 0xC3u); - injector::WriteMemory(0x810CA0, 0xC3u); + injector::MakeInline<0x53C9B7, 0x53C9B7+5>([](injector::reg_pack& regs) + { + injector::WriteMemory(0x5D95B0, 0xC3u); + injector::WriteMemory(0x810CA0, 0xC3u); + injector::WriteMemory(0x5D9730, 0xC3u); + }); injector::WriteMemory(0x56420F, 0xB83074); } } diff --git a/VCLodLights/dllmain.cpp b/VCLodLights/dllmain.cpp index 6d082e0..ee2ad31 100644 --- a/VCLodLights/dllmain.cpp +++ b/VCLodLights/dllmain.cpp @@ -159,6 +159,9 @@ void CLODLightManager::VC::ApplyMemoryPatches() if (bRenderLodLights) { injector::MakeCALL(0x4A6547, RenderLODLights, true); + + injector::MakeNOP(0x544186, 6, true); //disable ambientBrightness change + injector::MakeNOP(0x544533, 6, true); } if (RenderSearchlightEffects) @@ -166,15 +169,12 @@ void CLODLightManager::VC::ApplyMemoryPatches() injector::MakeJMP(0x4A6560, RenderSearchLights, true); } - injector::WriteMemory(0x542E66, 127, true); // sun reflection - if (SmoothEffect) { SmoothEffect = 1; } - injector::MakeNOP(0x544186, 6, true); //disable ambientBrightness change - injector::MakeNOP(0x544533, 6, true); + injector::WriteMemory(0x542E66, 127, true); // sun reflection injector::WriteMemory(0x68A860, 300.0f, true); // Traffic lights coronas draw distance @@ -292,6 +292,7 @@ void CLODLightManager::VC::LoadDatFile() } else { + RenderSearchlightEffects = 0; bRenderLodLights = 0; } } @@ -396,9 +397,6 @@ void CLODLightManager::VC::Init() else autoFarClip = true; - DrawDistance = iniReader.ReadFloat("DistanceLimits", "DrawDistance", 0.0); - MaxDrawDistanceForNormalObjects = iniReader.ReadFloat("DistanceLimits", "MaxDrawDistanceForNormalObjects", 0.0); - RenderStaticShadowsForLODs = iniReader.ReadInteger("StaticShadows", "RenderStaticShadowsForLODs", 0); IncreasePedsCarsShadowsDrawDistance = iniReader.ReadInteger("StaticShadows", "IncreasePedsCarsShadowsDrawDistance", 0); StaticShadowsIntensity = iniReader.ReadFloat("StaticShadows", "StaticShadowsIntensity", 0.0f); @@ -421,6 +419,10 @@ void CLODLightManager::VC::Init() MaxFPSValue = iniReader.ReadInteger("AdaptiveDrawDistance", "MaxFPSValue", 0); MaxPossibleDrawDistance = iniReader.ReadFloat("AdaptiveDrawDistance", "MaxPossibleDrawDistance", 0.0f); + MaxDrawDistanceForNormalObjects = iniReader.ReadFloat("DistanceLimits", "MaxDrawDistanceForNormalObjects", 0.0); + DrawDistance = iniReader.ReadFloat("DistanceLimits", "DrawDistance", 0.0); + bPreloadLODs = iniReader.ReadInteger("DistanceLimits", "PreloadLODs", 0) == 1; + LoadDatFile(); if (bRenderLodLights) { diff --git a/includes/CLODLightManager.h b/includes/CLODLightManager.h index 93f010f..2b1d6b1 100644 --- a/includes/CLODLightManager.h +++ b/includes/CLODLightManager.h @@ -44,6 +44,10 @@ __int16 TempBufferRenderIndexList[4096]; RxObjSpace3dVertex TempVertexBuffer[500]; int TempBufferIndicesStored = 0; unsigned int TempBufferVerticesStored = 0; +static int nLevelPortland = 1; +static auto CPopulationDealWithZoneChange = injector::cstd::call<0x4F6200>; +static auto LoadCollisionFile1 = injector::cstd::call<0x476520>; +static auto sub_595BD0 = injector::cstd::call<0x595BD0>; typedef struct { float X, Y, Z; } Vector3; #define RwV3D RwV3d @@ -507,7 +511,8 @@ RwV3D * GetCamPos() { return (RwV3D *)(0xB6F338 + (*(BYTE *)0xB6F081 * 0x238)); } -int MTraffic1, MTraffic2, MTraffic3, MTraffic4, trafficlight1, VGSSTRIPTLIGHTS1, CJ_TRAFFIC_LIGHT3; +short MTraffic1, MTraffic2, MTraffic3, MTraffic4, trafficlight1, VGSSTRIPTLIGHTS1, CJ_TRAFFIC_LIGHT3; +short CJ_TRAFFIC_LIGHT4, GAY_TRAFFIC_LIGHT, Streetlamp1, Streetlamp2, Gay_lamppost, bollardlight; bool CLODLightManager::SA::IsModelALamppostNotTrafficLight(unsigned short nModelIndex) { if (!MTraffic1) @@ -519,6 +524,12 @@ bool CLODLightManager::SA::IsModelALamppostNotTrafficLight(unsigned short nModel trafficlight1 = GetModelInfoUInt16("trafficlight1"); VGSSTRIPTLIGHTS1 = GetModelInfoUInt16("VGSSTRIPTLIGHTS1"); CJ_TRAFFIC_LIGHT3 = GetModelInfoUInt16("CJ_TRAFFIC_LIGHT3"); + CJ_TRAFFIC_LIGHT4 = GetModelInfoUInt16("CJ_TRAFFIC_LIGHT4"); + GAY_TRAFFIC_LIGHT = GetModelInfoUInt16("GAY_TRAFFIC_LIGHT"); + Streetlamp1 = GetModelInfoUInt16("Streetlamp1"); + Streetlamp2 = GetModelInfoUInt16("Streetlamp2"); + Gay_lamppost = GetModelInfoUInt16("Gay_lamppost"); + bollardlight = GetModelInfoUInt16("bollardlight"); } if (nModelIndex != MTraffic1