Surreal Engine Documentation
repository·master·Indexed 21 days ago
https://github.com/dpjudas/surrealengineA reimplementation of Unreal Engine 1 designed to make original UE1 titles, such as Unreal (Gold) and Unreal Tournament (UT99), playable on modern Windows 10+ and Linux systems. The project includes SurrealGPU for low-level graphics, SurrealVideo for lightweight indeo5 codec support, and SurrealWidgets for cross-platform UI development.
What's inside Surreal Engine
- SurrealGPU is a GPU graphics library designed for use within the Surreal Engine ecosystem. It provides the low-level graphics capabilities required for rendering.
Overview of Crypto++ Cryptographic Algorithms
masterCrypto++ is a free C++ class library providing a wide range of cryptographic schemes. Supported algorithms include:
- Authenticated Encryption: GCM, CCM, EAX, ChaCha20Poly1305, XChaCha20Poly1305.
- Stream Ciphers: ChaCha (8/12/20, IETF), Panama, Salsa20, Sosemanuk, XSalsa20, XChaCha20.
- Block Ciphers: AES (Rijndael), RC6, MARS, Twofish, Serpent, CAST-256, ARIA, Blowfish, Camellia, and many others (e.g., Triple-DES, TEA, XTEA).
- Hash Functions: SHA-1, SHA-2 (224/256/384/512), SHA-3, SHAKE, BLAKE2s, BLAKE2b, Keccack, etc.
- Public-Key Cryptography: RSA, DSA, ElGamal, and various EC-based schemes (ECDSA, ed25519, x25519, ECDH).
- Key Agreement: Diffie-Hellman (DH), MQV, and others.
- Message Authentication (MAC): HMAC, Poly1305, CMAC, GMAC, SipHash, etc.
- Key Derivation (KDF): PBKDF1, PBKDF2, HKDF, and Scrypt.
- Other Features: Pseudo random number generators (PRNG), Shamir's secret sharing, bignum/polynomial operations, and non-cryptographic utilities like DEFLATE compression and Base64 encoding.
Overview of SurrealWidgets
masterSurrealWidgets is a cross-platform UI framework designed for C++ development. It provides the tools necessary to build user interfaces that can run across different operating systems.Overview of SurrealVideo
masterSurrealVideo is a specialized fork of FFmpeg designed to be a lightweight video decoding library. It strips away the vast majority of the FFmpeg codebase, retaining only the
indeo5codec required for playing video content in Klingon Honor Guard.While a standard FFmpeg binary can exceed 100 MB, SurrealVideo is approximately 100 KB, making it an efficient way for SurrealEngine to provide codec support without the massive overhead of a full FFmpeg installation.
Overview of RtAudio
masterRtAudio is a set of C++ classes providing a common API for real-time audio input and output across multiple operating systems. It simplifies interacting with audio hardware by providing an object-oriented design with a single header and source file.
Key features include:
- Cross-platform support: Linux (ALSA, JACK, PulseAudio, OSS), macOS (CoreAudio, JACK), and Windows (DirectSound, ASIO, WASAPI).
- Audio Streams: The core abstraction representing audio playback (output) or recording (input).
- Device Management: Capability to enumerate available devices, probe capabilities, and support dynamic connection of devices.
- Automatic Conversions: Handles data format conversion, channel number compensation, (de)interleaving, and byte-swapping internally.
Overview of Lhasa LHA library
masterLhasa is a library designed for parsing and decompressing LHA (.lzh) archives. It serves as a free replacement for the Unix LHA tool.
Key features and limitations:
- Read-only: Currently, Lhasa only supports reading (decompressing) archives. Compression (generating archives) is not yet implemented.
- Format Compatibility: It aims for compatibility with various LHA variants, including LArc (.lzs) and PMarc (.pma).
- CLI Compatibility: The command-line interface is designed to be interface-compatible with the non-free Unix LHA tool, maintaining the same command-line syntax and output for backwards compatibility.
Overview of pugixml XML processing library
masterpugixml is a C++ XML processing library designed for high performance. It provides a DOM-like interface for traversing and modifying XML trees, an extremely fast XML parser that constructs DOM trees from files or buffers, and an XPath 1.0 implementation for complex queries. It includes full Unicode support with automatic encoding conversions during parsing and saving.Key features and capabilities of miniz
masterMiniz provides several specialized compression and archive capabilities:
- Zlib/Deflate Compatibility: Implements zlib (RFC 1950) and Deflate (RFC 1951) standards. It is a drop-in replacement for many zlib APIs.
- Stream-based Processing: Unlike block-based compressors, miniz supports stream-based processing using a coroutine-style implementation. The zlib-style API functions can be called one byte at a time.
- Low-level Codecs: The
tdefl(compressor) andtinfl(decompressor) low-level APIs use simple state structs that can be saved/restored viamemcpy. These APIs do not use the heap. - Archive Manipulation: Includes a set of APIs for reading, writing, and appending to
.ZIPformat archives, designed for embedded, mobile, or game development. - Image Support: Contains functions for writing
.PNGformat image files. - Real-time Compression: Includes specialized real-time compressor functions designed to compete with fastlz/minilzo.
Important Crypto++ Usage and Memory Management Rules
masterWhen using the Crypto++ library, adhere to these critical rules regarding ownership and thread safety:
Object Ownership
- Pointer Constructors: If a constructor for class
Atakes a pointer to an objectB(andBis not a primitive type likeintorchar),AownsBand will deleteBupon its own destruction. - Reference Constructors: If a constructor for
Atakes a reference to an objectB, the caller retains ownership ofBand must ensureBoutlivesA.
Thread Safety
- Crypto++ is thread-safe at the class level. You can use it in multithreaded applications, but you must provide your own synchronization (e.g., mutexes) if multiple threads access the same Crypto++ object simultaneously.
- Pointer Constructors: If a constructor for class
Licensing for SurrealVideo
masterSurrealVideo is licensed under the GNU Lesser General Public License (LGPL) version 2.1 or later.
Important Note for Developers: While the main SurrealEngine project uses a ZLIB-style license, any code or dependencies located within the
SurrealVideofolder are subject to the LGPL. SurrealEngine itself is not affected by the LGPL because it links against SurrealVideo as a dynamic library rather than being a derivative work of the FFmpeg codebase.Understand Unreal Engine 1 Package Data Types
masterUnreal Engine 1 package files use little-endian encoding. The format utilizes several custom data types for compression and string handling:
- Standard Integers:
byte(uint8),uint16,uint32,uint64. - Index: A compressed 32-bit integer. The two high bits of the first byte indicate the sign and if more bytes follow. Subsequent bytes use the high bit to indicate additional data. This allows for efficient storage of small integers while supporting up to 32 bits.
- Name: String encoding depends on the
PackageVersion:- Version < 64: A zero-terminated list of bytes.
- Version >= 64: An
indexrepresenting the size, followed by the string bytes.
// Example of reading the compressed Index type int32_t ReadIndex() { uint8_t value = ReadByte(); bool signbit = value & (1 << 7); bool nextbyte = value & (1 << 6); int32_t index = value & 0x3f; if (nextbyte) { int shift = 6; do { value = ReadByte(); index |= static_cast<int32_t>(value & 0x7f) << shift; shift += 7; } while ((value & (1 << 7)) && shift < 32); } if (signbit) index = -index; return index; }- Standard Integers:
Resisting Side Channel Attacks in Crypto++
masterCrypto++ implements several best-effort remediations to resist side-channel attacks (targeting CPU caches and internal buffers), though they may be incomplete due to hardware vulnerabilities like Spectre or Meltdown.
Mitigation Strategies
- Hardware Acceleration: The library uses hardware instructions for block ciphers and hashes where available to mitigate timing attacks.
- Cache-Awareness: Uses cache-aware algorithms and access patterns to minimize cache eviction leakage.
- Spectre: The library does not implement Spectre remediations by default. To use them, add the following GCC options to your
CXXFLAGSduring the library build:-mfunction-return=thunk-mindirect-branch=thunk
Recommendations for Users
- Disable Hyperthreading: To help resist attacks, it is recommended to disable hyperthreading on your CPUs.
- Report Leaks: If you discover an information leak, please report it to the Crypto++ mailing list.