Skip to content

Commit

Permalink
Avoid finding Tier0Dll twice
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkrupinski committed Oct 27, 2023
1 parent 63e77a5 commit 03e9c0a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
7 changes: 6 additions & 1 deletion Source/GameClasses/Implementation/FileNameSymbolTableImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
#include <GameDLLs/Tier0Dll.h>

struct FileNameSymbolTableImpl {
explicit FileNameSymbolTableImpl(Tier0Dll tier0Dll) noexcept
: string{ tier0Dll.filenameSymbolTableString() }
{
}

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

cs2::CUtlFilenameSymbolTable::String* string{ Tier0Dll{}.filenameSymbolTableString() };
cs2::CUtlFilenameSymbolTable::String* string;
};
6 changes: 6 additions & 0 deletions Source/GameClasses/Implementation/GameClassImplementations.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
#include "PlantedC4Impl.h"

struct GameClassImplementations {
explicit GameClassImplementations(Tier0Dll tier0Dll) noexcept
: fileNameSymbolTable{ tier0Dll }
, memAlloc{ tier0Dll }
{
}

ClientModeImpl clientMode;
FileNameSymbolTableImpl fileNameSymbolTable;
FileSystemImpl fileSystem;
Expand Down
7 changes: 6 additions & 1 deletion Source/GameClasses/Implementation/MemAllocImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@
#include <Utils/FieldOffset.h>

struct MemAllocImpl {
explicit MemAllocImpl(Tier0Dll tier0Dll) noexcept
: thisptr{ tier0Dll.memAlloc() }
{
}

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

cs2::IMemAlloc** thisptr{ Tier0Dll{}.memAlloc() };
cs2::IMemAlloc** thisptr;
FieldOffset<const void, cs2::IMemAlloc::Alloc*, std::int8_t> alloc{ MemAllocPatterns::allocOffset() };
};
2 changes: 1 addition & 1 deletion Source/GlobalContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct GlobalContext {
if (initializedFromGameThread)
return;

gameClasses.init();
gameClasses.init(Tier0Dll{});
const VmtLengthCalculator clientVmtLengthCalculator{ DynamicLibrary{cs2::CLIENT_DLL}.getCodeSection(), DynamicLibrary{cs2::CLIENT_DLL}.getVmtSection() };
hooks.init(clientVmtLengthCalculator);
features.init(HudProvider{}, hooks->loopModeGameHook, hooks->viewRenderHook);
Expand Down

0 comments on commit 03e9c0a

Please sign in to comment.