mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +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:
@@ -312,7 +312,7 @@ func (s *Server) BroadcastChatMessage(message string) {
|
||||
msgBinChat := &binpacket.MsgBinChat{
|
||||
Unk0: 0,
|
||||
Type: 5,
|
||||
Flags: 0x80,
|
||||
Flags: chatFlagServer,
|
||||
Message: message,
|
||||
SenderName: s.name,
|
||||
}
|
||||
@@ -420,8 +420,15 @@ func (s *Server) HasSemaphore(ses *Session) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Server ID arithmetic constants
|
||||
const (
|
||||
serverIDHighMask = uint16(0xFF00)
|
||||
serverIDBase = 0x1000 // first server ID offset
|
||||
serverIDStride = 0x100 // spacing between server IDs
|
||||
)
|
||||
|
||||
// Season returns the current in-game season (0-2) based on server ID and time.
|
||||
func (s *Server) Season() uint8 {
|
||||
sid := int64(((s.ID & 0xFF00) - 4096) / 256)
|
||||
return uint8(((TimeAdjusted().Unix() / 86400) + sid) % 3)
|
||||
sid := int64(((s.ID & serverIDHighMask) - serverIDBase) / serverIDStride)
|
||||
return uint8(((TimeAdjusted().Unix() / secsPerDay) + sid) % 3)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user