Build fixes for recent hl2sdk-dota updates.
Build fixes for recent hl2sdk-dota updates.
1.1 --- a/core/ChatTriggers.cpp Tue Apr 23 07:11:49 2013 -0400
1.2 +++ b/core/ChatTriggers.cpp Tue Apr 23 07:11:49 2013 -0400
1.3 @@ -37,23 +37,20 @@
1.4 #include "HalfLife2.h"
1.5 #include "logic_bridge.h"
1.6
1.7 -/* :HACKHACK: We can't SH_DECL here because ConCmdManager.cpp does.
1.8 - * While the OB build only runs on MM:S 1.6.0+ (SH 5+), the older one
1.9 - * can technically be compiled against any MM:S version after 1.4.2.
1.10 - */
1.11 -#if SOURCE_ENGINE >= SE_ORANGEBOX
1.12 -extern bool __SourceHook_FHRemoveConCommandDispatch(void *, bool, class fastdelegate::FastDelegate1<const CCommand &, void>);
1.13 -extern int __SourceHook_FHAddConCommandDispatch(void *, ISourceHook::AddHookMode, bool, class fastdelegate::FastDelegate1<const CCommand &, void>);
1.14 +#if SOURCE_ENGINE == SE_DOTA
1.15 +SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, void *, const CCommand &);
1.16 +#elif SOURCE_ENGINE >= SE_ORANGEBOX
1.17 +SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
1.18 +#elif SOURCE_ENGINE == SE_DARKMESSIAH
1.19 +SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
1.20 #else
1.21 -extern bool __SourceHook_FHRemoveConCommandDispatch(void *, bool, class fastdelegate::FastDelegate0<void>);
1.22 -#if SH_IMPL_VERSION >= 5
1.23 -extern int __SourceHook_FHAddConCommandDispatch(void *, ISourceHook::AddHookMode, bool, class fastdelegate::FastDelegate0<void>);
1.24 -#elif SH_IMPL_VERSION == 4
1.25 -extern int __SourceHook_FHAddConCommandDispatch(void *, bool, class fastdelegate::FastDelegate0<void>);
1.26 -#elif SH_IMPL_VERSION == 3
1.27 -extern bool __SourceHook_FHAddConCommandDispatch(void *, bool, class fastdelegate::FastDelegate0<void>);
1.28 -#endif //SH_IMPL_VERSION
1.29 -#endif //SE_ORANGEBOX
1.30 +# if SH_IMPL_VERSION >= 4
1.31 + extern int __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
1.32 +# else
1.33 + extern bool __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
1.34 +# endif
1.35 +extern bool __SourceHook_FHRemoveConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
1.36 +#endif
1.37
1.38 ChatTriggers g_ChatTriggers;
1.39 bool g_bSupressSilentFails = false;
1.40 @@ -150,7 +147,10 @@
1.41 g_Forwards.ReleaseForward(m_pDidFloodBlock);
1.42 }
1.43
1.44 -#if SOURCE_ENGINE >= SE_ORANGEBOX
1.45 +#if SOURCE_ENGINE == SE_DOTA
1.46 +void ChatTriggers::OnSayCommand_Pre(void *pUnknown, const CCommand &command)
1.47 +{
1.48 +#elif SOURCE_ENGINE >= SE_ORANGEBOX
1.49 void ChatTriggers::OnSayCommand_Pre(const CCommand &command)
1.50 {
1.51 #else
1.52 @@ -267,7 +267,9 @@
1.53 RETURN_META(MRES_IGNORED);
1.54 }
1.55
1.56 -#if SOURCE_ENGINE >= SE_ORANGEBOX
1.57 +#if SOURCE_ENGINE == SE_DOTA
1.58 +void ChatTriggers::OnSayCommand_Post(void *pUnknown, const CCommand &command)
1.59 +#elif SOURCE_ENGINE >= SE_ORANGEBOX
1.60 void ChatTriggers::OnSayCommand_Post(const CCommand &command)
1.61 #else
1.62 void ChatTriggers::OnSayCommand_Post()
2.1 --- a/core/ChatTriggers.h Tue Apr 23 07:11:49 2013 -0400
2.2 +++ b/core/ChatTriggers.h Tue Apr 23 07:11:49 2013 -0400
2.3 @@ -54,7 +54,10 @@
2.4 char *error,
2.5 size_t maxlength);
2.6 private: //ConCommand
2.7 -#if SOURCE_ENGINE >= SE_ORANGEBOX
2.8 +#if SOURCE_ENGINE == SE_DOTA
2.9 + void OnSayCommand_Pre(void *pUnknown, const CCommand &command);
2.10 + void OnSayCommand_Post(void *pUnknown, const CCommand &command);
2.11 +#elif SOURCE_ENGINE >= SE_ORANGEBOX
2.12 void OnSayCommand_Pre(const CCommand &command);
2.13 void OnSayCommand_Post(const CCommand &command);
2.14 #else
3.1 --- a/core/ConCmdManager.cpp Tue Apr 23 07:11:49 2013 -0400
3.2 +++ b/core/ConCmdManager.cpp Tue Apr 23 07:11:49 2013 -0400
3.3 @@ -40,7 +40,9 @@
3.4
3.5 ConCmdManager g_ConCmds;
3.6
3.7 -#if SOURCE_ENGINE >= SE_ORANGEBOX
3.8 +#if SOURCE_ENGINE == SE_DOTA
3.9 + SH_DECL_HOOK2_void(ConCommand, Dispatch, SH_NOATTRIB, false, void *, const CCommand &);
3.10 +#elif SOURCE_ENGINE >= SE_ORANGEBOX
3.11 SH_DECL_HOOK1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
3.12 #else
3.13 SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
3.14 @@ -206,7 +208,10 @@
3.15 delete pList;
3.16 }
3.17 }
3.18 -#if SOURCE_ENGINE >= SE_ORANGEBOX
3.19 +#if SOURCE_ENGINE == SE_DOTA
3.20 +void CommandCallback(void *pUnknown, const CCommand &command)
3.21 +{
3.22 +#elif SOURCE_ENGINE >= SE_ORANGEBOX
3.23 void CommandCallback(const CCommand &command)
3.24 {
3.25 #else
4.1 --- a/core/ConCmdManager.h Tue Apr 23 07:11:49 2013 -0400
4.2 +++ b/core/ConCmdManager.h Tue Apr 23 07:11:49 2013 -0400
4.3 @@ -98,7 +98,9 @@
4.4 public IPluginsListener,
4.5 public IConCommandTracker
4.6 {
4.7 -#if SOURCE_ENGINE >= SE_ORANGEBOX
4.8 +#if SOURCE_ENGINE == SE_DOTA
4.9 + friend void CommandCallback(void *pUnknown, const CCommand &command);
4.10 +#elif SOURCE_ENGINE >= SE_ORANGEBOX
4.11 friend void CommandCallback(const CCommand &command);
4.12 #else
4.13 friend void CommandCallback();
5.1 --- a/core/ConsoleDetours.cpp Tue Apr 23 07:11:49 2013 -0400
5.2 +++ b/core/ConsoleDetours.cpp Tue Apr 23 07:11:49 2013 -0400
5.3 @@ -59,7 +59,9 @@
5.4 #endif
5.5
5.6 #if SH_IMPL_VERSION >= 5
5.7 -# if SOURCE_ENGINE >= SE_ORANGEBOX
5.8 +# if SOURCE_ENGINE == SE_DOTA
5.9 + SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, void *, const CCommand &);
5.10 +# elif SOURCE_ENGINE >= SE_ORANGEBOX
5.11 SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
5.12 # else
5.13 SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
5.14 @@ -131,7 +133,9 @@
5.15 }
5.16 }
5.17
5.18 -# if SOURCE_ENGINE >= SE_ORANGEBOX
5.19 +# if SOURCE_ENGINE == SE_DOTA
5.20 + void Dispatch(void *pUnknown, const CCommand& args)
5.21 +# elif SOURCE_ENGINE >= SE_ORANGEBOX
5.22 void Dispatch(const CCommand& args)
5.23 # else
5.24 void Dispatch()
6.1 --- a/core/CoreConfig.cpp Tue Apr 23 07:11:49 2013 -0400
6.2 +++ b/core/CoreConfig.cpp Tue Apr 23 07:11:49 2013 -0400
6.3 @@ -61,7 +61,10 @@
6.4
6.5 void CheckAndFinalizeConfigs();
6.6
6.7 -#if SOURCE_ENGINE >= SE_ORANGEBOX
6.8 +#if SOURCE_ENGINE == SE_DOTA
6.9 +SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, void *, const CCommand &);
6.10 +void Hook_ExecDispatchPre(void *pUnknown, const CCommand &cmd)
6.11 +#elif SOURCE_ENGINE >= SE_ORANGEBOX
6.12 SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
6.13 void Hook_ExecDispatchPre(const CCommand &cmd)
6.14 #elif SOURCE_ENGINE == SE_DARKMESSIAH
6.15 @@ -89,7 +92,9 @@
6.16 }
6.17 }
6.18
6.19 -#if SOURCE_ENGINE >= SE_ORANGEBOX
6.20 +#if SOURCE_ENGINE == SE_DOTA
6.21 +void Hook_ExecDispatchPost(void *pUnknown, const CCommand &cmd)
6.22 +#elif SOURCE_ENGINE >= SE_ORANGEBOX
6.23 void Hook_ExecDispatchPost(const CCommand &cmd)
6.24 #else
6.25 void Hook_ExecDispatchPost()
7.1 --- a/core/NextMap.cpp Tue Apr 23 07:11:49 2013 -0400
7.2 +++ b/core/NextMap.cpp Tue Apr 23 07:11:49 2013 -0400
7.3 @@ -45,7 +45,9 @@
7.4 SH_DECL_HOOK4_void(IVEngineServer, ChangeLevel, SH_NOATTRIB, 0, const char *, const char *, const char *, bool);
7.5 #endif
7.6
7.7 -#if SOURCE_ENGINE >= SE_ORANGEBOX
7.8 +#if SOURCE_ENGINE == SE_DOTA
7.9 +SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, void *, const CCommand &);
7.10 +#elif SOURCE_ENGINE >= SE_ORANGEBOX
7.11 SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
7.12 #elif SOURCE_ENGINE == SE_DARKMESSIAH
7.13 SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
7.14 @@ -205,7 +207,10 @@
7.15 m_mapHistory = SourceHook::List<MapChangeData *>();
7.16 }
7.17
7.18 -#if SOURCE_ENGINE >= SE_ORANGEBOX
7.19 +#if SOURCE_ENGINE == SE_DOTA
7.20 +void CmdChangeLevelCallback(void *pUnknown, const CCommand &command)
7.21 +{
7.22 +#elif SOURCE_ENGINE >= SE_ORANGEBOX
7.23 void CmdChangeLevelCallback(const CCommand &command)
7.24 {
7.25 #else
8.1 --- a/core/NextMap.h Tue Apr 23 07:11:49 2013 -0400
8.2 +++ b/core/NextMap.h Tue Apr 23 07:11:49 2013 -0400
8.3 @@ -58,7 +58,9 @@
8.4 time_t startTime;
8.5 };
8.6
8.7 -#if SOURCE_ENGINE >= SE_ORANGEBOX
8.8 +#if SOURCE_ENGINE == SE_DOTA
8.9 +void CmdChangeLevelCallback(void *pUnknown, const CCommand &command);
8.10 +#elif SOURCE_ENGINE >= SE_ORANGEBOX
8.11 void CmdChangeLevelCallback(const CCommand &command);
8.12 #else
8.13 void CmdChangeLevelCallback();
8.14 @@ -69,7 +71,9 @@
8.15 public:
8.16 NextMapManager();
8.17
8.18 -#if SOURCE_ENGINE >= SE_ORANGEBOX
8.19 +#if SOURCE_ENGINE == SE_DOTA
8.20 + friend void CmdChangeLevelCallback(void *pUnknown, const CCommand &command);
8.21 +#elif SOURCE_ENGINE >= SE_ORANGEBOX
8.22 friend void CmdChangeLevelCallback(const CCommand &command);
8.23 #else
8.24 friend void CmdChangeLevelCallback();
9.1 --- a/core/PlayerManager.cpp Tue Apr 23 07:11:49 2013 -0400
9.2 +++ b/core/PlayerManager.cpp Tue Apr 23 07:11:49 2013 -0400
9.3 @@ -69,7 +69,9 @@
9.4 SH_DECL_HOOK1_void(IServerGameClients, ClientSettingsChanged, SH_NOATTRIB, 0, edict_t *);
9.5 SH_DECL_HOOK3_void(IServerGameDLL, ServerActivate, SH_NOATTRIB, 0, edict_t *, int, int);
9.6
9.7 -#if SOURCE_ENGINE >= SE_ORANGEBOX
9.8 +#if SOURCE_ENGINE == SE_DOTA
9.9 +SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, void *, const CCommand &);
9.10 +#elif SOURCE_ENGINE >= SE_ORANGEBOX
9.11 SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
9.12 #elif SOURCE_ENGINE == SE_DARKMESSIAH
9.13 SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
9.14 @@ -1711,7 +1713,10 @@
9.15 return 0;
9.16 }
9.17
9.18 -#if SOURCE_ENGINE >= SE_ORANGEBOX
9.19 +#if SOURCE_ENGINE == SE_DOTA
9.20 +void CmdMaxplayersCallback(void *pUnknown, const CCommand &command)
9.21 +{
9.22 +#elif SOURCE_ENGINE >= SE_ORANGEBOX
9.23 void CmdMaxplayersCallback(const CCommand &command)
9.24 {
9.25 #else
10.1 --- a/core/PlayerManager.h Tue Apr 23 07:11:49 2013 -0400
10.2 +++ b/core/PlayerManager.h Tue Apr 23 07:11:49 2013 -0400
10.3 @@ -230,7 +230,9 @@
10.4 int m_ReplayUserId;
10.5 };
10.6
10.7 -#if SOURCE_ENGINE >= SE_ORANGEBOX
10.8 +#if SOURCE_ENGINE == SE_DOTA
10.9 +void CmdMaxplayersCallback(void *, const CCommand &command);
10.10 +#elif SOURCE_ENGINE >= SE_ORANGEBOX
10.11 void CmdMaxplayersCallback(const CCommand &command);
10.12 #else
10.13 void CmdMaxplayersCallback();
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/core/convar_sm_dota.h Tue Apr 23 07:11:49 2013 -0400
11.3 @@ -0,0 +1,1045 @@
11.4 +//===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
11.5 +//
11.6 +// Purpose:
11.7 +//
11.8 +// $Workfile: $
11.9 +// $Date: $
11.10 +//
11.11 +//-----------------------------------------------------------------------------
11.12 +// $NoKeywords: $
11.13 +//===========================================================================//
11.14 +
11.15 +#ifndef CONVAR_H
11.16 +#define CONVAR_H
11.17 +
11.18 +#if _WIN32
11.19 +#pragma once
11.20 +#endif
11.21 +
11.22 +#include "tier0/dbg.h"
11.23 +#include "tier1/iconvar.h"
11.24 +#include "tier1/utlvector.h"
11.25 +#include "tier1/utlstring.h"
11.26 +#include "Color.h"
11.27 +#include "icvar.h"
11.28 +
11.29 +#ifdef _WIN32
11.30 +#define FORCEINLINE_CVAR FORCEINLINE
11.31 +#elif POSIX
11.32 +#define FORCEINLINE_CVAR inline
11.33 +#else
11.34 +#error "implement me"
11.35 +#endif
11.36 +
11.37 +
11.38 +//-----------------------------------------------------------------------------
11.39 +// Uncomment me to test for threading issues for material system convars
11.40 +// NOTE: You want to disable all threading when you do this
11.41 +// +host_thread_mode 0 +r_threaded_particles 0 +sv_parallel_packentities 0 +sv_disable_querycache 0
11.42 +//-----------------------------------------------------------------------------
11.43 +//#define CONVAR_TEST_MATERIAL_THREAD_CONVARS 1
11.44 +
11.45 +
11.46 +//-----------------------------------------------------------------------------
11.47 +// Forward declarations
11.48 +//-----------------------------------------------------------------------------
11.49 +class ConVar;
11.50 +class CCommand;
11.51 +class ConCommand;
11.52 +class ConCommandBase;
11.53 +struct characterset_t;
11.54 +
11.55 +
11.56 +
11.57 +//-----------------------------------------------------------------------------
11.58 +// Any executable that wants to use ConVars need to implement one of
11.59 +// these to hook up access to console variables.
11.60 +//-----------------------------------------------------------------------------
11.61 +class IConCommandBaseAccessor
11.62 +{
11.63 +public:
11.64 + // Flags is a combination of FCVAR flags in cvar.h.
11.65 + // hOut is filled in with a handle to the variable.
11.66 + virtual bool RegisterConCommandBase( ConCommandBase *pVar ) = 0;
11.67 +};
11.68 +
11.69 +
11.70 +//-----------------------------------------------------------------------------
11.71 +// Helper method for console development
11.72 +//-----------------------------------------------------------------------------
11.73 +#if defined( _X360 )
11.74 +void ConVar_PublishToVXConsole();
11.75 +#endif
11.76 +
11.77 +
11.78 +//-----------------------------------------------------------------------------
11.79 +// Called when a ConCommand needs to execute
11.80 +//-----------------------------------------------------------------------------
11.81 +typedef void ( *FnCommandCallbackV1_t )( void );
11.82 +typedef void ( *FnCommandCallback_t )( void *pUnknown, const CCommand &command );
11.83 +
11.84 +#define COMMAND_COMPLETION_MAXITEMS 64
11.85 +#define COMMAND_COMPLETION_ITEM_LENGTH 64
11.86 +
11.87 +//-----------------------------------------------------------------------------
11.88 +// Returns 0 to COMMAND_COMPLETION_MAXITEMS worth of completion strings
11.89 +//-----------------------------------------------------------------------------
11.90 +typedef int ( *FnCommandCompletionCallback )( const char *partial, char commands[ COMMAND_COMPLETION_MAXITEMS ][ COMMAND_COMPLETION_ITEM_LENGTH ] );
11.91 +
11.92 +
11.93 +//-----------------------------------------------------------------------------
11.94 +// Interface version
11.95 +//-----------------------------------------------------------------------------
11.96 +class ICommandCallback
11.97 +{
11.98 +public:
11.99 + virtual void CommandCallback( const CCommand &command ) = 0;
11.100 +};
11.101 +
11.102 +class ICommandCallback2
11.103 +{
11.104 +public:
11.105 + virtual void CommandCallback( void *pUnknown, const CCommand &command ) = 0;
11.106 +};
11.107 +
11.108 +class ICommandCompletionCallback
11.109 +{
11.110 +public:
11.111 + virtual int CommandCompletionCallback( const char *pPartial, CUtlVector< CUtlString > &commands ) = 0;
11.112 +};
11.113 +
11.114 +//-----------------------------------------------------------------------------
11.115 +// Purpose: The base console invoked command/cvar interface
11.116 +//-----------------------------------------------------------------------------
11.117 +class ConCommandBase
11.118 +{
11.119 + friend class CCvar;
11.120 + friend class ConVar;
11.121 + friend class ConCommand;
11.122 + friend void ConVar_Register( int nCVarFlag, IConCommandBaseAccessor *pAccessor );
11.123 + friend void ConVar_PublishToVXConsole();
11.124 +
11.125 + // FIXME: Remove when ConVar changes are done
11.126 + friend class CDefaultCvar;
11.127 +
11.128 +public:
11.129 + ConCommandBase( void );
11.130 + ConCommandBase( const char *pName, const char *pHelpString = 0,
11.131 + int flags = 0 );
11.132 +
11.133 + virtual ~ConCommandBase( void );
11.134 +
11.135 + virtual bool IsCommand( void ) const;
11.136 +
11.137 + // Check flag
11.138 + virtual bool IsFlagSet( int flag ) const;
11.139 + // Set flag
11.140 + virtual void AddFlags( int flags );
11.141 + // Clear flag
11.142 + virtual void RemoveFlags( int flags );
11.143 +
11.144 + virtual int GetFlags() const;
11.145 +
11.146 + // Return name of cvar
11.147 + virtual const char *GetName( void ) const;
11.148 +
11.149 + // Return help text for cvar
11.150 + virtual const char *GetHelpText( void ) const;
11.151 +
11.152 + // Deal with next pointer
11.153 + const ConCommandBase *GetNext( void ) const;
11.154 + ConCommandBase *GetNext( void );
11.155 +
11.156 + virtual bool IsRegistered( void ) const;
11.157 +
11.158 + // Returns the DLL identifier
11.159 + virtual CVarDLLIdentifier_t GetDLLIdentifier() const;
11.160 +
11.161 +protected:
11.162 + virtual void Create( const char *pName, const char *pHelpString = 0,
11.163 + int flags = 0 );
11.164 +
11.165 + // Used internally by OneTimeInit to initialize/shutdown
11.166 + virtual void Init();
11.167 + void Shutdown();
11.168 +
11.169 + // Internal copy routine ( uses new operator from correct module )
11.170 + char *CopyString( const char *from );
11.171 +
11.172 +private:
11.173 + // Next ConVar in chain
11.174 + // Prior to register, it points to the next convar in the DLL.
11.175 + // Once registered, though, m_pNext is reset to point to the next
11.176 + // convar in the global list
11.177 + ConCommandBase *m_pNext;
11.178 +
11.179 + // Has the cvar been added to the global list?
11.180 + bool m_bRegistered;
11.181 +
11.182 + // Static data
11.183 + const char *m_pszName;
11.184 + const char *m_pszHelpString;
11.185 +
11.186 + // ConVar flags
11.187 + int m_nFlags;
11.188 +
11.189 +protected:
11.190 + // ConVars add themselves to this list for the executable.
11.191 + // Then ConVar_Register runs through all the console variables
11.192 + // and registers them into a global list stored in vstdlib.dll
11.193 + static ConCommandBase *s_pConCommandBases;
11.194 +
11.195 + // ConVars in this executable use this 'global' to access values.
11.196 + static IConCommandBaseAccessor *s_pAccessor;
11.197 +public:
11.198 + inline void SetFlags(int flags)
11.199 + {
11.200 + m_nFlags = flags;
11.201 + }
11.202 +};
11.203 +
11.204 +
11.205 +//-----------------------------------------------------------------------------
11.206 +// Command tokenizer
11.207 +//-----------------------------------------------------------------------------
11.208 +class CCommand
11.209 +{
11.210 +public:
11.211 + CCommand();
11.212 + CCommand( int nArgC, const char **ppArgV );
11.213 + bool Tokenize( const char *pCommand, characterset_t *pBreakSet = NULL );
11.214 + void Reset();
11.215 +
11.216 + int ArgC() const;
11.217 + const char **ArgV() const;
11.218 + const char *ArgS() const; // All args that occur after the 0th arg, in string form
11.219 + const char *GetCommandString() const; // The entire command in string form, including the 0th arg
11.220 + const char *operator[]( int nIndex ) const; // Gets at arguments
11.221 + const char *Arg( int nIndex ) const; // Gets at arguments
11.222 +
11.223 + // Helper functions to parse arguments to commands.
11.224 + const char* FindArg( const char *pName ) const;
11.225 + int FindArgInt( const char *pName, int nDefaultVal ) const;
11.226 +
11.227 + static int MaxCommandLength();
11.228 + static characterset_t* DefaultBreakSet();
11.229 +
11.230 +private:
11.231 + enum
11.232 + {
11.233 + COMMAND_MAX_ARGC = 64,
11.234 + COMMAND_MAX_LENGTH = 512,
11.235 + };
11.236 +
11.237 + int m_nArgc;
11.238 + int m_nArgv0Size;
11.239 + char m_pArgSBuffer[ COMMAND_MAX_LENGTH ];
11.240 + char m_pArgvBuffer[ COMMAND_MAX_LENGTH ];
11.241 + const char* m_ppArgv[ COMMAND_MAX_ARGC ];
11.242 +};
11.243 +
11.244 +inline int CCommand::MaxCommandLength()
11.245 +{
11.246 + return COMMAND_MAX_LENGTH - 1;
11.247 +}
11.248 +
11.249 +inline int CCommand::ArgC() const
11.250 +{
11.251 + return m_nArgc;
11.252 +}
11.253 +
11.254 +inline const char **CCommand::ArgV() const
11.255 +{
11.256 + return m_nArgc ? (const char**)m_ppArgv : NULL;
11.257 +}
11.258 +
11.259 +inline const char *CCommand::ArgS() const
11.260 +{
11.261 + return m_nArgv0Size ? &m_pArgSBuffer[m_nArgv0Size] : "";
11.262 +}
11.263 +
11.264 +inline const char *CCommand::GetCommandString() const
11.265 +{
11.266 + return m_nArgc ? m_pArgSBuffer : "";
11.267 +}
11.268 +
11.269 +inline const char *CCommand::Arg( int nIndex ) const
11.270 +{
11.271 + // FIXME: Many command handlers appear to not be particularly careful
11.272 + // about checking for valid argc range. For now, we're going to
11.273 + // do the extra check and return an empty string if it's out of range
11.274 + if ( nIndex < 0 || nIndex >= m_nArgc )
11.275 + return "";
11.276 + return m_ppArgv[nIndex];
11.277 +}
11.278 +
11.279 +inline const char *CCommand::operator[]( int nIndex ) const
11.280 +{
11.281 + return Arg( nIndex );
11.282 +}
11.283 +
11.284 +
11.285 +//-----------------------------------------------------------------------------
11.286 +// Purpose: The console invoked command
11.287 +//-----------------------------------------------------------------------------
11.288 +class ConCommand : public ConCommandBase
11.289 +{
11.290 +friend class CCvar;
11.291 +
11.292 +public:
11.293 + typedef ConCommandBase BaseClass;
11.294 +
11.295 + ConCommand( const char *pName, FnCommandCallbackV1_t callback,
11.296 + const char *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 );
11.297 + ConCommand( const char *pName, FnCommandCallback_t callback,
11.298 + const char *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 );
11.299 + ConCommand( const char *pName, ICommandCallback *pCallback,
11.300 + const char *pHelpString = 0, int flags = 0, ICommandCompletionCallback *pCommandCompletionCallback = 0 );
11.301 + ConCommand( const char *pName, ICommandCallback2 *pCallback,
11.302 + const char *pHelpString = 0, int flags = 0, ICommandCompletionCallback *pCommandCompletionCallback = 0 );
11.303 +
11.304 + virtual ~ConCommand( void );
11.305 +
11.306 + virtual bool IsCommand( void ) const;
11.307 +
11.308 + virtual int AutoCompleteSuggest( const char *partial, CUtlVector< CUtlString > &commands );
11.309 +
11.310 + virtual bool CanAutoComplete( void );
11.311 +
11.312 + // Invoke the function
11.313 + virtual void Dispatch( void *pUnknown, const CCommand &command );
11.314 +
11.315 +private:
11.316 + // NOTE: To maintain backward compat, we have to be very careful:
11.317 + // All public virtual methods must appear in the same order always
11.318 + // since engine code will be calling into this code, which *does not match*
11.319 + // in the mod code; it's using slightly different, but compatible versions
11.320 + // of this class. Also: Be very careful about adding new fields to this class.
11.321 + // Those fields will not exist in the version of this class that is instanced
11.322 + // in mod code.
11.323 +
11.324 + // Call this function when executing the command
11.325 + union
11.326 + {
11.327 + FnCommandCallbackV1_t m_fnCommandCallbackV1;
11.328 + FnCommandCallback_t m_fnCommandCallback;
11.329 + ICommandCallback *m_pCommandCallback;
11.330 + ICommandCallback2 *m_pCommandCallback2;
11.331 + };
11.332 +
11.333 + union
11.334 + {
11.335 + FnCommandCompletionCallback m_fnCompletionCallback;
11.336 + ICommandCompletionCallback *m_pCommandCompletionCallback;
11.337 + };
11.338 +
11.339 + bool m_bHasCompletionCallback : 1;
11.340 + bool m_bUsingNewCommandCallback : 1;
11.341 + bool m_bUsingCommandCallbackInterface : 1;
11.342 + bool m_bUsingCommandCallbackInterface2 : 1;
11.343 +public:
11.344 + inline FnCommandCallback_t GetCallback() const
11.345 + {
11.346 + return m_fnCommandCallback;
11.347 + }
11.348 +};
11.349 +
11.350 +
11.351 +//-----------------------------------------------------------------------------
11.352 +// Purpose: A console variable
11.353 +//-----------------------------------------------------------------------------
11.354 +class ConVar : public ConCommandBase, public IConVar
11.355 +{
11.356 +friend class CCvar;
11.357 +friend class ConVarRef;
11.358 +friend class SplitScreenConVarRef;
11.359 +
11.360 +public:
11.361 + typedef ConCommandBase BaseClass;
11.362 +
11.363 + ConVar( const char *pName, const char *pDefaultValue, int flags = 0);
11.364 +
11.365 + ConVar( const char *pName, const char *pDefaultValue, int flags,
11.366 + const char *pHelpString );
11.367 + ConVar( const char *pName, const char *pDefaultValue, int flags,
11.368 + const char *pHelpString, bool bMin, float fMin, bool bMax, float fMax );
11.369 + ConVar( const char *pName, const char *pDefaultValue, int flags,
11.370 + const char *pHelpString, FnChangeCallback_t callback );
11.371 + ConVar( const char *pName, const char *pDefaultValue, int flags,
11.372 + const char *pHelpString, bool bMin, float fMin, bool bMax, float fMax,
11.373 + FnChangeCallback_t callback );
11.374 +
11.375 + virtual ~ConVar( void );
11.376 +
11.377 + virtual bool IsFlagSet( int flag ) const;
11.378 + virtual const char* GetHelpText( void ) const;
11.379 + virtual bool IsRegistered( void ) const;
11.380 + virtual const char *GetName( void ) const;
11.381 + // Return name of command (usually == GetName(), except in case of FCVAR_SS_ADDED vars
11.382 + virtual const char *GetBaseName( void ) const;
11.383 + virtual int GetSplitScreenPlayerSlot() const;
11.384 +
11.385 + virtual void AddFlags( int flags );
11.386 + virtual int GetFlags() const;
11.387 + virtual bool IsCommand( void ) const;
11.388 +
11.389 + // Install a change callback (there shouldn't already be one....)
11.390 + void InstallChangeCallback( FnChangeCallback_t callback, bool bInvoke = true );
11.391 + void RemoveChangeCallback( FnChangeCallback_t callbackToRemove );
11.392 +
11.393 + int GetChangeCallbackCount() const { return m_pParent->m_fnChangeCallbacks.Count(); }
11.394 + FnChangeCallback_t GetChangeCallback( int slot ) const { return m_pParent->m_fnChangeCallbacks[ slot ]; }
11.395 +
11.396 + // Retrieve value
11.397 + FORCEINLINE_CVAR float GetFloat( void ) const;
11.398 + FORCEINLINE_CVAR int GetInt( void ) const;
11.399 + FORCEINLINE_CVAR Color GetColor( void ) const;
11.400 + FORCEINLINE_CVAR bool GetBool() const { return !!GetInt(); }
11.401 + FORCEINLINE_CVAR char const *GetString( void ) const;
11.402 +
11.403 + // Compiler driven selection for template use
11.404 + template <typename T> T Get( void ) const;
11.405 + template <typename T> T Get( T * ) const;
11.406 +
11.407 + // Any function that allocates/frees memory needs to be virtual or else you'll have crashes
11.408 + // from alloc/free across dll/exe boundaries.
11.409 +
11.410 + // These just call into the IConCommandBaseAccessor to check flags and set the var (which ends up calling InternalSetValue).
11.411 + virtual void SetValue( const char *value );
11.412 + virtual void SetValue( float value );
11.413 + virtual void SetValue( int value );
11.414 + virtual void SetValue( Color value );
11.415 +
11.416 + // Reset to default value
11.417 + void Revert( void );
11.418 +
11.419 + // True if it has a min/max setting
11.420 + bool HasMin() const;
11.421 + bool HasMax() const;
11.422 +
11.423 + bool GetMin( float& minVal ) const;
11.424 + bool GetMax( float& maxVal ) const;
11.425 +
11.426 + float GetMinValue() const;
11.427 + float GetMaxValue() const;
11.428 +
11.429 + const char *GetDefault( void ) const;
11.430 +
11.431 + // Value
11.432 + struct CVValue_t
11.433 + {
11.434 + char *m_pszString;
11.435 + int m_StringLength;
11.436 +
11.437 + // Values
11.438 + float m_fValue;
11.439 + int m_nValue;
11.440 + };
11.441 +
11.442 + FORCEINLINE_CVAR CVValue_t &GetRawValue()
11.443 + {
11.444 + return m_Value;
11.445 + }
11.446 + FORCEINLINE_CVAR const CVValue_t &GetRawValue() const
11.447 + {
11.448 + return m_Value;
11.449 + }
11.450 +
11.451 +private:
11.452 + bool InternalSetColorFromString( const char *value );
11.453 + // Called by CCvar when the value of a var is changing.
11.454 + virtual void InternalSetValue(const char *value);
11.455 + // For CVARs marked FCVAR_NEVER_AS_STRING
11.456 + virtual void InternalSetFloatValue( float fNewValue );
11.457 + virtual void InternalSetIntValue( int nValue );
11.458 + virtual void InternalSetColorValue( Color value );
11.459 +
11.460 + virtual bool ClampValue( float& value );
11.461 + virtual void ChangeStringValue( const char *tempVal, float flOldValue );
11.462 +
11.463 + virtual void Create( const char *pName, const char *pDefaultValue, int flags = 0,
11.464 + const char *pHelpString = 0, bool bMin = false, float fMin = 0.0,
11.465 + bool bMax = false, float fMax = false, FnChangeCallback_t callback = 0 );
11.466 +
11.467 + // Used internally by OneTimeInit to initialize.
11.468 + virtual void Init();
11.469 +
11.470 +
11.471 +
11.472 +protected:
11.473 +
11.474 + // This either points to "this" or it points to the original declaration of a ConVar.
11.475 + // This allows ConVars to exist in separate modules, and they all use the first one to be declared.
11.476 + // m_pParent->m_pParent must equal m_pParent (ie: m_pParent must be the root, or original, ConVar).
11.477 + ConVar *m_pParent;
11.478 +
11.479 + // Static data
11.480 + const char *m_pszDefaultValue;
11.481 +
11.482 + CVValue_t m_Value;
11.483 +
11.484 + // Min/Max values
11.485 + bool m_bHasMin;
11.486 + float m_fMinVal;
11.487 + bool m_bHasMax;
11.488 + float m_fMaxVal;
11.489 +
11.490 + // Call this function when ConVar changes
11.491 + CUtlVector< FnChangeCallback_t > m_fnChangeCallbacks;
11.492 +public:
11.493 + inline void SetMin(bool set, float min=0.0)
11.494 + {
11.495 + m_bHasMin = set;
11.496 + m_fMinVal = min;
11.497 + }
11.498 + inline void SetMax(bool set, float max=0.0)
11.499 + {
11.500 + m_bHasMax = set;
11.501 + m_fMaxVal = max;
11.502 + }
11.503 +};
11.504 +
11.505 +
11.506 +//-----------------------------------------------------------------------------
11.507 +// Purpose: Return ConVar value as a float
11.508 +// Output : float
11.509 +//-----------------------------------------------------------------------------
11.510 +FORCEINLINE_CVAR float ConVar::GetFloat( void ) const
11.511 +{
11.512 +#ifdef CONVAR_TEST_MATERIAL_THREAD_CONVARS
11.513 + Assert( ThreadInMainThread() || IsFlagSet( FCVAR_MATERIAL_THREAD_MASK | FCVAR_ACCESSIBLE_FROM_THREADS ) );
11.514 +#endif
11.515 + return m_pParent->m_Value.m_fValue;
11.516 +}
11.517 +
11.518 +//-----------------------------------------------------------------------------
11.519 +// Purpose: Return ConVar value as an int
11.520 +// Output : int
11.521 +//-----------------------------------------------------------------------------
11.522 +FORCEINLINE_CVAR int ConVar::GetInt( void ) const
11.523 +{
11.524 +#ifdef CONVAR_TEST_MATERIAL_THREAD_CONVARS
11.525 + Assert( ThreadInMainThread() || IsFlagSet( FCVAR_MATERIAL_THREAD_MASK | FCVAR_ACCESSIBLE_FROM_THREADS ) );
11.526 +#endif
11.527 + return m_pParent->m_Value.m_nValue;
11.528 +}
11.529 +
11.530 +//-----------------------------------------------------------------------------
11.531 +// Purpose: Return ConVar value as a color
11.532 +// Output : Color
11.533 +//-----------------------------------------------------------------------------
11.534 +FORCEINLINE_CVAR Color ConVar::GetColor( void ) const
11.535 +{
11.536 +#ifdef CONVAR_TEST_MATERIAL_THREAD_CONVARS
11.537 + Assert( ThreadInMainThread() || IsFlagSet( FCVAR_MATERIAL_THREAD_MASK | FCVAR_ACCESSIBLE_FROM_THREADS ) );
11.538 +#endif
11.539 + unsigned char *pColorElement = ((unsigned char *)&m_pParent->m_Value.m_nValue);
11.540 + return Color( pColorElement[0], pColorElement[1], pColorElement[2], pColorElement[3] );
11.541 +}
11.542 +
11.543 +
11.544 +//-----------------------------------------------------------------------------
11.545 +
11.546 +template <> FORCEINLINE_CVAR float ConVar::Get<float>( void ) const { return GetFloat(); }
11.547 +template <> FORCEINLINE_CVAR int ConVar::Get<int>( void ) const { return GetInt(); }
11.548 +template <> FORCEINLINE_CVAR bool ConVar::Get<bool>( void ) const { return GetBool(); }
11.549 +template <> FORCEINLINE_CVAR const char * ConVar::Get<const char *>( void ) const { return GetString(); }
11.550 +template <> FORCEINLINE_CVAR float ConVar::Get<float>( float *p ) const { return ( *p = GetFloat() ); }
11.551 +template <> FORCEINLINE_CVAR int ConVar::Get<int>( int *p ) const { return ( *p = GetInt() ); }
11.552 +template <> FORCEINLINE_CVAR bool ConVar::Get<bool>( bool *p ) const { return ( *p = GetBool() ); }
11.553 +template <> FORCEINLINE_CVAR const char * ConVar::Get<const char *>( char const **p ) const { return ( *p = GetString() ); }
11.554 +
11.555 +//-----------------------------------------------------------------------------
11.556 +// Purpose: Return ConVar value as a string, return "" for bogus string pointer, etc.
11.557 +// Output : const char *
11.558 +//-----------------------------------------------------------------------------
11.559 +FORCEINLINE_CVAR const char *ConVar::GetString( void ) const
11.560 +{
11.561 +#ifdef CONVAR_TEST_MATERIAL_THREAD_CONVARS
11.562 + Assert( ThreadInMainThread() || IsFlagSet( FCVAR_MATERIAL_THREAD_MASK | FCVAR_ACCESSIBLE_FROM_THREADS ) );
11.563 +#endif
11.564 + if ( m_nFlags & FCVAR_NEVER_AS_STRING )
11.565 + return "FCVAR_NEVER_AS_STRING";
11.566 +
11.567 + char const *str = m_pParent->m_Value.m_pszString;
11.568 + return str ? str : "";
11.569 +}
11.570 +
11.571 +class CSplitScreenAddedConVar : public ConVar
11.572 +{
11.573 + typedef ConVar BaseClass;
11.574 +public:
11.575 + CSplitScreenAddedConVar( int nSplitScreenSlot, const char *pName, const ConVar *pBaseVar ) :
11.576 + BaseClass
11.577 + (
11.578 + pName,
11.579 + pBaseVar->GetDefault(),
11.580 + // Keep basevar flags, except remove _SS and add _SS_ADDED instead
11.581 + ( pBaseVar->GetFlags() & ~FCVAR_SS ) | FCVAR_SS_ADDED,
11.582 + pBaseVar->GetHelpText(),
11.583 + pBaseVar->HasMin(),
11.584 + pBaseVar->GetMinValue(),
11.585 + pBaseVar->HasMax(),
11.586 + pBaseVar->GetMaxValue()
11.587 + ),
11.588 + m_pBaseVar( pBaseVar ),
11.589 + m_nSplitScreenSlot( nSplitScreenSlot )
11.590 + {
11.591 + for ( int i = 0; i < pBaseVar->GetChangeCallbackCount(); ++i )
11.592 + {
11.593 + InstallChangeCallback( pBaseVar->GetChangeCallback( i ), false );
11.594 + }
11.595 + Assert( nSplitScreenSlot >= 1 );
11.596 + Assert( nSplitScreenSlot < MAX_SPLITSCREEN_CLIENTS );
11.597 + Assert( m_pBaseVar );
11.598 + Assert( IsFlagSet( FCVAR_SS_ADDED ) );
11.599 + Assert( !IsFlagSet( FCVAR_SS ) );
11.600 + }
11.601 +
11.602 + const ConVar *GetBaseVar() const;
11.603 + virtual const char *GetBaseName() const;
11.604 + void SetSplitScreenPlayerSlot( int nSlot );
11.605 + virtual int GetSplitScreenPlayerSlot() const;
11.606 +
11.607 +protected:
11.608 +
11.609 + const ConVar *m_pBaseVar;
11.610 + int m_nSplitScreenSlot;
11.611 +};
11.612 +
11.613 +FORCEINLINE_CVAR const ConVar *CSplitScreenAddedConVar::GetBaseVar() const
11.614 +{
11.615 + Assert( m_pBaseVar );
11.616 + return m_pBaseVar;
11.617 +}
11.618 +
11.619 +FORCEINLINE_CVAR const char *CSplitScreenAddedConVar::GetBaseName() const
11.620 +{
11.621 + Assert( m_pBaseVar );
11.622 + return m_pBaseVar->GetName();
11.623 +}
11.624 +
11.625 +FORCEINLINE_CVAR void CSplitScreenAddedConVar::SetSplitScreenPlayerSlot( int nSlot )
11.626 +{
11.627 + m_nSplitScreenSlot = nSlot;
11.628 +}
11.629 +
11.630 +FORCEINLINE_CVAR int CSplitScreenAddedConVar::GetSplitScreenPlayerSlot() const
11.631 +{
11.632 + return m_nSplitScreenSlot;
11.633 +}
11.634 +
11.635 +//-----------------------------------------------------------------------------
11.636 +// Used to read/write convars that already exist (replaces the FindVar method)
11.637 +//-----------------------------------------------------------------------------
11.638 +class ConVarRef
11.639 +{
11.640 +public:
11.641 + ConVarRef( const char *pName );
11.642 + ConVarRef( const char *pName, bool bIgnoreMissing );
11.643 + ConVarRef( IConVar *pConVar );
11.644 +
11.645 + void Init( const char *pName, bool bIgnoreMissing );
11.646 + bool IsValid() const;
11.647 + bool IsFlagSet( int nFlags ) const;
11.648 + IConVar *GetLinkedConVar();
11.649 +
11.650 + // Get/Set value
11.651 + float GetFloat( void ) const;
11.652 + int GetInt( void ) const;
11.653 + Color GetColor( void ) const;
11.654 + bool GetBool() const { return !!GetInt(); }
11.655 + const char *GetString( void ) const;
11.656 +
11.657 + void SetValue( const char *pValue );
11.658 + void SetValue( float flValue );
11.659 + void SetValue( int nValue );
11.660 + void SetValue( Color value );
11.661 + void SetValue( bool bValue );
11.662 +
11.663 + const char *GetName() const;
11.664 +
11.665 + const char *GetDefault() const;
11.666 +
11.667 + const char *GetBaseName() const;
11.668 +
11.669 + int GetSplitScreenPlayerSlot() const;
11.670 +
11.671 +private:
11.672 + // High-speed method to read convar data
11.673 + IConVar *m_pConVar;
11.674 + ConVar *m_pConVarState;
11.675 +};
11.676 +
11.677 +
11.678 +//-----------------------------------------------------------------------------
11.679 +// Did we find an existing convar of that name?
11.680 +//-----------------------------------------------------------------------------
11.681 +FORCEINLINE_CVAR bool ConVarRef::IsFlagSet( int nFlags ) const
11.682 +{
11.683 + return ( m_pConVar->IsFlagSet( nFlags ) != 0 );
11.684 +}
11.685 +
11.686 +FORCEINLINE_CVAR IConVar *ConVarRef::GetLinkedConVar()
11.687 +{
11.688 + return m_pConVar;
11.689 +}
11.690 +
11.691 +FORCEINLINE_CVAR const char *ConVarRef::GetName() const
11.692 +{
11.693 + return m_pConVar->GetName();
11.694 +}
11.695 +
11.696 +FORCEINLINE_CVAR const char *ConVarRef::GetBaseName() const
11.697 +{
11.698 + return m_pConVar->GetBaseName();
11.699 +}
11.700 +
11.701 +FORCEINLINE_CVAR int ConVarRef::GetSplitScreenPlayerSlot() const
11.702 +{
11.703 + return m_pConVar->GetSplitScreenPlayerSlot();
11.704 +}
11.705 +
11.706 +//-----------------------------------------------------------------------------
11.707 +// Purpose: Return ConVar value as a float
11.708 +//-----------------------------------------------------------------------------
11.709 +FORCEINLINE_CVAR float ConVarRef::GetFloat( void ) const
11.710 +{
11.711 + return m_pConVarState->m_Value.m_fValue;
11.712 +}
11.713 +
11.714 +//-----------------------------------------------------------------------------
11.715 +// Purpose: Return ConVar value as an int
11.716 +//-----------------------------------------------------------------------------
11.717 +FORCEINLINE_CVAR int ConVarRef::GetInt( void ) const
11.718 +{
11.719 + return m_pConVarState->m_Value.m_nValue;
11.720 +}
11.721 +
11.722 +//-----------------------------------------------------------------------------
11.723 +// Purpose: Return ConVar value as a color
11.724 +//-----------------------------------------------------------------------------
11.725 +FORCEINLINE_CVAR Color ConVarRef::GetColor( void ) const
11.726 +{
11.727 + return m_pConVarState->GetColor();
11.728 +}
11.729 +
11.730 +//-----------------------------------------------------------------------------
11.731 +// Purpose: Return ConVar value as a string, return "" for bogus string pointer, etc.
11.732 +//-----------------------------------------------------------------------------
11.733 +FORCEINLINE_CVAR const char *ConVarRef::GetString( void ) const
11.734 +{
11.735 + Assert( !IsFlagSet( FCVAR_NEVER_AS_STRING ) );
11.736 + return m_pConVarState->m_Value.m_pszString;
11.737 +}
11.738 +
11.739 +
11.740 +FORCEINLINE_CVAR void ConVarRef::SetValue( const char *pValue )
11.741 +{
11.742 + m_pConVar->SetValue( pValue );
11.743 +}
11.744 +
11.745 +FORCEINLINE_CVAR void ConVarRef::SetValue( float flValue )
11.746 +{
11.747 + m_pConVar->SetValue( flValue );
11.748 +}
11.749 +
11.750 +FORCEINLINE_CVAR void ConVarRef::SetValue( int nValue )
11.751 +{
11.752 + m_pConVar->SetValue( nValue );
11.753 +}
11.754 +
11.755 +FORCEINLINE_CVAR void ConVarRef::SetValue( Color value )
11.756 +{
11.757 + m_pConVar->SetValue( value );
11.758 +}
11.759 +
11.760 +FORCEINLINE_CVAR void ConVarRef::SetValue( bool bValue )
11.761 +{
11.762 + m_pConVar->SetValue( bValue ? 1 : 0 );
11.763 +}
11.764 +
11.765 +FORCEINLINE_CVAR const char *ConVarRef::GetDefault() const
11.766 +{
11.767 + return m_pConVarState->m_pszDefaultValue;
11.768 +}
11.769 +
11.770 +//-----------------------------------------------------------------------------
11.771 +// Helper for referencing splitscreen convars (i.e., "name" and "name2")
11.772 +//-----------------------------------------------------------------------------
11.773 +class SplitScreenConVarRef
11.774 +{
11.775 +public:
11.776 + SplitScreenConVarRef( const char *pName );
11.777 + SplitScreenConVarRef( const char *pName, bool bIgnoreMissing );
11.778 + SplitScreenConVarRef( IConVar *pConVar );
11.779 +
11.780 + void Init( const char *pName, bool bIgnoreMissing );
11.781 + bool IsValid() const;
11.782 + bool IsFlagSet( int nFlags ) const;
11.783 +
11.784 + // Get/Set value
11.785 + float GetFloat( int nSlot ) const;
11.786 + int GetInt( int nSlot ) const;
11.787 + Color GetColor( int nSlot ) const;
11.788 + bool GetBool( int nSlot ) const { return !!GetInt( nSlot ); }
11.789 + const char *GetString( int nSlot ) const;
11.790 +
11.791 + void SetValue( int nSlot, const char *pValue );
11.792 + void SetValue( int nSlot, float flValue );
11.793 + void SetValue( int nSlot, int nValue );
11.794 + void SetValue( int nSlot, Color value );
11.795 + void SetValue( int nSlot, bool bValue );
11.796 +
11.797 + const char *GetName( int nSlot ) const;
11.798 +
11.799 + const char *GetDefault() const;
11.800 +
11.801 + const char *GetBaseName() const;
11.802 +
11.803 +private:
11.804 + struct cv_t
11.805 + {
11.806 + IConVar *m_pConVar;
11.807 + ConVar *m_pConVarState;
11.808 + };
11.809 +
11.810 + cv_t m_Info[ MAX_SPLITSCREEN_CLIENTS ];
11.811 +};
11.812 +
11.813 +//-----------------------------------------------------------------------------
11.814 +// Did we find an existing convar of that name?
11.815 +//-----------------------------------------------------------------------------
11.816 +FORCEINLINE_CVAR bool SplitScreenConVarRef::IsFlagSet( int nFlags ) const
11.817 +{
11.818 + return ( m_Info[ 0 ].m_pConVar->IsFlagSet( nFlags ) != 0 );
11.819 +}
11.820 +
11.821 +FORCEINLINE_CVAR const char *SplitScreenConVarRef::GetName( int nSlot ) const
11.822 +{
11.823 + return m_Info[ nSlot ].m_pConVar->GetName();
11.824 +}
11.825 +
11.826 +FORCEINLINE_CVAR const char *SplitScreenConVarRef::GetBaseName() const
11.827 +{
11.828 + return m_Info[ 0 ].m_pConVar->GetBaseName();
11.829 +}
11.830 +
11.831 +//-----------------------------------------------------------------------------
11.832 +// Purpose: Return ConVar value as a float
11.833 +//-----------------------------------------------------------------------------
11.834 +FORCEINLINE_CVAR float SplitScreenConVarRef::GetFloat( int nSlot ) const
11.835 +{
11.836 + return m_Info[ nSlot ].m_pConVarState->m_Value.m_fValue;
11.837 +}
11.838 +
11.839 +//-----------------------------------------------------------------------------
11.840 +// Purpose: Return ConVar value as an int
11.841 +//-----------------------------------------------------------------------------
11.842 +FORCEINLINE_CVAR int SplitScreenConVarRef::GetInt( int nSlot ) const
11.843 +{
11.844 + return m_Info[ nSlot ].m_pConVarState->m_Value.m_nValue;
11.845 +}
11.846 +
11.847 +//-----------------------------------------------------------------------------
11.848 +// Purpose: Return ConVar value as an int
11.849 +//-----------------------------------------------------------------------------
11.850 +FORCEINLINE_CVAR Color SplitScreenConVarRef::GetColor( int nSlot ) const
11.851 +{
11.852 + return m_Info[ nSlot ].m_pConVarState->GetColor();
11.853 +}
11.854 +
11.855 +//-----------------------------------------------------------------------------
11.856 +// Purpose: Return ConVar value as a string, return "" for bogus string pointer, etc.
11.857 +//-----------------------------------------------------------------------------
11.858 +FORCEINLINE_CVAR const char *SplitScreenConVarRef::GetString( int nSlot ) const
11.859 +{
11.860 + Assert( !IsFlagSet( FCVAR_NEVER_AS_STRING ) );
11.861 + return m_Info[ nSlot ].m_pConVarState->m_Value.m_pszString;
11.862 +}
11.863 +
11.864 +
11.865 +FORCEINLINE_CVAR void SplitScreenConVarRef::SetValue( int nSlot, const char *pValue )
11.866 +{
11.867 + m_Info[ nSlot ].m_pConVar->SetValue( pValue );
11.868 +}
11.869 +
11.870 +FORCEINLINE_CVAR void SplitScreenConVarRef::SetValue( int nSlot, float flValue )
11.871 +{
11.872 + m_Info[ nSlot ].m_pConVar->SetValue( flValue );
11.873 +}
11.874 +
11.875 +FORCEINLINE_CVAR void SplitScreenConVarRef::SetValue( int nSlot, int nValue )
11.876 +{
11.877 + m_Info[ nSlot ].m_pConVar->SetValue( nValue );
11.878 +}
11.879 +
11.880 +FORCEINLINE_CVAR void SplitScreenConVarRef::SetValue( int nSlot, Color value )
11.881 +{
11.882 + m_Info[ nSlot ].m_pConVar->SetValue( value );
11.883 +}
11.884 +
11.885 +FORCEINLINE_CVAR void SplitScreenConVarRef::SetValue( int nSlot, bool bValue )
11.886 +{
11.887 + m_Info[ nSlot ].m_pConVar->SetValue( bValue ? 1 : 0 );
11.888 +}
11.889 +
11.890 +FORCEINLINE_CVAR const char *SplitScreenConVarRef::GetDefault() const
11.891 +{
11.892 + return m_Info[ 0 ].m_pConVarState->m_pszDefaultValue;
11.893 +}
11.894 +
11.895 +//-----------------------------------------------------------------------------
11.896 +// Called by the framework to register ConCommands with the ICVar
11.897 +//-----------------------------------------------------------------------------
11.898 +void ConVar_Register( int nCVarFlag = 0, IConCommandBaseAccessor *pAccessor = NULL );
11.899 +void ConVar_Unregister( );
11.900 +
11.901 +
11.902 +//-----------------------------------------------------------------------------
11.903 +// Utility methods
11.904 +//-----------------------------------------------------------------------------
11.905 +void ConVar_PrintDescription( const ConCommandBase *pVar );
11.906 +
11.907 +
11.908 +//-----------------------------------------------------------------------------
11.909 +// Purpose: Utility class to quickly allow ConCommands to call member methods
11.910 +//-----------------------------------------------------------------------------
11.911 +#ifdef _MSC_VER
11.912 +#pragma warning (disable : 4355 )
11.913 +#endif
11.914 +
11.915 +template< class T >
11.916 +class CConCommandMemberAccessor : public ConCommand, public ICommandCallback, public ICommandCompletionCallback
11.917 +{
11.918 + typedef ConCommand BaseClass;
11.919 + typedef void ( T::*FnMemberCommandCallback_t )( const CCommand &command );
11.920 + typedef int ( T::*FnMemberCommandCompletionCallback_t )( const char *pPartial, CUtlVector< CUtlString > &commands );
11.921 +
11.922 +public:
11.923 + CConCommandMemberAccessor( T* pOwner, const char *pName, FnMemberCommandCallback_t callback, const char *pHelpString = 0,
11.924 + int flags = 0, FnMemberCommandCompletionCallback_t completionFunc = 0 ) :
11.925 + BaseClass( pName, this, pHelpString, flags, ( completionFunc != 0 ) ? this : NULL )
11.926 + {
11.927 + m_pOwner = pOwner;
11.928 + m_Func = callback;
11.929 + m_CompletionFunc = completionFunc;
11.930 + }
11.931 +
11.932 + ~CConCommandMemberAccessor()
11.933 + {
11.934 + Shutdown();
11.935 + }
11.936 +
11.937 + void SetOwner( T* pOwner )
11.938 + {
11.939 + m_pOwner = pOwner;
11.940 + }
11.941 +
11.942 + virtual void CommandCallback( const CCommand &command )
11.943 + {
11.944 + Assert( m_pOwner && m_Func );
11.945 + (m_pOwner->*m_Func)( command );
11.946 + }
11.947 +
11.948 + virtual int CommandCompletionCallback( const char *pPartial, CUtlVector< CUtlString > &commands )
11.949 + {
11.950 + Assert( m_pOwner && m_CompletionFunc );
11.951 + return (m_pOwner->*m_CompletionFunc)( pPartial, commands );
11.952 + }
11.953 +
11.954 +private:
11.955 + T* m_pOwner;
11.956 + FnMemberCommandCallback_t m_Func;
11.957 + FnMemberCommandCompletionCallback_t m_CompletionFunc;
11.958 +};
11.959 +
11.960 +#ifdef _MSC_VER
11.961 +#pragma warning ( default : 4355 )
11.962 +#endif
11.963 +
11.964 +//-----------------------------------------------------------------------------
11.965 +// Purpose: Utility macros to quicky generate a simple console command
11.966 +//-----------------------------------------------------------------------------
11.967 +#define CON_COMMAND( name, description ) \
11.968 + static void name( void *pUnknown, const CCommand &args ); \
11.969 + static ConCommand name##_command( #name, name, description ); \
11.970 + static void name( void *pUnknown, const CCommand &args )
11.971 +
11.972 +#ifdef CLIENT_DLL
11.973 + #define CON_COMMAND_SHARED( name, description ) \
11.974 + static void name( void *pUnknown, const CCommand &args ); \
11.975 + static ConCommand name##_command_client( #name "_client", name, description ); \
11.976 + static void name( void *pUnknown, const CCommand &args )
11.977 +#else
11.978 + #define CON_COMMAND_SHARED( name, description ) \
11.979 + static void name( void *pUnknown, const CCommand &args ); \
11.980 + static ConCommand name##_command( #name, name, description ); \
11.981 + static void name( void *pUnknown, const CCommand &args )
11.982 +#endif
11.983 +
11.984 +
11.985 +#define CON_COMMAND_F( name, description, flags ) \
11.986 + static void name( void *pUnknown, const CCommand &args ); \
11.987 + static ConCommand name##_command( #name, name, description, flags ); \
11.988 + static void name( void *pUnknown, const CCommand &args )
11.989 +
11.990 +#ifdef CLIENT_DLL
11.991 + #define CON_COMMAND_F_SHARED( name, description, flags ) \
11.992 + static void name( void *pUnknown, const CCommand &args ); \
11.993 + static ConCommand name##_command_client( #name "_client", name, description, flags ); \
11.994 + static void name( void *pUnknown, const CCommand &args )
11.995 +#else
11.996 + #define CON_COMMAND_F_SHARED( name, description, flags ) \
11.997 + static void name( void *pUnknown, const CCommand &args ); \
11.998 + static ConCommand name##_command( #name, name, description, flags ); \
11.999 + static void name( void *pUnknown, const CCommand &args )
11.1000 +#endif
11.1001 +
11.1002 +
11.1003 +#define CON_COMMAND_F_COMPLETION( name, description, flags, completion ) \
11.1004 + static void name( void *pUnknown, const CCommand &args ); \
11.1005 + static ConCommand name##_command( #name, name, description, flags, completion ); \
11.1006 + static void name( void *pUnknown, const CCommand &args )
11.1007 +
11.1008 +#ifdef CLIENT_DLL
11.1009 + #define CON_COMMAND_F_COMPLETION_SHARED( name, description, flags, completion ) \
11.1010 + static void name( void *pUnknown, const CCommand &args ); \
11.1011 + static ConCommand name##_command_client( #name "_client", name, description, flags, completion ); \
11.1012 + static void name( void *pUnknown, const CCommand &args )
11.1013 +#else
11.1014 + #define CON_COMMAND_F_COMPLETION_SHARED( name, description, flags, completion ) \
11.1015 + static void name( void *pUnknown, const CCommand &args ); \
11.1016 + static ConCommand name##_command( #name, name, description, flags, completion ); \
11.1017 + static void name( void *pUnknown, const CCommand &args )
11.1018 +#endif
11.1019 +
11.1020 +
11.1021 +#define CON_COMMAND_EXTERN( name, _funcname, description ) \
11.1022 + void _funcname( void *pUnknown, const CCommand &args ); \
11.1023 + static ConCommand name##_command( #name, _funcname, description ); \
11.1024 + void _funcname( void *pUnknown, const CCommand &args )
11.1025 +
11.1026 +#define CON_COMMAND_EXTERN_F( name, _funcname, description, flags ) \
11.1027 + void _funcname( void *pUnknown, const CCommand &args ); \
11.1028 + static ConCommand name##_command( #name, _funcname, description, flags ); \
11.1029 + void _funcname( void *pUnknown, const CCommand &args )
11.1030 +
11.1031 +#define CON_COMMAND_MEMBER_F( _thisclass, name, _funcname, description, flags ) \
11.1032 + void _funcname( void *pUnknown, const CCommand &args ); \
11.1033 + friend class CCommandMemberInitializer_##_funcname; \
11.1034 + class CCommandMemberInitializer_##_funcname \
11.1035 + { \
11.1036 + public: \
11.1037 + CCommandMemberInitializer_##_funcname() : m_ConCommandAccessor( NULL, name, &_thisclass::_funcname, description, flags ) \
11.1038 + { \
11.1039 + m_ConCommandAccessor.SetOwner( GET_OUTER( _thisclass, m_##_funcname##_register ) ); \
11.1040 + } \
11.1041 + private: \
11.1042 + CConCommandMemberAccessor< _thisclass > m_ConCommandAccessor; \
11.1043 + }; \
11.1044 + \
11.1045 + CCommandMemberInitializer_##_funcname m_##_funcname##_register; \
11.1046 +
11.1047 +
11.1048 +#endif // CONVAR_H
12.1 --- a/core/logic_bridge.cpp Tue Apr 23 07:11:49 2013 -0400
12.2 +++ b/core/logic_bridge.cpp Tue Apr 23 07:11:49 2013 -0400
12.3 @@ -46,7 +46,9 @@
12.4 #include "AdminCache.h"
12.5 #include "HalfLife2.h"
12.6 #include "CoreConfig.h"
12.7 -#if SOURCE_ENGINE >= SE_ALIENSWARM
12.8 +#if SOURCE_ENGINE == SE_DOTA
12.9 +#include "convar_sm_dota.h"
12.10 +#elif SOURCE_ENGINE >= SE_ALIENSWARM
12.11 #include "convar_sm_swarm.h"
12.12 #elif SOURCE_ENGINE >= SE_LEFT4DEAD
12.13 #include "convar_sm_l4d.h"
13.1 --- a/core/sourcemm_api.h Tue Apr 23 07:11:49 2013 -0400
13.2 +++ b/core/sourcemm_api.h Tue Apr 23 07:11:49 2013 -0400
13.3 @@ -32,7 +32,9 @@
13.4 #ifndef _INCLUDE_SOURCEMOD_MM_API_H_
13.5 #define _INCLUDE_SOURCEMOD_MM_API_H_
13.6
13.7 -#if SOURCE_ENGINE >= SE_ALIENSWARM
13.8 +#if SOURCE_ENGINE == SE_DOTA
13.9 +#include "convar_sm_dota.h"
13.10 +#elif SOURCE_ENGINE >= SE_ALIENSWARM
13.11 #include "convar_sm_swarm.h"
13.12 #elif SOURCE_ENGINE >= SE_LEFT4DEAD
13.13 #include "convar_sm_l4d.h"