Skip to content

Commit

Permalink
Project2DFX v3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirteenAG committed Dec 26, 2015
1 parent 70ac26f commit 05e4410
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 53 deletions.
3 changes: 2 additions & 1 deletion 2DFXDataGrabber/2DFXDataGrabber.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<ProjectGuid>{8862820A-5A13-49D6-A4D1-0E44F1AA1C49}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>My2DFXDataGrabber</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand All @@ -25,7 +26,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down
7 changes: 6 additions & 1 deletion IIILodLights/IIILodLights.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<ProjectGuid>{B42AC8DF-B9B8-4B39-852B-259C71EFDA35}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>IIILodLights</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand All @@ -25,7 +26,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down Expand Up @@ -75,6 +76,10 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PreBuildEvent>
<Command>cd $(TargetDir)
del *.iobj</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="SearchlightsIII.h" />
Expand Down
45 changes: 17 additions & 28 deletions IIILodLights/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ void CLODLightManager::III::RegisterCustomCoronas()
template<uintptr_t addr>
void CExplosionAddModifiedExplosion()
{
using printstr_hook = injector::function_hooker<addr, void(int a1, int a2, int a3, int a4, int a5)>;
injector::make_static_hook<printstr_hook>([](printstr_hook::func_type AddExplosion, int a1, int a2, int eExplosionType, int a4, int a5)
using func_hook = injector::function_hooker<addr, void(int a1, int a2, int a3, int a4, int a5)>;
injector::make_static_hook<func_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);
Expand All @@ -144,8 +144,8 @@ void CExplosionAddModifiedExplosion()
template<uintptr_t addr>
void CBulletTracesAddTrace()
{
using printstr_hook = injector::function_hooker<addr, void(CVector *, CVector *)>;
injector::make_static_hook<printstr_hook>([](printstr_hook::func_type AddTrace, CVector* start, CVector* end)
using func_hook = injector::function_hooker<addr, void(CVector *, CVector *)>;
injector::make_static_hook<func_hook>([](func_hook::func_type AddTrace, CVector* start, CVector* end)
{
injector::MakeNOP(0x563B56, 5); // sub_50D140
injector::MakeNOP(0x563BBB, 5); // sub_510790
Expand Down Expand Up @@ -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)
Expand All @@ -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<unsigned int, const CLamppostInfo>;
pFileContent = new std::map<unsigned int, CLamppostInfo>;

while (const char* pLine = CFileMgr::LoadLine(hFile))
{
Expand All @@ -387,7 +387,7 @@ void CLODLightManager::III::LoadDatFile()
}
}

m_pLampposts = new std::vector<const CLamppostInfo>;
m_pLampposts = new std::vector<CLamppostInfo>;

CFileMgr::CloseFile(hFile);
}
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
Expand All @@ -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
{
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion IVLodLights/IVLodLights.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<ProjectGuid>{586D45F0-B4A6-4EEA-9AC5-15B2C2AAFE4D}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>IVLodLights</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand All @@ -25,7 +26,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down
3 changes: 2 additions & 1 deletion SALodLights/SALodLights.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<ProjectGuid>{32E8A22B-F9D9-4A3C-B524-9632BEC56A51}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>SALodLights</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand All @@ -25,7 +26,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions SALodLights/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned int, const CLamppostInfo>;
pFileContent = new std::map<unsigned int, CLamppostInfo>;

while (const char* pLine = CFileMgr::LoadLine(hFile))
{
Expand All @@ -210,7 +210,7 @@ void CLODLightManager::SA::LoadDatFile()
}
}

m_pLampposts = new std::vector<const CLamppostInfo>;
m_pLampposts = new std::vector<CLamppostInfo>;
m_bCatchLamppostsNow = true;

CFileMgr::CloseFile(hFile);
Expand Down
7 changes: 6 additions & 1 deletion VCLodLights/VCLodLights.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<ProjectGuid>{4304D8B7-2551-42BA-B62F-B898C42EABF2}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>VCLodLights</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand All @@ -25,7 +26,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down Expand Up @@ -75,6 +76,10 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PreBuildEvent>
<Command>cd $(TargetDir)
del *.iobj</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="SearchlightsVC.h" />
Expand Down
14 changes: 9 additions & 5 deletions VCLodLights/dllmain.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "stdafx.h"
//#include "stdafx.h"
#include <windows.h>
#include "..\includes\CLODLightManager.h"
#include "SearchlightsVC.h"

Expand Down Expand Up @@ -127,7 +128,7 @@ void RenderSirenParticles()
injector::make_static_hook<func_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;
});
}
Expand Down Expand Up @@ -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<unsigned int, const CLamppostInfo>;
pFileContent = new std::map<unsigned int, CLamppostInfo>;

while (const char* pLine = CFileMgr::LoadLine(hFile))
{
Expand All @@ -382,7 +383,7 @@ void CLODLightManager::VC::LoadDatFile()
}
}

m_pLampposts = new std::vector<const CLamppostInfo>;
m_pLampposts = new std::vector<CLamppostInfo>;

CFileMgr::CloseFile(hFile);
}
Expand Down Expand Up @@ -545,6 +546,7 @@ void CLODLightManager::VC::Init()
RegisterAllLampposts();
RegisterCustomCoronas();
}

ApplyMemoryPatches();

//delete pFileContent;
Expand All @@ -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);

Expand All @@ -576,6 +578,8 @@ BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD reason, LPVOID /*lpReserved*/)
{ });

injector::WriteMemory(0x691538, 0x4DDDDD, true); //CFileLoader::LoadMapZones((char const *))

injector::WriteMemory<unsigned char>(0x4C7946, 0xEB, true); //Lods in the interiors
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions includes/CLODLightManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ class CLamppostInfo
class CLODLightManager
{
private:
static std::vector<const CLamppostInfo>* m_pLampposts;
static std::map<unsigned int, const CLamppostInfo>* pFileContent;
static std::vector<CLamppostInfo>* m_pLampposts;
static std::map<unsigned int, CLamppostInfo>* pFileContent;
static bool m_bCatchLamppostsNow;

static bool IsModelALamppost(unsigned short nModel);
Expand Down Expand Up @@ -122,7 +122,7 @@ class CLODLightManager::III : public CLODLightManager
static char* CurrentTimeMinutes;
static float** fCurrentFarClip;
static char* DataFilePath;
static std::vector<const CEntityIII> VecEntities;
static std::vector<CEntityIII> VecEntities;

public:
static void Init();
Expand Down Expand Up @@ -173,7 +173,7 @@ class CLODLightManager::VC : public CLODLightManager
static char* CurrentTimeMinutes;
static float** fCurrentFarClip;
static char* DataFilePath;
static std::vector<const CEntityVC> VecEntities;
static std::vector<CEntityVC> VecEntities;

public:
static void Init();
Expand Down Expand Up @@ -392,10 +392,10 @@ class CLODLightManager::EFLC : public CLODLightManager::IV
static void RenderLODLights();
};

std::map<unsigned int, const CLamppostInfo>* CLODLightManager::pFileContent;
std::vector<const CLamppostInfo>* CLODLightManager::m_pLampposts = nullptr;
std::vector<const CEntityVC> CLODLightManager::VC::VecEntities;
std::vector<const CEntityIII> CLODLightManager::III::VecEntities;
std::map<unsigned int, CLamppostInfo>* CLODLightManager::pFileContent;
std::vector<CLamppostInfo>* CLODLightManager::m_pLampposts = nullptr;
std::vector<CEntityVC> CLODLightManager::VC::VecEntities;
std::vector<CEntityIII> CLODLightManager::III::VecEntities;
bool CLODLightManager::m_bCatchLamppostsNow = false;

bool CLODLightManager::IsModelALamppost(unsigned short nModel)
Expand Down Expand Up @@ -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<unsigned int, const CLamppostInfo>;
pFileContent = new std::map<unsigned int, CLamppostInfo>;

while (const char* pLine = CFileMgr::LoadLine(hFile))
{
Expand Down Expand Up @@ -668,7 +668,7 @@ void CLODLightManager::IV::LoadDatFile()
}
}

m_pLampposts = new std::vector<const CLamppostInfo>;
m_pLampposts = new std::vector<CLamppostInfo>;
m_bCatchLamppostsNow = true;

CFileMgr::CloseFile(hFile);
Expand Down
7 changes: 4 additions & 3 deletions includes/injector/assembly.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#endif

//
#include <memory>
#include "injector.hpp"

namespace injector
Expand Down Expand Up @@ -152,14 +153,14 @@ namespace injector
template<uintptr_t at, uintptr_t end, class FuncT>
void MakeInline(FuncT func)
{
static FuncT static_func = func; // Stores the func object
static_func = func; //
static std::unique_ptr<FuncT> 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
Expand Down

0 comments on commit 05e4410

Please sign in to comment.