diff --git a/Contributing.md b/Contributing.md index cc9203d..5d1bab5 100644 --- a/Contributing.md +++ b/Contributing.md @@ -2,6 +2,84 @@ This guide covers the development workflows for working on the Erupe codebase. +## Project Directory Guide + +``` +Erupe/ +├── main.go # Entry point — starts all servers, handles shutdown +├── config.example.json # Template config (copy to config.json) +│ +├── config/ # Config loading (Viper-backed) +│ └── config.go # Main Config struct, game version modes (S1–ZZ) +│ +├── network/ # Protocol layer +│ ├── packetid.go # Packet ID enum (~200+ opcodes, `go generate` for stringer) +│ ├── crypt_conn.go # Blowfish-encrypted TCP connection +│ ├── crypt_packet.go # Packet framing and checksum +│ ├── mhfpacket/ # ~400 packet structs (one file per message type) +│ │ └── msg_mhf_*.go # Parse/Build for each packet +│ ├── binpacket/ # Binary relay packets (chat, mail, targeted) +│ ├── crypto/ # Low-level Blowfish cipher +│ └── clientctx/ # Per-connection context +│ +├── server/ +│ ├── channelserver/ # Gameplay server (by far the largest) +│ │ ├── handlers_table.go # PacketID → handler dispatch (~200 entries) +│ │ ├── handlers_quest.go # Quest system +│ │ ├── handlers_guild.go # Guild operations (14 tables) +│ │ ├── handlers_stage.go # Multiplayer rooms/lobbies +│ │ ├── handlers_cast_binary.go # Real-time state relay (position, animation) +│ │ ├── handlers_mail.go # In-game mail +│ │ ├── handlers_shop.go # Shops and gacha +│ │ ├── handlers_*.go # ... ~50 handler files by game system +│ │ ├── sys_session.go # Per-connection state (character, stage, send queue) +│ │ ├── sys_stage.go # Stage lifecycle, player sync +│ │ ├── sys_semaphore.go # Distributed locks (Raviente, guild ops) +│ │ ├── sys_channel_server.go # Server lifecycle, Raviente shared state +│ │ └── compression/ # Save data compression +│ ├── signserver/ # Authentication (TCP 53312) +│ ├── entranceserver/ # World list & character select (TCP 53310) +│ ├── api/ # REST API (port 8080) — launcher, screenshots +│ └── discordbot/ # Discord bot — slash commands, chat relay +│ +├── common/ # Shared utility libraries +│ ├── byteframe/ # Binary read/write (big-endian) +│ ├── bfutil/ # Blowfish helpers +│ ├── decryption/ # Game file decryption +│ ├── gametime/ # MHF time ↔ real time conversion +│ ├── mhfcourse/ # Course/subscription definitions +│ ├── mhfitem/ # Item ID lookups +│ ├── mhfmon/ # Monster ID lookups +│ ├── mhfcid/ # Character ID handling +│ ├── token/ # Session token generation +│ ├── pascalstring/ # Length-prefixed string parsing +│ ├── stringstack/ # Stack for stage movement history +│ └── stringsupport/ # String utilities +│ +├── schemas/ # PostgreSQL schema management +│ ├── init.sql # Base schema (pg_dump format, bootstraps to v9.1.0) +│ ├── patch-schema/ # Incremental dev patches (apply in order) +│ ├── update-schema/ # Consolidated release schemas +│ └── bundled-schema/ # Demo data (shops, events, gacha) +│ +├── bin/ # Game data files (served to clients) +│ ├── quests/ # Quest binaries +│ ├── scenarios/ # Cutscene/scenario files +│ └── events/ # Event quest archives +│ +├── docker/ # Docker Compose setup (PostgreSQL, pgAdmin, server) +├── tools/loganalyzer/ # Log analysis utility +├── vendor/ # Vendored Go dependencies +└── .github/ # CI workflows (test, race, coverage, build) +``` + +### Where to look first + +- **Implementing a feature?** Start with the `handlers_*.go` file for that game system, then check the packet structs in `network/mhfpacket/`. +- **Fixing a bug?** Enable packet logging (see [Debugging](#debugging)) and trace from `handlers_table.go` to the relevant handler. +- **Adding a DB table?** Create a new patch in `schemas/patch-schema/` with the next number in sequence. +- **Understanding binary formats?** `common/byteframe/` is the serialization layer used everywhere. + ## Adding a Packet Handler This is the most common type of contribution. A new packet handler touches 4 files and optionally a 5th for code generation.