So I'm working on a custom interface that I will compile into HL2DM, that should ultimately be exposed and available for server plugins to request and use. Once I get it working and all I hope to convince valve to include it into the SDK and compile it into CS/DOD and such so we can have the functionality we've been asking them to add for some time now.
Here's the code.
in public/dlls/ientityinfo.h
Code:
class IEntityInfo
{
public:
virtual const char *GetClassName() = 0;
virtual const QAngle& GetAbsAngles() const = 0;
virtual const QAngle& GetLocalAngles() const = 0;
virtual const Vector& GetAbsOrigin() const = 0;
virtual const Vector& GetLocalOrigin() const = 0;
virtual const Vector& GetAbsVelocity() const = 0;
virtual const Vector& GetLocalVelocity() const = 0;
virtual const QAngle& GetLocalAngularVelocity() const = 0;
// add more useful stuff
};
#define INTERFACEVERSION_ENTITYINFOMANAGER "EntityInfoManager001"
class IEntityInfoManager
{
public:
virtual IEntityInfo *GetEntityInfo( edict_t *pEdict ) = 0;
};
in dlls\EntityInfoManager.h
Code:
#include "dlls/IEntityInfo.h"
#include "dlls/iplayerinfo.h"
class CEntityInfoManager : public IEntityInfoManager
{
public:
virtual IEntityInfo *GetEntityInfo( edict_t *pEdict );
};
//////////////////////////////////////////////////////////////////////////
class EntityInfo : public IEntityInfo
{
public:
inline void SetParent( CBaseEntity *_parent ) { m_pParent = _parent; }
const char *GetClassName();
const QAngle& GetAbsAngles() const;
const QAngle& GetLocalAngles() const;
const Vector& GetAbsOrigin() const;
const Vector& GetLocalOrigin() const;
const Vector& GetAbsVelocity() const;
const Vector& GetLocalVelocity() const;
const QAngle& GetLocalAngularVelocity() const;
IPlayerInfo* GetPlayerInfo() const;
EntityInfo();
protected:
CBaseEntity *m_pParent;
};
and in dlls\EntityInfoManager.cpp
Code:
#include "cbase.h"
#include "EntityInfoManager.h"
static CEntityInfoManager s_EntityInfoManager;
EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CEntityInfoManager, IEntityInfoManager, INTERFACEVERSION_ENTITYINFOMANAGER, s_EntityInfoManager);
IEntityInfo *CEntityInfoManager::GetEntityInfo( edict_t *pEdict )
{
CBaseEntity *pBaseEntity = CBaseEntity::Instance( pEdict );
return pBaseEntity ? pBaseEntity->GetEntityInfo() : NULL;
}
EntityInfo::EntityInfo() :
m_pParent(0)
{
}
const char *EntityInfo::GetClassName()
{
Assert(m_pParent);
return m_pParent->GetClassName();
}
*snip* implementations of all the rest of those functions, basic accessors
I added this as a member of CBaseEntity
Code:
EntityInfo m_EntityInfo;
I may change this to be completely non-intruesive to CBaseEntity class and rather than getting an EntityInfo from the CBaseEntity, add functions that all take the edict and get the CBaseEntity internally and return the results, like
Code:
bool CEntityInfoManager::GetEntityAbsVelocity( edict_t *pEdict, Vector &_vel )
{
CBaseEntity *pBaseEntity = CBaseEntity::Instance( pEdict );
if(pBaseEntity)
{
_vel = pBaseEntity->GetAbsVelocity();
return true;
}
return false;
}
But that doesn't matter at the moment, currently it emulates the same way the IPlayerInfo is set up. It's easy to change once I can figure out whats wrong with actually exporting the interface.
Anyways, this all compiles fine, and best I can tell it's set up exactly like the CPlayerInfoManager and has its interface exposed.
So it all builds fine, I copy the resulting server.dll to source dedicated server\hl2mp\bin and run a HL2DM dedicated server with my plugin that now requests the interface INTERFACEVERSION_ENTITYINFOMANAGER and apparently it's not being found.
Anyone see anything I'm missing from exposing the interface?
best I can tell my use of this
Code:
static CEntityInfoManager s_EntityInfoManager;
EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CEntityInfoManager, IEntityInfoManager, INTERFACEVERSION_ENTITYINFOMANAGER, s_EntityInfoManager);
is exactly the same as how the CPlayerInfoManager is exposed
Code:
static CPlayerInfoManager s_PlayerInfoManager;
EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CPlayerInfoManager, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER, s_PlayerInfoManager);
I don't see anything additional that it does? Am I blind? Anyone got any ideas?
Thanks.