How Jedi-Academy-master Works: Architecture, System Design & Code Deep Dive
Project Overview
The Jedi-Academy-master project represents a comprehensive C++ game engine and client application for the Star Wars Jedi Knight: Jedi Academy game. It supports both single-player and multiplayer gameplay, providing an interactive user interface for navigating menus, configuring game settings, and engaging in lightsaber-centric combat within its 3D world. Users interact with the client application to experience story-driven campaigns or competitive online matches, while core engine utilities manage global state, rendering, and game logic across both modes.
- Category
- Game
- Difficulty
- Advanced
- Tech Stack
- C++
- Tags
- example, tutorial
How Jedi-Academy-master Works
The Jedi-Academy-master project represents a comprehensive C++ game engine and client application for the Star Wars Jedi Knight: Jedi Academy game. It supports both single-player and multiplayer gameplay, providing an interactive user interface for navigating menus, configuring game settings, and engaging in lightsaber-centric combat within its 3D world. Users interact with the client application to experience story-driven campaigns or competitive online matches, while core engine utilities manage global state, rendering, and game logic across both modes.
Data Flow
Data flow initiates from the operating system, captured by `win_main.cpp` for window and input events. These events are processed by `cl_main.cpp`, which manages the client-side state, UI logic, and translates user input into game commands. For single-player, `cl_main.cpp` directly communicates with the in-process game logic module `g_main.cpp` which acts as the authoritative 'server' for the game world, updating entity states, processing combat (`g_combat.cpp`, `wp_saber.cpp`), and managing NPCs (`NPC.cpp`). The updated game state is then passed back to `cl_main.cpp` for rendering. For multiplayer, `cl_main.cpp` serializes input and state requests and sends them over the network to a dedicated `sv_main.cpp` server, which hosts the authoritative `g_main.c` game logic. The server processes these, updates its authoritative state, and sends relevant world updates back to connected clients. Both single-player and multiplayer client `cl_main.cpp` modules then feed rendering data (scene geometry, textures, animations) to `code/renderer/tr_main.cpp`. This renderer module, leveraging functions like `R_CullLocalBox`, processes and culls objects for optimal display, sending commands to the graphics API for final presentation on screen. `qcommon/common.cpp` serves as a central hub for shared data structures, configurations, and utility functions that are accessed across all modules.
Architecture & System Design
System Context
C4Context title Business Context - Jedi-Academy-master Person(client, "Client", "Interacts with the system") Person(user, "User", "Interacts with the system") Enterprise_Boundary(system, "Jedi-Academy-master") { System(app, "Jedi-Academy-master", "The Jedi-Academy-master project represents a comprehensive C++ game engine and client application fo") } System_Ext(database, "Database", "Integration with database services") System_Ext(storage, "Storage", "Integration with storage services") System_Ext(api_services, "API Services", "Integration with api services services") Rel(client, app, "Uses system to achieve goals") Rel(user, app, "Uses system to achieve goals") Rel(app, database, "Integrates with") Rel(app, storage, "Integrates with") Rel(app, api_services, "Integrates with") %% Revibe Brand Styling UpdateRelStyle(client, app, $textColor="#000000", $lineColor="#00f5ff", $offsetX="5") UpdateRelStyle(user, app, $textColor="#000000", $lineColor="#ff006e", $offsetX="10") UpdateRelStyle(app, database, $textColor="#000000", $lineColor="#00f5ff", $offsetX="10") UpdateRelStyle(app, storage, $textColor="#000000", $lineColor="#ff006e", $offsetX="15") UpdateRelStyle(app, api_services, $textColor="#000000", $lineColor="#8338ec", $offsetX="20")
Key Modules & Components
- Application Lifecycle Management: Handles the initialization, execution, and termination of the Jedi Academy client application, including system-level interactions and executable integrity checks.
Key files: code/win32/win_main.cpp, codemp/win32/win_main.cpp - Client-Server Communication and Game State Orchestration: Manages client-server connections, command processing, client-side state, and UI/rendering updates, enabling users to interact with the game world.
Key files: code/client/cl_main.cpp, codemp/client/cl_main.cpp - Core Game World Simulation: Implements the game's rules, entity management, AI behavior, and physics, defining how the game world evolves over time.
Key files: code/game/g_main.cpp, codemp/game/g_main.c - Multiplayer Server Management and Network Synchronization: Manages server-side game state, client connections, network communication, and game world synchronization, enabling multiplayer gameplay.
Key files: code/server/sv_main.cpp, codemp/server/sv_main.cpp - Engine Utility and Global State Management: Provides core utility functions and manages global engine state, facilitating inter-component communication and consistent engine behavior across the application.
Key files: code/qcommon/common.cpp, codemp/qcommon/common.cpp - Lightsaber Combat and Force Power System: Implements the unique lightsaber combat mechanics and Force abilities, defining the core gameplay experience of Jedi combat.
Key files: code/game/wp_saber.cpp, codemp/game/w_saber.c, code/game/g_combat.cpp
Explore the full interactive analysis of Jedi-Academy-master on Revibe — architecture diagrams, module flow, execution paths, and code-level insights.