Skip to content

Commit 635341c

Browse files
committed
Fix Undefined Behavior.
Undefined macro after includeing "convar.h".
1 parent 2dc44b4 commit 635341c

14 files changed

+53
-29
lines changed

src/core/modules/commands/commands.h

100644100755
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@
3030
// Includes.
3131
//-----------------------------------------------------------------------------
3232
#include "utilities/wrap_macros.h"
33+
34+
// This is required for accessing m_nFlags without patching convar.h
35+
#define private public
3336
#include "convar.h"
37+
#undef private
38+
3439
#include "utilities/ipythongenerator.h"
3540
#include "boost/typeof/typeof.hpp"
3641

src/core/modules/commands/commands_client.cpp

100644100755
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@
2727
//-----------------------------------------------------------------------------
2828
// Includes
2929
//-----------------------------------------------------------------------------
30-
// This is required for accessing m_nFlags without patching convar.h
31-
#define private public
32-
3330
#include "boost/unordered_map.hpp"
3431
#include "commands_client.h"
3532
#include "commands.h"
36-
#include "edict.h"
33+
34+
// This is required for accessing m_nFlags without patching convar.h
35+
#define private public
3736
#include "convar.h"
37+
#include "edict.h"
38+
#undef private
39+
3840
#include "engine/iserverplugin.h"
3941
#include "utilities/call_python.h"
4042
#include "boost/python/call.hpp"
@@ -69,7 +71,7 @@ CClientCommandManager* GetClientCommand(const char* szName)
6971
if (!find_manager<ClientCommandMap, ClientCommandMap::iterator>(g_ClientCommandMap, szName, iter))
7072
{
7173
manager = new CClientCommandManager(szName);
72-
g_ClientCommandMap.insert(std::make_pair(manager->m_Name, manager));
74+
g_ClientCommandMap.insert(std::make_pair(manager->GetName(), manager));
7375
}
7476
else
7577
{

src/core/modules/commands/commands_client.h

100644100755
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,13 @@
3232
#include "sp_python.h"
3333
#include "utilities/sp_util.h"
3434
#include "utilities/wrap_macros.h"
35-
#include "edict.h"
35+
36+
// This is required for accessing m_nFlags without patching convar.h
37+
#define private public
3638
#include "convar.h"
39+
#include "edict.h"
40+
#undef private
41+
3742
#include "commands.h"
3843
#include "game/server/iplayerinfo.h"
3944

src/core/modules/commands/commands_client_wrap.cpp

100644100755
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
//-----------------------------------------------------------------------------
2828
// Includes.
2929
//-----------------------------------------------------------------------------
30-
// This is required for accessing m_nFlags without patching convar.h
31-
#define private public
32-
3330
#include "export_main.h"
3431
#include "utilities/wrap_macros.h"
3532
#include "modules/memory/memory_tools.h"

src/core/modules/commands/commands_say.cpp

100644100755
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
//-----------------------------------------------------------------------------
2828
// Includes.
2929
//-----------------------------------------------------------------------------
30-
// This is required for accessing m_nFlags without patching convar.h
31-
#define private public
32-
3330
#include <iostream>
3431
#include <string>
3532
#include "utilities/call_python.h"
@@ -38,7 +35,11 @@
3835
#include "boost/unordered_map.hpp"
3936
#include "sp_main.h"
4037
#include "modules/listeners/listeners_manager.h"
38+
39+
// This is required for accessing m_nFlags without patching convar.h
40+
#define private public
4141
#include "convar.h"
42+
#undef private
4243

4344
#include "commands_say.h"
4445
#include "commands.h"
@@ -104,7 +105,7 @@ CSayCommandManager* GetSayCommand(const char* szName)
104105
if (!find_manager<SayCommandMap, SayCommandMap::iterator>(g_SayCommandMap, szName, iter))
105106
{
106107
manager = new CSayCommandManager(szName);
107-
g_SayCommandMap.insert(std::make_pair(manager->m_Name, manager));
108+
g_SayCommandMap.insert(std::make_pair(manager->GetName(), manager));
108109
}
109110
else
110111
{

src/core/modules/commands/commands_say.h

100644100755
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@
3131
//-----------------------------------------------------------------------------
3232
#include "utilities/sp_util.h"
3333
#include "commands.h"
34+
35+
// This is required for accessing m_nFlags without patching convar.h
36+
#define private public
37+
#include "convar.h"
3438
#include "edict.h"
39+
#undef private
40+
3541
#include "game/server/iplayerinfo.h"
3642

3743
#include "modules/listeners/listeners_manager.h"

src/core/modules/commands/commands_say_wrap.cpp

100644100755
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
//-----------------------------------------------------------------------------
2828
// Includes.
2929
//-----------------------------------------------------------------------------
30-
// This is required for accessing m_nFlags without patching convar.h
31-
#define private public
32-
3330
#include "export_main.h"
3431
#include "utilities/wrap_macros.h"
3532
#include "modules/memory/memory_tools.h"

src/core/modules/commands/commands_server.cpp

100644100755
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
//-----------------------------------------------------------------------------
2828
// Includes
2929
//-----------------------------------------------------------------------------
30-
// This is required for accessing m_nFlags without patching convar.h
31-
#define private public
32-
3330
#include "utilities/call_python.h"
3431

3532
#include "boost/unordered_map.hpp"
@@ -87,7 +84,7 @@ CServerCommandManager* GetServerCommand(const char* szName,
8784
if (!find_manager<ServerCommandMap, ServerCommandMap::iterator>(g_ServerCommandMap, szName, iter))
8885
{
8986
manager = CServerCommandManager::CreateCommand(szName, szHelpText, iFlags);
90-
g_ServerCommandMap.insert(std::make_pair(manager->m_Name, manager));
87+
g_ServerCommandMap.insert(std::make_pair(manager->GetName(), manager));
9188
}
9289
else
9390
{
@@ -238,6 +235,11 @@ void CServerCommandManager::Dispatch( const CCommand& command )
238235
CALL_LISTENERS_WITH_MNGR(m_vecCallables[HOOKTYPE_POST], boost::ref(command))
239236
}
240237

238+
const char* CServerCommandManager::GetName()
239+
{
240+
return m_Name;
241+
}
242+
241243
//-----------------------------------------------------------------------------
242244
// Removes all CServerCommandManager instances.
243245
//-----------------------------------------------------------------------------

src/core/modules/commands/commands_server.h

100644100755
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
//-----------------------------------------------------------------------------
3030
// Includes
3131
//-----------------------------------------------------------------------------
32+
// This is required for accessing m_nFlags without patching convar.h
33+
#define private public
3234
#include "convar.h"
35+
#undef private
3336

3437
#include "modules/listeners/listeners_manager.h"
3538
#include "hook.h"
@@ -47,6 +50,8 @@ class CServerCommandManager : public ConCommand
4750
void AddCallback(PyObject* pCallable, HookType_t type);
4851
void RemoveCallback(PyObject* pCallable, HookType_t type);
4952

53+
const char* GetName();
54+
5055
protected:
5156
void Dispatch( const CCommand& command);
5257

src/core/modules/commands/commands_server_wrap.cpp

100644100755
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
//-----------------------------------------------------------------------------
2828
// Includes.
2929
//-----------------------------------------------------------------------------
30-
// This is required for accessing m_nFlags without patching convar.h
31-
#define private public
32-
3330
#include "boost/unordered_map.hpp"
3431
#include "utilities/wrap_macros.h"
3532
#include "commands_server.h"

src/core/modules/commands/commands_wrap.cpp

100644100755
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
//-----------------------------------------------------------------------------
2828
// Includes.
2929
//-----------------------------------------------------------------------------
30-
// This is required for accessing m_nFlags without patching convar.h
31-
#define private public
32-
3330
#include "utilities/wrap_macros.h"
3431
#include "export_main.h"
3532
#include "modules/memory/memory_tools.h"

src/core/modules/cvars/cvars.h

100644100755
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@
3030
//-----------------------------------------------------------------------------
3131
// Includes.
3232
//-----------------------------------------------------------------------------
33+
// This is required for accessing m_nFlags without patching convar.h
34+
#define private public
3335
#include "convar.h"
36+
#undef private
37+
3438
#include "utilities/sp_util.h"
3539

3640

src/core/modules/cvars/cvars_wrap.cpp

100644100755
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@
2727
//-----------------------------------------------------------------------------
2828
// Includes.
2929
//-----------------------------------------------------------------------------
30-
// This is required for accessing m_nFlags without patching convar.h
31-
#define private public
32-
3330
#include "export_main.h"
3431
#include "modules/memory/memory_tools.h"
3532
#include "icvar.h"
33+
34+
// This is required for accessing m_nFlags without patching convar.h
35+
#define private public
3636
#include "convar.h"
37+
#undef private
38+
3739
#include "cvars.h"
3840

3941
#include ENGINE_INCLUDE_PATH(cvars.h)

src/core/sp_main.h

100644100755
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@
2929
//---------------------------------------------------------------------------------
3030
// Includes
3131
//---------------------------------------------------------------------------------
32+
// This is required for accessing m_nFlags without patching convar.h
33+
#define private public
3234
#include "engine/iserverplugin.h"
35+
#undef private
36+
3337
#include "igameevents.h"
3438
#include "modules/memory/memory_tools.h"
3539

0 commit comments

Comments
 (0)