mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-14 07:55:33 +01:00
rewrite EnumerateStage & parse ReserveStage
This commit is contained in:
@@ -3,7 +3,6 @@ package mhfpacket
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"erupe-ce/common/byteframe"
|
"erupe-ce/common/byteframe"
|
||||||
"erupe-ce/common/bfutil"
|
|
||||||
"erupe-ce/network"
|
"erupe-ce/network"
|
||||||
"erupe-ce/network/clientctx"
|
"erupe-ce/network/clientctx"
|
||||||
)
|
)
|
||||||
@@ -24,8 +23,8 @@ func (m *MsgSysReserveStage) Opcode() network.PacketID {
|
|||||||
func (m *MsgSysReserveStage) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
func (m *MsgSysReserveStage) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||||
m.AckHandle = bf.ReadUint32()
|
m.AckHandle = bf.ReadUint32()
|
||||||
m.Ready = bf.ReadUint8()
|
m.Ready = bf.ReadUint8()
|
||||||
stageIDLength := bf.ReadUint8()
|
_ = bf.ReadUint8() // StageID length
|
||||||
m.StageID = string(bfutil.UpToNull(bf.ReadBytes(uint(stageIDLength))))
|
m.StageID = string(bf.ReadNullTerminatedBytes())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -367,9 +367,9 @@ func handleMsgSysEnumerateStage(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
defer s.server.stagesLock.RUnlock()
|
defer s.server.stagesLock.RUnlock()
|
||||||
|
|
||||||
// Build the response
|
// Build the response
|
||||||
resp := byteframe.NewByteFrame()
|
|
||||||
bf := byteframe.NewByteFrame()
|
bf := byteframe.NewByteFrame()
|
||||||
var joinable int
|
var joinable uint16
|
||||||
|
bf.WriteUint16(0)
|
||||||
for sid, stage := range s.server.stages {
|
for sid, stage := range s.server.stages {
|
||||||
stage.RLock()
|
stage.RLock()
|
||||||
|
|
||||||
@@ -377,34 +377,32 @@ func handleMsgSysEnumerateStage(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
stage.RUnlock()
|
stage.RUnlock()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.Contains(stage.id, pkt.StagePrefix) {
|
if !strings.Contains(stage.id, pkt.StagePrefix) {
|
||||||
stage.RUnlock()
|
stage.RUnlock()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
joinable++
|
joinable++
|
||||||
|
|
||||||
resp.WriteUint16(uint16(len(stage.reservedClientSlots))) // Reserved players.
|
bf.WriteUint16(uint16(len(stage.reservedClientSlots)))
|
||||||
resp.WriteUint16(0) // Unk
|
bf.WriteUint16(0) // Unk
|
||||||
if len(stage.clients) > 0 {
|
if len(stage.clients) > 0 {
|
||||||
bf.WriteUint16(1)
|
bf.WriteUint16(1)
|
||||||
} else {
|
} else {
|
||||||
bf.WriteUint16(0)
|
bf.WriteUint16(0)
|
||||||
}
|
}
|
||||||
resp.WriteUint16(stage.maxPlayers) // Max players.
|
bf.WriteUint16(stage.maxPlayers)
|
||||||
if len(stage.password) > 0 {
|
if len(stage.password) > 0 {
|
||||||
// This byte has also been seen as 1
|
// This byte has also been seen as 1
|
||||||
// The quest is also recognised as locked when this is 2
|
// The quest is also recognised as locked when this is 2
|
||||||
resp.WriteUint8(3)
|
bf.WriteUint8(2)
|
||||||
} else {
|
} else {
|
||||||
resp.WriteUint8(0)
|
bf.WriteUint8(0)
|
||||||
}
|
}
|
||||||
ps.Uint8(resp, sid, false)
|
ps.Uint8(bf, sid, false)
|
||||||
stage.RUnlock()
|
stage.RUnlock()
|
||||||
}
|
}
|
||||||
bf.WriteUint16(uint16(joinable))
|
bf.Seek(0, 0)
|
||||||
bf.WriteBytes(resp.Data())
|
bf.WriteUint16(joinable)
|
||||||
|
|
||||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user