Skip to content

Commit

Permalink
Simplify.
Browse files Browse the repository at this point in the history
  • Loading branch information
bolrog committed May 16, 2021
1 parent d3bb657 commit 66ed512
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 50 deletions.
14 changes: 7 additions & 7 deletions src/d2dx/Detours.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ void d2dx::AttachDetours()
_Use_decl_annotations_
void d2dx::AttachLateDetours(
IGameHelper* gameHelper,
IFeatureFlags* supportFeature)
ID2DXContext* d2dxContext)
{
if (hasLateDetoured)
{
Expand Down Expand Up @@ -793,7 +793,7 @@ void d2dx::AttachLateDetours(
DetourAttach(&(PVOID&)D2Win_DrawText_Real, D2Win_DrawText_Hooked);
//DetourAttach(&(PVOID&)D2Win_DrawTextEx_Real, D2Win_DrawTextEx_Hooked);

if (supportFeature->IsFeatureEnabled(Feature::TextMotionPrediction))
if (d2dxContext->IsFeatureEnabled(Feature::TextMotionPrediction))
{
assert(D2Win_DrawFramedText_Real);
DetourAttach(&(PVOID&)D2Win_DrawFramedText_Real, D2Win_DrawFramedText_Hooked);
Expand All @@ -802,19 +802,19 @@ void d2dx::AttachLateDetours(
DetourAttach(&(PVOID&)D2Win_DrawRectangledText_Real, D2Win_DrawRectangledText_Hooked);
}

if (supportFeature->IsFeatureEnabled(Feature::UnitMotionPrediction))
if (d2dxContext->IsFeatureEnabled(Feature::UnitMotionPrediction))
{
assert(D2Client_DrawUnit_Real);
DetourAttach(&(PVOID&)D2Client_DrawUnit_Real,
(gameHelper->GetVersion() == GameVersion::Lod109d ||
gameHelper->GetVersion() == GameVersion::Lod110 ||
gameHelper->GetVersion() == GameVersion::Lod114d) ? D2Client_DrawUnit_ESI_Hooked : D2Client_DrawUnit_Stack_Hooked);
gameHelper->GetVersion() == GameVersion::Lod110 ||
gameHelper->GetVersion() == GameVersion::Lod114d) ? D2Client_DrawUnit_ESI_Hooked : D2Client_DrawUnit_Stack_Hooked);

assert(D2Client_DrawMissile_Real);
DetourAttach(&(PVOID&)D2Client_DrawMissile_Real, D2Client_DrawMissile_ESI_Hooked);
}

if (supportFeature->IsFeatureEnabled(Feature::WeatherMotionPrediction))
if (d2dxContext->IsFeatureEnabled(Feature::WeatherMotionPrediction))
{
assert(D2Client_DrawWeatherParticles_Real);
DetourAttach(&(PVOID&)D2Client_DrawWeatherParticles_Real,
Expand All @@ -830,7 +830,7 @@ void d2dx::AttachLateDetours(
}

void d2dx::DetachDetours()
{
{
if (!hasDetoured)
{
return;
Expand Down
6 changes: 3 additions & 3 deletions src/d2dx/Detours.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
namespace d2dx
{
struct IGameHelper;
struct IFeatureFlags;

struct ID2DXContext;
void AttachDetours();

void AttachLateDetours(
_In_ IGameHelper* gameHelper,
_In_ IFeatureFlags* supportFeature);
_In_ ID2DXContext* d2dxContext);

void DetachDetours();
}
14 changes: 11 additions & 3 deletions src/d2dx/ID2DXContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,21 @@
#include "IGlide3x.h"
#include "IWin32InterceptionHandler.h"
#include "ID2InterceptionHandler.h"
#include "IFeatureFlags.h"
#include "Options.h"

namespace d2dx
{
enum class Feature
{
UnitMotionPrediction = 1,
WeatherMotionPrediction = 2,
TextMotionPrediction = 4,
};

struct ID2DXContext abstract :
public IGlide3x,
public IWin32InterceptionHandler,
public ID2InterceptionHandler,
public IFeatureFlags
public ID2InterceptionHandler
{
virtual ~ID2DXContext() noexcept {}

Expand All @@ -44,5 +49,8 @@ namespace d2dx
virtual void DisableBuiltinResMod() = 0;

virtual Options& GetOptions() = 0;

virtual bool IsFeatureEnabled(
_In_ Feature feature) = 0;
};
}
35 changes: 0 additions & 35 deletions src/d2dx/IFeatureFlags.h

This file was deleted.

1 change: 0 additions & 1 deletion src/d2dx/d2dx.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@
<ClInclude Include="Buffer.h" />
<ClInclude Include="D2DXConfigurator.h" />
<ClInclude Include="dx256_bmp.h" />
<ClInclude Include="IFeatureFlags.h" />
<ClInclude Include="TextMotionPredictor.h" />
<ClInclude Include="IBuiltinResMod.h" />
<ClInclude Include="ID2DXContext.h" />
Expand Down
1 change: 0 additions & 1 deletion src/d2dx/d2dx.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@
<ClInclude Include="..\..\thirdparty\pocketlzma\pocketlzma.hpp">
<Filter>thirdparty\pocketlzma</Filter>
</ClInclude>
<ClInclude Include="IFeatureFlags.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="d2dx.rc" />
Expand Down

0 comments on commit 66ed512

Please sign in to comment.