• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Unmaintainable code

61 replies to this topic

### #1NightCreature83  Members

Posted 19 October 2013 - 01:45 PM

POPULAR

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

### #2TheChubu  Members

Posted 19 October 2013 - 03:31 PM

I hope they're doing much much better with Overgrowth

"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

### #3BGB  Members

Posted 19 October 2013 - 08:27 PM

quick skim...

seriously?!...

### #4Edvinas Kilbauskas  Members

Posted 20 October 2013 - 02:08 AM

POPULAR

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?

Edited by Edvinas Kilbauskas, 20 October 2013 - 02:09 AM.

“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

### #5nevS  Members

Posted 20 October 2013 - 02:39 AM

It's the god method pattern!

### #6mhagain  Members

Posted 20 October 2013 - 08:08 AM

POPULAR

10,000 lines.

A loathing for whitespace.

Globals all over the place.

Only god I'm seeing here is Cthulhu.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.

### #7slicer4ever  GDNet+

Posted 20 October 2013 - 10:37 AM

POPULAR

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.

Edited by slicer4ever, 20 October 2013 - 10:44 AM.

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

### #8samoth  Members

Posted 20 October 2013 - 10:41 AM

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

### #9Cornstalks  Members

Posted 20 October 2013 - 10:45 AM

POPULAR

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 !@#!

[ 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 ]

### #10Ohforf sake  Members

Posted 20 October 2013 - 11:18 AM

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.

### #11mhagain  Members

Posted 20 October 2013 - 11:20 AM

I've just done something incredibly stupid.

I looked at more of the code.  OK, I was thinking along the lines of "it can't all be that bad, maybe this one is some kind of freak and the rest of it is normal".

It is all that bad.  I need to go lie down in a dark room now.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.

### #12Migi0027 (肉コーダ)  Members

Posted 20 October 2013 - 11:25 AM

I really hope overgrowth is doing better, because that code beyond terrible. If in If in If in If IF IF IF!

For the first few seconds I was still looking for it, and thinking that it was a blank page, nope.

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

Nuking it won't be enough I'm afraid, NUKE IT TWICE DAMMIT!

Edited by Migi0027, 20 October 2013 - 11:26 AM.

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/cuboidzone.wordpress.com/

### #13swiftcoder  Senior Moderators

Posted 20 October 2013 - 12:11 PM

POPULAR

On the other hand, it shipped as part of a pretty damn successful indie title. On that score, not bad?

Tristam MacDonald - Software Engineer @ Amazon - [swiftcoding] [GitHub]

### #14ByteTroll  Members

Posted 20 October 2013 - 01:51 PM

Holy hell, that list of extern variables...

"The code you write when you learn a new language is shit.
You either already know that and you are wise, or you don’t realize it for many years and you are an idiot. Either way, your learning code is objectively shit." - L. Spiro

"This is called programming. The art of typing shit into an editor/IDE is not programming, it's basically data entry. The part that makes a programmer a programmer is their problem solving skills." - Serapth

"The 'friend' relationship in c++ is the tightest coupling you can give two objects. Friends can reach out and touch your privates." - frob

### #15TheChubu  Members

Posted 20 October 2013 - 03:25 PM

On the other hand, it shipped as part of a pretty damn successful indie title. On that score, not bad?

It certainly says a lot about the drive of Wolfire to finish their game.

"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

### #16samoth  Members

Posted 20 October 2013 - 03:58 PM

POPULAR

On the other hand, it shipped as part of a pretty damn successful indie title. On that score, not bad?

If that's the actual code the produced the title that shipped (and not some kind of joke), then like I said, I bow in awe. I find that code horrible, but as bad as the code may look... writing such a thing is one story, debugging and making it work it is yet another.

If the author really managed to turn this into a working product (and if it was successful, it must have been kind of functional), that was truly some great work. Now imagine what he could do otherwise...

### #17TheChubu  Members

Posted 20 October 2013 - 04:43 PM

On the other hand, it shipped as part of a pretty damn successful indie title. On that score, not bad?

If that's the actual code the produced the title that shipped (and not some kind of joke), then like I said, I bow in awe. I find that code horrible, but as bad as the code may look... writing such a thing is one story, debugging and making it work it is yet another.

If the author really managed to turn this into a working product (and if it was successful, it must have been kind of functional), that was truly some great work. Now imagine what he could do otherwise...

The authors are these guys http://www.wolfire.com/

"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

### #18mhagain  Members

Posted 20 October 2013 - 05:04 PM

POPULAR

On the other hand, it shipped as part of a pretty damn successful indie title. On that score, not bad?

On that score even worse, I'd say, as it might give out the idea that this is the way to write successful titles.  Sure, you can't argue with the success, but the ends don't justify the means.

I note from their blog post announcing it's release: "The coding style is what you might expect from a self-taught high school student, so it could be a challenge to understand" so at least the author(s) acknowledge it's dreadfulness (if in a somewhat understated way), and I've also found that some poor fool has (or had) a fork of the code with the intention of cleaning it up.  That's ... brave.

There's probably a moral to this story, something about not letting the endless quest for perfect code get in the way of actually getting stuff done, but this really does lie at one extreme whereas the ideal place to be would be somewhere in the middle.

Edited by mhagain, 20 October 2013 - 05:11 PM.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.

### #19swiftcoder  Senior Moderators

Posted 20 October 2013 - 05:36 PM

There's probably a moral to this story, something about not letting the endless quest for perfect code get in the way of actually getting stuff done, but this really does lie at one extreme whereas the ideal place to be would be somewhere in the middle.

QFT.

Tristam MacDonald - Software Engineer @ Amazon - [swiftcoding] [GitHub]

### #20Hodgman  Moderators

Posted 20 October 2013 - 07:19 PM

I note from their blog post announcing it's release: "The coding style is what you might expect from a self-taught high school student, so it could be a challenge to understand" so at least the author(s) acknowledge it's dreadfulness (if in a somewhat understated way),
Until I read that, I assumed that the code was produced by an automated tool, stitching together snippets  ....

On the bright side, their compilation times would be pretty fast!