# OpenDecal - Project Context

## What This Is
Open-source rebuild of **Decal**, the plugin framework for Asheron's Call.
The original v2.9.8.3 is closed-source. This project produces a fully open-source
drop-in replacement with identical COM interfaces and GUIDs for plugin compatibility.

## Current Status: All 5 Phases Complete (Skeleton)

The solution compiles with **25 C# projects, 0 errors**. Most COM server methods
are **stubs** that need real implementations. See `docs/PLAN.md` for the full plan.

### What's built:
- **Phase 1**: 14 decompiled .NET projects (Interop.*, Adapter, FileService, DecalUtil)
- **Phase 2**: 10 native DLLs rewritten as C# COM servers with matching GUIDs
- **Phase 3**: C++ shims — Inject.DLL (D3D9 hooking) + LauncherHook.DLL
- **Phase 4**: DenAgent WinForms tray app replacing the MFC original
- **Phase 5**: WiX installer + build script

### What's next (Phase 6):
Bottom-up verification — swap one original DLL at a time with our C# version,
test against a running AC client, fix what breaks. See `docs/PLAN.md` "Phase 6".

## Key Files
- `Managed/Decal.sln` — Main solution (25 projects)
- `Managed/Directory.Build.props` — Shared build settings (net472, x86)
- `Managed/Decal.Interop.*/` — COM interface contracts (the spec for everything)
- `Native/InjectModern/` — Inject.DLL C++ source (~530 lines)
- `Native/LauncherHookModern/` — LauncherHook.DLL C++ source (~330 lines)
- `Native/` — Old C++ source (reference for algorithms, NOT part of the build)
- `Installer/Package.wxs` — WiX v5 MSI package
- `build.cmd` — Top-level build script
- `docs/PLAN.md` — Full project plan with all phases and next steps

## Build Commands
```bash
# Managed (.NET) — works on Linux/WSL or Windows
dotnet build Managed/Decal.sln

# Native C++ — Windows only, requires VS 2022
cd Native
cmake -G "Visual Studio 17 2022" -A Win32 -B build
cmake --build build --config Release
```

## Architecture
- **10 COM servers** (C#): DecalDat, DHS, SpellFilter, DecalInput, DecalNet,
  DecalFilters, Decal.Core, DecalControls, DecalRender, D3DService
- **2 native DLLs** (C++): Inject.DLL (D3D9 vtable hooking), LauncherHook.DLL
- **1 tray app** (C# WinForms): DenAgent
- All COM servers use `[ComVisible]`, `[Guid]`, `[ClassInterface]`, `[ProgId]`
- Original CLSIDs preserved exactly for plugin compatibility

## Common Pitfalls
- `record` types need IsExternalInit — unavailable in net472, use class instead
- `CollectionsMarshal.AsSpan` unavailable in net472
- LongValueKey enum: correct names are `keyStackCount`, `keyContainer`
- tagPOINT defined in Interop.Inject, needed by Interop.Render → add ProjectReference
- ICommandEvents delegates ambiguous between Interop.Controls and Interop.Inject → use `using` aliases

## Goal
**Pixel-perfect drop-in replacement** for closed-source Decal v2.9.8.3,
targeting the original AC client.exe. Existing community plugins (VTank,
Mag-Tools, etc.) should load and work without modification.
