Installing and Debugging the Source Code: Difference between revisions
Jump to navigation
Jump to search
Note:It is on debug compile by default. In order to run the mod with a debug dll you must right click the mod in the Steam game browser, click Properties then Set Launch Options... and add -allowdebug to the end of anything that may already be there (separated by spaces). You can change to a release build (for distributing the mod) in the configuration manager.
Note:This will only work if you have installed and launched the Source SDK Base.
(Added back the debbuging info. Do not remove this!) |
mNo edit summary |
||
Line 31: | Line 31: | ||
===Debugging=== | ===Debugging=== | ||
* In the Solution Explorer window, right-click on the current project (the one in bold) and choose Properties. | ==== Setup debugging parameters ==== | ||
* In the Property Pages dialog that appears, choose the Debugging item on the left-hand side. | |||
* On the right-hand side, in the text control next to Command, enter C:\Steam\SteamApps\Username\source sdk base\hl2.exe (adjusting the folder names given here to reflect your own Steam installation). | {{note|This will only work if you have installed and launched the Source SDK Base.}} | ||
* Next to Command Arguments, enter -dev -sw -game "C:\Steam\SteamApps\SourceMods\MyMod" (where MyMod is the name of your mod you entered in the Create a Mod dialog). | * In the '''Solution Explorer window,''' right-click on the current project (the one in bold) and choose '''Properties'''. | ||
* Next to Working Directory, enter C:\Steam\SteamApps\Username\source sdk base (adjusting the folder names given here to reflect your own Steam installation). | * In the Property Pages dialog that appears, choose the Debugging item on the left-hand side. | ||
* Click the OK button. | * On the right-hand side, in the text control next to '''Command''', enter <code>C:\Steam\SteamApps\'''Username'''\source sdk base\hl2.exe</code> (adjusting the folder names given here to reflect your own Steam installation). | ||
* Next to '''Command Arguments''', enter <code>-dev -sw -game "C:\Steam\SteamApps\SourceMods\MyMod"</code> (where '''MyMod''' is the name of your mod you entered in the ''Create a Mod'' dialog). | |||
* Next to '''Working Directory''', enter <code>C:\Steam\SteamApps\'''Username'''\source sdk base</code> (adjusting the folder names given here to reflect your own Steam installation). | |||
* Click the '''OK''' button. | |||
* Important: after an SDK update, you must make sure to run whatever game you're editing through Steam once (only one time is necessary) before running in the debugger. If you don't, you may get Steam errors when running through the debugger. | ==== Run in the debugger ==== | ||
* Right-click on the same project you were editing the properties for, and choose Debug->Start New Instance. | |||
* If you get a warning that hl2.exe has no debugging information, ignore it. | * ''Important: after an SDK update, you must make sure to run whatever game you're editing'' '''through Steam''' ''once (only one time is necessary) before running in the debugger. If you don't, you may get Steam errors when running through the debugger.'' | ||
* It should now launch Half-Life 2 and run your code. You can make modifications to the code now, rebuild, and rerun the game with your changes! | * Right-click on the same project you were editing the properties for, and choose Debug->Start New Instance. | ||
* If you get a warning that <code>hl2.exe</code> has no debugging information, ignore it. | |||
* It should now launch Half-Life 2 and run your code. You can make modifications to the code now, rebuild, and rerun the game with your changes! | |||
Revision as of 19:46, 3 June 2008
Overview
The general steps to installing and debugging the source code are:
- Run the Create a Mod tool in the SDK to install the source code.
- Use Microsoft Visual Studio .NET 2003 to compile the source code.
- Setup debugging parameters.
- Run in the debugger.
Step By Step
Run the Create a Mod wizard
- Run the Source SDK from Steam and choose the Create a Mod link.
- You can normally choose any type of mod here, but for the purposes of this tutorial, choose the Modify Half-Life 2 Single Player option and click Next.
- In the top edit control of the next dialog, enter a directory where you would like to create a mod. This tutorial will assume you entered C:\MyMod.
- In the bottom edit control, enter any name for your mod. This will become a subdirectory under your SteamInstallPath\SteamApps\SourceMods folder. This example will assume you entered MyMod here.
- Click the Next button and the source code will be installed on your hard drive.
- Wait for the mod wizard to finish.
Compile the Source Code
Compiling under VS2003
Compiling under VS2005
Compiling under VS2008

Debugging
Setup debugging parameters

- In the Solution Explorer window, right-click on the current project (the one in bold) and choose Properties.
- In the Property Pages dialog that appears, choose the Debugging item on the left-hand side.
- On the right-hand side, in the text control next to Command, enter
C:\Steam\SteamApps\Username\source sdk base\hl2.exe
(adjusting the folder names given here to reflect your own Steam installation). - Next to Command Arguments, enter
-dev -sw -game "C:\Steam\SteamApps\SourceMods\MyMod"
(where MyMod is the name of your mod you entered in the Create a Mod dialog). - Next to Working Directory, enter
C:\Steam\SteamApps\Username\source sdk base
(adjusting the folder names given here to reflect your own Steam installation). - Click the OK button.
Run in the debugger
- Important: after an SDK update, you must make sure to run whatever game you're editing through Steam once (only one time is necessary) before running in the debugger. If you don't, you may get Steam errors when running through the debugger.
- Right-click on the same project you were editing the properties for, and choose Debug->Start New Instance.
- If you get a warning that
hl2.exe
has no debugging information, ignore it. - It should now launch Half-Life 2 and run your code. You can make modifications to the code now, rebuild, and rerun the game with your changes!
Links
A good next step after mastering this document is to look at the Your First Entity document, in which you will make changes to some of the source code.
If you plan to integrate code updates from Valve, and if you want code backups and revision history, take a look at the Using Source Control with the Source SDK document. Template:Otherlang:en Template:Otherlang:en:jp