-
Notifications
You must be signed in to change notification settings - Fork 218
Internals
YVT edited this page Nov 11, 2016
·
8 revisions
TODO: A block diagram for this would be really cool.
OpenSpades is made of several important components. Here's a partial list of them:
- Core
- [C++] Dispatch Queue - distributes given tasks to multiple CPU cores. Similar to OS X's Grand Central Dispatch.
- [C++] Backtrace Tracker - traces function calls to provide activation records (backtrace) in case of an unexpected error.
- [C++] <- AS Settings - manages configuration variables (aka cvars).
- [C++] File Manager - manages access to multiple file systems.
- [C++] File System - abstracts one directory tree.
- [C++] Bitmap Codec - Decodes/encodes bitmap images.
- [C++] Stream - abstract class which involves the following fundamental operations: read/write/seeking.
- [C++] Audio Stream - a read-only stream that is used to decode audio data.
- Presentation Layer (interface between code and user)
- [C++] <- AS Audio Device - receives audio commands and plays sound. An audio device might use the spatial structure of the game map for better auralization.
- [C++] <- AS Renderer - receives renderer commands, draws everything needed, and shows the rendered off-screen image to the user. This is implemented using C++ code, though this is accessible by the script. Script needs a handle to the renderer to access.
- [C++] Runner - creates renderer and audio device, and pass them to the initial view. A runner also handles input events that comes from the window system and converts them into the format that views accept.
- Abstract User Interfaces
- [C++] View - (new in 0.0.10) an abstract object that is responsible for receiving input events and managing operations that is required to do in each frame. A view might delegate some events to the subview. Note that although some views let script handle events, views are not accessible from script.
- [AS] UI Framework - simple GUI toolkit designed to work on the renderer interface.
- [C++] <- AS Font
- World Objects
- [C++] World - encapsulates the state of the game world.
- [C++] <- AS Game Map - encapsulates the state of game map.
- [C++] Game Map Wrapper - mediates the access to the game map for floating-block detection.
- [C++] Player - encapsulates the behavior of a connected player.
- Game Logic
- [C++] Client
- [C++] Network Client
- [C++] Client Player - encapsulates the visual of a connected player. If the player is Model of MVC, the client player would be View.
- [C++] Local Entity - Client-side object that has no corresponding in the server-side. This includes grenade smoke and tracers.
Legends: [C++] = implemented using C++, <- AS = accessible from script
0.0.9:
- Game executable is loaded by the operating system, initializing some data sections.
- List of script-visible objects is created using the constructor of
ScriptRegistrar
. - Now we enters
main
function. - Core features (backtrace tracker, dispatch queue) are initialized.
- Read-write file systems to access non-compressed resources are initialized.
- Now writable file systems are ready, so we start recording output messages (
SPLog
) to the log file. - Pak files are scanned, sorted, and registered as zip read-only file systems.
- Script engine is initialized. All script-visible objects are registered to the script engine.
- FLTK is initialized.
- Main window is created and becomes visible.
- OpenGL capability is checked by creating a small OpenGL renderable window.
- User clicks the connect button.
- A runner is created.
- The runner initializes SDL, renderer, and audio device. At this time, renderer only initializes 2D rendering subsystem.
- The runner creates client by passing the created renderer/audio device objects.
- The client loads some images to render the loading screen.
- The client initializes in-game UIs.
- The client draws the loading screen.
- The client asks the renderer for the full initialization.
- The client creates a network client and initiates the connection to the AoS server.
- During this, ENet library is initialized. And then ENet host object is created.
- After receiving the map data, the network client decompress and decode the map data.
- The network client creates a world object by passing the map.
- The network client creates player objects and registers them to the world object.
- The network client gives the world object to the client.
- The client gives the map of the world object to the renderer and the audio device.
- The renderer initializes map-rendering subsystems.
- The renderer registers itself as a game map listener.
- The client creates the client player objects that correspond to the player objects.
- The client player invokes the skin script to create the skin renderer.
- The limbo window and scoreboard is displayed.
- User selects a team and weapon.
-
ExistingPlayer
packet is sent to the server. - The server sends
CreatePlayer
andStateData
packets which include the local player index. - The client player is created for the new local player.
- Main Window - startup window that allows users to configure the graphics options and access server lists. This is implemented using FLTK, not through the renderer interface nor UI Framework.
- Main Screen - new startup screen implemented in 0.0.10. As the main window, this also contains server lists and options, but configurable options are restricted because the renderer is already initialized when the main screen is loaded. This is implemented using UI Framework.
- Setup - new quick config screen implemented in 0.0.10. This is implemented using UI Framework.
- In-game Menu - new menu window implemented in 0.0.10. This is accessible by hitting ESC during the game. This is implemented using UI Framework.
- Say Window - This used to be implemented using C++, however, in 0.0.10 this is implemented using UI Framework.
- Scoreboard - implemented using C++
- Limbo Screen - Weapon/team switcher implemented using C++.
This wiki is in the middle of an update process to match the latest changes of OpenSpades 0.1.2
It may contain outdated, incorrect or incomplete information.
Please contact the repository owner (@yvt) via email or ask a question in the issue tracker if there is any obscure information you are looking for that can't be found in neither the source code nor in this wiki.