Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions sp/src/game/client/vscript_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern IScriptManager *scriptmanager;
extern ScriptClassDesc_t * GetScriptDesc( CBaseEntity * );

#ifdef MAPBASE_VSCRIPT
extern int vscript_debugger_port;
ConVar script_connect_debugger_on_mapspawn_client( "script_connect_debugger_on_mapspawn_client", "0" );
#endif

// #define VMPROFILE 1
Expand Down Expand Up @@ -687,10 +687,13 @@ bool VScriptClientInit()
#endif

#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 );
vscript_debugger_port = 0;
}
#endif

Expand Down
9 changes: 6 additions & 3 deletions sp/src/game/server/vscript_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
extern ScriptClassDesc_t * GetScriptDesc( CBaseEntity * );

#ifdef MAPBASE_VSCRIPT
extern int vscript_debugger_port;
ConVar script_connect_debugger_on_mapspawn( "script_connect_debugger_on_mapspawn", "0" );
#endif

// #define VMPROFILE 1
Expand Down Expand Up @@ -668,10 +668,13 @@ bool VScriptServerInit()
#endif

#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 );
vscript_debugger_port = 0;
}
#endif

Expand Down
16 changes: 1 addition & 15 deletions sp/src/game/shared/vscript_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ extern ScriptClassDesc_t * GetScriptDesc( CBaseEntity * );
#ifdef MAPBASE_VSCRIPT
// This is to ensure a dependency exists between the vscript library and the game DLLs
extern int vscript_token;
extern int vscript_debugger_port;
int vscript_token_hack = vscript_token;
#endif

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

#ifdef MAPBASE_VSCRIPT
#ifdef GAME_DLL
int port = 1212;
#else
int port = 1213;
#endif
#endif

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" );
#endif
return;
}

#ifdef MAPBASE_VSCRIPT
g_pScriptVM->ConnectDebugger( port );
g_pScriptVM->ConnectDebugger( vscript_debugger_port );
#else
g_pScriptVM->ConnectDebugger();
#endif
Expand Down
6 changes: 6 additions & 0 deletions sp/src/game/shared/vscript_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class CBaseEntityScriptInstanceHelper : public IScriptInstanceHelper
extern CBaseEntityScriptInstanceHelper g_BaseEntityScriptInstanceHelper;

#ifdef MAPBASE_VSCRIPT
#ifdef GAME_DLL
const int vscript_debugger_port = 1212;
#else
const int vscript_debugger_port = 1213;
#endif

void RegisterSharedScriptConstants();
void RegisterSharedScriptFunctions();

Expand Down
2 changes: 1 addition & 1 deletion sp/src/public/vscript/ivscript.h
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ class IScriptVM
virtual void Shutdown() = 0;

#ifdef MAPBASE_VSCRIPT
virtual bool ConnectDebugger( int port = 0 ) = 0;
virtual bool ConnectDebugger( int port = 0, float timeout = 0.0f ) = 0;
#else
virtual bool ConnectDebugger() = 0;
#endif
Expand Down
19 changes: 19 additions & 0 deletions sp/src/vscript/sqdbg/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) samisalreadytaken

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 6 additions & 1 deletion sp/src/vscript/sqdbg/include/sqdbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,14 @@ SQDBG_API int sqdbg_listen_socket( HSQDEBUGSERVER dbg, unsigned short port );
SQDBG_API void sqdbg_frame( HSQDEBUGSERVER dbg );

// Copies the script to be able to source it to debugger clients
SQDBG_API void sqdbg_on_script_compile( HSQDEBUGSERVER dbg, const SQChar *script, SQInteger size,
SQDBG_API void sqdbg_on_script_compile( HSQDEBUGSERVER dbg,
const SQChar *script, SQInteger scriptlen,
const SQChar *sourcename, SQInteger sourcenamelen );

// Check if a client is connected to the debugger
// Returns 0 if there is no client connected
SQDBG_API int sqdbg_is_client_connected( HSQDEBUGSERVER dbg );

#ifdef __cplusplus
}
#endif
Expand Down
Loading