mirror of
https://github.com/WiiLink24/wfc-server.git
synced 2026-04-23 01:37:33 -05:00
64 lines
1.4 KiB
Go
64 lines
1.4 KiB
Go
package gpcm
|
|
|
|
import "wwfc/common"
|
|
|
|
func kickPlayer(profileID uint32, reason string) {
|
|
if session, exists := sessions[profileID]; exists {
|
|
errorMessage := WWFCMsgKickedGeneric
|
|
|
|
switch reason {
|
|
case "banned":
|
|
errorMessage = WWFCMsgProfileBannedTOSNow
|
|
|
|
case "restricted":
|
|
errorMessage = WWFCMsgProfileRestrictedNow
|
|
|
|
case "restricted_join":
|
|
errorMessage = WWFCMsgProfileRestricted
|
|
|
|
case "moderator_kick":
|
|
errorMessage = WWFCMsgKickedModerator
|
|
|
|
case "room_kick":
|
|
errorMessage = WWFCMsgKickedRoomHost
|
|
|
|
case "invalid_elo":
|
|
errorMessage = WWFCMsgInvalidELO
|
|
|
|
case "network_error":
|
|
// No error message
|
|
common.CloseConnection(ServerName, session.ConnIndex)
|
|
return
|
|
}
|
|
|
|
session.replyError(GPError{
|
|
ErrorCode: ErrConnectionClosed.ErrorCode,
|
|
ErrorString: "The player was kicked from the server. Reason: " + reason,
|
|
Fatal: true,
|
|
WWFCMessage: errorMessage,
|
|
})
|
|
}
|
|
}
|
|
|
|
func KickPlayer(profileID uint32, reason string) {
|
|
mutex.Lock()
|
|
defer mutex.Unlock()
|
|
|
|
kickPlayer(profileID, reason)
|
|
}
|
|
|
|
func KickPlayerCustomMessage(profileID uint32, reason string, message WWFCErrorMessage) {
|
|
mutex.Lock()
|
|
defer mutex.Unlock()
|
|
|
|
if session, exists := sessions[profileID]; exists {
|
|
session.replyError(GPError{
|
|
ErrorCode: ErrConnectionClosed.ErrorCode,
|
|
ErrorString: "The player was kicked from the server. Reason: " + reason,
|
|
Fatal: true,
|
|
WWFCMessage: message,
|
|
Reason: reason,
|
|
})
|
|
}
|
|
}
|