Config / DB now its own package

This commit is contained in:
stratic-dev
2024-10-12 22:37:42 +01:00
parent 44692e986e
commit 5f975c97b5
76 changed files with 3249 additions and 2359 deletions

View File

@@ -3,7 +3,7 @@ package network
import (
"encoding/hex"
"errors"
_config "erupe-ce/config"
"erupe-ce/config"
"erupe-ce/network/crypto"
"fmt"
"io"
@@ -51,7 +51,7 @@ func (cc *CryptConn) ReadPacket() ([]byte, error) {
var encryptedPacketBody []byte
// Don't know when support for this was added, works in Forward.4, doesn't work in Season 6.0
if _config.ErupeConfig.ClientID < _config.F1 {
if config.GetConfig().ClientID < config.F1 {
encryptedPacketBody = make([]byte, cph.DataSize)
} else {
encryptedPacketBody = make([]byte, uint32(cph.DataSize)+(uint32(cph.Pf0-0x03)*0x1000))

View File

@@ -2,7 +2,7 @@ package mhfpacket
import (
"errors"
_config "erupe-ce/config"
"erupe-ce/config"
"erupe-ce/network"
"erupe-ce/utils/byteframe"
@@ -30,7 +30,7 @@ func (m *MsgMhfAcquireCafeItem) Parse(bf *byteframe.ByteFrame) error {
m.ItemType = bf.ReadUint16()
m.ItemID = bf.ReadUint16()
m.Quant = bf.ReadUint16()
if _config.ErupeConfig.ClientID >= _config.G1 {
if config.GetConfig().ClientID >= config.G1 {
m.PointCost = bf.ReadUint32()
} else {
m.PointCost = uint32(bf.ReadUint16())

View File

@@ -2,7 +2,7 @@ package mhfpacket
import (
"errors"
_config "erupe-ce/config"
"erupe-ce/config"
"erupe-ce/network"
"erupe-ce/utils/byteframe"
)
@@ -26,10 +26,10 @@ func (m *MsgMhfApplyDistItem) Parse(bf *byteframe.ByteFrame) error {
m.AckHandle = bf.ReadUint32()
m.DistributionType = bf.ReadUint8()
m.DistributionID = bf.ReadUint32()
if _config.ErupeConfig.ClientID >= _config.G8 {
if config.GetConfig().ClientID >= config.G8 {
m.Unk2 = bf.ReadUint32()
}
if _config.ErupeConfig.ClientID >= _config.G10 {
if config.GetConfig().ClientID >= config.G10 {
m.Unk3 = bf.ReadUint32()
}
return nil

View File

@@ -2,7 +2,7 @@ package mhfpacket
import (
"errors"
_config "erupe-ce/config"
"erupe-ce/config"
"erupe-ce/network"
"erupe-ce/utils/byteframe"
)
@@ -27,7 +27,7 @@ func (m *MsgMhfEnumerateDistItem) Parse(bf *byteframe.ByteFrame) error {
m.DistType = bf.ReadUint8()
m.Unk1 = bf.ReadUint8()
m.Unk2 = bf.ReadUint16() // Maximum? Hardcoded to 256
if _config.ErupeConfig.ClientID >= _config.Z1 {
if config.GetConfig().ClientID >= config.Z1 {
m.Unk3 = bf.ReadBytes(uint(bf.ReadUint8()))
}
return nil

View File

@@ -2,7 +2,7 @@ package mhfpacket
import (
"errors"
_config "erupe-ce/config"
"erupe-ce/config"
"erupe-ce/network"
"erupe-ce/utils/byteframe"
@@ -29,7 +29,7 @@ func (m *MsgMhfEnumerateQuest) Parse(bf *byteframe.ByteFrame) error {
m.Unk0 = bf.ReadUint8()
m.World = bf.ReadUint8()
m.Counter = bf.ReadUint16()
if _config.ErupeConfig.ClientID <= _config.Z1 {
if config.GetConfig().ClientID <= config.Z1 {
m.Offset = uint16(bf.ReadUint8())
} else {
m.Offset = bf.ReadUint16()

View File

@@ -2,7 +2,7 @@ package mhfpacket
import (
"errors"
_config "erupe-ce/config"
"erupe-ce/config"
"erupe-ce/network"
"erupe-ce/utils/byteframe"
@@ -31,7 +31,7 @@ func (m *MsgMhfEnumerateShop) Parse(bf *byteframe.ByteFrame) error {
m.ShopID = bf.ReadUint32()
m.Limit = bf.ReadUint16()
m.Unk3 = bf.ReadUint8()
if _config.ErupeConfig.ClientID >= _config.G2 {
if config.GetConfig().ClientID >= config.G2 {
m.Unk4 = bf.ReadUint8()
m.Unk5 = bf.ReadUint32()
}

View File

@@ -2,7 +2,7 @@ package mhfpacket
import (
"errors"
_config "erupe-ce/config"
"erupe-ce/config"
"erupe-ce/network"
"erupe-ce/utils/byteframe"
@@ -29,7 +29,7 @@ func (m *MsgMhfSavedata) Parse(bf *byteframe.ByteFrame) error {
m.AllocMemSize = bf.ReadUint32()
m.SaveType = bf.ReadUint8()
m.Unk1 = bf.ReadUint32()
if _config.ErupeConfig.ClientID >= _config.G1 {
if config.GetConfig().ClientID >= config.G1 {
m.DataSize = bf.ReadUint32()
}
if m.DataSize == 0 { // seems to be used when DataSize = 0 rather than on savetype?

View File

@@ -2,7 +2,7 @@ package mhfpacket
import (
"errors"
_config "erupe-ce/config"
"erupe-ce/config"
"erupe-ce/network"
"erupe-ce/utils/byteframe"
@@ -31,12 +31,12 @@ func (m *MsgMhfStampcardStamp) Opcode() network.PacketID {
func (m *MsgMhfStampcardStamp) Parse(bf *byteframe.ByteFrame) error {
m.AckHandle = bf.ReadUint32()
m.HR = bf.ReadUint16()
if _config.ErupeConfig.ClientID >= _config.G1 {
if config.GetConfig().ClientID >= config.G1 {
m.GR = bf.ReadUint16()
}
m.Stamps = bf.ReadUint16()
bf.ReadUint16() // Zeroed
if _config.ErupeConfig.ClientID >= _config.Z2 {
if config.GetConfig().ClientID >= config.Z2 {
m.Reward1 = uint16(bf.ReadUint32())
m.Reward2 = uint16(bf.ReadUint32())
m.Item1 = uint16(bf.ReadUint32())

View File

@@ -3,7 +3,7 @@ package mhfpacket
import (
"errors"
_config "erupe-ce/config"
"erupe-ce/config"
"erupe-ce/network"
"erupe-ce/utils/byteframe"
)
@@ -22,11 +22,11 @@ func (m *MsgMhfUpdateMyhouseInfo) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfUpdateMyhouseInfo) Parse(bf *byteframe.ByteFrame) error {
m.AckHandle = bf.ReadUint32()
if _config.ErupeConfig.ClientID >= _config.G10 {
if config.GetConfig().ClientID >= config.G10 {
m.Data = bf.ReadBytes(362)
} else if _config.ErupeConfig.ClientID >= _config.GG {
} else if config.GetConfig().ClientID >= config.GG {
m.Data = bf.ReadBytes(338)
} else if _config.ErupeConfig.ClientID >= _config.F5 {
} else if config.GetConfig().ClientID >= config.F5 {
// G1 is a guess
m.Data = bf.ReadBytes(314)
} else {

View File

@@ -2,7 +2,7 @@ package mhfpacket
import (
"errors"
_config "erupe-ce/config"
"erupe-ce/config"
"erupe-ce/network"
"erupe-ce/utils/byteframe"
)
@@ -24,7 +24,7 @@ func (m *MsgSysCreateAcquireSemaphore) Opcode() network.PacketID {
func (m *MsgSysCreateAcquireSemaphore) Parse(bf *byteframe.ByteFrame) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint16()
if _config.ErupeConfig.ClientID >= _config.S7 { // Assuming this was added with Ravi?
if config.GetConfig().ClientID >= config.S7 { // Assuming this was added with Ravi?
m.PlayerCount = bf.ReadUint8()
}
bf.ReadUint8() // SemaphoreID length

View File

@@ -2,7 +2,7 @@ package mhfpacket
import (
"errors"
_config "erupe-ce/config"
"erupe-ce/config"
"erupe-ce/network"
"erupe-ce/utils/byteframe"
@@ -25,7 +25,7 @@ func (m *MsgSysCreateSemaphore) Opcode() network.PacketID {
func (m *MsgSysCreateSemaphore) Parse(bf *byteframe.ByteFrame) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint16()
if _config.ErupeConfig.ClientID >= _config.S7 { // Assuming this was added with Ravi?
if config.GetConfig().ClientID >= config.S7 { // Assuming this was added with Ravi?
m.PlayerCount = bf.ReadUint8()
}
bf.ReadUint8() // SemaphoreID length

View File

@@ -2,7 +2,7 @@ package mhfpacket
import (
"errors"
_config "erupe-ce/config"
"erupe-ce/config"
"erupe-ce/network"
"erupe-ce/utils/byteframe"
@@ -48,7 +48,7 @@ func (m *MsgSysTerminalLog) Parse(bf *byteframe.ByteFrame) error {
e.Unk1 = bf.ReadInt32()
e.Unk2 = bf.ReadInt32()
e.Unk3 = bf.ReadInt32()
if _config.ErupeConfig.ClientID >= _config.G1 {
if config.GetConfig().ClientID >= config.G1 {
for j := 0; j < 4; j++ {
e.Unk4 = append(e.Unk4, bf.ReadInt32())
}