增加loader

This commit is contained in:
Huoji's
2023-10-08 01:56:49 +08:00
parent 9232d1c390
commit d787a7da07
28 changed files with 1692 additions and 131 deletions

View File

@@ -1,5 +1,5 @@
#include "convar.hpp"
#include "../../head.h"
inline const char** CCommand::ArgV() const {
return ArgC() ? (const char**)m_Args.Base() : NULL;
}
@@ -114,3 +114,64 @@ int DefaultCompletionFunc(const char* partial,
CUtlVector<CUtlString>& commands) {
return 0;
}
//-----------------------------------------------------------------------------
// Statically constructed list of ConCommandBases,
// used for registering them with the ICVar interface
//-----------------------------------------------------------------------------
static int64 s_nCVarFlag = 0;
static bool s_bRegistered = false;
class ConCommandRegList;
class ConCommandRegList
{
public:
static void RegisterCommand(ConCommand* pCmd)
{
if (s_bConCommandsRegistered)
{
ConCommandHandle hndl = Offset::InterFaces::IVEngineCvar->RegisterConCommand(pCmd, s_nCVarFlag);
if (!hndl.IsValid())
{
__debugbreak();
}
pCmd->SetHandle(hndl);
}
else
{
GetCommandRegList()->AddToTail(pCmd);
}
}
static void RegisterAll()
{
if (!s_bConCommandsRegistered && Offset::InterFaces::IVEngineCvar)
{
s_bConCommandsRegistered = true;
for (int i = 0; i < GetCommandRegList()->Count(); i++)
{
ConCommand* pCmd = GetCommandRegList()->Element(i);
ConCommandHandle hndl = Offset::InterFaces::IVEngineCvar->RegisterConCommand(pCmd, s_nCVarFlag);
pCmd->SetHandle(hndl);
if (!hndl.IsValid())
{
__debugbreak();
}
}
}
}
private:
// GAMMACASE: Required to prevent static initialization order problem https://isocpp.org/wiki/faq/ctors#static-init-order
static CUtlVector<ConCommand*>* GetCommandRegList()
{
static CUtlVector<ConCommand*> s_ConCommandRegList;
return &s_ConCommandRegList;
}
static bool s_bConCommandsRegistered;
};

View File

@@ -1,25 +1,49 @@
#pragma once
#include "../sdk.h"
struct characterset_t {
char set[256];
class CCommandContext;
class ConCommandHandle;
class CCommand;
class ConCommandRefAbstract;
class ICommandCallback
{
public:
virtual void CommandCallback(const CCommandContext& context, const CCommand& command) = 0;
};
class ConCommandBase {
class ICommandCompletionCallback
{
public:
virtual int CommandCompletionCallback(const char* pPartial, CUtlVector< CUtlString >& commands) = 0;
};
//-----------------------------------------------------------------------------
// Called when a ConCommand needs to execute
//-----------------------------------------------------------------------------
typedef void (*FnCommandCallback_t)(const CCommandContext& context, const CCommand& command);
typedef void (*FnCommandCallbackNoContext_t)(const CCommand& command);
typedef void (*FnCommandCallbackVoid_t)();
typedef int(*FnCommandCompletionCallback)(const char* partial, CUtlVector< CUtlString >& commands);
//-----------------------------------------------------------------------------
// Purpose: The base console invoked command/cvar interface
//-----------------------------------------------------------------------------
class ConCommandBase
{
friend class CCvar;
friend class ConCommand;
protected:
protected:
ConCommandBase(void);
public:
public:
~ConCommandBase(void);
// Check flag
bool IsFlagSet(int64_t flag) const;
bool IsFlagSet(int64 flag) const;
// Set flag
void AddFlags(int64_t flags);
void AddFlags(int64 flags);
// Clear flag
void RemoveFlags(int64_t flags);
void RemoveFlags(int64 flags);
int64_t GetFlags() const;
int64 GetFlags() const;
// Return name of cvar
const char* GetName(void) const;
@@ -27,14 +51,127 @@ class ConCommandBase {
// Return help text for cvar
const char* GetHelpText(void) const;
private:
private:
// Static data
const char* m_pszName;
const char* m_pszHelpString;
// ConVar flags
int64_t m_nFlags;
int64 m_nFlags;
};
class ConCommandHandle
{
public:
bool IsValid() { return value != kInvalidConCommandHandle; }
uint16 Get() { return value; }
void Set(uint16 _value) { value = _value; }
void Reset() { value = kInvalidConCommandHandle; }
bool HasCallback() const;
void Dispatch(const CCommandContext& context, const CCommand& command);
void Unregister();
private:
uint16_t value = kInvalidConCommandHandle;
private:
static const uint16 kInvalidConCommandHandle = 0xFFFF;
};
class ConCommandRefAbstract
{
public:
ConCommandHandle handle;
};
//-----------------------------------------------------------------------------
// Purpose: The console invoked command
//-----------------------------------------------------------------------------
class ConCommand : public ConCommandBase
{
friend class CCvar;
friend class ConCommandHandle;
public:
typedef ConCommandBase BaseClass;
ConCommand(ConCommandRefAbstract* pReferenceOut, const char* pName, FnCommandCallback_t callback,
const char* pHelpString = 0, int64 flags = 0, FnCommandCompletionCallback completionFunc = 0);
ConCommand(ConCommandRefAbstract* pReferenceOut, const char* pName, FnCommandCallbackVoid_t callback,
const char* pHelpString = 0, int64 flags = 0, FnCommandCompletionCallback completionFunc = 0);
ConCommand(ConCommandRefAbstract* pReferenceOut, const char* pName, FnCommandCallbackNoContext_t callback,
const char* pHelpString = 0, int64 flags = 0, FnCommandCompletionCallback completionFunc = 0);
ConCommand(ConCommandRefAbstract* pReferenceOut, const char* pName, ICommandCallback* pCallback,
const char* pHelpString = 0, int64 flags = 0, ICommandCompletionCallback* pCommandCompletionCallback = 0);
~ConCommand(void);
// Used internally by OneTimeInit to initialize/shutdown
void Init();
void Shutdown();
void Create(const char* pName, const char* pHelpString = 0,
int64 flags = 0);
int AutoCompleteSuggest(const char* partial, CUtlVector< CUtlString >& commands);
bool CanAutoComplete(void);
inline ConCommandRefAbstract* GetRef(void) const
{
return m_pReference;
}
inline void SetHandle(ConCommandHandle hndl)
{
m_pReference->handle = hndl;
}
private:
// Call this function when executing the command
class CallbackInfo_t
{
public:
union {
FnCommandCallback_t m_fnCommandCallback;
FnCommandCallbackVoid_t m_fnVoidCommandCallback;
FnCommandCallbackNoContext_t m_fnContextlessCommandCallback;
ICommandCallback* m_pCommandCallback;
};
bool m_bUsingCommandCallbackInterface : 1;
bool m_bHasVoidCommandCallback : 1;
bool m_bHasContextlessCommandCallback : 1;
};
CallbackInfo_t m_Callback;
// NOTE: To maintain backward compat, we have to be very careful:
// All public virtual methods must appear in the same order always
// since engine code will be calling into this code, which *does not match*
// in the mod code; it's using slightly different, but compatible versions
// of this class. Also: Be very careful about adding new fields to this class.
// Those fields will not exist in the version of this class that is instanced
// in mod code.
union
{
FnCommandCompletionCallback m_fnCompletionCallback;
ICommandCompletionCallback* m_pCommandCompletionCallback;
};
bool m_bHasCompletionCallback : 1;
bool m_bUsingCommandCompletionInterface : 1;
ConCommandRefAbstract* m_pReference;
};
struct characterset_t {
char set[256];
};
class CCommand {
public:
@@ -81,3 +218,116 @@ class CCommand {
CUtlVectorFixedGrowable<char, COMMAND_MAX_LENGTH> m_ArgvBuffer;
CUtlVectorFixedGrowable<char*, COMMAND_MAX_ARGC> m_Args;
};
struct CSplitScreenSlot
{
CSplitScreenSlot(int index)
{
m_Data = index;
}
int Get() const
{
return m_Data;
}
int m_Data;
};
class ConVarHandle
{
public:
bool IsValid() { return value != kInvalidConVarHandle; }
uint32 Get() { return value; }
void Set(uint32 _value) { value = _value; }
private:
uint32 value = kInvalidConVarHandle;
private:
static const uint32 kInvalidConVarHandle = 0xFFFFFFFF;
};
enum EConVarType : short
{
EConVarType_Invalid = -1,
EConVarType_Bool,
EConVarType_Int16,
EConVarType_UInt16,
EConVarType_Int32,
EConVarType_UInt32,
EConVarType_Int64,
EConVarType_UInt64,
EConVarType_Float32,
EConVarType_Float64,
EConVarType_String,
EConVarType_Color,
EConVarType_Vector2,
EConVarType_Vector3,
EConVarType_Vector4,
EConVarType_Qangle
};
class Vector;
union CVValue_t
{
bool m_bValue;
short m_i16Value;
uint16 m_u16Value;
int m_i32Value;
uint m_u32Value;
int64 m_i64Value;
uint64 m_u64Value;
float m_flValue;
double m_dbValue;
const char* m_szValue;
Color m_clrValue;
Vector2D m_vec2Value;
Vector_SimPleSdk m_vec3Value;
Vector4D m_vec4Value;
Vector_SimPleSdk m_angValue;
};
//-----------------------------------------------------------------------------
// Purpose: A console variable
//-----------------------------------------------------------------------------
class ConVar
{
friend class CCvar;
friend class ConVarRef;
friend class SplitScreenConVarRef;
public:
const char* m_pszName;
CVValue_t* m_cvvDefaultValue;
CVValue_t* m_cvvMinValue;
CVValue_t* m_cvvMaxValue;
const char* m_pszHelpString;
EConVarType m_eVarType;
// This gets copied from the ConVarDesc_t on creation
short unk1;
unsigned int timesChanged;
int64 flags;
unsigned int callback_index;
// Used when setting default, max, min values from the ConVarDesc_t
// although that's not the only place of usage
// flags seems to be:
// (1 << 0) Skip setting value to split screen slots and also something keyvalues related
// (1 << 1) Skip setting default value
// (1 << 2) Skip setting min/max values
int allocation_flag_of_some_sort;
CVValue_t** values;
};
class ConVarRefAbstract
{
public:
// High-speed method to read convar data
ConVarHandle m_Handle;
ConVar* m_pConVarState;
};

View File

@@ -6,146 +6,169 @@
#include "../interfaces/interfaces.h"
class CMsgSource1LegacyGameEvent;
class CUtlString;
class IToolGameEventAPI
{
virtual void unk001(void*) = 0;
class IToolGameEventAPI {
virtual void unk001(void*) = 0;
};
struct UnkGameEventStruct_t {
UnkGameEventStruct_t(const char* keyName) {
m_Unk = 0;
m_Key = keyName;
}
UnkGameEventStruct_t(const char* keyName) {
m_Unk = 0;
m_Key = keyName;
}
uint64_t m_Unk;
const char* m_Key;
uint64_t m_Unk;
const char* m_Key;
};
class IGameEvent
{
public:
// 0
virtual ~IGameEvent() {};
virtual const char* GetName() const = 0; // get event name
virtual int GetID() const = 0;
class IGameEvent {
public:
// 0
virtual ~IGameEvent(){};
virtual const char* GetName() const = 0; // get event name
virtual int GetID() const = 0;
virtual bool IsReliable() const = 0; // if event handled reliable
virtual bool IsLocal() const = 0; // if event is never networked
virtual bool IsEmpty(const char* keyName = NULL) = 0; // check if data field exists
virtual bool IsReliable() const = 0; // if event handled reliable
virtual bool IsLocal() const = 0; // if event is never networked
virtual bool IsEmpty(
const char* keyName = NULL) = 0; // check if data field exists
// Data access index 6
virtual bool GetBool(UnkGameEventStruct_t* keyName = NULL, bool defaultValue = false) = 0;
virtual int GetInt(const char* keyName = NULL, int defaultValue = 0) = 0;
virtual uint64_t GetUint64(const char* keyName = NULL, uint64_t defaultValue = 0) = 0;
virtual float GetFloat(const char* keyName = NULL, float defaultValue = 0.0f) = 0;
virtual const char* GetString(const char* keyName = NULL, const char* defaultValue = "") = 0;
virtual void* GetPtr(const char* keyName = NULL, void* defaultValue = NULL) = 0;
// Data access index 6
virtual bool GetBool(UnkGameEventStruct_t* keyName = NULL,
bool defaultValue = false) = 0;
virtual int GetInt(UnkGameEventStruct_t* keyName = NULL,
int defaultValue = 0) = 0;
virtual uint64_t GetUint64(const char* keyName = NULL,
uint64_t defaultValue = 0) = 0;
virtual float GetFloat(const char* keyName = NULL,
float defaultValue = 0.0f) = 0;
virtual const char* GetString(UnkGameEventStruct_t* keyName = NULL,
const char* defaultValue = "") = 0;
virtual void* GetPtr(const char* keyName = NULL,
void* defaultValue = NULL) = 0;
/* These function prototypes and names are very speculative and might be incorrect */
virtual CEntityHandle GetEHandle(UnkGameEventStruct_t* keyName, CEntityHandle defaultValue) = 0;
virtual CEntityHandle GetStrictEHandle(UnkGameEventStruct_t* keyName, CEntityHandle defaultValue) = 0;
virtual CEntityHandle GetEHandle2(UnkGameEventStruct_t* keyName, CEntityHandle defaultValue) = 0;
/* These function prototypes and names are very speculative and might be
* incorrect */
virtual CEntityHandle GetEHandle(UnkGameEventStruct_t* keyName,
CEntityHandle defaultValue) = 0;
virtual CEntityHandle GetStrictEHandle(UnkGameEventStruct_t* keyName,
CEntityHandle defaultValue) = 0;
virtual CEntityHandle GetEHandle2(UnkGameEventStruct_t* keyName,
CEntityHandle defaultValue) = 0;
virtual CPlayerSlot* GetPlayerSlot(UnkGameEventStruct_t* keyName = NULL) = 0;
virtual CBasePlayer* GetPlayer(UnkGameEventStruct_t* keyName = NULL) = 0;
virtual CPlayerSlot* GetPlayerSlot(
UnkGameEventStruct_t* keyName = NULL) = 0;
virtual CBasePlayer* GetPlayer(UnkGameEventStruct_t* keyName = NULL) = 0;
virtual void* GetPlayerPawn(UnkGameEventStruct_t* keyName = NULL) = 0;
virtual CEntityHandle GetPlayerControllerEHandle(UnkGameEventStruct_t* keyName = NULL) = 0;
virtual CEntityHandle GetPlayerControllerEHandle2(UnkGameEventStruct_t* keyName = NULL) = 0;
/* ============================================================ */
virtual void* GetPlayerPawn(UnkGameEventStruct_t* keyName = NULL) = 0;
virtual CEntityHandle GetPlayerControllerEHandle(
UnkGameEventStruct_t* keyName = NULL) = 0;
virtual CEntityHandle GetPlayerControllerEHandle2(
UnkGameEventStruct_t* keyName = NULL) = 0;
/* ============================================================ */
virtual void SetBool(const char* keyName, bool value) = 0;
virtual void SetInt(const char* keyName, int value) = 0;
virtual void SetUint64(const char* keyName, uint64_t value) = 0;
virtual void SetFloat(const char* keyName, float value) = 0;
virtual void SetString(const char* keyName, const char* value) = 0;
virtual void SetPtr(const char* keyName, void* value) = 0;
virtual void SetBool(const char* keyName, bool value) = 0;
virtual void SetInt(const char* keyName, int value) = 0;
virtual void SetUint64(const char* keyName, uint64_t value) = 0;
virtual void SetFloat(const char* keyName, float value) = 0;
virtual void SetString(const char* keyName, const char* value) = 0;
virtual void SetPtr(const char* keyName, void* value) = 0;
/* These function prototypes and names are very speculative and might be incorrect */
virtual void SetEHandleStrict(const char* keyName, CEntityHandle handle) = 0;
virtual void SetEHandle(const char* keyName, CEntityHandle handle) = 0;
/* These function prototypes and names are very speculative and might be
* incorrect */
virtual void SetEHandleStrict(const char* keyName,
CEntityHandle handle) = 0;
virtual void SetEHandle(const char* keyName, CEntityHandle handle) = 0;
// Also sets the _pawn key
virtual void SetPlayerSlot(const char* keyName, CPlayerSlot value) = 0;
virtual void SetPlayer(const char* keyName, CBasePlayer* value) = 0;
/* ============================================================ */
// Also sets the _pawn key
virtual void SetPlayerSlot(const char* keyName, CPlayerSlot value) = 0;
virtual void SetPlayer(const char* keyName, CBasePlayer* value) = 0;
/* ============================================================ */
virtual bool HasKey(const char* keyName) = 0;
virtual bool HasKey(const char* keyName) = 0;
// Something script vm related
virtual void unk001() = 0;
// Something script vm related
virtual void unk001() = 0;
//virtual KeyValues* GetDataKeys() const = 0;
// virtual KeyValues* GetDataKeys() const = 0;
};
class IGameEventListener2
{
public:
virtual ~IGameEventListener2(void) {};
class IGameEventListener2 {
public:
virtual ~IGameEventListener2(void){};
// FireEvent is called by EventManager if event just occured
// KeyValue memory will be freed by manager if not needed anymore
virtual void FireGameEvent(IGameEvent* event) = 0;
// FireEvent is called by EventManager if event just occured
// KeyValue memory will be freed by manager if not needed anymore
virtual void FireGameEvent(IGameEvent* event) = 0;
};
class IGameEventManager2 : public IBaseInterface, public IToolGameEventAPI
{
public:
virtual ~IGameEventManager2(void) {};
class IGameEventManager2 : public IBaseInterface, public IToolGameEventAPI {
public:
virtual ~IGameEventManager2(void){};
// load game event descriptions from a file eg "resource\gameevents.res"
virtual int LoadEventsFromFile(const char* filename, bool bSearchAll) = 0;
// load game event descriptions from a file eg "resource\gameevents.res"
virtual int LoadEventsFromFile(const char* filename, bool bSearchAll) = 0;
// removes all and anything
virtual void Reset() = 0;
// removes all and anything
virtual void Reset() = 0;
// adds a listener for a particular event
virtual bool AddListener(IGameEventListener2* listener, const char* name, bool bServerSide) = 0;
// adds a listener for a particular event
virtual bool AddListener(IGameEventListener2* listener, const char* name,
bool bServerSide) = 0;
// returns true if this listener is listens to given event
virtual bool FindListener(IGameEventListener2* listener, const char* name) = 0;
// returns true if this listener is listens to given event
virtual bool FindListener(IGameEventListener2* listener,
const char* name) = 0;
// removes a listener
virtual void RemoveListener(IGameEventListener2* listener) = 0;
// removes a listener
virtual void RemoveListener(IGameEventListener2* listener) = 0;
// create an event by name, but doesn't fire it. returns NULL is event is not
// known or no listener is registered for it. bForce forces the creation even if no listener is active
virtual IGameEvent* CreateEvent(const char* name, bool bForce = false, int* pCookie = NULL) = 0;
// create an event by name, but doesn't fire it. returns NULL is event is
// not known or no listener is registered for it. bForce forces the creation
// even if no listener is active
virtual IGameEvent* CreateEvent(const char* name, bool bForce = false,
int* pCookie = NULL) = 0;
// fires a server event created earlier, if bDontBroadcast is set, event is not send to clients
virtual bool FireEvent(IGameEvent* event, bool bDontBroadcast = false) = 0;
// fires a server event created earlier, if bDontBroadcast is set, event is
// not send to clients
virtual bool FireEvent(IGameEvent* event, bool bDontBroadcast = false) = 0;
// fires an event for the local client only, should be used only by client code
virtual bool FireEventClientSide(IGameEvent* event) = 0;
// fires an event for the local client only, should be used only by client
// code
virtual bool FireEventClientSide(IGameEvent* event) = 0;
// create a new copy of this event, must be free later
virtual IGameEvent* DuplicateEvent(IGameEvent* event) = 0;
// create a new copy of this event, must be free later
virtual IGameEvent* DuplicateEvent(IGameEvent* event) = 0;
// if an event was created but not fired for some reason, it has to bee freed, same UnserializeEvent
virtual void FreeEvent(IGameEvent* event) = 0;
// if an event was created but not fired for some reason, it has to bee
// freed, same UnserializeEvent
virtual void FreeEvent(IGameEvent* event) = 0;
// write/read event to/from bitbuffer
virtual bool SerializeEvent(IGameEvent* event, CMsgSource1LegacyGameEvent* ev) = 0;
virtual IGameEvent* UnserializeEvent(const CMsgSource1LegacyGameEvent& ev) = 0; // create new KeyValues, must be deleted
// write/read event to/from bitbuffer
virtual bool SerializeEvent(IGameEvent* event,
CMsgSource1LegacyGameEvent* ev) = 0;
virtual IGameEvent* UnserializeEvent(
const CMsgSource1LegacyGameEvent&
ev) = 0; // create new KeyValues, must be deleted
virtual int LookupEventId(const char* name) = 0;
virtual int LookupEventId(const char* name) = 0;
virtual void PrintEventToString(IGameEvent* event, CUtlString& out) = 0;
virtual void PrintEventToString(IGameEvent* event, CUtlString& out) = 0;
virtual bool HasEventDescriptor(const char* name) = 0;
virtual bool HasEventDescriptor(const char* name) = 0;
};
class CGameEventManager : public IGameEventManager2
{
public: // IGameEventManager functions
virtual ~CGameEventManager() = 0;
class CGameEventManager : public IGameEventManager2 {
public: // IGameEventManager functions
virtual ~CGameEventManager() = 0;
virtual int LoadEventsFromFile(const char* filename) = 0;
virtual void Reset() = 0;
virtual int LoadEventsFromFile(const char* filename) = 0;
virtual void Reset() = 0;
virtual bool AddListener(IGameEventListener2* listener, const char* name, bool bServerSide) = 0;
virtual bool FindListener(IGameEventListener2* listener, const char* name) = 0;
virtual void RemoveListener(IGameEventListener2* listener) = 0;
virtual bool AddListener(IGameEventListener2* listener, const char* name,
bool bServerSide) = 0;
virtual bool FindListener(IGameEventListener2* listener,
const char* name) = 0;
virtual void RemoveListener(IGameEventListener2* listener) = 0;
virtual IGameEvent* CreateEvent(const char* name, bool bForce = false) = 0;
virtual IGameEvent* DuplicateEvent(IGameEvent* event) = 0;
virtual bool FireEvent(IGameEvent* event, bool bDontBroadcast = false) = 0;
virtual bool FireEventClientSide(IGameEvent* event) = 0;
virtual IGameEvent* CreateEvent(const char* name, bool bForce = false) = 0;
virtual IGameEvent* DuplicateEvent(IGameEvent* event) = 0;
virtual bool FireEvent(IGameEvent* event, bool bDontBroadcast = false) = 0;
virtual bool FireEventClientSide(IGameEvent* event) = 0;
};

View File

@@ -0,0 +1,49 @@
#pragma once
#include "../sdk.h"
//cancer fix me
struct Vector_SimPleSdk
{
public:
float x, y, z;
Vector_SimPleSdk()
{}
Vector_SimPleSdk(float x_, float y_, float z_)
{
x = x_;
y = y_;
z = z_;
}
};
struct Vector2D
{
public:
float x, y;
Vector2D()
{}
Vector2D(float x_, float y_)
{
x = x_;
y = y_;
}
};
struct Vector4D
{
public:
float x, y, z, c;
Vector4D()
{}
Vector4D(float x_, float y_, float z_, float c_)
{
x = x_;
y = y_;
z = z_;
c = c_;
}
};

367
csgo2/sdk/public/color.h Normal file
View File

@@ -0,0 +1,367 @@
#pragma once
#include "../sdk.h"
class Color
{
public:
Color()
{
*((int*)this) = 0;
}
Color(int color32)
{
*((int*)this) = color32;
}
Color(int _r, int _g, int _b)
{
SetColor(_r, _g, _b, 255);
}
Color(int _r, int _g, int _b, int _a)
{
SetColor(_r, _g, _b, _a);
}
void SetColor(int _r, int _g, int _b, int _a = 255)
{
_color[0] = (unsigned char)_r;
_color[1] = (unsigned char)_g;
_color[2] = (unsigned char)_b;
_color[3] = (unsigned char)_a;
}
void GetColor(int& _r, int& _g, int& _b, int& _a) const
{
_r = _color[0];
_g = _color[1];
_b = _color[2];
_a = _color[3];
}
void SetRawColor(int color32)
{
*((int*)this) = color32;
}
int GetRawColor() const
{
return *((int*)this);
}
int GetD3DColor() const
{
return ((int)((((_color[3]) & 0xff) << 24) | (((_color[0]) & 0xff) << 16) | (((_color[1]) & 0xff) << 8) | ((_color[2]) & 0xff)));
}
inline int r() const
{
return _color[0];
}
inline int g() const
{
return _color[1];
}
inline int b() const
{
return _color[2];
}
inline int a() const
{
return _color[3];
}
inline float rBase() const
{
return _color[0] / 255.0f;
}
inline float gBase() const
{
return _color[1] / 255.0f;
}
inline float bBase() const
{
return _color[2] / 255.0f;
}
inline float aBase() const
{
return _color[3] / 255.0f;
}
unsigned char& operator[](int index)
{
return _color[index];
}
const unsigned char& operator[](int index) const
{
return _color[index];
}
bool operator ==(const Color& rhs) const
{
return (*((int*)this) == *((int*)&rhs));
}
bool operator !=(const Color& rhs) const
{
return !(operator==(rhs));
}
Color& operator=(const Color& rhs)
{
SetRawColor(rhs.GetRawColor());
return *this;
}
float* Base()
{
float clr[3];
clr[0] = _color[0] / 255.0f;
clr[1] = _color[1] / 255.0f;
clr[2] = _color[2] / 255.0f;
return &clr[0];
}
float* BaseAlpha()
{
float clr[4];
clr[0] = _color[0] / 255.0f;
clr[1] = _color[1] / 255.0f;
clr[2] = _color[2] / 255.0f;
clr[3] = _color[3] / 255.0f;
return &clr[0];
}
float Hue() const
{
if (_color[0] == _color[1] && _color[1] == _color[2])
{
return 0.0f;
}
float r = _color[0] / 255.0f;
float g = _color[1] / 255.0f;
float b = _color[2] / 255.0f;
float max = r > g ? r : g > b ? g : b,
min = r < g ? r : g < b ? g : b;
float delta = max - min;
float hue = 0.0f;
if (r == max)
{
hue = (g - b) / delta;
}
else if (g == max)
{
hue = 2 + (b - r) / delta;
}
else if (b == max)
{
hue = 4 + (r - g) / delta;
}
hue *= 60;
if (hue < 0.0f)
{
hue += 360.0f;
}
return hue;
}
float Saturation() const
{
float r = _color[0] / 255.0f;
float g = _color[1] / 255.0f;
float b = _color[2] / 255.0f;
float max = r > g ? r : g > b ? g : b,
min = r < g ? r : g < b ? g : b;
float l, s = 0;
if (max != min)
{
l = (max + min) / 2;
if (l <= 0.5f)
s = (max - min) / (max + min);
else
s = (max - min) / (2 - max - min);
}
return s;
}
float Brightness() const
{
float r = _color[0] / 255.0f;
float g = _color[1] / 255.0f;
float b = _color[2] / 255.0f;
float max = r > g ? r : g > b ? g : b,
min = r < g ? r : g < b ? g : b;
return (max + min) / 2;
}
static Color FromHSB(float hue, float saturation, float brightness)
{
float h = hue == 1.0f ? 0 : hue * 6.0f;
float f = h - (int)h;
float p = brightness * (1.0f - saturation);
float q = brightness * (1.0f - saturation * f);
float t = brightness * (1.0f - (saturation * (1.0f - f)));
if (h < 1)
{
return Color(
(unsigned char)(brightness * 255),
(unsigned char)(t * 255),
(unsigned char)(p * 255)
);
}
else if (h < 2)
{
return Color(
(unsigned char)(q * 255),
(unsigned char)(brightness * 255),
(unsigned char)(p * 255)
);
}
else if (h < 3)
{
return Color(
(unsigned char)(p * 255),
(unsigned char)(brightness * 255),
(unsigned char)(t * 255)
);
}
else if (h < 4)
{
return Color(
(unsigned char)(p * 255),
(unsigned char)(q * 255),
(unsigned char)(brightness * 255)
);
}
else if (h < 5)
{
return Color(
(unsigned char)(t * 255),
(unsigned char)(p * 255),
(unsigned char)(brightness * 255)
);
}
else
{
return Color(
(unsigned char)(brightness * 255),
(unsigned char)(p * 255),
(unsigned char)(q * 255)
);
}
}
static Color Red()
{
return Color(255, 0, 0);
}
static Color Green()
{
return Color(0, 255, 0);
}
static Color Blue()
{
return Color(0, 0, 255);
}
static Color LightBlue()
{
return Color(100, 100, 255);
}
static Color Grey()
{
return Color(128, 128, 128);
}
static Color DarkGrey()
{
return Color(45, 45, 45);
}
static Color Black()
{
return Color(0, 0, 0);
}
static Color White()
{
return Color(255, 255, 255);
}
static Color Purple()
{
return Color(220, 0, 220);
}
//Menu
static Color Background()
{
return Color(55, 55, 55);
}
static Color FrameBorder()
{
return Color(80, 80, 80);
}
static Color MainText()
{
return Color(230, 230, 230);
}
static Color HeaderText()
{
return Color(49, 124, 230);
}
static Color CurrentTab()
{
return Color(55, 55, 55);
}
static Color Tabs()
{
return Color(23, 23, 23);
}
static Color Highlight()
{
return Color(49, 124, 230);
}
static Color ElementBorder()
{
return Color(0, 0, 0);
}
static Color SliderScroll()
{
return Color(78, 143, 230);
}
private:
unsigned char _color[4];
};

View File

@@ -127,7 +127,36 @@ inline CGlobalVars::CGlobalVars() :
}
class CSharedEdictChangeInfo;
class IAchievementMgr;
class CCommandContext;
enum CommandTarget_t
{
CT_NO_TARGET = -1,
CT_FIRST_SPLITSCREEN_CLIENT = 0,
CT_LAST_SPLITSCREEN_CLIENT = 3,
};
class CCommandContext
{
public:
CCommandContext(CommandTarget_t nTarget, CPlayerSlot nSlot) :
m_nTarget(nTarget), m_nPlayerSlot(nSlot)
{
}
CommandTarget_t GetTarget() const
{
return m_nTarget;
}
CPlayerSlot GetPlayerSlot() const
{
return m_nPlayerSlot;
}
private:
CommandTarget_t m_nTarget;
CPlayerSlot m_nPlayerSlot;
};
class EconControlPointInfo_t;
struct EconItemInfo_t {

84
csgo2/sdk/public/icvar.h Normal file
View File

@@ -0,0 +1,84 @@
#pragma once
#include "../sdk.h"
class ConCommandBase;
class ConVar;
class Color;
class IConVarListener;
class CConVarDetail;
struct ConVarSnapshot_t;
union CVValue_t;
class KeyValues;
class ConVarRefAbstract;
class ConVarHandle;
struct CSplitScreenSlot;
class ConCommandHandle;
class ConCommand;
typedef void(*FnChangeCallbackGlobal_t)(ConVarRefAbstract* cvar, CSplitScreenSlot nSlot, const char* pNewValue, const char* pOldValue);
typedef void(*FnChangeCallback_t)(ConVarRefAbstract* cvar, CSplitScreenSlot nSlot, CVValue_t* pNewValue, CVValue_t* pOldValue);
class ConCommandRefAbstract;
class ConVarRefAbstract;
class ICVarListenerCallbacks
{
public:
virtual void OnConVarCreated(ConVarRefAbstract* pNewCvar) = 0;
virtual void OnConCommandCreated(ConCommandRefAbstract* pNewCommand) = 0;
};
//-----------------------------------------------------------------------------
// Purpose: DLL interface to ConVars/ConCommands
//-----------------------------------------------------------------------------
class ICvar : public IAppSystem
{
public:
// bAllowDeveloper - Allows finding convars with FCVAR_DEVELOPMENTONLY flag
virtual ConVarHandle FindConVar(const char* name, bool bAllowDeveloper = false) = 0;
virtual ConVarHandle FindFirstConVar() = 0;
virtual ConVarHandle FindNextConVar(ConVarHandle prev) = 0;
virtual void SetConVarValue(ConVarHandle cvarid, CSplitScreenSlot nSlot, CVValue_t* pNewValue, CVValue_t* pOldValue) = 0;
virtual ConCommandHandle FindCommand(const char* name) = 0;
virtual ConCommandHandle FindFirstCommand() = 0;
virtual ConCommandHandle FindNextCommand(ConCommandHandle prev) = 0;
virtual void DispatchConCommand(ConCommandHandle cmd, const CCommandContext& ctx, const CCommand& args) = 0;
// Install a global change callback (to be called when any convar changes)
virtual void InstallGlobalChangeCallback(FnChangeCallbackGlobal_t callback) = 0;
virtual void RemoveGlobalChangeCallback(FnChangeCallbackGlobal_t callback) = 0;
virtual void CallGlobalChangeCallbacks(ConVarRefAbstract* var, CSplitScreenSlot nSlot, const char* pOldString, float flOldValue) = 0;
// Reverts cvars which contain a specific flag
virtual void RevertFlaggedConVars(int nFlag) = 0;
virtual void SetMaxSplitScreenSlots(int nSlots) = 0;
virtual int GetMaxSplitScreenSlots() const = 0;
virtual void RegisterCreationListeners(ICVarListenerCallbacks* callbacks) = 0;
virtual void RemoveCreationListeners(ICVarListenerCallbacks* callbacks) = 0;
virtual void unk1() = 0;
virtual void ResetConVarsToDefaultValues(const char* pszPrefix) = 0;
virtual ConVarSnapshot_t* TakeConVarSnapshot(void) = 0;
virtual void ResetConVarsToSnapshot(ConVarSnapshot_t* pSnapshot) = 0;
virtual void DestroyConVarSnapshot(ConVarSnapshot_t* pSnaoshot) = 0;
virtual characterset_t GetCharacterSet(void) = 0;
virtual void SetConVarsFromGameInfo(KeyValues* pKV) = 0;
virtual void unk2() = 0;
// Register, unregister vars
virtual void RegisterConVar(ConVar* pConVar, int64 nAdditionalFlags, ConVarHandle& pCvarRef, ConVar& pCvar) = 0;
virtual void UnregisterConVar(ConVarHandle handle) = 0;
virtual ConVar* GetConVar(ConVarHandle handle) = 0;
// Register, unregister commands
virtual ConCommandHandle RegisterConCommand(ConCommand* pCmd, int64 nAdditionalFlags = 0) = 0;
virtual void UnregisterConCommand(ConCommandHandle handle) = 0;
virtual ConCommand* GetCommand(ConCommandHandle handle) = 0;
virtual void QueueThreadSetValue(ConVarRefAbstract* ref, CSplitScreenSlot nSlot, CVValue_t* value) = 0;
};

View File

@@ -16,6 +16,7 @@
#define INCORRECT_PATH_SEPARATOR '/'
#define INCORRECT_PATH_SEPARATOR_S "/"
#define FMTFUNCTION(a, b)
enum EStringConvertErrorPolicy {
_STRINGCONVERTFLAG_SKIP = 1,
_STRINGCONVERTFLAG_FAIL = 2,
@@ -79,6 +80,10 @@ inline T AlignValue(T val, uintptr_t alignment) {
return (T)(((uintptr_t)val + alignment - 1) & ~(alignment - 1));
}
#include "public/Vector_Sdk.h"
#include "public/color.h"
#include "player/playerslot.h"
#include "public/mathlib.h"
@@ -103,7 +108,7 @@ inline T AlignValue(T val, uintptr_t alignment) {
#include "interfaces/interfaces.h"
#include "gameevent/IGameEvent.h"
#include "convar/convar.hpp"
#include "public/icvar.h"
#include "gameevent/IGameEvent.h"
#include "tier1/bufferstring.h"
#include "public/eiface.h"