From dbedab4d33b8712d5feb942349239c23808662e0 Mon Sep 17 00:00:00 2001 From: wish Date: Sat, 22 Jul 2023 16:47:44 +1000 Subject: [PATCH] add ClientMode support based on Forward.4 --- network/crypt_conn.go | 8 +++++--- network/mhfpacket/msg_mhf_acquire_cafe_item.go | 9 +++++++-- network/mhfpacket/msg_sys_terminal_log.go | 2 +- server/channelserver/handlers_guild.go | 4 ++++ server/entranceserver/make_resp.go | 2 +- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/network/crypt_conn.go b/network/crypt_conn.go index 439e9e3a0..3a952ee19 100644 --- a/network/crypt_conn.go +++ b/network/crypt_conn.go @@ -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 diff --git a/network/mhfpacket/msg_mhf_acquire_cafe_item.go b/network/mhfpacket/msg_mhf_acquire_cafe_item.go index 8dcad0b53..04e603a44 100644 --- a/network/mhfpacket/msg_mhf_acquire_cafe_item.go +++ b/network/mhfpacket/msg_mhf_acquire_cafe_item.go @@ -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() - m.PointCost = bf.ReadUint32() + if _config.ErupeConfig.RealClientMode >= _config.G1 { + m.PointCost = bf.ReadUint32() + } else { + m.PointCost = uint32(bf.ReadUint16()) + } m.Unk0 = bf.ReadUint16() return nil } diff --git a/network/mhfpacket/msg_sys_terminal_log.go b/network/mhfpacket/msg_sys_terminal_log.go index 27cc5b1f6..43bf43dd3 100644 --- a/network/mhfpacket/msg_sys_terminal_log.go +++ b/network/mhfpacket/msg_sys_terminal_log.go @@ -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++ { diff --git a/server/channelserver/handlers_guild.go b/server/channelserver/handlers_guild.go index 879969e79..3c28a7bed 100644 --- a/server/channelserver/handlers_guild.go +++ b/server/channelserver/handlers_guild.go @@ -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 } diff --git a/server/entranceserver/make_resp.go b/server/entranceserver/make_resp.go index 86256d02c..3d64dd9f2 100644 --- a/server/entranceserver/make_resp.go +++ b/server/entranceserver/make_resp.go @@ -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))