Skip to content

Instantly share code, notes, and snippets.

@lepinkainen
Created August 27, 2025 10:51
Show Gist options
  • Save lepinkainen/926e6d21add53f96d11f4c5247429bf1 to your computer and use it in GitHub Desktop.
Save lepinkainen/926e6d21add53f96d11f4c5247429bf1 to your computer and use it in GitHub Desktop.
C&C Generals code comments

Funny Generals Source code comments

Just a compilation of funny code comments and entity names I found while browsing: https://github.com/electronicarts/CnC_Generals_Zero_Hour

// our RNG is basically shit -- horribly nonrandom at the start of the sequence.
// get a few values at random to get rid of the dreck.
// there's no mathematical basis for this, but empirically, it helps a lot.
UnsignedInt silly = GetGameLogicRandomSeed() % 7;
for (Int poo = 0; poo < silly; ++poo) 
{
   GameLogicRandomValue(0, 1);// ignore result
}

GameLogic.cpp

//Are we disguise transitioning (either gaining or losing disguise look?)
/** u/todo srj -- evil hack here... this whole heat-vision thing is fucked.
don't want it on mines but no good way to do that. hack for now. */

StealthUpdate.cpp

// Homework for today.  Write 2000 words reconciling "Your code must never crash" with "Intentionally putting crashes in the code".  Fucktard.

Xfer.cpp

// FILE: WorkerAIUpdate.h //////////////////////////////////////////////////////////////////////////
// Author: Graham Smallwood, June 2002
// Desc:   A Worker is a unit that is both a Dozer and a Supply Truck.  Holy Fuck.

WorkerAIUpdate.h

// Why, oh why does Visual C need this!!! It's bugged. <sigh>
#pragma warning(disable : 4505)

Vector.h

 // Can't wait infinite or the other process will never create its window
 //   Only Bill himself knows why this is happening

CHATAPI.cpp

// srj sez: this may sound familiar somehow, but let me reiterate, just in case you missed it:
//
// hardcoding is bad. 
//
// the anim got changed and now is only 20 seconds max, so the previous code was wrong. 
// 
// hey, I've got an idea! why don't we ASK the anim how long it is?

Drawable.cpp

// in theory, the above is the correct calculation, but in practice,
// doesn't work in some situations (eg, opening of USA01 map). Why, I dunno.
// But for now I have gone back to the old, looks-incorrect-to-me-but-works calc. (srj)

Locomotor.cpp

void ConnectionManager::processFrameInfo(NetFrameCommandMsg *msg) {
//stupid frame info, why don't you process yourself?

ConnectionManager.cpp

m_initiallyActive = TRUE; //Patch 1.02 -- Craptacular HACK -- should default to FALSE but only ONE case sets it false out of 847!

FXListDie.h

 REPLACE THIS CRAP

// Parses a date string that's in modified RFC 1123 format

(OP: I highly recommend reading this function, holy FUCK its bad hahaha)

xtime.cpp (stinky)

// I can't take it any more.  Let the record show that I think the UpgradeMux multiple inheritence is CRAP.
getAutoHealBehaviorModuleData()->m_upgradeMuxData.muxDataProcessUpgradeRemoval(getObject());

AutoHealBahaviour.h

// Lets discuss how Windows is a flaming pile of poo. I'm now casting the header
// directly into the structure, because its the one I want, and this is just how
// its done. I hate Windows. - jkmcd

WinMain.cpp

// We need to be able to grab w3d's from a localization dir, since Germany hates exploding people units.

W3DFileSystem.cpp

void Whatever(
...
)

meshmdl.cpp

// the missile on the raising up launch platform is actually 45 degrees from the missile
// that is flying around the world ... we want to rotate it "on end and in place" so 
// that we don't see any decals on the side of the missile 'pop' to the new angle
/// u/todo, this should not be a hard coded value ... I love demos!!!

NeutronMissileUpdate.cpp

// this is intended ONLY for use by INI::scanScience.
// Don't use it anywhere else. In particular, never, ever, ever
// call this with a hardcoded science name. (srj)

Science.h

} else if (type == ARGUMENTDATATYPE_TIMESTAMP) {  // Not to be confused with Terrance Stamp... Kneel before Zod!!!

Recorder.cpp

; String is returned by const for a reason.  Bad things will happen 
; if you modify it.  You have been warned.

locale.cpp

// ??? ugh, public stuff that shouldn't be -- hell yeah!
UnsignedInt getSpecialObjectCount() const;
UnsignedInt getSpecialObjectMax() const;
Object* findSpecialObjectWithProducerID( const Object *target );
SpecialPowerType getSpecialPowerType( void ) const;

SpecialAbilityUpdate.h

//Ack, this is ass. These enums fix a bug where new enums were missing for 
//shortcut powers... but the real clincher was that if you were say USA and
//captured a Tank China command center, your US paradrop would be assigned
//to the china tank drop and when you tried to fire it from the shortcut
//it could pick the china one and not fire it because it didn't have
//complete connection... ugh!!!

SpecialPowerType.h

// ugh, this is a little hokey, but lets us pretend that a StaticNameKey == NameKeyType
inline operator NameKeyType() const { return key(); }

NameKeyGenerator.h

//Wow, this is bogus... but we need this template pointer in order to fire special powers from the
//shortcut... ugh.
m_commandCenterTemplate = thing;

AcademyStats.cpp

// if he is not a warehouse or a center, then shut the hell up
if( (warehouseModule == NULL)  &&  (centerModule == NULL) )
   return FALSE;

ActionManager.cpp

riderDraw->draw( NULL );// What the hell?  This param isn't used for anything

W3DOverloadTruckDraw.cpp

//Added this to support attacking cargo planes without being able to select them.
//I added the KINDOF_FORCEATTACKABLE to them, but unsure if it's possible to select
//something without the KINDOF_SELECTABLE -- so doing a LATE code change. My gut
//says we should simply have the KINDOF_SELECTABLE check only... but best to be safe.

SelectionXlat.cpp

Thats it for now! If you find anything funny I missed please comment and I'll add it with credit.

More found:

// Get the year from a daycount since year 0
// Also get the daycount since the start of the year
//
// Ayecarumba what a pain in the ass!
//

xtime.cpp

//
// force the tree control to redraw, it seems to have problems updating
// the plus signs, lame ass Microsoft
//

HeirarchyView.cpp

    // Assumption: Things with a KINDOF_STRUCTURE flag can never be built from 
    // a factory (ProductionUpdateInterface), because the building can't move
    // out of the factory. When we do our Starcraft port and have flying Terran
    // buildings, we'll have to change this ;-)
    // Remember: To ASSUME makes an ASS out of U and ME. 

Player.cpp

// Totally hacky set of conditions to make col. burton's monkey ass not slide down 
// the cliffs backwards.  This could use some improvement at some point.  jba. 31DEC2002

AIstates.cpp

  // but wait! I may be riding on an Overlord
  // This code detects the case of whether the contained passenger is in a bunker riding on an overlord, inside a helix!
  // Oh  my  God.

TransportContain.cpp

    // Since it is very late in the project, and there is no call for such code...
    // there is currently no support here for linked turrets, as regards Attacking Objects (victims)
    // If the concept of linked turrets is further developed then God help you, and put more code right here
    // that lookl like the //LINKED TURRETS// block, below

AIStates.cpp

// Oh god... this is a total hack for shortcut buttons to handle rendering text top left corner...
m_specialPowerShortcutButtons[ i ]->winSetStatus( WIN_STATUS_SHORTCUT_BUTTON );

ControlBar.cpp

if (isKindOf(KINDOF_MOB_NEXUS)) // quicker idiot test
{
    pos.z += 20;// dear God, I confess my kluge, and repent.
}

Object.cpp

/// todo Ack!  the todo in PlayerList::reset() mentioning the need for a Player::reset() really needs to get done.
m_playerRelations->m_map.clear(); // For now, it has been decided to just fix this one.  Dear god me must reset.
m_teamRelations->m_map.clear(); // For now, it has been decided to just fix this one.  Dear god me must reset.

Player.cpp

    // HERE WOULD BE A GREAT PLACE FOR AN IDIOT TEST:
  // REJECT SIMULATION NODES THAT ARE OFF SCREEN!!!!!!!!!!
    // HERE WOULD BE A GREAT PLACE FOR AN IDIOT TEST:
  // REJECT SIMULATION NODES THAT ARE OFF SCREEN!!!!!!!!!!

W3DTerrainVisual.cpp

permalink by thelunararmy (↑ 195/ ↓ 0)

Comments

  • I suspect that my husband may be the source of a few of those…

Edit: yeah, his name is on one of them, LOL. ⏤ by dalek_999 (↑ 68/ ↓ 0) - Lol what? Who? ⏤ by FrostByteGER (↑ 16/ ↓ 0) - Eh, I don't want to connect his name directly to my account/comments, but it's the 4th comment in the list.

He just confirmed over chat that he's the source for some of these, including the one about kneeling before Zod, which he knew/knows is one of my favorite quotes, so I feel like I've been indirectly referenced there. ⏤ by dalek_999 (↑ 42/ ↓ 0) - Despite his frustrations, please thank your husband for helping to make one of my favourite games ever. ⏤ by Setekh79 (↑ 35/ ↓ 0) - And thank you for marrying one of the best video game coders even if the codes are messy and difficult (this is why I am not a coder because it's hard!)!! He is awesome. I (OK, we) would love to hear more about his C&C:G stories! Coding, playing, EA, etc. whatever! Was he surprised to see his old codes again? Now, everyone is going to read his codes. Oh no! ;) ⏤ by antdude (↑ 15/ ↓ 0) - Yo your husband created some of the formative experiences of our childhoods. The impact of that is IMMENSE. Thank you (him and you). ⏤ by juicebox12 (↑ 11/ ↓ 0) - That's really cool. It looks like he's an associate professor now!  ⏤ by arjungmenon (↑ 7/ ↓ 0) - Oh, that's so cool! This whole thread has made my day! ⏤ by cBurger4Life (↑ 7/ ↓ 0) - Damm, please let him know that its been a while, but we love his work! SEND HIM OUR REGARDS!!

This is the closest I'll ever be to saying thanks to one of the devs of the games I grew up playing ⏤ by Juanmusse (↑ 8/ ↓ 0) - He's been reading this thread and is very appreciative of the kind comments :) ⏤ by dalek_999 (↑ 9/ ↓ 0)

  • Huh... As a senior dev, I'd be fired for putting some of these comments in code or commit logs today, like the one early on about reconciling code never crashing, but rest assured, very similar statements or worse run through my head whenever I'm faced with someone else's code. ESPECIALLY if it's an offshore vendor team's code. Holy shit I've seen some shit...

gif ⏤ by Valdearg20 (↑ 44/ ↓ 0) - It was a different time. Good ol' 2002 ⏤ by PandaParado (↑ 12/ ↓ 0) - So, it must had been an intern? ;) ⏤ by antdude (↑ 3/ ↓ 0) - Hahahahahaha oh man if you've never been in a software development department, you'd be absolutely AMAZED at the overall incompetence present at all levels. It's actually kind of incredible.

I've seen devs with 20 years of experience write code so blatantly thread unsafe that I genuinely couldn't believe they wrote it, and even after I explained the issue to them, they didn't understand why it was a problem.

I've seen Principal level engineers advocate for design patterns with such cripplingly bad scalability that I, as a middling dev with 5 years of experience at the time, had to write a demo to show off it's shortcomings to prove why I refused to use it for my app so that my boss and his boss and his boss' boss would accept the fact that it was shit and stop trying to pressure me to use it.

Don't get me wrong, I've had to deal with my fair share of poorly written code by juniors, but that honestly doesn't bother me much. As long as they're willing to learn and capable of understanding how to improve, those are just learning opportunities for people that I hope to be able to mentor in a way that they can fill my shoes once I retire.

But holy shit, the fucking "Team Lead" for the offshore team who literally can't read a fucking stack trace or understand that setting an object to null on line 125 and then trying to call a method on that object in line 127 WONT FUCKING WORK NO MATTER HOW MANY TIMES YOU FUCKING TELL HIM IT WILL RESULT IN A NULL POINTER EXCEPTION... Those kinds of guys can fuck right off, useless wastes of time and money... Who the hell makes it to a team lead role who literally can't write code or read a stack trace?!?

Like I said... I've seen some shit... ⏤ by Valdearg20 (↑ 10/ ↓ 0) - So what you're saying is there's hope out there for us shitty programmers to find jobs. ⏤ by Sudden-Variation8684 (↑ 5/ ↓ 0) - Bruh, you're in the majority in the industry! 🤣🤣

But in all seriousness, we're all shitty programmers in our own ways. Just gotta be less shitty than your competition! ⏤ by Valdearg20 (↑ 2/ ↓ 0) - I used to be a web developer, but I hated it. I also have been a SQA tester close to software development, and geez all the bugs I had to report. I love finding issues and making and fixing stuff. Ugh, out of country people. Yeah, I had to deal with them too! :( ⏤ by antdude (↑ 3/ ↓ 0) - If it makes you feel better this is true of an engineering department is any company.

Incompetence is fairly common lol ⏤ by StupidityHurts (↑ 3/ ↓ 0)

  • // Lets discuss how Windows is a flaming pile of poo. I'm now casting the header
    
    // directly into the structure, because its the one I want, and this is just how // its done. I hate Windows. - jkmcd

I related a little too hard to this one xD ⏤ by EternalDeiwos (↑ 46/ ↓ 0) - Who was jkmcd in the game credits? ⏤ by antdude (↑ 10/ ↓ 0) - John McDonald ⏤ by dalek_999 (↑ 8/ ↓ 0)

  • The one about Germany had me laughing real good. ⏤ by Electric-Mountain (↑ 24/ ↓ 0)
  • I like that bug where the USA Ranger paradrop would be replaced with Battlemasters when USA captures Kwai's command center.

Just imagine each Ranger just straight up replaced with a whole Battlemaster. 20 horde-bonus autoloader battlemasters straight to your base.

Pity the devs fixed the code before we could get such shenanigans.

Also, even the devs though of putting infantry in overlords, in helixes. And I like that you could've built fake buildings out of your war factory, but the mechanics were scrapped because they can't move out, because they're buildings. ⏤ by mttspiii (↑ 15/ ↓ 0) - And here I thought the side comments for the .big files were already kinda funny. ⏤ by mttspiii (↑ 6/ ↓ 0)

  • This stuff is gold, please share more if you find it. ⏤ by USA_Bruce (↑ 8/ ↓ 0)
    • There has to be more! Everyone comb the codes (like Spaceballs' movie scene with comb the desert -- https://www.youtube.com/watch?v=hD5eqBDPMDg)! ⏤ by antdude (↑ 3/ ↓ 0)
      • We ain't found shit! ⏤ by IngramPrisken (↑ 5/ ↓ 0)
        • "I am surrounded by assholes." ⏤ by antdude (↑ 3/ ↓ 0)
  • This is amazing, thanks for compiling the list ⏤ by ReLiFeD (↑ 3/ ↓ 0)
  • They were considering doing a Starcraft port? I thought it was already a PC game at that time. ⏤ by AlphSaber (↑ 3/ ↓ 0)
  • Did the other C&C and non-C&C games (Doom, Quake, etc.) have funny comments like these? ⏤ by antdude (↑ 1/ ↓ 0)
    • Team Fortress 2 and The Simpsons: Hit and Run were other games I know that have pretty funny code comments. Go look those up. ⏤ by Sgt_Kelp (↑ 7/ ↓ 0)
      • Simpsons:H&R was open sourced??????? ⏤ by antdude (↑ 2/ ↓ 0)
        • Nah just leaked but the comments are still there ⏤ by Sgt_Kelp (↑ 6/ ↓ 0)
      • Wait Hit and Run got it's source code release/leaked? ⏤ by AshleyAshes1984 (↑ 2/ ↓ 0)
    • Here's a good one https://www.youtube.com/watch?v=k238XpMMn38 ⏤ by ScottyWired (↑ 2/ ↓ 0)
      • Haahaha! Thanks. ⏤ by antdude (↑ 1/ ↓ 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment