Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds Squirrel debugger
This is not the one that is used in Valve games, that is an old, very limited, Eclipse only debugger. This one is as extensive as possible, uses the Debug Adapter Protocol by Microsoft, a new debugger protocol standard that is already implemented by a number of editors.
Port numbers 1212 and 1213 are completely arbitrary, they can be changed.
vscript_debugger_portvariable is used to attach the debugger as soon as possible (but after classes are registered) for it to enable debug information for scripts loaded on map load. This only works for client though, script_debug command can't be executed while a server doesn't exist.sqdbg_definitions.nutfile is executed when the debugger attaches, this file is used to let the debugger know of the class names and how to display them in the client.https://gist.github.com/samisalreadytaken/0e4238f501bcff21649cd2c99ae0ab2c
Ideally this would be distributed with game files, it would be too cumbersome to ask users to manually download/write this every time. It's not embedded in the binaries because it should be possible to adjust things manually.
L4D2 branch has the concommands
script_connect_debuggerandscript_disconnect_debugger. They could replace thescript_debugcommand to be able to disconnect the debugger on will.Steps to test it on VS Code:
Download VS Code: https://code.visualstudio.com/download
Download and install the debugger extension: https://github.com/samisalreadytaken/sqdbg-vs/releases/download/0.1.0/sqdbg-vs-0.1.0.vsix
Install a Squirrel language extension from its marketplace. The one by "marcinbar" seems to work well enough.
Attach the debugger in game with
script_debugorscript_debug_clientLoad a squirrel script in the editor, press F5, enter the connection port (1212 for server, 1213 for client)
You may now place breakpoints and use the Debug Console to execute scripts while the game is running.
This video briefly shows installation of the extension, placing line and function breakpoints, and debugging both server and client at the same time with 'compound' configurations (compounds only work for opening a folder in vscode and creating launch.json)
https://www.youtube.com/watch?v=qIxujbfh_0c
Even though VSCode is a terribly slow editor, it has (not all, but) most debugging features implemented. Other (present and future) DAP compatible editors can be used as well.
PR Checklist
developbranch OR targets another branch with a specific goal in mind