Skip to content

Commit 405ba1d

Browse files
Uncomment debug code
1 parent 35eeef2 commit 405ba1d

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

sp/src/game/shared/mapbase/vscript_singletons.cpp

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,11 @@ END_SCRIPTDESC();
366366
//=============================================================================
367367
// Game Event Listener
368368
// Based on Source 2 API
369+
//
370+
// NOTE: In Source 2 vscript (Lua) event listener contexts are tables that are
371+
// passed to the callback function as the call environment.
372+
// In mapbase implementation these are string identifiers because unlike Lua,
373+
// Squirrel has closure methods such as 'bindenv' which can bind functions to specified environments.
369374
//=============================================================================
370375

371376
// Define to use the older code that loads all events manually independent from the game event manager.
@@ -375,7 +380,13 @@ END_SCRIPTDESC();
375380
class CScriptGameEventListener : public IGameEventListener2, public CAutoGameSystem
376381
{
377382
public:
378-
CScriptGameEventListener() : m_bActive(false) /*, m_nEventTick(0)*/ {}
383+
CScriptGameEventListener() : m_bActive(false)
384+
{
385+
#ifdef _DEBUG
386+
m_nEventTick = 0;
387+
#endif
388+
}
389+
379390
~CScriptGameEventListener()
380391
{
381392
StopListeningForEvent();
@@ -397,7 +408,9 @@ class CScriptGameEventListener : public IGameEventListener2, public CAutoGameSys
397408
HSCRIPT m_hCallback;
398409
unsigned int m_iContextHash;
399410
bool m_bActive;
400-
//int m_nEventTick;
411+
#ifdef _DEBUG
412+
int m_nEventTick;
413+
#endif
401414

402415
static StringHashFunctor Hash;
403416
static inline unsigned int HashContext( const char* c ) { return c ? Hash(c) : 0; }
@@ -592,7 +605,9 @@ void CScriptGameEventListener::LevelShutdownPreEntity()
592605

593606
void CScriptGameEventListener::FireGameEvent( IGameEvent *event )
594607
{
595-
//m_nEventTick = gpGlobals->tickcount;
608+
#ifdef _DEBUG
609+
m_nEventTick = gpGlobals->tickcount;
610+
#endif
596611
ScriptVariant_t hTable;
597612
g_pScriptVM->CreateTable( hTable );
598613
WriteEventData( event, hTable );
@@ -722,13 +737,15 @@ void CScriptGameEventListener::StopListeningForEvent()
722737
if ( gameeventmanager )
723738
gameeventmanager->RemoveListener( this );
724739

740+
#ifdef _DEBUG
725741
// Event listeners are iterated forwards in the game event manager,
726742
// removing while iterating will cause it to skip one listener.
727743
// This could be prevented by writing a custom game event manager.
728-
//if ( m_nEventTick == gpGlobals->tickcount )
729-
//{
730-
// Warning("CScriptGameEventListener stopped in the same frame it was fired. This will break other event listeners!\n");
731-
//}
744+
if ( m_nEventTick == gpGlobals->tickcount )
745+
{
746+
Warning("CScriptGameEventListener stopped in the same frame it was fired. This will break other event listeners!\n");
747+
}
748+
#endif
732749
}
733750

734751
//-----------------------------------------------------------------------------
@@ -2405,9 +2422,7 @@ class CScriptConvarAccessor : public CAutoGameSystem
24052422
inline bool IsOverridable( unsigned int hash )
24062423
{
24072424
int idx = g_ConCommandsOverridable.Find( hash );
2408-
if ( idx == g_ConCommandsOverridable.InvalidIndex() )
2409-
return false;
2410-
return true;
2425+
return ( idx != g_ConCommandsOverridable.InvalidIndex() );
24112426
}
24122427

24132428
inline void AddBlockedConVar( const char *name )
@@ -2418,9 +2433,7 @@ class CScriptConvarAccessor : public CAutoGameSystem
24182433
inline bool IsBlockedConvar( const char *name )
24192434
{
24202435
int idx = g_ConVarsBlocked.Find( Hash(name) );
2421-
if ( idx == g_ConVarsBlocked.InvalidIndex() )
2422-
return false;
2423-
return true;
2436+
return ( idx != g_ConVarsBlocked.InvalidIndex() );
24242437
}
24252438

24262439
public:

0 commit comments

Comments
 (0)