Raydium 3D Game Engine

Official forum for everything about Raydium, ManiaDrive, MeMak, ...
It is currently Thu Mar 28, 2024 8:29 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Jul 22, 2009 10:26 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
This is a first preliminar version of the Raydium Coding Style Guidelines. I guess this thread will become a wiki page in a future (when finished).

Guidelines
  • Take care of indentation
  • Remove trailing spaces
  • Don't use TABS! Use 4 spaces instead. Your IDE/RAID surely can do it automatically.
  • Function names are like: raydium_group_subject_action/property_others
  • Functions accessing by name will have the suffix "_name".
  • Functions using 3(for example) float values instead of a *float will have the "_3f" suffix.
  • Function definitions will be done in the appropiate .c file in ./raydium/ folder.
  • Function prototypes will be done in the appropiate .h file in ./raydium/headers/ folder.
  • Don't create new files (.c or .h ) if not really needed.
  • defines and global variables will be created in common.h
  • global variables, if needed, will be initialized in init.c
  • Before commiting a change, do a make all and check the code it's 100% working. Raydium SVN has to be "always" stable.
  • Comments: do what you want (/* */ or multiples //) in the code, but respect our standard for documentation headers: raydium/headers/*.h


Top
 Profile  
 
PostPosted: Thu Jul 23, 2009 4:41 pm 
Offline

Joined: Tue Jul 08, 2008 2:37 am
Posts: 181
As already talked about on IRC, I have always tried to create something similar, for that I've used the existing files as templates for new things. The coding style guidelines is a very good idea, especially for new members. Nothing to comment so far for your initial coding style guidelines. Perhaps we should add a simple code example to demonstrate all of the coding style guidelines.

I think the best would be that Xfennec will look at this, he defines the rules! :twisted:


Top
 Profile  
 
PostPosted: Mon Jul 27, 2009 9:37 am 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
Well, I think this is not my preferred part of the job.

But anyway, about code indentation, here's my dictatorial choice:

Code:
signed char raydium_hdr_texture(int texture, signed char hdr)
{
//if(texture>=0 && texture<(int)raydium_texture_index)
if(raydium_texture_is_slot_used(texture))
    {
    raydium_texture_hdr[texture]=hdr;
    return 1;
    }

raydium_log("this is an example : %i",10);
return 0;
}


In plain english:
  • Do not use unnecessary spaces: "a=10;" is better than "a = 10;"
  • Same thing for function arguments, when calling: foobar(10,20);
  • Put spaces for function declaration/prototypes.
  • Do not place braces on the same line as the function, if, for, ...
  • Typical exception to the preceding rule: if(foo) { bar=10; foo=0; } (note spaces around braces)
  • Indent code blocks with braces (at the same level)

I'll edit vicente's message above, about comments, and post new messages here if some new ideas pops into my mind (may hurt). Ideas welcome.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 36 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group