Profile Lifecycle Flow
This flowchart illustrates the complete lifecycle of a game profile, from creation through launch, execution, and cleanup.
Overview
Game profiles are user-configured instances of a game with specific content (mods, maps, addons), settings, and workspace strategies. Each profile is isolated and can be launched independently.
Flow Diagram
Key Components
Profile Creation
Profile Model
- File:
GenHub.Core/Models/GameProfile.cs - Fields:
id: Unique identifiername: User-defined namegameId: Target game identifiercontentIds: List of manifest IDsworkspaceStrategy: Symlink, Hardlink, or Copysettings: Game-specific settingscreated: Creation timestamplastPlayed: Last launch timestamp
Content Selection
- Source: ManifestPool (installed content)
- Filtering: By target game compatibility
- Validation: Dependency resolution, conflict checking
Settings Configuration
- ViewModel:
GameProfileSettingsViewModel.cs - Categories:
- Display (resolution, windowed mode)
- Graphics (quality, effects)
- Audio (volume, music)
- Gameplay (difficulty, speed)
Profile Launch
Workspace Preparation
- Service:
ProfileLauncherFacade.cs - Process:
- Create workspace directory (e.g.,
workspaces/profile-{id}) - Resolve content files from CAS
- Apply workspace strategy
- Write Options.ini
- Create workspace directory (e.g.,
Workspace Strategies
Symlink Strategy
- Command:
mklink /D(Windows) orln -s(Unix) - Pros: No disk space duplication, instant setup
- Cons: Requires Developer Mode or admin rights
- Cleanup: Remove symlinks only (CAS files remain)
Hardlink Strategy
- Command:
mklink /H(Windows) orln(Unix) - Pros: No disk space duplication, no special permissions
- Cons: Same filesystem required
- Cleanup: Remove hardlinks (CAS files remain)
Copy Strategy
- Command: File copy
- Pros: Works everywhere, no special requirements
- Cons: Duplicates disk space, slower setup
- Cleanup: Delete all copied files
Options.ini Generation
- Service:
GameSettingsMapper.cs - Process:
- Load profile settings
- Map to game-specific INI format
- Write to workspace/Options.ini
- Validate INI syntax
Game Launch
- Process:
- Find game executable path
- Set working directory to workspace
- Start process with arguments
- Monitor process lifecycle
Process Monitoring
Monitoring Loop
- Interval: 1 second
- Checks:
- Process still running
- Process exit code
- Crash detection
Crash Detection
- Indicators:
- Non-zero exit code
- Unexpected termination
- Exception logs
- Action: Log crash details, show dialog
Cleanup
Workspace Cleanup
- Trigger: Game process exits
- Process:
- Remove workspace files (based on strategy)
- Delete workspace directory
- Preserve logs and save files (if configured)
Reference Counting
- Purpose: Track CAS file usage
- Action: Decrement reference count for profile content
- Cleanup: Remove unused CAS files (if count = 0)
Profile Management
Profile Storage
- File:
profiles.json(user data directory) - Schema:
json
{
"profiles": [
{
"id": "uuid",
"name": "My Mod Profile",
"gameId": "generals-zh",
"contentIds": ["1.0.publisher.mod.content1", "..."],
"workspaceStrategy": "Symlink",
"settings": { ... },
"created": "2026-03-15T10:00:00Z",
"lastPlayed": "2026-03-15T12:30:00Z"
}
]
}Profile Operations
- Create: Add new profile to profiles.json
- Edit: Modify content or settings
- Duplicate: Clone existing profile
- Delete: Remove profile and cleanup workspace
- Export: Share profile configuration
- Import: Load profile from file
Error Handling
Content Validation Errors
- Missing content from ManifestPool
- Incompatible content versions
- Unresolved dependencies
Workspace Errors
- Symlink creation failure (permissions)
- Hardlink creation failure (filesystem)
- Copy failure (disk space, permissions)
Launch Errors
- Game executable not found
- Process start failure
- Crash on startup
Cleanup Errors
- File deletion failure (in use)
- Permission errors
- Orphaned workspace directories
Performance Optimizations
Lazy Loading
- Load profile settings only when needed
- Defer content validation until launch
- Cache workspace paths
Parallel Operations
- Copy files in parallel (copy strategy)
- Create symlinks in parallel
- Background dependency resolution
Caching
- Cache resolved dependencies
- Cache game settings mappings
- Cache workspace paths
Related Files
GenHub.Core/Models/GameProfile.csGenHub/Features/GameProfiles/ViewModels/GameProfileSettingsViewModel.csGenHub/Features/GameProfiles/Services/ProfileLauncherFacade.csGenHub/Features/GameProfiles/Services/GameSettingsMapper.csGenHub.Core/Services/Storage/WorkspaceStrategy.csGenHub.Core/Services/Manifest/ManifestPool.cs
