# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

This is the NeoRylClient, a C++ MMORPG game client built with Visual Studio 2010 using DirectX for graphics rendering. The codebase follows a component-based architecture with clear separation between game logic, networking, UI, and rendering systems.

## Build System

### Building the Project

Use Visual Studio 2010 or later to build this project:

```bash
# Open the solution
devenv NeoRylClient.sln

# Build from command line (if MSBuild is available)
msbuild NeoRylClient.sln /p:Configuration=Debug /p:Platform=Win32
msbuild NeoRylClient.sln /p:Configuration=Release /p:Platform=Win32
```

### Build Configurations

- **Debug**: Standard debug build with full debugging symbols
- **Debug_MY**: Custom debug configuration (outputs to `D:\Navezine\ROWTest_MY\`)
- **Release**: Standard release build (outputs to `../../../Game/`)
- **Release_NoGD**: Release build without GameGuard (outputs to `../../Executable/Release_NoGD\`)
- **Release_MY**: Custom release configuration

### Project Dependencies

The solution builds in this order:
1. MemoryManager (custom memory management)
2. Caldron (core engine utilities)
3. CrossM (cross-platform compatibility layer)
4. Effect (visual effects system)
5. SoundLib (audio system)
6. Zalla3D Base Class (3D engine foundation)
7. Zalla3D Scene Class (3D scene management)
8. CharacterActionControl (character animation and control)
9. GlobalScript (game logic and network layer)
10. ScriptEngine (custom scripting language VM)
11. LUA (Lua scripting support)
12. NeoRylClient (main game client)

## Architecture

### Core Systems

**Network Layer** (`GlobalScript/Network/`):
- Client-server communication using custom networking framework
- `ClientNet::CClientEventHandler` base class for event handling
- `AuthHandler`: Handles authentication server communication
- `GameHandler`: Event-driven game server communication with command registration system
- `UDPHandler`: UDP-based communication for real-time updates
- Packet-based protocol with `PktBase` as the base packet structure

**Event Processing** (`RYLClient/EventHandler/GameProcess/`):
- Domain-specific event processors organized by game feature
- `GameProcess` namespace contains specialized processors:
  - `LoginoutProcess`: Character login/logout handling
  - `CharInfoProcess`: Character information updates
  - `FightProcess`: Combat system events
  - `ItemProcess`: Item management events
  - `SkillProcess`: Skill system events
  - `ChatProcess`: Chat and communication
  - `QuestProcess`: Quest system
  - `MoveProcess`: Character movement
  - `CastleProcess`: Castle/siege warfare
  - `BattleGroundClientProcess`: Battleground PvP events
  - `BroadcastProcess`: Server broadcasts
  - `CommunityProcess`: Guild and social features

**Scene Management** (`RYLClient/RYLClient/`):
- `CRYLSceneManager`: Central scene coordinator
- Scene hierarchy:
  - `RYLIntroScene`: Game startup/intro
  - `RYLLoginScene`: Login screen
  - `RYLRaceSelectScene`: Race/class selection
  - `RYLCharacterSelectScene`: Character selection
  - `RYLGameScene`: Main gameplay scene
  - `RYLLoadingScene`: Loading screens between scenes

**UI System** (`RYLClient/RYLUI/`):
- Custom UI framework built on GM (Game Management) base classes
- Component hierarchy: `GMUIObject` → specialized UI controls
- UI Controls: Button, CheckBox, ComboBox, ListBox, Label, Edit, TabButton, Dialog
- Custom extensions: `RYLButton`, `RYLDialog`, `RYLMessageBox`, `RYLImageManager`
- `RYLTextureManager`: Manages UI textures and sprites
- `RYLImageCabinet`: Centralized image resource management

**Character System** (`CharacterActionControl/`):
- `RYLCreatureManager`: Manages all entities (players, NPCs, monsters)
- `RYLCreature`: Base entity class with rendering and animation
- `RYLCharacterControl`: Player character control and input handling
- Specialized controls for different weapon types and combat modes
- `CameraControl`: Camera system with scripting support

**Script Engine** (`ScriptEngine/`):
- Custom scripting language VM with compiler toolchain
- Flex/Bison-based parser (`string.l`, `string.y`)
- Intermediate code generation and virtual machine execution
- Symbol table, syntax tree, and relocation table support
- Used for game logic scripting alongside Lua

**Game Data Management**:
- `CRYLGameData`: Central game state and data manager
- `CRYLNetworkData`: Network state management
- `CRYLCommunityData`: Social features data (guild, friends, etc.)
- `CCharStatus`: Character stats and attributes
- `CRYLCastleManager` / `CRYLCampManager`: Territory control systems
- `CRYLSkillScriptMgr`: Lua-based skill scripting

### Key Design Patterns

**Event-Driven Network Architecture**:
- Game server events use a registration system in `CGameEventHandler`
- Register handlers with `AddHandler(commandId, functionPointer, ignoreStatusMask)`
- Events dispatched through `OnDispatch()` to registered function pointers
- Each event function signature: `bool EventFunc(CClientEventHandler*, PktBase*)`

**Manager Pattern**:
- Multiple manager classes coordinate subsystems (Scene, Creature, Texture, Castle, Camp, Notice)
- Managers are owned by `CClientMain` and accessed globally

**Namespace Organization**:
- `ClientNet`: Network layer abstractions
- `GameProcess`: Game event processing logic
- `Skill`, `Item`: Domain-specific data structures
- `DbgUtils`: Debug utilities
- `GameClientLog`: Logging functionality

## Working with the Codebase

### Adding Network Event Handlers

Event handlers are registered in `GameHandler` during initialization:

```cpp
// In game initialization
pGameHandler->AddHandler(CMD_YOUR_EVENT, &YourEventFunction);

// Event function in appropriate GameProcess file
namespace GameProcess {
    GAME_EVENT_FUNC(YourEventFunction) {
        // Extract packet data
        // Update game state
        return true;
    }
}
```

### UI Development

UI dialogs inherit from `RYLDialog` and use the component system:

```cpp
class CYourDialog : public CRYLDialog {
    RYLButton* m_pButton;
    RYLLabel* m_pLabel;

    void InitControls();
    void OnButtonClick();
};
```

UI resources are managed through `RYLTextureManager` and loaded from image files.

### Character/Entity Management

All visible entities go through `RYLCreatureManager`:
- Creates and destroys creature instances
- Updates position, animation, and rendering
- Handles entity lifecycle and cleanup

### Scene Transitions

Scene changes flow through `CRYLSceneManager`:
- Properly cleanup current scene before transition
- Initialize new scene resources
- Handle loading screens for resource-intensive transitions

## Code Conventions

- **Character Set**: MultiByte (not Unicode)
- **Naming**:
  - Classes: Prefix with `C` (e.g., `CClientMain`, `CRYLGameData`)
  - Managers: Suffix with `Manager` (e.g., `CRYLCreatureManager`)
  - Event handlers: Suffix with `Handler` (e.g., `CGameEventHandler`)
  - UI controls: Prefix with `RYL` or `GMUI` (e.g., `RYLButton`, `GMUIObject`)
- **Hungarian Notation**: Used extensively (m_ for members, p for pointers, dw for DWORD, etc.)
- **Headers**: Include guards use `#ifndef __FILENAME_H__` pattern
- **Namespaces**: Event processors in `GameProcess`, network in `ClientNet`

## Dependencies

**External Libraries**:
- DirectX SDK (graphics and sound)
- Winsock2 (networking)
- Lua (embedded in RYLClient/LUA/)
- EAX (3D audio - eax.dll, eax.lib, eaxguid.lib)
- DbgHelp (crash dumps - dbghelp.dll, DbgHelp.Lib)

**Engine Modules** (located in `../Engine/`):
- Caldron: Core utilities
- CrossM: Cross-platform layer
- Effect: Visual effects
- SoundLib: Audio engine
- Zalla3D: 3D rendering engine

## Special Notes

- The main client executable is named `NeoRylClient` but outputs to different directories depending on build configuration
- Lua scripting is integrated through the LUA project (dependency of NeoRylClient)
- The custom script engine uses Flex/Bison; if modifying grammar, run `Parse.bat` in ScriptEngine directory
- Character encoding in source files may contain Korean comments (MultiByte character set)
- Anti-cheat integration through GameGuard (referenced in headers and build configs)
