Advertisement

Funny source code/documentation/comments?

Started by January 16, 2005 10:53 PM
75 comments, last by jonaakey 10 years, 5 months ago
Got to love Linus:
/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. *//* * Wirzenius wrote this portably, Torvalds fucked it up :-) */


I have similar garbage in my Operating System too.
At my last programming job, we were to write a sample screen for our client. We'll call it the "new project." The vice president of the company was going to whip up a new screen in Visual Basic quick for a demo.

Of course, he wrote up generic error handling that would popup a message box on the screen "Oh, we're fucked now!" So he would know if he ran into an error during his coding phase.

He never did... Until we showed it to the client which was going to buy "new project." You should have seen his face when the message box popped up on this lady's screen with that message, and she just sat there scratching her head.

Advertisement
I was making a pong clone and had a class named the Balls vector. It didn't look too good with:

Ball* ball = new Ball();ball->size = BIG;          // One of the big ballsif(Balls.size() < 2)       // Too little big balls  Balls.insert(ball);      // Insert the ball in there nicely...  Yes, just like that
Rob Loach [Website] [Projects] [Contact]
Well, here's one I recently used when I was porting Doug Lea's memory allocator to a different platform. I ended up rewriting it from scratch and only used the algorithm, not the code.

//This is my version of the large bin lookup.//My direct lookup (with branching) is faster than Lea's convoluted mess of an //algorithm.//And no one knows why he only uses even numbered bins either.//I don't care if he is a computer science professor, he should never be allowed//to touch a computer again.
After a week of work I determined that it wouldn't work anyway, since his algorithm sucks for parallel systems. His mutual exclusion is a complete hack.
______________________________"Man is born free, and everywhere he is in chains" - J.J. Rousseau
Straight out of the object that performs a loading pass on my game's resources:

// Leeloo Dallas :)
multi_pass = true;

Thread of old, arise from thy grave!

While looking through the Quake 2 source code years ago I saw this:


void R_Flash (void)

So I changed it to this:


void R_Flash (void) // AHH-AHH!!!

You have to be a certain age. ;)

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Advertisement


You have to be a certain age. ;)

I must be old enough then :D

if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight

I guess..


double d = 0.0d; // lols.. double d's.. 

:)

---

Cinder Interative - Indie Game Studio | MikeaDev.net - My Blog | Michael Adaixo - My Website.

A guy I used to work with would refer to objects as puppies, as in:
// these are good puppies!

Also came across code labeled:
//********************************************
// Here be magic. DO NOT TOUCH!!!
//********************************************

And

If ....
Else if....
Else
{
//if we get here it's too late and we're buggered.
}

Here are some funny comments from the source code driving one of those LED displays you see at train stations.

Blending colours


// The question is: Will it Blend?
extern inline unsigned short blendColours( unsigned short colour1, unsigned short colour2, unsigned char startPosition, unsigned char endPosition, unsigned char position, unsigned char blendDistance )
{
	return ((((colour1&0xF00)>>8)*(endPosition-position)/blendDistance + ((colour2&0xF00)>>8)*(position-startPosition)/blendDistance)<<8) | ((((colour1&0x0F0)>>4)*(endPosition-position)/blendDistance + ((colour2&0x0F0)>>4)*(position-startPosition)/blendDistance)<<4) | ((colour1&0x00F)*(endPosition-position)/blendDistance + (colour2&0x00F)*(position-startPosition)/blendDistance);
}


Writing to shift registers at high frequency


// output serial data
for( x = 0; x != 8; x++ )
{

	// NOTE: my god, I hope the shift registers can handle this without delay. It's torture I say, TORTURE
	// NOTE2: On second thought, they *were* a pain to solder. I guess it's only fair to punish them

	// output next 6 bits
	P3OUT = pixelArray[x][y][currentPWMCycle];

	// write them to shift registers
	P3OUT |= SHIFT_REGISTER_WRITE;
}
"I would try to find halo source code by bungie best fps engine ever created, u see why call of duty loses speed due to its detail." -- GettingNifty

This topic is closed to new replies.

Advertisement