Skip to content

Commit

Permalink
Project2DFX v2.993
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirteenAG committed Apr 9, 2015
1 parent 6cf1049 commit 0478ec2
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 25 deletions.
18 changes: 15 additions & 3 deletions 2DFXDataGrabber/2DFXDataGrabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion IIILodLights/SearchlightsIII.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ void CLODLightManager::III::RenderSearchLights()
}
}
} while (nObjectPoolSize);
RenderHeliSearchLights();
true ? RenderHeliSearchLights() : nullptr;
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, 1);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, 1);
RwRenderStateSet(rwRENDERSTATESRCBLEND, 5);
Expand Down
49 changes: 46 additions & 3 deletions IIILodLights/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ void CLODLightManager::III::LoadDatFile()
}
else
{
RenderSearchlightEffects = 0;
bRenderLodLights = 0;
}

Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand All @@ -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 *))
}
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions SALodLights/SearchlightsSA.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@


void CLODLightManager::SA::RenderSearchLights()
{
static CPool **pObjectPool = (CPool **)0xB7449C;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
15 changes: 10 additions & 5 deletions SALodLights/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ void CLODLightManager::SA::LoadDatFile()
}
else
{
//RenderSearchlightEffects = 0;
bRenderLodLights = 0;
injector::MakeNOP(0x53C131, 5);
}
Expand Down Expand Up @@ -456,11 +457,12 @@ void __cdecl CIplStoreLoadAll()
}
}

void LoadAllBinaryIPLs()
char LoadAllBinaryIPLs()
{
static auto CIplStoreLoad = (char *(__cdecl *)()) 0x5D54A0;
CIplStoreLoad();
CIplStoreLoadAll();
return 1;
}

static std::vector<void*> lods; // CEntity*
Expand Down Expand Up @@ -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;
Expand All @@ -528,6 +528,7 @@ void CLODLightManager::SA::ApplyMemoryPatches()
injector::MakeNOP(0x6FAE1F, 6, true);
}

injector::WriteMemory(0x6FC051 + 0x2, 0x7080 * 0xA, true); // sun reflection
injector::WriteMemory<float>(0x49DCF4, 550.0f, true); //Traffic lights corona draw distance
injector::MakeJMP(0x6FCFC4, LamppostsCoronaFarclpHook, true);

Expand Down Expand Up @@ -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<unsigned char>(0x5D95B0, 0xC3u);
injector::WriteMemory<unsigned char>(0x810CA0, 0xC3u);
injector::MakeInline<0x53C9B7, 0x53C9B7+5>([](injector::reg_pack& regs)
{
injector::WriteMemory<unsigned char>(0x5D95B0, 0xC3u);
injector::WriteMemory<unsigned char>(0x810CA0, 0xC3u);
injector::WriteMemory<unsigned char>(0x5D9730, 0xC3u);
});
injector::WriteMemory(0x56420F, 0xB83074);
}
}
Expand Down
16 changes: 9 additions & 7 deletions VCLodLights/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,22 +159,22 @@ 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)
{
injector::MakeJMP(0x4A6560, RenderSearchLights, true);
}

injector::WriteMemory<char>(0x542E66, 127, true); // sun reflection

if (SmoothEffect)
{
SmoothEffect = 1;
}

injector::MakeNOP(0x544186, 6, true); //disable ambientBrightness change
injector::MakeNOP(0x544533, 6, true);
injector::WriteMemory<char>(0x542E66, 127, true); // sun reflection

injector::WriteMemory<float>(0x68A860, 300.0f, true); // Traffic lights coronas draw distance

Expand Down Expand Up @@ -292,6 +292,7 @@ void CLODLightManager::VC::LoadDatFile()
}
else
{
RenderSearchlightEffects = 0;
bRenderLodLights = 0;
}
}
Expand Down Expand Up @@ -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);
Expand All @@ -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)
{
Expand Down
13 changes: 12 additions & 1 deletion includes/CLODLightManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<void(int a1, int a2, char a3)>::call<0x4F6200>;
static auto LoadCollisionFile1 = injector::cstd<void(int a1)>::call<0x476520>;
static auto sub_595BD0 = injector::cstd<void()>::call<0x595BD0>;

typedef struct { float X, Y, Z; } Vector3;
#define RwV3D RwV3d
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 0478ec2

Please sign in to comment.