mirror of
https://github.com/WiiLink24/wfc-server.git
synced 2026-07-12 22:52:11 -05:00
QR2: Remove players from old groups on RESV_OK
This commit is contained in:
parent
22a80518f0
commit
c5d9628b5b
16
qr2/group.go
16
qr2/group.go
|
|
@ -91,6 +91,10 @@ func processResvOK(moduleName string, matchVersion int, reservation common.Match
|
|||
destination.Data["+localplayers"] = strconv.FormatUint(uint64(reservation.LocalPlayerCount), 10)
|
||||
}
|
||||
|
||||
if destination.GroupPointer != nil && destination.GroupPointer != group {
|
||||
destination.removeFromGroup()
|
||||
}
|
||||
|
||||
group.Players[destination] = true
|
||||
destination.GroupPointer = group
|
||||
|
||||
|
|
@ -177,17 +181,7 @@ func ProcessGPStatusUpdate(profileID uint32, senderIP uint64, status string) {
|
|||
return
|
||||
}
|
||||
|
||||
delete(session.GroupPointer.Players, session)
|
||||
|
||||
if len(session.GroupPointer.Players) == 0 {
|
||||
logging.Notice("QR2", "Deleting group", aurora.Cyan(session.GroupPointer.GroupName))
|
||||
delete(groups, session.GroupPointer.GroupName)
|
||||
} else if session.GroupPointer.Server == session {
|
||||
logging.Notice("QR2", "Server down in group", aurora.Cyan(session.GroupPointer.GroupName))
|
||||
session.GroupPointer.findNewServer()
|
||||
}
|
||||
|
||||
session.GroupPointer = nil
|
||||
session.removeFromGroup()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ var (
|
|||
mutex = deadlock.Mutex{}
|
||||
)
|
||||
|
||||
// Remove a session.
|
||||
// Remove a session. Expects the global mutex to already be locked.
|
||||
func removeSession(addr uint64) {
|
||||
session := sessions[addr]
|
||||
if session == nil {
|
||||
|
|
@ -50,18 +50,7 @@ func removeSession(addr uint64) {
|
|||
}
|
||||
|
||||
if session.GroupPointer != nil {
|
||||
delete(session.GroupPointer.Players, session)
|
||||
|
||||
if len(session.GroupPointer.Players) == 0 {
|
||||
logging.Notice("QR2", "Deleting group", aurora.Cyan(session.GroupPointer.GroupName))
|
||||
delete(groups, session.GroupPointer.GroupName)
|
||||
} else if session.GroupPointer.Server == session {
|
||||
logging.Notice("QR2", "Server down in group", aurora.Cyan(session.GroupPointer.GroupName))
|
||||
session.GroupPointer.Server = nil
|
||||
session.GroupPointer.findNewServer()
|
||||
}
|
||||
|
||||
session.GroupPointer = nil
|
||||
session.removeFromGroup()
|
||||
}
|
||||
|
||||
if session.Login != nil {
|
||||
|
|
@ -75,6 +64,26 @@ func removeSession(addr uint64) {
|
|||
delete(sessions, addr)
|
||||
}
|
||||
|
||||
// Remove session from group. Expects the global mutex to already be locked.
|
||||
func (session *Session) removeFromGroup() {
|
||||
if session.GroupPointer == nil {
|
||||
return
|
||||
}
|
||||
|
||||
delete(session.GroupPointer.Players, session)
|
||||
|
||||
if len(session.GroupPointer.Players) == 0 {
|
||||
logging.Notice("QR2", "Deleting group", aurora.Cyan(session.GroupPointer.GroupName))
|
||||
delete(groups, session.GroupPointer.GroupName)
|
||||
} else if session.GroupPointer.Server == session {
|
||||
logging.Notice("QR2", "Server down in group", aurora.Cyan(session.GroupPointer.GroupName))
|
||||
session.GroupPointer.Server = nil
|
||||
session.GroupPointer.findNewServer()
|
||||
}
|
||||
|
||||
session.GroupPointer = nil
|
||||
}
|
||||
|
||||
// Update session data, creating the session if it doesn't exist. Returns a copy of the session data.
|
||||
func setSessionData(moduleName string, addr net.Addr, sessionId uint32, payload map[string]string) (Session, bool) {
|
||||
newPID, newPIDValid := payload["dwc_pid"]
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user