Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/core/modules/entities/entities.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,22 @@ class _BaseEdictExt
};


#ifdef ENGINE_ORANGEBOX
//-----------------------------------------------------------------------------
// CBaseHandle extension class.
//-----------------------------------------------------------------------------
class CBaseHandleExt
{
public:
static boost::shared_ptr<CBaseHandle> __init__(unsigned long value)
{
CBaseHandle hBaseHandle = CBaseHandle::UnsafeFromIndex(value);
return boost::shared_ptr<CBaseHandle>(new CBaseHandle(hBaseHandle));
}
};
#endif


//-----------------------------------------------------------------------------
// CTakeDamageInfo wrapper class.
//-----------------------------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions src/core/modules/entities/entities_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,18 @@ DECLARE_SP_MODULE(_entities)
//-----------------------------------------------------------------------------
void export_base_entity_handle(scope _entities)
{
#ifndef ENGINE_ORANGEBOX
class_<CBaseHandle>("BaseEntityHandle")
.def(init<CBaseHandle&>())
.def(init<unsigned long>())
.def(init<int, int>())
#else
class_<CBaseHandle, boost::shared_ptr<CBaseHandle>>("BaseEntityHandle")
.def(init<CBaseHandle&>())
.def(init<int, int>())

.def("__init__", make_constructor(&CBaseHandleExt::__init__))
#endif

.def("init",
&CBaseHandle::Init,
Expand Down
4 changes: 4 additions & 0 deletions src/core/utilities/conversions/basehandle_from.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ bool BaseHandleFromIndex( unsigned int iEntityIndex, CBaseHandle& output )
//-----------------------------------------------------------------------------
bool BaseHandleFromIntHandle( unsigned int iEntityHandle, CBaseHandle& output )
{
#ifndef ENGINE_ORANGEBOX
CBaseHandle hBaseHandle = CBaseHandle(iEntityHandle);
#else
CBaseHandle hBaseHandle = CBaseHandle::UnsafeFromIndex(iEntityHandle);
#endif
unsigned int iIndex;
if (!IndexFromBaseHandle(hBaseHandle, iIndex))
return false;
Expand Down
6 changes: 5 additions & 1 deletion src/core/utilities/conversions/index_from.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ bool IndexFromIntHandle( unsigned int iEntityHandle, unsigned int& output )
if (iEntityHandle == (int) INVALID_EHANDLE_INDEX)
return false;

CBaseHandle hBaseHandle(iEntityHandle);
#ifndef ENGINE_ORANGEBOX
CBaseHandle hBaseHandle = CBaseHandle(iEntityHandle);
#else
CBaseHandle hBaseHandle = CBaseHandle::UnsafeFromIndex(iEntityHandle);
#endif
unsigned int iEntityIndex;
if (!IndexFromBaseHandle(hBaseHandle, iEntityIndex))
return false;
Expand Down