Skip to content

Commit c573d95

Browse files
Add script_connect_debugger_on_mapspawn cvar
1 parent ff704e0 commit c573d95

File tree

5 files changed

+11
-22
lines changed

5 files changed

+11
-22
lines changed

sp/src/game/client/vscript_client.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern IScriptManager *scriptmanager;
2929
extern ScriptClassDesc_t * GetScriptDesc( CBaseEntity * );
3030

3131
#ifdef MAPBASE_VSCRIPT
32-
extern int vscript_debugger_port;
32+
ConVar script_connect_debugger_on_mapspawn_client( "script_connect_debugger_on_mapspawn_client", "0" );
3333
#endif
3434

3535
// #define VMPROFILE 1
@@ -687,10 +687,9 @@ bool VScriptClientInit()
687687
#endif
688688

689689
#ifdef MAPBASE_VSCRIPT
690-
if ( vscript_debugger_port )
690+
if ( script_connect_debugger_on_mapspawn_client.GetBool() )
691691
{
692692
g_pScriptVM->ConnectDebugger( vscript_debugger_port );
693-
vscript_debugger_port = 0;
694693
}
695694
#endif
696695

sp/src/game/server/vscript_server.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
extern ScriptClassDesc_t * GetScriptDesc( CBaseEntity * );
2424

2525
#ifdef MAPBASE_VSCRIPT
26-
extern int vscript_debugger_port;
26+
ConVar script_connect_debugger_on_mapspawn( "script_connect_debugger_on_mapspawn", "0" );
2727
#endif
2828

2929
// #define VMPROFILE 1
@@ -668,10 +668,9 @@ bool VScriptServerInit()
668668
#endif
669669

670670
#ifdef MAPBASE_VSCRIPT
671-
if ( vscript_debugger_port )
671+
if ( script_connect_debugger_on_mapspawn.GetBool() )
672672
{
673673
g_pScriptVM->ConnectDebugger( vscript_debugger_port );
674-
vscript_debugger_port = 0;
675674
}
676675
#endif
677676

sp/src/game/shared/vscript_shared.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ extern ScriptClassDesc_t * GetScriptDesc( CBaseEntity * );
3737
#ifdef MAPBASE_VSCRIPT
3838
// This is to ensure a dependency exists between the vscript library and the game DLLs
3939
extern int vscript_token;
40-
extern int vscript_debugger_port;
4140
int vscript_token_hack = vscript_token;
4241
#endif
4342

@@ -391,27 +390,14 @@ CON_COMMAND_F( script_debug, "Connect the vscript VM to the script debugger", FC
391390
if ( !IsCommandIssuedByServerAdmin() )
392391
return;
393392

394-
#ifdef MAPBASE_VSCRIPT
395-
#ifdef GAME_DLL
396-
int port = 1212;
397-
#else
398-
int port = 1213;
399-
#endif
400-
#endif
401-
402393
if ( !g_pScriptVM )
403394
{
404-
#ifdef MAPBASE_VSCRIPT
405-
vscript_debugger_port = port;
406-
CGMsg( 0, CON_GROUP_VSCRIPT, "VScript VM is not running, waiting for it to attach the debugger to port %d...\n", port );
407-
#else
408395
CGWarning( 0, CON_GROUP_VSCRIPT, "Scripting disabled or no server running\n" );
409-
#endif
410396
return;
411397
}
412398

413399
#ifdef MAPBASE_VSCRIPT
414-
g_pScriptVM->ConnectDebugger( port );
400+
g_pScriptVM->ConnectDebugger( vscript_debugger_port );
415401
#else
416402
g_pScriptVM->ConnectDebugger();
417403
#endif

sp/src/game/shared/vscript_shared.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ class CBaseEntityScriptInstanceHelper : public IScriptInstanceHelper
4343
extern CBaseEntityScriptInstanceHelper g_BaseEntityScriptInstanceHelper;
4444

4545
#ifdef MAPBASE_VSCRIPT
46+
#ifdef GAME_DLL
47+
const int vscript_debugger_port = 1212;
48+
#else
49+
const int vscript_debugger_port = 1213;
50+
#endif
51+
4652
void RegisterSharedScriptConstants();
4753
void RegisterSharedScriptFunctions();
4854

sp/src/vscript/vscript.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
IScriptVM* makeSquirrelVM();
1818

1919
int vscript_token = 0;
20-
int vscript_debugger_port = 0;
2120

2221
class CScriptManager : public CTier1AppSystem<IScriptManager>
2322
{

0 commit comments

Comments
 (0)