Plan for Tom Bampton
by Tom Bampton · 09/24/2004 (2:46 pm) · 4 comments
Well, BoomBall development is back in full swing. Matt and I are busy getting it done for IGC. BB is looking really cool ...
... but I'm not going to show you any screenies ;-) You'll have to wait til IGC!
Instead I'm going to rant about debugging.
Today I hit a really nasty snag. The other day I hacked up a certain HUD element (and nifty it is now), but I did it in a slightly kludgey way. The nice clean way was to hack castRay() support in for triggers, which Matt did last night. The theory was that all we'd need to do was change the LOS mask for the ray cast, and all would work as before.
It was a good theory. A theory that, in theory, there was no problems with. That was also a good theory.
Both turned out to be completely and utterly wrong.
I spent 2 or 3 hours earlier in the debugger trying out more theories, that were also in theory quite sound. The worst part is the ray cast worked for projectiles, but not for this certain HUD element. In amoungst all the intensive debugging I hit upon another (equally good sounding but in the end, wrong) theory that the type masks were screwed. So I knocked up a little test program that converted the type mask i was seeing in the debugger back into something i could actually read and figure out what the hell was going on. Another dead end. Unfortunately, I ran out of time and had to pass it on to Matt to look at. In his words: "it is me area of expertise." That is the nice part about working in a team, there's always someone else to bounce bugs off. Works both ways, of course.
When I look back on the days events now (its almost midnight and I have to be at work at 8:30am. oh the joys of being an indie with a part time job.) it's hardly surprising that this was such hell. Whilst getting the scoreboards in earlier, it went far too well. I grabbed Robert Brower's scoreboard resource, took a look in the script. Thought "hmm, thats not going to work, it will only support 1 counter," then I proceeded to hack it up to do multiple counters. Ran BB. It compiled, great. I stuck the counters into the .mis and they worked fine. It compiled worked first time. I didnt even run Rob's original code. If you've spoken to me for any length of time you will know about the deep loathing I have for code that works first time. It is usually indication that something very big, very bad and very hard to fix is going to happen very soon. Code just doesnt work first time unless it's "hello world," and even then I would expect typos.
I take pity on those who's only method of debugging is printf debugging. There are some issues, such as this trigger problem, that are either impossible or would take weeks to fix just by reading the code and sticking printfs in. Debuggers are worth the weight of the computer they run on in diamonds. They make the task of making code work so much quicker and easier. If you are a programmer and you dont know how to use a debugger, go find tutorials on debugging on the net. Read them, multiple times. Keep reading them til you understand them. Use their teachings in your work. Everybody hates debugging, but debuggers and good coding practices mean the debugging you have to do is greatly reduced. Sure, it takes time to learn. In fact, learning to debug well can take almost as long as learning to program well. If not, longer. But: It's worth every second of time spent.
For anyone who wants it, I uploaded my typemask tool here: www.burntwasp.com/typemask.exe ... it's a command line app, and I spent a grand total of 5 minutes working on it. It will convert all the arguments you give it to type masks. It's expected that you obtain the numbers from the debugger. The args are passed through strtoul() with a base of 0, so you can specify the args in any format that supports. Example:
D:\Development\BoomBall\Test>typemask 1024 0x420
1024 (0x00000400) = GameBaseObjectType|
1056 (0x00000420) = TriggerObjectType|GameBaseObjectType|
If anyone wants the source they can email me. It's a mess, but it is 100% cross platform. The only reason I'm not posting the source here is because it uses an enum i copy/pasted from TGE, and this is a public .plan. Some may say it's a pedantic interpretation of the license, but i dont care ;-)
... but I'm not going to show you any screenies ;-) You'll have to wait til IGC!
Instead I'm going to rant about debugging.
Today I hit a really nasty snag. The other day I hacked up a certain HUD element (and nifty it is now), but I did it in a slightly kludgey way. The nice clean way was to hack castRay() support in for triggers, which Matt did last night. The theory was that all we'd need to do was change the LOS mask for the ray cast, and all would work as before.
It was a good theory. A theory that, in theory, there was no problems with. That was also a good theory.
Both turned out to be completely and utterly wrong.
I spent 2 or 3 hours earlier in the debugger trying out more theories, that were also in theory quite sound. The worst part is the ray cast worked for projectiles, but not for this certain HUD element. In amoungst all the intensive debugging I hit upon another (equally good sounding but in the end, wrong) theory that the type masks were screwed. So I knocked up a little test program that converted the type mask i was seeing in the debugger back into something i could actually read and figure out what the hell was going on. Another dead end. Unfortunately, I ran out of time and had to pass it on to Matt to look at. In his words: "it is me area of expertise." That is the nice part about working in a team, there's always someone else to bounce bugs off. Works both ways, of course.
When I look back on the days events now (its almost midnight and I have to be at work at 8:30am. oh the joys of being an indie with a part time job.) it's hardly surprising that this was such hell. Whilst getting the scoreboards in earlier, it went far too well. I grabbed Robert Brower's scoreboard resource, took a look in the script. Thought "hmm, thats not going to work, it will only support 1 counter," then I proceeded to hack it up to do multiple counters. Ran BB. It compiled, great. I stuck the counters into the .mis and they worked fine. It compiled worked first time. I didnt even run Rob's original code. If you've spoken to me for any length of time you will know about the deep loathing I have for code that works first time. It is usually indication that something very big, very bad and very hard to fix is going to happen very soon. Code just doesnt work first time unless it's "hello world," and even then I would expect typos.
I take pity on those who's only method of debugging is printf debugging. There are some issues, such as this trigger problem, that are either impossible or would take weeks to fix just by reading the code and sticking printfs in. Debuggers are worth the weight of the computer they run on in diamonds. They make the task of making code work so much quicker and easier. If you are a programmer and you dont know how to use a debugger, go find tutorials on debugging on the net. Read them, multiple times. Keep reading them til you understand them. Use their teachings in your work. Everybody hates debugging, but debuggers and good coding practices mean the debugging you have to do is greatly reduced. Sure, it takes time to learn. In fact, learning to debug well can take almost as long as learning to program well. If not, longer. But: It's worth every second of time spent.
For anyone who wants it, I uploaded my typemask tool here: www.burntwasp.com/typemask.exe ... it's a command line app, and I spent a grand total of 5 minutes working on it. It will convert all the arguments you give it to type masks. It's expected that you obtain the numbers from the debugger. The args are passed through strtoul() with a base of 0, so you can specify the args in any format that supports. Example:
D:\Development\BoomBall\Test>typemask 1024 0x420
1024 (0x00000400) = GameBaseObjectType|
1056 (0x00000420) = TriggerObjectType|GameBaseObjectType|
If anyone wants the source they can email me. It's a mess, but it is 100% cross platform. The only reason I'm not posting the source here is because it uses an enum i copy/pasted from TGE, and this is a public .plan. Some may say it's a pedantic interpretation of the license, but i dont care ;-)
About the author
Recent Blogs
• A Game in 2750 Days• GID23 and NPC Editor
• Fun with Lua
• How NOT to make a game
• Thinking Outside the Box
#2
09/25/2004 (9:35 am)
Sounds like you're having some "fun" ;) Good luck with your projects
#3
09/25/2004 (4:47 pm)
Yeh, much fun was had by all. Matt's fixed the bug now though so its all good :)
#4
-Griff
08/13/2006 (8:00 pm)
Well, this plan is a little old, but I would just personally like to thank you for the typemask tool. I've been having some trouble figuring out why my typemasks aren't correct, and I've tracked it down thanks to this tool.-Griff
Torque 3D Owner Phil Carlisle