eliminat el checkFiles inicial que a jaildoc li molestava
This commit is contained in:
93
CLAUDE.md
93
CLAUDE.md
@@ -55,6 +55,46 @@ cmake --build build --clean-first
|
||||
|
||||
**Important:** The build directory is `/Users/sergio/Gitea/jaildoctors_dilemma/build` and the output executable is placed in the project root directory.
|
||||
|
||||
### Testing in Headless Environment (SSH/Remote Server)
|
||||
|
||||
**IMPORTANT:** When working on a remote server via SSH without a physical display, the game MUST be run using Xvfb (X Virtual Framebuffer) to avoid SDL3 display initialization errors.
|
||||
|
||||
#### Required Setup (One-time)
|
||||
```bash
|
||||
# Install Xvfb
|
||||
sudo apt-get install xvfb
|
||||
```
|
||||
|
||||
#### Running the Game in Headless Mode
|
||||
|
||||
**Option 1: Using the wrapper script (RECOMMENDED)**
|
||||
```bash
|
||||
./run_headless.sh
|
||||
```
|
||||
|
||||
**Option 2: Using xvfb-run directly**
|
||||
```bash
|
||||
xvfb-run -a ./jaildoctors_dilemma
|
||||
```
|
||||
|
||||
**Option 3: Custom display configuration**
|
||||
```bash
|
||||
xvfb-run -a -s "-screen 0 1280x720x24" ./jaildoctors_dilemma
|
||||
```
|
||||
|
||||
#### Why This Is Critical
|
||||
|
||||
- **SDL3 requires a display:** The game uses SDL3 which requires X11/Wayland display
|
||||
- **No code changes needed:** Xvfb simulates a virtual display without modifying the codebase
|
||||
- **Full logging:** Console output and logs work normally, essential for debugging resource loading
|
||||
- **Testing resource loading:** When modifying asset loading code, running with xvfb-run allows seeing all initialization logs
|
||||
|
||||
**ALWAYS use xvfb-run when testing on the remote server, especially when:**
|
||||
- Modifying resource loading code
|
||||
- Testing asset initialization
|
||||
- Debugging startup issues
|
||||
- Verifying configuration changes
|
||||
|
||||
### Static Analysis Tools (Linters)
|
||||
|
||||
This project uses two complementary static analysis tools for code quality:
|
||||
@@ -306,8 +346,8 @@ class Screen {
|
||||
- `Screen` - Rendering, window management, palette/shader effects
|
||||
- `Input` - Keyboard & gamepad input binding and checking
|
||||
- `Audio` - Music and sound effect playback
|
||||
- `Resource` - Asset loading, caching, streaming
|
||||
- `Asset` - Asset path registry and verification
|
||||
- `Resource::Cache` - Asset loading, caching, streaming (with error handling)
|
||||
- `Resource::List` - Asset path registry from assets.yaml (O(1) lookups)
|
||||
- `Director` - Main application controller
|
||||
- `Cheevos` - Achievement state management
|
||||
- `Debug` - Debug information overlay
|
||||
@@ -413,12 +453,14 @@ struct AnimationData {
|
||||
main()
|
||||
↓
|
||||
Director::Director() [Initialization]
|
||||
├─ Options::init() - Load game configuration
|
||||
├─ Asset::init() - Register asset paths
|
||||
├─ Screen::init() - Create window, SDL renderer
|
||||
├─ Resource::List::init() - Initialize asset registry singleton
|
||||
├─ Director::setFileList() - Load assets.yaml configuration (no verification)
|
||||
├─ Options::loadFromFile() - Load game configuration
|
||||
├─ Audio::init() - Initialize SDL audio
|
||||
├─ Screen::init() - Create window, SDL renderer
|
||||
├─ Input::init() - Bind keyboard/gamepad controls
|
||||
├─ Resource::init() - Load all game resources
|
||||
├─ Resource::Cache::init() - Load ALL game resources (with verification)
|
||||
│ └─ Throws exception if any required asset is missing
|
||||
└─ Cheevos::init() - Load achievement state
|
||||
|
||||
Director::run() [Main loop]
|
||||
@@ -433,11 +475,11 @@ Director::run() [Main loop]
|
||||
|
||||
Director::~Director() [Cleanup]
|
||||
├─ Options::saveToFile() - Save game settings
|
||||
├─ Resource::destroy()
|
||||
├─ Resource::Cache::destroy()
|
||||
├─ Audio::destroy()
|
||||
├─ Input::destroy()
|
||||
├─ Screen::destroy()
|
||||
└─ Asset::destroy()
|
||||
└─ Resource::List::destroy()
|
||||
```
|
||||
|
||||
### 4.2 Game Scene Flow (Core Gameplay Loop)
|
||||
@@ -468,24 +510,27 @@ Game::run() {
|
||||
|
||||
```
|
||||
Director::setFileList()
|
||||
├─ Asset::loadFromFile(config_path, PREFIX, system_folder_)
|
||||
│ ├─ Read config/assets.yaml - Parse text configuration file
|
||||
│ ├─ Parse each line: TYPE|PATH|OPTIONS - Extract asset information
|
||||
│ ├─ Replace variables (${PREFIX}, ${SYSTEM_FOLDER})
|
||||
│ └─ Store in unordered_map (O(1) lookup) - Fast asset path retrieval
|
||||
└─ Asset::check() - Verify required files exist
|
||||
└─ Asset::loadFromFile(config_path, PREFIX, system_folder_)
|
||||
├─ Read config/assets.yaml - Parse text configuration file
|
||||
├─ Parse YAML structure: assets grouped by category
|
||||
├─ Replace variables (${PREFIX}, ${SYSTEM_FOLDER})
|
||||
└─ Store in unordered_map (O(1) lookup) - Fast asset path retrieval
|
||||
|
||||
Game Scene initialization
|
||||
└─ Resource::init() - Loads all resources
|
||||
├─ loadSounds() - WAV files
|
||||
├─ loadMusics() - OGG files
|
||||
├─ loadSurfaces() - GIF/PNG images
|
||||
├─ loadAnimations() - .ani animation definitions
|
||||
├─ loadTileMaps() - .room tilemap data
|
||||
└─ loadRooms() - Room metadata
|
||||
└─ Resource::Cache::init() - Loads all resources
|
||||
├─ loadSounds() - WAV files (with error handling)
|
||||
├─ loadMusics() - OGG files (with error handling)
|
||||
├─ loadSurfaces() - GIF/PNG images (with error handling)
|
||||
├─ loadPalettes() - PAL palette files (with error handling)
|
||||
├─ loadTextFiles() - Font definition files (with error handling)
|
||||
├─ loadAnimations() - YAML animation definitions (with error handling)
|
||||
└─ loadRooms() - Room YAML files (with error handling)
|
||||
|
||||
Note: Asset verification happens during actual loading.
|
||||
If a required file is missing, Cache::load() throws detailed exception.
|
||||
|
||||
During gameplay
|
||||
└─ Resource::get*(name) - Return cached resource
|
||||
└─ Resource::Cache::get*(name) - Return cached resource
|
||||
```
|
||||
|
||||
### 4.4 Input Flow
|
||||
@@ -653,8 +698,8 @@ Achievements trigger notifications on unlock.
|
||||
| `Screen` | Rendering, window, palette management | Singleton |
|
||||
| `Input` | Keyboard & gamepad input | Singleton |
|
||||
| `Audio` | Music and SFX playback | Singleton |
|
||||
| `Resource` | Asset caching and loading | Singleton |
|
||||
| `Asset` | Asset path registry from config/assets.yaml, O(1) lookups, variable substitution | Singleton |
|
||||
| `Resource::Cache` | Asset caching and loading (with detailed error messages) | Singleton |
|
||||
| `Resource::List` | Asset path registry from config/assets.yaml, O(1) lookups, variable substitution | Singleton |
|
||||
| `Debug` | Debug overlay information | Singleton |
|
||||
| `globalEvents` | Global SDL event handling (quit, device reset, mouse) | Namespace |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user