Code cleanup

From FlightGear wiki
Revision as of 20:44, 20 April 2006 by Hellosimon (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The purpose of this page is to provide a todo-list or check-list for anyone that wants to help clean up the Flightgear (FG) code. In addition to this list, you also want to try running FG in Valgrind, a very powerful memory debugger and profiler.

Feel free to add additional items to this page

Thanks -- Cameron Moore

Major Task List

  • Move code out of fgMainLoop() and into separate functions or source files.
  • Replace system() calls in simgear/io/sg_binobj.cxx to `mkdir`
  • Replace system() call in simgear/io/sg_binobj.cxx to `gzip`
  • Allow aircraft to be reliably changed at runtime, without requiring a restart of FlightGear
  • Replace all hardcoded PLIB PUI dialogs with dynamic XML dialogs that use FGDialog, this will require some additional Nasal hooks, so that more complex dialogs (e.g. the property browser or airport list) can actually be realized using XML & Nasal alone.
  • Implement scenery support for dynamic LOD configuration at runtime
  • Optimize the 3D panel code and optionally support display list usage
  • Make Textures reloadable at runtime for debugging and development purposes
  • Add OpenGL bindings to the scripting language Nasal to support scripted creation of instruments like the HUD
  • Helicopter flight is still not yet modelled too convincingly, it would be good if someone could either take the time and add realism to the current FDMs or maybe ven come up with a new dedicated helicopter FDM altogether?

Persistent Checklist


  • Properly allocate and deallocate memory using malloc/new/new[{][}] and free/delete/delete[{][}].

Valgrind is helpful when looking for these.


  • Use the SG_LOG() facilities instead of cout and printf().
  • Use the SG_USING_STD() facilities instead of explicitly using std::function.
  • Use the STL_* variables defined in simgear/compiler.h when including STL headers.
  • When including header files, only use double-quotes when the header is in the same directory.


  • When performance is crucial, consider using the "fastmath.hxx" headers.


  • Use C-string functions with fixed write buffers whenever possible to avoid buffer overflows.

For example, use snprintf() instead of sprintf() and strncpy() instead of strcpy().