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.
This commit is contained in:
Houmgaor
2026-02-20 21:18:40 +01:00
parent 28bf6e93fb
commit 458d8c9397
20 changed files with 182 additions and 124 deletions

View File

@@ -394,6 +394,8 @@ func handleMsgSysIssueLogkey(s *Session, p mhfpacket.MHFPacket) {
doAckBufSucceed(s, pkt.AckHandle, resp.Data())
}
const localhostAddrLE = uint32(0x0100007F) // 127.0.0.1 in little-endian
// Kill log binary layout constants
const (
killLogHeaderSize = 32 // bytes before monster kill count array
@@ -557,7 +559,7 @@ func handleMsgMhfTransitMessage(s *Session, p mhfpacket.MHFPacket) {
if !local {
resp.WriteUint32(binary.LittleEndian.Uint32(r.ip))
} else {
resp.WriteUint32(0x0100007F)
resp.WriteUint32(localhostAddrLE)
}
resp.WriteUint16(r.port)
resp.WriteUint32(r.charID)
@@ -757,7 +759,7 @@ func handleMsgMhfTransitMessage(s *Session, p mhfpacket.MHFPacket) {
if !local {
resp.WriteUint32(binary.LittleEndian.Uint32(sr.ip))
} else {
resp.WriteUint32(0x0100007F)
resp.WriteUint32(localhostAddrLE)
}
resp.WriteUint16(sr.port)