Houmgaor
4960c5cb5d
chore: apply gofmt formatting
2026-02-06 13:02:38 +01:00
Houmgaor
6ccbc24a4a
fix(gacha): prevent infinite loop in getRandomEntries
...
Add guards for edge cases:
- Empty entries with rolls > 0
- Zero or negative rolls
- Zero total weight in non-box mode
- Box mode with more rolls than available entries
Previously these cases caused infinite loops or panics.
2026-02-05 08:51:09 +01:00
Houmgaor
a11ee6d9eb
test(channelserver): add tests for guild member and gacha functions
...
Add comprehensive tests for pure logic functions:
- GuildMember.CanRecruit() and IsSubLeader() methods
- getRandomEntries() for gacha weighted/box selection
All targeted functions now have 100% coverage.
2026-02-05 08:48:05 +01:00
Houmgaor
f138cb5f77
fix: replace panic calls with proper error handling
...
Remove 51 panic() calls from handler code and replace with:
- Proper error logging using zap
- Appropriate client error responses (doAckBufFail, doAckSimpleFail)
- Graceful error recovery instead of server crashes
Files updated:
- handlers_guild_scout.go (9 panics)
- handlers_guild_tresure.go (10 panics)
- handlers_guild.go (7 panics + dead code removal)
- handlers_mail.go (5 panics)
- handlers.go (9 panics)
- handlers_tower.go (2 panics)
- handlers_clients.go (3 panics)
- handlers_guild_alliance.go (1 panic)
- handlers_quest.go (1 panic)
- handlers_rengoku.go (1 panic)
- handlers_stage.go (1 panic)
- handlers_data.go (1 panic)
- handlers_cafe.go (1 panic)
- signserver/sign_server.go (1 panic)
Remaining panics (3) are in test files and compression library
where panicking on programming errors is appropriate.
2026-02-02 17:14:34 +01:00
Houmgaor
dbc3b21827
test: increase test coverage across multiple packages
...
Add comprehensive tests for:
- network: CryptConn encryption connection tests
- signserver: character and member struct validation
- entranceserver: encryption roundtrip, server config tests
- channelserver: stage creation, object IDs, quest membership
All tests pass with race detector enabled.
2026-02-02 16:48:57 +01:00
wish
813cf169c9
mitigate LoadDecoMyset crashing on older versions
2026-02-02 16:29:42 +01:00
wish
633061caa1
prevent save error crashes
2026-02-02 16:27:54 +01:00
Houmgaor
80c3634895
fix(session): race condition.
2026-02-02 16:07:36 +01:00
Houmgaor
e654bc47bf
fix(stage): fix race condition with stages.
2026-02-02 16:05:39 +01:00
Houmgaor
488e8fa045
fix(stage): fix deadlock that was preventing stage change.
2026-02-02 16:04:45 +01:00
Houmgaor
7e9440d8cc
test: expand channelserver coverage from 20% to 25%
...
Add tests for:
- Discord handlers (getPlayerSlice, getCharacterList)
- House handlers (boxToBytes, HouseData, Title structs)
- Mail struct tests
- Mercenary handlers (Partner, HunterNavi structs)
- Shop/Gacha handlers (writeShopItems, ShopItem, Gacha structs)
- Additional handler coverage for guild, tower, and simple handlers
- Stage handler tests for binary operations and enumeration
- Channel server tests for BroadcastMHF and session management
2026-02-02 16:02:01 +01:00
Houmgaor
2d8f1d3b41
test: expand channelserver coverage from 16% to 20%
...
Add comprehensive tests for handler functions and utilities:
- Achievement system (GetAchData, curves, mappings)
- Language system (getLangStrings)
- Core handlers (empty handlers, simple responses)
- Cafe/boost handlers
- Diva defense handlers
- Reward, caravan, tactics handlers
- Festa/ranking handlers
- Cast binary constants
2026-02-02 15:15:47 +01:00
Houmgaor
711916f4a1
test: expand channelserver coverage from 12% to 16%
...
Add comprehensive tests for handler files:
- handlers_object: object creation, positioning, binary ops
- handlers_semaphore: create, acquire, release, check, delete
- handlers_reserve: stub handlers and reserve188/18B
- handlers_event: registration, release, feature weapons
- handlers_mutex: create, open, close, delete operations
- handlers_campaign: enumerate, state, apply
- handlers_bbs: user status, SNS status, article apply
- handlers_tournament: info, entry, acquire
- handlers_users: user binary operations
- handlers_clients: client enumeration
- handlers_rengoku: ranking
- handlers_register: raviente semaphore functions
- handlers_tower: tower info, tenrouirai, seibatu ranking
All tests pass with race detection enabled.
2026-02-02 11:42:47 +01:00
Houmgaor
0f1684564d
test: expand channelserver coverage from 7.5% to 12%
...
Add comprehensive tests for channelserver package:
- handlers_character_test.go: CharacterSaveData, pointer constants
- handlers_data_test.go: grpToGR function with boundary tests
- handlers_quest_test.go: findSubSliceIndices, equal functions
- handlers_simple_test.go: simple handlers, ack responses
- handlers_util_test.go: stub handlers, ack helpers
- sys_channel_server_test.go: Server, Raviente, stages, semaphores
- sys_object_test.go: Object, Stage, stageBinaryKey structs
All tests pass with race detection enabled.
2026-02-02 11:25:08 +01:00
Houmgaor
dad6a23bba
test: improve test coverage from 11% to 20%
...
Add comprehensive tests across multiple packages:
- mhfpacket: Add tests for 300+ packet opcodes, system packets,
MHF packets, and detailed parsing tests (6.4% -> 38.8%)
- timeserver: Add tests for all time functions (0% -> 97.4%)
- deltacomp: Add edge case tests for compression functions
- entranceserver: Add server creation tests
- binpacket: Add mail notify panic test
- config: Add Mode.String() tests
- signserver: Expand server tests
2026-02-02 11:02:52 +01:00
Houmgaor
db3e0bccc7
test: improve test coverage for mhfpacket, channelserver, and server packages
...
Add comprehensive tests for:
- Pure time functions in channelserver (sys_time_test.go)
- Stage-related packet parsing (msg_sys_stage_test.go)
- Acquire packet family parsing (msg_mhf_acquire_test.go)
- Extended mhfpacket tests for login, logout, and stage packets
- Entrance server makeHeader structure and checksum tests
- SignV2 server request/response JSON structure tests
2026-02-01 23:28:19 +01:00
Houmgaor
021705c006
fix(quest): add S6 compatibility for quest data backporting
...
Cherry-picked from 8d1c6a7 with conflict resolution.
2026-01-30 01:14:13 +01:00
Houmgaor
c4036daebc
fix(guild): conditionally write GR field in InfoGuild for G10+ only
...
Cherry-picked from main (8c219be ) with conflict resolution.
Pre-G10 clients don't have the GR field in the applicant list,
so only write it when RealClientMode >= G10.
Also optimizes two consecutive uint16(0) writes to single uint32(0).
2026-01-30 01:09:48 +01:00
Houmgaor
94175e6e85
fix(guild): fix nil pointer condition in GetGuildManageRight
...
Cherry-picked from main (5028355 ) with conflict resolution.
Changes condition from && to || to properly handle the case where
a player has a guild but also has a prevGuildID set.
2026-01-30 01:03:20 +01:00
Houmgaor
a66b15d6c8
fix(stage): add timeout to WaitStageBinary handler
...
Cherry-picked from main (c539905 ).
Prevents infinite loop when stage binary data never arrives by
limiting to 10 iterations (10 seconds) before returning empty response.
2026-01-30 01:02:43 +01:00
Houmgaor
355c2c01cc
fix(guild): fix poogie outfit unlock calculation
...
Cherry-picked from main (7459ded ) with conflict resolution.
The original fix changed the poogie outfit unlock from incorrect
math.Pow calculation to direct value assignment.
Also removes unused math import (531b3d2 ).
2026-01-30 01:02:18 +01:00
Houmgaor
982393daf4
test: add unit tests for cherry-pick impacted handlers
...
Add comprehensive tests documenting current behavior before applying
fixes from main branch. Tests cover:
- Cafe item PointCost parsing (uint32 vs uint16 for different client modes)
- Guild poogie outfit unlock calculation bug (math.Pow issue)
- Guild manage right nil pointer condition (&& vs || logic)
- InfoGuild applicant GR field size for <G10 clients
- Stage binary wait infinite loop risk (no timeout)
- Entrance server hardcoded clan member limit
2026-01-30 01:01:21 +01:00
Houmgaor
3a1b410ee3
fix(guild): rename GuildMealDuration to ClanMealDuration to match upstream 9.3
...
- Renamed config key from GuildMealDuration to ClanMealDuration
- Changed unit from minutes to seconds (matching upstream convention)
- Updated handler to use seconds-based calculation
- Updated documentation and examples
This fixes the bug where clan meals were not being shared between
guild members when using a config.json with the upstream naming.
2026-01-30 00:32:00 +01:00
Houmgaor
e929346bf3
test: add unit tests for core packages
...
Add comprehensive test coverage for:
- common/token: token generation and RNG tests
- common/stringsupport: string encoding, CSV operations
- common/byteframe: binary read/write operations
- common/mhfcourse: course/subscription logic
- network/crypt_packet: packet header parsing
- network/binpacket: binary packet round-trips
- network/mhfpacket: packet interface and opcode mapping
- config: configuration struct and loading
- server/entranceserver: response building
- server/signserver: response ID constants
- server/signv2server: HTTP endpoint validation
- server/channelserver: session, semaphore, and handler tests
All tests pass with race detector enabled.
2026-01-30 00:19:27 +01:00
Houmgaor
69cc84aa2f
refactor(distribution): use distribution_items table instead of data blob
...
Distributions now read items from the distribution_items table instead of
requiring a pre-built binary data blob. This enables creating distributions
via simple SQL inserts rather than generating binary data manually.
Changes:
- Add getDistributionItems() to fetch items from distribution_items table
- Update handleMsgMhfApplyDistItem to build response from table data
- Move server-side rewards (points, RP) to handleMsgMhfAcquireDistItem
- Support G8+ item format (13 bytes per item)
2026-01-29 23:59:19 +01:00
Houmgaor
64cc285fd8
doc: inline code documentation.
2025-11-24 18:41:37 +01:00
Houmgaor
a992c5a603
refactor(format): automated formatting with go fmt.
2025-11-24 17:59:41 +01:00
Houmgaor
bfdfed0c71
fix(presets): players with more than 40 presets would crash on logging in.
2025-11-24 11:20:00 +01:00
Houmgaor
67dad15204
fix(server): race condition that created server panic.
2025-11-24 00:51:45 +01:00
Houmgaor
c8c0dae8fe
test: imports basic tests, all passing.
2025-11-09 12:36:56 +01:00
wish
006f44f3a6
fix feature weapon RNG
2023-03-31 00:53:50 +11:00
wish
7d884da938
replace deprecated code
2023-03-31 00:04:51 +11:00
wish
a042cef5b1
fix possible infinite loop in gacha rolls
2023-03-30 23:32:10 +11:00
wish
8749674a63
replace deprecated rand call
2023-03-30 21:59:51 +11:00
wish
61d15ddd43
remove mail item workaround
2023-03-30 21:48:23 +11:00
wish
107eddfea5
stub interception map packets
2023-03-27 21:29:23 +11:00
wish
f85be55a6d
fix login boost creating hanging connections
2023-03-14 02:16:09 +11:00
wish
c344fdd4c9
fix scout enumeration data
2023-03-12 23:43:30 +11:00
wish
a2a4989cda
replace outdated code
2023-03-12 23:36:26 +11:00
wish
6aa075009e
timestamp fixes
2023-03-12 23:31:39 +11:00
wish
ccfd2ac36f
create RNG in token module
2023-03-12 23:29:50 +11:00
wish
cce558db9c
amend comment
2023-03-12 22:28:27 +11:00
wish
40d5c67902
merge shop enumeration fixes from feature/diva
2023-03-12 22:05:42 +11:00
wish
9a42042686
improve course command responses
2023-03-12 01:59:21 +11:00
wish
baf53ea212
flip error check in course command and remove unused code
2023-03-11 23:40:49 +11:00
wish
c95d02ec82
fix edge case on 0 rights int
2023-03-11 23:34:43 +11:00
wish
bcb71536ec
initial rights v4 concept
2023-03-11 23:17:14 +11:00
wish
29cf7add11
rework netcafe course activation
2023-03-11 16:26:16 +11:00
wish
c110082ab5
test session timeout
2023-03-11 01:08:21 +11:00
wish
ab4669acc9
unhide EnumerateQuest packet logs
2023-03-11 00:57:14 +11:00