Skip to content

Commit 34e37d4

Browse files
committed
fix: Replaced old Valve types and interface includes with remade ones
1 parent e02fc9b commit 34e37d4

File tree

13 files changed

+81
-137
lines changed

13 files changed

+81
-137
lines changed

src/commands.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,8 @@ CON_COMMAND(p2sm_spmaplist, "")
5353
// BF F0 2D 94 10 84 DB
5454
// GetNumChapters: 55 8B EC 80 7D ?? ?? 57 74
5555

56-
//uintptr_t GetNumChapters = *static_cast<uintptr_t*>(Memory::Scanner::Scan<void*>(CLIENT, "55 8B EC 80 7D 08 00 57 74 0C", 0));//16));
5756
ChapterContext_t** chapterArrayPtr = Memory::Scan<ChapterContext_t**>(MODULE_CLIENT, "55 8B EC 80 7D 08 00 57 74 0C", 16);
5857
const ChapterContext_t* chapterArray = *chapterArrayPtr;
59-
// chapterArray = *reinterpret_cast<ChapterContext_t*>(tempChapterArray + 16);
60-
//chapterArray = reinterpret_cast<ChapterContext_t*>(GetNumChapters + 16);
61-
//chapterArray = static_cast<ChapterContext_t*>(Memory::Scanner::Scan<void*>(CLIENT, "B8 F0 A8 93 10 8D 64 24", 0));
62-
6358

6459
if (!chapterArrayPtr)
6560
{

src/globals.hpp

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77

88
#pragma once
99

10-
#include "eiface.h"
11-
#include "cdll_int.h"
12-
#include "engine/iserverplugin.h"
13-
#include "game/server/iplayerinfo.h"
14-
#include "public/steam/steamclientpublic.h"
15-
#include "irecipientfilter.h"
16-
1710
#include <comdef.h>
1811

1912
#define CUR_MAPFILE_NAME STRING(g_pGlobals->mapname)
@@ -34,14 +27,7 @@
3427
#define FOR_ALL_PLAYERS(i) \
3528
for (int (i) = 1; (i) <= Utils::CurPlayerCount(); (i)++)
3629

37-
// Player team enum.
38-
enum PlayerTeam : std::uint8_t
39-
{
40-
TEAM_SINGLEPLAYER = 0,
41-
TEAM_SPECTATOR,
42-
TEAM_RED,
43-
TEAM_BLUE
44-
};
30+
4531

4632
//---------------------------------------------------------------------------------
4733
// Public variables.
@@ -59,37 +45,4 @@ extern IPlayerInfoManager* g_pPlayerInfoManager;
5945
// extern IServerTools* g_pServerTools;
6046
// extern IGameEventManager2* g_pGameEventManager_;
6147
// extern IServerPluginHelpers* g_pPluginHelpers;
62-
// extern IFileSystem* g_pFileSystem;
63-
64-
//---------------------------------------------------------------------------------
65-
// Player recipient filter.
66-
//---------------------------------------------------------------------------------
67-
class CPlayerFilter : public IRecipientFilter
68-
{
69-
public:
70-
CPlayerFilter(): recipients{} { recipientCount = 0; }
71-
~CPlayerFilter() override = default;
72-
73-
bool IsReliable() const override { return false; }
74-
bool IsInitMessage() const override { return false; }
75-
76-
int GetRecipientCount() const override { return recipientCount; }
77-
78-
int GetRecipientIndex(const int slot) const override
79-
{
80-
return (slot < 0 || slot >= recipientCount) ? -1 : recipients[slot];
81-
}
82-
83-
void AddPlayer(const int playerIndex)
84-
{
85-
if (recipientCount < 256)
86-
{
87-
recipients[recipientCount] = playerIndex;
88-
recipientCount++;
89-
}
90-
}
91-
92-
private:
93-
int recipients[256];
94-
int recipientCount;
95-
};
48+
// extern IFileSystem* g_pFileSystem;

src/modules/cbaseentity.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class Vector;
1414
class IRecipientFilter;
1515
class CBasePlayer;
16-
struct edict_t;
16+
struct Edict;
1717
typedef struct HSCRIPT__* HSCRIPT;
1818

1919
class CBaseEntity

src/modules/cbaseplayer.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
#include "stdafx.hpp"
99
#include "modules/cbaseplayer.hpp"
1010

11-
#include <KeyValues.h>
12-
1311
#include "utils.hpp"
1412

1513
void CBasePlayer::ShowViewPortPanel(const int playerIndex, const char* name, const bool bShow, KeyValues* data)

src/modules/cportal_player.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
#include "stdafx.hpp"
99
#include "modules/cportal_player.hpp"
1010

11-
#include <const.h>
12-
1311
#include "modules/cbaseentity.hpp"
1412
#include "modules/cbaseplayer.hpp"
1513

src/modules/misc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ DETOUR_T(void, CUGCFileRequestManager::Update)
2626
}
2727

2828
/**
29-
* @brief func_precipitation entity brushes are bugged where they need to set to the world origin to function properly.
29+
* @brief func_precipitation entity brushes are bugged where they need to set to the world origin to function properly.
3030
*/
3131
DEFINE_HOOK(CPrecipitation, Spawn);
3232
DETOUR_T(void, CPrecipitation::Spawn)

src/p2sm.cpp

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22
//
33
// Authors: Orsell & Nanoman2525 & NULLderef
44
// Purpose: P2SourceMod++ Plugin
5-
//
5+
//
66
//===========================================================================//
77

88
#include "stdafx.hpp"
99
#include "p2sm.hpp"
1010

11-
#include <cdll_int.h> // Client interfacing
12-
#include <eiface.h> // Server interfacing
13-
1411
#include "modules/gui.hpp"
1512

1613
#include "utils.hpp"
@@ -248,7 +245,7 @@ void CP2SMPlusPlusPlugin::Unload(void)
248245
Log(INFO, false, "Plugin unloaded! Goodbye!");
249246
}
250247

251-
void CP2SMPlusPlusPlugin::ClientFullyConnect(edict_t* pEntity)
248+
void CP2SMPlusPlusPlugin::ClientFullyConnect(Edict* pEntity)
252249
{
253250
// Make sure the r_drawscreenoverlay ConVar is enabled for connecting clients.
254251
engineServer->ClientCommand(pEntity, "r_drawscreenoverlay 1");
@@ -259,23 +256,19 @@ void CP2SMPlusPlusPlugin::ClientFullyConnect(edict_t* pEntity)
259256
// Purpose: Unused callbacks
260257
//---------------------------------------------------------------------------------
261258
#pragma region UNUSED_CALLBACKS
262-
void CP2SMPlusPlusPlugin::SetCommandClient(int index) {}
263-
void CP2SMPlusPlusPlugin::ServerActivate(edict_t* pEdictList, int edictCount, int clientMax) {}
264-
void CP2SMPlusPlusPlugin::LevelInit(char const* pMapName) {}
265-
PLUGIN_RESULT CP2SMPlusPlusPlugin::ClientCommand(edict_t* pEntity, const CCommand& args) { return PLUGIN_CONTINUE; }
266-
void CP2SMPlusPlusPlugin::ClientActive(edict_t* pEntity) {}
267-
void CP2SMPlusPlusPlugin::GameFrame(bool simulating) {}
268-
void CP2SMPlusPlusPlugin::LevelShutdown(void) {}
269-
void CP2SMPlusPlusPlugin::Pause(void) {}
270-
void CP2SMPlusPlusPlugin::UnPause(void) {}
271-
void CP2SMPlusPlusPlugin::ClientDisconnect(edict_t* pEntity) {}
272-
void CP2SMPlusPlusPlugin::ClientPutInServer(edict_t* pEntity, char const* playerName) {}
273-
void CP2SMPlusPlusPlugin::ClientSettingsChanged(edict_t* pEdict) {}
274-
PLUGIN_RESULT CP2SMPlusPlusPlugin::ClientConnect(bool* bAllowConnect, edict_t* pEntity, const char* pszName, const char* pszAddress, char* reject, int maxRejectLen) { return PLUGIN_CONTINUE; }
275-
PLUGIN_RESULT CP2SMPlusPlusPlugin::NetworkIDValidated(const char* pszUserName, const char* pszNetworkID) { return PLUGIN_CONTINUE; }
276-
void CP2SMPlusPlusPlugin::OnQueryCvarValueFinished(QueryCvarCookie_t iCookie, edict_t* pPlayerEntity, EQueryCvarValueStatus eStatus, const char* pCvarName, const char* pCvarValue) {}
277-
void CP2SMPlusPlusPlugin::OnEdictAllocated(edict_t* edict) {}
278-
void CP2SMPlusPlusPlugin::OnEdictFreed(const edict_t* edict) {}
279-
bool CP2SMPlusPlusPlugin::BNetworkCryptKeyCheckRequired(uint32 unFromIP, uint16 usFromPort, uint32 unAccountIdProvidedByClient, bool bClientWantsToUseCryptKey) { return false; }
280-
bool CP2SMPlusPlusPlugin::BNetworkCryptKeyValidate(uint32 unFromIP, uint16 usFromPort, uint32 unAccountIdProvidedByClient, int nEncryptionKeyIndexFromClient, int numEncryptedBytesFromClient, byte* pbEncryptedBufferFromClient, byte* pbPlainTextKeyForNetchan) { return true; }
259+
void Pause() {}
260+
void UnPause() {}
261+
void ServerActivate(Edict* edictList, int edictCount, int clientMax) {}
262+
void GameFrame(bool simulating) {}
263+
void ClientActive(Edict* edict) {}
264+
void ClientDisconnect(Edict* edict) {}
265+
void ClientPutInServer(Edict* edict, char const* playerName) {}
266+
void SetCommandClient(int index) {}
267+
void ClientSettingsChanged(Edict* edict) {}
268+
PluginResult ClientConnect(bool* allowConnect, Edict* edict, const char* name, const char* ipAddress, char* reject, int maxRejectLen) { return PluginResult::Continue; }
269+
PluginResult ClientCommand(Edict* edict, const CCommand& args) { return PluginResult::Continue; }
270+
PluginResult NetworkIDValidated(const char* username, const char* networkID) { return PluginResult::Continue; }
271+
void OnQueryCvarValueFinished(QueryCvarCookie cookie, Edict* edict, QueryCvarValueStatus status, const char* cvarName, const char* cvarValue) {}
272+
void OnEdictAllocated(Edict* edict) {}
273+
void OnEdictFreed(const Edict* edict) {}
281274
#pragma endregion

src/p2sm.hpp

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,64 @@
22
//
33
// Authors: Orsell & Nanoman2525 & NULLderef
44
// Purpose: P2SourceModPlusPlus plugin
5-
//
5+
//
66
//===========================================================================//
77

88
#pragma once
99

1010
#ifndef P2SM_HPP
1111
#define P2SM_HPP
1212

13-
#include "engine/iserverplugin.h"
13+
#include "interfaces/serverplugin.hpp"
14+
#include "interfaces/gameevents.hpp"
1415

1516
#define P2SMPLUSPLUS_PLUGIN_VERSION "1.2.0 PREVIEW" // Update this when a new version of the plugin is released.
1617

1718
//---------------------------------------------------------------------------------
1819
// Purpose: P2SourceModPlusPlus server plugin class
1920
//---------------------------------------------------------------------------------
2021

21-
class CP2SMPlusPlusPlugin : public IServerPluginCallbacks
22+
class CP2SMPlusPlusPlugin : public IServerPluginCallbacks, public IGameEventListener2
2223
{
2324
public:
2425
CP2SMPlusPlusPlugin();
2526
virtual ~CP2SMPlusPlusPlugin() = default;
2627

27-
// IServerPluginCallbacks methods.
28-
virtual bool Load(CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory);
29-
virtual void Unload(void);
30-
virtual void Pause(void);
31-
virtual void UnPause(void);
32-
virtual const char* GetPluginDescription(void);
33-
virtual void LevelInit(char const* pMapName);
34-
virtual void ServerActivate(edict_t* pEdictList, int edictCount, int clientMax);
35-
virtual void GameFrame(bool simulating);
36-
virtual void LevelShutdown(void);
37-
virtual void ClientActive(edict_t* pEntity);
38-
virtual void ClientDisconnect(edict_t* pEntity);
39-
virtual void ClientPutInServer(edict_t* pEntity, char const* playerName);
40-
virtual void SetCommandClient(int index);
41-
virtual void ClientSettingsChanged(edict_t* pEdict);
42-
virtual PLUGIN_RESULT ClientConnect(bool* bAllowConnect, edict_t* pEntity, const char* pszName, const char* pszAddress, char* reject, int maxRejectLen);
43-
virtual void ClientFullyConnect(edict_t* pEntity);
44-
virtual PLUGIN_RESULT ClientCommand(edict_t* pEntity, const CCommand& args);
45-
virtual PLUGIN_RESULT NetworkIDValidated(const char* pszUserName, const char* pszNetworkID);
46-
virtual void OnQueryCvarValueFinished(QueryCvarCookie_t iCookie, edict_t* pPlayerEntity, EQueryCvarValueStatus eStatus, const char* pCvarName, const char* pCvarValue);
47-
virtual void OnEdictAllocated(edict_t* edict);
48-
virtual void OnEdictFreed(const edict_t* edict);
49-
virtual bool BNetworkCryptKeyCheckRequired(uint32 unFromIP, uint16 usFromPort, uint32 unAccountIdProvidedByClient, bool bClientWantsToUseCryptKey);
50-
virtual bool BNetworkCryptKeyValidate(uint32 unFromIP, uint16 usFromPort, uint32 unAccountIdProvidedByClient, int nEncryptionKeyIndexFromClient, int numEncryptedBytesFromClient, byte* pbEncryptedBufferFromClient, byte* pbPlainTextKeyForNetchan);
28+
bool Load(CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory) override;
29+
void Unload() override;
30+
void Pause() override;
31+
void UnPause() override;
32+
const char* GetPluginDescription() override;
33+
void LevelInit(const char* mapName) override;
34+
void ServerActivate(Edict* edictList, int edictCount, int clientMax) override;
35+
void GameFrame(bool simulating) override;
36+
void LevelShutdown() override;
37+
void ClientActive(Edict* edict) override;
38+
void ClientFullyConnect(Edict* edict) override;
39+
void ClientDisconnect(Edict* edict) override;
40+
void ClientPutInServer(Edict* edict, char const* playerName) override;
41+
void SetCommandClient(int index) override;
42+
void ClientSettingsChanged(Edict* edict) override;
43+
PluginResult ClientConnect(bool* allowConnect, Edict* edict, const char* name, const char* ipAddress, char* reject, int maxRejectLen) override;
44+
PluginResult ClientCommand(Edict* edict, const CCommand& args) override;
45+
PluginResult NetworkIDValidated(const char* username, const char* networkID) override;
46+
void OnQueryCvarValueFinished(QueryCvarCookie cookie, Edict* edict, QueryCvarValueStatus status, const char* cvarName, const char* cvarValue) override;
47+
void OnEdictAllocated(Edict* edict) override;
48+
void OnEdictFreed(const Edict* edict) override;
49+
50+
// IGameEventListener2 methods
51+
virtual void FireGameEvent(IGameEvent* event);
52+
virtual int GetEventDebugID(void) { return m_nDebugID; }
53+
54+
virtual int GetCommandIndex() { return m_iClientCommandIndex; }
5155

5256
private:
5357
// Plugin state member variables.
5458
bool m_bPluginLoaded;
5559
bool m_bNoUnload;
60+
61+
int m_nDebugID;
62+
int m_iClientCommandIndex;
5663
};
5764

5865
static CP2SMPlusPlusPlugin g_P2SMPlusPlusPlugin;

src/stdafx.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,5 @@
3636
#include <sstream>
3737
#include <filesystem>
3838
#include <cstdint>
39-
#include <strtools.h>
40-
41-
// MARK: Common Valve types/used includes
42-
#include <mathlib/vector.h>
4339

4440
#endif

src/utils.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ int Utils::UserIDToPlayerIndex(const int userid)
2121
{
2222
for (int i = 1; i <= MAX_PLAYERS; i++)
2323
{
24-
const edict_t* pEdict = nullptr;
24+
const Edict* pEdict = nullptr;
2525
if (i >= 0 && i < g_pGlobals->maxEntities)
2626
pEdict = (g_pGlobals->pEdicts + i);
2727

@@ -61,7 +61,7 @@ const char* Utils::GetPlayerName(const int playerIndex)
6161
*/
6262
int Utils::GetSteamID(const int playerIndex)
6363
{
64-
edict_t* pEdict = nullptr;
64+
Edict* pEdict = nullptr;
6565
if (playerIndex >= 0 && playerIndex < MAX_PLAYERS)
6666
pEdict = (g_pGlobals->pEdicts + playerIndex);
6767

@@ -200,7 +200,7 @@ int Utils::CurPlayerCount()
200200
*/
201201
HSCRIPT Utils::EntIndexScriptHandle(const int entityIndex)
202202
{
203-
edict_t* pEdict = IndexToEdict(entityIndex);
203+
Edict* pEdict = IndexToEdict(entityIndex);
204204
if (!pEdict->GetUnknown())
205205
return nullptr;
206206

@@ -302,7 +302,7 @@ int Utils::EntityIndex(CBaseEntity* pEntity)
302302
* @param pEdict Pointer to edict.
303303
* @return Entity index for edict.
304304
*/
305-
int Utils::EdictIndex(const edict_t* pEdict)
305+
int Utils::EdictIndex(const Edict* pEdict)
306306
{
307307
if (!pEdict)
308308
return 0;
@@ -316,12 +316,12 @@ int Utils::EdictIndex(const edict_t* pEdict)
316316
* @param entityIndex Entity index.
317317
* @return Edict of entity index.
318318
*/
319-
edict_t* Utils::IndexToEdict(const int entityIndex)
319+
Edict* Utils::IndexToEdict(const int entityIndex)
320320
{
321321
assert(entityIndex >= 0 && entityIndex < MAX_EDICTS);
322322
if (g_pGlobals->pEdicts)
323323
{
324-
edict_t* pEdict = g_pGlobals->pEdicts + entityIndex;
324+
Edict* pEdict = g_pGlobals->pEdicts + entityIndex;
325325
if (pEdict->IsFree())
326326
return nullptr;
327327
return pEdict;
@@ -334,7 +334,7 @@ edict_t* Utils::IndexToEdict(const int entityIndex)
334334
* @param pEntity Pointer to entity.
335335
* @return Edict of CBaseEntity.
336336
*/
337-
edict_t* Utils::EntityToEdict(CBaseEntity* pEntity)
337+
Edict* Utils::EntityToEdict(CBaseEntity* pEntity)
338338
{
339339
return IndexToEdict(EntityIndex(pEntity));
340340
}

0 commit comments

Comments
 (0)