Added edict_t and CBaseHandle conversion functions to IGameHelpers (bug 2616, r=dvander)
This commit is contained in:
parent
3fac7d027a
commit
79f9dc61a4
@ -576,3 +576,59 @@ void CHalfLife2::ProcessDelayedKicks()
|
||||
player->Kick(info.buffer);
|
||||
}
|
||||
}
|
||||
|
||||
edict_t *CHalfLife2::EdictOfIndex(int index)
|
||||
{
|
||||
return ::PEntityOfEntIndex(index);
|
||||
}
|
||||
|
||||
int CHalfLife2::IndexOfEdict(edict_t *pEnt)
|
||||
{
|
||||
return ::IndexOfEdict(pEnt);
|
||||
}
|
||||
|
||||
edict_t *CHalfLife2::GetHandleEntity(CBaseHandle &hndl)
|
||||
{
|
||||
if (!hndl.IsValid())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int index = hndl.GetEntryIndex();
|
||||
|
||||
edict_t *pStoredEdict;
|
||||
CBaseEntity *pStoredEntity;
|
||||
|
||||
pStoredEdict = GetEntity(index, &pStoredEntity);
|
||||
|
||||
if (pStoredEdict == NULL || pStoredEntity == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IServerEntity *pSE = pStoredEdict->GetIServerEntity();
|
||||
|
||||
if (pSE == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pSE->GetRefEHandle() != hndl)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pStoredEdict;
|
||||
}
|
||||
|
||||
void CHalfLife2::SetHandleEntity(CBaseHandle &hndl, edict_t *pEnt)
|
||||
{
|
||||
IServerEntity *pEntOther = pEnt->GetIServerEntity();
|
||||
|
||||
if (pEntOther == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
hndl.Set(pEntOther);
|
||||
}
|
||||
|
@ -109,6 +109,10 @@ public: //IGameHelpers
|
||||
bool ShowVGUIMenu(int client, const char *name, KeyValues *data, bool show);
|
||||
bool IsLANServer();
|
||||
bool KVLoadFromFile(KeyValues *kv, IBaseFileSystem *filesystem, const char *resourceName, const char *pathID = NULL);
|
||||
edict_t *EdictOfIndex(int index);
|
||||
int IndexOfEdict(edict_t *pEnt);
|
||||
edict_t *GetHandleEntity(CBaseHandle &hndl);
|
||||
void SetHandleEntity(CBaseHandle &hndl, edict_t *pEnt);
|
||||
public:
|
||||
void AddToFakeCliCmdQueue(int client, int userid, const char *cmd);
|
||||
void ProcessFakeCliCmdQueue();
|
||||
@ -140,4 +144,6 @@ private:
|
||||
|
||||
extern CHalfLife2 g_HL2;
|
||||
|
||||
inline edict_t *GetEntity(cell_t num, CBaseEntity **pData);
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_CHALFLIFE2_H_
|
||||
|
@ -40,9 +40,10 @@
|
||||
*/
|
||||
|
||||
#define SMINTERFACE_GAMEHELPERS_NAME "IGameHelpers"
|
||||
#define SMINTERFACE_GAMEHELPERS_VERSION 2
|
||||
#define SMINTERFACE_GAMEHELPERS_VERSION 3
|
||||
|
||||
class CBaseEntity;
|
||||
class CBaseHandle;
|
||||
class SendProp;
|
||||
class ServerClass;
|
||||
struct edict_t;
|
||||
@ -145,6 +146,39 @@ namespace SourceMod
|
||||
virtual bool FindSendPropInfo(const char *classname,
|
||||
const char *offset,
|
||||
sm_sendprop_info_t *info) =0;
|
||||
|
||||
/**
|
||||
* @brief Converts an entity index into an edict pointer.
|
||||
*
|
||||
* @param index Entity Index.
|
||||
* @return Edict pointer or NULL on failure.
|
||||
*/
|
||||
virtual edict_t *EdictOfIndex(int index) =0;
|
||||
|
||||
/**
|
||||
* @brief Converts an edict pointer into an entity index.
|
||||
*
|
||||
* @param index Edict Pointer.
|
||||
* @return Entity index or -1 on failure.
|
||||
*/
|
||||
virtual int IndexOfEdict(edict_t *pEnt) =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves the edict pointer from a CBaseHandle object.
|
||||
*
|
||||
* @param hndl CBaseHandle object.
|
||||
* @return Edict pointer or NULL on failure.
|
||||
*/
|
||||
virtual edict_t *GetHandleEntity(CBaseHandle &hndl) =0;
|
||||
|
||||
/**
|
||||
* @brief Sets the edict pointer in a CBaseHandle object.
|
||||
*
|
||||
* @param hndl CBaseHandle object.
|
||||
* @param pEnt Edict pointer.
|
||||
* @noreturn
|
||||
*/
|
||||
virtual void SetHandleEntity(CBaseHandle &hndl, edict_t *pEnt) =0;
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user