add ClientMode support based on Forward.4

This commit is contained in:
wish
2023-07-22 16:47:44 +10:00
parent cc428d85d3
commit dbedab4d33
5 changed files with 18 additions and 7 deletions

View File

@@ -47,8 +47,10 @@ func (cc *CryptConn) ReadPacket() ([]byte, error) {
return nil, err
}
dataSize := uint32(cph.DataSize) + (uint32(cph.Pf0-0x03) * 0x1000)
// Now read the encrypted packet body after getting its size from the header.
encryptedPacketBody := make([]byte, cph.DataSize)
encryptedPacketBody := make([]byte, dataSize)
_, err = io.ReadFull(cc.conn, encryptedPacketBody)
if err != nil {
return nil, err
@@ -56,7 +58,7 @@ func (cc *CryptConn) ReadPacket() ([]byte, error) {
// Update the key rotation before decrypting.
if cph.KeyRotDelta != 0 {
cc.readKeyRot = (uint32(cph.KeyRotDelta) * (cc.readKeyRot + 1))
cc.readKeyRot = uint32(cph.KeyRotDelta) * (cc.readKeyRot + 1)
}
out, combinedCheck, check0, check1, check2 := crypto.Decrypt(encryptedPacketBody, cc.readKeyRot, nil)
@@ -94,7 +96,7 @@ func (cc *CryptConn) SendPacket(data []byte) error {
keyRotDelta := byte(3)
if keyRotDelta != 0 {
cc.sendKeyRot = (uint32(keyRotDelta) * (cc.sendKeyRot + 1))
cc.sendKeyRot = uint32(keyRotDelta) * (cc.sendKeyRot + 1)
}
// Encrypt the data

View File

@@ -2,10 +2,11 @@ package mhfpacket
import (
"errors"
_config "erupe-ce/config"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
"erupe-ce/common/byteframe"
)
// MsgMhfAcquireCafeItem represents the MSG_MHF_ACQUIRE_CAFE_ITEM
@@ -30,7 +31,11 @@ func (m *MsgMhfAcquireCafeItem) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Cl
m.ItemType = bf.ReadUint16()
m.ItemID = bf.ReadUint16()
m.Quant = bf.ReadUint16()
if _config.ErupeConfig.RealClientMode >= _config.G1 {
m.PointCost = bf.ReadUint32()
} else {
m.PointCost = uint32(bf.ReadUint16())
}
m.Unk0 = bf.ReadUint16()
return nil
}

View File

@@ -39,7 +39,7 @@ func (m *MsgSysTerminalLog) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Client
m.Unk0 = bf.ReadUint16()
values := 15
if _config.ErupeConfig.RealClientMode <= _config.S6 {
if _config.ErupeConfig.RealClientMode <= _config.F4 {
values = 7
}
for i := 0; i < int(m.EntryCount); i++ {

View File

@@ -130,6 +130,8 @@ func (g *Guild) Rank() uint16 {
if g.RankRP < u {
if _config.ErupeConfig.RealClientMode <= _config.S6 && i >= 12 {
return 12
} else if _config.ErupeConfig.RealClientMode <= _config.F4 && i >= 13 {
return 13
} else if _config.ErupeConfig.RealClientMode <= _config.G32 && i >= 14 {
return 14
}
@@ -138,6 +140,8 @@ func (g *Guild) Rank() uint16 {
}
if _config.ErupeConfig.RealClientMode <= _config.S6 {
return 12
} else if _config.ErupeConfig.RealClientMode <= _config.F4 {
return 13
} else if _config.ErupeConfig.RealClientMode <= _config.G32 {
return 14
}

View File

@@ -56,7 +56,7 @@ func encodeServerInfo(config *_config.Config, s *Server, local bool) []byte {
bf.WriteUint8(si.Recommended)
}
if s.erupeConfig.RealClientMode <= _config.S6 {
if s.erupeConfig.RealClientMode <= _config.F4 {
combined := append(stringsupport.UTF8ToSJIS(si.Name), []byte{0x00}...)
combined = append(combined, stringsupport.UTF8ToSJIS(si.Description)...)
bf.WriteBytes(stringsupport.PaddedString(string(combined), 65, false))