How mehah/otclient works
Project Type and Purpose
• The project is an alternative Tibia client (used with OTServers) that uses C++20 for the core engine and Lua scripting to implement game functionalities and a highly customizable user interface.
• Its primary goal is to offer a modular framework for game clients by separating core engine components, graphics, networking, and user interface modules, allowing extensive customization via scripts (using a CSS-like syntax for UI design).
Analyzing the File Structure
• Directories such as “src” and “src/framework” contain the core C++ implementation, including modules for graphics, input handling, networking, and platform abstraction.
• The “modules” directory has many separated subdirectories (for game actions, UI widgets, battle, containers, etc.) that represent different game functionalities. These illustrate the modular design principle.
• The “mods” directory offers extended functionality and client modifications that can be loaded on top of the core system.
• The “data” directory holds resource files – images, fonts, UI styles, language files, and sound resources – which are separately managed.
• There are platform‐specific folders such as “android” (mobile integration) and “browser” (browser client support), showing that multiple platforms are supported.
• Build files (CMakeLists.txt, Dockerfile, vc17 folder) and configuration files indicate containerized builds and multi-platform compilation.
Identifying Main Components and Their Relationships
• Core Engine (C++ Code): Represented by the “src” and “src/framework” directories.
– Input & Event Dispatching: Components for window events, mouse/keyboard handling, asynchronous dispatchers, and multi-threading coordination.
– Networking Module: Found in “src/framework/net” with protocol parsers/senders for handling game communication.
– Resource Management: Handling files, caching, and resource loading from “assets” and “data”.
• Scripting and UI Subsystem:
– Lua Engine & Scripting: Illustrate how game logic, UI widgets, and interface configurations are implemented via Lua (evident in the “mods”, “modules”, and “init.lua”).
– UI & Styling: Show the use of OTML (a CSS-like language) to style the UI, and how data-driven configuration files (in “data/styles” and locally within modules) affect the client’s look.
• Modular Architecture:
– Modules and Addons: Use “modules” and “mods” to emphasize that most functionality (e.g., battle, inventory, creature info, etc.) is encapsulated in individual components.
– Communication between modules is often done via event dispatchers and shared game state.
• Platform-Specific Layers:
– Mobile/Android Layer: Represent the “android” directory as an adapter layer that includes native Android code and Gradle configurations.
– Browser Support: Include a component for the “browser” folder that wraps the client for web environments.
– Build and Deployment Components: Show build scripts (Dockerfile, CMake files, GitHub workflows) as part of the continuous integration and deployment process.
• External Tools and API Integration:
– Tools folder: Represent tools such as language binding generators and other utilities used during development.
Architectural Patterns and Design Principles
• Separation of concerns: The clear split between the engine (real-time game update, rendering, network I/O) and scripting/UI (traditionally running in a separate Lua interpreter and plugins).
• Platform abstraction: Indicate that platform-specific implementations (Android, Browser, Windows, Linux) are abstracted from the core engine with adapter layers.