added command line, added basic character
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "engine.h"
|
||||
#include "tier1/utlvector.h"
|
||||
#include "cglm/cglm.h"
|
||||
#include "math3d.h"
|
||||
|
||||
class CBaseEntity;
|
||||
class C_BaseEntity;
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
void SetRotationMatrix( mat3 matrix );
|
||||
void SetScale( vec3 scale );
|
||||
|
||||
C_BaseEntity *pClientEntity;
|
||||
C_BaseEntity *pClientEntity = NULL;
|
||||
mat3 m_matrix;
|
||||
vec3 m_position;
|
||||
vec3 m_scale;
|
||||
|
||||
14
public/baseplayer.h
Normal file
14
public/baseplayer.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef BASE_PLAYER_H
|
||||
#define BASE_PLAYER_H
|
||||
|
||||
#include "baseentity.h"
|
||||
#include "playerstart.h"
|
||||
class CBaseEntity;
|
||||
|
||||
class CBasePlayer: public CBaseEntity
|
||||
{
|
||||
public:
|
||||
CPlayerStart *pOwningSpawn;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "engine.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "tier1/utlvector.h"
|
||||
|
||||
class ConVar;
|
||||
class ConCommand;
|
||||
@@ -16,13 +17,15 @@ public:
|
||||
static void UnRegisterVar( ConVar *cvar );
|
||||
static ConVar *FindVar( const char *pName );
|
||||
|
||||
static void RegisterCommand( ConVar *cvar );
|
||||
static void UnRegisterCommand( ConVar *cvar );
|
||||
static void RegisterCommand( ConCommand *cvar );
|
||||
static void UnRegisterCommand( ConCommand *cvar );
|
||||
static ConCommand *FindCommand( const char *pName );
|
||||
|
||||
static void Execute( void );
|
||||
static void AddCommand( const char *psz );
|
||||
static void InsertCommand( const char *psz );
|
||||
private:
|
||||
static void Execute2( CUtlVector<CUtlString> &args );
|
||||
};
|
||||
|
||||
|
||||
@@ -83,9 +86,13 @@ class ConCommand
|
||||
public:
|
||||
ConCommand(const char *pName, ConCommandFn callback,
|
||||
const char *pHelpString=0, int flags=0);
|
||||
|
||||
const char *GetName( void );
|
||||
const char *GetHelpText( void );
|
||||
ConCommandFn GetCallback( void );
|
||||
private:
|
||||
char *m_szName;
|
||||
char *m_szHelpString = NULL;
|
||||
CUtlString m_szName;
|
||||
CUtlString m_szHelpString = NULL;
|
||||
ConCommandFn m_callback;
|
||||
|
||||
int m_flags;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
/* for windows as it sucks */
|
||||
#include "tier0/platform.h"
|
||||
#include "server.h"
|
||||
#include "tier1/utlvector.h"
|
||||
|
||||
class CBaseEntity;
|
||||
|
||||
@@ -14,12 +16,18 @@ public:
|
||||
static void Shutdown();
|
||||
};
|
||||
|
||||
extern IIClient g_localClient;
|
||||
extern CUtlVector<IIClient*> g_clients;
|
||||
|
||||
|
||||
interface IIEngine
|
||||
{
|
||||
public:
|
||||
static CBaseEntity *SpawnEntity( const char *szName );
|
||||
static void InitEntity(CBaseEntity *pEntity);
|
||||
static void DestroyEntity( CBaseEntity *pEntity );
|
||||
static void ConnectClient( IIClient *pClient);
|
||||
static void DisconnectClient( IIClient *pClient);
|
||||
};
|
||||
|
||||
|
||||
|
||||
24
public/gamemode.h
Normal file
24
public/gamemode.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef GAMEMODE_H
|
||||
#define GAMEMODE_H
|
||||
|
||||
#include "tier0/platform.h"
|
||||
|
||||
class CGameMode
|
||||
{
|
||||
public:
|
||||
virtual void RoundBegin( void );
|
||||
virtual void RoundEnd( void );
|
||||
bool bCanPlayerSpawnMidRound;
|
||||
};
|
||||
|
||||
interface IGameModeManager
|
||||
{
|
||||
public:
|
||||
static void Init( void );
|
||||
static void Frame( void );
|
||||
static void StartGameMode(CGameMode *pGameMode);
|
||||
static CGameMode *GetCurrentMode( void );
|
||||
static void RestartCurrentMode( void );
|
||||
};
|
||||
|
||||
#endif
|
||||
103
public/input.h
103
public/input.h
@@ -0,0 +1,103 @@
|
||||
#ifndef INPUT_H
|
||||
#define INPUT_H
|
||||
|
||||
#include "tier0/platform.h"
|
||||
|
||||
enum EKeyEventType
|
||||
{
|
||||
KEY_EVENT_TYPE_DOWN,
|
||||
KEY_EVENT_TYPE_UP,
|
||||
};
|
||||
|
||||
enum EInputKey
|
||||
{
|
||||
KEY_NONE = 0,
|
||||
KEY_ESCAPE,
|
||||
KEY_TAB,
|
||||
KEY_TILDE,
|
||||
KEY_CAPSLOCK,
|
||||
KEY_CONTROL,
|
||||
KEY_SHIFT,
|
||||
KEY_WIN,
|
||||
KEY_ALT,
|
||||
KEY_SPACE,
|
||||
|
||||
KEY_BACKSPACE,
|
||||
KEY_LBRACKET,
|
||||
KEY_RBRACKET,
|
||||
KEY_BACKSLASH,
|
||||
KEY_SEMICOLON,
|
||||
KEY_APOSTROPHE,
|
||||
KEY_SLASH,
|
||||
KEY_ENTER,
|
||||
|
||||
KEY_F1,
|
||||
KEY_F2,
|
||||
KEY_F3,
|
||||
KEY_F4,
|
||||
KEY_F5,
|
||||
KEY_F6,
|
||||
KEY_F7,
|
||||
KEY_F8,
|
||||
KEY_F9,
|
||||
KEY_F10,
|
||||
KEY_F11,
|
||||
KEY_F12,
|
||||
|
||||
KEY_1,
|
||||
KEY_2,
|
||||
KEY_3,
|
||||
KEY_4,
|
||||
KEY_5,
|
||||
KEY_6,
|
||||
KEY_7,
|
||||
KEY_8,
|
||||
KEY_9,
|
||||
KEY_0,
|
||||
|
||||
KEY_A,
|
||||
KEY_B,
|
||||
KEY_C,
|
||||
KEY_D,
|
||||
KEY_E,
|
||||
KEY_F,
|
||||
KEY_G,
|
||||
KEY_H,
|
||||
KEY_I,
|
||||
KEY_J,
|
||||
KEY_K,
|
||||
KEY_L,
|
||||
KEY_M,
|
||||
KEY_N,
|
||||
KEY_O,
|
||||
KEY_P,
|
||||
KEY_Q,
|
||||
KEY_R,
|
||||
KEY_S,
|
||||
KEY_T,
|
||||
KEY_U,
|
||||
KEY_V,
|
||||
KEY_W,
|
||||
KEY_X,
|
||||
KEY_Y,
|
||||
KEY_Z,
|
||||
};
|
||||
|
||||
enum EInputAxis
|
||||
{
|
||||
AXIS_MOUSE_X,
|
||||
AXIS_MOUSE_Y,
|
||||
AXIS_MOUSE_SCROLL,
|
||||
};
|
||||
|
||||
interface IInput
|
||||
{
|
||||
public:
|
||||
static void Init( void );
|
||||
static void KeyEvent( EInputKey key, EKeyEventType event );
|
||||
static void AxisEvent( unsigned char axis, float fX, float fY );
|
||||
static void Frame( void );
|
||||
static void Deinit( void );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
8
public/math3d.h
Normal file
8
public/math3d.h
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
#ifndef MATH_3D_H
|
||||
#define MATH_3D_H
|
||||
#include "tier0/minmax_off.h"
|
||||
#include "cglm/cglm.h"
|
||||
#include "cglm/affine.h"
|
||||
#include "tier0/minmax.h"
|
||||
#endif
|
||||
11
public/net.h
Normal file
11
public/net.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef NET_H
|
||||
#define NET_H
|
||||
|
||||
#include "tier0/platform.h"
|
||||
|
||||
interface INet
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -54,11 +54,25 @@ public:
|
||||
virtual void Destroy( void ) override;
|
||||
};
|
||||
|
||||
class CPxRigidKinematicPosition
|
||||
{
|
||||
public:
|
||||
void Spawn( CPxCollider *pCollider, px_matrix matrix, px_rigidbody_params params );
|
||||
px_vec3 GetPosition( void );
|
||||
px_matrix GetMatrix ( void );
|
||||
void Destroy( void );
|
||||
CPxCollider *m_pCollider;
|
||||
RigidBodyHandle *m_pRigidBody;
|
||||
};
|
||||
|
||||
class CPxRigidBody
|
||||
{
|
||||
public:
|
||||
void Spawn( CPxCollider *pCollider, px_matrix matrix, px_rigidbody_params params );
|
||||
px_vec3 GetPosition( void );
|
||||
px_vec3 GetVelocity( void );
|
||||
void SetPosition( px_vec3 position );
|
||||
void SetVelocity( px_vec3 velocity );
|
||||
px_matrix GetMatrix ( void );
|
||||
void Destroy( void );
|
||||
CPxCollider *m_pCollider;
|
||||
|
||||
@@ -72,6 +72,11 @@ struct px_vec3 px_getvelocity(struct funnyphysics *px_world, RigidBodyHandle *bo
|
||||
|
||||
struct funnyphysics *px_init(void);
|
||||
|
||||
RigidBodyHandle *px_kinematic_position_body(struct funnyphysics *px_world,
|
||||
Collider *collider,
|
||||
struct px_matrix m,
|
||||
struct px_rigidbody_params params);
|
||||
|
||||
RigidBodyHandle *px_rigidbody(struct funnyphysics *px_world,
|
||||
Collider *collider,
|
||||
struct px_matrix m,
|
||||
|
||||
25
public/playerstart.h
Normal file
25
public/playerstart.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef PLAYER_START_H
|
||||
#define PLAYER_START_H
|
||||
|
||||
#include "baseentity.h"
|
||||
#include "server.h"
|
||||
|
||||
|
||||
class CPlayerStart: public CBaseEntity
|
||||
{
|
||||
public:
|
||||
virtual void Precache ( void ) override;
|
||||
virtual void Spawn( void ) override;
|
||||
virtual void ReadParameter( const char *szName, const char *szValue ) override;
|
||||
virtual void Destroy( void ) override;
|
||||
virtual void Think( float fDelta ) override;
|
||||
virtual void RoundEnd( void );
|
||||
virtual void RoundStart( IIClient *pClient );
|
||||
|
||||
CBasePlayer *pOwningPlayer = NULL;
|
||||
bool m_bIsRunning = false;
|
||||
};
|
||||
|
||||
extern CUtlVector<CPlayerStart*> g_PlayerStarts;
|
||||
|
||||
#endif
|
||||
@@ -1,13 +1,14 @@
|
||||
#ifndef RENDERING_H
|
||||
#define RENDERING_H
|
||||
|
||||
#include "cglm/affine.h"
|
||||
#include "cglm/cglm.h"
|
||||
#include "math3d.h"
|
||||
#include "tier0/platform.h"
|
||||
#include "tier1/utlbuffer.h"
|
||||
#include "baseentity.h"
|
||||
#include "tier1/utlvector.h"
|
||||
|
||||
extern mat4 g_cameraView;
|
||||
|
||||
interface IVideo
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -11,4 +11,13 @@ public:
|
||||
static void UnloadGame( const char *psz );
|
||||
};
|
||||
|
||||
#endif
|
||||
class CBasePlayer;
|
||||
|
||||
abstract_class IIClient
|
||||
{
|
||||
public:
|
||||
uint64_t playerID;
|
||||
CBasePlayer *pBasePlayer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
#ifndef TIER0_STDLIB_H
|
||||
#define TIER0_STDLIB_H
|
||||
|
||||
#include "tier0/minmax.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "stdint.h"
|
||||
#include "string.h"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#else
|
||||
#include "stdint.h"
|
||||
#include "string.h"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#endif
|
||||
|
||||
// TODO: bad stuff, reimplement it
|
||||
|
||||
|
||||
8
public/tier0/minmax.h
Normal file
8
public/tier0/minmax.h
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
#undef max
|
||||
#endif
|
||||
|
||||
#define max(x, y) (((x) > (y)) ? (x) : (y))
|
||||
#define min(x, y) (((x) < (y)) ? (x) : (y))
|
||||
4
public/tier0/minmax_off.h
Normal file
4
public/tier0/minmax_off.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#ifdef min
|
||||
#undef min
|
||||
#undef max
|
||||
#endif
|
||||
@@ -5,7 +5,9 @@
|
||||
#include "tier0/mem.h"
|
||||
#include "tier0/platform.h"
|
||||
#include "tier0/lib.h"
|
||||
#include "tier0/minmax_off.h"
|
||||
#include "new"
|
||||
#include "tier0/minmax.h"
|
||||
|
||||
template <typename T>
|
||||
class CUtlBuffer;
|
||||
@@ -161,7 +163,7 @@ public:
|
||||
|
||||
size_t GetSize() const;
|
||||
size_t GetRealSize() const;
|
||||
void Resize( size_t nSize );
|
||||
void Resize( size_t nSize, size_t nDataOffset = 0 );
|
||||
void* GetMemory(void) const;
|
||||
|
||||
operator T*( void ) const;
|
||||
@@ -248,7 +250,7 @@ size_t CUtlResizableBuffer<T>::GetRealSize( void ) const
|
||||
// Resizes memory.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void CUtlResizableBuffer<T>::Resize( size_t nSize )
|
||||
void CUtlResizableBuffer<T>::Resize( size_t nSize, size_t nDataOffset )
|
||||
{
|
||||
if (nSize > m_nAllocatedSize)
|
||||
{
|
||||
@@ -256,14 +258,14 @@ void CUtlResizableBuffer<T>::Resize( size_t nSize )
|
||||
T *pData = (T*)V_malloc(nAllocationSize*sizeof(T));
|
||||
for (size_t i = 0; i < m_nSize; i++)
|
||||
{
|
||||
new (&pData[i]) T(m_pData[i]);
|
||||
new (&pData[i+nDataOffset]) T(m_pData[i]);
|
||||
m_pData[i].~T();
|
||||
}
|
||||
V_free(m_pData);
|
||||
m_pData = pData;
|
||||
m_nAllocatedSize = nAllocationSize;
|
||||
}
|
||||
for ( size_t i = m_nSize; i < nSize; ++i )
|
||||
for ( size_t i = m_nSize+nDataOffset; i < nSize; ++i )
|
||||
new (&m_pData[i]) T();
|
||||
m_nSize = nSize;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,9 @@ public:
|
||||
CUtlString( const CUtlString &sz );
|
||||
|
||||
void AppendTail( const char *psz );
|
||||
void AppendTail( char ch );
|
||||
void AppendHead( const char *psz );
|
||||
void AppendHead( char ch );
|
||||
void AppendAt( size_t nPosition, const char *psz );
|
||||
|
||||
void RemoveTail( size_t nCount );
|
||||
@@ -20,6 +22,7 @@ public:
|
||||
char *GetString( void );
|
||||
size_t GetLenght( void );
|
||||
operator char*( void );
|
||||
operator CUtlVector<char>&( void );
|
||||
CUtlString& operator=(const CUtlString &sz);
|
||||
bool operator==(const char* psz);
|
||||
bool operator!=(const char* psz);
|
||||
|
||||
@@ -32,8 +32,8 @@ public:
|
||||
|
||||
T *GetData( void );
|
||||
size_t GetSize( void );
|
||||
void Resize( size_t nSize );
|
||||
void Reserve( size_t nSize );
|
||||
void Resize( size_t nSize, size_t nDataOffset = 0 );
|
||||
void Reserve( size_t nSize, size_t nDataOffset = 0 );
|
||||
|
||||
T &operator[]( size_t nIndex );
|
||||
T &operator[]( size_t nIndex ) const;
|
||||
@@ -121,7 +121,11 @@ void CUtlVector<T>::AppendHead( const T &data )
|
||||
template<typename T>
|
||||
void CUtlVector<T>::AppendHead( const T *pData, size_t n )
|
||||
{
|
||||
|
||||
size_t prevSize = m_data.GetSize();
|
||||
m_data.Resize(prevSize+n, n);
|
||||
for ( size_t i = 0; i < n; i++ )
|
||||
new (&m_data[i]) T(pData[i]);
|
||||
m_nSize+=n;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -135,7 +139,7 @@ void CUtlVector<T>::AppendTail( const T *pData, size_t n )
|
||||
{
|
||||
m_data.Resize(m_data.GetSize()+n);
|
||||
for ( size_t i = 0; i < n; i++ )
|
||||
m_data[i+m_nSize] = pData[i];
|
||||
new (&m_data[i+m_nSize]) T(pData[i]);
|
||||
m_nSize+=n;
|
||||
}
|
||||
|
||||
@@ -180,15 +184,15 @@ size_t CUtlVector<T>::GetSize( void )
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CUtlVector<T>::Resize( size_t nSize )
|
||||
void CUtlVector<T>::Resize( size_t nSize, size_t nDataOffset )
|
||||
{
|
||||
m_data.Resize(nSize);
|
||||
m_data.Resize(nSize, nDataOffset);
|
||||
m_nSize = nSize;
|
||||
}
|
||||
template<typename T>
|
||||
void CUtlVector<T>::Reserve( size_t nSize )
|
||||
void CUtlVector<T>::Reserve( size_t nSize, size_t nDataOffset )
|
||||
{
|
||||
m_data.Resize(nSize);
|
||||
m_data.Resize(nSize, nDataOffset);
|
||||
}
|
||||
template<typename T>
|
||||
CUtlVector<T> &CUtlVector<T>::operator=(const CUtlVector<T> &vec)
|
||||
|
||||
Reference in New Issue
Block a user