Commit Graph

106 Commits

Author SHA1 Message Date
Houmgaor
7ea2660335 docs(stubs): annotate empty handlers and add unimplemented reference doc
Add // stub: unimplemented to 70 empty game-feature handlers and
// stub: reserved to 56 protocol-reserved slots in handlers_reserve.go,
making them discoverable via grep. Add docs/unimplemented.md listing all
unimplemented handlers grouped by subsystem with descriptions.
2026-03-19 10:57:09 +01:00
Houmgaor
bfc5319cb6 fix(guild): fix nil panics causing clan menu softlock (#171)
The crash was in handleMsgMhfGetGuildManageRight where a variable
shadowing bug (guild, err := instead of guild, err =) left the
outer guild pointer nil after the inner GetByID lookup succeeded,
panicking at guild.MemberCount. This is confirmed by the user's
stack trace pointing to handlers_guild.go:234.

Also fix 6 other nil-dereference risks across guild handlers:
- handleMsgMhfArrangeGuildMember: guild nil after GetByID
- handleMsgMhfEnumerateGuildMember: alliance nil when AllianceID > 0
- handleMsgMhfUpdateGuildIcon: guild and characterInfo nil
- handleMsgMhfOperateGuild: guild nil, characterGuildInfo nil
- handleAvoidLeadershipUpdate: characterGuildData nil

Improve panic recovery to log opcode and full stack trace so
future panics can be diagnosed from console screenshots.
2026-03-06 00:15:53 +01:00
Houmgaor
4e8c4b4e92 fix(channelserver): handle silently discarded errors across handlers
Replace ~17 instances of '_ =' / '_ :=' with proper error checks that
log warnings or send fail ACKs. Affected handlers: cafe, distitem, data,
guild, guild_board, guild_cooking, guild_scout, house, mercenary, misc,
and rengoku. Also resolves all pre-existing lint issues: unchecked
bf.Seek in tests, unused filtered slice in svc_festa, unused mock
fields, and unused signserver test helper.
2026-02-27 11:33:25 +01:00
Houmgaor
2acbb5d03a feat(channelserver): implement monthly guild item claim tracking
Players could never claim monthly guild items because the handler
always returned 0x01 (claimed). Now tracks per-character per-type
(standard/HLC/EXC) claim timestamps in the stamps table, comparing
against the current month boundary to determine claim eligibility.

Adds MonthStart() to gametime, extends StampRepo with
GetMonthlyClaimed/SetMonthlyClaimed, and includes schema migration
31-monthly-items.sql.
2026-02-22 16:46:57 +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
f584c5a688 feat(channelserver): add daily noon resets for gacha stepup and guild RP
Gacha stepup progress now resets when queried after the most recent
noon boundary, using a new created_at column on gacha_stepup.

Guild member rp_today rolls into rp_yesterday lazily when members are
enumerated after noon, using a new rp_reset_at column on guilds.

Both follow the established lazy-reset pattern from the cafe handler.
2026-02-21 00:50:55 +01:00
Houmgaor
d2a9b0ba5c refactor(channelserver): migrate remaining guild SQL into GuildRepository
Move ~39 inline SQL queries from six handler files into repo_guild.go,
consolidating all guild-related DB access (posts, alliances, adventures,
treasure hunts, meals, kill logs, scouts) behind GuildRepository methods.

Handler files now contain only packet serialization, business logic, and
ACK responses with no direct database calls.
2026-02-20 22:14:48 +01:00
Houmgaor
96d07f1c04 refactor(channelserver): extract GuildRepository for guild table access
Per anti-patterns.md item #9, guild-related SQL was scattered across
~15 handler files with no repository abstraction. Following the same
pattern established by CharacterRepository, this centralizes all
guilds, guild_characters, and guild_applications table access into a
single GuildRepository (~30 methods).

guild_model.go and handlers_guild_member.go are trimmed to types and
pure business logic only. All handler files (guild_*, festa, mail,
house, mercenary, rengoku) now call s.server.guildRepo methods
instead of direct DB queries or methods on domain objects.
2026-02-20 22:06:55 +01:00
Houmgaor
24ccc167fe fix(channelserver): add fail ACKs to silent error paths to prevent client softlocks
Handlers that log errors and return without sending a MsgSysAck leave
the client waiting indefinitely. Add doAckSimpleFail/doAckBufFail to
14 error paths across 4 files, matching the pattern already used in
~70 other error paths across the codebase.

Affected handlers:
- handleMsgMhfGetCafeDuration (1 path)
- handleMsgMhfSavedata (1 path)
- handleMsgMhfArrangeGuildMember (3 paths)
- handleMsgMhfEnumerateGuildMember (5 paths)
- handleMsgSysLogin (4 paths)
- handleMsgSysIssueLogkey (1 path)
2026-02-20 19:35:25 +01:00
Houmgaor
d32e77efba refactor: replace panic calls with structured error handling
Replace ~25 panic() calls in non-fatal code paths with proper
s.logger.Error + return patterns. Panics in handler code crashed
goroutines (caught by defer/recover but still disruptive) instead
of failing gracefully.

Key changes:
- SJISToUTF8 now returns (string, error); all 30+ callers updated
- Handler DB/IO panics replaced with log + return/ack fail
- Unhandled switch-case panics replaced with logger.Error
- Sign server Accept() panic replaced with log + continue
- Dead unreachable panic in guild_model.go removed
- deltacomp patch error logs and returns partial data

Panics intentionally kept: ByteFrame sentinel, unimplemented
packet stubs, os.Exit in main.go.
2026-02-20 19:11:41 +01:00
Houmgaor
ed2a9597f2 refactor(channelserver): extract guild model, chat commands, and seibattle
Split three large files into focused modules:
- handlers_guild.go: extract types/ORM into guild_model.go
- handlers_cast_binary.go: extract command parser into handlers_commands.go
- handlers.go: move seibattle types/handlers into handlers_seibattle.go
2026-02-18 18:24:36 +01:00
Houmgaor
35665a46d8 refactor(channelserver): split handlers_guild.go into sub-files
handlers_guild.go was 2090 lines mixing unrelated guild subsystems.
Extract handlers into focused files following the existing pattern:

- handlers_guild_ops.go: OperateGuild switch + member operations
- handlers_guild_info.go: InfoGuild + EnumerateGuild display
- handlers_guild_mission.go: guild mission system
- handlers_guild_cooking.go: meals, weekly bonus, hunt data
- handlers_guild_board.go: message board system

Core types, methods, and DB functions remain in handlers_guild.go
(now ~1000 lines).
2026-02-18 00:19:11 +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
88fc17e790 fix: purge excess guild posts and clarify alliance TODO
Purge oldest guild posts beyond the limit (100 messages, 4 news) after
each new post is created. Replace misleading alliance application TODO
with a note that the feature is not yet implemented.
2026-02-17 18:12:07 +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
2a0e3e2c84 fix: re-enable CI lint job and fix ~65 lint errors (partial)
Re-enable the golangci-lint job in CI (disabled Oct 2025), update to
Go 1.25 and golangci-lint-action v7. Fix errcheck, gosimple S1009,
staticcheck SA4031 and SA2001 errors across 54 files. Remaining ~39
lint errors will be addressed in follow-up commits.
2026-02-17 17:59:00 +01:00
Houmgaor
fb3e86f429 fix: handle Query/QueryRow/transaction errors in channel server handlers
Add error checking and logging for ~25 database call sites that were
silently dropping errors, preventing resource leaks (unclosed rows),
nil pointer panics, and silent data corruption in festa transactions.
2026-02-17 17:44:35 +01:00
Houmgaor
c55f23442b fix(lint): fixing go static check failing. 2025-10-19 22:52:58 +02:00
Houmgaor
fc6e479df9 fix(lint): fixing more complex formatters problems. 2025-10-19 22:46:21 +02:00
Houmgaor
1398383a8d fix(lint): automated linting, with simple formatter. 2025-10-19 22:43:05 +02:00
wish
531b3d2fa6 Remove unused import 'math' from handlers_guild.go
Removed unused 'math' import from handlers_guild.go
2025-08-29 22:56:46 +10:00
wish
7459dede49 fix guild poogie outfit unlock 2025-08-28 23:27:56 +10:00
wish
8c219be30f fix InfoGuild response on <G10 2025-03-10 11:38:00 +11:00
wish
3e71c308f4 minor MhfInfoGuild changes 2025-03-06 23:01:22 +11:00
wish
5028355cfc prevent nil pointer in MhfGetGuildManageRight 2025-02-23 21:46:00 +11:00
wish
846f8d6693 retain excess Room RP 2024-02-28 21:24:55 +11:00
wish
e5703617bb add support for Clan Changing Room 2024-02-28 19:29:06 +11:00
wish
f5c772413e rename instances of HRP to HR 2024-02-25 22:20:12 +11:00
wish
c74ce4b07f simplify reused code 2024-02-25 14:22:21 +11:00
wish
40d4aba3c4 convert other Warehouse types to new system 2024-02-25 14:12:37 +11:00
wish
d0e727d444 fix remaining Festa queries 2024-02-20 18:52:56 +11:00
wish
d22a7c782f changes to FestivalColor 2024-02-20 04:16:26 +11:00
wish
52082aaf06 use correct GuildMember length 2023-12-31 11:43:10 +11:00
wish
3d08e64b07 add comments 2023-12-02 21:18:16 +11:00
wish
4bae0e5758 add option to alter maximum Clan Members 2023-11-30 23:07:13 +11:00
wish
b3af01b803 use seconds for arbitrary durations in config 2023-11-26 18:54:04 +11:00
wish
1e6675b3f5 add support for Festa Trial voting 2023-11-19 04:59:30 +11:00
wish
85fc76edd5 update parsing of many packets 2023-11-19 02:34:02 +11:00
wish
fc57d63689 update parsing of many packets 2023-11-19 00:35:22 +11:00
wish
6f99698525 fix indentation 2023-10-08 20:37:04 +11:00
wish
641032f862 implement hunt data logging (partial #82) 2023-10-08 19:25:48 +11:00
wish
f37915bcae simplify Guild Huntdata & decimal conversions 2023-10-07 19:59:37 +11:00
wish
8e27617727 convert Guild Missions to struct 2023-10-07 19:58:49 +11:00
wish
aad9425a73 guess Forward.5 compatibility 2023-07-22 18:22:21 +10:00
wish
dbedab4d33 add ClientMode support based on Forward.4 2023-07-22 16:47:44 +10:00
wish
0b4dca5c45 fix RP not being consistent between clients 2023-07-22 03:00:07 +10:00
wish
216893e3ce InfoGuild decoding & GetGuildManageRight cleanup 2023-07-09 15:57:48 +10:00
wish
db6b7795c5 clean up OperateGuild 2023-07-08 22:41:57 +10:00
wish
a23e1b62a2 GetGuildInfo further decoding 2023-07-08 22:16:58 +10:00