Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf580a7134 | ||
|
|
2fdb11ef1e |
@@ -36,11 +36,7 @@
|
|||||||
|
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
SH_DECL_HOOK1_void(ICvar, UnregisterConCommand, SH_NOATTRIB, 0, ConCommandBase *);
|
SH_DECL_HOOK1_void(ICvar, UnregisterConCommand, SH_NOATTRIB, 0, ConCommandBase *);
|
||||||
#if SOURCE_ENGINE == SE_CSGO
|
|
||||||
SH_DECL_HOOK2_void(ICvar, RegisterConCommand, SH_NOATTRIB, 0, ConCommandBase *, bool);
|
|
||||||
#else
|
|
||||||
SH_DECL_HOOK1_void(ICvar, RegisterConCommand, SH_NOATTRIB, 0, ConCommandBase *);
|
SH_DECL_HOOK1_void(ICvar, RegisterConCommand, SH_NOATTRIB, 0, ConCommandBase *);
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
SH_DECL_HOOK1_void(ICvar, RegisterConCommandBase, SH_NOATTRIB, 0, ConCommandBase *);
|
SH_DECL_HOOK1_void(ICvar, RegisterConCommandBase, SH_NOATTRIB, 0, ConCommandBase *);
|
||||||
#endif
|
#endif
|
||||||
@@ -82,11 +78,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_CSGO
|
|
||||||
void LinkConCommandBase(ConCommandBase *pBase, bool unknown)
|
|
||||||
#else
|
|
||||||
void LinkConCommandBase(ConCommandBase *pBase)
|
void LinkConCommandBase(ConCommandBase *pBase)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
IConCommandLinkListener *listener = IConCommandLinkListener::head;
|
IConCommandLinkListener *listener = IConCommandLinkListener::head;
|
||||||
while (listener)
|
while (listener)
|
||||||
|
|||||||
@@ -112,7 +112,6 @@ IServerTools *servertools = NULL;
|
|||||||
|
|
||||||
// global hooks and forwards
|
// global hooks and forwards
|
||||||
IForward *g_pOnEntityCreated = NULL;
|
IForward *g_pOnEntityCreated = NULL;
|
||||||
IForward *g_pOnEntitySpawned = NULL;
|
|
||||||
IForward *g_pOnEntityDestroyed = NULL;
|
IForward *g_pOnEntityDestroyed = NULL;
|
||||||
|
|
||||||
#ifdef GAMEDESC_CAN_CHANGE
|
#ifdef GAMEDESC_CAN_CHANGE
|
||||||
@@ -253,7 +252,6 @@ bool SDKHooks::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
plsys->AddPluginsListener(&g_Interface);
|
plsys->AddPluginsListener(&g_Interface);
|
||||||
|
|
||||||
g_pOnEntityCreated = forwards->CreateForward("OnEntityCreated", ET_Ignore, 2, NULL, Param_Cell, Param_String);
|
g_pOnEntityCreated = forwards->CreateForward("OnEntityCreated", ET_Ignore, 2, NULL, Param_Cell, Param_String);
|
||||||
g_pOnEntitySpawned = forwards->CreateForward("OnEntitySpawned", ET_Ignore, 2, NULL, Param_Cell, Param_String);
|
|
||||||
g_pOnEntityDestroyed = forwards->CreateForward("OnEntityDestroyed", ET_Ignore, 1, NULL, Param_Cell);
|
g_pOnEntityDestroyed = forwards->CreateForward("OnEntityDestroyed", ET_Ignore, 1, NULL, Param_Cell);
|
||||||
#ifdef GAMEDESC_CAN_CHANGE
|
#ifdef GAMEDESC_CAN_CHANGE
|
||||||
g_pOnGetGameNameDescription = forwards->CreateForward("OnGetGameDescription", ET_Hook, 2, NULL, Param_String);
|
g_pOnGetGameNameDescription = forwards->CreateForward("OnGetGameDescription", ET_Hook, 2, NULL, Param_String);
|
||||||
@@ -346,7 +344,6 @@ void SDKHooks::SDK_OnUnload()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
forwards->ReleaseForward(g_pOnEntityCreated);
|
forwards->ReleaseForward(g_pOnEntityCreated);
|
||||||
forwards->ReleaseForward(g_pOnEntitySpawned);
|
|
||||||
forwards->ReleaseForward(g_pOnEntityDestroyed);
|
forwards->ReleaseForward(g_pOnEntityDestroyed);
|
||||||
#ifdef GAMEDESC_CAN_CHANGE
|
#ifdef GAMEDESC_CAN_CHANGE
|
||||||
forwards->ReleaseForward(g_pOnGetGameNameDescription);
|
forwards->ReleaseForward(g_pOnGetGameNameDescription);
|
||||||
@@ -423,7 +420,6 @@ void SDKHooks::OnClientPutInServer(int client)
|
|||||||
CBaseEntity *pPlayer = gamehelpers->ReferenceToEntity(client);
|
CBaseEntity *pPlayer = gamehelpers->ReferenceToEntity(client);
|
||||||
|
|
||||||
HandleEntityCreated(pPlayer, client, gamehelpers->EntityToReference(pPlayer));
|
HandleEntityCreated(pPlayer, client, gamehelpers->EntityToReference(pPlayer));
|
||||||
HandleEntitySpawned(pPlayer, client, gamehelpers->EntityToReference(pPlayer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDKHooks::OnClientDisconnecting(int client)
|
void SDKHooks::OnClientDisconnecting(int client)
|
||||||
@@ -883,27 +879,6 @@ void SDKHooks::OnEntityCreated(CBaseEntity *pEntity)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDKHooks::OnEntitySpawned(CBaseEntity *pEntity)
|
|
||||||
{
|
|
||||||
// Call OnEntitySpawned forward
|
|
||||||
int ref = gamehelpers->EntityToReference(pEntity);
|
|
||||||
int index = gamehelpers->ReferenceToIndex(ref);
|
|
||||||
|
|
||||||
// This can be -1 for player ents before any players have connected
|
|
||||||
if ((unsigned)index == INVALID_EHANDLE_INDEX || (index > 0 && index <= playerhelpers->GetMaxClients()))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!IsEntityIndexInRange(index))
|
|
||||||
{
|
|
||||||
g_pSM->LogError(myself, "SDKHooks::OnEntitySpawned - Got entity index out of range (%d)", index);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
HandleEntitySpawned(pEntity, index, ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef GAMEDESC_CAN_CHANGE
|
#ifdef GAMEDESC_CAN_CHANGE
|
||||||
const char *SDKHooks::Hook_GetGameDescription()
|
const char *SDKHooks::Hook_GetGameDescription()
|
||||||
{
|
{
|
||||||
@@ -1816,32 +1791,6 @@ void SDKHooks::HandleEntityCreated(CBaseEntity *pEntity, int index, cell_t ref)
|
|||||||
m_EntityCache[index] = ref;
|
m_EntityCache[index] = ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDKHooks::HandleEntitySpawned(CBaseEntity *pEntity, int index, cell_t ref)
|
|
||||||
{
|
|
||||||
if (g_pOnEntitySpawned->GetFunctionCount() || m_EntListeners.size())
|
|
||||||
{
|
|
||||||
cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity);
|
|
||||||
const char *pName = gamehelpers->GetEntityClassname(pEntity);
|
|
||||||
if (!pName)
|
|
||||||
pName = "";
|
|
||||||
|
|
||||||
// Send OnEntitySpawned to SM listeners
|
|
||||||
for (SourceHook::List<ISMEntityListener *>::iterator iter = m_EntListeners.begin(); iter != m_EntListeners.end(); iter++)
|
|
||||||
{
|
|
||||||
ISMEntityListener *pListener = (*iter);
|
|
||||||
pListener->OnEntitySpawned(pEntity, pName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Call OnEntitySpawned forward
|
|
||||||
if (g_pOnEntitySpawned->GetFunctionCount())
|
|
||||||
{
|
|
||||||
g_pOnEntitySpawned->PushCell(bcompatRef);
|
|
||||||
g_pOnEntitySpawned->PushString(pName);
|
|
||||||
g_pOnEntitySpawned->Execute(NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SDKHooks::HandleEntityDeleted(CBaseEntity *pEntity)
|
void SDKHooks::HandleEntityDeleted(CBaseEntity *pEntity)
|
||||||
{
|
{
|
||||||
cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity);
|
cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity);
|
||||||
|
|||||||
@@ -238,7 +238,6 @@ public: // IFeatureProvider
|
|||||||
|
|
||||||
public: // IEntityListener
|
public: // IEntityListener
|
||||||
virtual void OnEntityCreated(CBaseEntity *pEntity);
|
virtual void OnEntityCreated(CBaseEntity *pEntity);
|
||||||
virtual void OnEntitySpawned(CBaseEntity *pEntity);
|
|
||||||
virtual void OnEntityDeleted(CBaseEntity *pEntity);
|
virtual void OnEntityDeleted(CBaseEntity *pEntity);
|
||||||
|
|
||||||
public: // IClientListener
|
public: // IClientListener
|
||||||
@@ -331,7 +330,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void HandleEntityCreated(CBaseEntity *pEntity, int index, cell_t ref);
|
void HandleEntityCreated(CBaseEntity *pEntity, int index, cell_t ref);
|
||||||
void HandleEntitySpawned(CBaseEntity *pEntity, int index, cell_t ref);
|
|
||||||
void HandleEntityDeleted(CBaseEntity *pEntity);
|
void HandleEntityDeleted(CBaseEntity *pEntity);
|
||||||
void Unhook(CBaseEntity *pEntity);
|
void Unhook(CBaseEntity *pEntity);
|
||||||
void Unhook(IPluginContext *pContext);
|
void Unhook(IPluginContext *pContext);
|
||||||
|
|||||||
@@ -615,10 +615,7 @@ native int FormatNativeString(int out_param,
|
|||||||
*
|
*
|
||||||
* @param data Data passed to the RequestFrame native.
|
* @param data Data passed to the RequestFrame native.
|
||||||
*/
|
*/
|
||||||
typeset RequestFrameCallback {
|
typedef RequestFrameCallback = function void (any data);
|
||||||
function void ();
|
|
||||||
function void (any data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a single use Next Frame hook.
|
* Creates a single use Next Frame hook.
|
||||||
|
|||||||
@@ -333,14 +333,6 @@ typeset SDKHookCB
|
|||||||
*/
|
*/
|
||||||
forward void OnEntityCreated(int entity, const char[] classname);
|
forward void OnEntityCreated(int entity, const char[] classname);
|
||||||
|
|
||||||
/**
|
|
||||||
* When an entity is spawned
|
|
||||||
*
|
|
||||||
* @param entity Entity index
|
|
||||||
* @param classname Class name
|
|
||||||
*/
|
|
||||||
forward void OnEntitySpawned(int entity, const char[] classname);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When an entity is destroyed
|
* When an entity is destroyed
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
#include <IShareSys.h>
|
#include <IShareSys.h>
|
||||||
|
|
||||||
#define SMINTERFACE_SDKHOOKS_NAME "ISDKHooks"
|
#define SMINTERFACE_SDKHOOKS_NAME "ISDKHooks"
|
||||||
#define SMINTERFACE_SDKHOOKS_VERSION 2
|
#define SMINTERFACE_SDKHOOKS_VERSION 1
|
||||||
|
|
||||||
class CBaseEntity;
|
class CBaseEntity;
|
||||||
|
|
||||||
@@ -71,16 +71,6 @@ namespace SourceMod
|
|||||||
virtual void OnEntityDestroyed(CBaseEntity *pEntity)
|
virtual void OnEntityDestroyed(CBaseEntity *pEntity)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief When an entity is spawned
|
|
||||||
*
|
|
||||||
* @param pEntity CBaseEntity entity.
|
|
||||||
* @param classname Entity classname.
|
|
||||||
*/
|
|
||||||
virtual void OnEntitySpawned(CBaseEntity *pEntity, const char *classname)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user