mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-14 07:55:33 +01:00
fix enumerate client and handle type L stages
This commit is contained in:
@@ -3,8 +3,8 @@ package mhfpacket
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"erupe-ce/common/byteframe"
|
|
||||||
"erupe-ce/common/bfutil"
|
"erupe-ce/common/bfutil"
|
||||||
|
"erupe-ce/common/byteframe"
|
||||||
"erupe-ce/network"
|
"erupe-ce/network"
|
||||||
"erupe-ce/network/clientctx"
|
"erupe-ce/network/clientctx"
|
||||||
)
|
)
|
||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
type MsgSysEnumerateClient struct {
|
type MsgSysEnumerateClient struct {
|
||||||
AckHandle uint32
|
AckHandle uint32
|
||||||
Unk0 uint8 // Hardcoded 1 in the client
|
Unk0 uint8 // Hardcoded 1 in the client
|
||||||
Unk1 uint8
|
Get uint8
|
||||||
StageID string
|
StageID string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ func (m *MsgSysEnumerateClient) Opcode() network.PacketID {
|
|||||||
func (m *MsgSysEnumerateClient) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
func (m *MsgSysEnumerateClient) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||||
m.AckHandle = bf.ReadUint32()
|
m.AckHandle = bf.ReadUint32()
|
||||||
m.Unk0 = bf.ReadUint8()
|
m.Unk0 = bf.ReadUint8()
|
||||||
m.Unk1 = bf.ReadUint8()
|
m.Get = bf.ReadUint8()
|
||||||
stageIDLength := bf.ReadUint8()
|
stageIDLength := bf.ReadUint8()
|
||||||
m.StageID = string(bfutil.UpToNull(bf.ReadBytes(uint(stageIDLength))))
|
m.StageID = string(bfutil.UpToNull(bf.ReadBytes(uint(stageIDLength))))
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -24,7 +24,11 @@ func handleMsgSysEnumerateClient(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
resp := byteframe.NewByteFrame()
|
resp := byteframe.NewByteFrame()
|
||||||
stage.RLock()
|
stage.RLock()
|
||||||
var clients []uint32
|
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
|
case 1: // Not ready
|
||||||
for cid, ready := range stage.reservedClientSlots {
|
for cid, ready := range stage.reservedClientSlots {
|
||||||
if !ready {
|
if !ready {
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ func destructEmptyStages(s *Session) {
|
|||||||
defer s.server.Unlock()
|
defer s.server.Unlock()
|
||||||
for _, stage := range s.server.stages {
|
for _, stage := range s.server.stages {
|
||||||
// Destroy empty Quest/My series/Guild 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 {
|
if len(stage.reservedClientSlots) == 0 && len(stage.clients) == 0 {
|
||||||
delete(s.server.stages, stage.id)
|
delete(s.server.stages, stage.id)
|
||||||
s.logger.Debug("Destructed stage", zap.String("stage.id", 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
|
// 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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user