Skip to content

Commit

Permalink
Project2DFX v3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirteenAG committed Apr 13, 2015
1 parent a00c1d5 commit b58a8c6
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 319 deletions.
32 changes: 31 additions & 1 deletion IIILodLights/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,32 @@ void CLODLightManager::III::ApplyMemoryPatches()

if (MaxDrawDistanceForNormalObjects)
{
injector::WriteMemory<float>(0x5F72A4, MaxDrawDistanceForNormalObjects, true);
//injector::WriteMemory<float>(0x5F72A4, MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4A8AB1, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4A8AC6, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4A8AD9, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4A8B0E, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4A8B21, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4A8B34, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4A8B82, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4A8B97, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4A8BAA, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4A8BDF, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4A8BF2, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4A8C05, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4A8DA6, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4AA391, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4AA3A6, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4AA3B9, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4AA3EE, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4AA401, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4AA414, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4AA462, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4AA477, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4AA48A, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4AA4BF, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4AA4D2, &MaxDrawDistanceForNormalObjects, true);
injector::WriteMemory(0x4AA4E5, &MaxDrawDistanceForNormalObjects, true);
}

if (EnableDrawDistanceChanger)
Expand Down Expand Up @@ -445,6 +470,11 @@ BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD reason, LPVOID /*lpReserved*/)
injector::WriteMemory<unsigned char>(0x40A6E6, 0xBD, true); //mov ebp
injector::WriteMemory(0x40A6E6 + 0x1, nLevelPortland, true);

//opcode
injector::MakeNOP(0x5887FD, 5, true);
injector::MakeNOP(0x588809, 5, true);
injector::MakeNOP(0x58881A, 5, true);

injector::WriteMemory(0x4A8F79 + 0x1, &nLevelPortland, true);

injector::WriteMemory(0x4B61BC, nLevelPortland, true);
Expand Down
149 changes: 149 additions & 0 deletions IVLodLights/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,60 @@ void CLODLightManager::IV::IncreaseCoronaLimit()
WriteMemory<unsigned int>(aslr_ptr(0x7E1072 + 0x2), nCoronasLimit);
WriteMemory<unsigned int>(aslr_ptr(0x7E1189 + 0x1), nCoronasLimit * 64);
}
else
{
AdjustPointer(aslr_ptr(0x89A104), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A0FE), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x8995C5), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A112), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A120), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A184), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A18C), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A194), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A19D), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x8997B2), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A0B1), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A149), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A15C), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A16A), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A0D1), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A0EA), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A0C5), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A0BB), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A0DD), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A0AA), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A132), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A170), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A1A3), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));
AdjustPointer(aslr_ptr(0x89A1BB), &aCoronas[0], aslr_ptr(0x111A040), aslr_ptr(0x111A040 + 0x3C));

AdjustPointer(aslr_ptr(0x8996DB), &aCoronas2[0], aslr_ptr(0x110E040), aslr_ptr(0x110E040 + 0x1B));
AdjustPointer(aslr_ptr(0x899BCA), &aCoronas2[0], aslr_ptr(0x110E040), aslr_ptr(0x110E040 + 0x1B));
AdjustPointer(aslr_ptr(0x8996E9), &aCoronas2[0], aslr_ptr(0x110E040), aslr_ptr(0x110E040 + 0x1B));
AdjustPointer(aslr_ptr(0x8996F7), &aCoronas2[0], aslr_ptr(0x110E040), aslr_ptr(0x110E040 + 0x1B));
AdjustPointer(aslr_ptr(0x8996FF), &aCoronas2[0], aslr_ptr(0x110E040), aslr_ptr(0x110E040 + 0x1B));
AdjustPointer(aslr_ptr(0x899BD2), &aCoronas2[0], aslr_ptr(0x110E040), aslr_ptr(0x110E040 + 0x1B));
AdjustPointer(aslr_ptr(0x89972D), &aCoronas2[0], aslr_ptr(0x110E040), aslr_ptr(0x110E040 + 0x1B));
AdjustPointer(aslr_ptr(0x899BDA), &aCoronas2[0], aslr_ptr(0x110E040), aslr_ptr(0x110E040 + 0x1B));
AdjustPointer(aslr_ptr(0x899705), &aCoronas2[0], aslr_ptr(0x110E040), aslr_ptr(0x110E040 + 0x1B));
AdjustPointer(aslr_ptr(0x899D81), &aCoronas2[0], aslr_ptr(0x110E040), aslr_ptr(0x110E040 + 0x1B));
AdjustPointer(aslr_ptr(0x89970B), &aCoronas2[0], aslr_ptr(0x110E040), aslr_ptr(0x110E040 + 0x1B));
AdjustPointer(aslr_ptr(0x899BB5), &aCoronas2[0], aslr_ptr(0x110E040), aslr_ptr(0x110E040 + 0x1B));
AdjustPointer(aslr_ptr(0x899715), &aCoronas2[0], aslr_ptr(0x110E040), aslr_ptr(0x110E040 + 0x1B));
AdjustPointer(aslr_ptr(0x899BBC), &aCoronas2[0], aslr_ptr(0x110E040), aslr_ptr(0x110E040 + 0x1B));
AdjustPointer(aslr_ptr(0x899725), &aCoronas2[0], aslr_ptr(0x110E040), aslr_ptr(0x110E040 + 0x1B));
AdjustPointer(aslr_ptr(0x899BC3), &aCoronas2[0], aslr_ptr(0x110E040), aslr_ptr(0x110E040 + 0x1B));
AdjustPointer(aslr_ptr(0x899733), &aCoronas2[0], aslr_ptr(0x110E040), aslr_ptr(0x110E040 + 0x1B));
AdjustPointer(aslr_ptr(0x899A28), &aCoronas2[0], aslr_ptr(0x110E040), aslr_ptr(0x110E040 + 0x1B));

WriteMemory<unsigned char>(aslr_ptr(0x8996CF + 0x2), NewLimitExponent);
WriteMemory<unsigned char>(aslr_ptr(0x899A1E + 0x2), NewLimitExponent);
WriteMemory<unsigned char>(aslr_ptr(0x899BAA + 0x2), NewLimitExponent);

WriteMemory<unsigned int>(aslr_ptr(0x89A089 + 0x2), nCoronasLimit);
WriteMemory<unsigned int>(aslr_ptr(0x8996A2 + 0x2), nCoronasLimit);
WriteMemory<unsigned int>(aslr_ptr(0x8997B9 + 0x1), nCoronasLimit * 64);
}
}


Expand Down Expand Up @@ -142,6 +196,76 @@ void CLODLightManager::IV::RenderLODLights()
}
}

void CLODLightManager::EFLC::RenderLODLights()
{
if (*CurrentTimeHours > 19 || *CurrentTimeHours < 7)
{
unsigned char bAlpha;
float fRadius;
unsigned int nTime = *CurrentTimeHours * 60 + *CurrentTimeMinutes;
unsigned int curMin = *CurrentTimeMinutes;
//CoronaFarClip = autoFarClip ? **fCurrentFarClip : CoronaFarClip;
GetRootCam(&currentCamera);

if (nTime >= 20 * 60)
bAlpha = static_cast<unsigned char>((5.0f / 6.0f)*nTime - 1000.0f);
else if (nTime < 3 * 60)
bAlpha = 200;
else
bAlpha = static_cast<unsigned char>((-5.0f / 6.0f)*nTime + 350.0f);

for (auto it = m_pLampposts->cbegin(); it != m_pLampposts->cend(); it++)
{
Vector3 pCamPos;
GetCamPos(currentCamera, &pCamPos.X, &pCamPos.Y, &pCamPos.Z);

if (GetDistance((RwV3d*)&it->vecPos, (RwV3d*)&pCamPos) <= CoronaFarClip)
{
if ((it->vecPos.z >= -15.0f) && (it->vecPos.z <= 1030.0f))
{
if (CamIsSphereVisible(currentCamera, it->vecPos.x, it->vecPos.y, it->vecPos.z, 5.0f))
{
float fDistSqr = (pCamPos.X - it->vecPos.x)*(pCamPos.X - it->vecPos.x) + (pCamPos.Y - it->vecPos.y)*(pCamPos.Y - it->vecPos.y) + (pCamPos.Z - it->vecPos.z)*(pCamPos.Z - it->vecPos.z);

if ((fDistSqr > 250.0f*250.0f && fDistSqr < CoronaFarClip*CoronaFarClip) || it->nNoDistance)
{
if (!it->nNoDistance)
fRadius = (fDistSqr < 300.0f*300.0f) ? (0.07f)*sqrt(fDistSqr) - 17.5f : 3.5f; // http://goo.gl/vhAZSx
else
fRadius = 3.5f;

if (SlightlyIncreaseRadiusWithDistance)
fRadius *= min((0.0025f)*sqrt(fDistSqr) + 0.25f, 4.0f); // http://goo.gl/3kDpnC

if (it->fCustomSizeMult != 0.45f)
{
DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier) * 127.5f, 0, 0.0f, (bAlpha / 500.0f) * it->colour.r, (bAlpha / 500.0f) * it->colour.g, (bAlpha / 500.0f) * it->colour.b);
}
else
{
if ((curMin > 0 && curMin < 10) || (curMin > 20 && curMin < 30) || (curMin > 40 && curMin < 50))
{
if ((int)it->vecPos.x % 2 || (int)it->vecPos.y % 2)
DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier) * 127.5f, 0, 0.0f, (bAlpha / 500.0f) * 255u, (bAlpha / 500.0f) * 0, (bAlpha / 500.0f) * 0);
else
DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier) * 127.5f, 0, 0.0f, (bAlpha / 500.0f) * 0, (bAlpha / 500.0f) * 255u, (bAlpha / 500.0f) * 0);
}
else
{
if ((int)it->vecPos.x % 2 || (int)it->vecPos.y % 2)
DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier) * 127.5f, 0, 0.0f, (bAlpha / 500.0f) * 0, (bAlpha / 500.0f) * 255u, (bAlpha / 500.0f) * 0);
else
DrawCorona(it->vecPos.x, it->vecPos.y, it->vecPos.z, (fRadius * it->fCustomSizeMult * CoronaRadiusMultiplier) * 127.5f, 0, 0.0f, (bAlpha / 500.0f) * 255u, (bAlpha / 500.0f) * 0, (bAlpha / 500.0f) * 0);
}
}
}
}
}
}
}
}
}

void __declspec(naked) CLODLightManager::IV::LoadObjectInstanceHook()
{
_asm
Expand Down Expand Up @@ -190,6 +314,15 @@ void CLODLightManager::IV::GetMemoryAddresses()
CLODLightManager::IV::CamIsSphereVisible = (bool(__cdecl *)(int camera, float pX, float pY, float pZ, float radius))(aslr_ptr(0xBB9340).get());
CLODLightManager::IV::GetCamPos = (void(__cdecl *)(int camera, float *pX, float *pY, float *pZ))(aslr_ptr(0xBB8510).get());
}
else
{
CLODLightManager::EFLC::CurrentTimeHours = injector::aslr_ptr(0x10C9398).get();
CLODLightManager::EFLC::CurrentTimeMinutes = injector::aslr_ptr(0x10C9394).get();
CLODLightManager::EFLC::DrawCorona = (int(__cdecl *)(float, float, float, float, unsigned int, float, unsigned char, unsigned char, unsigned char))(aslr_ptr(0xAA3100).get());
CLODLightManager::EFLC::GetRootCam = (void(__stdcall *)(int *camera))(aslr_ptr(0xAFA7E0).get());
CLODLightManager::EFLC::CamIsSphereVisible = (bool(__cdecl *)(int camera, float pX, float pY, float pZ, float radius))(aslr_ptr(0xC27DD0).get());
CLODLightManager::EFLC::GetCamPos = (void(__cdecl *)(int camera, float *pX, float *pY, float *pZ))(aslr_ptr(0xC26FA0).get());
}
}

void CLODLightManager::IV::Init()
Expand Down Expand Up @@ -229,6 +362,22 @@ void CLODLightManager::IV::Init()

injector::MakeCALL(aslr_ptr(0x00402D6C), RenderLODLights, true);
}
else
{
if (SkipIntro) { injector::WriteMemory<uint8_t>(aslr_ptr(0x473439), 0xEB, true); }
if (DoNotPauseOnMinimize) { injector::MakeNOP(aslr_ptr(0x402D5A), 2, true); }

if (DisableDefaultLodLights) { injector::WriteMemory<unsigned char>(aslr_ptr(0x00975860), 0xC3u, true); }
if (DisableCoronasWaterReflection) { injector::MakeNOP(aslr_ptr(0xC8E183), 5, true); }

injector::MakeJMP(aslr_ptr(0x0091C851), LoadObjectInstanceHook, true);
hookJmpAddr = (uintptr_t)injector::aslr_ptr(0x91C857).get<void>();

injector::MakeJMP(aslr_ptr(0x00918891), ParseIdeObjsHook, true);
hookJmpAddr2 = (uintptr_t)injector::aslr_ptr(0x918897).get<void>();

injector::MakeCALL(aslr_ptr(0x0047361F), CLODLightManager::EFLC::RenderLODLights);
}
}
}

Expand Down
Loading

0 comments on commit b58a8c6

Please sign in to comment.