Welcome, Guest! Login | Register

Debugging your half-life 2 mod [Print this Article]
Posted by: ibutsu
Date posted: Dec 07 2004
User Rating: 3.7 out of 5.0
Number of views: 16326
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 09 2004 at 00:04:21
Nice Tutorial =]

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

Posted By: DOOManiac on Dec 15 2004 at 00: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 16: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 28 2005 at 01: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 17: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, 18:01:18

Posted By: blackshark on Aug 17 2007 at 17: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 05 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
knock knock
General | News
By: MIFUNE | Dec 31 2017
 
knock knock
General | News
By: omega | Dec 22 2016
 
knock knock
General | News
By: MIFUNE | Oct 10 2015
 
New HL HUD Message System
Half-Life | Coding | Shared Tutorials
By: chbrules | Dec 31 2011
 
knock knock
General | News
By: Whistler | Nov 05 2011
 
Particle Engine tutorial part 4
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 18 2010
 
Particle Engine tutorial part 2
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
 
Particle Engine tutorial part 3
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
 
Game Movement Series #2: Analog Jumping and Floating
Half-Life 2 | Coding | Shared Tutorials
By: mars3554 | Oct 26 2009
 
Particle Engine tutorial part 5
Half-Life | Coding | Client Side Tutorials
By: Deadpool | Aug 02 2009
 

Site Info
297 Approved Articless
8 Pending Articles
3940 Registered Members
0 People Online (4 guests)
About - Credits - Contact Us

Wavelength version: 3.0.0.9
Valid XHTML 1.0! Valid CSS!