mirror of
https://github.com/WiiLink24/wfc-server.git
synced 2026-03-21 17:44:58 -05:00
Send kick and ban reasons to players
This commit is contained in:
parent
e12944ccab
commit
df1c6a83fc
15
api/ban.go
15
api/ban.go
|
|
@ -94,11 +94,16 @@ func handleBanImpl(w http.ResponseWriter, r *http.Request) (*database.User, bool
|
|||
return nil, false, "Failed to ban user", http.StatusInternalServerError
|
||||
}
|
||||
|
||||
if req.Tos {
|
||||
gpcm.KickPlayer(req.Pid, "banned")
|
||||
} else {
|
||||
gpcm.KickPlayer(req.Pid, "restricted")
|
||||
}
|
||||
gpcm.KickPlayerCustomMessage(req.Pid, req.Reason, gpcm.WWFCErrorMessage{
|
||||
ErrorCode: 22002,
|
||||
MessageRMC: map[byte]string{
|
||||
gpcm.LangEnglish: "" +
|
||||
"You have been banned from Retro WFC\n" +
|
||||
"Reason: " + req.Reason + "\n" +
|
||||
"Error Code: %[1]d\n" +
|
||||
"Support Info: NG%08[2]x",
|
||||
},
|
||||
})
|
||||
|
||||
var message string
|
||||
user, success := database.GetProfile(pool, ctx, req.Pid)
|
||||
|
|
|
|||
16
api/kick.go
16
api/kick.go
|
|
@ -41,6 +41,7 @@ func HandleKick(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
type KickRequestSpec struct {
|
||||
Secret string
|
||||
Reason string
|
||||
Pid uint32
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +67,20 @@ func handleKickImpl(w http.ResponseWriter, r *http.Request) (*database.User, boo
|
|||
return nil, false, "pid missing or 0 in request", http.StatusBadRequest
|
||||
}
|
||||
|
||||
gpcm.KickPlayer(req.Pid, "moderator_kick")
|
||||
if req.Reason == "" {
|
||||
return nil, false, "Missing kick reason in request", http.StatusBadRequest
|
||||
}
|
||||
|
||||
gpcm.KickPlayerCustomMessage(req.Pid, "moderator_kick", gpcm.WWFCErrorMessage{
|
||||
ErrorCode: 22004,
|
||||
MessageRMC: map[byte]string{
|
||||
gpcm.LangEnglish: "" +
|
||||
"You have been kicked from\n" +
|
||||
"Retro WFC by a moderator.\n" +
|
||||
"Reason: " + req.Reason + "\n" +
|
||||
"Error Code: %[1]d",
|
||||
},
|
||||
})
|
||||
|
||||
var message string
|
||||
user, success := database.GetProfile(pool, ctx, req.Pid)
|
||||
|
|
|
|||
|
|
@ -172,6 +172,7 @@ func LoginUserToGPCM(pool *pgxpool.Pool, ctx context.Context, userId uint64, gsb
|
|||
var bannedDeviceIdList []uint32
|
||||
timeNow := time.Now()
|
||||
err = pool.QueryRow(ctx, SearchUserBan, user.NgDeviceId, user.ProfileId, ipAddress, *lastIPAddress, timeNow).Scan(&banExists, &banTOS, &bannedDeviceIdList)
|
||||
|
||||
if err != nil {
|
||||
if err != pgx.ErrNoRows {
|
||||
return User{}, err
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ type User struct {
|
|||
LastName string
|
||||
Restricted bool
|
||||
RestrictedDeviceId uint32
|
||||
BanReason string
|
||||
OpenHost bool
|
||||
LastInGameSn string
|
||||
LastIPAddress string
|
||||
|
|
|
|||
15
gpcm/kick.go
15
gpcm/kick.go
|
|
@ -49,3 +49,18 @@ func KickPlayer(profileID uint32, reason string) {
|
|||
|
||||
kickPlayer(profileID, reason)
|
||||
}
|
||||
|
||||
// Exists because the above function is used in too many places to be updated easily
|
||||
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,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -476,7 +476,16 @@ func (g *GameSpySession) performLoginWithDatabase(userId uint64, gsbrCode string
|
|||
ErrorCode: ErrLogin.ErrorCode,
|
||||
ErrorString: "The profile is banned from the service.",
|
||||
Fatal: true,
|
||||
WWFCMessage: WWFCMsgProfileBannedTOS,
|
||||
WWFCMessage: WWFCErrorMessage{
|
||||
ErrorCode: 22002,
|
||||
MessageRMC: map[byte]string{
|
||||
LangEnglish: "" +
|
||||
"You are banned from Retro WFC\n" +
|
||||
"Reason: " + user.BanReason + "\n" +
|
||||
"Error Code: %[1]d\n" +
|
||||
"Support Info: NG%08[2]x",
|
||||
},
|
||||
},
|
||||
})
|
||||
} else {
|
||||
g.replyError(GPError{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user