Commit Graph

1370 Commits

Author SHA1 Message Date
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
abb40f163c ci: remove --out-format flag for golangci-lint v2 compatibility
golangci-lint v2 removed the --out-format CLI flag, causing the lint
job to fail. The golangci-lint-action v7 already uses problem matchers
to surface issues natively in GitHub Actions.
2026-02-17 23:43:45 +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
d2b5bb72f8 refactor: extract gametime package, replace fmt.Printf with zap logging
Move time utilities (TimeAdjusted, TimeMidnight, TimeWeekStart, TimeWeekNext,
TimeGameAbsolute) from channelserver into common/gametime to break the
inappropriate dependency where signserver, entranceserver, and api imported
the 38K-line channelserver package just for time functions.

Replace all fmt.Printf debug logging in sys_session.go and handlers_object.go
with structured zap logging for consistent observability.
2026-02-17 17:54:51 +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
645c4ddd38 test: increase code coverage from 45.1% to 48.3%
Add unit tests across multiple packages:
- byteframe: SetBE/SetLE byte order switching
- config: Mode.String() for all safe version ranges
- mhfpacket: 28 Parse methods, 5 Build methods, empty packet builds,
  variable-length packets, NOT IMPLEMENTED error paths, UpdateWarehouse
- network: PacketID.String() for known IDs, out-of-range, and all valid
- channelserver: handleMsgMhfGetPaperData (6 switch cases), grpToGR
  (11 input values), gacha handlers, TimeGameAbsolute, equipSkinHistSize
  (4 config branches), guild mission handlers, dumpSaveData disabled path
- entranceserver: makeHeader with various inputs
2026-02-17 17:32:54 +01:00
Houmgaor
a8f70df1fb fix: clean up Docker setup (compose, README, gitignore)
- Remove deprecated version field from docker-compose.yml
- Pin Postgres to 18-alpine (matches existing db-data)
- Remove undocumented web (Apache) service
- Fix config/bin volume mounts to use docker/ directory
- Gitignore docker/savedata, docker/bin, docker/config.json
- Rewrite docker/README.md: fix typos, use docker compose V2
  commands, match actual compose file behavior
- Link docker/README.md from main README Docker section
2026-02-17 15:16:57 +01:00
Houmgaor
3413ff638a doc: restructure README for new users and fix dead community links
Reorganize README to put Quick Start first with three install paths
(Docker/binary/source), give quest files their own section, consolidate
updating instructions, trim configuration to essentials with wiki link,
and move informational sections (features, architecture) below setup.

Absorb community tool links from the now-removed pastebin FAQ and update
dead URLs: Ferias → English Project, damage calc → fist.moe, armor set
searcher → mhfz-ass GitHub releases.
2026-02-17 15:04:01 +01:00
Houmgaor
63a91a879a doc: describe Mogapedia as French MH community and Erupe maintainers 2026-02-17 14:46:25 +01:00
Houmgaor
85cdac036e fix: validate quest file existence in seasonConversion fallbacks
The final fallback in seasonConversion blindly constructed a filename
without checking if it existed on disk. When the file was missing,
handleMsgSysGetFile would send doAckBufFail, but the original Frontier
client does not gracefully handle this during quest loading — causing a
softlock instead of showing the built-in error dialog.

Now every fallback path validates file existence before returning, and
also tries the opposite time-of-day variant as a last resort. If no
file variant exists at all, the original filename is returned with a
warning log so the failure ack is still sent.
2026-02-17 01:19:26 +01:00
Houmgaor
25fba1c724 fix: remove untracked www/ from Dockerfile COPY
www/ only contains gitignored content (www/jp/) so it doesn't exist
in the CI checkout, causing the Docker build to fail.
2026-02-17 00:34:15 +01:00
Houmgaor
89d97a15b6 ci: remove redundant go.yml workflow
go-improved.yml is a superset (tests + build). Also fix its path
trigger to reference itself and include main.go.
2026-02-17 00:32:11 +01:00
Houmgaor
7d54dd0ee6 ci: add Docker CD workflow to push images to GHCR
Multi-stage Dockerfile for smaller runtime image, CD workflow triggers
on main branch pushes and version tags, docker-compose defaults to the
prebuilt GHCR image.
2026-02-17 00:28:37 +01:00
Houmgaor
220de4cf3b doc: replace Codecov badge with Go version badge 2026-02-17 00:22:22 +01:00
Houmgaor
6eb9ed66cc doc: add Codecov coverage badge to README 2026-02-17 00:13:26 +01:00
Houmgaor
5724a605a2 doc: add CI, CodeQL, and release badges to README 2026-02-17 00:12:02 +01:00
Houmgaor
0bd724f74e test: backport remaining test files from v9.2.x-stable
Import 18 network packet test files and 5 server infrastructure test
files, adapted for main branch APIs: fix config import alias (_config),
remove non-existent DevMode field, use global handlerTable instead of
per-server handlers map, and correct validateToken mock expectations
to include both token and tokenID arguments.

Adds go-sqlmock dependency for database mocking in signserver tests.
2026-02-17 00:09:41 +01:00
Houmgaor
4c3810df7e fix: Docker DB init fails due to pg_restore error on existing database (#129)
pg_restore would fail because the dump contains CREATE DATABASE but
POSTGRES_DB already creates it. With set -e this aborted the script
before update/patch schemas could run.

- Allow pg_restore to continue past non-fatal errors
- Add --no-owner --no-acl to avoid permission mismatches
- Force LF line endings for .sh files via .gitattributes
- Quote file path variables in schema loops
2026-02-16 22:53:09 +01:00
Houmgaor
be4cd2001c test: import 38 channelserver test files from v9.2.x-stable
Port test files from v9.2.x-stable branch to increase channelserver
coverage from 13.8% to 25.6% (556 tests passing).

Adapted all files to main's struct definitions: config import alias,
Airou/CatDefinition rename, packet field mismatches, Raviente struct
differences, and maxPlayers defaults. Removed tests referencing
production code not yet on main (Player, FestivalColour, etc.).
Excluded handlers_register_test.go (Raviente completely redesigned).
2026-02-16 22:19:44 +01:00
Houmgaor
b1c8b2848f security: fix CodeQL warnings for integer overflow and workflow permissions
- handlers_tower.go: add bounds checks before int-to-int16 and int-to-uint16
  conversions to prevent overflow/wraparound (CodeQL #7, #8)
- go-improved.yml, go.yml: add top-level `permissions: contents: read` to
  restrict workflow token scope (CodeQL #15, #16, #17)
2026-02-16 19:14:14 +01:00
Houmgaor
5e0d578670 security: bump golang.org/x/crypto to v0.48.0
Fixes two moderate GitHub security alerts:
- CVE: ssh allows unbounded memory consumption via GSSAPI OIDs
- CVE: ssh/agent panic on malformed constraint (out of bounds read)

Also bumps transitive deps: x/net v0.49.0, x/sys v0.41.0, x/text v0.34.0.
2026-02-16 19:10:18 +01:00
Houmgaor
10e09630a6 fix: send failure ack for missing quest/scenario files instead of crashing client
When a quest or scenario file was missing, handleMsgSysGetFile sent nil
data via doAckBufSucceed, which crashed the game client. Now sends
doAckBufFail so the client can handle the missing file gracefully.

Closes #109
2026-02-16 18:35:44 +01:00
Houmgaor
a7b0deaa42 fix: resolve data race in token.RNG global
Wrap *rand.Rand in a mutex-protected SafeRand type to make the global
RNG safe for concurrent use across goroutines. The previous bare
*rand.Rand caused data races detected by go test -race.
2026-02-16 18:19:18 +01:00
Houmgaor
9b69564c49 fix: prevent server crash on unsupported Shift-JIS characters (#116)
UTF8ToSJIS panicked when encountering characters outside the Shift-JIS
range (emoji, Lenny faces, cuneiform, etc.), crashing the server when
such characters were sent via the Discord relay channel.

Replace the panic with graceful filtering that drops unmappable runes
and preserves valid content. Also fix ToNGWord index-out-of-range panic
on empty encoder output.

Closes #116
2026-02-16 18:16:42 +01:00
Houmgaor
7689bc2ee9 Merge remote-tracking branch 'upstream/main' 2026-02-16 12:31:57 +01:00
Houmgaor
4028de27ce Merge pull request #153 from Mezeporta/doc/update-readme
doc: rewrite README, add CONTRIBUTING.md and SECURITY.md
2026-02-16 12:27:19 +01:00
Houmgaor
33d42362c0 doc: rewrite README, add CONTRIBUTING.md and SECURITY.md
Rewrite README with comprehensive documentation covering architecture,
configuration, features, troubleshooting, and development. Update all
links to Mezeporta/Erupe. Add contributing guidelines and security
policy (supported: main, stable/v9.2.x).
2026-02-16 12:25:13 +01:00
Houmgaor
9c0a65069d doc: update README for upstream transition
Remove fork language and point all links to Mezeporta/Erupe.
Update stable branch reference to stable/v9.2.x.
2026-02-16 12:20:44 +01:00
Houmgaor
9761f84e05 chore: add logs, binaries, and env to .gitignore 2026-02-16 11:32:47 +01:00
Houmgaor
7dfc3e6049 Merge upstream/main into main
Resolve conflict in handlers_stage.go: keep lock-free packet
building pattern (copy session list, release lock, then build)
over upstream's in-lock QueueSendMHF approach.

Fix test compilation: remove objectIDs field references after
upstream removed it from Server struct.

Resync vendor directory with updated go.mod dependencies.
2026-02-16 11:31:42 +01:00
wish
e9bd0b2ddb Merge pull request #151 from Mezeporta/test/aobp v9.3.0-beta 2025-12-17 09:27:56 +11:00
Houmgaor
cb2eeb6ae4 Merge remote-tracking branch 'upstream/main'
# Conflicts:
#	docker/README.md
2025-11-09 18:11:18 +01:00
Houmgaor
2b94eb196d doc: completes history. 2025-11-09 17:02:18 +01:00
Houmgaor
e31a37e0f9 chore: upgrading minimal Go from 1.23 to 1.25. 2025-11-09 16:51:02 +01:00
Houmgaor
68b9cf48d1 doc: expamding documentation. 2025-11-09 16:47:18 +01:00
Houmgaor
42fa7a34b6 Major fixes: testing, db, warehouse, etc...
See the changelog for details.
2025-11-09 11:59:04 +01:00
Houmgaor
0fac429fac fix(transmog): fix transmog issues.
Untested commit.
2025-11-09 11:57:28 +01:00
Houmgaor
36065ce273 fix(plate data): was not save, nor transmog data. 2025-11-01 18:14:30 +01:00
Houmgaor
3da54fade8 chore: adds remaining logging for Hunter Navi and Plate data. 2025-11-01 17:14:05 +01:00
Houmgaor
afc554f1ec fix(save): avoid double-save.
feat(logging): more complete logging data.
2025-11-01 00:37:59 +01:00
Houmgaor
18592c5ded fix(handlers): trying to fix issues with incomplete saves. 2025-10-31 13:10:17 +01:00
Houmgaor
2d3edcfd10 test: session lifecycle tests to reveal issues with sessions configuration. 2025-10-31 12:59:32 +01:00
wish
5f265ee291 Merge pull request #144 from gab3-dev/patch-1
Fix typos in Docker README
2025-10-29 00:00:32 +11:00
Gabriel Henrique
2a297e693f Fix typos in Docker README
"soruce" to "source"
2025-10-28 09:33:52 -03:00
Houmgaor
a6cf550fdb tests(common): comprehensive code coverage for common 2025-10-27 12:59:22 +01:00
Houmgaor
d3fd0c72b0 tests: extra tests for Dicord bit and nullcomp. 2025-10-27 12:33:33 +01:00