Tremulous Forum
Mods => Modding Center => Topic started by: /dev/humancontroller on July 12, 2007, 06:14:14 am
-
I mean, of course, for the majority of the code, because slight mixing can be acceptable/good.
I ask this, because the stock version has one style in one file, and another style in another file. And I hate one of them, which I won't tell. Let's see...
I you have explanations, go ahead and write.
-
4 spaces for me.
Although tabs are best, as they let each dev have it how they want.
-
indentation is for the losers I code everything in 1 line
-
I hate Tremulous code's spaces around EVERYTHING.
Spacing is mostly good, but when it's even sometimes inside [] it can seem excessive and just as confusing as no spacing at all.
Yeah, and I voted four spaces.
-
Indentation is for code beautifiers
http://astyle.sourceforge.net/
I use tabs myself.
-
I hate Tremulous code's spaces around EVERYTHING.
Spacing is mostly good, but when it's even sometimes inside [] it can seem excessive and just as confusing as no spacing at all.
Yeah, and I voted four spaces.
What looks good for me:
thaip funkshun( war neim, thaip_t twu, ... )
asd[0], qwerty[1337]
anotherLong.struct[ referenceWith->everything ].inside // space in [] when something long is in it
do you even disagree with these?
-
Indentation is for code beautifiers
http://astyle.sourceforge.net/
I use tabs myself.
Sample result code plz?
-
Sample result code plz?
Before:
int main(int argc, char ** argv) {
int a;
if (cin >> a)
{
cout << a << endl;
if (cin >> a)
{
cout << a;
}
}
return 0;
}
Command:
astyle --style=linux example.cpp
After:
int main(int argc, char ** argv)
{
int a;
if (cin >> a) {
cout << a << endl;
if (cin >> a) {
cout << a;
}
}
return 0;
}
-
I hate people who put the opening { on the same line as what it opens.
The { and } should line up!
-
omg formatting doesnt matter as long as it is readable
it is just a convention
btw ansi FTW
-
I hate people who put the opening { on the same line as what it opens.
The { and } should line up!
Do you hate me more than my style? :D
I accept that style because the indentation shows that you're in a new block.
The compactness of the code is also a requirement. When we have to execute 1 conditional statement, like a return, here are the options:
if( some > condition ) {
return;
}
// Allows you to quickly add debug lines like Com_Printf( "ZOMGWUTDAFUK\n" );
// Remove the braces once the program has been tested.
if( some > condition )
return;
if( some > condition ) return;
// Uh... these two are kind of interchangable,
// chose the second one if compactness is the first priority.
if( some > condition )
{
return;
}
// Does this make it better?
OK, if more than 1 statement is inside, blocks are required.
if( right ) {
right[0] = -1*sr*sp*cy+-1*cr*-sy;
right[1] = -1*sr*sp*sy+-1*cr*cy;
right[2] = -1*sr*cp;
}
if( up )
{
up[0] = cr*sp*cy+-sr*-sy;
up[1] = cr*sp*sy+-sr*cy;
up[2] = cr*cp;
}
// Well, the second one is less compact, but more readable.
// Wether the first or the second block is better, I don't know.
// What about this? eeewww
if( forward ) {
forward[0] = cp*cy;
forward[1] = cp*sy;
forward[2] = -sp;
}
-
2. Or 3 sometimes.
//Fuck this shit...
{
printf "I am";
printf " listening to";
printf " ManOwaR!";
}
-
http://www.linuxhq.com/kernel/v1.3/53/Documentation/CodingStyle
-
if( up )
{
up[0] = cr * sp * cy + -sr * -sy;
up[1] = cr * sp * sy + -sr * cy;
up[2] = cr * cp;
}
now it is more readable (I would kill myself if I had to read your code)
and for kaleo
printf( "I am" " listening to" " umbrella by " "rihanna." );
-
http://www.linuxhq.com/kernel/v1.3/53/Documentation/CodingStyle
Thx. You wouldn't happen to also know the source of the additional readability spaces, would you?func( var qwerty );