How fwgs/xash3d-fwgs works
Project type and purpose
• This is a cross‑platform, modular C/C++ game engine (“Xash3D FWGS”) compatible with the Half‑Life engine and extensible by game developers. It includes core simulation, client‑side rendering and audio, a headless server, a virtual filesystem, multiple rendering backends, platform abstraction layers, and an Android UI wrapper.
File structure
• Top‑level modules:
• engine/ (core client, common, server, platform code)
• ref/ (renderer backends: OpenGL, GLES, software, null)
• filesystem/ (VFS implementation, .pak/.wad/.zip support, tests)
• public/ (shared libraries, utilities, unit tests)
• pm_shared/ (player‑movement definitions)
• game_launch/ (native Windows launcher UI)
• android/ (Android application wrapper, UI, services)
• 3rdparty/ (embedded external libs: bzip2, libogg, vorbis, opus, etc.)
• scripts/ & waf*/ (build and CI automation)
• Build system: Waf (wscript), CI scripts (.cirrus.yml, GitHub workflows).
• Platform abstraction: engine/platform/* (android, linux, win32, posix, etc.).
README for additional insights
• Explicit support for multiple renderers (OpenGL, GLESv1/v2, software).
• Virtual filesystem with .pk3/.pk3dir, case‑insensitive emulation.
• Server supports IPv6, voice chat, headless mode.
• Mobility API for touch, vibration.
• Build instructions emphasize waf configure/build on many platforms.
• Core Engine
• Simulation & game logic (engine/common, server, client)
• Networking & master servers
• Virtual filesystem (filesystem/)
• Plugin interfaces (render_api.h, eiface.h, vgui_api.h)
• Client Subsystem
• Input subsystem (keyboard, mouse, touch, gamepad)
• Audio subsystem (soundlib, Ogg/Opus, MP3)
• UI & VGUI (mainui_cpp)
• Renderer interface
• Renderer Backends (implement RenderAPI)
• OpenGL (ref/gl)
• GLESv1/GLESv2 (ref/gl4es, gl-wes-v2)
• Software rasterizer (ref/soft)
• Null renderer (ref/null)
• Server Subsystem
• Headless game server (engine/server)
• Voice chat, master‑server listing
• Platform Abstraction Layer
• OS-specific glue (engine/platform/*)
• File I/O, dynamic loading, threading, system calls
• Android UI Wrapper
• Java/Kotlin app (android/app/src)
• JNI bridge to native engine
• External/3rd‑party libraries
• Compression (bzip2, miniz)
• Audio (vorbis, opus)
• Backtrace, font, etc.
• Build & CI
• Waf build scripts, CI pipelines, cross‑compile scripts
b. Relationships & data flows
• Client → Core Engine: input events, requests simulation updates
• Core Engine → VFS: file loading (.pk3, .wad)
• Core Engine → Audio: play sounds/music
• Core Engine ↔ Server: game state replication over network
• Platform Layer underpins Client, Server, VFS, Renderer, Audio
• Android UI → JNI Bridge → Native Engine
• Build System orchestrates compilation of all C/C++ modules and Android wrapper
c. Architectural patterns & principles
• Modular “plugin” backends for rendering (Strategy pattern)
• Clear separation of concerns: engine core vs. platform vs. render vs. filesystem
• Abstraction layers for cross‑platform portability
• Use of virtual interfaces (RenderAPI, IFileSystem)
d. Key technologies & libraries
• C/C++ codebase, Waf build system
• OpenGL / GLES / software rasterization
• SDL2 for windowing/input on desktops
• JNI, Android SDK + Gradle for Android target
• Ogg Vorbis, Ogg Opus, libmpg for audio
• ZIP, BZ2 support via embedded libs
Detail
• Every subsystem (client, server, filesystem, renderers, platform, Android UI, third‑party).
• Interface boundaries (e.g., RenderAPI, IFileSystem).
• Keep it hierarchical: high‑level blocks drill down into major submodules.