Source Code Humor

omlette

Newbie
Joined
Jul 6, 2003
Messages
345
Reaction score
0
Nice to see that Valve is as crazy as their code. :D

Anyone find anything funny while looking through the source code? If so, please try and post a filename along with the excerpt.


From npc_Combine.cpp

Code:
// ---------------------------------------------------------------------
// Are any of my squad members near the intended grenade impact area?
// ---------------------------------------------------------------------
if ( m_pSquad )
{
if (m_pSquad->SquadMemberInRange( vecTarget, COMBINE_MIN_GRENADE_CLEAR_DIST ))
{
// crap, I might blow my own guy up. Don't throw a grenade and don't check again for a while.
m_flNextGrenadeCheck = gpGlobals->curtime + 1; // one full second.

And,

Code:
// Make sure not trying to kick through a window or something.

And,

Code:
// A turret that I've kicked recently is still standing 5 seconds later. 
if ( sourceEnt == GetEnemy() )
{
// It's still my enemy. Time to grenade it.

From npc_fastzombie.cpp,

Code:
// Death waits for no man. Or zombie. Or something.
return SCHED_ZOMBIE_RELEASECRAB;

And,


Code:
// Just lost track of our enemy. 
// Wander around a bit so we don't look like a dingus.
return SCHED_ZOMBIE_WANDER_MEDIUM;

And,

Code:
// Drumroll please!
// The final check! Is the path from my position to halfway between me
// and the player clear?

And,

Code:
// Shut up my screaming sounds.
CPASAttenuationFilter filter( this );
EmitSound( filter, entindex(), "NPC_FastZombie.NoSound" );

Finally, from npc_alyx.cpp:
Code:
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: Alyx, the female sidekick and love interest that's taking the world by storm!
//
// Try the new Alyx Brite toothpaste!
// Alyx lederhosen!
//
// FIXME: need a better comment block
//
//=============================================================================//
 
Code:
// Just lost track of our enemy. 
// Wander around a bit so we don't look like a dingus.

Rofl, I lurve VALVe :D

-Alix
 
hahaahah! nice find! I'll have a look see and post up anything i find.

valve is crazy...
 
Code:
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: Dr. Kleiner, a suave ladies man leading the fight against the evil 
//			combine while constantly having to help his idiot assistant Gordon
//
//=============================================================================//

Code:
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: Dr. Eli Vance, earths last great hope, single-handedly fighting
//			off both an evil alien invasion, as well as trying to stop 
//			that idiot lab assistant from putting the moves on his daughter.
//=============================================================================//
 
hahah.

i so need to finish downloading the sdk.
 
omlette said:
Nice to see that Valve is as crazy as their code. :D

Anyone find anything funny while looking through the source code? If so, please try and post a filename along with the excerpt.


From npc_Combine.cpp

Code:
// ---------------------------------------------------------------------
// Are any of my squad members near the intended grenade impact area?
// ---------------------------------------------------------------------
if ( m_pSquad )
{
if (m_pSquad->SquadMemberInRange( vecTarget, COMBINE_MIN_GRENADE_CLEAR_DIST ))
{
// crap, I might blow my own guy up. Don't throw a grenade and don't check again for a while.
m_flNextGrenadeCheck = gpGlobals->curtime + 1; // one full second.

And,

Code:
// Make sure not trying to kick through a window or something.

And,

Code:
// A turret that I've kicked recently is still standing 5 seconds later. 
if ( sourceEnt == GetEnemy() )
{
// It's still my enemy. Time to grenade it.

From npc_fastzombie.cpp,

Code:
// Death waits for no man. Or zombie. Or something.
return SCHED_ZOMBIE_RELEASECRAB;

And,


Code:
// Just lost track of our enemy. 
// Wander around a bit so we don't look like a dingus.
return SCHED_ZOMBIE_WANDER_MEDIUM;

And,

Code:
// Drumroll please!
// The final check! Is the path from my position to halfway between me
// and the player clear?

And,

Code:
// Shut up my screaming sounds.
CPASAttenuationFilter filter( this );
EmitSound( filter, entindex(), "NPC_FastZombie.NoSound" );

Finally, from npc_alyx.cpp:
Code:
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: Alyx, the female sidekick and love interest that's taking the world by storm!
//
// Try the new Alyx Brite toothpaste!
// Alyx lederhosen!
//
// FIXME: need a better comment block
//
//=============================================================================//


LOL those are some funny "\\" (unused bye progam) messages!:LOL:
 
Yup yup. Just so you know, they are called "comments", because they do just that -- comment on the code but don't get processed by the computer. If encompassing a large part of code in a comment to disable it, /* codehere */ is used.
 
npc_Manhack.cpp

Code:
	// Relentless bastard! Doesn't fail (fail not valid anyway)
			return TranslateSchedule( SCHED_CHASE_ENEMY );

Code:
		//FIXME: This code sucks -- jdw

				offsetDir.z = 0.0f;
				m_vForceVelocity += ( offsetDir * ( offsetSpeed.Length2D() * 0.25f ) );
 
Haha, idiot lab assistant. I love in jokes :D
 
weapon_stunstick.cpp

Code:
	// If player will be in front of me in one-half second, clock his arse.
 
good descriptions..very helpfull...i saw one that said, "oh whoops i just shot a squad member, shoot, better go wander off this way"
 
Code:
if ( IsFlying() )
	{
		//ARGH! Fix this up! THIS SHOULD NEVER HAPPEN!!! WHY GOD WHY!!??!
		if ( IsCurSchedule( SCHED_CROW_IDLE_FLY ) == false &&
			 IsCurSchedule( SCHED_CROW_FLY_AWAY ) == false && 
			 IsCurSchedule( SCHED_CROW_FLY ) == false )

Found that funny :)
 
qckbeam said:
Code:
if ( IsFlying() )
	{
		//ARGH! Fix this up! THIS SHOULD NEVER HAPPEN!!! WHY GOD WHY!!??!
		if ( IsCurSchedule( SCHED_CROW_IDLE_FLY ) == false &&
			 IsCurSchedule( SCHED_CROW_FLY_AWAY ) == false && 
			 IsCurSchedule( SCHED_CROW_FLY ) == false )

Found that funny :)
wait...does that mean that it doesnt fly away at all?
 
ne0_shiny said:
wait...does that mean that it doesnt fly away at all?

I didn't post the complete code. Basically, from what I saw, it seemed that they had to add backup code to make sure the crow had actually changed it's state to SCHED_CROW_FLY and was really, well, flying when IsFlying() evaluates as true. It's redundant (because even if it comes back as true they need to check again), and programmers hate having to do things twice :)
 
hehehe - there's something about '//FIXME: This code sucks' that's pretty amusing...
 
Back
Top