How sardonyx-forks/commonlibvr works
This project is a C++ library designed to support Skyrim plugin development by providing reverse‐engineered wrappers for Skyrim’s internal classes and systems. It is essentially an evolution of CommonLibSSE (for Skyrim Special Edition) that now also supports Skyrim VR. It serves as a static dependency for SKSE and SKSEVR plugins, abstracting various internal details (memory addresses, game interfaces, etc.) via its “RE” (reverse engineered) components. In addition, the project includes a Flash/AS2 GUI component and a set of build system files (using CMake, vcpkg, and related scripts) to manage presets for both SSE and VR builds.
Main Components
• Build & Configuration Subsystem:
– CMakeLists.txt, CMake presets (vs2022-windows-vcpkg and vs2022-windows-vcpkg-vr), xmake files, and scripts in the “scripts” folder.
– Vcpkg integration and other configuration files (.clang-format, .gitignore, etc.)
• Core Library Modules:
– “include” directory which houses extensive header files (especially under include/RE and its subdirectories) defining reverse-engineered SKSE interfaces, game object wrappers, and utility functions.
– “src” directory which implements the library; note the organization by modules like RE/A, RE/B, … RE/Z, etc.
• Graphical/User Interface Components:
– The “Flash” folder, particularly the Flash/AS2/CLIK directory which contains ActionScript files for GUI controls (e.g., Button, Dialog, TextInput).
• External Dependencies and Integration:
– External submodules like “extern/openvr” (for VR-specific functionality).
– Dependencies on third-party libraries such as spdlog, fmt, and binary_io.
• SKSE/SKSEVR Integration Layer:
– Folders like “SKSE” (and related files) are used to interface with the runtime components in Skyrim.
– Also, include the REL, REX, and other system interface wrappers that abstract OS-level or game-engine level functionality.
Relationships and Flow
• The Build & Configuration subsystem sits at the top, controlling how all modules are compiled and linked.
• External dependencies (vcpkg, spdlog, fmt, OpenVR, etc.) are injected during the build configuration phase.
• The Core Library (header “include” and their corresponding “src” implementations) forms the heart of the system. Modules under “RE” are organized (for example, RE/A, RE/B,… RE/T, etc.) and interact to expose game functionalities.
• The Flash UI components are an auxiliary module that interacts with the core via specific interfaces (possibly exposing visual elements to in-game plugins).
• Finally, the library exposes abstraction layers that integrate with SKSE and SKSEVR. In the build flow, there are separate presets that compile everything for either Skyrim SE or Skyrim VR.
Architectural Patterns
• Modularity: The project is decomposed into a number of well-organized modules (by reverse-engineered game subsystems, UI components, and external integration).
• Layering: There are clear layers from low-level interfacing (RE, REL, REX, SKSE) up to higher-level UI (Flash/AS2) and build configuration.
• Dependency Injection: External libraries and configuration files are managed centrally through CMake and vcpkg, ensuring that dependencies are injected into the build processes.
• Abstraction: The reverse-engineered “RE” modules act as an abstraction layer that hides the internal complexities of Skyrim’s engine from the plugin developers.