Skip to content

Commit 061c063

Browse files
committed
OB SDK fixes
1 parent f3f1647 commit 061c063

File tree

12 files changed

+70
-34
lines changed

12 files changed

+70
-34
lines changed

src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# ------------------------------------------------------------------
22
# Set minimum required version of CMake
33
# ------------------------------------------------------------------
4-
CMake_Minimum_Required(VERSION 3.0)
5-
project(Source-Python)
4+
CMake_Minimum_Required(VERSION 3.15)
5+
project(source-python)
66

77
# ------------------------------------------------------------------
88
# Makefile includes.

src/core/modules/engines/engines_server_wrap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ static void export_iserver(scope _server)
881881

882882
_IServer.add_property(
883883
"udp_port",
884-
#if defined(ENGINE_BRANCH_TF2) || defined(ENGINE_BRANCH_HL2DM)
884+
#if defined(ENGINE_ORANGEBOX)
885885
&IServer::GetLocalUDPPort,
886886
#else
887887
&IServer::GetUDPPort,

src/core/modules/entities/entities.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ class TakeDamageInfoBaseWrapper: public CTakeDamageInfo
102102

103103
void set_inflictor(unsigned int uiInflictor)
104104
{
105+
#if defined(ENGINE_ORANGEBOX)
106+
m_hInflictor = EHANDLE::UnsafeFromIndex(uiInflictor);
107+
#else
105108
m_hInflictor = ExcBaseHandleFromIndex(uiInflictor);
109+
#endif
106110
}
107111

108112
unsigned int get_attacker()
@@ -144,7 +148,7 @@ class TakeDamageInfoBaseWrapper: public CTakeDamageInfo
144148
m_CSGOAttacker.m_iUserId = -1;
145149
}
146150
#else
147-
m_hAttacker = ExcBaseHandleFromIndex(uiAttacker);
151+
m_hAttacker = EHANDLE::UnsafeFromIndex(uiAttacker);
148152
#endif
149153
}
150154

@@ -172,7 +176,11 @@ class TakeDamageInfoBaseWrapper: public CTakeDamageInfo
172176

173177
void set_weapon(unsigned int uiWeapon)
174178
{
179+
#if defined(ENGINE_ORANGEBOX)
180+
m_hWeapon = EHANDLE::UnsafeFromIndex(uiWeapon);
181+
#else
175182
m_hWeapon = ExcBaseHandleFromIndex(uiWeapon);
183+
#endif
176184
}
177185

178186
void set_base_damage(float flBaseDamage)

src/core/modules/keyvalues/keyvalues_wrap.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,31 @@
4949
friend void RecursiveCopyKeyValuesHack(KeyValues* pThis, KeyValues& src);
5050
void RecursiveCopyKeyValues( KeyValues& src );
5151
*/
52-
#define RecursiveCopyKeyValues \
53-
JustFinishTheDeclaration() {} \
54-
friend void RecursiveCopyKeyValuesHack(KeyValues* pThis, KeyValues& src); \
55-
void RecursiveCopyKeyValues
52+
#if defined(ENGINE_ORANGEBOX)
53+
#define CopyKeyValuesFromRecursive \
54+
JustFinishTheDeclaration() {} \
55+
friend void RecursiveCopyKeyValuesHack(KeyValues* pThis, KeyValues& src); \
56+
void CopyKeyValuesFromRecursive
57+
#else
58+
#define RecursiveCopyKeyValues \
59+
JustFinishTheDeclaration() {} \
60+
friend void RecursiveCopyKeyValuesHack(KeyValues* pThis, KeyValues& src); \
61+
void RecursiveCopyKeyValues
62+
#endif
5663

5764
#include "tier1/KeyValues.h"
5865

5966
// Now, remove the replacement, so the friend function can call the member function.
6067
#define RecursiveCopyKeyValues RecursiveCopyKeyValues
68+
#define CopyKeyValuesFromRecursive CopyKeyValuesFromRecursive
69+
6170
void RecursiveCopyKeyValuesHack(KeyValues* pThis, KeyValues& src)
6271
{
72+
#if defined(ENGINE_ORANGEBOX)
73+
pThis->CopyKeyValuesFromRecursive(src);
74+
#else
6375
pThis->RecursiveCopyKeyValues(src);
76+
#endif
6477
}
6578

6679

@@ -191,7 +204,7 @@ void export_keyvalues(scope _keyvalues)
191204

192205
.add_property("next_key",
193206
make_function(
194-
&KeyValues::GetNextKey,
207+
GET_CONST_METHOD(const KeyValues*, KeyValues, GetNextKey),
195208
reference_existing_object_policy()
196209
),
197210
&KeyValues::SetNextKey,

src/core/modules/players/players_wrap.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
//-----------------------------------------------------------------------------
2828
// Includes.
2929
//-----------------------------------------------------------------------------
30+
class CBasePlayer;
31+
3032
#include "players_generator.h"
3133
#include "export_main.h"
3234
#include "modules/memory/memory_tools.h"

src/core/modules/steam/orangebox/steam_wrap.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ void export_engine_specific_steamid(scope _steam, T SteamID)
3535
template<class T>
3636
void export_engine_specific_account_type(scope _steam, T AccountType)
3737
{
38-
AccountType.value("P2P_SUPER_SEEDER", k_EAccountTypeP2PSuperSeeder);
3938
}
4039

4140
#endif // _STEAM_WRAP_ORANGEBOX_H

src/core/sp_hooks.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
//---------------------------------------------------------------------------------
2828
// Includes
2929
//---------------------------------------------------------------------------------
30+
class CBasePlayer;
31+
3032
// Boost.Python
3133
#include "boost/python.hpp"
3234
using namespace boost::python;

src/core/sp_main.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ bool CSourcePython::Load( CreateInterfaceFn interfaceFactory, CreateInterfaceFn
219219
DevMsg(1, MSG_PREFIX "Connecting tier1 libraries...\n");
220220
ConnectTier1Libraries( &interfaceFactory, 1 );
221221

222-
DevMsg(1, MSG_PREFIX "Connecting tier2 libraries...\n");
223-
ConnectTier2Libraries( &interfaceFactory, 2 );
222+
//DevMsg(1, MSG_PREFIX "Connecting tier2 libraries...\n");
223+
//ConnectTier2Libraries( &interfaceFactory, 2 );
224224
#endif
225225

226226
// Get all engine interfaces.
@@ -317,8 +317,8 @@ void CSourcePython::Unload( void )
317317
DevMsg(1, MSG_PREFIX "Disconnecting interfaces...\n");
318318
DisconnectInterfaces();
319319
#else
320-
DevMsg(1, MSG_PREFIX "Disconnecting tier2 libraries...\n");
321-
DisconnectTier2Libraries( );
320+
//DevMsg(1, MSG_PREFIX "Disconnecting tier2 libraries...\n");
321+
//DisconnectTier2Libraries( );
322322

323323
DevMsg(1, MSG_PREFIX "Disconnecting tier1 libraries...\n");
324324
DisconnectTier1Libraries( );
@@ -351,7 +351,7 @@ void CSourcePython::UnPause( void )
351351
//-----------------------------------------------------------------------------
352352
const char *CSourcePython::GetPluginDescription( void )
353353
{
354-
return "Source.Python, (C) 2012-2021, Source.Python Team.";
354+
return "Source.Python, (C) 2012-2025, Source.Python Team.";
355355
}
356356

357357
//-----------------------------------------------------------------------------
@@ -507,7 +507,7 @@ void CSourcePython::ClientFullyConnect( edict_t *pEntity )
507507
}
508508
#endif
509509

510-
#if defined(ENGINE_CSGO) || defined(ENGINE_BMS) || defined(ENGINE_BLADE)
510+
#if defined(ENGINE_CSGO) || defined(ENGINE_BMS) || defined(ENGINE_BLADE) || defined(ENGINE_ORANGEBOX)
511511
void CSourcePython::OnEdictAllocated( edict_t *edict )
512512
{
513513
unsigned int iEntityIndex;

src/core/sp_main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class CSourcePython: public IServerPluginCallbacks, public IEntityListener, publ
8383
virtual void ClientFullyConnect( edict_t *pEntity );
8484
#endif
8585

86-
#if defined(ENGINE_CSGO) || defined(ENGINE_BMS) || defined(ENGINE_BLADE)
86+
#if defined(ENGINE_CSGO) || defined(ENGINE_BMS) || defined(ENGINE_BLADE) || defined(ENGINE_ORANGEBOX)
8787
virtual void OnEdictAllocated( edict_t *edict );
8888
virtual void OnEdictFreed( const edict_t *edict );
8989
#endif

src/loader/loader_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ void CSourcePython::ClientFullyConnect( edict_t *pEntity )
463463
}
464464
#endif
465465

466-
#if defined(ENGINE_CSGO) || defined(ENGINE_BMS) || defined(ENGINE_BLADE)
466+
#if defined(ENGINE_CSGO) || defined(ENGINE_BMS) || defined(ENGINE_BLADE) || defined(ENGINE_ORANGEBOX)
467467
void CSourcePython::OnEdictAllocated( edict_t *edict )
468468
{
469469
if (m_pCorePlugin != NULL)

src/loader/loader_main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class CSourcePython: public IServerPluginCallbacks
7676
virtual void ClientFullyConnect( edict_t *pEntity );
7777
#endif
7878

79-
#if defined(ENGINE_CSGO) || defined(ENGINE_BMS) || defined(ENGINE_BLADE)
79+
#if defined(ENGINE_CSGO) || defined(ENGINE_BMS) || defined(ENGINE_BLADE) || defined(ENGINE_ORANGEBOX)
8080
virtual void OnEdictAllocated( edict_t *edict );
8181
virtual void OnEdictFreed( const edict_t *edict );
8282
#endif

src/makefiles/win32/win32.base.cmake

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,19 @@ Set(CMAKE_CXX_FLAGS_RELEASE "/D_NDEBUG /MD /wd4005 /MP")
3737
# ------------------------------------------------------------------
3838
# Statically link runtime libraries for the loader
3939
# ------------------------------------------------------------------
40-
# This looks like a bug...
41-
# For the debug config we need to specify the release flag and vice versa.
42-
target_compile_options(source-python PRIVATE "/MT$<$<CONFIG:Debug>:d>")
43-
target_compile_options(source-python PRIVATE "/MTd$<$<CONFIG:Release>:d>")
44-
target_compile_options(core PRIVATE "/MT$<$<CONFIG:Debug>:d>")
45-
target_compile_options(core PRIVATE "/MTd$<$<CONFIG:Release>:d>")
40+
set_property(TARGET core source-python PROPERTY
41+
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
4642

47-
Set_Target_Properties(core PROPERTIES
48-
LINK_FLAGS_RELEASE "/NODEFAULTLIB:LIBC.lib /NODEFAULTLIB:LIBCMT.lib /NODEFAULTLIB:LIBCPMT.lib"
49-
)
43+
#Set_Target_Properties(core PROPERTIES
44+
# LINK_FLAGS_RELEASE "/NODEFAULTLIB:LIBC.lib /NODEFAULTLIB:LIBCMT.lib /NODEFAULTLIB:LIBCPMT.lib"
45+
#)
46+
47+
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
5048

5149
# ------------------------------------------------------------------
5250
# Link libraries.
5351
# ------------------------------------------------------------------
5452
Set(SOURCEPYTHON_LINK_LIBRARIES
55-
${SOURCESDK_LIB}/public/tier0.lib
56-
${SOURCESDK_LIB}/public/tier1.lib
57-
${SOURCESDK_LIB}/public/tier2.lib
58-
${SOURCESDK_LIB}/public/tier3.lib
59-
${SOURCESDK_LIB}/public/vstdlib.lib
60-
${SOURCESDK_LIB}/public/mathlib.lib
6153
${DYNCALLSDK_LIB}/libdyncall_s.lib
6254
${DYNCALLSDK_LIB}/libdyncallback_s.lib
6355
${DYNCALLSDK_LIB}/libdynload_s.lib
@@ -67,6 +59,26 @@ Set(SOURCEPYTHON_LINK_LIBRARIES
6759
${BOOSTSDK_LIB}/libboost_system-vc143-mt-s-x32-1_87.lib
6860
)
6961

62+
If( SOURCE_ENGINE MATCHES "csgo" OR SOURCE_ENGINE MATCHES "blade")
63+
Set(SOURCEPYTHON_LINK_LIBRARIES
64+
${SOURCEPYTHON_LINK_LIBRARIES}
65+
${SOURCESDK_LIB}/public/tier0.lib
66+
${SOURCESDK_LIB}/public/tier1.lib
67+
${SOURCESDK_LIB}/public/tier2.lib
68+
${SOURCESDK_LIB}/public/tier3.lib
69+
${SOURCESDK_LIB}/public/vstdlib.lib
70+
${SOURCESDK_LIB}/public/mathlib.lib
71+
)
72+
Else()
73+
Set(SOURCEPYTHON_LINK_LIBRARIES
74+
${SOURCEPYTHON_LINK_LIBRARIES}
75+
${SOURCESDK_LIB}/public/x86/tier0.lib
76+
${SOURCESDK_LIB}/public/x86/tier1.lib
77+
${SOURCESDK_LIB}/public/x86/vstdlib.lib
78+
${SOURCESDK_LIB}/public/x86/mathlib.lib
79+
)
80+
Endif()
81+
7082
# CSGO Engine adds in interfaces.lib
7183
If( SOURCE_ENGINE MATCHES "csgo" OR SOURCE_ENGINE MATCHES "blade")
7284
Set(SOURCEPYTHON_LINK_LIBRARIES

0 commit comments

Comments
 (0)