Skip to content

Commit 2b00bc0

Browse files
committed
Reworked globals_c module
- Added new macro NOT_IMPLEMENTED_ATTR() - Two CS:GO fixes
1 parent bfe25f1 commit 2b00bc0

17 files changed

+214
-699
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,10 @@ Set(SOURCEPYTHON_ENTITY_MODULE_SOURCES
196196
# Globals module
197197
# ------------------------------------------------------------------
198198
Set(SOURCEPYTHON_GLOBALS_MODULE_HEADERS
199-
core/modules/globals/globals_wrap.h
200-
core/modules/globals/globals_engine_base.h
201-
core/modules/globals/engine${SOURCE_ENGINE}/globals_engine_implementation.h
199+
core/modules/globals/engine${SOURCE_ENGINE}/globals_wrap_python.h
202200
)
203201

204202
Set(SOURCEPYTHON_GLOBALS_MODULE_SOURCES
205-
core/modules/globals/globals_wrap.cpp
206-
core/modules/globals/globals_engine_base.cpp
207-
core/modules/globals/engine${SOURCE_ENGINE}/globals_engine_implementation.cpp
208203
core/modules/globals/globals_wrap_python.cpp
209204
)
210205

src/core/core/sp_python.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ CPythonManager g_PythonManager;
5252
//---------------------------------------------------------------------------------
5353
// PyMODINIT_FUNC PyInit_sp( void );
5454

55+
void InitConverters();
56+
5557
//---------------------------------------------------------------------------------
5658
// Adds a path to sys.path (relative to g_GamePaths.GetSPDir()).
5759
//---------------------------------------------------------------------------------
@@ -117,6 +119,9 @@ bool CPythonManager::Initialize( void )
117119
// And of course, the plugins directory for script imports.
118120
AddToSysPath("/plugins");
119121

122+
// Initialize all converters
123+
InitConverters();
124+
120125
// Initialize all submodules
121126
modulsp_init();
122127

@@ -140,3 +145,24 @@ bool CPythonManager::Shutdown( void )
140145
{
141146
return true;
142147
}
148+
149+
150+
//---------------------------------------------------------------------------------
151+
// Converters
152+
//---------------------------------------------------------------------------------
153+
struct string_t_to_python_str
154+
{
155+
static PyObject* convert(string_t const& s)
156+
{
157+
return incref(object(s.ToCStr()).ptr());
158+
}
159+
};
160+
161+
162+
//---------------------------------------------------------------------------------
163+
// Initializes all converters
164+
//---------------------------------------------------------------------------------
165+
void InitConverters()
166+
{
167+
to_python_converter< string_t, string_t_to_python_str >();
168+
}

src/core/modules/cvar/cvar_wrap_python.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,6 @@ void export_concommandbase()
144144
reference_existing_object_policy()
145145
)
146146

147-
.def("set_next",
148-
&ConCommandBase::SetNext,
149-
"Sets the next ConCommandBase instance."
150-
)
151-
152147
.def("is_registered",
153148
&ConCommandBase::IsRegistered,
154149
"Returns wheter the ConCommandBase instance is registered."

src/core/modules/effects/effects_wrap_python.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
//-----------------------------------------------------------------------------
3030
// These includes are really important. Be careful if you try to change the
3131
// order or remove an include!
32+
#include "mathlib/vector.h"
3233
#include <stddef.h>
3334
#include "wchartypes.h"
3435
#include "string_t.h"

src/core/modules/globals/engine1/globals_engine_implementation.h

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/core/modules/globals/engine1/globals_engine_implementation.cpp renamed to src/core/modules/globals/engine1/globals_wrap_python.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,12 @@
2424
* Development Team grants this exception to all derivative works.
2525
*/
2626

27-
#include "globals_engine_implementation.h"
27+
template<class T>
28+
void GlobalsBase_Visitor(T cls)
29+
{
30+
}
31+
32+
template<class T>
33+
void Globals_Visitor(T cls)
34+
{
35+
}

src/core/modules/globals/engine2/globals_engine_implementation.h

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/core/modules/globals/engine2/globals_engine_implementation.cpp renamed to src/core/modules/globals/engine2/globals_wrap_python.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,12 @@
2424
* Development Team grants this exception to all derivative works.
2525
*/
2626

27-
#include "globals_engine_implementation.h"
27+
template<class T>
28+
void GlobalsBase_Visitor(T cls)
29+
{
30+
}
31+
32+
template<class T>
33+
void Globals_Visitor(T cls)
34+
{
35+
}

src/core/modules/globals/engine3/globals_engine_implementation.cpp

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/core/modules/globals/engine3/globals_engine_implementation.h renamed to src/core/modules/globals/engine3/globals_wrap_python.h

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,33 @@
2424
* Development Team grants this exception to all derivative works.
2525
*/
2626

27-
//-----------------------------------------------------------------------------
28-
// Includes
29-
//-----------------------------------------------------------------------------
30-
#include "../globals_engine_base.h"
27+
#include "edict.h"
3128

32-
//-----------------------------------------------------------------------------
33-
// Purpose: Source Engine 3 Specific engine implementation calls
34-
//-----------------------------------------------------------------------------
35-
class CGlobalServerImplementation : public CGlobalServerImplementationBase
29+
template<class T>
30+
void GlobalsBase_Visitor(T cls)
3631
{
37-
public:
38-
virtual bool is_remote_client();
39-
virtual const char* get_map_group_name();
40-
virtual int get_server_count();
41-
virtual CEdict* get_edicts();
42-
};
32+
cls
33+
.def("is_remote_client",
34+
&CGlobalVarsBase::IsRemoteClient
35+
)
36+
;
37+
}
38+
39+
template<class T>
40+
void Globals_Visitor(T cls)
41+
{
42+
cls
43+
.add_property("map_group_name",
44+
make_getter(&CGlobalVars::mapGroupName, return_value_policy<return_by_value>())
45+
)
46+
47+
// TODO: Is this a list?
48+
.def_readonly("edicts",
49+
&CGlobalVars::pEdicts
50+
)
51+
52+
.def_readonly("server_count",
53+
&CGlobalVars::serverCount
54+
)
55+
;
56+
}

0 commit comments

Comments
 (0)