Skip to content

Commit 5090186

Browse files
committed
Patched KeyValues class
1 parent caad960 commit 5090186

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

src/core/modules/keyvalues/keyvalues_wrap_python.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,11 @@ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(is_empty_overload, IsEmpty, 0, 1);
8484

8585
void export_keyvalues()
8686
{
87-
// TODO: Add constructors. There are two possibilities:
88-
// 1. Patch SDK and make destructor public. Then deleteThis() isn't required anymore
89-
// 2. Create functions which construct a new object
90-
class_<KeyValues, boost::noncopyable>("KeyValues", no_init)//init<const char *>())
91-
/*
87+
class_<KeyValues, boost::noncopyable>("KeyValues",init<const char *>())
9288
.def(init<const char *, const char *, const char *>())
9389
.def(init<const char *, const char *, int>())
9490
.def(init<const char *, const char *, const char *, const char *, const char *>())
9591
.def(init<const char *, const char *, int, const char *, int>())
96-
*/
97-
98-
.def("delete",
99-
&KeyValues::deleteThis,
100-
"Ensures that KeyValues object is deleted from correct heap"
101-
)
10292

10393
.def("get_name",
10494
&KeyValues::GetName,

src/core/utility/patches/engine1/patches.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,9 @@
3737
#include "eiface.h"
3838
#ifndef PATCH_EIFACE_H_BBOX_T
3939
#error "Implement struct bbox_t in public/eiface.h"
40+
#endif
41+
42+
#include "KeyValues.h"
43+
#ifndef PATCH_KEYVALUES_DESTRUCTOR
44+
#error "Make KeyValues::~KeyValues() public."
4045
#endif

src/core/utility/patches/engine3/patches.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@
2222
* by the Valve Corporation. You must obey the GNU General Public License in
2323
* all respects for all other code used. Additionally, the Source.Python
2424
* Development Team grants this exception to all derivative works.
25-
*/
25+
*/
26+
27+
#include "KeyValues.h"
28+
#ifndef PATCH_KEYVALUES_DESTRUCTOR
29+
#error "Make KeyValues::~KeyValues() public.
30+
#endif

src/sdks/hl2sdk-csgo/public/tier1/KeyValues.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,11 @@ class KeyValues
281281
private:
282282
KeyValues( KeyValues& ); // prevent copy constructor being used
283283

284+
#define PATCH_KEYVALUES_DESTRUCTOR
285+
public:
284286
// prevent delete being called except through deleteThis()
285287
~KeyValues();
288+
private:
286289

287290
KeyValues* CreateKey( const char *keyName );
288291

src/sdks/hl2sdk-ob-valve/public/tier1/KeyValues.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,11 @@ class KeyValues
221221
private:
222222
KeyValues( KeyValues& ); // prevent copy constructor being used
223223

224+
#define PATCH_KEYVALUES_DESTRUCTOR
225+
public:
224226
// prevent delete being called except through deleteThis()
225227
~KeyValues();
228+
private:
226229

227230
KeyValues* CreateKey( const char *keyName );
228231

0 commit comments

Comments
 (0)