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
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
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?
10,000 lines.
A loathing for whitespace.
Globals all over the place.
Only god I'm seeing here is Cthulhu.
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.
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 !@#!