Skip to content

Commit

Permalink
Make methods of pattern classes non-static
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkrupinski committed Dec 22, 2023
1 parent bfea58c commit ffaaa8b
Show file tree
Hide file tree
Showing 71 changed files with 383 additions and 210 deletions.
14 changes: 11 additions & 3 deletions Source/FeatureHelpers/FeatureHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@
#include "WorldToClipSpaceConverter.h"

struct FeatureHelpers {
explicit FeatureHelpers(const VmtFinder& panoramaVmtFinder) noexcept
: stylePropertiesVMTs{panoramaVmtFinder}
explicit FeatureHelpers(const ClientPatterns& clientPatterns, const PanelStylePatterns& panelStylePatterns, const VmtFinder& panoramaVmtFinder) noexcept
: hudProvider{clientPatterns}
, globalVarsProvider{clientPatterns}
, transformFactory{clientPatterns}
, worldtoClipSpaceConverter{clientPatterns}
, plantedC4Provider{clientPatterns}
, viewToProjectionMatrix{clientPatterns}
, sniperScopeBlurRemover{clientPatterns}
, stylePropertiesVMTs{panoramaVmtFinder}
, stylePropertiesSymbols{StylePropertySymbolMap{panelStylePatterns.stylePropertiesSymbols()}}
{
}

Expand Down Expand Up @@ -50,5 +58,5 @@ struct FeatureHelpers {
ViewToProjectionMatrix viewToProjectionMatrix;
SniperScopeBlurRemover sniperScopeBlurRemover;
StylePropertiesVMTs stylePropertiesVMTs;
StylePropertiesSymbols stylePropertiesSymbols{StylePropertySymbolMap{PanelStylePatterns::stylePropertiesSymbols()}};
StylePropertiesSymbols stylePropertiesSymbols;
};
9 changes: 7 additions & 2 deletions Source/FeatureHelpers/GlobalVarsProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
#include <MemoryPatterns/ClientPatterns.h>

struct GlobalVarsProvider {
explicit GlobalVarsProvider(const ClientPatterns& clientPatterns) noexcept
: globalVars{clientPatterns.globalVars()}
{
}

[[nodiscard]] explicit operator bool() const noexcept
{
return globalVars != nullptr;
Expand All @@ -18,5 +23,5 @@ struct GlobalVarsProvider {
}

private:
cs2::GlobalVars** globalVars{ ClientPatterns::globalVars() };
};
cs2::GlobalVars** globalVars;
};
10 changes: 8 additions & 2 deletions Source/FeatureHelpers/Sound/SoundWatcherImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
template <typename... Sounds>
class SoundWatcherImpl {
public:
explicit SoundWatcherImpl(const FileSystemPatterns& fileSystemPatterns, const SoundSystemPatterns& soundSystemPatterns) noexcept
: soundChannels{soundSystemPatterns.soundChannels()}
, fileSystem{fileSystemPatterns.fileSystem()}
{
}

template <typename Sound>
void startWatching() noexcept
{
Expand Down Expand Up @@ -140,8 +146,8 @@ class SoundWatcherImpl {
return utils::typeIndex<Sound, std::tuple<Sounds...>>();
}

cs2::SoundChannels** soundChannels{ SoundSystemPatterns::soundChannels() };
cs2::CBaseFileSystem** fileSystem{ FileSystemPatterns::fileSystem() };
cs2::SoundChannels** soundChannels;
cs2::CBaseFileSystem** fileSystem;

TypeBitFlags<Sounds...> soundsToWatch;
std::array<WatchedSounds, sizeof...(Sounds)> watchedSounds;
Expand Down
7 changes: 6 additions & 1 deletion Source/FeatureHelpers/ViewToProjectionMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
#include <MemoryPatterns/ClientPatterns.h>

struct ViewToProjectionMatrix {
explicit ViewToProjectionMatrix(const ClientPatterns& clientPatterns) noexcept
: viewToProjectionMatrix{clientPatterns.viewToProjectionMatrix()}
{
}

[[nodiscard]] float getFovScale() const noexcept
{
if (viewToProjectionMatrix)
Expand All @@ -13,5 +18,5 @@ struct ViewToProjectionMatrix {
}

private:
const cs2::VMatrix* viewToProjectionMatrix{ClientPatterns::viewToProjectionMatrix()};
const cs2::VMatrix* viewToProjectionMatrix;
};
10 changes: 8 additions & 2 deletions Source/FeatureHelpers/Visuals/SniperScopeBlurRemover.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@

class SniperScopeBlurRemover {
public:
explicit SniperScopeBlurRemover(const ClientPatterns& clientPatterns) noexcept
: getWorldSessionInClientMode{clientPatterns.getWorldSessionInClientMode()}
, clientMode{clientPatterns.clientMode()}
{
}

void incrementReferenceCount(LoopModeGameHook& loopModeGameHook) noexcept
{
assert(referenceCount < (std::numeric_limits<std::size_t>::max)());
Expand Down Expand Up @@ -42,7 +48,7 @@ class SniperScopeBlurRemover {
return referenceCount > 0;
}

ReturnAddress getWorldSessionInClientMode{ClientPatterns::getWorldSessionInClientMode()};
ClientMode clientMode{ClientPatterns::clientMode()};
ReturnAddress getWorldSessionInClientMode;
ClientMode clientMode;
std::size_t referenceCount{0};
};
7 changes: 6 additions & 1 deletion Source/FeatureHelpers/WorldToClipSpaceConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
#include <MemoryPatterns/ClientPatterns.h>

struct WorldToClipSpaceConverter {
explicit WorldToClipSpaceConverter(const ClientPatterns& clientPatterns) noexcept
: worldToProjectionMatrix{clientPatterns.worldToProjectionMatrix()}
{
}

[[nodiscard]] explicit operator bool() const noexcept
{
return worldToProjectionMatrix != nullptr;
Expand All @@ -27,5 +32,5 @@ struct WorldToClipSpaceConverter {
}

private:
const cs2::VMatrix* worldToProjectionMatrix{ ClientPatterns::worldToProjectionMatrix() };
const cs2::VMatrix* worldToProjectionMatrix;
};
7 changes: 4 additions & 3 deletions Source/Features/Features.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
class SniperScopeBlurRemover;

struct Features {
Features(SniperScopeBlurRemover& sniperScopeBlurRemover, LoopModeGameHook& loopModeGameHook, ViewRenderHook& viewRenderHook, SoundWatcher& soundWatcher) noexcept
: visuals{sniperScopeBlurRemover, loopModeGameHook }
, soundFeatures{ viewRenderHook, soundWatcher }
Features(const ClientPatterns& clientPatterns, SniperScopeBlurRemover& sniperScopeBlurRemover, LoopModeGameHook& loopModeGameHook, ViewRenderHook& viewRenderHook, SoundWatcher& soundWatcher) noexcept
: hudFeatures{clientPatterns}
, visuals{clientPatterns, sniperScopeBlurRemover, loopModeGameHook}
, soundFeatures{viewRenderHook, soundWatcher}
{
}

Expand Down
5 changes: 5 additions & 0 deletions Source/Features/Hud/HudFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
#include "KillfeedPreserver.h"

struct HudFeatures {
explicit HudFeatures(const ClientPatterns& clientPatterns) noexcept
: killfeedPreserver{clientPatterns}
{
}

BombTimer bombTimer;
DefusingAlert defusingAlert;
KillfeedPreserver killfeedPreserver;
Expand Down
7 changes: 6 additions & 1 deletion Source/Features/Hud/KillfeedPreserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

class KillfeedPreserver : public TogglableFeature<KillfeedPreserver> {
public:
explicit KillfeedPreserver(const ClientPatterns& clientPatterns) noexcept
: gameRules{clientPatterns.gameRules()}
{
}

void run(const KillfeedPreserverHelpers& params) noexcept
{
if (!isEnabled())
Expand Down Expand Up @@ -80,7 +85,7 @@ class KillfeedPreserver : public TogglableFeature<KillfeedPreserver> {

friend TogglableFeature;

cs2::C_CSGameRules** gameRules{ ClientPatterns::gameRules() };
cs2::C_CSGameRules** gameRules;

cs2::CPanoramaSymbol deathNoticeKillerSymbol{ -1 };
cs2::CPanoramaSymbol spawnTimeSymbol{ -1 };
Expand Down
7 changes: 6 additions & 1 deletion Source/Features/Visuals/ScopeOverlayRemover/HudScopePanels.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
#include <Helpers/PanoramaPanelPointer.h>

struct HudScopePanels {
explicit HudScopePanels(const ClientPatterns& clientPatterns) noexcept
: mainMenu{clientPatterns.mainMenuPanel()->uiPanel}
{
}

void updatePanelPointers(HudProvider hudProvider) noexcept
{
if (!shouldUpdatePanelPointers())
Expand Down Expand Up @@ -38,7 +43,7 @@ struct HudScopePanels {
return mainMenu.findChildInLayoutFile(cs2::HudScope);
}

PanoramaUiPanel mainMenu{ ClientPatterns::mainMenuPanel()->uiPanel };
PanoramaUiPanel mainMenu;
PanoramaPanelPointer scopeCirclePointer;
PanoramaPanelPointer scopeDustPointer;
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@

class ScopeOverlayRemover : public TogglableFeature<ScopeOverlayRemover> {
public:
ScopeOverlayRemover(LoopModeGameHook& loopModeGameHook, SniperScopeBlurRemover& sniperScopeBlurRemover) noexcept
: loopModeGameHook{loopModeGameHook}
ScopeOverlayRemover(const ClientPatterns& clientPatterns, LoopModeGameHook& loopModeGameHook, SniperScopeBlurRemover& sniperScopeBlurRemover) noexcept
: hudScope{clientPatterns.hudScope()}
, loopModeGameHook{loopModeGameHook}
, sniperScopeBlurRemover{sniperScopeBlurRemover}
, hudScopePanels{clientPatterns}
{
}

Expand Down Expand Up @@ -65,7 +67,7 @@ class ScopeOverlayRemover : public TogglableFeature<ScopeOverlayRemover> {
hudScopePanels.setPanelsVisible(true);
}

cs2::CPanel2D** hudScope{ ClientPatterns::hudScope() };
cs2::CPanel2D** hudScope;
LoopModeGameHook& loopModeGameHook;
SniperScopeBlurRemover& sniperScopeBlurRemover;
HudScopePanels hudScopePanels;
Expand Down
4 changes: 2 additions & 2 deletions Source/Features/Visuals/VisualFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class LoopModeGameHook;
class SniperScopeBlurRemover;

struct VisualFeatures {
VisualFeatures(SniperScopeBlurRemover& sniperScopeBlurRemover, LoopModeGameHook& loopModeGameHook) noexcept
: scopeOverlayRemover{loopModeGameHook, sniperScopeBlurRemover}
VisualFeatures(const ClientPatterns& clientPatterns, SniperScopeBlurRemover& sniperScopeBlurRemover, LoopModeGameHook& loopModeGameHook) noexcept
: scopeOverlayRemover{clientPatterns, loopModeGameHook, sniperScopeBlurRemover}
, sniperScopeBlurRemoval{loopModeGameHook, sniperScopeBlurRemover}
{
}
Expand Down
10 changes: 8 additions & 2 deletions Source/GameClasses/Implementation/ClientModeImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
#include <MemoryPatterns/ClientModePatterns.h>

struct ClientModeImpl {
explicit ClientModeImpl(const ClientModePatterns& clientModePatterns) noexcept
: zoomedSniperEffectWeight{clientModePatterns.zoomedSniperEffectWeightOffset()}
, zoomedMovingSniperEffectWeight{clientModePatterns.zoomedMovingSniperEffectWeightOffset()}
{
}

[[nodiscard]] static const ClientModeImpl& instance() noexcept;

ZoomedSniperEffectWeightOffset zoomedSniperEffectWeight{ ClientModePatterns::zoomedSniperEffectWeightOffset() };
ZoomedMovingSniperEffectWeightOffset zoomedMovingSniperEffectWeight{ ClientModePatterns::zoomedMovingSniperEffectWeightOffset() };
ZoomedSniperEffectWeightOffset zoomedSniperEffectWeight;
ZoomedMovingSniperEffectWeightOffset zoomedMovingSniperEffectWeight;
};
7 changes: 6 additions & 1 deletion Source/GameClasses/Implementation/FileSystemImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
#include <MemoryPatterns/FileSystemPatterns.h>

struct FileSystemImpl {
explicit FileSystemImpl(const FileSystemPatterns& fileSystemPatterns) noexcept
: fileNamesOffset{fileSystemPatterns.fileNamesOffset()}
{
}

[[nodiscard]] static const FileSystemImpl& instance() noexcept;

FileNamesOffset fileNamesOffset{ FileSystemPatterns::fileNamesOffset() };
FileNamesOffset fileNamesOffset;
};
28 changes: 25 additions & 3 deletions Source/GameClasses/Implementation/GameClassImplementations.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,31 @@
#include <Platform/VmtFinder.h>

struct GameClassImplementations {
explicit GameClassImplementations(Tier0Dll tier0Dll) noexcept
: fileNameSymbolTable{tier0Dll}
, memAlloc{tier0Dll}
GameClassImplementations(const ClientModePatterns& clientModePatterns,
const ClientPatterns& clientPatterns,
const FileSystemPatterns& fileSystemPatterns,
const GameRulesPatterns& gameRulesPatterns,
const MemAllocPatterns& memAllocPatterns,
const PanelPatterns& panelPatterns,
const PanelStylePatterns& panelStylePatterns,
const PanoramaImagePanelPatterns& panoramaImagePanelPatterns,
const PanoramaLabelPatterns& panoramaLabelPatterns,
const PanoramaUiEnginePatterns& panoramaUiEnginePatterns,
const PanoramaUiPanelPatterns& panoramaUiPanelPatterns,
const PlantedC4Patterns& plantedC4Patterns,
Tier0Dll tier0Dll) noexcept
: clientMode{clientModePatterns}
, fileNameSymbolTable{tier0Dll}
, fileSystem{fileSystemPatterns}
, gameRules{gameRulesPatterns}
, memAlloc{tier0Dll, memAllocPatterns}
, panel{panelPatterns}
, panelStyle{panelStylePatterns}
, imagePanel{panoramaImagePanelPatterns}
, panoramaLabel{panoramaLabelPatterns}
, uiEngine{clientPatterns, panoramaUiEnginePatterns}
, panoramaUiPanelOffsets{panoramaUiPanelPatterns}
, plantedC4{plantedC4Patterns}
{
}

Expand Down
7 changes: 6 additions & 1 deletion Source/GameClasses/Implementation/GameRulesImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
#include <MemoryPatterns/GameRulesPatterns.h>

struct GameRulesImpl {
explicit GameRulesImpl(const GameRulesPatterns& gameRulesPatterns) noexcept
: roundStartTimeOffset{gameRulesPatterns.roundStartTimeOffset()}
{
}

[[nodiscard]] static const GameRulesImpl& instance() noexcept;

RoundStartTimeOffset roundStartTimeOffset{ GameRulesPatterns::roundStartTimeOffset() };
RoundStartTimeOffset roundStartTimeOffset;
};
7 changes: 4 additions & 3 deletions Source/GameClasses/Implementation/MemAllocImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
#include <Utils/FieldOffset.h>

struct MemAllocImpl {
explicit MemAllocImpl(Tier0Dll tier0Dll) noexcept
: thisptr{ tier0Dll.memAlloc() }
MemAllocImpl(Tier0Dll tier0Dll, const MemAllocPatterns& memAllocPatterns) noexcept
: thisptr{tier0Dll.memAlloc()}
, alloc{memAllocPatterns.allocOffset()}
{
}

[[nodiscard]] static const MemAllocImpl& instance() noexcept;

cs2::IMemAlloc** thisptr;
FieldOffset<const void, cs2::IMemAlloc::Alloc*, std::int8_t> alloc{ MemAllocPatterns::allocOffset() };
FieldOffset<const void, cs2::IMemAlloc::Alloc*, std::int8_t> alloc;
};
7 changes: 6 additions & 1 deletion Source/GameClasses/Implementation/PanelImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
#include <MemoryPatterns/PanelPatterns.h>

struct PanelImpl {
explicit PanelImpl(const PanelPatterns& panelPatterns) noexcept
: create{panelPatterns.create()}
{
}

[[nodiscard]] static const PanelImpl& instance() noexcept;

cs2::CPanel2D::Create* create{ PanelPatterns::create() };
cs2::CPanel2D::Create* create;
};
7 changes: 6 additions & 1 deletion Source/GameClasses/Implementation/PanelStyleImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
#include <MemoryPatterns/PanelStylePatterns.h>

struct PanelStyleImpl {
explicit PanelStyleImpl(const PanelStylePatterns& panelStylePatterns) noexcept
: setProperty{panelStylePatterns.setProperty()}
{
}

[[nodiscard]] static const PanelStyleImpl& instance() noexcept;

cs2::CPanelStyle::SetProperty* setProperty{PanelStylePatterns::setProperty()};
cs2::CPanelStyle::SetProperty* setProperty;
};
7 changes: 6 additions & 1 deletion Source/GameClasses/Implementation/PanoramaImagePanelImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
#include <MemoryPatterns/PanoramaImagePanelPatterns.h>

struct PanoramaImagePanelImpl {
explicit PanoramaImagePanelImpl(const PanoramaImagePanelPatterns& panoramaImagePanelPatterns) noexcept
: setImage{panoramaImagePanelPatterns.setImage()}
{
}

[[nodiscard]] static const PanoramaImagePanelImpl& instance() noexcept;

cs2::CImagePanel::setImage setImage{ PanoramaImagePanelPatterns::setImage() };
cs2::CImagePanel::setImage setImage;
};
7 changes: 6 additions & 1 deletion Source/GameClasses/Implementation/PanoramaLabelImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
#include <MemoryPatterns/PanoramaLabelPatterns.h>

struct PanoramaLabelImpl {
explicit PanoramaLabelImpl(const PanoramaLabelPatterns& panoramaLabelPatterns) noexcept
: setTextInternal{panoramaLabelPatterns.setTextInternal()}
{
}

[[nodiscard]] static const PanoramaLabelImpl& instance() noexcept;

cs2::CLabel::setTextInternal setTextInternal{ PanoramaLabelPatterns::setTextInternal() };
cs2::CLabel::setTextInternal setTextInternal;
};
Loading

0 comments on commit ffaaa8b

Please sign in to comment.