Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Funniest line of code ever ?

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

#121 OandO   Members   -  Reputation: 965

Like
10Likes
Like

Posted 19 January 2015 - 09:14 PM

typedef float flaot; // Quicker than learning to tpye accurately.

Edited by OandO, 19 January 2015 - 09:15 PM.


Sponsor:

#122 Bearhugger   Members   -  Reputation: 796

Like
3Likes
Like

Posted 25 January 2015 - 02:31 PM

try {

    //
    // Some Java code that throws a lot of checked exceptions.
    //

} catch (SomeCheckedException e) {
    // I DON'T ALWAYS WRITE EMPTY CATCH BLOCKS
} catch (AnotherCheckedException e) {
    // BUT WHEN I DO, I'M CODING IN JAVA
}


#123 braindigitalis   Crossbones+   -  Reputation: 5129

Like
0Likes
Like

Posted 25 January 2015 - 05:03 PM

I just had to share this from my r-type clone from 1998.

 

Procedure DrawFloor(FloorStep:Integer);
begin
_RangeCheck:=True;
{Enable CJEPROC flag for clipping of sprites}
Flr.PlotVirtual(31-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(47-FloorStep,16,ScreenPtr); {Don't even think of accusing}
Flr.PlotVirtual(63-FloorStep,16,ScreenPtr); {me of being a lazy coder,}
Flr.PlotVirtual(79-FloorStep,16,ScreenPtr); {'coz this chunk of calls is}
Flr.PlotVirtual(95-FloorStep,16,ScreenPtr); {about ten times faster than}
Flr.PlotVirtual(111-FloorStep,16,ScreenPtr); {a loop, so there!}
Flr.PlotVirtual(127-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(143-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(159-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(175-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(191-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(207-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(223-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(239-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(255-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(271-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(287-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(303-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(319-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(335-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(351-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(367-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(-1-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(15-FloorStep,16,ScreenPtr);
If (Level=2) or (Level=3) then
begin
Flr2.PlotVirtual(31-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(47-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(63-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(79-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(95-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(111-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(127-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(143-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(159-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(175-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(191-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(207-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(223-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(239-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(255-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(271-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(287-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(303-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(319-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(335-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(351-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(367-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(-1-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(15-FloorStep,184,ScreenPtr);
end;
_RangeCheck:=False;
{Disable it again for increse in speed}
end;

 

The scary thing was, on my 386 at 25mhz it was noticeably faster, even without needing to profile to notice! I feel dirty just re-reading it...


Games Currently In Development:
Currently rewriting Firework Factory - Casual Puzzler for PC in Direct3D 11. Latest Journal Entry: Texture Caching, Concept Art and more! (09-Apr-2015).


#124 kalle_h   Members   -  Reputation: 1993

Like
1Likes
Like

Posted 25 January 2015 - 05:10 PM

float4 color = u_texture.Load(uv, int2(+0, +0));

This was causing crash bug on intel gpu's on our shipped game. Offsetting by zero isn't that wise thing to do but who would have guessed the implications.



#125 SmkViper   Members   -  Reputation: 2474

Like
1Likes
Like

Posted 26 January 2015 - 08:37 AM

I just had to share this from my r-type clone from 1998.
 


Procedure DrawFloor(FloorStep:Integer);
begin
_RangeCheck:=True;
{Enable CJEPROC flag for clipping of sprites}
Flr.PlotVirtual(31-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(47-FloorStep,16,ScreenPtr); {Don't even think of accusing}
Flr.PlotVirtual(63-FloorStep,16,ScreenPtr); {me of being a lazy coder,}
Flr.PlotVirtual(79-FloorStep,16,ScreenPtr); {'coz this chunk of calls is}
Flr.PlotVirtual(95-FloorStep,16,ScreenPtr); {about ten times faster than}
Flr.PlotVirtual(111-FloorStep,16,ScreenPtr); {a loop, so there!}
Flr.PlotVirtual(127-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(143-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(159-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(175-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(191-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(207-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(223-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(239-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(255-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(271-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(287-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(303-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(319-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(335-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(351-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(367-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(-1-FloorStep,16,ScreenPtr);
Flr.PlotVirtual(15-FloorStep,16,ScreenPtr);
If (Level=2) or (Level=3) then
begin
Flr2.PlotVirtual(31-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(47-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(63-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(79-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(95-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(111-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(127-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(143-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(159-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(175-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(191-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(207-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(223-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(239-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(255-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(271-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(287-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(303-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(319-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(335-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(351-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(367-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(-1-FloorStep,184,ScreenPtr);
Flr2.PlotVirtual(15-FloorStep,184,ScreenPtr);
end;
_RangeCheck:=False;
{Disable it again for increse in speed}
end;
 
The scary thing was, on my 386 at 25mhz it was noticeably faster, even without needing to profile to notice! I feel dirty just re-reading it...


This is not entirely surprising, the overhead of incrementing and doing a conditional branch can be significant, and compilers of the time weren't smart enough to do this thing for you. Now days the compilers are smart enough to do this behind the scenes if they think it will actually benefit your code based on various metrics.

#126 AndreTheGiant   Members   -  Reputation: 191

Like
6Likes
Like

Posted 23 February 2015 - 08:09 AM

The best one from recent memory is this:

 

int seven = 9; // this MUST be 6 to work.



#127 Orymus3   Crossbones+   -  Reputation: 13952

Like
0Likes
Like

Posted 26 February 2015 - 07:51 PM


int seven = 9; // this MUST be 6 to work.

 

Ouch.


-=- My Articles-=-
Getting Games Done - Method and tools on how to start a hobby project and get it Done!

Retro Mortis - "RTS" - Article Series (3 Parts) on the history of RTS development






PARTNERS