auto-unregister from host-less quests

This commit is contained in:
wish
2022-10-22 05:54:53 +11:00
parent 6413be5320
commit e5e3750045
3 changed files with 15 additions and 0 deletions

View File

@@ -190,6 +190,18 @@ func logoutPlayer(s *Session) {
s.server.Unlock()
for _, stage := range s.server.stages {
// Tell sessions registered to disconnecting players quest to unregister
if stage.hostCharID == s.charID {
if s.stage.id == "sl1Ns200p0a0u0" {
for _, sess := range s.server.sessions {
for rSlot := range stage.reservedClientSlots {
if sess.charID == rSlot {
sess.QueueSendMHF(&mhfpacket.MsgSysStageDestruct{})
}
}
}
}
}
for session := range stage.clients {
if session.charID == s.charID {
delete(stage.clients, session)

View File

@@ -19,6 +19,7 @@ func handleMsgSysCreateStage(s *Session, p mhfpacket.MHFPacket) {
doAckSimpleFail(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
} else {
stage := NewStage(pkt.StageID)
stage.hostCharID = s.charID
stage.maxPlayers = uint16(pkt.PlayerCount)
s.server.stages[stage.id] = stage
doAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
@@ -42,6 +43,7 @@ func doStageTransfer(s *Session, ackHandle uint32, stageID string) {
stage = s.server.stages[stageID]
s.server.Unlock()
stage.Lock()
stage.hostCharID = s.charID
stage.clients[s] = s.charID
stage.Unlock()
}

View File

@@ -46,6 +46,7 @@ type Stage struct {
// other clients expect the server to echo them back in the exact same format.
rawBinaryData map[stageBinaryKey][]byte
hostCharID uint32
maxPlayers uint16
password string
createdAt string