fix enumerate client and handle type L stages

This commit is contained in:
wish
2022-08-04 23:04:55 +10:00
parent 96247a0101
commit 2f35823e1e
3 changed files with 10 additions and 6 deletions

View File

@@ -3,8 +3,8 @@ package mhfpacket
import (
"errors"
"erupe-ce/common/byteframe"
"erupe-ce/common/bfutil"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
)
@@ -13,7 +13,7 @@ import (
type MsgSysEnumerateClient struct {
AckHandle uint32
Unk0 uint8 // Hardcoded 1 in the client
Unk1 uint8
Get uint8
StageID string
}
@@ -26,7 +26,7 @@ func (m *MsgSysEnumerateClient) Opcode() network.PacketID {
func (m *MsgSysEnumerateClient) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint8()
m.Unk1 = bf.ReadUint8()
m.Get = bf.ReadUint8()
stageIDLength := bf.ReadUint8()
m.StageID = string(bfutil.UpToNull(bf.ReadBytes(uint(stageIDLength))))
return nil

View File

@@ -24,7 +24,11 @@ func handleMsgSysEnumerateClient(s *Session, p mhfpacket.MHFPacket) {
resp := byteframe.NewByteFrame()
stage.RLock()
var clients []uint32
switch pkt.Unk1 {
switch pkt.Get {
case 0: // All
for _, cid := range stage.clients {
clients = append(clients, cid)
}
case 1: // Not ready
for cid, ready := range stage.reservedClientSlots {
if !ready {

View File

@@ -121,7 +121,7 @@ func destructEmptyStages(s *Session) {
defer s.server.Unlock()
for _, stage := range s.server.stages {
// Destroy empty Quest/My series/Guild stages.
if stage.id[3:5] == "Qs" || stage.id[3:5] == "Ms" || stage.id[3:5] == "Gs" {
if stage.id[3:5] == "Qs" || stage.id[3:5] == "Ms" || stage.id[3:5] == "Gs" || stage.id[3:5] == "Ls" {
if len(stage.reservedClientSlots) == 0 && len(stage.clients) == 0 {
delete(s.server.stages, stage.id)
s.logger.Debug("Destructed stage", zap.String("stage.id", stage.id))
@@ -367,7 +367,7 @@ func handleMsgSysEnumerateStage(s *Session, p mhfpacket.MHFPacket) {
}
// Check for valid stage type
if sid[3:5] != "Qs" && sid[3:5] != "Ms" {
if sid[3:5] != "Qs" && sid[3:5] != "Ms" && sid[3:5] != "Ls" {
continue
}