Skip to content

Commit 188cf55

Browse files
committed
Fixed some import errors in the Python API with recent changes to class names. Currently, core imports newly named EngineServer as GameEngine to not break backwards compat.
Changed all other instances within the API of GameEngine to use EngineServer. Undid rename of CMRecipientFilter to RecipientFilter due to class of the same name in filters.recipients. The name will be changed in the future, but to avoid this name conflict, the old name was returned. Added missing section headers in conversions_wrap.h
1 parent 1f0ff07 commit 188cf55

File tree

12 files changed

+44
-27
lines changed

12 files changed

+44
-27
lines changed

addons/source-python/packages/source-python/_core/command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from configobj import ConfigObj
99

1010
# Source.Python Imports
11+
from engine_c import EngineServer
1112
from _core import _CoreLogger
12-
from core import GameEngine
1313
from paths import SP_DATA_PATH
1414
# Plugins
1515
from plugins import _plugin_strings
@@ -121,7 +121,7 @@ def delay_execution(*args):
121121
# Add the delay
122122
TickDelays.delay(
123123
float(args[0]),
124-
GameEngine.server_command, ' '.join(args[1:]) + '\n')
124+
EngineServer.server_command, ' '.join(args[1:]) + '\n')
125125

126126
@staticmethod
127127
def print_version():

addons/source-python/packages/source-python/config/manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from textwrap import TextWrapper
1111

1212
# Source.Python Imports
13-
from core import GameEngine
13+
from engine_c import EngineServer
1414
from excepthooks import ExceptHooks
1515
from paths import CFG_PATH
1616
from public import public
@@ -386,7 +386,7 @@ def write(self):
386386

387387
def execute(self):
388388
'''Executes the config file'''
389-
GameEngine.server_command(
389+
EngineServer.server_command(
390390
'exec source-python/{0}\n'.format(self.filepath))
391391

392392
def _parse_old_file(self):

addons/source-python/packages/source-python/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from os import sep
99

1010
# Source.Python Imports
11-
from engine_c import GameEngine
11+
from engine_c import EngineServer as GameEngine
1212
from paths import GAME_PATH
1313
from public import public
1414

addons/source-python/packages/source-python/downloads.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# =============================================================================
66
# Source.Python Imports
77
from Source import Misc
8+
from engine_c import EngineServer
89
from core import AutoUnload
9-
from core import GameEngine
1010
from public import public
1111
# Events
1212
from events.manager import EventRegistry
@@ -67,13 +67,13 @@ def _add_to_download_table(self, item):
6767
'''Add the given file to the downloadables table'''
6868

6969
# Lock the network string tables
70-
locked = GameEngine.lock_network_string_tables(False)
70+
locked = EngineServer.lock_network_string_tables(False)
7171

7272
# Add the given file
7373
self.download_table.AddString(True, item)
7474

7575
# Reset the lock status
76-
GameEngine.lock_network_string_tables(locked)
76+
EngineServer.lock_network_string_tables(locked)
7777

7878
def server_spawn(self, GameEvent):
7979
'''Adds all items stored as downloadables to the stringtable'''

addons/source-python/packages/source-python/filters/players.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from configobj import ConfigObj
99

1010
# Source.Python Imports
11+
from engine_c import EngineServer
1112
from player_c import PlayerGenerator
12-
from core import GameEngine
1313
from core import GAME_NAME
1414
from paths import SP_DATA_PATH
1515
from public import public
@@ -213,7 +213,7 @@ def _return_weapon(PlayerInfo):
213213

214214
def _return_language(PlayerInfo):
215215
'''Returns the player's language'''
216-
return GameEngine.get_client_convar_value(
216+
return EngineServer.get_client_convar_value(
217217
index_from_playerinfo(PlayerInfo), 'cl_language')
218218

219219

addons/source-python/packages/source-python/loggers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
# Source.Python Imports
1919
from cvar_c import ConVar
20-
from core import GameEngine
20+
from engine_c import EngineServer
2121
from core import echo_console
2222
from paths import LOG_PATH
2323
from public import public
@@ -143,7 +143,7 @@ def _log(self, level, msg, *args, **kwargs):
143143
message = self.formatter.format(record)
144144

145145
# Print to the main log
146-
GameEngine.log_print(message + '\n')
146+
EngineServer.log_print(message + '\n')
147147

148148
# Print to the console?
149149
if CONSOLE & areas:

addons/source-python/packages/source-python/messages/base.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
from path import path
1818

1919
# Source.Python Imports
20+
from engine_c import EngineServer
2021
from core import echo_console
21-
from core import GameEngine
2222
from excepthooks import ExceptHooks
2323
# UserMessage
24-
from usermessage_c import CUserMessage
24+
from usermessage_c import UserMessage
2525
# Filters
2626
from filters.recipients import RecipientFilter
2727
# Translations
@@ -442,8 +442,8 @@ def _write_field_value(self, parameter_name, usermsg, field_type,
442442
def _send_message(self, recipient, **kwargs):
443443
'''Send the message to the given recipient filter'''
444444

445-
# Get a CUserMessage instance
446-
usermsg = CUserMessage(recipient, self._message_name)
445+
# Get a UserMessage instance
446+
usermsg = UserMessage(recipient, self._message_name)
447447

448448
# Loop through all required parameters
449449
for parameter_name in self._required_parameters:
@@ -550,7 +550,7 @@ def send(self, *args, **kwargs):
550550
for index in recipient:
551551

552552
# Add the current index
553-
languages[GameEngine.get_client_convar_value(index,
553+
languages[EngineServer.get_client_convar_value(index,
554554
'cl_language')].add(index)
555555

556556
# Loop through all languages

addons/source-python/packages/source-python/players/entity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# =============================================================================
66
# Source.Python Imports
77
from conversions_c import playerinfo_from_index
8-
from core import GameEngine
8+
from engine_c import EngineServer
99
from public import public
1010
# Entities
1111
from entities.entity import BaseEntity
@@ -78,7 +78,7 @@ def isdead(self):
7878
@property
7979
def language(self):
8080
'''Returns the player's language'''
81-
return GameEngine.get_client_convar_value(self.index, 'cl_language')
81+
return EngineServer.get_client_convar_value(self.index, 'cl_language')
8282

8383
@property
8484
def uniqueid(self):

addons/source-python/packages/source-python/players/helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# =============================================================================
66
# Source.Python Imports
77
from conversions_c import *
8+
from engine_c import EngineServer
89
from public import public
910

1011

@@ -102,7 +103,7 @@ def address_from_playerinfo(player):
102103
index = index_from_playerinfo(player)
103104

104105
# Get the player's NetInfo instance
105-
netinfo = GameEngine.get_player_net_info(index)
106+
netinfo = EngineServer.get_player_net_info(index)
106107

107108
# Return the player's IP Address
108109
return netinfo.get_address()

addons/source-python/packages/source-python/settings/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from collections import OrderedDict
99

1010
# Source.Python Imports
11-
from core import GameEngine
11+
from engine_c import EngineServer
1212
# Players
1313
from players.helpers import playerinfo_from_index
1414
from players.helpers import uniqueid_from_playerinfo
@@ -73,7 +73,7 @@ def get_setting(self, index):
7373
convar = self.prefix + self.name.lower().replace(' ', '_')
7474

7575
# Get the client's convar value
76-
value = GameEngine.get_client_convar_value(index, convar)
76+
value = EngineServer.get_client_convar_value(index, convar)
7777

7878
# Use try/except to typecast the value
7979
try:

src/core/modules/conversions/conversions_wrap.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,18 @@
3636
#include "public/game/server/iplayerinfo.h"
3737
#include "modules/memory/memory_tools.h"
3838

39-
39+
//-----------------------------------------------------------------------------
4040
// Externals
41+
//-----------------------------------------------------------------------------
4142
extern IVEngineServer* engine;
4243
extern CGlobalVars* gpGlobals;
4344
extern IPlayerInfoManager* playerinfomanager;
4445

4546
extern unsigned long ExtractPyPtr(object obj);
4647

48+
//-----------------------------------------------------------------------------
4749
// Forward declarations
50+
//-----------------------------------------------------------------------------
4851
edict_t* EdictFromIndex( unsigned int iEntIndex );
4952
edict_t* EdictFromUserid( unsigned int userid );
5053
edict_t* EdictFromPlayerInfo( IPlayerInfo* playerinfo );
@@ -53,6 +56,7 @@ IPlayerInfo* PlayerInfoFromIndex( unsigned int index );
5356
IPlayerInfo* PlayerInfoFromUserid( unsigned int userid );
5457

5558
//-----------------------------------------------------------------------------
59+
// Functions that return an entity's index.
5660
//-----------------------------------------------------------------------------
5761
inline unsigned int IndexFromEdict( edict_t* pEdict )
5862
{
@@ -124,6 +128,7 @@ inline unsigned int IndexFromPlayerInfo( IPlayerInfo* playerinfo )
124128
}
125129

126130
//-----------------------------------------------------------------------------
131+
// Functions that return an entity's edict_t instance.
127132
//-----------------------------------------------------------------------------
128133
inline edict_t* EdictFromIndex( unsigned int iEntIndex )
129134
{
@@ -177,6 +182,7 @@ inline edict_t* EdictFromPlayerInfo( IPlayerInfo* playerinfo )
177182
}
178183

179184
//-----------------------------------------------------------------------------
185+
// Functions that return an entity's CBaseHandle instance.
180186
//-----------------------------------------------------------------------------
181187
inline const CBaseHandle BaseHandleFromIndex( unsigned int index )
182188
{
@@ -209,6 +215,7 @@ inline const CBaseHandle BaseHandleFromPlayerInfo( IPlayerInfo* playerinfo )
209215
}
210216

211217
//-----------------------------------------------------------------------------
218+
// Functions that return an entity's integer handle.
212219
//-----------------------------------------------------------------------------
213220
inline int IntHandleFromIndex( unsigned int index )
214221
{
@@ -241,6 +248,7 @@ inline int IntHandleFromPlayerInfo( IPlayerInfo* playerinfo )
241248
}
242249

243250
//-----------------------------------------------------------------------------
251+
// Functions that return an entity's CPointer instance.
244252
//-----------------------------------------------------------------------------
245253
inline CPointer* PointerFromIndex( unsigned int index )
246254
{
@@ -273,6 +281,7 @@ inline CPointer* PointerFromPlayerInfo( IPlayerInfo* playerinfo )
273281
}
274282

275283
//-----------------------------------------------------------------------------
284+
// Functions that return an player's userid.
276285
//-----------------------------------------------------------------------------
277286
inline unsigned int UseridFromIndex( unsigned int index )
278287
{
@@ -305,6 +314,7 @@ inline unsigned int UseridFromPlayerInfo( IPlayerInfo* playerinfo )
305314
}
306315

307316
//-----------------------------------------------------------------------------
317+
// Functions that return an player's IPlayerInfo instance.
308318
//-----------------------------------------------------------------------------
309319
inline IPlayerInfo* PlayerInfoFromIndex( unsigned int index )
310320
{

src/core/modules/recipientfilter/recipientfilter_wrap_python.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,29 @@
2727
* https://developer.valvesoftware.com/wiki/Ingame_menu_for_server_plugins_(CS:S_only)
2828
*/
2929

30+
//-----------------------------------------------------------------------------
31+
// Includes
32+
//-----------------------------------------------------------------------------
3033
#include "modules/export_main.h"
3134
#include "mrecipientfilter.h"
3235

33-
//---------------------------------------------------------------------------------
34-
// Exposes the engine module.
35-
//---------------------------------------------------------------------------------
36+
//-----------------------------------------------------------------------------
37+
// Exposes the recipientfilter_c module.
38+
//-----------------------------------------------------------------------------
3639
void export_mrecipientfilter();
3740

3841
DECLARE_SP_MODULE(recipientfilter_c)
3942
{
4043
export_mrecipientfilter();
4144
}
4245

46+
//-----------------------------------------------------------------------------
47+
// Expose MRecipientFilter
48+
//-----------------------------------------------------------------------------
4349
void export_mrecipientfilter()
4450
{
4551
// TODO: Rename class
46-
class_<MRecipientFilter, boost::noncopyable>("RecipientFilter")
52+
class_<MRecipientFilter, boost::noncopyable>("CMRecipientFilter")
4753
.def("is_reliable",
4854
&MRecipientFilter::IsReliable,
4955
"Whether this recipient filter will be network reliable (sent in-order)"

0 commit comments

Comments
 (0)