| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ff7819a commit 02e3490
16 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -53,4 +53,12 @@ def __call__(self, callback): | |||
| 53 | 53 | ||
| 54 | 54 | def _unload_instance(self): | |
| 55 | 55 | """Unregister the commands.""" | |
| 56 | - self._manager_class.unregister_commands(self.names, self.callback) | ||
| 56 | + # Get the registered callback | ||
| 57 | + callback = self.callback | ||
| 58 | + | ||
| 59 | + # Was no callback registered? | ||
| 60 | + if callback is None: | ||
| 61 | + return | ||
| 62 | + | ||
| 63 | + # Unregister the commands | ||
| 64 | + self._manager_class.unregister_commands(self.names, callback) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,7 @@ | |||
| 30 | 30 | // Includes. | |
| 31 | 31 | //----------------------------------------------------------------------------- | |
| 32 | 32 | #include "utilities/wrap_macros.h" | |
| 33 | - #include "convar.h" | ||
| 33 | + #include "utilities/convar.h" | ||
| 34 | 34 | #include "utilities/ipythongenerator.h" | |
| 35 | 35 | #include "boost/typeof/typeof.hpp" | |
| 36 | 36 | ||
@@ -99,34 +99,6 @@ class CCommandExt | |||
| 99 | 99 | }; | |
| 100 | 100 | ||
| 101 | 101 | ||
| 102 | - //----------------------------------------------------------------------------- | ||
| 103 | - // ConCommandBase extension class. | ||
| 104 | - //----------------------------------------------------------------------------- | ||
| 105 | - class ConCommandBaseExt | ||
| 106 | - { | ||
| 107 | - public: | ||
| 108 | - static int GetFlags(ConCommandBase* command) | ||
| 109 | - { | ||
| 110 | - return command->m_nFlags; | ||
| 111 | - } | ||
| 112 | - | ||
| 113 | - static void SetFlags(ConCommandBase* command, int flags) | ||
| 114 | - { | ||
| 115 | - command->m_nFlags = flags; | ||
| 116 | - } | ||
| 117 | - | ||
| 118 | - static void AddFlags(ConCommandBase* command, int flags) | ||
| 119 | - { | ||
| 120 | - command->m_nFlags |= flags; | ||
| 121 | - } | ||
| 122 | - | ||
| 123 | - static void RemoveFlags(ConCommandBase* command, int flags) | ||
| 124 | - { | ||
| 125 | - command->m_nFlags &= ~flags; | ||
| 126 | - } | ||
| 127 | - }; | ||
| 128 | - | ||
| 129 | - | ||
| 130 | 102 | //----------------------------------------------------------------------------- | |
| 131 | 103 | // ConCommand extension class. | |
| 132 | 104 | //----------------------------------------------------------------------------- | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,14 +27,11 @@ | |||
| 27 | 27 | //----------------------------------------------------------------------------- | |
| 28 | 28 | // Includes | |
| 29 | 29 | //----------------------------------------------------------------------------- | |
| 30 | - // This is required for accessing m_nFlags without patching convar.h | ||
| 31 | - #define private public | ||
| 32 | - | ||
| 33 | 30 | #include "boost/unordered_map.hpp" | |
| 34 | 31 | #include "commands_client.h" | |
| 35 | 32 | #include "commands.h" | |
| 36 | 33 | #include "edict.h" | |
| 37 | - #include "convar.h" | ||
| 34 | + #include "utilities/convar.h" | ||
| 38 | 35 | #include "engine/iserverplugin.h" | |
| 39 | 36 | #include "utilities/call_python.h" | |
| 40 | 37 | #include "boost/python/call.hpp" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -56,7 +56,7 @@ class CClientCommandManager | |||
| 56 | 56 | ||
| 57 | 57 | const char* GetName(); | |
| 58 | 58 | ||
| 59 | - private: | ||
| 59 | + public: | ||
| 60 | 60 | CListenerManager m_vecCallables; | |
| 61 | 61 | const char* m_Name; | |
| 62 | 62 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,9 +27,6 @@ | |||
| 27 | 27 | //----------------------------------------------------------------------------- | |
| 28 | 28 | // Includes. | |
| 29 | 29 | //----------------------------------------------------------------------------- | |
| 30 | - // This is required for accessing m_nFlags without patching convar.h | ||
| 31 | - #define private public | ||
| 32 | - | ||
| 33 | 30 | #include "export_main.h" | |
| 34 | 31 | #include "utilities/wrap_macros.h" | |
| 35 | 32 | #include "modules/memory/memory_tools.h" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,9 +27,6 @@ | |||
| 27 | 27 | //----------------------------------------------------------------------------- | |
| 28 | 28 | // Includes. | |
| 29 | 29 | //----------------------------------------------------------------------------- | |
| 30 | - // This is required for accessing m_nFlags without patching convar.h | ||
| 31 | - #define private public | ||
| 32 | - | ||
| 33 | 30 | #include <iostream> | |
| 34 | 31 | #include <string> | |
| 35 | 32 | #include "utilities/call_python.h" | |
@@ -38,7 +35,7 @@ | |||
| 38 | 35 | #include "boost/unordered_map.hpp" | |
| 39 | 36 | #include "sp_main.h" | |
| 40 | 37 | #include "modules/listeners/listeners_manager.h" | |
| 41 | - #include "convar.h" | ||
| 38 | + #include "utilities/convar.h" | ||
| 42 | 39 | ||
| 43 | 40 | #include "commands_say.h" | |
| 44 | 41 | #include "commands.h" | |
@@ -158,7 +155,7 @@ SayConCommand* SayConCommand::CreateCommand(const char* szName, const char* szHe | |||
| 158 | 155 | { | |
| 159 | 156 | // Store the current command's help text and flags | |
| 160 | 157 | szHelpTextCopy = strdup(pConCommand->GetHelpText()); | |
| 161 | - iFlags = pConCommand->m_nFlags; | ||
| 158 | + iFlags = GetConCommandFlags(pConCommand); | ||
| 162 | 159 | ||
| 163 | 160 | // Unregister the old command | |
| 164 | 161 | g_pCVar->UnregisterConCommand(pConCommand); | |
@@ -192,8 +189,8 @@ SayConCommand::~SayConCommand() | |||
| 192 | 189 | // Get the ConCommand instance | |
| 193 | 190 | ConCommand* pConCommand = g_pCVar->FindCommand(m_Name); | |
| 194 | 191 | ||
| 195 | - // Was the command overwritten as a ConVar or by another DLL? | ||
| 196 | - if (pConCommand && pConCommand->GetDLLIdentifier() == CVarDLLIdentifier()) | ||
| 192 | + // Make sure we only unregister ourselves | ||
| 193 | + if (pConCommand == this) | ||
| 197 | 194 | { | |
| 198 | 195 | // Unregister the ConCommand | |
| 199 | 196 | g_pCVar->UnregisterConCommand(pConCommand); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,7 +50,7 @@ class SayConCommand: public ConCommand | |||
| 50 | 50 | protected: | |
| 51 | 51 | void Dispatch( const CCommand& command ); | |
| 52 | 52 | ||
| 53 | - private: | ||
| 53 | + public: | ||
| 54 | 54 | SayConCommand(ConCommand* pConCommand, const char* szName, const char* szHelpText, int iFlags); | |
| 55 | 55 | const char* m_Name; | |
| 56 | 56 | ConCommand* m_pOldCommand; | |
@@ -86,7 +86,7 @@ class CSayCommandManager | |||
| 86 | 86 | ||
| 87 | 87 | const char* GetName(); | |
| 88 | 88 | ||
| 89 | - private: | ||
| 89 | + public: | ||
| 90 | 90 | const char* m_Name; | |
| 91 | 91 | CListenerManager m_vecCallables; | |
| 92 | 92 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,9 +27,6 @@ | |||
| 27 | 27 | //----------------------------------------------------------------------------- | |
| 28 | 28 | // Includes. | |
| 29 | 29 | //----------------------------------------------------------------------------- | |
| 30 | - // This is required for accessing m_nFlags without patching convar.h | ||
| 31 | - #define private public | ||
| 32 | - | ||
| 33 | 30 | #include "export_main.h" | |
| 34 | 31 | #include "utilities/wrap_macros.h" | |
| 35 | 32 | #include "modules/memory/memory_tools.h" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,9 +27,6 @@ | |||
| 27 | 27 | //----------------------------------------------------------------------------- | |
| 28 | 28 | // Includes | |
| 29 | 29 | //----------------------------------------------------------------------------- | |
| 30 | - // This is required for accessing m_nFlags without patching convar.h | ||
| 31 | - #define private public | ||
| 32 | - | ||
| 33 | 30 | #include "utilities/call_python.h" | |
| 34 | 31 | ||
| 35 | 32 | #include "boost/unordered_map.hpp" | |
@@ -56,8 +53,12 @@ class CPluginConVarAccessor : public IConCommandBaseAccessor | |||
| 56 | 53 | public: | |
| 57 | 54 | virtual bool RegisterConCommandBase(ConCommandBase* pCommand) | |
| 58 | 55 | { | |
| 59 | - g_pCVar->RegisterConCommand(pCommand); | ||
| 60 | - return true; | ||
| 56 | + if (!g_pCVar->FindCommandBase(pCommand->GetName())) { | ||
| 57 | + g_pCVar->RegisterConCommand(pCommand); | ||
| 58 | + return true; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + return false; | ||
| 61 | 62 | } | |
| 62 | 63 | }; | |
| 63 | 64 | ||
@@ -121,15 +122,17 @@ CServerCommandManager* CServerCommandManager::CreateCommand(const char* szName, | |||
| 121 | 122 | char* szHelpTextCopy = NULL; | |
| 122 | 123 | ||
| 123 | 124 | // FInd if the command already exists | |
| 124 | - ConCommand* pConCommand = g_pCVar->FindCommand(szName); | ||
| 125 | + ConCommandBase* pConCommand = g_pCVar->FindCommandBase(szName); | ||
| 125 | 126 | if( pConCommand ) | |
| 126 | 127 | { | |
| 127 | 128 | // Store the current command's help text and flags | |
| 128 | 129 | szHelpTextCopy = strdup(pConCommand->GetHelpText()); | |
| 129 | - iFlags = pConCommand->m_nFlags; | ||
| 130 | + iFlags = GetConCommandFlags(pConCommand); | ||
| 130 | 131 | ||
| 131 | 132 | // Unregister the old command | |
| 132 | - g_pCVar->UnregisterConCommand(pConCommand); | ||
| 133 | + if (pConCommand->IsRegistered()) { | ||
| 134 | + g_pCVar->UnregisterConCommand(pConCommand); | ||
| 135 | + } | ||
| 133 | 136 | } | |
| 134 | 137 | else if( szHelpText != NULL ) | |
| 135 | 138 | { | |
@@ -144,7 +147,7 @@ CServerCommandManager* CServerCommandManager::CreateCommand(const char* szName, | |||
| 144 | 147 | //----------------------------------------------------------------------------- | |
| 145 | 148 | // CServerCommandManager constructor. | |
| 146 | 149 | //----------------------------------------------------------------------------- | |
| 147 | - CServerCommandManager::CServerCommandManager(ConCommand* pConCommand, | ||
| 150 | + CServerCommandManager::CServerCommandManager(ConCommandBase* pConCommand, | ||
| 148 | 151 | const char* szName, const char* szHelpText, int iFlags): | |
| 149 | 152 | ConCommand(szName, (FnCommandCallback_t)NULL, szHelpText, iFlags), | |
| 150 | 153 | m_pOldCommand(pConCommand) | |
@@ -163,8 +166,8 @@ CServerCommandManager::~CServerCommandManager() | |||
| 163 | 166 | // Get the ConCommand instance | |
| 164 | 167 | ConCommand* pConCommand = g_pCVar->FindCommand(m_Name); | |
| 165 | 168 | ||
| 166 | - // Was the command overwritten as a ConVar or by another DLL? | ||
| 167 | - if (pConCommand && pConCommand->GetDLLIdentifier() == CVarDLLIdentifier()) | ||
| 169 | + // Make sure we only unregister ourselves | ||
| 170 | + if (pConCommand == this) | ||
| 168 | 171 | { | |
| 169 | 172 | // Unregister the ConCommand | |
| 170 | 173 | g_pCVar->UnregisterConCommand(pConCommand); | |
@@ -236,7 +239,12 @@ void CServerCommandManager::Dispatch( const CCommand& command ) | |||
| 236 | 239 | // Was the command previously registered? | |
| 237 | 240 | if(m_pOldCommand) | |
| 238 | 241 | { | |
| 239 | - m_pOldCommand->Dispatch(command); | ||
| 242 | + if (m_pOldCommand->IsCommand()) { | ||
| 243 | + static_cast<ConCommand *>(m_pOldCommand)->Dispatch(command); | ||
| 244 | + } | ||
| 245 | + else { | ||
| 246 | + static_cast<ConVar *>(m_pOldCommand)->SetValue(command.ArgS()); | ||
| 247 | + } | ||
| 240 | 248 | } | |
| 241 | 249 | ||
| 242 | 250 | // Post hook callbacks | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,11 +50,11 @@ class CServerCommandManager : public ConCommand | |||
| 50 | 50 | protected: | |
| 51 | 51 | void Dispatch( const CCommand& command); | |
| 52 | 52 | ||
| 53 | - private: | ||
| 54 | - CServerCommandManager(ConCommand* pConCommand, const char* szName, const char* szHelpString = 0, int iFlags = 0); | ||
| 53 | + public: | ||
| 54 | + CServerCommandManager(ConCommandBase* pConCommand, const char* szName, const char* szHelpString = 0, int iFlags = 0); | ||
| 55 | 55 | std::map< HookType_t, CListenerManager* > m_vecCallables; | |
| 56 | 56 | const char* m_Name; | |
| 57 | - ConCommand* m_pOldCommand; | ||
| 57 | + ConCommandBase* m_pOldCommand; | ||
| 58 | 58 | }; | |
| 59 | 59 | ||
| 60 | 60 | #endif // _COMMANDS_SERVER_H | |
| Back | FazBrowse Home | New Git URL |
0 commit comments