Game Development Community

Programmer Tips: Debugging

by Darrel Cusey · in Torque Game Engine · 12/24/2005 (9:38 am) · 8 replies

Like many people on this list, I struggled through getting the examples to run. Here's a couple tips that I found useful that weren't immediately obvious to me (although they probably should have been):

1. Once your scripts successfully compile (even if they have errors), the TGE included with the various chapter kits will _NOT_ compile them again from the .cs files -- it will keep using the .dso files instead and blistfully ignore any changes you've made to the .cs files.

Tip: Create a windows batch script that will delete all the *.cs.dso files from the root of your current game folder (i.e. c:\emaga5\) and run it before testing -- this will force the engine to re-compile. I'm thinking there's probably a command-line option that can be put in the shortcut to do the same thing, but I haven't found it yet.

2. The "missing files" that Ken wants you to type in _are_ included on the CD, it's just that the various installed kits don't copy them over. You can find all the scripts on the CD under "\RESOURCES\CHx\" (where x is the chapter number) in the same location they should be under your "C:\Emagax" folder.

Tip: After typing in each script, compare it with Ken's version on the CD to make sure you have everything right. If you have UltraEdit 10, the "Compare Files" function under the "File" menu has a "lite" file compare utility that worked well for me -- it found all my typos at least :)

#1
12/24/2005 (12:26 pm)
I pull this URL out a lot on IRC, seems appropriate here ...

www.0x68.com/shorts/debugging/

If you dont know how to use a debugger, then you really need to read that URL. Yes, it's VC++ specific, however the concepts it discusses are applicable to any debugger. Pretty much all debuggers work in a similar way and provide roughly the same features.

T.
#2
12/24/2005 (8:45 pm)
Hehehe, I'm not using a debugger at this point -- I'm just hacking away some scripts in UltraEdit following along step-by-step through 3DGPAi1.

3DGPAi1 does not ask the reader to use a compiler. Nowhere does it ask the reader to compile the scripts that we are modifying, that's because the version of TGE included with the book does the compile step for you (from CS files to CS.DSO files).

The problem that I'm pointing out is that IF a compiled version of the script already exists, then TGE.exe will NOT recompile for you (keep in mind we are just asked to edit .cs files, and then run tge.exe).

Because (1) we are not being asked to use a compiler (at least as far as Chapter 6) in 3DGPAi1, and because (2) I don't think a compiler exists besides Torque that will actually compile TorqueScript CS files into DSO files; then simply deleting the .cs.dso files is a far far simpler solution than solving both (1) and (2) above.

I know how to use a debugger (thanks, been coding for 26 years now), but even with that much experience I still ran into these issues.

Now, granted, I figured out what was going on pretty quick -- but there seems to be an awful lot of people in these forums who are relatively new to programming in general and are almost certainly going to run into these same issues because they are following along with the tutorials just like I was.

I'm simply trying to save people the frustration of making changes to their .CS files over and over again and not figuring out why everything keeps running the same :-)

Thanks.
#3
01/04/2006 (3:40 pm)
As for the batch command, I like to put this file into my \game\ directory and save it as run.bat or something

cls
echo Deleting Torque Compiled Binaries...
del /s *.cs.dso
engine.exe

The /s parameter specifies to delete all .cs.dso files from the subdirectories of the current root folder.
You need to change engine.exe to whatever your Torque launcher is named, (tge.exe, engine.exe, etc...)
You also might need to cd to the directory of the current Torque folder - (add this to your first line and adjust the directory to your proper location)

cd c:\torque\game\
#4
01/09/2006 (6:26 pm)
@Tyler

Just getting rid of the .cs.dso files leaves the .gui.dso files behind :-)

This is actually what I use:

cls
echo Doing a Make Clean
del /s *.dso

And if you just want to reset your preferences and config files, then this works well:

cls
echo Resettting Preferences and Config Files
del /s prefs.cs
del /s config.cs
del /s config.cs.dso
del /s prefs.cs.dso
#5
01/09/2006 (6:41 pm)
Strange... I've never had to delete dso files to see script changes.

Is there a set rule to when it "sticks" or not?
#6
01/09/2006 (9:05 pm)
Generally it will recompile the DSO if there is a change in the .cs that generated it, but it doesn't always notice small changes.
#7
01/10/2006 (7:45 am)
Is that because it detects changes in filesize or "last modified" date, or something like that?
#8
01/10/2006 (8:09 am)
I like Torsion IDE which has a delete DSO option in the drop down Project menu.