Random line of code thread
category: code [glöplog]
Code:
// 2005 IA topology
void IA_init()
{
CreateWispsLikeItIs();
InitBots();
}
void IA_Play()
{
DoWispsTravelAndParseAllThe3DWorld();
for each bot
{
if (bots encounter wisp) ChangeStateOfMindAndShortMemory(of the bot);
DoIAWithStuffs(bot);
}
}
void IA_Free()
{
Thank(wisps);
}
Very simple mistake that made me loose my sleep and now I am too lazy to finish my Ludum Dare entry (I haven't even started as planned and not sure if I want to go for the Jam)
Code:
if (hasHitWall(r));
{
// do stuff
}
Optimus: That´s why i zoom the Text-Editor a lot when coding...lets me see such typos directly. If your Editor doesn´t support zooming just use a bigger font! ;)
any decent compiler should warn you about such constructs...
Maybe I didn't see the warning.
Generally a problem amongst coders! Most just never look at warnings at all...while they should be handled like Errors in many cases.
It´s really a bad habit every coder that wants to be a good coder should get rid of asap!
It´s really a bad habit every coder that wants to be a good coder should get rid of asap!
Warning as errors is the way to go!
Code:
crc32 eax, dword [ebx]
Code:
if flashy: did dumb stuff
then: do stuff
Rudi, did you miss a struct for low and high?
Code:
union Flags
{
WORD EFLAGS;
BYTE low;
BYTE high;
struct flagbits bits;
};
Code:
str[strlen(str)] = 0;
In a commercial project with millions of users.
0xF: seems like a smart hack to ensure the string always ends with a 0, which is actually useful to avoid buffer memory leaks and such C foley. not sure if there are any misuse consequences though?!
although strings should end with \0 not 0 itself... hmm.. fuck me if i'll ever know any proper c trickery.
//code of random line
DrawLine(Random2D(), Random2D());
//TODO: add Threading
DrawLine(Random2D(), Random2D());
//TODO: add Threading
psenough: strlen counts the characters up to the first \0 (which is equal to 0)... i.e. this is just a (very expensive) NOP
Perhaps it's a fix for a race condition in case another thread overwrites the 0 with garbage inbetween the strlen() and the write. :P
More likely written by someone who switches between programming languages a lot.
Quote:
0xF: seems like a smart hack to ensure the string always ends with a 0, which is actually useful to avoid buffer memory leaks and such C foley. not sure if there are any misuse consequences though?!
If the string hasnt a 0 it will write a 0 somewhere else in memory.
If the string already has 0 it an expensive shitload of nop.
Thats clearly retarted.
It just zeroes twice to make the string extra secure!
Code:
#define ES 0
#define IN_RIGHT 1
#define IN_DOWN 2 //down square is y+1
#define IN_LEFT 3
#define IN_UP 4 //up square is y-1
#define OUT_RIGHT 5
#define OUT_DOWN 6
#define OUT_LEFT 7
#define OUT_UP 8
char ClockwiseRotationImages[9]={0,IN_DOWN,IN_LEFT,IN_UP,IN_RIGHT,OUT_DOWN,OUT_LEFT,OUT_UP,OUT_RIGHT};
When writing a math lib at night, always working with transposed matrices, and don't get the matrix inverse correct.
Code:
// Shit cheat, just reverse the transformations.
Matrix Matrix::Reverse() const
{
Matrix matrix;
// Inverse determinant of rotation part.
float f = 1.0f / (M11 * (M22 * M33 - M32 * M23) - M21 * (M12 * M33 - M32 * M13) + M31 * (M12 * M23 - M22 * M13));
// Rotation.
matrix.M11 = f * (M22 * M33 - M32 * M23);
matrix.M12 = -f * (M12 * M33 - M32 * M13);
matrix.M13 = f * (M12 * M23 - M22 * M13);
matrix.M21 = -f * (M21 * M33 - M31 * M23);
matrix.M22 = f * (M11 * M33 - M31 * M13);
matrix.M23 = -f * (M11 * M23 - M21 * M13);
matrix.M31 = f * (M21 * M32 - M31 * M22);
matrix.M32 = -f * (M11 * M32 - M31 * M12);
matrix.M33 = f * (M11 * M22 - M21 * M12);
// Translation.
matrix.M14 = -(M14 * matrix.M11 + M24 * matrix.M12 + M34 * matrix.M13);
matrix.M24 = -(M14 * matrix.M21 + M24 * matrix.M22 + M34 * matrix.M23);
matrix.M34 = -(M14 * matrix.M31 + M24 * matrix.M32 + M34 * matrix.M33);
// Last row.
matrix.M41 = 0.0f;
matrix.M42 = 0.0f;
matrix.M43 = 0.0f;
matrix.M44 = 1.0f;
return matrix;
}
Code:
for (;;)
{
//random stuff to do
}
Code:
/// AAAAAAAAAA JAVA
if (afd == null)
{
// (ノಥДಥ)ノ︵┻━┻・/
return;
}
Is this a great way to greet?
Code:
main (void){
definer greetingslist {
greetz_goes_to:
chrysalis
conspiracy
exceed
pathos
mfx+kewlers
logicoma
matt_current
alcatraz
nuance
trsi
umlaut_design
you
}};
^ in what language does this work?