Skip to content

Commit 163b2a2

Browse files
authored
Merge branch 'Source-Python-Dev-Team:master' into master
2 parents a8175e8 + 45b24d8 commit 163b2a2

File tree

14 files changed

+142
-57
lines changed

14 files changed

+142
-57
lines changed

addons/source-python/data/source-python/credits.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
ThomasVieth = "Thomas Vieth"
4444
ericentin = "Eric Entin"
4545
roflmuffin = "Michael"
46+
laurirasanen = "Lauri Räsänen"
4647
4748
4849
# This category is for people that have helped in development
@@ -60,7 +61,7 @@
6061
# <GitHub name> = "<actual name>"
6162
[Translators]
6263
63-
Doldol = ""
64+
Doldol/ismael-git = ""
6465
MrMalina = ""
6566
Hackmastr = ""
6667
2389736818 = ""

addons/source-python/data/source-python/entities/csgo/CBaseCombatCharacter.ini

100644100755
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ srv_check = False
55

66
# _ZNK20CBaseCombatCharacter15IsInFieldOfViewERK6Vector
77
[[is_in_field_of_view]]
8-
offset_linux = 274
9-
offset_windows = 273
8+
offset_linux = 276
9+
offset_windows = 275
1010
arguments = POINTER
1111
return_type = BOOL
1212

1313
# _ZN20CBaseCombatCharacter18OnTakeDamage_AliveERK15CTakeDamageInfo
1414
[[on_take_damage_alive]]
15-
offset_linux = 299
16-
offset_windows = 298
15+
offset_linux = 300
16+
offset_windows = 299
1717
arguments = POINTER
1818
return_type = INT
1919

2020
# _ZN20CBaseCombatCharacter13Weapon_SwitchEP17CBaseCombatWeaponi
2121
[[weapon_switch]]
22-
offset_linux = 289
23-
offset_windows = 288
22+
offset_linux = 290
23+
offset_windows = 289
2424
arguments = POINTER, INT
2525
return_type = BOOL

addons/source-python/data/source-python/entities/csgo/CBasePlayer.ini

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,57 @@ srv_check = False
55

66
# _ZN11CBasePlayer10BumpWeaponEP17CBaseCombatWeapon
77
[[bump_weapon]]
8-
offset_linux = 453
9-
offset_windows = 452
8+
offset_linux = 454
9+
offset_windows = 453
1010
arguments = POINTER
1111
return_type = BOOL
1212

1313
# _ZN11CBasePlayer11Weapon_DropEP17CBaseCombatWeaponPK6VectorS4_
1414
[[drop_weapon]]
15-
offset_linux = 288
16-
offset_windows = 287
15+
offset_linux = 289
16+
offset_windows = 288
1717
arguments = POINTER, POINTER, POINTER
1818

1919
# _ZN11CBasePlayer13GiveNamedItemEPKciP13CEconItemViewb
2020
[[give_named_item]]
21-
offset_linux = 458
22-
offset_windows = 457
21+
offset_linux = 459
22+
offset_windows = 458
2323
arguments = STRING, INT, POINTER, BOOL, POINTER
2424
return_type = POINTER
2525

2626
# _ZN11CBasePlayer21IncrementAssistsCountEi
2727
[[increment_assists_count]]
28-
offset_linux = 500
29-
offset_windows = 499
28+
offset_linux = 501
29+
offset_windows = 500
3030
arguments = INT
3131

3232
# _ZN11CBasePlayer19IncrementDeathCountEi
3333
[[increment_death_count]]
34-
offset_linux = 501
35-
offset_windows = 500
34+
offset_linux = 502
35+
offset_windows = 501
3636
arguments = INT
3737

3838
# _ZN11CBasePlayer18IncrementFragCountEii
3939
[[increment_frag_count]]
40-
offset_linux = 499
41-
offset_windows = 498
40+
offset_linux = 500
41+
offset_windows = 499
4242
arguments = INT, INT
4343

4444
# _ZN11CBasePlayer16PlayerRunCommandEP8CUserCmdP11IMoveHelper
4545
[[run_command]]
46-
offset_linux = 478
47-
offset_windows = 477
46+
offset_linux = 479
47+
offset_windows = 478
4848
arguments = POINTER, POINTER
4949

5050
# _ZN11CBasePlayer8PreThinkEv
5151
[[pre_think]]
52-
offset_linux = 372
53-
offset_windows = 371
52+
offset_linux = 373
53+
offset_windows = 372
5454

5555
# _ZN11CBasePlayer9PostThinkEv
5656
[[post_think]]
57-
offset_linux = 373
58-
offset_windows = 372
57+
offset_linux = 374
58+
offset_windows = 373
5959

6060

6161
[based_attribute]

addons/source-python/data/source-python/entities/csgo/CCSPlayer.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ srv_check = False
4141

4242
# _ZN9CCSPlayer12Weapon_EquipEP17CBaseCombatWeapon
4343
[[equip_weapon]]
44-
offset_linux = 286
45-
offset_windows = 285
44+
offset_linux = 287
45+
offset_windows = 286
4646
arguments = POINTER
4747

4848
# _ZN9CCSPlayer5BlindEfff
4949
[[blind]]
50-
offset_linux = 550
51-
offset_windows = 547
50+
offset_linux = 551
51+
offset_windows = 548
5252
arguments = FLOAT, FLOAT, FLOAT
5353

5454

addons/source-python/docs/source-python/source/general/updating.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ Manually
55
--------
66

77
1. Delete the entire ``../addons/source-python/data/source-python/`` directory.
8-
2. Delete the entire ``../addons/source-python/packages/source-python/`` directory.
9-
3. Delete the entire ``../addons/source-python/docs/source-python/`` directory.
10-
4. Delete the entire ``../addons/source-python/Python3/`` directory.
11-
5. Continue with the :doc:`installation tutorial <installation>`.
8+
2. Delete the ``../addons/source-python/data/source-python-data.zip`` file if present.
9+
3. Delete the entire ``../addons/source-python/packages/source-python/`` directory.
10+
4. Delete the entire ``../addons/source-python/docs/source-python/`` directory.
11+
5. Delete the entire ``../addons/source-python/Python3/`` directory.
12+
6. Continue with the :doc:`installation tutorial <installation>`.
1213

1314

1415
Automatically

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

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
from paths import ADDONS_PATH
2222
from paths import GAME_PATH
2323
from paths import UPDATE_PATH
24+
from paths import UPDATE_DATA_PATH
25+
from paths import UPDATE_SP_DATA_PATH
2426
from paths import DATA_PATH
2527
from paths import SP_DATA_PATH
2628
# KeyValues
@@ -197,6 +199,18 @@ def _apply_update_stage1():
197199
else:
198200
_apply_update_stage1_linux()
199201

202+
# Apply latest data update
203+
if not DATA_ZIP_FILE.isfile():
204+
return
205+
206+
update_logger.log_debug('Applying latest data update...')
207+
208+
if UPDATE_SP_DATA_PATH.isdir():
209+
update_logger.log_debug(f'Removing {UPDATE_SP_DATA_PATH} ...')
210+
UPDATE_SP_DATA_PATH.rmtree()
211+
212+
_unpack_data(UPDATE_DATA_PATH)
213+
200214
def _apply_update_stage1_windows():
201215
"""Apply the Windows specific part of stage 1.
202216
@@ -262,7 +276,7 @@ def update_data(timeout=DEFAULT_TIMEOUT):
262276
update_logger.log_debug('Removing {} ...'.format(SP_DATA_PATH))
263277
SP_DATA_PATH.rmtree()
264278

265-
_unpack_data()
279+
_unpack_data(DATA_PATH)
266280

267281
def is_new_data_available(timeout=DEFAULT_TIMEOUT):
268282
"""Return ``True`` if new data is available.
@@ -294,8 +308,12 @@ def _download_latest_data(timeout=DEFAULT_TIMEOUT):
294308
"""
295309
download_file(DATA_URL, DATA_ZIP_FILE, timeout)
296310

297-
def _unpack_data():
298-
"""Unpack ``source-python-data.zip``."""
299-
update_logger.log_debug('Extracting data in {} ...'.format(DATA_PATH))
311+
def _unpack_data(path):
312+
"""Unpack ``source-python-data.zip`` into the given path.
313+
314+
:param Path path:
315+
The path the data file should be unpacked into.
316+
"""
317+
update_logger.log_debug(f'Extracting data in {path} ...')
300318
with ZipFile(DATA_ZIP_FILE) as zip:
301-
zip.extractall(DATA_PATH)
319+
zip.extractall(path)

addons/source-python/packages/source-python/listeners/__init__.py

100644100755
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from core.version import VERSION
2222
# Cvars
2323
from cvars import ConVar
24-
from cvars import cvar
2524
# Engines
2625
from engines.server import server_game_dll
2726
# Entities
@@ -52,6 +51,7 @@
5251
from _listeners import on_client_fully_connect_listener_manager
5352
from _listeners import on_client_put_in_server_listener_manager
5453
from _listeners import on_client_settings_changed_listener_manager
54+
from _listeners import on_convar_changed_listener_manager
5555
from _listeners import on_level_init_listener_manager
5656
from _listeners import on_level_shutdown_listener_manager
5757
from _listeners import on_network_id_validated_listener_manager
@@ -166,7 +166,6 @@
166166
listeners_logger = _sp_logger.listeners
167167

168168
on_version_update_listener_manager = ListenerManager()
169-
on_convar_changed_listener_manager = ListenerManager()
170169
on_plugin_loaded_manager = ListenerManager()
171170
on_plugin_unloaded_manager = ListenerManager()
172171
on_plugin_loading_manager = ListenerManager()
@@ -600,14 +599,6 @@ def _on_level_shutdown():
600599
OnLevelEnd._level_initialized = False
601600

602601

603-
@PreHook(get_virtual_function(cvar, 'CallGlobalChangeCallbacks'))
604-
def _pre_call_global_change_callbacks(args):
605-
"""Called when a ConVar has been changed."""
606-
convar = make_object(ConVar, args[1])
607-
old_value = args[2]
608-
on_convar_changed_listener_manager.notify(convar, old_value)
609-
610-
611602
def _pre_fire_output(args):
612603
"""Called when an output is about to be fired."""
613604
if not on_entity_output_listener_manager:

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
'TRANSLATION_PATH',
3636
'AUTH_CFG_PATH',
3737
'BACKENDS_PATH',
38-
'UPDATE_PATH'
38+
'UPDATE_PATH',
39+
'UPDATE_DATA_PATH',
40+
'UPDATE_SP_DATA_PATH'
3941
)
4042

4143

@@ -54,6 +56,12 @@
5456
# ../addons/source-python/update
5557
UPDATE_PATH = BASE_PATH / 'update'
5658

59+
# ../addons/source-python/update/addons/source-python/data/
60+
UPDATE_DATA_PATH = UPDATE_PATH / 'addons' / 'source-python' / 'data'
61+
62+
# ../addons/source-python/update/addons/source-python/data/source-python
63+
UPDATE_SP_DATA_PATH = UPDATE_DATA_PATH / 'source-python'
64+
5765
# ../addons/source-python/docs
5866
DOCS_PATH = BASE_PATH / 'docs'
5967

src/core/modules/engines/engines_server_wrap.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,11 +521,6 @@ static void export_engine_server(scope _server)
521521
"Tells the engine we can immediately re-use all the edict indices."
522522
)
523523

524-
.def("is_internal_build",
525-
&IVEngineServer::IsInternalBuild,
526-
"Returns true if the engine is an internal build."
527-
)
528-
529524
.def("get_change_accessor",
530525
&IVEngineServer::GetChangeAccessor,
531526
args("edict"),
@@ -751,7 +746,6 @@ static void export_engine_server(scope _server)
751746
FUNCTION_INFO(GetPrevCheckTransmitInfo)
752747
FUNCTION_INFO(GetSharedEdictChangeInfo)
753748
FUNCTION_INFO(AllowImmediateEdictReuse)
754-
FUNCTION_INFO(IsInternalBuild)
755749
FUNCTION_INFO(GetChangeAccessor)
756750
FUNCTION_INFO(CleanUpEntityClusterList)
757751
FUNCTION_INFO(GetAppID)
@@ -887,7 +881,11 @@ static void export_iserver(scope _server)
887881

888882
_IServer.add_property(
889883
"udp_port",
884+
#if defined(ENGINE_BRANCH_TF2)
885+
&IServer::GetLocalUDPPort,
886+
#else
890887
&IServer::GetUDPPort,
888+
#endif
891889
"Return the currently used UDP port.\n\n"
892890
":rtype: int"
893891
);

src/core/modules/listeners/listeners_manager.cpp

100644100755
Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@
3030
#include "listeners_manager.h"
3131

3232

33+
//-----------------------------------------------------------------------------
34+
// External variables.
35+
//-----------------------------------------------------------------------------
36+
extern ICvar* g_pCVar;
37+
38+
39+
//-----------------------------------------------------------------------------
40+
// Extern functions
41+
//-----------------------------------------------------------------------------
42+
extern CConVarChangedListenerManager* GetOnConVarChangedListenerManager();
43+
44+
3345
//-----------------------------------------------------------------------------
3446
// Adds a callable to the end of the CListenerManager vector.
3547
//-----------------------------------------------------------------------------
@@ -149,7 +161,38 @@ object CListenerManager::__getitem__(unsigned int index)
149161

150162
void CListenerManager::clear()
151163
{
152-
m_vecCallables.RemoveAll();
164+
if (GetCount()) {
165+
m_vecCallables.RemoveAll();
166+
Finalize();
167+
}
168+
}
169+
170+
171+
//-----------------------------------------------------------------------------
172+
// Convar changed callback.
173+
//-----------------------------------------------------------------------------
174+
void ConVarChangedCallback(IConVar* var, const char* pOldValue, float flOldValue)
175+
{
176+
static CConVarChangedListenerManager* on_convar_changed_listener_manager = GetOnConVarChangedListenerManager();
177+
CALL_LISTENERS_WITH_MNGR(on_convar_changed_listener_manager, ptr(static_cast<ConVar*>(var)), pOldValue);
178+
}
179+
180+
181+
//-----------------------------------------------------------------------------
182+
// Called when the first callback is being registered.
183+
//-----------------------------------------------------------------------------
184+
void CConVarChangedListenerManager::Initialize()
185+
{
186+
g_pCVar->InstallGlobalChangeCallback(ConVarChangedCallback);
187+
}
188+
189+
190+
//-----------------------------------------------------------------------------
191+
// Called when the last callback is being unregistered.
192+
//-----------------------------------------------------------------------------
193+
void CConVarChangedListenerManager::Finalize()
194+
{
195+
g_pCVar->RemoveGlobalChangeCallback(ConVarChangedCallback);
153196
}
154197

155198

src/core/modules/listeners/listeners_manager.h

100644100755
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#include "utilities/wrap_macros.h"
3434
#include "utlvector.h"
3535

36+
#include "convar.h"
37+
3638

3739
//-----------------------------------------------------------------------------
3840
// Helper macros.
@@ -99,6 +101,17 @@ class CListenerManager: public wrapper<CListenerManager>
99101
};
100102

101103

104+
//-----------------------------------------------------------------------------
105+
// CConVarChangedListenerManager class.
106+
//-----------------------------------------------------------------------------
107+
class CConVarChangedListenerManager: public CListenerManager
108+
{
109+
public:
110+
virtual void Initialize();
111+
virtual void Finalize();
112+
};
113+
114+
102115
//-----------------------------------------------------------------------------
103116
// Functions
104117
//-----------------------------------------------------------------------------

0 commit comments

Comments
 (0)