Skip to content

Commit 40fad43

Browse files
committed
Signatures implementation and cleanup
- feat: reimplemented the signature namespace macro - chore: removed whitespace and garbage in files
1 parent 4ba5c3e commit 40fad43

24 files changed

+220
-219
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
> 2. Compatibility will not be 100%, so expect bugs or other issues.
1515
> 3. If you are using this plugin with your mod, I am not responsible if anything bad happens to your mod's page on Steam.
1616
>
17-
> Ideally, if you wish to have some of these features but want to be able to have your mod on Steam, wait for P2:CE to release rather than using this.
18-
>
17+
> Ideally, if you wish to have some of these features but want to be able to have your mod on Steam, wait for P2:CE to release rather than using this.
18+
>
1919
> I will, in the future, try to add custom elements involving interactions with Steam's API, like achievements, but for now, I don't expect this to work correctly with Steam mods. Plus, in the end, P2:CE will do this properly in the future.
2020
2121
### Features Implemented/Potentially Plan to Implement:

src/commands.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ static void ChangePtexVolumetricState(IConVar* var, const char* pOldValue, float
2626
if (dynamic_cast<ConVar*>(var)->GetBool())
2727
{
2828
Log(INFO, false, "Enabled volumetrics for projected textures...");
29-
Memory::ReplacePattern("engine", Signature::CShadowMgr_DrawVolumetrics_VolState, Signature::CShadowMgr_DrawVolumetrics_VolState_Patch);
29+
Memory::ReplacePattern("engine", Signatures::CShadowMgr_DrawVolumetrics_VolState, Signatures::CShadowMgr_DrawVolumetrics_VolState_Patch);
3030
}
3131
else
3232
{
3333
Log(INFO, false, "Disabled volumetrics for projected textures...");
34-
Memory::ReplacePattern("engine", Signature::CShadowMgr_DrawVolumetrics_VolState_Patch, Signature::CShadowMgr_DrawVolumetrics_VolState);
34+
Memory::ReplacePattern("engine", Signatures::CShadowMgr_DrawVolumetrics_VolState_Patch, Signatures::CShadowMgr_DrawVolumetrics_VolState);
3535
}
3636
}
3737
ConVar p2sm_ptex_volumetrics("p2sm_ptex_volumetrics", "0", FCVAR_NONE, "Enable or disable volumetrics for projected textures.", ChangePtexVolumetricState);
@@ -52,21 +52,21 @@ CON_COMMAND(p2sm_spmaplist, "")
5252
{
5353
// BF F0 2D 94 10 84 DB
5454
// GetNumChapters: 55 8B EC 80 7D ?? ?? 57 74
55-
55+
5656
//uintptr_t GetNumChapters = *static_cast<uintptr_t*>(Memory::Scanner::Scan<void*>(CLIENT, "55 8B EC 80 7D 08 00 57 74 0C", 0));//16));
5757
ChapterContext_t** chapterArrayPtr = Memory::Scan<ChapterContext_t**>(MODULE_CLIENT, "55 8B EC 80 7D 08 00 57 74 0C", 16);
5858
const ChapterContext_t* chapterArray = *chapterArrayPtr;
5959
// chapterArray = *reinterpret_cast<ChapterContext_t*>(tempChapterArray + 16);
6060
//chapterArray = reinterpret_cast<ChapterContext_t*>(GetNumChapters + 16);
6161
//chapterArray = static_cast<ChapterContext_t*>(Memory::Scanner::Scan<void*>(CLIENT, "B8 F0 A8 93 10 8D 64 24", 0));
6262

63-
63+
6464
if (!chapterArrayPtr)
6565
{
6666
Log(WARNING, false, "Failed to get chapterArray!");
6767
return;
6868
}
69-
69+
7070
for (int i = 0; chapterArray[i].mapName != nullptr; i++)
7171
{
7272
Log(INFO, false, "Map: %s, Chapter: %d, Subchapter: %d\n",
@@ -80,5 +80,5 @@ CON_COMMAND(p2sm_spmaplist, "")
8080

8181
*chapterArrayPtr = newChapters;
8282

83-
84-
}
83+
84+
}

src/globals.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// Author: Orsell
44
// Purpose: Global functions & variables used repeatedly throughout the plugin
5-
//
5+
//
66
//===========================================================================//
77

88
#pragma once
@@ -14,7 +14,7 @@
1414
#include "public/steam/steamclientpublic.h"
1515
#include "irecipientfilter.h"
1616

17-
#include <comdef.h>
17+
#include <comdef.h>
1818

1919
#define CUR_MAPFILE_NAME STRING(g_pGlobals->mapname)
2020
#define MAX_PLAYERS g_pGlobals->maxClients
@@ -39,7 +39,7 @@ enum PlayerTeam : std::uint8_t
3939
{
4040
TEAM_SINGLEPLAYER = 0,
4141
TEAM_SPECTATOR,
42-
TEAM_RED,
42+
TEAM_RED,
4343
TEAM_BLUE
4444
};
4545

@@ -92,4 +92,4 @@ class CPlayerFilter : public IRecipientFilter
9292
private:
9393
int recipients[256];
9494
int recipientCount;
95-
};
95+
};

src/modules/cbaseentity.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void CBaseEntity::RemoveEntity(CBaseEntity* pEntity)
2424
{
2525
if (!pEntity)
2626
return;
27-
27+
2828
static auto removeEntity = reinterpret_cast<void (__cdecl*)(void*)>(Memory::Scan<void*>(MODULE_SERVER, "55 8B EC 57 8B 7D 08 85 FF 74 72"));
2929
removeEntity((reinterpret_cast<IServerEntity*>(pEntity)->GetNetworkable()));
3030
}
@@ -66,7 +66,7 @@ HSCRIPT CBaseEntity::GetScriptInstance(CBaseEntity* entity)
6666
* @param filter Filter of recipient entities that can hear this noise.
6767
* @param soundName Sound file path, or script name to play.
6868
* @param pOrigin Position in the world the sound will play.
69-
* @param soundTime Time in seconds till sound is played. NOT HOW LONG SOUND WILL PLAY!
69+
* @param soundTime Time in seconds till sound is played. NOT HOW LONG SOUND WILL PLAY!
7070
* @return Return code for sound.
7171
*/
7272
int CBaseEntity::EmitSound(CBaseEntity* pEntity, int entityIndex, IRecipientFilter& filter, const char* soundName, const Vector* pOrigin, const float soundTime)

src/modules/cbaseentity.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class CBaseEntity
2727
static int EmitSound(CBaseEntity* pEntity, int entityIndex, IRecipientFilter& filter, const char* soundName, const Vector* pOrigin, float soundTime);
2828
static void AddEffects(CBaseEntity* pEntity, int nEffects);
2929
static void RemoveEffects(CBaseEntity* pEntity, int nEffects);
30-
30+
3131
#pragma endregion
3232

3333
private: // MARK: CBaseEntity Private Members

src/modules/cbaseplayer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ class CBasePlayer
1818
#pragma region Public Members
1919

2020
static void ShowViewPortPanel(int playerIndex, const char* name, bool bShow, KeyValues* data);
21-
21+
2222
#pragma endregion
2323

2424
private: // MARK: CBasePlayer Private Members
2525
#pragma region Private Members
2626
#pragma endregion
2727
};
2828

29-
#endif
29+
#endif

src/modules/cportal_player.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ DETOUR_T(bool, CPortal_Player::FlashlightTurnOn, bool playSound)
5656
Log(WARNING, false, "CPortal_Player::FlashlightTurnOn was called with a invalid player!");
5757
return false;
5858
}
59-
59+
6060
CPortal_Player::SetFlashlightState(playerIndex, true);
61-
61+
6262
CPlayerFilter filter;
6363
filter.AddPlayer(playerIndex);
6464
CBaseEntity::EmitSound(pEntity, playerIndex, filter, "HL2Player.FlashLightOn", nullptr, 0.0f);
@@ -80,9 +80,9 @@ DETOUR_T(void, CPortal_Player::FlashlightTurnOff, bool playSound)
8080
Log(WARNING, false, "CPortal_Player::FlashlightTurnOff was called with a invalid player!");
8181
return;
8282
}
83-
83+
8484
CPortal_Player::SetFlashlightState(playerIndex, false);
85-
85+
8686
CPlayerFilter filter;
8787
filter.AddPlayer(playerIndex);
8888
CBaseEntity::EmitSound(pEntity, playerIndex, filter, "HL2Player.FlashLightOff", nullptr, 0.0f);

src/modules/cportal_player.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ class CPortal_Player
4444

4545
static void RespawnPlayer(int playerEntityIndex);
4646
static void SetFlashlightState(int playerEntityIndex, bool enabled);
47-
47+
4848
#pragma endregion
4949

5050
private: // MARK: CPortal_Player Private Members
5151
#pragma region Private Members
5252
#pragma endregion
5353
};
5454

55-
#endif
55+
#endif

src/modules/gui.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ bool GeneralGUI::InitializeGUISystems()
1919
Log(WARNING, false, "Failed to get window handle!");
2020
return false;
2121
}
22-
22+
2323
// Log(INFO, true, "Starting ImGUI...");
2424
// if (!ImGui::Init())
2525
// {
@@ -64,7 +64,7 @@ bool ImGui::Init()
6464
deviceAddressPtr = Memory::Scan(MODULE_SHADERAPIDX9, "A1 ? ? ? ? 6A 00", 1);
6565
else
6666
deviceAddressPtr = Memory::Scan(MODULE_APIVULKAN, "A1 ? ? ? ? 56 84 DB", 1);
67-
67+
6868
if (!deviceAddressPtr)
6969
{
7070
assert(0 && "Failed to get address pointer to the DirectX9 device!");
@@ -86,7 +86,7 @@ bool ImGui::Init()
8686
Log(INFO, false, "Present %p", Present);
8787

8888
// TODO: Add ImGui initialization calls here.
89-
89+
9090
return true;
9191
}
9292

@@ -97,4 +97,4 @@ void ImGui::Shutdown()
9797

9898
HWND GeneralGUI::hWnd = nullptr;
9999
IDirect3DDevice9* ImGui::g_pDXDevice = nullptr;
100-
void* ImGui::Present = nullptr;
100+
void* ImGui::Present = nullptr;

src/modules/gui.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ class GeneralGUI
2626

2727

2828
static bool InitializeGUISystems();
29-
29+
3030
static HWND GetWindowHandle();
31-
31+
3232
#pragma endregion
3333

3434
private: // MARK: WindowsGUI Private Members
@@ -58,23 +58,23 @@ class ImGui
5858
{
5959
public: // MARK: ImGui Public Members
6060
#pragma region Public Members
61-
61+
6262
static bool Init();
6363
static void Shutdown();
6464

6565
#pragma endregion
66-
66+
6767
private: // MARK: ImGui Private Members
6868
#pragma region Private Members
69-
69+
7070
#ifdef _WIN32
7171
static IDirect3DDevice9* g_pDXDevice;
7272
#else
7373
// TODO: Implement SDL and Vulkan devices
7474
#endif
75-
75+
7676
static void* Present;
77-
77+
7878

7979
#pragma endregion
8080
};

0 commit comments

Comments
 (0)