mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 15:34:38 +01:00
matchmaking support
This commit is contained in:
@@ -345,14 +345,11 @@ func handleMsgSysRightsReload(s *Session, p mhfpacket.MHFPacket) {
|
||||
|
||||
func handleMsgMhfTransitMessage(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfTransitMessage)
|
||||
// 1 -> CID
|
||||
// 2 -> Name
|
||||
// 4 -> Group
|
||||
resp := byteframe.NewByteFrame()
|
||||
resp.WriteUint16(0)
|
||||
var count uint16
|
||||
switch pkt.SearchType {
|
||||
case 1:
|
||||
case 1: // CID
|
||||
bf := byteframe.NewByteFrameFromBytes(pkt.MessageData)
|
||||
CharID := bf.ReadUint32()
|
||||
for _, c := range s.server.Channels {
|
||||
@@ -366,17 +363,17 @@ func handleMsgMhfTransitMessage(s *Session, p mhfpacket.MHFPacket) {
|
||||
resp.WriteUint32(session.charID)
|
||||
resp.WriteBool(true)
|
||||
resp.WriteUint8(uint8(len(sessionName) + 1))
|
||||
resp.WriteUint16(0x180) // lenUserBinary
|
||||
resp.WriteUint16(uint16(len(c.userBinaryParts[userBinaryPartID{charID: session.charID, index: 3}])))
|
||||
resp.WriteBytes(make([]byte, 40))
|
||||
resp.WriteUint8(uint8(len(sessionStage) + 1))
|
||||
resp.WriteBytes(make([]byte, 8))
|
||||
resp.WriteNullTerminatedBytes(sessionName)
|
||||
resp.WriteBytes(c.userBinaryParts[userBinaryPartID{charID: session.charID, index: 3}])
|
||||
resp.WriteBytes(c.userBinaryParts[userBinaryPartID{session.charID, 3}])
|
||||
resp.WriteNullTerminatedBytes(sessionStage)
|
||||
}
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
case 2: // Name
|
||||
bf := byteframe.NewByteFrameFromBytes(pkt.MessageData)
|
||||
bf.ReadUint16() // lenSearchTerm
|
||||
bf.ReadUint16() // maxResults
|
||||
@@ -396,7 +393,7 @@ func handleMsgMhfTransitMessage(s *Session, p mhfpacket.MHFPacket) {
|
||||
resp.WriteUint32(session.charID)
|
||||
resp.WriteBool(true)
|
||||
resp.WriteUint8(uint8(len(sessionName) + 1))
|
||||
resp.WriteUint16(0x180) // lenUserBinary
|
||||
resp.WriteUint16(uint16(len(c.userBinaryParts[userBinaryPartID{session.charID, 3}])))
|
||||
resp.WriteBytes(make([]byte, 40))
|
||||
resp.WriteUint8(uint8(len(sessionStage) + 1))
|
||||
resp.WriteBytes(make([]byte, 8))
|
||||
@@ -406,6 +403,95 @@ func handleMsgMhfTransitMessage(s *Session, p mhfpacket.MHFPacket) {
|
||||
}
|
||||
}
|
||||
}
|
||||
case 3: // Enumerate Party
|
||||
bf := byteframe.NewByteFrameFromBytes(pkt.MessageData)
|
||||
ip := bf.ReadBytes(4)
|
||||
ipString := fmt.Sprintf("%d.%d.%d.%d", ip[3], ip[2], ip[1], ip[0])
|
||||
port := bf.ReadUint16()
|
||||
bf.ReadUint16() // lenStage
|
||||
maxResults := bf.ReadUint16()
|
||||
bf.ReadBytes(1)
|
||||
stageID := stringsupport.SJISToUTF8(bf.ReadNullTerminatedBytes())
|
||||
for _, c := range s.server.Channels {
|
||||
if c.IP == ipString && c.Port == port {
|
||||
for _, stage := range c.stages {
|
||||
if stage.id == stageID {
|
||||
if count == maxResults {
|
||||
break
|
||||
}
|
||||
for session := range stage.clients {
|
||||
count++
|
||||
sessionStage := stringsupport.UTF8ToSJIS(session.stageID)
|
||||
sessionName := stringsupport.UTF8ToSJIS(session.Name)
|
||||
resp.WriteUint32(binary.LittleEndian.Uint32(net.ParseIP(c.IP).To4()))
|
||||
resp.WriteUint16(c.Port)
|
||||
resp.WriteUint32(session.charID)
|
||||
resp.WriteUint8(uint8(len(sessionStage) + 1))
|
||||
resp.WriteUint8(uint8(len(sessionName) + 1))
|
||||
resp.WriteUint8(0)
|
||||
resp.WriteUint8(7) // lenBinary
|
||||
resp.WriteBytes(make([]byte, 48))
|
||||
resp.WriteNullTerminatedBytes(sessionStage)
|
||||
resp.WriteNullTerminatedBytes(sessionName)
|
||||
resp.WriteUint16(999) // HR
|
||||
resp.WriteUint16(999) // GR
|
||||
resp.WriteBytes([]byte{0x06, 0x10, 0x00}) // Unk
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case 4: // Find Party
|
||||
bf := byteframe.NewByteFrameFromBytes(pkt.MessageData)
|
||||
bf.ReadUint8()
|
||||
maxResults := bf.ReadUint16()
|
||||
bf.ReadUint8()
|
||||
bf.ReadUint8()
|
||||
partyType := bf.ReadUint16()
|
||||
_ = bf.DataFromCurrent() // Restrictions
|
||||
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 _, stage := range c.stages {
|
||||
if count == maxResults {
|
||||
break
|
||||
}
|
||||
if strings.HasPrefix(stage.id, stagePrefix) {
|
||||
count++
|
||||
sessionStage := stringsupport.UTF8ToSJIS(stage.id)
|
||||
resp.WriteUint32(binary.LittleEndian.Uint32(net.ParseIP(c.IP).To4()))
|
||||
resp.WriteUint16(c.Port)
|
||||
|
||||
// TODO: This is half right, could be trimmed
|
||||
resp.WriteUint16(0)
|
||||
resp.WriteUint16(uint16(len(stage.clients)))
|
||||
resp.WriteUint16(uint16(len(stage.clients)))
|
||||
resp.WriteUint16(stage.maxPlayers)
|
||||
resp.WriteUint16(0)
|
||||
resp.WriteUint16(uint16(len(stage.clients)))
|
||||
//
|
||||
|
||||
resp.WriteUint16(uint16(len(sessionStage) + 1))
|
||||
resp.WriteUint8(1)
|
||||
resp.WriteUint8(uint8(len(stage.rawBinaryData[stageBinaryKey{1, 1}])))
|
||||
resp.WriteBytes(make([]byte, 16))
|
||||
resp.WriteNullTerminatedBytes(sessionStage)
|
||||
resp.WriteBytes([]byte{0x00})
|
||||
resp.WriteBytes(stage.rawBinaryData[stageBinaryKey{1, 1}])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resp.Seek(0, io.SeekStart)
|
||||
resp.WriteUint16(count)
|
||||
|
||||
@@ -124,7 +124,16 @@ func handleMsgSysCreateAcquireSemaphore(s *Session, p mhfpacket.MHFPacket) {
|
||||
}
|
||||
|
||||
func handleMsgSysAcquireSemaphore(s *Session, p mhfpacket.MHFPacket) {
|
||||
//pkt := p.(*mhfpacket.MsgSysAcquireSemaphore)
|
||||
pkt := p.(*mhfpacket.MsgSysAcquireSemaphore)
|
||||
if sema, exists := s.server.semaphore[pkt.SemaphoreID]; exists {
|
||||
sema.clients[s] = s.charID
|
||||
bf := byteframe.NewByteFrame()
|
||||
bf.WriteUint32(sema.id)
|
||||
doAckSimpleSucceed(s, pkt.AckHandle, bf.Data())
|
||||
} else {
|
||||
doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func handleMsgSysReleaseSemaphore(s *Session, p mhfpacket.MHFPacket) {
|
||||
|
||||
Reference in New Issue
Block a user