mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-03-04 18:31:32 +00:00
PT_SAY and gamestochat: the rest of the owl
This commit is contained in:
parent
eae6c2fa80
commit
167f5f40ed
5 changed files with 49 additions and 2 deletions
|
|
@ -222,6 +222,8 @@ consvar_t cv_httpsource = CVAR_INIT ("http_source", "", CV_SAVE, NULL, NULL);
|
|||
|
||||
consvar_t cv_kicktime = CVAR_INIT ("kicktime", "10", CV_SAVE, CV_Unsigned, NULL);
|
||||
|
||||
consvar_t cv_gamestochat = CVAR_INIT ("gamestochat", "0", 0, CV_Unsigned, NULL);
|
||||
|
||||
static tic_t stop_spamming[MAXPLAYERS];
|
||||
|
||||
// Generate a message for an authenticating client to sign, with some guarantees about who we are.
|
||||
|
|
@ -5258,6 +5260,13 @@ static void HandlePacketFromPlayer(SINT8 node)
|
|||
break;
|
||||
}
|
||||
|
||||
if ((say.flags & HU_PRIVNOTICE) && !(IsPlayerAdmin(say.source)))
|
||||
{
|
||||
CONS_Debug(DBG_NETPLAY,"Received SAY cmd from Player %d (%s) with an illegal HU_PRIVNOTICE flag.\n", say.source+1, player_names[say.source]);
|
||||
SendKick(say.source, KICK_MSG_CON_FAIL);
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
size_t i;
|
||||
const size_t j = strlen(say.message);
|
||||
|
|
@ -5266,8 +5275,7 @@ static void HandlePacketFromPlayer(SINT8 node)
|
|||
if (say.message[i] & 0x80)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Illegal say command received from %s containing invalid characters\n"), player_names[say.source]);
|
||||
if (server)
|
||||
SendKick(say.source, KICK_MSG_CON_FAIL);
|
||||
SendKick(say.source, KICK_MSG_CON_FAIL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -5282,6 +5290,20 @@ static void HandlePacketFromPlayer(SINT8 node)
|
|||
|
||||
stop_spamming[say.source] = 4;
|
||||
|
||||
serverplayer_t *stats = SV_GetStatsByPlayerIndex(say.source);
|
||||
int remainingGames = cv_gamestochat.value - stats->finishedrounds;
|
||||
|
||||
if (remainingGames > 0 && !(IsPlayerAdmin(say.source)))
|
||||
{
|
||||
CONS_Debug(DBG_NETPLAY,"Received SAY cmd from Player %d (%s), but they aren't permitted to chat yet.\n", say.source+1, player_names[say.source]);
|
||||
|
||||
char rejectmsg[256];
|
||||
strlcpy(rejectmsg, va("Please play %d more games to use chat.", remainingGames), 256);
|
||||
SendServerNotice(say.source, rejectmsg);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
DoSayCommand(say.message, say.target, say.flags, say.source);
|
||||
break;
|
||||
case PT_LOGIN:
|
||||
|
|
@ -7032,4 +7054,11 @@ void DoSayPacketFromCommand(SINT8 target, size_t usedargs, UINT8 flags)
|
|||
}
|
||||
|
||||
DoSayPacket(target, flags, consoleplayer, msg);
|
||||
}
|
||||
|
||||
void SendServerNotice(SINT8 target, char *message)
|
||||
{
|
||||
if (client)
|
||||
return;
|
||||
DoSayCommand(message, target + 1, HU_PRIVNOTICE, servernode);
|
||||
}
|
||||
|
|
@ -542,6 +542,8 @@ extern consvar_t cv_discordinvites;
|
|||
|
||||
extern consvar_t cv_allowguests;
|
||||
|
||||
extern consvar_t cv_gamestochat;
|
||||
|
||||
#ifdef DEVELOP
|
||||
extern consvar_t cv_badjoin;
|
||||
extern consvar_t cv_badtraffic;
|
||||
|
|
@ -645,6 +647,7 @@ void HandleSigfail(const char *string);
|
|||
|
||||
void DoSayPacket(SINT8 target, UINT8 flags, UINT8 source, char *message);
|
||||
void DoSayPacketFromCommand(SINT8 target, size_t usedargs, UINT8 flags);
|
||||
void SendServerNotice(SINT8 target, char *message);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
|
|
|||
|
|
@ -953,6 +953,7 @@ void D_RegisterClientCommands(void)
|
|||
CV_RegisterVar(&cv_mindelay);
|
||||
|
||||
CV_RegisterVar(&cv_allowguests);
|
||||
CV_RegisterVar(&cv_gamestochat);
|
||||
|
||||
#ifdef DEVELOP
|
||||
CV_RegisterVar(&cv_badjoin);
|
||||
|
|
|
|||
|
|
@ -790,6 +790,13 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
|
|||
cstart = "\x82";
|
||||
textcolor = "\x82";
|
||||
fmt2 = "%s<%s%s>%s\x80 %s%s";
|
||||
|
||||
if (flags & HU_PRIVNOTICE)
|
||||
{
|
||||
dispname = "SERVER";
|
||||
prefix = "\x82";
|
||||
fmt2 = "%s[%s%s]%s %s%s";
|
||||
}
|
||||
}
|
||||
else if (target > 0) // By you, to another player
|
||||
{
|
||||
|
|
@ -799,6 +806,12 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
|
|||
cstart = "\x82";
|
||||
fmt2 = "%s<%s%s>%s\x80 %s%s";
|
||||
|
||||
if (flags & HU_PRIVNOTICE)
|
||||
{
|
||||
if (tempchar)
|
||||
Z_Free(tempchar);
|
||||
return; // I pretend I do not see it
|
||||
}
|
||||
}
|
||||
else // To everyone or sayteam, it doesn't change anything.
|
||||
fmt2 = "%s<%s%s%s>\x80 %s%s";
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ typedef enum
|
|||
{
|
||||
HU_SHOUT = 1, // Shout message
|
||||
HU_CSAY = 1<<1, // Middle-of-screen server message
|
||||
HU_PRIVNOTICE = 1<<2, // Special server sayto, we don't want to see it as the sender.
|
||||
} sayflags_t;
|
||||
|
||||
// some functions
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue