enforce Stage.maxPlayers on EnterStage

This commit is contained in:
wish
2024-03-10 18:26:26 +11:00
parent bfb22951f2
commit b08c41a886
2 changed files with 8 additions and 1 deletions

View File

@@ -151,6 +151,13 @@ func removeSessionFromStage(s *Session) {
func handleMsgSysEnterStage(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgSysEnterStage)
if stage, exists := s.server.stages[pkt.StageID]; exists {
if len(stage.reservedClientSlots) == int(stage.maxPlayers) {
doAckSimpleFail(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x01})
return
}
}
// Push our current stage ID to the movement stack before entering another one.
if s.stage != nil {
s.stage.Lock()

View File

@@ -59,7 +59,7 @@ func NewStage(ID string) *Stage {
objects: make(map[uint32]*Object),
objectIndex: 0,
rawBinaryData: make(map[stageBinaryKey][]byte),
maxPlayers: 4,
maxPlayers: 127,
}
return s
}