# Forge Initialization Module

## Overview
The Initialization module provides a comprehensive player initialization and data persistence system for the Forge client. It handles player data loading, saving, and synchronization with the database, ensuring a seamless experience across sessions.

## Dependencies
- forge_client_main
- ArmaDragonflyClient

## Authors
- J. Schmidt
- Creedcoder
- IDSolutions

## Features

### Player Initialization
1. **Player Setup** (`fnc_initPlayer.sqf`)
   - Initializes player state
   - Clears default equipment
   - Sets up player variables
   - Configures initial loadout
   - Manages loading screen

2. **Data Management**
   - **Player Load** (`fnc_playerDBLoad.sqf`)
     - Loads player data from database
     - Handles first-time login
     - Restores player state
     - Manages data synchronization

   - **Player Save** (`fnc_playerDBSave.sqf`)
     - Saves player data to database
     - Manages data persistence
     - Handles state synchronization
     - Preserves player information

   - **Save Loop** (`fnc_playerSaveLoop.sqf`)
     - Periodic data saving
     - Configurable save intervals
     - Automatic state persistence
     - Error handling

3. **Data Handling** (`fnc_handlePlayerLoad.sqf`)
   - Processes loaded data
   - Restores player state
   - Manages default values
   - Handles data validation

### Persisted Data
1. **Player Information**
   - Armory unlocks
   - Garage unlocks
   - Locker contents
   - Vehicle inventory
   - Financial data (cash/bank)
   - Contact details
   - Organization membership
   - Player statistics
   - Equipment loadouts
   - Position and state

2. **State Management**
   - Player position
   - Player direction
   - Weapon state
   - Stance information
   - Rating/reputation
   - Paygrade
   - Organization status

## Event Handlers
The module uses several event handlers for initialization and execution:
- `XEH_preInit.sqf`: Pre-initialization setup
- `XEH_postInit.sqf`: Post-initialization tasks
- `XEH_preStart.sqf`: Pre-start configuration
- `XEH_postInit_client.sqf`: Client-specific post-initialization
- `XEH_preInit_server.sqf`: Server-specific pre-initialization

## Usage
To use the initialization module:
1. Ensure the module is properly loaded in your mission
2. The module automatically handles player initialization
3. Access player data using the appropriate functions:
   ```sqf
   // Initialize player
   [] call forge_client_init_fnc_initPlayer;
   
   // Load player data
   [] call forge_client_init_fnc_playerDBLoad;
   
   // Save player data
   [] call forge_client_init_fnc_playerDBSave;
   ```
4. Monitor player state and data persistence

## Debugging
Debug mode can be enabled by uncommenting the following in `script_component.hpp`:
```cpp
#define DEBUG_MODE_FULL
```

## Version Information
Version information is managed through the main Forge client system configuration.

## Technical Details
- Automatic player initialization
- Database integration
- Periodic data saving
- State persistence
- Error handling
- Data validation
- First-time login handling
- Default value management
- Position tracking
- Equipment management
- Financial synchronization
- Organization integration 