mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-26 17:43:21 +01:00
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:
@@ -15,7 +15,7 @@ import (
|
||||
const (
|
||||
divaPhaseDuration = 601200 // 6d 23h = first song phase
|
||||
divaInterlude = 3900 // 65 min = gap between phases
|
||||
divaWeekDuration = 604800 // 7 days = subsequent phase length
|
||||
divaWeekDuration = secsPerWeek // 7 days = subsequent phase length
|
||||
divaTotalLifespan = 2977200 // ~34.5 days = full event window
|
||||
)
|
||||
|
||||
@@ -76,7 +76,8 @@ func handleMsgMhfGetUdSchedule(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfGetUdSchedule)
|
||||
bf := byteframe.NewByteFrame()
|
||||
|
||||
id, start := uint32(0xCAFEBEEF), uint32(0)
|
||||
const divaIDSentinel = uint32(0xCAFEBEEF)
|
||||
id, start := divaIDSentinel, uint32(0)
|
||||
rows, err := s.server.db.Queryx("SELECT id, (EXTRACT(epoch FROM start_time)::int) as start_time FROM events WHERE event_type='diva'")
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to query diva schedule", zap.Error(err))
|
||||
|
||||
Reference in New Issue
Block a user