Skip to content
Ingo Ruhnke edited this page Mar 22, 2015 · 3 revisions

Windstille uses mostly standard GNU indention style, which is the default in Emacs:

void
ClassName::function_name (float delta)
{
  value -= 10*delta;

  std::list<Player*>* lst = get_world ()->get_players ();

  for (std::list<Player*>::iterator i = lst->begin (); i != lst->end (); ++i)
    {
      if (fabs((pos - (*i)->get_pos ()).norm ()) < 20.0f)
        {
          player_catched(*i);
          remove();
        }
    }
}

The few exceptions are:

  • return type is on its own line
  • namespaces aren't indented
  • case lables are indented
  • no space between parenthisis an function call (i.e. foobar() not foobar ())

These can be achived with:

(setq indent-tabs-mode nil)
(setq parens-require-spaces nil)
(setq c-offsets-alist '((innamespace   . 0)
                        (inline-open   . 0)
                        (inline-close  . 0)
                        (case-label    . 2)
                        (inextern-lang . 0)))

The whole indention thing can be fixed with a keypress in Emacs, so one shouldn't bother to much with trying to get it correct manually. Instead one should simply use the style that makes one most productive and if needed fix it up later.

Some notes about nameing convention:

  • classes are CamelCase (i.e. DrawingManager)
  • functions are lowercase (i.e. set_foobar(5))
  • variables are lowercase (i.e. player_position)
  • files are named after the class they contain, but lowercased (i.e. drawing_manager.hpp for DrawingManager)
  • include guards defines are HEADER_WINDSTILLE_//DIRECTORY//_//FILENAME//

Other things

  • external libraries go to external/ not into the src/ directory
  • code that can be reused by other projects (lisp, tinygettext, ...) shall be moved to external/
  • complex hacks on external libraries are not allowed unless absolutely necessarry and well documented
  • each testable sub-module shall have test cases and examples
  • all interactive sub-modules shall have a visual demonstration reachable from the normal in-game menu
  • no code unreachable by either test cases, visual demonstration or test level shall enter the repository

Clone this wiki locally