Difference between revisions of "Source Code Reference"

From FreeSpace Wiki
Jump to: navigation, search
(Alphabetical View)
 
(19 intermediate revisions by 7 users not shown)
Line 1: Line 1:
==Getting the source==
+
== External Libraries ==
Although there are some CVS client tools, one of the most user-friendly is TortoiseCVS (it is by far better than WinCVS). Here you have some noob instructions to download the CVS code of the Freespace2 Open Project:
 
  
* Go to [http://www.tortoisecvs.org the TortoiseCVS homepage] and download the latest version.
+
FreeSpace 2 relies on the following libraries which are included in the source tree:
* Install it. You'll have to restart your PC afterwards. TortoiseCVS integrates itself with Explorer. You access and mark a folder as a code container with mouse right button contextual menu.
+
* jansson: JSON library
* Make a new folder on your HD where you'd like to install the code. You'll need a fair bit of space for the code and the intermediate files when building it. Right click over it and choose '''CVS Checkout...''' from the list.
+
* libjpeg: JPEG library
* A new window will open up. Cut and paste this text into the 'CVSROOT:' textbox<br>''':pserver:[email protected]:/home/fs2source/cvsroot'''
+
* libpng: PNG library
* This instruction will fill the editable drop lists below 'CVSROOT:' textbox. (You could also have filled every one of them instead of the 'CVSROOT:' textbox):
+
* lua: LUA Scripting language
** Protocol: Password server (:pserver:)
+
* mongoose: HTTP server library
** Protocol parameters: <empty>
+
* oggvorbis: Ogg Vorbis sound library
** Server: warpcore.org
+
* openal: OpenAL sound library
** Port: <empty>
+
* zlib: ZIP compression library; necessary for libpng
** Repository folder: /home/fs2source/cvsroot
 
** User name: anonymous
 
* Press 'Fetch list...' button. It'll connect with CVS server to get all the names of active modules.
 
** As this is the very first time you connect to the server you'll be asked a password. The password for anonymous user is also '''anonymous''' (in low case).
 
** From the drop list now you can select the module you want to download.
 
*** '''fs2_open''' is the repository for FS2 source code. (You could also have typed it in the 'Module:' textbox).
 
* If you press OK button, source code download will begin in the folder you've selected. A '''fs2_open''' subfolder will be created inside it.
 
* By default, the HEAD branch, which contains the developement (and maybe pretty unstable) code, will be downloaded. If you want to checkout the current stable branch rather than this development branch (since you don't have write access you probably should go with the stable build so that that more of the bugs you encounter are your own fault), you should change the Branch or Tag options:
 
** Before pressing OK button switch to 'Revision' tab (the second one). (You should be in the first one, 'Module' tab).
 
** Click on the 'Choose Branch or Tag' option. Press the Update List button. TortoiseCVS will then connect to the server and get a list of revisions.
 
** In the "Branch or Tag Name" dropdown you can now see a list of branches that CVS contains. '''fs2_open_3_6_9''' is probably the one you want.
 
** Press OK now.
 
* Of course, you can set up different checkouts in different folders. Just repeat these steps.
 
* If you want to update any of the previously downloaded code, go to the container folder, right click over '''fs2_open''' folder (or any other one) and select '''CVS Update''' option.
 
  
== Freespace2 Code Base ==
+
For information on each library, look in the respective README files.
  
The root directory contains the following external libraries (See msdn.microsoft.com for discussion of the DirectX libraries; for the other libraries, look in the README files for more info):
+
== FreeSpace 2 Source Code ==
* lua: LUA Scripting language
 
* libjpeg: Jpeg library
 
* oggvorbis: Ogg Vorbis sound library
 
* dx8sdk: DirectX 8 SDK
 
* dx9sdk: DirectX 9 SDK
 
  
The root also contains the actual Freespace2 code, in the code/ directory. The Freespace2 source code consists in several components, each of which is kept in a separate subdirectory. These components are listed below.
+
The root also contains the actual FreeSpace 2 code, in the code/ directory. The FreeSpace 2 source code consists of several components, each of which is kept in a separate subdirectory. These components are listed below from different views.
  
=== Alphabetical view ===
+
=== Alphabetical View ===
  
* ai (Computer AI)
+
* [[Source ai|ai]] (Computer AI)
 
* [[Source anim|anim]] (Displaying .ani animated bitmaps)
 
* [[Source anim|anim]] (Displaying .ani animated bitmaps)
* asteroid (Handle asteroids - movement, collisions, creating smaller asteriods when larger ones are blown up etc.)
+
* asteroid (Handle asteroids - movement, collisions, creating smaller asteroids when larger ones are blown up etc.)
 
* autopilot (Handles autopilot control - where if there are no enemies, travelling a long distance etc. control is temporarily switched to the computer)
 
* autopilot (Handles autopilot control - where if there are no enemies, travelling a long distance etc. control is temporarily switched to the computer)
 
* [[Source bmpman|bmpman]] (Manage 2d graphics files, such as .bmp, .tga, .jpg etc.)
 
* [[Source bmpman|bmpman]] (Manage 2d graphics files, such as .bmp, .tga, .jpg etc.)
* camera (???)
+
* camera (used for ingame cutscenes ???)
* cfile (File/directory management routines including .VP file handling that are OS independent eg. handles differences between Linux & Windows)
+
* cfile (File/directory management routines including .VP file handling that are OS independent e.g. handles differences between Linux & Windows)
 
* cmdline (Handles command line switches, such as -mipmap etc.)
 
* cmdline (Handles command line switches, such as -mipmap etc.)
 
* cmeasure (Handles countermeasures - flares that the player & AI can drop to disrupt missiles)
 
* cmeasure (Handles countermeasures - flares that the player & AI can drop to disrupt missiles)
Line 59: Line 39:
 
* fireball (Displays & handles fireballs and warping effects)
 
* fireball (Displays & handles fireballs and warping effects)
 
* freespace2 (Main code - handles engine initialisation, loading resources, plus windows resources like icons & dialog boxes)
 
* freespace2 (Main code - handles engine initialisation, loading resources, plus windows resources like icons & dialog boxes)
* fs2open_pxo (Network code)
+
* fs2netd (Game matchmaker network client code)
 
* gamehelp (Displays context sensitive help text)
 
* gamehelp (Displays context sensitive help text)
 
* gamesequence (Handles progression of events during a campaign, such as entering a mission, showing credits etc.)
 
* gamesequence (Handles progression of events during a campaign, such as entering a mission, showing credits etc.)
Line 65: Line 45:
 
* globalincs (Basic global constants & definitions, eg. version, colours)
 
* globalincs (Basic global constants & definitions, eg. version, colours)
 
* [[Source graphics|graphics]] (Low-level wrapper for all 2d & 3d graphics that handles different display engines (DirectX, OpenGL etc)
 
* [[Source graphics|graphics]] (Low-level wrapper for all 2d & 3d graphics that handles different display engines (DirectX, OpenGL etc)
* hud (Handles the HUD - all the 2d cockpit graphics that the player can see eg. radar, ammo, escort list, sqaud etc)
+
* hud (Handles the HUD - all the 2d cockpit graphics that the player can see e.g. radar, ammo, escort list, squad etc)
* iff_defs (Handles traitor ships???)
+
* iff_defs (Handles the iffs in [[iff_defs.tbl]], controlling what color they show up as and what iffs they attack)
 
* io (Handles IO devices, such as keyboard, mouse & joystick)
 
* io (Handles IO devices, such as keyboard, mouse & joystick)
 
* irc (Adds support for an IRC chat client)
 
* irc (Adds support for an IRC chat client)
 
* [[Source jpgutils|jpgutils]] (Opens, reads JPG files)
 
* [[Source jpgutils|jpgutils]] (Opens, reads JPG files)
 
* jumpnode (Displays & handles jump nodes)
 
* jumpnode (Displays & handles jump nodes)
* lab (???)
+
* lab (Responsible for WMCoolmon's F3 lab screen)
 
* lighting (Handles light sources, and their effect on ships)
 
* lighting (Handles light sources, and their effect on ships)
 
* localization (Handles a global string table for translating all written text into foreign languages)
 
* localization (Handles a global string table for translating all written text into foreign languages)
 
* math (Library of math routines for handling vectors, splines etc)
 
* math (Library of math routines for handling vectors, splines etc)
 
* menuui (Handles all the misc user interface, such as the main menu, tech room, campaign list etc)
 
* menuui (Handles all the misc user interface, such as the main menu, tech room, campaign list etc)
* mission (Handles general mission actions eg. briefing, goals, training info, in-mission messages etc)
+
* mission (Handles general mission actions e.g. briefing, goals, training info, in-mission messages etc)
 
* missionui (Handles UI for general mission actions)
 
* missionui (Handles UI for general mission actions)
 
* mm (Headers for older MS Multimedia library)
 
* mm (Headers for older MS Multimedia library)
* model (Displays and handles ship models eg. reading files, collission detection etc)
+
* model (Displays and handles ship models e.g. reading files, collision detection etc)
 
* nebula (Displays and handles nebulae)
 
* nebula (Displays and handles nebulae)
* network (All multi-player code, eg. UI, network traffic)
+
* network (All multi-player code, e.g. UI, network traffic)
 
* object (High-level code to handle all objects eg. ships, weapons, debris, asteroids, waypoints, fireballs, shockwaves)
 
* object (High-level code to handle all objects eg. ships, weapons, debris, asteroids, waypoints, fireballs, shockwaves)
* observer (???)
+
* observer (Responsible for the multiplayer observer mode)
 
* osapi (Wraps low-level Operating System calls, for different OS, eg. multi-threads, windows event loops, main app window)
 
* osapi (Wraps low-level Operating System calls, for different OS, eg. multi-threads, windows event loops, main app window)
 +
* padlock (Handles cockpit views with a simulated head tracking of targets relative to the ship)
 
* palman (Handles bitmap palettes - different colour maps for the same 2d bitmap)
 
* palman (Handles bitmap palettes - different colour maps for the same 2d bitmap)
 
* parse (Handles scripting files, eg. python, LUA etc)
 
* parse (Handles scripting files, eg. python, LUA etc)
Line 91: Line 72:
 
* physics (Handles realistic physical behaviour of objects, such as ship acceleration/deceleration, rotation etc.)
 
* physics (Handles realistic physical behaviour of objects, such as ship acceleration/deceleration, rotation etc.)
 
* playerman (Handles pilot files & player ship movement)
 
* playerman (Handles pilot files & player ship movement)
* popup (Displays & handles 2d pop-up windows, eg. when the player dies)
+
* popup (Displays & handles 2d pop-up windows, e.g. when the player dies)
 
* radar (Displays & handles the radar)
 
* radar (Displays & handles the radar)
 
* [[Source render|render]] (Low-level 3d rendering code for some primitives)
 
* [[Source render|render]] (Low-level 3d rendering code for some primitives)
* ship (Displays & handles all ship code, eg. shields, afterburner)
+
* ship (Displays & handles all ship code, e.g. shields, afterburner)
* sound (Low-level sound, speach & music routines)
+
* sound (Low-level sound, speech & music routines)
 
* species_defs (Reads species_defs.tbl to handle different behaviour for different species)
 
* species_defs (Reads species_defs.tbl to handle different behaviour for different species)
 
* starfield (Displays & handles background images such as starfields, nebulae etc)
 
* starfield (Displays & handles background images such as starfields, nebulae etc)
 
* stats (Displays & handles player statistics, medals etc)
 
* stats (Displays & handles player statistics, medals etc)
 
* [[Source tgautils|tgautils]] (Handles .tga 2d graphics files)
 
* [[Source tgautils|tgautils]] (Handles .tga 2d graphics files)
* ui (Low-level user inteface routines eg. buttons, scrollbars)
+
* ui (Low-level user inteface routines e.g. buttons, scrollbars)
 
* vcodec (Handles player voice streaming for multiplayer ???)
 
* vcodec (Handles player voice streaming for multiplayer ???)
 
* weapon (Displays & handles everything to do with weapons)
 
* weapon (Displays & handles everything to do with weapons)
Line 115: Line 96:
 
* wxfred2 (Cross-platform version of FRED2)
 
* wxfred2 (Cross-platform version of FRED2)
  
=== Layer view ===
+
=== Layer View ===
  
 
* Infrastructure
 
* Infrastructure
Line 133: Line 114:
 
*** windows_stub/
 
*** windows_stub/
 
** 2D graphics
 
** 2D graphics
*** anim/
+
*** [[Source anim|anim]]
*** bmpman/
+
*** [[Source bmpman|bmpman]]
*** ddsutils/
+
*** [[Source ddsutils|ddsutils]]
*** tgautils/
+
*** [[Source jpgutils|jpgutils]]
*** jpgutils/
+
*** [[Source pcxutils|pcxutils]]
*** pcxutils/
+
*** [[Source tgautils|tgautils]]
 
*** palman/
 
*** palman/
 
** 3D graphics
 
** 3D graphics
Line 144: Line 125:
 
*** mm/
 
*** mm/
 
*** directx/
 
*** directx/
*** graphics/
+
*** [[Source graphics|graphics]]
 
*** camera/
 
*** camera/
*** render/
+
*** [[Source render|render]]
 
** User Input
 
** User Input
 
*** controlconfig/
 
*** controlconfig/
Line 157: Line 138:
 
*** debugconsole/
 
*** debugconsole/
 
** In Space
 
** In Space
*** ai/
+
*** [[Source ai|ai]]
 
*** asteroid/
 
*** asteroid/
 
*** autopilot/
 
*** autopilot/
Line 206: Line 187:
 
** variables/
 
** variables/
  
==Category Browser==
+
=== Category Browser ===
 
The subdirectories above are also categorised by function. See the Category:Source Code to browse this way.
 
The subdirectories above are also categorised by function. See the Category:Source Code to browse this way.
  
 
[[Category:Source Code]]
 
[[Category:Source Code]]

Latest revision as of 05:30, 3 May 2015

External Libraries

FreeSpace 2 relies on the following libraries which are included in the source tree:

  • jansson: JSON library
  • libjpeg: JPEG library
  • libpng: PNG library
  • lua: LUA Scripting language
  • mongoose: HTTP server library
  • oggvorbis: Ogg Vorbis sound library
  • openal: OpenAL sound library
  • zlib: ZIP compression library; necessary for libpng

For information on each library, look in the respective README files.

FreeSpace 2 Source Code

The root also contains the actual FreeSpace 2 code, in the code/ directory. The FreeSpace 2 source code consists of several components, each of which is kept in a separate subdirectory. These components are listed below from different views.

Alphabetical View

  • ai (Computer AI)
  • anim (Displaying .ani animated bitmaps)
  • asteroid (Handle asteroids - movement, collisions, creating smaller asteroids when larger ones are blown up etc.)
  • autopilot (Handles autopilot control - where if there are no enemies, travelling a long distance etc. control is temporarily switched to the computer)
  • bmpman (Manage 2d graphics files, such as .bmp, .tga, .jpg etc.)
  • camera (used for ingame cutscenes ???)
  • cfile (File/directory management routines including .VP file handling that are OS independent e.g. handles differences between Linux & Windows)
  • cmdline (Handles command line switches, such as -mipmap etc.)
  • cmeasure (Handles countermeasures - flares that the player & AI can drop to disrupt missiles)
  • controlconfig (Configures keyboard/mouse/joystick controls)
  • cutscene (Handles cutscene viewing)
  • ddsutils (Handles compressed textures for 3d graphics cards that support it)
  • debris (Creates & handles flying debris from exploding ships)
  • debugconsole (Handles debugging console and file)
  • decals (Adds support for painting decals - small 2d textures - onto ships etc.)
  • demo (Allows you to save & playback games to show as demos)
  • directx (Specific includes for the Microsoft DirectX library - Windows only)
  • exceptionhandler (Deals with crashes, saving stack trace, system info etc.)
  • fireball (Displays & handles fireballs and warping effects)
  • freespace2 (Main code - handles engine initialisation, loading resources, plus windows resources like icons & dialog boxes)
  • fs2netd (Game matchmaker network client code)
  • gamehelp (Displays context sensitive help text)
  • gamesequence (Handles progression of events during a campaign, such as entering a mission, showing credits etc.)
  • gamesnd (Handles sounds & music)
  • globalincs (Basic global constants & definitions, eg. version, colours)
  • graphics (Low-level wrapper for all 2d & 3d graphics that handles different display engines (DirectX, OpenGL etc)
  • hud (Handles the HUD - all the 2d cockpit graphics that the player can see e.g. radar, ammo, escort list, squad etc)
  • iff_defs (Handles the iffs in iff_defs.tbl, controlling what color they show up as and what iffs they attack)
  • io (Handles IO devices, such as keyboard, mouse & joystick)
  • irc (Adds support for an IRC chat client)
  • jpgutils (Opens, reads JPG files)
  • jumpnode (Displays & handles jump nodes)
  • lab (Responsible for WMCoolmon's F3 lab screen)
  • lighting (Handles light sources, and their effect on ships)
  • localization (Handles a global string table for translating all written text into foreign languages)
  • math (Library of math routines for handling vectors, splines etc)
  • menuui (Handles all the misc user interface, such as the main menu, tech room, campaign list etc)
  • mission (Handles general mission actions e.g. briefing, goals, training info, in-mission messages etc)
  • missionui (Handles UI for general mission actions)
  • mm (Headers for older MS Multimedia library)
  • model (Displays and handles ship models e.g. reading files, collision detection etc)
  • nebula (Displays and handles nebulae)
  • network (All multi-player code, e.g. UI, network traffic)
  • object (High-level code to handle all objects eg. ships, weapons, debris, asteroids, waypoints, fireballs, shockwaves)
  • observer (Responsible for the multiplayer observer mode)
  • osapi (Wraps low-level Operating System calls, for different OS, eg. multi-threads, windows event loops, main app window)
  • padlock (Handles cockpit views with a simulated head tracking of targets relative to the ship)
  • palman (Handles bitmap palettes - different colour maps for the same 2d bitmap)
  • parse (Handles scripting files, eg. python, LUA etc)
  • particle (Displays and handles particles, such as smoke, fire)
  • pcxutils (Handles 2d .pcx graphics files)
  • physics (Handles realistic physical behaviour of objects, such as ship acceleration/deceleration, rotation etc.)
  • playerman (Handles pilot files & player ship movement)
  • popup (Displays & handles 2d pop-up windows, e.g. when the player dies)
  • radar (Displays & handles the radar)
  • render (Low-level 3d rendering code for some primitives)
  • ship (Displays & handles all ship code, e.g. shields, afterburner)
  • sound (Low-level sound, speech & music routines)
  • species_defs (Reads species_defs.tbl to handle different behaviour for different species)
  • starfield (Displays & handles background images such as starfields, nebulae etc)
  • stats (Displays & handles player statistics, medals etc)
  • tgautils (Handles .tga 2d graphics files)
  • ui (Low-level user inteface routines e.g. buttons, scrollbars)
  • vcodec (Handles player voice streaming for multiplayer ???)
  • weapon (Displays & handles everything to do with weapons)
  • windows_stub (Low-level windows functions that are needed for Unix)

There are also some directories that are only used for generating tools (not part of the main fs2 executable):

  • cfilearchiver (Creates .VP file archives)
  • cfileextractor (Extracts .VP file archives)
  • cryptstring (Creates encrypted strings)
  • fred2 (The FReespace EDitor)
  • inetfile (FTP & HTTP network handlers)
  • scramble (Utility to scramble file tables for the Demo version)
  • variables (???)
  • wxfred2 (Cross-platform version of FRED2)

Layer View

  • Infrastructure
  • Freespace2
    • Common
      • globalincs/
      • cutscene/
      • cmdline/
      • debugconsole/
    • In Space
      • ai
      • asteroid/
      • autopilot/
      • cmeasure/
      • debris/
      • demo/
      • fireball/
      • gamehelp/
      • gamesequence/
      • gamesnd/
      • hud/
      • iff_defs/
      • jumpnode/
      • lighting/
      • nebula/
      • object/
      • observer/
      • model/
      • network/
      • particle/
      • parse/
      • popup/
      • physics/
      • radar/
      • ship/
      • species_defs/
      • starfield/
      • weapon/
    • In Base
      • stats/
      • menuui/
      • mission/
      • missionui/
    • Engine
      • fs2open_pxo/
      • freespace2/
      • playerman/
  • FRED
    • fred2/
    • wxfred2/
  • Tools
    • cfilearchiver/
    • cfileextractor/
    • cryptstring/
    • lab/
    • scramble/
    • inetfile/
    • variables/

Category Browser

The subdirectories above are also categorised by function. See the Category:Source Code to browse this way.