mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
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
67 lines
1.6 KiB
Go
67 lines
1.6 KiB
Go
package mhfpacket
|
|
|
|
import (
|
|
"errors"
|
|
_config "erupe-ce/config"
|
|
|
|
"erupe-ce/common/byteframe"
|
|
"erupe-ce/network"
|
|
"erupe-ce/network/clientctx"
|
|
)
|
|
|
|
// TerminalLogEntry represents an entry in the MSG_SYS_TERMINAL_LOG packet.
|
|
type TerminalLogEntry struct {
|
|
Index uint32
|
|
Type1 uint8
|
|
Type2 uint8
|
|
Unk0 int16
|
|
Unk1 int32
|
|
Unk2 int32
|
|
Unk3 int32
|
|
Unk4 []int32
|
|
}
|
|
|
|
// MsgSysTerminalLog represents the MSG_SYS_TERMINAL_LOG
|
|
type MsgSysTerminalLog struct {
|
|
AckHandle uint32
|
|
LogID uint32 // 0 on the first packet, and the server sends back a value to use for subsequent requests.
|
|
Entries []TerminalLogEntry
|
|
}
|
|
|
|
// Opcode returns the ID associated with this packet type.
|
|
func (m *MsgSysTerminalLog) Opcode() network.PacketID {
|
|
return network.MSG_SYS_TERMINAL_LOG
|
|
}
|
|
|
|
// Parse parses the packet from binary
|
|
func (m *MsgSysTerminalLog) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
|
m.AckHandle = bf.ReadUint32()
|
|
m.LogID = bf.ReadUint32()
|
|
entryCount := int(bf.ReadUint16())
|
|
bf.ReadUint16() // Zeroed
|
|
|
|
for i := 0; i < entryCount; i++ {
|
|
var e TerminalLogEntry
|
|
e.Index = bf.ReadUint32()
|
|
e.Type1 = bf.ReadUint8()
|
|
e.Type2 = bf.ReadUint8()
|
|
e.Unk0 = bf.ReadInt16()
|
|
e.Unk1 = bf.ReadInt32()
|
|
e.Unk2 = bf.ReadInt32()
|
|
e.Unk3 = bf.ReadInt32()
|
|
if ctx.RealClientMode >= _config.G1 {
|
|
for j := 0; j < 4; j++ {
|
|
e.Unk4 = append(e.Unk4, bf.ReadInt32())
|
|
}
|
|
}
|
|
m.Entries = append(m.Entries, e)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// Build builds a binary packet from the current data.
|
|
func (m *MsgSysTerminalLog) Build(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
|
return errors.New("NOT IMPLEMENTED")
|
|
}
|