mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-28 13:21:10 +00:00
Merge branch 'SRB2-CHAT' into 'SRB2-CHAT'
Final code fixes and minor cleanup See merge request SinnamonLat/SRB2!5
This commit is contained in:
commit
809bb8a9d5
3 changed files with 152 additions and 175 deletions
|
@ -22,6 +22,7 @@
|
|||
#define MAXNETNODES 32
|
||||
#define BROADCASTADDR MAXNETNODES
|
||||
#define MAXSPLITSCREENPLAYERS 2 // Max number of players on a single computer
|
||||
//#define NETSPLITSCREEN // Kart's splitscreen netgame feature
|
||||
|
||||
#define STATLENGTH (TICRATE*2)
|
||||
|
||||
|
|
104
src/hu_stuff.c
104
src/hu_stuff.c
|
@ -490,7 +490,7 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags)
|
|||
//CONS_Printf("%d\n", target);
|
||||
|
||||
// check for target player, if it doesn't exist then we can't send the message!
|
||||
if (playeringame[target]) // player exists
|
||||
if (target < MAXPLAYERS && playeringame[target]) // player exists
|
||||
target++; // even though playernums are from 0 to 31, target is 1 to 32, so up that by 1 to have it work!
|
||||
else
|
||||
{
|
||||
|
@ -585,7 +585,7 @@ static void Command_CSay_f(void)
|
|||
|
||||
DoSayCommand(0, 1, HU_CSAY);
|
||||
}
|
||||
static tic_t stop_spamming_you_cunt[MAXPLAYERS];
|
||||
static tic_t stop_spamming[MAXPLAYERS];
|
||||
|
||||
/** Receives a message, processing an ::XD_SAY command.
|
||||
* \sa DoSayCommand
|
||||
|
@ -648,15 +648,15 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
|
|||
|
||||
// before we do anything, let's verify the guy isn't spamming, get this easier on us.
|
||||
|
||||
//if (stop_spamming_you_cunt[playernum] != 0 && cv_chatspamprotection.value && !(flags & HU_CSAY))
|
||||
if (stop_spamming_you_cunt[playernum] != 0 && consoleplayer != playernum && cv_chatspamprotection.value && !(flags & HU_CSAY))
|
||||
//if (stop_spamming[playernum] != 0 && cv_chatspamprotection.value && !(flags & HU_CSAY))
|
||||
if (stop_spamming[playernum] != 0 && consoleplayer != playernum && cv_chatspamprotection.value && !(flags & HU_CSAY))
|
||||
{
|
||||
CONS_Debug(DBG_NETPLAY,"Received SAY cmd too quickly from Player %d (%s), assuming as spam and blocking message.\n", playernum+1, player_names[playernum]);
|
||||
stop_spamming_you_cunt[playernum] = 4;
|
||||
stop_spamming[playernum] = 4;
|
||||
spam_eatmsg = 1;
|
||||
}
|
||||
else
|
||||
stop_spamming_you_cunt[playernum] = 4; // you can hold off for 4 tics, can you?
|
||||
stop_spamming[playernum] = 4; // you can hold off for 4 tics, can you?
|
||||
|
||||
// run the lua hook even if we were supposed to eat the msg, netgame consistency goes first.
|
||||
|
||||
|
@ -847,10 +847,13 @@ static inline boolean HU_keyInChatString(char *s, char ch)
|
|||
|
||||
// move everything past c_input for new characters:
|
||||
size_t m = HU_MAXMSGLEN-1;
|
||||
for (;(m>=c_input);m--)
|
||||
while (m>=c_input)
|
||||
{
|
||||
if (s[m])
|
||||
s[m+1] = (s[m]);
|
||||
if (m == 0) // prevent overflow
|
||||
break;
|
||||
m--;
|
||||
}
|
||||
s[c_input] = ch; // and replace this.
|
||||
}
|
||||
|
@ -910,7 +913,7 @@ static INT32 head = 0, tail = 0;*/
|
|||
// WHY DO YOU OVERCOMPLICATE EVERYTHING?????????
|
||||
|
||||
// Clear spaces so we don't end up with messages only made out of emptiness
|
||||
static boolean HU_clearChatSpaces()
|
||||
static boolean HU_clearChatSpaces(void)
|
||||
{
|
||||
size_t i = 0; // Used to just check our message
|
||||
char c; // current character we're iterating.
|
||||
|
@ -1011,7 +1014,7 @@ static void HU_queueChatChar(char c)
|
|||
//CONS_Printf("%d\n", target);
|
||||
|
||||
// check for target player, if it doesn't exist then we can't send the message!
|
||||
if (playeringame[target]) // player exists
|
||||
if (target < MAXPLAYERS && playeringame[target]) // player exists
|
||||
target++; // even though playernums are from 0 to 31, target is 1 to 32, so up that by 1 to have it work!
|
||||
else
|
||||
{
|
||||
|
@ -1177,11 +1180,13 @@ boolean HU_Responder(event_t *ev)
|
|||
else // otherwise, we need to shift everything and make space, etc etc
|
||||
{
|
||||
size_t i = HU_MAXMSGLEN-1;
|
||||
for (; i>=c_input;i--)
|
||||
while (i >= c_input)
|
||||
{
|
||||
if (w_chat[i])
|
||||
w_chat[i+pastelen] = w_chat[i];
|
||||
|
||||
if (i == 0) // prevent overflow
|
||||
break;
|
||||
i--;
|
||||
}
|
||||
memcpy(&w_chat[c_input], paste, pastelen); // copy all of that.
|
||||
c_input += pastelen;
|
||||
|
@ -1435,39 +1440,6 @@ static void HU_drawMiniChat(void)
|
|||
|
||||
}
|
||||
|
||||
|
||||
// HU_DrawUpArrow
|
||||
// You see, we don't have arrow graphics in 2.1 and I'm too lazy to include a 2 bytes file for it.
|
||||
|
||||
static void HU_DrawUpArrow(INT32 x, INT32 y, INT32 options)
|
||||
{
|
||||
// Ok I'm super lazy so let's make this as the worst draw function:
|
||||
V_DrawFill(x+2, y, 1, 1, 103|options);
|
||||
V_DrawFill(x+1, y+1, 3, 1, 103|options);
|
||||
V_DrawFill(x, y+2, 5, 1, 103|options); // that's the yellow part, I swear
|
||||
|
||||
V_DrawFill(x+3, y, 1, 1, 26|options);
|
||||
V_DrawFill(x+4, y+1, 1, 1, 26|options);
|
||||
V_DrawFill(x+5, y+2, 1, 1, 26|options);
|
||||
V_DrawFill(x, y+3, 6, 1, 26|options); // that's the black part. no racism intended. i swear.
|
||||
}
|
||||
|
||||
// HU_DrawDownArrow
|
||||
// Should we talk about anime waifus to pass the time? This feels retarded.
|
||||
|
||||
static void HU_DrawDownArrow(INT32 x, INT32 y, INT32 options)
|
||||
{
|
||||
// Ok I'm super lazy so let's make this as the worst draw function:
|
||||
V_DrawFill(x, y, 6, 1, 26|options);
|
||||
V_DrawFill(x, y+1, 5, 1, 26|options);
|
||||
V_DrawFill(x+1, y+2, 3, 1, 26|options);
|
||||
V_DrawFill(x+2, y+3, 1, 1, 26|options); // that's the black part. no racism intended. i swear.
|
||||
|
||||
V_DrawFill(x, y, 5, 1, 103|options);
|
||||
V_DrawFill(x+1, y+1, 3, 1, 103|options);
|
||||
V_DrawFill(x+2, y+2, 1, 1, 103|options); // that's the yellow part, I swear
|
||||
}
|
||||
|
||||
// HU_DrawChatLog
|
||||
|
||||
static void HU_drawChatLog(INT32 offset)
|
||||
|
@ -1483,27 +1455,27 @@ static void HU_drawChatLog(INT32 offset)
|
|||
if (chat_scroll > chat_maxscroll)
|
||||
chat_scroll = chat_maxscroll;
|
||||
|
||||
/*if (splitscreen)
|
||||
#ifdef NETSPLITSCREEN
|
||||
if (splitscreen)
|
||||
{
|
||||
boxh = max(6, boxh/2);
|
||||
if (splitscreen > 1)
|
||||
boxw = max(64, boxw/2);
|
||||
}*/
|
||||
|
||||
// Unused SRB2KART splitscreen stuff. I'll leave it here in case it ever happens in Vanilla?
|
||||
}
|
||||
#endif
|
||||
|
||||
y = chaty - offset*charheight - (chat_scroll*charheight) - boxh*charheight - 12;
|
||||
|
||||
/*if (splitscreen)
|
||||
#ifdef NETSPLITSCREEN
|
||||
if (splitscreen)
|
||||
{
|
||||
y -= BASEVIDHEIGHT/2;
|
||||
if (splitscreen > 1)
|
||||
y += 16;
|
||||
}*/
|
||||
}
|
||||
#endif
|
||||
y -= (G_RingSlingerGametype() ? 16 : 0);
|
||||
|
||||
// Unused SRB2KART splitscreen stuff. I'll leave it here in case it ever happens in Vanilla? (x2)
|
||||
|
||||
|
||||
chat_topy = y + chat_scroll*charheight;
|
||||
chat_bottomy = chat_topy + boxh*charheight;
|
||||
|
@ -1575,11 +1547,10 @@ static void HU_drawChatLog(INT32 offset)
|
|||
chat_scroll = chat_maxscroll;
|
||||
|
||||
// draw arrows to indicate that we can (or not) scroll.
|
||||
|
||||
if (chat_scroll > 0)
|
||||
HU_DrawUpArrow(chatx-8, ((justscrolledup) ? (chat_topy-1) : (chat_topy)), V_SNAPTOBOTTOM | V_SNAPTOLEFT);
|
||||
V_DrawThinString(chatx-8, ((justscrolledup) ? (chat_topy-1) : (chat_topy)), V_SNAPTOBOTTOM | V_SNAPTOLEFT | V_YELLOWMAP, "\x1A"); // up arrow
|
||||
if (chat_scroll < chat_maxscroll)
|
||||
HU_DrawDownArrow(chatx-8, chat_bottomy-((justscrolleddown) ? 3 : 4), V_SNAPTOBOTTOM | V_SNAPTOLEFT);
|
||||
V_DrawThinString(chatx-8, chat_bottomy-((justscrolleddown) ? 5 : 6), V_SNAPTOBOTTOM | V_SNAPTOLEFT | V_YELLOWMAP, "\x1B"); // down arrow
|
||||
|
||||
justscrolleddown = false;
|
||||
justscrolledup = false;
|
||||
|
@ -1602,7 +1573,8 @@ static void HU_DrawChat(void)
|
|||
const char *talk = ntalk;
|
||||
const char *mute = "Chat has been muted.";
|
||||
|
||||
/*if (splitscreen)
|
||||
#ifdef NETSPLITSCREEN
|
||||
if (splitscreen)
|
||||
{
|
||||
y -= BASEVIDHEIGHT/2;
|
||||
if (splitscreen > 1)
|
||||
|
@ -1610,11 +1582,10 @@ static void HU_DrawChat(void)
|
|||
y += 16;
|
||||
boxw = max(64, boxw/2);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
#endif
|
||||
y -= (G_RingSlingerGametype() ? 16 : 0);
|
||||
|
||||
// More unused SRB2KART stuff.
|
||||
|
||||
if (teamtalk)
|
||||
{
|
||||
talk = ttalk;
|
||||
|
@ -1698,16 +1669,16 @@ static void HU_DrawChat(void)
|
|||
{
|
||||
INT32 count = 0;
|
||||
INT32 p_dispy = chaty - charheight -1;
|
||||
/*if (splitscreen)
|
||||
#ifdef NETSPLITSCREEN
|
||||
if (splitscreen)
|
||||
{
|
||||
p_dispy -= BASEVIDHEIGHT/2;
|
||||
if (splitscreen > 1)
|
||||
p_dispy += 16;
|
||||
}*/
|
||||
}
|
||||
#endif
|
||||
p_dispy -= (G_RingSlingerGametype() ? 16 : 0);
|
||||
|
||||
// more kart leftovers.
|
||||
|
||||
i = 0;
|
||||
for(i=0; (i<MAXPLAYERS); i++)
|
||||
{
|
||||
|
@ -1725,6 +1696,7 @@ static void HU_DrawChat(void)
|
|||
nodenum = (char*) malloc(3);
|
||||
strncpy(nodenum, w_chat+3, 3);
|
||||
n = atoi((const char*) nodenum); // turn that into a number
|
||||
free(nodenum);
|
||||
// special cases:
|
||||
|
||||
if ((n == 0) && !(w_chat[4] == '0'))
|
||||
|
@ -2023,7 +1995,7 @@ void HU_Drawer(void)
|
|||
if (!OLDCHAT)
|
||||
HU_DrawChat();
|
||||
else
|
||||
HU_DrawChat_Old(); // why the fuck.........................
|
||||
HU_DrawChat_Old();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2040,8 +2012,8 @@ void HU_Drawer(void)
|
|||
// handle spam while we're at it:
|
||||
for(; (i<MAXPLAYERS); i++)
|
||||
{
|
||||
if (stop_spamming_you_cunt[i] > 0)
|
||||
stop_spamming_you_cunt[i]--;
|
||||
if (stop_spamming[i] > 0)
|
||||
stop_spamming[i]--;
|
||||
}
|
||||
|
||||
// handle chat timers
|
||||
|
|
|
@ -58,7 +58,11 @@ typedef struct
|
|||
//------------------------------------
|
||||
#define HU_MAXMSGLEN 224
|
||||
#define CHAT_BUFSIZE 64 // that's enough messages, right? We'll delete the older ones when that gets out of hand.
|
||||
#ifdef NETSPLITSCREEN
|
||||
#define OLDCHAT (cv_consolechat.value == 1 || dedicated || vid.width < 640)
|
||||
#else
|
||||
#define OLDCHAT (cv_consolechat.value == 1 || dedicated || vid.width < 640 || splitscreen)
|
||||
#endif
|
||||
#define CHAT_MUTE (cv_mute.value && !(server || IsPlayerAdmin(consoleplayer))) // this still allows to open the chat but not to type. That's used for scrolling and whatnot.
|
||||
#define OLD_MUTE (OLDCHAT && cv_mute.value && !(server || IsPlayerAdmin(consoleplayer))) // this is used to prevent oldchat from opening when muted.
|
||||
|
||||
|
|
Loading…
Reference in a new issue