mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-26 20:31:30 +00:00
Merge branch 'name-change-spam' into 'next'
Don't let players change their name more than five times per minute See merge request KartKrew/Kart-Public!221
This commit is contained in:
commit
460c627274
5 changed files with 48 additions and 7 deletions
|
@ -3024,6 +3024,8 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason)
|
|||
// Reset the name
|
||||
sprintf(player_names[playernum], "Player %d", playernum+1);
|
||||
|
||||
player_name_changes[playernum] = 0;
|
||||
|
||||
if (IsPlayerAdmin(playernum))
|
||||
{
|
||||
RemoveAdminPlayer(playernum); // don't stay admin after you're gone
|
||||
|
@ -3692,6 +3694,8 @@ void SV_ResetServer(void)
|
|||
adminplayers[i] = -1; // Populate the entire adminplayers array with -1.
|
||||
}
|
||||
|
||||
memset(player_name_changes, 0, sizeof player_name_changes);
|
||||
|
||||
mynode = 0;
|
||||
cl_packetmissed = false;
|
||||
|
||||
|
|
|
@ -536,6 +536,10 @@ typedef enum
|
|||
|
||||
} kickreason_t;
|
||||
|
||||
/* the max number of name changes in some time period */
|
||||
#define MAXNAMECHANGES (5)
|
||||
#define NAMECHANGERATE (60*TICRATE)
|
||||
|
||||
extern boolean server;
|
||||
extern boolean serverrunning;
|
||||
#define client (!server)
|
||||
|
|
|
@ -1218,6 +1218,8 @@ static void SetPlayerName(INT32 playernum, char *newname)
|
|||
if (netgame)
|
||||
HU_AddChatText(va("\x82*%s renamed to %s", player_names[playernum], newname), false);
|
||||
|
||||
player_name_changes[playernum]++;
|
||||
|
||||
strcpy(player_names[playernum], newname);
|
||||
demo_extradata[playernum] |= DXD_NAME;
|
||||
}
|
||||
|
@ -1399,7 +1401,12 @@ static void SendNameAndColor(void)
|
|||
snacpending++;
|
||||
|
||||
// Don't change name if muted
|
||||
if (cv_mute.value && !(server || IsPlayerAdmin(consoleplayer)))
|
||||
if (player_name_changes[consoleplayer] >= MAXNAMECHANGES)
|
||||
{
|
||||
CV_StealthSet(&cv_playername, player_names[consoleplayer]);
|
||||
HU_AddChatText("\x85*You must wait to change your name again", false);
|
||||
}
|
||||
else if (cv_mute.value && !(server || IsPlayerAdmin(consoleplayer)))
|
||||
CV_StealthSet(&cv_playername, player_names[consoleplayer]);
|
||||
else // Cleanup name if changing it
|
||||
CleanupPlayerName(consoleplayer, cv_playername.zstring);
|
||||
|
@ -1523,7 +1530,12 @@ static void SendNameAndColor2(void)
|
|||
snac2pending++;
|
||||
|
||||
// Don't change name if muted
|
||||
if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[1])))
|
||||
if (player_name_changes[displayplayers[1]] >= MAXNAMECHANGES)
|
||||
{
|
||||
CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]);
|
||||
HU_AddChatText("\x85*You must wait to change your name again", false);
|
||||
}
|
||||
else if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[1])))
|
||||
CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]);
|
||||
else // Cleanup name if changing it
|
||||
CleanupPlayerName(displayplayers[1], cv_playername2.zstring);
|
||||
|
@ -1638,7 +1650,12 @@ static void SendNameAndColor3(void)
|
|||
snac3pending++;
|
||||
|
||||
// Don't change name if muted
|
||||
if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[2])))
|
||||
if (player_name_changes[displayplayers[2]] >= MAXNAMECHANGES)
|
||||
{
|
||||
CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]);
|
||||
HU_AddChatText("\x85*You must wait to change your name again", false);
|
||||
}
|
||||
else if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[2])))
|
||||
CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]);
|
||||
else // Cleanup name if changing it
|
||||
CleanupPlayerName(displayplayers[2], cv_playername3.zstring);
|
||||
|
@ -1761,7 +1778,12 @@ static void SendNameAndColor4(void)
|
|||
snac4pending++;
|
||||
|
||||
// Don't change name if muted
|
||||
if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[3])))
|
||||
if (player_name_changes[displayplayers[3]] >= MAXNAMECHANGES)
|
||||
{
|
||||
CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]);
|
||||
HU_AddChatText("\x85*You must wait to change your name again", false);
|
||||
}
|
||||
else if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[3])))
|
||||
CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]);
|
||||
else // Cleanup name if changing it
|
||||
CleanupPlayerName(displayplayers[3], cv_playername4.zstring);
|
||||
|
@ -1816,8 +1838,11 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
|
|||
skin = READUINT8(*cp);
|
||||
|
||||
// set name
|
||||
if (strcasecmp(player_names[playernum], name) != 0)
|
||||
SetPlayerName(playernum, name);
|
||||
if (player_name_changes[playernum] < MAXNAMECHANGES)
|
||||
{
|
||||
if (strcasecmp(player_names[playernum], name) != 0)
|
||||
SetPlayerName(playernum, name);
|
||||
}
|
||||
|
||||
// set color
|
||||
p->skincolor = color % MAXSKINCOLORS;
|
||||
|
|
|
@ -548,6 +548,8 @@ char player_names[MAXPLAYERS][MAXPLAYERNAME+1] =
|
|||
"Player 16"
|
||||
}; // SRB2kart - removed Players 17 through 32
|
||||
|
||||
INT32 player_name_changes[MAXPLAYERS];
|
||||
|
||||
INT16 rw_maximums[NUM_WEAPONS] =
|
||||
{
|
||||
800, // MAX_INFINITY
|
||||
|
@ -2502,6 +2504,11 @@ void G_Ticker(boolean run)
|
|||
spectatedelay3--;
|
||||
if (spectatedelay4)
|
||||
spectatedelay4--;
|
||||
|
||||
if (gametic % NAMECHANGERATE == 0)
|
||||
{
|
||||
memset(player_name_changes, 0, sizeof player_name_changes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,8 @@ extern char customversionstring[32];
|
|||
#ifdef SEENAMES
|
||||
extern player_t *seenplayer;
|
||||
#endif
|
||||
extern char player_names[MAXPLAYERS][MAXPLAYERNAME+1];
|
||||
extern char player_names[MAXPLAYERS][MAXPLAYERNAME+1];
|
||||
extern INT32 player_name_changes[MAXPLAYERS];
|
||||
|
||||
extern player_t players[MAXPLAYERS];
|
||||
extern boolean playeringame[MAXPLAYERS];
|
||||
|
|
Loading…
Reference in a new issue