How stjr/srb2 works
Project type and purpose
• Project: Sonic Robo Blast 2 (SRB2), a 3D Sonic the Hedgehog fangame and game engine derived from Doom Legacy.
• Purpose: real-time game simulation—rendering, audio, physics, input, networking—cross-platform (Windows, Linux, macOS, Android) in C/C++ with scripting support (Lua).
File structure
Top-level directories:
• src/ – core engine source, subdivided into:
– hardware/ & r_opengl/ – renderer and graphics pipeline
– sdl/ & android/ & win32/ – platform abstraction layers, entry points
– netcode/ – multiplayer client/server logic
– blua/ & lua_*.c/h – embedded Lua scripting
– dedicated/, dummy/ – server-only or headless builds
– modules: audio (s_sound.c), input (g_input.c), game logic (g_game.c), etc.
• libs/ – vendored third-party static libraries (SDL2, SDL2_mixer, libupnp, libgme, libopenmpt, libpng, zlib, curl, miniupnpc, iconv, etc.).
• android/ – Eclipse/NDK project wrapper for Android port.
• thirdparty/ – CMake toolchains and patches to download/build dependencies.
• cmake/, scripts/ – build system modules, custom CMake macros and presets.
• tools/ – auxiliary utilities (level converter, IRC bot, master server, wad tools…).
• deployer/, .circleci/, .gitlab/ci/, .travis.yml, appveyor.yml – CI/CD pipelines and deployment scripts.
• assets/ – data packaging templates and resource licenses.
• doc/ – specs, documentation.
Extract insights from README
• Core dependencies: SDL2, SDL2-Mixer, libupnp, libgme, libopenmpt on Linux/macOS.
• Multi-platform engine with optional modules (audio backends, networking, dedicated server).
• CI pipelines build on many OS/config permutations.
a. Game Engine Core
– Sub-modules: Game Logic, Physics, Resource Manager, Scripting (Lua).
b. Rendering System
– hardware/r_opengl pipeline, platform-specific window/context creation via SDL or native APIs.
c. Audio System
– s_sound layer → SDL2_Mixer + streaming modules (libgme, libopenmpt)
d. Input System
– g_input layer → SDL2 or platform-raw events
e. Networking System
– netcode module: server/client, protocols, master-server integration (tools/masterserver).
f. Platform Abstraction Layer
– src/sdl, src/android, src/win32 front-ends → call into Core & subsystems
g. Third-Party Libraries
– static link libs in libs/ and via thirdparty/vcpkg overlays
h. Build & CI Pipeline
– scripts/, cmake/, deployer/, .circleci/, .gitlab/, .travis.yml, appveyor.yml
Relationships and interactions
– Game Logic ↔ Scripting (Lua).
– Game Logic ↔ Physics & Collision.
– Network module ↔ Game Logic (synchronize state).
– Core ↔ Platform Layer (windowing, threads, timers).
– All subsystems call into or link against Third-Party Libraries.
– Build System drives compilation of src/, thirdparty, and links libs/.
Architectural patterns / design principles
• Modular separation: core engine vs. platform vs. subsystems.
• Abstraction layers for portability (SDL vs. native).
• Plugin-style scripting (embedded Lua).
• Client-server model in netcode.
• Conditional builds: dedicated, headless, Android APK, Windows exe.
Essential elements
– Component labels (e.g., “Netcode Module”, “Lua VM”).
– Build pipeline overview: CMake → SRC compile + thirdparty → link → package → CI jobs.
Final advice
• Platform variants (SDL front-end, dedicated server, Android).
• Don’t overload with file names—focus on modules and subsystems.
• Use layering and grouping to convey architecture depth.
• Iterate with your team to refine interactions and update as new modules appear.