Commit Graph

43 Commits

Author SHA1 Message Date
Houmgaor
74798fc8b3 fix(channelserver): return error from Save() to prevent misleading success logs
CharacterSaveData.Save() silently returned on failure (nil decompressed
data, compression error, DB error) while the caller unconditionally
logged "Saved character data successfully". This made diagnosing save
failures difficult (ref #163).

Save() now returns an error, and all six call sites check it. The
success log in saveAllCharacterData only fires when the save actually
persisted.
2026-02-27 11:21:37 +01:00
Houmgaor
a9cca84bc3 refactor(channelserver): move remaining s.server.db calls into repositories
Eliminate the last three direct DB accesses from handler code:

- CharacterRepo.LoadSaveData: replaces db.Query in GetCharacterSaveData,
  using QueryRow instead of Query+Next for cleaner single-row access
- EventRepo.GetEventQuests, UpdateEventQuestStartTime, BeginTx: moves
  event quest enumeration and rotation queries behind the repo layer
- UserRepo.BanUser: consolidates permanent/temporary ban upserts into a
  single method with nil/*time.Time semantics
2026-02-21 14:08:01 +01:00
Houmgaor
2738b19c32 refactor(channelserver): extract Goocoo, Diva, Misc, Scenario, and Mercenary repositories
Move remaining raw s.server.db.* queries from handler files into
dedicated repository structs, completing the repository extraction
effort. Also adds SaveCharacterData and SaveHouseData to
CharacterRepository.

Fixes guild_hunts query to select both cats_used and start columns
to match the existing two-column Scan call. Adds slot index
validation in GoocooRepository to prevent SQL injection via
fmt.Sprintf.
2026-02-21 13:27:08 +01:00
Houmgaor
f17cb96b52 refactor(config): rename package _config to config with cfg alias
The config package used `package _config` with a leading underscore,
which is unconventional in Go. Rename to `package config` (matching the
directory name) and use `cfg` as the standard import alias across all
93 importing files.
2026-02-21 13:20:15 +01:00
Houmgaor
5f3c843082 refactor(config): eliminate ErupeConfig global variable
Replace the mutable global `_config.ErupeConfig` with dependency
injection across 79 files. Config is now threaded through existing
paths: `ClientContext.RealClientMode` for packet encoding, `s.server.
erupeConfig` for channel handlers, and explicit parameters for utility
functions. This removes hidden coupling, enables test parallelism
without global save/restore, and prevents low-level packages from
reaching up to the config layer.

Key changes:
- Enrich ClientContext with RealClientMode for packet files
- Add mode parameter to CryptConn, mhfitem, mhfcourse functions
- Convert handlers_commands init() to lazy sync.Once initialization
- Delete global var, init(), and helper functions from config.go
- Update all tests to pass config explicitly
2026-02-20 17:07:42 +01:00
Houmgaor
486be65a38 fix(protbot,channelserver): fix sign protocol and entrance parsing, guard nil save data
The protbot sent "DSGN:\x00" as the sign request type, but the server
strips the last 3 characters as a version suffix. Send "DSGN:041"
(ZZ client mode 41) to match the real client format.

The entrance channel entry parser read 14 bytes for remaining fields
but the server writes 18 bytes (9 uint16, not 7), causing a panic
when parsing the server list.

The channel server panicked on disconnect when a session had no
decompressed save data (e.g. protbot or early client disconnect).
Guard Save() against nil decompSave.

Also fix docker-compose volume mount for Postgres 18 which changed
its data directory layout.
2026-02-20 14:17:40 +01:00
Houmgaor
2bd5f98f32 docs: add doc.go files and godoc comments to all packages
Add package-level documentation (doc.go) to all 22 first-party
packages and godoc comments to ~150 previously undocumented
exported symbols across common/, network/, and server/.
2026-02-18 21:39:13 +01:00
Houmgaor
e5802a053e refactor(channelserver): extract CharacterSaveData model into model_character.go
Move SavePointer type/constants, CharacterSaveData struct, getPointers,
Compress, Decompress, and save data serialization methods out of
handlers_character.go into a dedicated model file.
2026-02-18 19:40:33 +01:00
Houmgaor
c64dabc3ba fix: check all Close() return values for errcheck lint
Add explicit error discards (_ =) for Close() calls on network
connections, SQL rows, and file handles across 28 files. Also add
.golangci.yml with standard linter defaults to match CI configuration.
2026-02-17 23:57:14 +01:00
Houmgaor
47f7a1f636 fix(channelserver): handle bare Exec errors and filter expected ErrNoRows
138 bare db.Exec calls across 22 handler files silently dropped write
errors. Each is now wrapped with error check and zap logging.

4 QueryRow sites that legitimately return sql.ErrNoRows during normal
operation (new player mezfes, festa rankings, empty guild item box)
now filter it out to reduce log noise.
2026-02-17 23:33:44 +01:00
Houmgaor
46bbb6adf9 fix: resolve all remaining lint errors (errcheck) across 49 files
Fix unchecked error returns on bf.Seek(), db.Exec(), QueryRow().Scan(),
pkt.Build(), logger.Sync(), and binary.Write() calls. The linter now
passes with 0 errors, build compiles, and all tests pass with -race.
2026-02-17 18:07:38 +01:00
Houmgaor
c55f23442b fix(lint): fixing go static check failing. 2025-10-19 22:52:58 +02:00
wish
4eed6a9738 add playtime chat command 2024-11-09 18:20:49 +11:00
wish
d26ae4563e fix G1 compatibility 2024-03-17 16:35:16 +11:00
wish
f5c772413e rename instances of HRP to HR 2024-02-25 22:20:12 +11:00
wish
df062613eb add Save pointers for S6.0 2024-02-20 03:08:48 +11:00
wish
7d0ef7db23 enable save pointers in legacy versions G1->G2 2023-11-27 22:20:17 +11:00
wish
ce849ef06e enable save pointers in legacy versions G3->G9.1 2023-11-27 22:09:02 +11:00
wish
c152e2d0b9 verify save pointers in legacy versions G3->G9.1 2023-11-27 22:00:47 +11:00
wish
e75a77e6b8 optimise grpToGR 2023-10-28 11:55:06 +11:00
wish
8fbbf13822 use better Bookshelf pointer & simplify pointer assignment 2023-10-03 00:48:37 +11:00
wish
d389f110a8 test new pointers 2023-10-02 22:09:20 +11:00
wish
5d4a81a84f fix BookshelfData length 2023-10-01 23:18:23 +11:00
Samboge
8f1317f498 Fix RP for MHF-F5
forgot to modify updateSaveDataWithStruct() to include forward 5
2023-09-27 13:52:29 +07:00
Samboge
2027238250 Fix for Festa Rewards and House Visit MHF-F5
Partial Fix for Forward 5
2023-09-27 07:12:27 +07:00
wish
a66a32936f add S6 Savedata compatibility 2023-07-21 20:54:36 +10:00
wish
d700b8bd91 simplify Savedata pointers 2023-07-19 22:13:01 +10:00
wish
4826882bcd correctly parse SexChanger 2023-07-19 21:42:54 +10:00
wish
4e2cb1fad9 skip invalid pointers 2023-07-13 18:12:46 +10:00
wish
1f93419cb7 add support for more versions 2023-07-03 00:30:44 +10:00
wish
b4df642ee3 add ClientMode config option 2023-06-18 20:31:18 +10:00
wish
ba1eea81e7 prevent save error crashes 2023-06-10 16:04:17 +10:00
Sophie R
13522ef2c9 Fix pointerGender offset being wrong
Every character seems to be assigned as male no matter what and changing the offset to 0x51 fixes this.
2023-04-06 14:44:27 +02:00
wish
174f58c014 fix nil savedata error proper 2023-02-12 01:35:48 +11:00
wish
7676f2e7d5 terminate session on save corruption 2022-12-23 23:12:01 +11:00
wish
1152ec8970 fix default GR1 2022-10-09 05:14:11 +11:00
wish
6ee9234745 fix various savedata bugs 2022-10-08 13:59:48 +11:00
wish
e0c658363c fix struct save data 2022-09-30 17:40:23 +10:00
wish
e90e3da142 add KQF command 2022-09-30 03:47:59 +10:00
wish
9259476316 implement persistent house data 2022-09-04 15:53:24 +10:00
wish
6c9e39a5cd fix savedata bugs 2022-09-04 15:52:50 +10:00
wish
90314fa411 rework savedata 2022-09-04 03:19:32 +10:00
wish
2c0e7a5267 repository cleanup 2022-07-29 03:25:23 +10:00