Welcome, Guest! Login | Register

Debugging your half-life 2 mod [Print this Article]
Posted by: ibutsu
Date posted: Dec 06 2004
User Rating: 3.7 out of 5.0
Number of views: 9654
Number of comments: 7
Description: I go through both methods for debugging your modification
Hello again! This time around I'm going to show you the two methods for debugging your dlls, the first method will run your mod from within the debugger and the second method will show you how to attach the debugger to a running copy of your mod.

Method 1

Okay, this method is a bit trickier to get set up.

First thing you have to do is go to your main steam directory and copy Steam.dll into your \Steam\SteamApps\<steam@account>\half-life 2\bin directory.

Next create a text file in \Steam\SteamApps\<steam@account>\half-life 2\ directory and name it SteamApp.cfg.
Now open it up and paste the following into it:

 CODE  

SteamAppId=220
SteamAppVersionId=0
SteamInstallPath="<drive/path>\Steam"
SteamAppUser="<steam@account>"


Make certain you do NOT put a trailing backspace after your steam directory.

For example, mine is:

 CODE  

SteamAppId=220
SteamAppVersionId=0
SteamInstallPath="E:\Steam"
SteamAppUser="ibutsu@gdnmail.net"


Now open up Visual Studio.NET and your mods solution/workspace, I have Visual Studio.NET 2002, but 2003 should not be too different.
Open up the project settings for the client and server dll and go down to the Debugging section.

Set the Command field to point to \Steam\SteamApps\<steam@account>\half-life 2\hl2.exe
Mine is set to: E:\Steam\SteamApps\ibutsu@gdnmail.net\half-life 2\hl2.exe

Set the Command Arguments field to -steam -sw -dev -allowdebug -game "<path to your mod>"
Mine is set to: -steam -sw -dev -allowdebug -game "f:\hl2modding\ninjamod"

Make sure Attach is set to No otherwise it will either hang or error.

Apply your project settings and you should be set to go!

Method 2

This method is easy to set up, but it's more of a hassle when you want to debug.

Open up your mod's solution/workspace in Visual Studio.NET and open the project settings dialog for both your client and server dlls and select the Debugging section.

Set the Command field to point to \Steam\SteamApps\<steam@account>\half-life 2\hl2.exe
Mine is set to: E:\Steam\SteamApps\ibutsu@gdnmail.net\half-life 2\hl2.exe

Now make sure Attach is set to Yes.

Apply your project settings.

Now when you want to debug, run your run_mod.bat for your mod, once your mod loads, start debugging in Visual Studio, instead of running your mod, it will debug the copy of your mod that is running!

Important:

When using the attach method (method 2), you must exit your mod and NOT stop the debugger, if you stop the debugger using the stop button in the IDE Visual Studio will lock some intermediate files that are used for debugging and you will have to restart visual studio before you'll be able to compile your project again.

Rate This Article
This article is currently rated: 3.7 out of 5.0 (3 Votes)

You have to register to rate this article.
User Comments Showing comments 1-7

Posted By: Zoc on Dec 08 2004 at 18:04:21
Nice Tutorial =]

Posted By: ibutsu on Dec 08 2004 at 18:44:18
Thanks :)

Posted By: DOOManiac on Dec 14 2004 at 18:11:50
If you notice your HL2 no longer loads after the most recent Steam Update, this is because of your copied Steam.dll being old. Delete it.

HL2 just hangs, so you need to either copy a new one every time Steam updates, or don't use Method 1.

Posted By: ibutsu on Dec 20 2004 at 10:42:08
they changed the way it works now, no need for a cfg/steam.dll in your half-life 2 directory, I haven't tested it yet though.

Posted By: locketine on Jul 27 2005 at 19:17:20
I just copied the commands in the run_mod.bat file into the command section of the debugger and did everything else like valve says to do and it works great so far. Haven't had to debug nething yet though, just use it for quick compiling/testing.

Posted By: Black Panther on Mar 28 2006 at 10:49:54
This article is pretty much 80% outdated as valve simplified the things required for debugging.

Better check this article: http://developer.valvesoftware.com/wiki/In...the_Source_CodeEdited by Black Panther on Mar 28 2006, 11:01:18

Posted By: blackshark on Aug 17 2007 at 11:21:59
Hi,
Whenever my Half life 2 autosaves it pops up a runtime error and I have to restart th whole thing.Is there anyway i can stop the autosave feature?


You must register to post a comment. If you have already registered, you must login.

Latest Articles
3rd person View in Multiplayer
Half-Life 2 | Coding | Client Side Tutorials
How to enable it in HL2DM

By: cct | Nov 13 2006

Making a Camera
Half-Life 2 | Level Design
This camera is good for when you join a map, it gives you a view of the map before you join a team

By: slackiller | Mar 04 2006

Making a camera , Part 2
Half-Life 2 | Level Design
these cameras are working monitors that turn on when a button is pushed.

By: slackiller | Mar 04 2006

Storing weapons on ladder
Half-Life 2 | Coding | Snippets
like Raven Sheild or BF2

By: British_Bomber | Dec 24 2005

Implementation of a string lookup table
Half-Life 2 | Coding | Snippets
A string lookup table is a set of functions that is used to convert strings to pre-defined values

By: deathz0rz | Nov 13 2005


Latest Comments
Spinning Corpses Simple Fix
Half-Life | Coding | Snippets
By: darkPhoenix | Sep 05 2008
 
Where do we go from here
General | News
By: MIFUNE | Jun 09 2008
 
The Input/Output system
Half-Life 2 | Level Design
By: nazitaco | Dec 23 2007
 
Where do we go from here
General | News
By: Rob_F | Nov 22 2007
 
Rescaling Half-Life
Half-Life | Coding | Shared Tutorials
By: christoph | Nov 12 2007
 
GameUI
Half-Life 2 | Coding | Client Side Tutorials
By: Evil_j | Oct 29 2007
 
3 State Zoom For Any Weapon
Half-Life 2 | Coding | Server Side Tutorials
By: Ennuified | Oct 18 2007
 
Storing weapons on ladder
Half-Life 2 | Coding | Snippets
By: cct | Sep 07 2007
 
CTF Gameplay Part 1
Half-Life | Coding | Shared Tutorials
By: DarkNight | Aug 28 2007
 
CTF Gameplay Part 1
Half-Life | Coding | Shared Tutorials
By: deedok | Aug 20 2007
 

Site Info
296 Approved Articless
5 Pending Articles
3940 Registered Members
0 People Online (15 guests)
About - Credits - Contact Us

Wavelength version: 3.0.0.9
Valid XHTML 1.0! Valid CSS!