Coding Style

This is our preferred coding style. It was inspired by googles coding style at http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml, but this set is only a small subset of it. Currently, not all our sources are following this style, and we welcome any patches that improves this.

Most of the sources follow this coding style, and the rest is being re-styled as we continue development.

Contents

File names and directories

Including files

Layout

int main()
{
    return 0;
}
Exceptions to this are one line functions in header files:
 float getValue() const { return m_my_value; }
   NetworkMode  getMode() const                   {return m_mode;           }
   void         becomeServer();
   void         becomeClient();
   void         setState(NetworkState s)          {m_state = s;             }
   NetworkState getState() const                  {return m_state;          }
   int          getMyHostId() const               {return m_host_id;        }
   void         setHostId(int host_id)            {m_host_id = host_id;     }
   unsigned int getNumClients() const             {return m_num_clients;    }
   const std::string& 
                getClientName(int i) const        {return m_client_names[i];}
   bool         initialiseConnections();
   void         update(float dt);

Doxygen

Use Doxygen comments (this is work in progress). The comments should be before the definition of the function/class/variable/... abd be in the following format (Doxyfile is set up to use the first sentence as a brief description):

// -----------------------------------------------------------------------------
/** Searches recursively through the model for any branches representing
 *  wheels. It looks for any branches having the name
 *  WheelFront.L, WheelFront.R, WheelRear.L, WheelRear.R. If a wheel is found,
 *  a new transform node will be inserted 'above' the branch.
 *  \param branch This is the branch in which the wheels are searched.
 *  \return true if found.
 */
bool Kart::load_wheels(ssgBranch* branch)
{
}

//----------------------------------------------------------------------------
/** Updates the physics for a kart.                                         */
Kart::handlePhysics()

Coding

Retrieved from "http://supertuxkart.sourceforge.net/Coding_Style"

User Tools