Game Development Community

"0xdeadbeef" - what's the story?

by Josef Jahn · in Torque Game Engine · 04/02/2003 (4:14 am) · 26 replies

I love the enthropy pool stuff in Torque, it makes Q* and U*-Engines look like bad hacks ;)
Anyway, can anyone tell me the story behind the "0xdeadbeef" constant? How did this constant end up with this value? ;)
Page «Previous 1 2
#1
04/02/2003 (4:49 am)
Rofl! that's funny, where is that... there are many comments of that kind in torque... very funny :)
I think it was a feature added to stimulate the coder to force a smile when things ain't just working. :P
#2
04/02/2003 (4:58 am)
Look into math/mathUtils.cc, game/audioEmitter.cc and others...
There's another constant in audio/vorbisStream.cc (if you have that) called 0xfeedface ;)

I was really fascinated when I found out that torque doesn't put up with pseudo-randomized numbers, but actually uses the lower 2 bits of the mouse movements for those.
#3
04/02/2003 (6:10 am)
I wonder if 0xBAADF00D is still in there?
#4
04/02/2003 (6:13 am)
and who said coders did not have a sense of humor ;)
#5
04/02/2003 (6:16 am)
*chuckles*
Now I know what constants to use at work next time ;)
You wouldn't believe what kinds of such stuff I find in otherwise dead-serious ATC-related program sourcecode. From "hello world" return-strings to "game over, insert new plane to continue"...
#6
04/02/2003 (7:16 am)
I've come across:

#ifdef WANT_STUPID_NON_WORKING_CODE

and

#define MAGIC_NUMBER 42

in commercial projects before. As well as some "colorful" variable names from frsutrated developers.
#7
04/02/2003 (7:47 am)
Here's something similar, and I swear I'm not making this up. This one really shows how enlightening comments can be...

www.playspoon.com/images/PanelMagic.png
#8
04/02/2003 (8:50 am)
If i recall correctly, there are some values that are "intert" when inserted into the code (i.e. the assembly opcodes reduce to something that is non harmful).

I think its usually a NOP (cd?) but maybe deadbeef is also a reasonably "safe" bunch of code bytes..

Either that or it generates an int 3 (stop the debugger) when executed. Cant actually remember of the top of my head.

Phil.
#9
04/02/2003 (10:43 am)
0xDEADBEEF = 3735928559L
#10
04/02/2003 (10:58 am)
Heheh, how about that function name and parameter... :P
(from "Bot.uc", an official UNREAL script...)
function YellAt(Pawn Moron)
{
   ...
}
;)
#11
04/02/2003 (2:58 pm)
I can't speak for the Dynamix/GG people, but using 0xdeadbeef as an initialization constant is usually done because it will jump out at you (and hit you over the head with a baseball bat) if you see it in the variable watch during a debug session.

It (or another hex-able word) is fairly often used in memory managers to indicate that the data wasn't initialized as expected. Similar to the way VC++, in debug builds, will pre-initialize everything to 0xcdcdcdcd (VC++'s constant is, as Phil mentioned, primarily there to cause an int 3 (debug exception) if the processor tries to execute it).
#12
04/02/2003 (4:06 pm)
there is tons of little funny comments throughout the half-life source, I found a site outlining them once, dont remember where that was...

Programmers should make it a point to put funny comments in their code. Its great to see that stuff, it always makes for a good chuckle.

--Grant
#13
04/02/2003 (5:26 pm)
Here a line of script from the game I am working on:

if (%dist < $AIDroids::BraveSirRobbinRadius)
             %runaway = true;
#14
04/02/2003 (5:47 pm)
Don't tempt me to write code with Monty Python references

if (%damage == $justAFleshWound)
{
     %msg = "You swing like a girl!";
}
#15
04/02/2003 (10:19 pm)
My favorite part of the Torque source:

/engine/game/net/netTest.cc

//#pragma message "MDF: Make sure this file gets taken out before we go gold"

*gives Mark Frohnmayer a gold star* ;-)
#16
04/03/2003 (4:51 am)
Hahah, yeah that last one is the best one. I hope they don't remove it from TGE :)
#17
04/03/2003 (2:11 pm)
Yeeehaw! A gold star :)
#18
04/03/2003 (4:38 pm)
Our company is working on a net app that builds 'data trees' that trace the lifespan of lots of livestock and display their entire life cycle visually. We use a mobile cellular automaton to wander through the compressed DB fields and create the tree. The CA's name is wally.

So all of our errors and debug information contained variables like WallyParent, WallyMom, WallyStepKid, WallyStepSon, WallyAges, WallyLibido, WallySperm, WallyGotLaid, WallyDead. And the error messages would say things like "Error: Wally got laid too many times!"

Now that we have better error handling in place no one sees that stuff but us, though.
#19
04/03/2003 (6:27 pm)
Searching through the engine for some explitives...

from winGL.cc
if ( LoadLibrary("Glide3X") != 0 ) 
   {
      // FIXME: 3Dfx needs to fix this shit
      return true;

from interiorRender.cc
AssertFatal(currRenderBufferPoint < 512 && currIndexPoint < 2048, "Aw, crap.");
That line appears about 12 times in interiorRender.cc

from interiorCollision.cc
// Test & clip all the edges
      S32 sideBase = ++polytope.sideCount << 1;
      AssertFatal(sideBase != 0, "Well, crap.");

from zipAggregate.cc
if (dirReadSuccess == true) {
      // Every thing went well, we're done, position the stream to the end of the
      //  CD...
      //
      io_pStream->setPosition(endCDPosition);
      return true;
   } else {
      // Oh, crap.
      io_pStream->setPosition(initialPosition);
      destroyZipDirectory();
      return false;
   }

from profiler.cc
FileStream fws;
      bool success = fws.open(mDumpFileName, FileStream::Write);
      AssertFatal(success, "Oh, fuck.");

Sounds like the developers got a little frustrated at times...
#20
04/03/2003 (7:54 pm)
Do a quick search for "hack" once and you'll find some pretty funny comments like:

// warning! hacking ahead

// This is soo hacky...

// This is a horrid hack, but it will have to do for now. (DMM, aided
// and abetted by MF.)

// evil hack to get around insane X windows #define-happy header files

// this is a nasty pointer math hack

// Is this Replicator on the Server?
if (isServerObject())
// Yes, so stop it from Ghosting. (Hack, Hack, Hack!)
fxStatic->touchNetFlags(Ghostable, false);
else
// No, so flag as ghost object. (Another damn Hack!)
fxStatic->touchNetFlags(IsGhost, true);

// DMM: Major hack here until we decide what do to about this problem.

if (skipFirstFog)
// HACK: This is the dumbest hack for 3Dfx yet:
// don't two-pass fog for the first frame

// skip first two-pass fogging (dumb 3Dfx hack)

// Added UNIX emacs key bindings - just a little hack here...

// Select detail levels on mounted items
// but... always draw the control object's mounted images
// in high detail (I can't believe I'm commenting this hack :)

// This is something of a hack, but since the 3space objects don't have a
// clear conception of texels/meter like the interiors do, we're sorta
// stuck. I can't even claim this is anything more scientific than eyeball
// work. DMM

// need to set a mask bit to make the ghost manager delete copies of this object
// hacky, but oh well.
Page «Previous 1 2