mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 15:34:38 +01:00
Merge pull request #78 from ZeruLight/fix/transit-message
fix/transit-message
This commit is contained in:
@@ -47,8 +47,10 @@ func (cc *CryptConn) ReadPacket() ([]byte, error) {
|
|||||||
return nil, err
|
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.
|
// 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)
|
_, err = io.ReadFull(cc.conn, encryptedPacketBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -56,7 +58,7 @@ func (cc *CryptConn) ReadPacket() ([]byte, error) {
|
|||||||
|
|
||||||
// Update the key rotation before decrypting.
|
// Update the key rotation before decrypting.
|
||||||
if cph.KeyRotDelta != 0 {
|
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)
|
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)
|
keyRotDelta := byte(3)
|
||||||
|
|
||||||
if keyRotDelta != 0 {
|
if keyRotDelta != 0 {
|
||||||
cc.sendKeyRot = (uint32(keyRotDelta) * (cc.sendKeyRot + 1))
|
cc.sendKeyRot = uint32(keyRotDelta) * (cc.sendKeyRot + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encrypt the data
|
// Encrypt the data
|
||||||
|
|||||||
@@ -2,10 +2,11 @@ package mhfpacket
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
_config "erupe-ce/config"
|
||||||
|
|
||||||
|
"erupe-ce/common/byteframe"
|
||||||
"erupe-ce/network"
|
"erupe-ce/network"
|
||||||
"erupe-ce/network/clientctx"
|
"erupe-ce/network/clientctx"
|
||||||
"erupe-ce/common/byteframe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// MsgMhfAcquireCafeItem represents the MSG_MHF_ACQUIRE_CAFE_ITEM
|
// 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.ItemType = bf.ReadUint16()
|
||||||
m.ItemID = bf.ReadUint16()
|
m.ItemID = bf.ReadUint16()
|
||||||
m.Quant = 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()
|
m.Unk0 = bf.ReadUint16()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ func (m *MsgSysTerminalLog) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Client
|
|||||||
m.Unk0 = bf.ReadUint16()
|
m.Unk0 = bf.ReadUint16()
|
||||||
|
|
||||||
values := 15
|
values := 15
|
||||||
if _config.ErupeConfig.RealClientMode <= _config.S6 {
|
if _config.ErupeConfig.RealClientMode <= _config.F4 {
|
||||||
values = 7
|
values = 7
|
||||||
}
|
}
|
||||||
for i := 0; i < int(m.EntryCount); i++ {
|
for i := 0; i < int(m.EntryCount); i++ {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"erupe-ce/common/mhfcourse"
|
"erupe-ce/common/mhfcourse"
|
||||||
ps "erupe-ce/common/pascalstring"
|
ps "erupe-ce/common/pascalstring"
|
||||||
"erupe-ce/common/stringsupport"
|
"erupe-ce/common/stringsupport"
|
||||||
|
_config "erupe-ce/config"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
@@ -447,48 +448,110 @@ func handleMsgMhfTransitMessage(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 4: // Find Party
|
case 4: // Find Party
|
||||||
|
type FindPartyParams struct {
|
||||||
|
StagePrefix string
|
||||||
|
RankRestriction uint16
|
||||||
|
Targets []uint16
|
||||||
|
Unk0 []uint16
|
||||||
|
Unk1 []uint16
|
||||||
|
QuestID []uint16
|
||||||
|
}
|
||||||
|
findPartyParams := FindPartyParams{
|
||||||
|
StagePrefix: "sl2Ls210",
|
||||||
|
}
|
||||||
bf := byteframe.NewByteFrameFromBytes(pkt.MessageData)
|
bf := byteframe.NewByteFrameFromBytes(pkt.MessageData)
|
||||||
setting := bf.ReadUint8()
|
numParams := int(bf.ReadUint8())
|
||||||
maxResults := bf.ReadUint16()
|
maxResults := bf.ReadUint16()
|
||||||
bf.Seek(2, 1)
|
for i := 0; i < numParams; i++ {
|
||||||
partyType := bf.ReadUint16()
|
switch bf.ReadUint8() {
|
||||||
rankRestriction := uint16(0)
|
case 0:
|
||||||
if setting >= 2 {
|
values := int(bf.ReadUint8())
|
||||||
bf.Seek(2, 1)
|
for i := 0; i < values; i++ {
|
||||||
rankRestriction = bf.ReadUint16()
|
if _config.ErupeConfig.RealClientMode >= _config.Z1 {
|
||||||
}
|
findPartyParams.RankRestriction = bf.ReadUint16()
|
||||||
targets := make([]uint16, 4)
|
} else {
|
||||||
if setting >= 3 {
|
findPartyParams.RankRestriction = uint16(bf.ReadInt8())
|
||||||
bf.Seek(1, 1)
|
}
|
||||||
lenTargets := int(bf.ReadUint8())
|
}
|
||||||
for i := 0; i < lenTargets; i++ {
|
case 1:
|
||||||
targets[i] = bf.ReadUint16()
|
values := int(bf.ReadUint8())
|
||||||
|
for i := 0; i < values; i++ {
|
||||||
|
if _config.ErupeConfig.RealClientMode >= _config.Z1 {
|
||||||
|
findPartyParams.Targets = append(findPartyParams.Targets, bf.ReadUint16())
|
||||||
|
} else {
|
||||||
|
findPartyParams.Targets = append(findPartyParams.Targets, uint16(bf.ReadInt8()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
values := int(bf.ReadUint8())
|
||||||
|
for i := 0; i < values; i++ {
|
||||||
|
var value int16
|
||||||
|
if _config.ErupeConfig.RealClientMode >= _config.Z1 {
|
||||||
|
value = bf.ReadInt16()
|
||||||
|
} else {
|
||||||
|
value = int16(bf.ReadInt8())
|
||||||
|
}
|
||||||
|
switch value {
|
||||||
|
case 0: // Public Bar
|
||||||
|
findPartyParams.StagePrefix = "sl2Ls210"
|
||||||
|
case 1: // Tokotoko Partnya
|
||||||
|
findPartyParams.StagePrefix = "sl2Ls463"
|
||||||
|
case 2: // Hunting Prowess Match
|
||||||
|
findPartyParams.StagePrefix = "sl2Ls286"
|
||||||
|
case 3: // Volpakkun Together
|
||||||
|
findPartyParams.StagePrefix = "sl2Ls465"
|
||||||
|
case 5: // Quick Party
|
||||||
|
// Unk
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 3: // Unknown
|
||||||
|
values := int(bf.ReadUint8())
|
||||||
|
for i := 0; i < values; i++ {
|
||||||
|
if _config.ErupeConfig.RealClientMode >= _config.Z1 {
|
||||||
|
findPartyParams.Unk0 = append(findPartyParams.Unk0, bf.ReadUint16())
|
||||||
|
} else {
|
||||||
|
findPartyParams.Unk0 = append(findPartyParams.Unk0, uint16(bf.ReadInt8()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 4: // Looking for n or already have n
|
||||||
|
values := int(bf.ReadUint8())
|
||||||
|
for i := 0; i < values; i++ {
|
||||||
|
if _config.ErupeConfig.RealClientMode >= _config.Z1 {
|
||||||
|
findPartyParams.Unk1 = append(findPartyParams.Unk1, bf.ReadUint16())
|
||||||
|
} else {
|
||||||
|
findPartyParams.Unk1 = append(findPartyParams.Unk1, uint16(bf.ReadInt8()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
|
values := int(bf.ReadUint8())
|
||||||
|
for i := 0; i < values; i++ {
|
||||||
|
if _config.ErupeConfig.RealClientMode >= _config.Z1 {
|
||||||
|
findPartyParams.QuestID = append(findPartyParams.QuestID, bf.ReadUint16())
|
||||||
|
} else {
|
||||||
|
findPartyParams.QuestID = append(findPartyParams.QuestID, uint16(bf.ReadInt8()))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var stagePrefix string
|
|
||||||
switch partyType {
|
|
||||||
case 0: // Public Bar
|
|
||||||
stagePrefix = "sl2Ls210"
|
|
||||||
case 1: // Tokotoko Partnya
|
|
||||||
stagePrefix = "sl2Ls463"
|
|
||||||
case 2: // Hunting Prowess Match
|
|
||||||
stagePrefix = "sl2Ls286"
|
|
||||||
case 3: // Volpakkun Together
|
|
||||||
stagePrefix = "sl2Ls465"
|
|
||||||
case 5: // Quick Party
|
|
||||||
// Unk
|
|
||||||
}
|
|
||||||
for _, c := range s.server.Channels {
|
for _, c := range s.server.Channels {
|
||||||
for _, stage := range c.stages {
|
for _, stage := range c.stages {
|
||||||
if count == maxResults {
|
if count == maxResults {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(stage.id, stagePrefix) {
|
if strings.HasPrefix(stage.id, findPartyParams.StagePrefix) {
|
||||||
sb3 := byteframe.NewByteFrameFromBytes(stage.rawBinaryData[stageBinaryKey{1, 3}])
|
sb3 := byteframe.NewByteFrameFromBytes(stage.rawBinaryData[stageBinaryKey{1, 3}])
|
||||||
sb3.Seek(4, 0)
|
sb3.Seek(4, 0)
|
||||||
stageRankRestriction := sb3.ReadUint16()
|
stageRankRestriction := sb3.ReadUint16()
|
||||||
stageTarget := sb3.ReadUint16()
|
stageTarget := sb3.ReadUint16()
|
||||||
if rankRestriction != 0xFFFF && stageRankRestriction < rankRestriction {
|
if stageRankRestriction > findPartyParams.RankRestriction {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if len(findPartyParams.Targets) > 0 {
|
||||||
|
for _, target := range findPartyParams.Targets {
|
||||||
|
if target == stageTarget {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
count++
|
count++
|
||||||
|
|||||||
@@ -130,6 +130,8 @@ func (g *Guild) Rank() uint16 {
|
|||||||
if g.RankRP < u {
|
if g.RankRP < u {
|
||||||
if _config.ErupeConfig.RealClientMode <= _config.S6 && i >= 12 {
|
if _config.ErupeConfig.RealClientMode <= _config.S6 && i >= 12 {
|
||||||
return 12
|
return 12
|
||||||
|
} else if _config.ErupeConfig.RealClientMode <= _config.F4 && i >= 13 {
|
||||||
|
return 13
|
||||||
} else if _config.ErupeConfig.RealClientMode <= _config.G32 && i >= 14 {
|
} else if _config.ErupeConfig.RealClientMode <= _config.G32 && i >= 14 {
|
||||||
return 14
|
return 14
|
||||||
}
|
}
|
||||||
@@ -138,6 +140,8 @@ func (g *Guild) Rank() uint16 {
|
|||||||
}
|
}
|
||||||
if _config.ErupeConfig.RealClientMode <= _config.S6 {
|
if _config.ErupeConfig.RealClientMode <= _config.S6 {
|
||||||
return 12
|
return 12
|
||||||
|
} else if _config.ErupeConfig.RealClientMode <= _config.F4 {
|
||||||
|
return 13
|
||||||
} else if _config.ErupeConfig.RealClientMode <= _config.G32 {
|
} else if _config.ErupeConfig.RealClientMode <= _config.G32 {
|
||||||
return 14
|
return 14
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ func encodeServerInfo(config *_config.Config, s *Server, local bool) []byte {
|
|||||||
bf.WriteUint8(si.Recommended)
|
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(stringsupport.UTF8ToSJIS(si.Name), []byte{0x00}...)
|
||||||
combined = append(combined, stringsupport.UTF8ToSJIS(si.Description)...)
|
combined = append(combined, stringsupport.UTF8ToSJIS(si.Description)...)
|
||||||
bf.WriteBytes(stringsupport.PaddedString(string(combined), 65, false))
|
bf.WriteBytes(stringsupport.PaddedString(string(combined), 65, false))
|
||||||
|
|||||||
Reference in New Issue
Block a user