fix issue where broadcasts can go to unmapped sessions

This commit is contained in:
wish
2022-11-12 02:50:32 +11:00
parent 9fb8165be0
commit 3ad5d7eea2
2 changed files with 2 additions and 2 deletions

View File

@@ -135,7 +135,6 @@ func destructEmptyStages(s *Session) {
func removeSessionFromStage(s *Session) {
// Remove client from old stage.
s.stage.Lock()
delete(s.stage.clients, s)
// Delete old stage objects owned by the client.
@@ -146,7 +145,6 @@ func removeSessionFromStage(s *Session) {
delete(s.stage.objects, object.ownerCharID)
}
}
s.stage.Unlock()
destructEmptyStages(s)
destructEmptySemaphores(s)
}

View File

@@ -69,6 +69,8 @@ func NewStage(ID string) *Stage {
// BroadcastMHF queues a MHFPacket to be sent to all sessions in the stage.
func (s *Stage) BroadcastMHF(pkt mhfpacket.MHFPacket, ignoredSession *Session) {
s.Lock()
defer s.Unlock()
// Broadcast the data.
for session := range s.clients {
if session == ignoredSession {