mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-26 17:43:21 +01:00
prevent crash on enumerating nil stage
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
package channelserver
|
package channelserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"erupe-ce/common/byteframe"
|
||||||
"erupe-ce/common/stringsupport"
|
"erupe-ce/common/stringsupport"
|
||||||
"erupe-ce/network/mhfpacket"
|
"erupe-ce/network/mhfpacket"
|
||||||
"erupe-ce/common/byteframe"
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -13,7 +13,10 @@ func handleMsgSysEnumerateClient(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
s.server.stagesLock.RLock()
|
s.server.stagesLock.RLock()
|
||||||
stage, ok := s.server.stages[pkt.StageID]
|
stage, ok := s.server.stages[pkt.StageID]
|
||||||
if !ok {
|
if !ok {
|
||||||
s.logger.Fatal("Can't enumerate clients for stage that doesn't exist!", zap.String("stageID", pkt.StageID))
|
s.server.stagesLock.RUnlock()
|
||||||
|
s.logger.Warn("Can't enumerate clients for stage that doesn't exist!", zap.String("stageID", pkt.StageID))
|
||||||
|
doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
s.server.stagesLock.RUnlock()
|
s.server.stagesLock.RUnlock()
|
||||||
|
|
||||||
@@ -29,12 +32,12 @@ func handleMsgSysEnumerateClient(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 2: // Ready
|
case 2: // Ready
|
||||||
for cid, ready := range stage.reservedClientSlots {
|
for cid, ready := range stage.reservedClientSlots {
|
||||||
if ready {
|
if ready {
|
||||||
clients = append(clients, cid)
|
clients = append(clients, cid)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
resp.WriteUint16(uint16(len(clients)))
|
resp.WriteUint16(uint16(len(clients)))
|
||||||
for _, cid := range clients {
|
for _, cid := range clients {
|
||||||
resp.WriteUint32(cid)
|
resp.WriteUint32(cid)
|
||||||
|
|||||||
Reference in New Issue
Block a user