mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-28 02:23:37 +01:00
refactor(config): eliminate ErupeConfig global variable
Replace the mutable global `_config.ErupeConfig` with dependency injection across 79 files. Config is now threaded through existing paths: `ClientContext.RealClientMode` for packet encoding, `s.server. erupeConfig` for channel handlers, and explicit parameters for utility functions. This removes hidden coupling, enables test parallelism without global save/restore, and prevents low-level packages from reaching up to the config layer. Key changes: - Enrich ClientContext with RealClientMode for packet files - Add mode parameter to CryptConn, mhfitem, mhfcourse functions - Convert handlers_commands init() to lazy sync.Once initialization - Delete global var, init(), and helper functions from config.go - Update all tests to pass config explicitly
This commit is contained in:
@@ -4,7 +4,9 @@ import (
|
||||
"testing"
|
||||
|
||||
"erupe-ce/common/byteframe"
|
||||
_config "erupe-ce/config"
|
||||
"erupe-ce/network"
|
||||
"erupe-ce/network/clientctx"
|
||||
)
|
||||
|
||||
func TestMsgMhfUpdateGuacotOpcode_Guacot(t *testing.T) {
|
||||
@@ -39,7 +41,7 @@ func TestMsgMhfUpdateGuacotParse_SingleEntry(t *testing.T) {
|
||||
|
||||
pkt := &MsgMhfUpdateGuacot{}
|
||||
_, _ = bf.Seek(0, 0)
|
||||
err := pkt.Parse(bf, nil)
|
||||
err := pkt.Parse(bf, &clientctx.ClientContext{RealClientMode: _config.ZZ})
|
||||
if err != nil {
|
||||
t.Fatalf("Parse() error: %v", err)
|
||||
}
|
||||
@@ -100,7 +102,7 @@ func TestMsgMhfUpdateGuacotParse_MultipleEntries(t *testing.T) {
|
||||
|
||||
pkt := &MsgMhfUpdateGuacot{}
|
||||
_, _ = bf.Seek(0, 0)
|
||||
err := pkt.Parse(bf, nil)
|
||||
err := pkt.Parse(bf, &clientctx.ClientContext{RealClientMode: _config.ZZ})
|
||||
if err != nil {
|
||||
t.Fatalf("Parse() error: %v", err)
|
||||
}
|
||||
@@ -130,7 +132,7 @@ func TestMsgMhfUpdateGuacotParse_ZeroEntries(t *testing.T) {
|
||||
|
||||
pkt := &MsgMhfUpdateGuacot{}
|
||||
_, _ = bf.Seek(0, 0)
|
||||
err := pkt.Parse(bf, nil)
|
||||
err := pkt.Parse(bf, &clientctx.ClientContext{RealClientMode: _config.ZZ})
|
||||
if err != nil {
|
||||
t.Fatalf("Parse() error: %v", err)
|
||||
}
|
||||
@@ -161,7 +163,7 @@ func TestMsgMhfUpdateGuacotParse_DeletionEntry(t *testing.T) {
|
||||
|
||||
pkt := &MsgMhfUpdateGuacot{}
|
||||
_, _ = bf.Seek(0, 0)
|
||||
err := pkt.Parse(bf, nil)
|
||||
err := pkt.Parse(bf, &clientctx.ClientContext{RealClientMode: _config.ZZ})
|
||||
if err != nil {
|
||||
t.Fatalf("Parse() error: %v", err)
|
||||
}
|
||||
@@ -188,7 +190,7 @@ func TestMsgMhfUpdateGuacotParse_EmptyName(t *testing.T) {
|
||||
|
||||
pkt := &MsgMhfUpdateGuacot{}
|
||||
_, _ = bf.Seek(0, 0)
|
||||
err := pkt.Parse(bf, nil)
|
||||
err := pkt.Parse(bf, &clientctx.ClientContext{RealClientMode: _config.ZZ})
|
||||
if err != nil {
|
||||
t.Fatalf("Parse() error: %v", err)
|
||||
}
|
||||
@@ -206,7 +208,7 @@ func TestMsgMhfEnumerateGuacotParse(t *testing.T) {
|
||||
|
||||
pkt := &MsgMhfEnumerateGuacot{}
|
||||
_, _ = bf.Seek(0, 0)
|
||||
err := pkt.Parse(bf, nil)
|
||||
err := pkt.Parse(bf, &clientctx.ClientContext{RealClientMode: _config.ZZ})
|
||||
if err != nil {
|
||||
t.Fatalf("Parse() error: %v", err)
|
||||
}
|
||||
@@ -221,7 +223,7 @@ func TestMsgMhfEnumerateGuacotParse(t *testing.T) {
|
||||
|
||||
func TestMsgMhfUpdateGuacotBuild_NotImplemented(t *testing.T) {
|
||||
pkt := &MsgMhfUpdateGuacot{}
|
||||
err := pkt.Build(byteframe.NewByteFrame(), nil)
|
||||
err := pkt.Build(byteframe.NewByteFrame(), &clientctx.ClientContext{RealClientMode: _config.ZZ})
|
||||
if err == nil {
|
||||
t.Error("Build() should return error (not implemented)")
|
||||
}
|
||||
@@ -229,7 +231,7 @@ func TestMsgMhfUpdateGuacotBuild_NotImplemented(t *testing.T) {
|
||||
|
||||
func TestMsgMhfEnumerateGuacotBuild_NotImplemented(t *testing.T) {
|
||||
pkt := &MsgMhfEnumerateGuacot{}
|
||||
err := pkt.Build(byteframe.NewByteFrame(), nil)
|
||||
err := pkt.Build(byteframe.NewByteFrame(), &clientctx.ClientContext{RealClientMode: _config.ZZ})
|
||||
if err == nil {
|
||||
t.Error("Build() should return error (not implemented)")
|
||||
}
|
||||
@@ -252,7 +254,7 @@ func TestGoocooStruct_Data1Size(t *testing.T) {
|
||||
|
||||
pkt := &MsgMhfUpdateGuacot{}
|
||||
_, _ = bf.Seek(0, 0)
|
||||
_ = pkt.Parse(bf, nil)
|
||||
_ = pkt.Parse(bf, &clientctx.ClientContext{RealClientMode: _config.ZZ})
|
||||
|
||||
g := pkt.Goocoos[0]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user