mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-06-07 19:32:09 +03:00
Add script_connect_debugger_on_mapspawn cvar
This commit is contained in:
parent
cf4014a97c
commit
2b77baefbe
@ -29,7 +29,7 @@ extern IScriptManager *scriptmanager;
|
|||||||
extern ScriptClassDesc_t * GetScriptDesc( CBaseEntity * );
|
extern ScriptClassDesc_t * GetScriptDesc( CBaseEntity * );
|
||||||
|
|
||||||
#ifdef MAPBASE_VSCRIPT
|
#ifdef MAPBASE_VSCRIPT
|
||||||
extern int vscript_debugger_port;
|
ConVar script_connect_debugger_on_mapspawn_client( "script_connect_debugger_on_mapspawn_client", "0" );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// #define VMPROFILE 1
|
// #define VMPROFILE 1
|
||||||
@ -687,10 +687,13 @@ bool VScriptClientInit()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MAPBASE_VSCRIPT
|
#ifdef MAPBASE_VSCRIPT
|
||||||
if ( vscript_debugger_port )
|
if ( script_connect_debugger_on_mapspawn_client.GetInt() == 2 )
|
||||||
|
{
|
||||||
|
g_pScriptVM->ConnectDebugger( vscript_debugger_port, 10.0f );
|
||||||
|
}
|
||||||
|
else if ( script_connect_debugger_on_mapspawn_client.GetInt() != 0 )
|
||||||
{
|
{
|
||||||
g_pScriptVM->ConnectDebugger( vscript_debugger_port );
|
g_pScriptVM->ConnectDebugger( vscript_debugger_port );
|
||||||
vscript_debugger_port = 0;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
extern ScriptClassDesc_t * GetScriptDesc( CBaseEntity * );
|
extern ScriptClassDesc_t * GetScriptDesc( CBaseEntity * );
|
||||||
|
|
||||||
#ifdef MAPBASE_VSCRIPT
|
#ifdef MAPBASE_VSCRIPT
|
||||||
extern int vscript_debugger_port;
|
ConVar script_connect_debugger_on_mapspawn( "script_connect_debugger_on_mapspawn", "0" );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// #define VMPROFILE 1
|
// #define VMPROFILE 1
|
||||||
@ -668,10 +668,13 @@ bool VScriptServerInit()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MAPBASE_VSCRIPT
|
#ifdef MAPBASE_VSCRIPT
|
||||||
if ( vscript_debugger_port )
|
if ( script_connect_debugger_on_mapspawn.GetInt() == 2 )
|
||||||
|
{
|
||||||
|
g_pScriptVM->ConnectDebugger( vscript_debugger_port, 10.0f );
|
||||||
|
}
|
||||||
|
else if ( script_connect_debugger_on_mapspawn.GetInt() != 0 )
|
||||||
{
|
{
|
||||||
g_pScriptVM->ConnectDebugger( vscript_debugger_port );
|
g_pScriptVM->ConnectDebugger( vscript_debugger_port );
|
||||||
vscript_debugger_port = 0;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -37,7 +37,6 @@ extern ScriptClassDesc_t * GetScriptDesc( CBaseEntity * );
|
|||||||
#ifdef MAPBASE_VSCRIPT
|
#ifdef MAPBASE_VSCRIPT
|
||||||
// This is to ensure a dependency exists between the vscript library and the game DLLs
|
// This is to ensure a dependency exists between the vscript library and the game DLLs
|
||||||
extern int vscript_token;
|
extern int vscript_token;
|
||||||
extern int vscript_debugger_port;
|
|
||||||
int vscript_token_hack = vscript_token;
|
int vscript_token_hack = vscript_token;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -391,27 +390,14 @@ CON_COMMAND_F( script_debug, "Connect the vscript VM to the script debugger", FC
|
|||||||
if ( !IsCommandIssuedByServerAdmin() )
|
if ( !IsCommandIssuedByServerAdmin() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef MAPBASE_VSCRIPT
|
|
||||||
#ifdef GAME_DLL
|
|
||||||
int port = 1212;
|
|
||||||
#else
|
|
||||||
int port = 1213;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ( !g_pScriptVM )
|
if ( !g_pScriptVM )
|
||||||
{
|
{
|
||||||
#ifdef MAPBASE_VSCRIPT
|
|
||||||
vscript_debugger_port = port;
|
|
||||||
CGMsg( 0, CON_GROUP_VSCRIPT, "VScript VM is not running, waiting for it to attach the debugger to port %d...\n", port );
|
|
||||||
#else
|
|
||||||
CGWarning( 0, CON_GROUP_VSCRIPT, "Scripting disabled or no server running\n" );
|
CGWarning( 0, CON_GROUP_VSCRIPT, "Scripting disabled or no server running\n" );
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MAPBASE_VSCRIPT
|
#ifdef MAPBASE_VSCRIPT
|
||||||
g_pScriptVM->ConnectDebugger( port );
|
g_pScriptVM->ConnectDebugger( vscript_debugger_port );
|
||||||
#else
|
#else
|
||||||
g_pScriptVM->ConnectDebugger();
|
g_pScriptVM->ConnectDebugger();
|
||||||
#endif
|
#endif
|
||||||
|
@ -43,6 +43,12 @@ class CBaseEntityScriptInstanceHelper : public IScriptInstanceHelper
|
|||||||
extern CBaseEntityScriptInstanceHelper g_BaseEntityScriptInstanceHelper;
|
extern CBaseEntityScriptInstanceHelper g_BaseEntityScriptInstanceHelper;
|
||||||
|
|
||||||
#ifdef MAPBASE_VSCRIPT
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
#ifdef GAME_DLL
|
||||||
|
const int vscript_debugger_port = 1212;
|
||||||
|
#else
|
||||||
|
const int vscript_debugger_port = 1213;
|
||||||
|
#endif
|
||||||
|
|
||||||
void RegisterSharedScriptConstants();
|
void RegisterSharedScriptConstants();
|
||||||
void RegisterSharedScriptFunctions();
|
void RegisterSharedScriptFunctions();
|
||||||
|
|
||||||
|
@ -839,7 +839,7 @@ public:
|
|||||||
virtual void Shutdown() = 0;
|
virtual void Shutdown() = 0;
|
||||||
|
|
||||||
#ifdef MAPBASE_VSCRIPT
|
#ifdef MAPBASE_VSCRIPT
|
||||||
virtual bool ConnectDebugger( int port = 0 ) = 0;
|
virtual bool ConnectDebugger( int port = 0, float timeout = 0.0f ) = 0;
|
||||||
#else
|
#else
|
||||||
virtual bool ConnectDebugger() = 0;
|
virtual bool ConnectDebugger() = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
IScriptVM* makeSquirrelVM();
|
IScriptVM* makeSquirrelVM();
|
||||||
|
|
||||||
int vscript_token = 0;
|
int vscript_token = 0;
|
||||||
int vscript_debugger_port = 0;
|
|
||||||
|
|
||||||
class CScriptManager : public CTier1AppSystem<IScriptManager>
|
class CScriptManager : public CTier1AppSystem<IScriptManager>
|
||||||
{
|
{
|
||||||
|
@ -141,7 +141,7 @@ public:
|
|||||||
virtual bool Init() override;
|
virtual bool Init() override;
|
||||||
virtual void Shutdown() override;
|
virtual void Shutdown() override;
|
||||||
|
|
||||||
virtual bool ConnectDebugger( int port = 0 ) override;
|
virtual bool ConnectDebugger( int port = 0, float timeout = 0.0f ) override;
|
||||||
virtual void DisconnectDebugger() override;
|
virtual void DisconnectDebugger() override;
|
||||||
|
|
||||||
virtual ScriptLanguage_t GetLanguage() override;
|
virtual ScriptLanguage_t GetLanguage() override;
|
||||||
@ -2077,12 +2077,27 @@ void SquirrelVM::Shutdown()
|
|||||||
|
|
||||||
bool VScriptRunScript( const char *pszScriptName, HSCRIPT hScope, bool bWarnMissing );
|
bool VScriptRunScript( const char *pszScriptName, HSCRIPT hScope, bool bWarnMissing );
|
||||||
|
|
||||||
bool SquirrelVM::ConnectDebugger( int port )
|
bool SquirrelVM::ConnectDebugger( int port, float timeout )
|
||||||
{
|
{
|
||||||
if ( !debugger_ )
|
if ( !debugger_ )
|
||||||
{
|
{
|
||||||
debugger_ = sqdbg_attach_debugger( vm_ );
|
debugger_ = sqdbg_attach_debugger( vm_ );
|
||||||
sqdbg_listen_socket( debugger_, port );
|
|
||||||
|
if ( sqdbg_listen_socket( debugger_, port ) == 0 && timeout )
|
||||||
|
{
|
||||||
|
float startTime = Plat_FloatTime();
|
||||||
|
|
||||||
|
while ( !sqdbg_is_client_connected( debugger_ ) )
|
||||||
|
{
|
||||||
|
float time = Plat_FloatTime();
|
||||||
|
if ( time - startTime > timeout )
|
||||||
|
break;
|
||||||
|
|
||||||
|
ThreadSleep( 50 );
|
||||||
|
|
||||||
|
sqdbg_frame( debugger_ );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user