Jump to content

  • Log In with Google      Sign In   
  • Create Account


Unmaintainable code

  • You cannot reply to this topic
55 replies to this topic

#1 NightCreature83   Crossbones+   -  Reputation: 2669

Like
16Likes
Like

Posted 19 October 2013 - 01:45 PM

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, Mad Max

Sponsor:

#2 TheChubu   Crossbones+   -  Reputation: 3698

Like
3Likes
Like

Posted 19 October 2013 - 03:31 PM

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


#3 BGB   Crossbones+   -  Reputation: 1545

Like
0Likes
Like

Posted 19 October 2013 - 08:27 PM

quick skim...

 

seriously?!...



#4 _greyfox()   Members   -  Reputation: 1128

Like
9Likes
Like

Posted 20 October 2013 - 02:08 AM

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

#5 nevS   Members   -  Reputation: 142

Like
2Likes
Like

Posted 20 October 2013 - 02:39 AM

It's the god method pattern! laugh.png



#6 mhagain   Crossbones+   -  Reputation: 7413

Like
11Likes
Like

Posted 20 October 2013 - 08:08 AM

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.


#7 slicer4ever   Crossbones+   -  Reputation: 3192

Like
8Likes
Like

Posted 20 October 2013 - 10:37 AM

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.

#8 samoth   Crossbones+   -  Reputation: 4496

Like
2Likes
Like

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.



#9 Cornstalks   Crossbones+   -  Reputation: 6966

Like
9Likes
Like

Posted 20 October 2013 - 10:45 AM

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 ]

#10 Ohforf sake   Members   -  Reputation: 1441

Like
0Likes
Like

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.

#11 mhagain   Crossbones+   -  Reputation: 7413

Like
3Likes
Like

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.


#12 MiniMigi   Crossbones+   -  Reputation: 1430

Like
0Likes
Like

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! wacko.png

 

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.


#13 swiftcoder   Senior Moderators   -  Reputation: 9584

Like
3Likes
Like

Posted 20 October 2013 - 12:11 PM

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]


#14 ByteTroll   Prime Members   -  Reputation: 1133

Like
0Likes
Like

Posted 20 October 2013 - 01:51 PM

Holy hell, that list of extern variables...


▬▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬▬▬▬▬▬
I see the future in 1's and 0's
▬▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬▬▬▬▬▬

"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

#15 TheChubu   Crossbones+   -  Reputation: 3698

Like
3Likes
Like

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


#16 samoth   Crossbones+   -  Reputation: 4496

Like
6Likes
Like

Posted 20 October 2013 - 03:58 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...



#17 TheChubu   Crossbones+   -  Reputation: 3698

Like
0Likes
Like

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


#18 mhagain   Crossbones+   -  Reputation: 7413

Like
7Likes
Like

Posted 20 October 2013 - 05:04 PM

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.


#19 swiftcoder   Senior Moderators   -  Reputation: 9584

Like
2Likes
Like

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]


#20 Hodgman   Moderators   -  Reputation: 27519

Like
2Likes
Like

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 laugh.png .... sad.png

 

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







PARTNERS