Unmaintainable code

Started by
58 comments, last by tristan1333 7 years, 4 months ago

Came across this the other day and thought I would share on how not to write game code:

http://hg.icculus.org/icculus/lugaru/file/97b303e79826/Source/GameTick.cpp#l7276

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

Advertisement

I hope they're doing much much better with Overgrowth :D

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

quick skim...

seriously?!...


if(i<numplayers&&i!=k&&player[k].skeleton.free==0&&player[i].skeleton.oldfree==0&&(player[i].targetanimation==jumpupanim||player[k].targetanimation==jumpupanim)&&(player[i].aitype==playercontrolled||player[k].aitype==playercontrolled)&&((player[i].aitype==attacktypecutoff&&player[i].stunned<=0)||(player[k].aitype==attacktypecutoff&&player[k].stunned<=0))){
    if(findDistancefast(&player[i].coords,&player[k].coords)<10*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)&&findDistancefastflat(&player[i].coords,&player[k].coords)<2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)){
        if(player[i].targetanimation==jumpupanim&&player[k].targetanimation!=getupfrombackanim&&player[k].targetanimation!=getupfromfrontanim&&animation[player[k].targetanimation].height==middleheight&&normaldotproduct(player[i].velocity,player[k].coords-player[i].coords)<0&&((player[k].aitype==playercontrolled&&player[k].attackkeydown)||player[k].aitype!=playercontrolled)){

lolwut?

“There are thousands and thousands of people out there leading lives of quiet, screaming desperation, where they work long, hard hours at jobs they hate to enable them to buy things they don't need to impress people they don't like.”? Nigel Marsh

It's the god method pattern! laugh.png

10,000 lines.

A loathing for whitespace.

Globals all over the place.

Only god I'm seeing here is Cthulhu.

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

nuke it....it's the only way to be sure.

edit: this is so bad, i have to edit this post, because i feel that quote does not do justice to how terrible this code is, and i'm so scared that it would somehow survive a nuke just for the shear fact of how bad it is. I actually feel a bit woozy looking at it.

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

This is... wow. If that actually compiles without errors, and the resulting binary actually works, then I bow in awe.

My response was this: What is he talking about? It's just a blank file. I see nothing. Granted, it's thousands of lines of nothing, but I can maintain blank lines pretty well.

**scroll around, notice I can scroll to the right, and so I scroll to the right as much as I can**

Oh.. Oh no... No no no no no. That can't be... Yup... it really is... HOLY !@#!

[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]
Read a bit into it and it seems, that all the game logic, all the little scripts that you usually attach to triggers, everything of every level, even dialogs, was compiled into the Game::Tick function, including the trigger checks for them (if (distanceToThing < ...) { ...} ).


If there was a yearly contest for the Coding Horrors forum, that 6854 LOC method would be a close contender. If at all, only seconded by that OBJ rendering code s.b. posted.

This topic is closed to new replies.

Advertisement