mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-28 05:11:34 +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
|
// Reset the name
|
||||||
sprintf(player_names[playernum], "Player %d", playernum+1);
|
sprintf(player_names[playernum], "Player %d", playernum+1);
|
||||||
|
|
||||||
|
player_name_changes[playernum] = 0;
|
||||||
|
|
||||||
if (IsPlayerAdmin(playernum))
|
if (IsPlayerAdmin(playernum))
|
||||||
{
|
{
|
||||||
RemoveAdminPlayer(playernum); // don't stay admin after you're gone
|
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.
|
adminplayers[i] = -1; // Populate the entire adminplayers array with -1.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(player_name_changes, 0, sizeof player_name_changes);
|
||||||
|
|
||||||
mynode = 0;
|
mynode = 0;
|
||||||
cl_packetmissed = false;
|
cl_packetmissed = false;
|
||||||
|
|
||||||
|
|
|
@ -536,6 +536,10 @@ typedef enum
|
||||||
|
|
||||||
} kickreason_t;
|
} kickreason_t;
|
||||||
|
|
||||||
|
/* the max number of name changes in some time period */
|
||||||
|
#define MAXNAMECHANGES (5)
|
||||||
|
#define NAMECHANGERATE (60*TICRATE)
|
||||||
|
|
||||||
extern boolean server;
|
extern boolean server;
|
||||||
extern boolean serverrunning;
|
extern boolean serverrunning;
|
||||||
#define client (!server)
|
#define client (!server)
|
||||||
|
|
|
@ -1218,6 +1218,8 @@ static void SetPlayerName(INT32 playernum, char *newname)
|
||||||
if (netgame)
|
if (netgame)
|
||||||
HU_AddChatText(va("\x82*%s renamed to %s", player_names[playernum], newname), false);
|
HU_AddChatText(va("\x82*%s renamed to %s", player_names[playernum], newname), false);
|
||||||
|
|
||||||
|
player_name_changes[playernum]++;
|
||||||
|
|
||||||
strcpy(player_names[playernum], newname);
|
strcpy(player_names[playernum], newname);
|
||||||
demo_extradata[playernum] |= DXD_NAME;
|
demo_extradata[playernum] |= DXD_NAME;
|
||||||
}
|
}
|
||||||
|
@ -1399,7 +1401,12 @@ static void SendNameAndColor(void)
|
||||||
snacpending++;
|
snacpending++;
|
||||||
|
|
||||||
// Don't change name if muted
|
// 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]);
|
CV_StealthSet(&cv_playername, player_names[consoleplayer]);
|
||||||
else // Cleanup name if changing it
|
else // Cleanup name if changing it
|
||||||
CleanupPlayerName(consoleplayer, cv_playername.zstring);
|
CleanupPlayerName(consoleplayer, cv_playername.zstring);
|
||||||
|
@ -1523,7 +1530,12 @@ static void SendNameAndColor2(void)
|
||||||
snac2pending++;
|
snac2pending++;
|
||||||
|
|
||||||
// Don't change name if muted
|
// 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]]);
|
CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]);
|
||||||
else // Cleanup name if changing it
|
else // Cleanup name if changing it
|
||||||
CleanupPlayerName(displayplayers[1], cv_playername2.zstring);
|
CleanupPlayerName(displayplayers[1], cv_playername2.zstring);
|
||||||
|
@ -1638,7 +1650,12 @@ static void SendNameAndColor3(void)
|
||||||
snac3pending++;
|
snac3pending++;
|
||||||
|
|
||||||
// Don't change name if muted
|
// 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]]);
|
CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]);
|
||||||
else // Cleanup name if changing it
|
else // Cleanup name if changing it
|
||||||
CleanupPlayerName(displayplayers[2], cv_playername3.zstring);
|
CleanupPlayerName(displayplayers[2], cv_playername3.zstring);
|
||||||
|
@ -1761,7 +1778,12 @@ static void SendNameAndColor4(void)
|
||||||
snac4pending++;
|
snac4pending++;
|
||||||
|
|
||||||
// Don't change name if muted
|
// 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]]);
|
CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]);
|
||||||
else // Cleanup name if changing it
|
else // Cleanup name if changing it
|
||||||
CleanupPlayerName(displayplayers[3], cv_playername4.zstring);
|
CleanupPlayerName(displayplayers[3], cv_playername4.zstring);
|
||||||
|
@ -1816,8 +1838,11 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
|
||||||
skin = READUINT8(*cp);
|
skin = READUINT8(*cp);
|
||||||
|
|
||||||
// set name
|
// set name
|
||||||
if (strcasecmp(player_names[playernum], name) != 0)
|
if (player_name_changes[playernum] < MAXNAMECHANGES)
|
||||||
SetPlayerName(playernum, name);
|
{
|
||||||
|
if (strcasecmp(player_names[playernum], name) != 0)
|
||||||
|
SetPlayerName(playernum, name);
|
||||||
|
}
|
||||||
|
|
||||||
// set color
|
// set color
|
||||||
p->skincolor = color % MAXSKINCOLORS;
|
p->skincolor = color % MAXSKINCOLORS;
|
||||||
|
|
|
@ -548,6 +548,8 @@ char player_names[MAXPLAYERS][MAXPLAYERNAME+1] =
|
||||||
"Player 16"
|
"Player 16"
|
||||||
}; // SRB2kart - removed Players 17 through 32
|
}; // SRB2kart - removed Players 17 through 32
|
||||||
|
|
||||||
|
INT32 player_name_changes[MAXPLAYERS];
|
||||||
|
|
||||||
INT16 rw_maximums[NUM_WEAPONS] =
|
INT16 rw_maximums[NUM_WEAPONS] =
|
||||||
{
|
{
|
||||||
800, // MAX_INFINITY
|
800, // MAX_INFINITY
|
||||||
|
@ -2502,6 +2504,11 @@ void G_Ticker(boolean run)
|
||||||
spectatedelay3--;
|
spectatedelay3--;
|
||||||
if (spectatedelay4)
|
if (spectatedelay4)
|
||||||
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
|
#ifdef SEENAMES
|
||||||
extern player_t *seenplayer;
|
extern player_t *seenplayer;
|
||||||
#endif
|
#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 player_t players[MAXPLAYERS];
|
||||||
extern boolean playeringame[MAXPLAYERS];
|
extern boolean playeringame[MAXPLAYERS];
|
||||||
|
|
Loading…
Reference in a new issue