Added edict_t and CBaseHandle conversion functions to IGameHelpers (bug 2616, r=dvander)

This commit is contained in:
Matt Woodrow
2009-02-22 14:38:05 +13:00
parent 3fac7d027a
commit 79f9dc61a4
3 changed files with 97 additions and 1 deletions
+56
View File
@@ -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);
}
+6
View File
@@ -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_