Commit Graph

51 Commits

Author SHA1 Message Date
Houmgaor
b96cd0904b fix: ease onboarding with startup warnings and doc corrections
- Warn at startup when quest files are missing (clients crash without
  them) and point users to the download link
- Fix Host config description: it's the advertised IP, not a bind
  address — 0.0.0.0 was wrong advice
- Load bundled schemas (shops, events, gacha) in Docker init so new
  users get working demo data out of the box
- Renumber duplicate patch schema 28 → 32 to resolve numbering
  collision
- Fix patch schema example filename to use hyphens matching actual
  files
2026-02-23 20:23:08 +01:00
Houmgaor
53b5bb3b96 refactor(channelserver): remove Channels fallbacks, use Registry as sole cross-channel API
main.go always sets both Channels and Registry together, making the
Channels fallback paths dead code. This removes:

- Server.Channels field from the Server struct
- 3 if/else fallback blocks in handlers_session.go (replaced with
  Registry.FindChannelForStage, SearchSessions, SearchStages)
- 1 if/else fallback block in handlers_guild_ops.go (replaced with
  Registry.NotifyMailToCharID)
- 3 method fallbacks in sys_channel_server.go (WorldcastMHF,
  FindSessionByCharID, DisconnectUser now delegate directly)

Updates anti-patterns.md #6 to "accepted design" — Session struct is
appropriate for this game server's handler pattern, and cross-channel
coupling is now fully routed through the ChannelRegistry interface.
2026-02-22 16:16:44 +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
f9d9260274 fix(channelserver): configure DB pool and add transactions for guild ops
sqlx.Open was called with no pool configuration, risking PostgreSQL
connection exhaustion under load. Set max open/idle conns and lifetimes.

CreatePost INSERT + soft-delete UPDATE were two separate queries with
no transaction, risking inconsistent state on partial failure.

CollectAdventure used SELECT then UPDATE without a lock, allowing
concurrent guild members to double-collect. Now uses SELECT FOR UPDATE
within a transaction.
2026-02-21 00:29:09 +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
754b5a3bff feat(channelserver): decouple channel servers for independent operation (#33)
Enable multiple Erupe instances to share a single PostgreSQL database
without destroying each other's state, fix existing data races in
cross-channel access, and lay groundwork for future distributed
channel server deployments.

Phase 1 — DB safety:
- Scope DELETE FROM servers/sign_sessions to this instance's server IDs
- Fix ci++ bug where failed channel start shifted subsequent IDs

Phase 2 — Fix data races in cross-channel access:
- Lock sessions map in FindSessionByCharID and DisconnectUser
- Lock stagesLock in handleMsgSysLockGlobalSema
- Snapshot sessions/stages under lock in TransitMessage types 1-4
- Lock channel when finding mail notification targets

Phase 3 — ChannelRegistry interface:
- Define ChannelRegistry interface with 7 cross-channel operations
- Implement LocalChannelRegistry with proper locking
- Add SessionSnapshot/StageSnapshot immutable copy types
- Delegate WorldcastMHF, FindSessionByCharID, DisconnectUser to Registry
- Migrate LockGlobalSema and guild mail handlers to use Registry
- Add comprehensive tests including concurrent access

Phase 4 — Per-channel enable/disable:
- Add Enabled *bool to EntranceChannelInfo (nil defaults to true)
- Skip disabled channels in startup loop, preserving ID stability
- Add IsEnabled() helper with backward-compatible default
- Update config.example.json with Enabled field
2026-02-19 18:13:34 +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
90c8a50316 fix(main): wrong configuration in last commit. 2025-10-18 19:24:24 +02:00
Houmgaor
f410cbd48b chore: minor files update. 2025-10-18 18:57:16 +02:00
stratic-dev
d123182a2f Renamed signv2 to api and enabled it by default 2024-03-15 19:37:55 +00:00
wish
0d28637095 support long messages, rename to RelayChannel, move commands out of main 2024-01-01 21:22:51 +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
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
wish
22b1d1b716 Merge pull request #99 from rockisch/dev-proxy
Add dev proxy config
2023-11-26 20:53:55 +11:00
wish
a2f488e5e3 move ProxyPort config out of DevMode 2023-11-26 20:50:08 +11:00
rockisch
e39630564e Add dev proxy config 2023-11-22 00:01:04 -03:00
wish
2f8d09b09e more GuildTresure optimisation 2023-10-24 21:21:21 +11:00
wish
f23da6fba5 remove Season from database 2023-07-18 23:00:00 +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
23138b2d5b update versioning 2023-04-11 21:08:00 +10:00
wish
f0db7f0a19 finalise 9.2 2023-04-01 17:58:26 +11:00
wish
ce30c1231d remove countdown on auto restart 2023-03-09 22:23:45 +11:00
wish
dcab41a6c7 rework logging code 2023-03-09 22:05:32 +11:00
wish
d5dc15fc93 implement guild semaphore locking 2023-03-09 17:31:43 +11:00
wish
cfe6bd118c update startup logging 2023-03-05 22:24:33 +11:00
wish
aa3deca70a remove obsolete LauncherServer 2022-12-31 01:57:16 +11:00
wish
f8e21483ef escape db connection arguments 2022-12-24 00:09:38 +11:00
wish
ec2ff61199 update versioning 2022-11-07 08:43:46 +11:00
wish
492e64d0d0 rename sign server and merge conflicts 2022-11-07 08:37:40 +11:00
rockisch
7f45d09d96 implement new sign server 2022-11-05 20:28:52 -03:00
wish
77f8f2019d finalise 9.1 2022-11-02 23:44:35 +11:00
wish
fda2e74442 persist cafe time 2022-10-24 16:51:56 +11:00
wish
77ed0564ce normalise config 2022-10-24 16:00:58 +11:00
wish
f346c181d3 add versioning print 2022-10-12 19:27:35 +11:00
Eclipse
2f123d96df Implemented the ability to enable/disable entrance, sign, and channel servers 2022-09-22 20:51:18 -04:00
Eclipse
44a42a3365 Implemented the ability to enable and disable commands in configuration as well as increased scope of the config to the entire project. 2022-09-18 14:15:11 -04:00
wish
e0176ca774 indexing changes and add world description 2022-09-04 16:40:06 +10:00
Eclipse
dc874877d7 Added world_name and land columns to the servers table to provide easier identification for external and internal applications utilizing the database 2022-09-04 01:16:15 -04:00
wish
8099c5fd66 make launcher server optional 2022-08-23 18:38:13 +10:00
wish
14d3b37435 discord bot cleanup 2022-08-17 23:29:16 +10:00
wish
d8072ee06e default netcafe rewards and maintenance 2022-08-13 18:22:56 +10:00
wish
d10dcbc630 remove unused import 2022-08-07 20:16:21 +10:00
wish
f8ed2ef40d use sequential seasons 2022-08-07 17:16:54 +10:00
wish
08a7b91e11 handle TransitMessage 2022-08-05 01:57:56 +10:00
wish
e9cc5cc3e2 parse host as FQDN or IP 2022-08-04 23:52:13 +10:00
wish
cdbc11c4b2 add option to disable soft-crashing 2022-08-04 23:11:19 +10:00