Commit Graph

83 Commits

Author SHA1 Message Date
Houmgaor
ab9fd0bc9c refactor(channelserver): extract UserRepository for users table access
Centralizes all 31 direct users-table SQL queries from 11 handler
files into a single UserRepository, following the same pattern as
CharacterRepository and GuildRepository. The only excluded query is
the sign_sessions JOIN in handleMsgSysLogin which spans multiple
tables.
2026-02-20 22:18:46 +01:00
Houmgaor
458d8c9397 refactor(channelserver): add numeric column helpers and extract protocol constants
Add readCharacterInt/adjustCharacterInt helpers for single-column
integer operations on the characters table. Eliminates fmt.Sprintf
SQL construction in handlers_misc.go and replaces inline queries
across cafe, kouryou, and mercenary handlers.

Second round of protocol constant extraction: adds constants_time.go
(secsPerDay, secsPerWeek), constants_raviente.go (register IDs,
semaphore constants), and named constants across 14 handler files
replacing raw hex/numeric literals. Updates anti-patterns doc to
mark #4 (magic numbers) as substantially fixed.
2026-02-20 21:18:40 +01:00
Houmgaor
d456bd23e0 fix(channelserver): handle ignored DB errors and cache userID on session
Silently ignored DB errors in handlers could cause data loss (frontier
point transactions completing without DB writes), reward duplication
(stamp exchange granting items on failed UPDATE), and crashes (tower
mission page=0 causing index-out-of-bounds). House access state
defaulting to 0 on DB failure also bypassed all access controls.

HIGH risk fixes:
- frontier point buy/sell now fails with ACK on DB error
- stamp exchange/stampcard abort on failed UPDATE
- guild meal INSERT returns fail ACK instead of orphaned ID 0
- mercenary/airou creation aborts on failed sequence nextval

MEDIUM risk fixes:
- tower mission page clamped to >= 1 preventing array underflow
- tower RP donation returns early on failed guild state read
- house state defaults to 2 (password-protected) on DB failure
- playtime read failure logged instead of silently resetting RP

Also cache userID on Session at login time, eliminating ~25 redundant
subqueries of the form WHERE u.id=(SELECT c.user_id FROM characters
c WHERE c.id=$1) across shop, gacha, command, and distitem handlers.
2026-02-20 21:06:16 +01:00
Houmgaor
bf983966a0 refactor(channelserver): migrate inline queries to helpers and define named constants
Migrate 6 character data handlers to use the existing loadCharacterData
and saveCharacterData helpers, eliminating duplicate inline SQL:
- LoadFavoriteQuest, SaveFavoriteQuest, LoadDecoMyset, LoadMezfesData,
  LoadHunterNavi, GetEquipSkinHist

Define named constants replacing magic numbers across handlers:
- Achievement trophy tiers, broadcast/message types, diva phase
  durations, RP accrual rates, kill log layout, semaphore bases,
  quest stage/loading screen IDs

Update anti-patterns doc with accurate line counts, evidence-based
softlock analysis, and revised refactoring priorities.
2026-02-20 19:46:57 +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
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
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
1398383a8d fix(lint): automated linting, with simple formatter. 2025-10-19 22:43:05 +02:00
Houmgaor
f79e05c0c9 feat(go): upgrade from go 1.21 to 1.23
BREAKING CHANGE: will not work properly with Go 1.21.
2025-10-19 22:24:48 +02:00
wish
d1dfc3fbb1 packet queue fix proposal 2025-02-18 03:12:09 +11:00
wish
4eed6a9738 add playtime chat command 2024-11-09 18:20:49 +11:00
wish
a9b9c94347 fix RNG 2024-02-21 03:46:15 +11:00
wish
b73f85ef4a add Quest timer toggle Chat Command 2024-02-20 00:33:38 +11:00
wish
4fbfd569df Merge pull request #111 from ZeruLight/feature/moderation
feature/moderation
2024-01-11 23:04:29 +11:00
wish
c8e21387c0 rewrite CastBinary payload handling 2024-01-06 17:43:25 +11:00
wish
f73bdd7445 rewrite CastBinary payload handling 2024-01-05 02:39:25 +11:00
wish
2135c443d8 add ban chat command 2024-01-03 19:30:57 +11:00
wish
e0615dcd0c add support for operator accounts & bans 2024-01-03 19:08:45 +11:00
wish
ca80a98141 i18n proposal 2024-01-03 04:22:25 +11:00
wish
a602bda47b reuse existing token, JP string & command description 2024-01-01 02:10:27 +11:00
wish
b3a265e218 Merge remote-tracking branch 'origin/main' into feature/discord-login 2023-12-31 22:38:08 +11:00
wish
0ea0dc217b simplify config 2023-12-31 12:51:24 +11:00
Matthew
26438306c6 fix: Missing closing bracket 2023-12-04 13:48:17 -05:00
Matthew
b7c5fe70e7 Merge branch 'main' into feature/discord-login 2023-11-29 10:52:01 -08:00
wish
1cd60eb5ae hide disabled commands 2023-11-28 23:41:22 +11:00
wish
8d02c9f907 remove unnecessary dependency change 2023-11-28 23:40:47 +11:00
Matthew
eeeb998040 Merge branch 'ZeruLight:main' into feature/discord-login 2023-11-27 12:44:25 -08:00
Matthew
de5c3addd1 fix: Show config prefix instead of just ! 2023-11-27 15:34:28 -05:00
Matthew
88652e1dc0 chore: Change command name to show the prefix instead. 2023-11-27 15:32:52 -05:00
Matthew
325f6bebb9 Merge branch 'ZeruLight:main' into feature/custom-prefix 2023-11-27 12:29:15 -08:00
wish
f0744b4040 disable KQF command before G10 2023-11-27 21:59:58 +11:00
Matthew
23bc66eda5 fix: Consider prefix length when slicing. 2023-11-27 04:07:44 -05:00
Matthew
ce773a6c56 feat: Finish help command and add description to commands. 2023-11-27 04:05:15 -05:00
Matthew
76ba7cb942 feat: Custom prefixes and basic help command 2023-11-27 03:41:48 -05:00
Matthew
a4745f05d5 refactor: Clean up random token implementation 2023-11-27 03:03:48 -05:00
Matthew
38b57c6d98 refactor: Change to using rand.Read instead of whatever the hell else was before 2023-11-27 01:08:40 -05:00
Matthew
226adddc43 feat: Generate hashes for Discord and allow password resets 2023-11-26 16:47:54 -05:00
Matthew
33665130cf feat: Discord basic implementation 2023-11-26 01:22:51 -05:00
wish
43f8cef35d fix server-side messages using wrong CID 2023-11-21 21:48:15 +11:00
wish
bcf2ba40e5 fix possible integer bounding issues 2023-11-20 00:13:49 +11:00
wish
6c32eae9f2 simplify code 2023-11-16 21:56:48 +11:00
wish
0bdd873336 broadcast Raviente party message correctly 2023-09-02 23:52:15 +10:00
wish
42abdfb0c7 change getRaviSemaphore scope & handle RegisterEvent 2023-08-30 22:29:49 +10:00
wish
e6f1298935 disable incompatible ravi commands 2023-08-30 00:15:52 +10:00
wish
48fcfbd304 Merge remote-tracking branch 'origin/main' into fix/ravi-v3
# Conflicts:
#	server/channelserver/handlers_cast_binary.go
2023-08-29 23:38:24 +10:00
wish
1590d9c8d6 fix wrong arg 2023-08-29 23:26:10 +10:00
wish
4a95535314 Merge remote-tracking branch 'origin/main' into fix/chat-commands-args
# Conflicts:
#	server/channelserver/handlers_cast_binary.go
2023-08-29 22:41:59 +10:00
wish
1685f409e7 initial ravi-v3 commit 2023-08-27 22:16:51 +10:00