summaryrefslogtreecommitdiff
path: root/public/game/server
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /public/game/server
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'public/game/server')
-rw-r--r--public/game/server/ientityinfo.h150
-rw-r--r--public/game/server/igameinfo.h45
-rw-r--r--public/game/server/iplayerinfo.h195
-rw-r--r--public/game/server/pluginvariant.h165
4 files changed, 555 insertions, 0 deletions
diff --git a/public/game/server/ientityinfo.h b/public/game/server/ientityinfo.h
new file mode 100644
index 0000000..04ab6b3
--- /dev/null
+++ b/public/game/server/ientityinfo.h
@@ -0,0 +1,150 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: provides an interface for plugins to query information about entities from the game dll
+//
+//===============================================================================================//
+#ifndef IENTITYINFO_H
+#define IENTITYINFO_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "mathlib/vector.h"
+#include "pluginvariant.h"
+
+abstract_class IEntityInfo
+{
+public:
+ // returns true if entity is a player
+ virtual const int EntityIndex() = 0;
+ virtual const char *GetEntityName() = 0;
+ virtual const char *GetClassname() = 0;
+ virtual const char *GetModelName() = 0;
+//TODO
+ virtual const char *GetTargetName() = 0;
+ virtual void SetModel(const char *modelName) = 0;
+ virtual bool IsPlayer() = 0;
+ virtual bool IsNPC() = 0;
+ virtual bool IsDead() = 0;
+ virtual bool IsAlive() = 0;
+ virtual bool IsInWorld() = 0;
+ virtual bool IsTemplate() = 0;
+ virtual int GetEFlags() = 0;
+ virtual void SetEFlags( int iEFlags ) = 0;
+ virtual void AddEFlags( int nEFlagMask ) = 0;
+ virtual bool IsEFlagSet( int EFlagMask ) = 0;
+
+ virtual const int GetEffects( void ) = 0;
+ virtual void AddEffects( int nEffects ) = 0;
+ virtual void RemoveEffects( int nEffects ) = 0;
+ virtual void ClearEffects( void ) = 0;
+ virtual void SetEffects( int nEffects ) = 0;
+ virtual bool IsEffectActive( int nEffects ) = 0;
+ virtual int GetRenderMode() = 0;
+ virtual void SetRenderMode( int nRenderMode ) = 0;
+
+ virtual void SetBlocksLOS( bool bBlocksLOS ) = 0;
+ virtual bool BlocksLOS( void ) = 0;
+
+ virtual const int GetHealth() = 0;
+ virtual const int GetMaxHealth() = 0;
+ virtual void SetHealth( int iHealth ) = 0;
+ virtual void SetMaxHealth( int iMaxHealth ) = 0;
+
+ // returns the team the entity is on
+ virtual int GetTeamIndex() = 0;
+ // changes the entity to a new team (if the game dll logic allows it)
+ virtual void ChangeTeam( int iTeamNum ) = 0;
+
+ // positioning and sizes
+ virtual const Vector GetAbsOrigin() = 0;
+ virtual void SetAbsOrigin( Vector & vec ) = 0;
+ virtual const QAngle GetAbsAngles() = 0;
+ virtual void SetAbsAngles( QAngle & ang ) = 0;
+ virtual const Vector GetLocalOrigin() = 0;
+ virtual void SetLocalOrigin( const Vector& origin ) = 0;
+ virtual const QAngle GetLocalAngles() = 0;
+ virtual void SetLocalAngles( const QAngle& angles ) = 0;
+ virtual const Vector GetAbsVelocity() = 0;
+ virtual const Vector GetLocalVelocity() = 0;
+ virtual const QAngle GetLocalAngularVelocity() = 0;
+ virtual void EntityToWorldSpace( const Vector &in, Vector *pOut ) = 0;
+ virtual void WorldToEntitySpace( const Vector &in, Vector *pOut ) = 0;
+ virtual Vector EyePosition() = 0;
+ virtual QAngle EyeAngles() = 0;
+ virtual QAngle LocalEyeAngles() = 0;
+ virtual Vector EarPosition() = 0;
+
+ // returns world aligned mins/maxs of this entity
+ virtual const Vector GetWorldMins() = 0;
+ virtual const Vector GetWorldMaxs() = 0;
+ virtual const Vector WorldSpaceCenter() = 0;
+
+ virtual int GetWaterLevel() = 0;
+
+ // if this entity has an owner, it returns their edict_t.
+ virtual edict_t *GetOwner() = 0;
+ virtual edict_t *GetParent() = 0;
+ virtual edict_t *GetMoveParent() = 0;
+ virtual edict_t *GetRootMoveParent() = 0;
+
+ // if this entity is following another, returns that entities edict_t.
+ virtual edict_t *GetFollowedEntity() = 0;
+ virtual edict_t *GetGroundEntity() = 0; //returns the entity that this one is standing on - if set.
+
+ // accessor to hook mod specific information about the entity.
+ virtual bool GetCustomInfo(int valueType, pluginvariant &outValue, pluginvariant options) = 0;
+
+ // entity debugging stuff.
+ virtual const char *GetDebugName() = 0;
+ virtual void EntityText( int text_offset, const char *text, float flDuration, int r = 255, int g = 255, int b = 255, int a = 255 ) = 0;
+
+ //Keyvalues
+ virtual bool GetKeyValue( const char *szKeyName, char *szValue, int iMaxLen ) = 0;
+
+
+};
+
+
+#define INTERFACEVERSION_ENTITYINFOMANAGER "EntityInfoManager001"
+abstract_class IEntityInfoManager
+{
+public:
+ virtual IEntityInfo *GetEntityInfo( edict_t *pEdict ) = 0;
+ virtual IEntityInfo *GetEntityInfo( int index ) = 0; //Retrieves the info
+
+ //Experiment..
+ virtual IServerUnknown *GetServerEntity( edict_t *pEdict ) = 0;
+
+ //-----------------------------------------------------------------------------
+ // Purpose: Iterates the entities with a given classname.
+ // Input : pStartEntity - Last entity found, NULL to start a new iteration.
+ // szName - Classname to search for.
+ //-----------------------------------------------------------------------------
+ virtual edict_t *FindEntityByClassname( edict_t *pStartEntity, const char *szName ) = 0;
+
+ //-----------------------------------------------------------------------------
+ // Purpose: Iterates the entities with a given name.
+ // Input : pStartEntity - Last entity found, NULL to start a new iteration.
+ // szName - Name to search for.
+ //-----------------------------------------------------------------------------
+ virtual edict_t *FindEntityByName( edict_t *pStartEntity, const char *szName ) = 0;
+
+ //-----------------------------------------------------------------------------
+ // Purpose: Iterates the entities with a given model name.
+ // Input : pStartEntity - Last entity found, NULL to start a new iteration.
+ // szModelName - Model Name to search for.
+ //-----------------------------------------------------------------------------
+ virtual edict_t *FindEntityByModel( edict_t *pStartEntity, const char *szModelName ) = 0;
+
+ //-----------------------------------------------------------------------------
+ // Purpose: Used to iterate all the entities within a sphere.
+ // Input : pStartEntity -
+ // vecCenter -
+ // flRadius -
+ //-----------------------------------------------------------------------------
+ virtual edict_t *FindEntityInSphere( edict_t *pStartEntity, const Vector &vecCenter, float flRadius ) = 0;
+
+ virtual void GetWorldBounds( Vector &mins, Vector &maxs ) = 0;
+};
+#endif // IENTITYINFO_H
diff --git a/public/game/server/igameinfo.h b/public/game/server/igameinfo.h
new file mode 100644
index 0000000..8218a1f
--- /dev/null
+++ b/public/game/server/igameinfo.h
@@ -0,0 +1,45 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: provides an interface for plugins to query information about the gamerules in a simple
+// and organized mannor.
+//
+//===============================================================================================//
+#ifndef IGAMEINFO_H
+#define IGAMEINFO_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "mathlib/vector.h"
+#include "pluginvariant.h"
+
+//Tony; prefixing everything in this so that i can make IGameInfo an extension of CGameRules and not stomp on anything, since gamerules isn't an entity.
+abstract_class IGameInfo
+{
+public:
+ // returns an enumerated id for the current game type
+ virtual const int GetInfo_GameType() = 0;
+ // returns a name associated with the gametype, if defined.
+ virtual const char *GetInfo_GameTypeName() = 0;
+ // returns the team name associated with the number
+ virtual const char *GetInfo_GetTeamName(int teamNumber) = 0;
+ // returns how many teams the game has (typically always 4; 0 = unassigned, 1 = spectator, 2 = team1, 3 = team2)
+ virtual const int GetInfo_GetTeamCount() = 0;
+ // returns how many players are on a given team
+ virtual const int GetInfo_NumPlayersOnTeam(int teamNumber) = 0;
+
+ // accessor to hook mod specific information about the rules. for TF2, fields such as
+ virtual bool GetInfo_Custom(int valueType, pluginvariant &outValue, pluginvariant options) = 0;
+
+};
+
+
+//Interface is very simple, there's not much really needed for the manager, this stuff is just in it's own interface so it's not mixed up with the entity
+//or player managers.
+#define INTERFACEVERSION_GAMEINFOMANAGER "GameInfoManager001"
+abstract_class IGameInfoManager
+{
+public:
+ virtual IGameInfo *GetGameInfo() = 0;
+};
+#endif // IGAMEINFO_H
diff --git a/public/game/server/iplayerinfo.h b/public/game/server/iplayerinfo.h
new file mode 100644
index 0000000..630abe9
--- /dev/null
+++ b/public/game/server/iplayerinfo.h
@@ -0,0 +1,195 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: provides an interface for dlls to query information about players from the game dll
+//
+//=============================================================================//
+#ifndef IPLAYERINFO_H
+#define IPLAYERINFO_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "mathlib/vector.h"
+
+// helper class for user commands
+class CBotCmd
+{
+public:
+ CBotCmd()
+ {
+ Reset();
+ }
+
+ virtual ~CBotCmd() { };
+
+ void Reset()
+ {
+ command_number = 0;
+ tick_count = 0;
+ viewangles.Init();
+ forwardmove = 0.0f;
+ sidemove = 0.0f;
+ upmove = 0.0f;
+ buttons = 0;
+ impulse = 0;
+ weaponselect = 0;
+ weaponsubtype = 0;
+ random_seed = 0;
+ mousedx = 0;
+ mousedy = 0;
+
+ hasbeenpredicted = false;
+ }
+
+ CBotCmd& operator =( const CBotCmd& src )
+ {
+ if ( this == &src )
+ return *this;
+
+ command_number = src.command_number;
+ tick_count = src.tick_count;
+ viewangles = src.viewangles;
+ forwardmove = src.forwardmove;
+ sidemove = src.sidemove;
+ upmove = src.upmove;
+ buttons = src.buttons;
+ impulse = src.impulse;
+ weaponselect = src.weaponselect;
+ weaponsubtype = src.weaponsubtype;
+ random_seed = src.random_seed;
+ mousedx = src.mousedx;
+ mousedy = src.mousedy;
+ hasbeenpredicted = src.hasbeenpredicted;
+ return *this;
+ }
+
+ // For matching server and client commands for debugging
+ int command_number;
+
+ // the tick the client created this command
+ int tick_count;
+
+ // Player instantaneous view angles.
+ QAngle viewangles;
+ // Intended velocities
+ // forward velocity.
+ float forwardmove;
+ // sideways velocity.
+ float sidemove;
+ // upward velocity.
+ float upmove;
+ // Attack button states
+ int buttons;
+ // Impulse command issued.
+ byte impulse;
+ // Current weapon id
+ int weaponselect;
+ int weaponsubtype;
+
+ int random_seed; // For shared random functions
+
+ short mousedx; // mouse accum in x from create move
+ short mousedy; // mouse accum in y from create move
+
+ // Client only, tracks whether we've predicted this command at least once
+ bool hasbeenpredicted;
+};
+
+
+
+
+abstract_class IPlayerInfo
+{
+public:
+ // returns the players name (UTF-8 encoded)
+ virtual const char *GetName() = 0;
+ // returns the userid (slot number)
+ virtual int GetUserID() = 0;
+ // returns the string of their network (i.e Steam) ID
+ virtual const char *GetNetworkIDString() = 0;
+ // returns the team the player is on
+ virtual int GetTeamIndex() = 0;
+ // changes the player to a new team (if the game dll logic allows it)
+ virtual void ChangeTeam( int iTeamNum ) = 0;
+ // returns the number of kills this player has (exact meaning is mod dependent)
+ virtual int GetFragCount() = 0;
+ // returns the number of deaths this player has (exact meaning is mod dependent)
+ virtual int GetDeathCount() = 0;
+ // returns if this player slot is actually valid
+ virtual bool IsConnected() = 0;
+ // returns the armor/health of the player (exact meaning is mod dependent)
+ virtual int GetArmorValue() = 0;
+
+ // extensions added to V2
+
+ // various player flags
+ virtual bool IsHLTV() = 0;
+ virtual bool IsPlayer() = 0;
+ virtual bool IsFakeClient() = 0;
+ virtual bool IsDead() = 0;
+ virtual bool IsInAVehicle() = 0;
+ virtual bool IsObserver() = 0;
+
+ // player position and size
+ virtual const Vector GetAbsOrigin() = 0;
+ virtual const QAngle GetAbsAngles() = 0;
+ virtual const Vector GetPlayerMins() = 0;
+ virtual const Vector GetPlayerMaxs() = 0;
+ // the name of the weapon currently being carried
+ virtual const char *GetWeaponName() = 0;
+ // the name of the player model in use
+ virtual const char *GetModelName() = 0;
+ // current player health
+ virtual const int GetHealth() = 0;
+ // max health value
+ virtual const int GetMaxHealth() = 0;
+ // the last user input from this player
+ virtual CBotCmd GetLastUserCommand() = 0;
+
+ virtual bool IsReplay() = 0;
+};
+
+
+#define INTERFACEVERSION_PLAYERINFOMANAGER "PlayerInfoManager002"
+abstract_class IPlayerInfoManager
+{
+public:
+ virtual IPlayerInfo *GetPlayerInfo( edict_t *pEdict ) = 0;
+ virtual CGlobalVars *GetGlobalVars() = 0;
+};
+
+
+
+
+abstract_class IBotController
+{
+public:
+ // change the bots position
+ virtual void SetAbsOrigin( Vector & vec ) = 0;
+ virtual void SetAbsAngles( QAngle & ang ) = 0;
+ virtual void SetLocalOrigin( const Vector& origin ) = 0;
+ virtual const Vector GetLocalOrigin( void ) = 0;
+ virtual void SetLocalAngles( const QAngle& angles ) = 0;
+ virtual const QAngle GetLocalAngles( void ) = 0;
+
+ // strip them of weapons, etc
+ virtual void RemoveAllItems( bool removeSuit ) = 0;
+ // give them a weapon
+ virtual void SetActiveWeapon( const char *WeaponName ) = 0;
+ // check various effect flags
+ virtual bool IsEFlagSet( int nEFlagMask ) = 0;
+ // fire a virtual move command to the bot
+ virtual void RunPlayerMove( CBotCmd *ucmd ) = 0;
+};
+
+
+#define INTERFACEVERSION_PLAYERBOTMANAGER "BotManager001"
+abstract_class IBotManager
+{
+public:
+ virtual IBotController *GetBotController( edict_t *pEdict ) = 0;
+ // create a new bot and spawn it into the server
+ virtual edict_t *CreateBot( const char *botname ) = 0;
+};
+
+#endif // IPLAYERINFO_H
diff --git a/public/game/server/pluginvariant.h b/public/game/server/pluginvariant.h
new file mode 100644
index 0000000..b4a798c
--- /dev/null
+++ b/public/game/server/pluginvariant.h
@@ -0,0 +1,165 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#ifndef PLUGINVARIANT_H
+#define PLUGINVARIANT_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "stdstring.h"
+#include "mathlib/vmatrix.h"
+
+/*
+//Tony; including stdstring at this point (which I need) messes up the offsetof override in linux, so I need to reset it here.
+#if defined( POSIX )
+#undef offsetof
+#define offsetof(s,m) (size_t)&(((s *)0)->m)
+#endif
+ */
+//
+// A modified variant class for that functions almost identically to variant_t, for plugins to pass data back and forth.
+//
+class pluginvariant
+{
+ union
+ {
+ bool bVal;
+ int iVal;
+ float flVal;
+ float vecVal[3];
+ color32 rgbaVal;
+ };
+ //Tony; neither of these can be in the union because of constructors.
+ edict_t *eVal;
+ char iszVal[1024];
+
+ fieldtype_t fieldType;
+
+public:
+
+ // constructor
+ pluginvariant() : fieldType(FIELD_VOID), iVal(0) {}
+
+ inline bool Bool( void ) const { return( fieldType == FIELD_BOOLEAN ) ? bVal : false; }
+ inline const char *String( void ) const { return( ToString() ); }
+ inline int Int( void ) const { return( fieldType == FIELD_INTEGER ) ? iVal : 0; }
+ inline float Float( void ) const { return( fieldType == FIELD_FLOAT ) ? flVal : 0; }
+ inline const edict_t *Edict(void) const;
+ inline color32 Color32(void) const { return rgbaVal; }
+ inline void Vector3D(Vector &vec) const;
+
+ fieldtype_t FieldType( void ) { return fieldType; }
+
+ void SetBool( bool b ) { bVal = b; fieldType = FIELD_BOOLEAN; }
+ void SetString( char *str ) { Q_snprintf(iszVal, 1024, "%s", str); fieldType = FIELD_STRING; }
+ void SetInt( int val ) { iVal = val, fieldType = FIELD_INTEGER; }
+ void SetFloat( float val ) { flVal = val, fieldType = FIELD_FLOAT; }
+ void SetEdict( edict_t *val ) { eVal = val; fieldType = FIELD_EHANDLE; }
+ void SetVector3D( const Vector &val ) { vecVal[0] = val[0]; vecVal[1] = val[1]; vecVal[2] = val[2]; fieldType = FIELD_VECTOR; }
+ void SetPositionVector3D( const Vector &val ) { vecVal[0] = val[0]; vecVal[1] = val[1]; vecVal[2] = val[2]; fieldType = FIELD_POSITION_VECTOR; }
+ void SetColor32( color32 val ) { rgbaVal = val; fieldType = FIELD_COLOR32; }
+ void SetColor32( int r, int g, int b, int a ) { rgbaVal.r = r; rgbaVal.g = g; rgbaVal.b = b; rgbaVal.a = a; fieldType = FIELD_COLOR32; }
+
+protected:
+
+ //
+ // Returns a string representation of the value without modifying the variant.
+ //
+ const char *ToString( void ) const
+ {
+ static char szBuf[512];
+
+ switch (fieldType)
+ {
+ case FIELD_STRING:
+ {
+ return (const char *)iszVal;
+ }
+
+ case FIELD_BOOLEAN:
+ {
+ if (bVal == 0)
+ {
+ Q_strncpy(szBuf, "false",sizeof(szBuf));
+ }
+ else
+ {
+ Q_strncpy(szBuf, "true",sizeof(szBuf));
+ }
+ return(szBuf);
+ }
+
+ case FIELD_INTEGER:
+ {
+ Q_snprintf( szBuf, sizeof( szBuf ), "%i", iVal );
+ return(szBuf);
+ }
+
+ case FIELD_FLOAT:
+ {
+ Q_snprintf(szBuf,sizeof(szBuf), "%g", flVal);
+ return(szBuf);
+ }
+
+ case FIELD_COLOR32:
+ {
+ Q_snprintf(szBuf,sizeof(szBuf), "%d %d %d %d", (int)rgbaVal.r, (int)rgbaVal.g, (int)rgbaVal.b, (int)rgbaVal.a);
+ return(szBuf);
+ }
+
+ case FIELD_VECTOR:
+ {
+ Q_snprintf(szBuf,sizeof(szBuf), "[%g %g %g]", (double)vecVal[0], (double)vecVal[1], (double)vecVal[2]);
+ return(szBuf);
+ }
+
+ case FIELD_VOID:
+ {
+ szBuf[0] = '\0';
+ return(szBuf);
+ }
+ }
+
+ return("No conversion to string");
+ }
+};
+
+
+////////////////////////// pluginvariant implementation //////////////////////////
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Returns this variant as a vector.
+//-----------------------------------------------------------------------------
+inline void pluginvariant::Vector3D(Vector &vec) const
+{
+ if (( fieldType == FIELD_VECTOR ) || ( fieldType == FIELD_POSITION_VECTOR ))
+ {
+ vec[0] = vecVal[0];
+ vec[1] = vecVal[1];
+ vec[2] = vecVal[2];
+ }
+ else
+ {
+ vec = vec3_origin;
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Returns this variant as an edict_t
+//-----------------------------------------------------------------------------
+inline const edict_t *pluginvariant::Edict(void) const
+{
+ if ( fieldType == FIELD_EHANDLE )
+ return eVal;
+
+ return NULL;
+}
+
+
+#endif // pluginvariant_H