mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-25 00:54:05 +01:00
refactor(channelserver): replace init() handler registration with explicit construction
The handler table was a package-level global populated by init(), making registration implicit and untestable. Move it to buildHandlerTable() which returns the map, store it as a Server struct field initialized in NewServer(), and add a missing-handler guard in handlePacketGroup to log a warning instead of panicking on unknown opcodes.
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"erupe-ce/common/byteframe"
|
||||
_config "erupe-ce/config"
|
||||
"erupe-ce/network"
|
||||
"erupe-ce/network/binpacket"
|
||||
"erupe-ce/network/mhfpacket"
|
||||
"erupe-ce/server/discordbot"
|
||||
@@ -81,6 +82,8 @@ type Server struct {
|
||||
questCacheLock sync.RWMutex
|
||||
questCacheData map[int][]byte
|
||||
questCacheTime map[int]time.Time
|
||||
|
||||
handlerTable map[network.PacketID]handlerFunc
|
||||
}
|
||||
|
||||
// NewServer creates a new Server type.
|
||||
@@ -109,6 +112,7 @@ func NewServer(config *Config) *Server {
|
||||
},
|
||||
questCacheData: make(map[int][]byte),
|
||||
questCacheTime: make(map[int]time.Time),
|
||||
handlerTable: buildHandlerTable(),
|
||||
}
|
||||
|
||||
// Mezeporta
|
||||
|
||||
Reference in New Issue
Block a user