-
Notifications
You must be signed in to change notification settings - Fork 965
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement removing sniper rifle scope blur
- Loading branch information
1 parent
a88ca48
commit 091f318
Showing
12 changed files
with
116 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#pragma once | ||
|
||
#include <cassert> | ||
#include <cstddef> | ||
#include <limits> | ||
|
||
#include <GameClasses/ClientMode.h> | ||
#include <Hooks/LoopModeGameHook.h> | ||
#include <MemoryPatterns/ClientPatterns.h> | ||
#include <Utils/ReturnAddress.h> | ||
|
||
class SniperScopeBlurRemover { | ||
public: | ||
void incrementReferenceCount(LoopModeGameHook& loopModeGameHook) noexcept | ||
{ | ||
assert(referenceCount < (std::numeric_limits<std::size_t>::max)()); | ||
++referenceCount; | ||
loopModeGameHook.incrementReferenceCount(); | ||
} | ||
|
||
void decrementReferenceCount(LoopModeGameHook& loopModeGameHook) noexcept | ||
{ | ||
assert(referenceCount > 0); | ||
--referenceCount; | ||
loopModeGameHook.decrementReferenceCount(); | ||
} | ||
|
||
void getWorldSessionHook(ReturnAddress returnAddress) const noexcept | ||
{ | ||
if (shouldRemoveZoomedSniperEffect(returnAddress)) | ||
clientMode.removeZoomedSniperEffect(); | ||
} | ||
|
||
private: | ||
[[nodiscard]] bool shouldRemoveZoomedSniperEffect(ReturnAddress returnAddress) const noexcept | ||
{ | ||
return isEnabled() && returnAddress == getWorldSessionInClientMode && clientMode; | ||
} | ||
|
||
[[nodiscard]] bool isEnabled() const noexcept | ||
{ | ||
return referenceCount > 0; | ||
} | ||
|
||
ReturnAddress getWorldSessionInClientMode{ClientPatterns::getWorldSessionInClientMode()}; | ||
ClientMode clientMode{ClientPatterns::clientMode()}; | ||
std::size_t referenceCount{0}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include <FeatureHelpers/TogglableFeature.h> | ||
#include <FeatureHelpers/Visuals/SniperScopeBlurRemover.h> | ||
|
||
class LoopModeGameHook; | ||
|
||
class SniperScopeBlurRemovalFeature : public TogglableFeature<SniperScopeBlurRemovalFeature> { | ||
public: | ||
SniperScopeBlurRemovalFeature(LoopModeGameHook& loopModeGameHook, SniperScopeBlurRemover& sniperScopeBlurRemover) noexcept | ||
: loopModeGameHook{loopModeGameHook} | ||
, sniperScopeBlurRemover{sniperScopeBlurRemover} | ||
{ | ||
} | ||
|
||
private: | ||
friend TogglableFeature; | ||
|
||
void onEnable() const noexcept | ||
{ | ||
sniperScopeBlurRemover.incrementReferenceCount(loopModeGameHook); | ||
} | ||
|
||
void onDisable() const noexcept | ||
{ | ||
sniperScopeBlurRemover.decrementReferenceCount(loopModeGameHook); | ||
} | ||
|
||
LoopModeGameHook& loopModeGameHook; | ||
SniperScopeBlurRemover& sniperScopeBlurRemover; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
#pragma once | ||
|
||
#include "ScopeOverlayRemover/ScopeOverlayRemover.h" | ||
#include "SniperScopeBlurRemovalFeature.h" | ||
|
||
class LoopModeGameHook; | ||
class SniperScopeBlurRemover; | ||
|
||
struct VisualFeatures { | ||
VisualFeatures(LoopModeGameHook& loopModeGameHook) noexcept | ||
: scopeOverlayRemover{ loopModeGameHook } | ||
VisualFeatures(SniperScopeBlurRemover& sniperScopeBlurRemover, LoopModeGameHook& loopModeGameHook) noexcept | ||
: scopeOverlayRemover{loopModeGameHook, sniperScopeBlurRemover} | ||
, sniperScopeBlurRemoval{loopModeGameHook, sniperScopeBlurRemover} | ||
{ | ||
} | ||
|
||
ScopeOverlayRemover scopeOverlayRemover; | ||
SniperScopeBlurRemovalFeature sniperScopeBlurRemoval; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters