mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-26 20:11:47 +00:00
Merge remote-tracking branch 'origin/chat-flood-fix'
This commit is contained in:
commit
7ab84ebd2f
3 changed files with 206 additions and 230 deletions
|
|
@ -139,12 +139,78 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr)
|
||||||
|
|
||||||
#undef DEALIGNED
|
#undef DEALIGNED
|
||||||
|
|
||||||
#define WRITESTRINGN(p,s,n) do { size_t tmp_i = 0; for (; tmp_i < n && s[tmp_i] != '\0'; tmp_i++) WRITECHAR(p, s[tmp_i]); if (tmp_i < n) WRITECHAR(p, '\0');} while (0)
|
#define WRITESTRINGN(p, s, n) do { \
|
||||||
#define WRITESTRING(p,s) do { size_t tmp_i = 0; for (; s[tmp_i] != '\0'; tmp_i++) WRITECHAR(p, s[tmp_i]); WRITECHAR(p, '\0');} while (0)
|
size_t tmp_i; \
|
||||||
#define WRITEMEM(p,s,n) do { memcpy(p, s, n); p += n; } while (0)
|
\
|
||||||
|
for (tmp_i = 0; tmp_i < n && s[tmp_i] != '\0'; tmp_i++) \
|
||||||
|
WRITECHAR(p, s[tmp_i]); \
|
||||||
|
\
|
||||||
|
if (tmp_i < n) \
|
||||||
|
WRITECHAR(p, '\0'); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SKIPSTRING(p) while (READCHAR(p) != '\0')
|
#define WRITESTRINGL(p, s, n) do { \
|
||||||
|
size_t tmp_i; \
|
||||||
|
\
|
||||||
|
for (tmp_i = 0; tmp_i < n - 1 && s[tmp_i] != '\0'; tmp_i++) \
|
||||||
|
WRITECHAR(p, s[tmp_i]); \
|
||||||
|
\
|
||||||
|
WRITECHAR(p, '\0'); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define READSTRINGN(p,s,n) do { size_t tmp_i = 0; for (; tmp_i < n && (s[tmp_i] = READCHAR(p)) != '\0'; tmp_i++); s[tmp_i] = '\0';} while (0)
|
#define WRITESTRING(p, s) do { \
|
||||||
#define READSTRING(p,s) do { size_t tmp_i = 0; for (; (s[tmp_i] = READCHAR(p)) != '\0'; tmp_i++); s[tmp_i] = '\0';} while (0)
|
size_t tmp_i; \
|
||||||
#define READMEM(p,s,n) do { memcpy(s, p, n); p += n; } while (0)
|
\
|
||||||
|
for (tmp_i = 0; s[tmp_i] != '\0'; tmp_i++) \
|
||||||
|
WRITECHAR(p, s[tmp_i]); \
|
||||||
|
\
|
||||||
|
WRITECHAR(p, '\0'); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define WRITEMEM(p, s, n) do { \
|
||||||
|
memcpy(p, s, n); \
|
||||||
|
p += n; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define SKIPSTRING(p) while (READCHAR(p) != '\0')
|
||||||
|
|
||||||
|
#define SKIPSTRINGN(p, n) do { \
|
||||||
|
size_t tmp_i = 0; \
|
||||||
|
\
|
||||||
|
while (tmp_i < n && READCHAR(p) != '\0') \
|
||||||
|
tmp_i++; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define SKIPSTRINGL(p, n) SKIPSTRINGN(p, n)
|
||||||
|
|
||||||
|
#define READSTRINGN(p, s, n) do { \
|
||||||
|
size_t tmp_i = 0; \
|
||||||
|
\
|
||||||
|
while (tmp_i < n && (s[tmp_i] = READCHAR(p)) != '\0') \
|
||||||
|
tmp_i++; \
|
||||||
|
\
|
||||||
|
s[tmp_i] = '\0'; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define READSTRINGL(p, s, n) do { \
|
||||||
|
size_t tmp_i = 0; \
|
||||||
|
\
|
||||||
|
while (tmp_i < n - 1 && (s[tmp_i] = READCHAR(p)) != '\0') \
|
||||||
|
tmp_i++; \
|
||||||
|
\
|
||||||
|
s[tmp_i] = '\0'; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define READSTRING(p, s) do { \
|
||||||
|
size_t tmp_i = 0; \
|
||||||
|
\
|
||||||
|
while ((s[tmp_i] = READCHAR(p)) != '\0') \
|
||||||
|
tmp_i++; \
|
||||||
|
\
|
||||||
|
s[tmp_i] = '\0'; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define READMEM(p, s, n) do { \
|
||||||
|
memcpy(s, p, n); \
|
||||||
|
p += n; \
|
||||||
|
} while (0)
|
||||||
|
|
|
||||||
352
src/hu_stuff.c
352
src/hu_stuff.c
|
|
@ -85,9 +85,9 @@ patch_t *framecounter;
|
||||||
patch_t *frameslash; // framerate stuff. Used in screen.c
|
patch_t *frameslash; // framerate stuff. Used in screen.c
|
||||||
|
|
||||||
static player_t *plr;
|
static player_t *plr;
|
||||||
boolean chat_on; // entering a chat message?
|
|
||||||
boolean hu_keystrokes; // :)
|
boolean hu_keystrokes; // :)
|
||||||
static char w_chat[HU_MAXMSGLEN];
|
boolean chat_on; // entering a chat message?
|
||||||
|
static char w_chat[HU_MAXMSGLEN + 1];
|
||||||
static size_t c_input = 0; // let's try to make the chat input less shitty.
|
static size_t c_input = 0; // let's try to make the chat input less shitty.
|
||||||
static boolean headsupactive = false;
|
static boolean headsupactive = false;
|
||||||
boolean hu_showscores; // draw rankings
|
boolean hu_showscores; // draw rankings
|
||||||
|
|
@ -487,7 +487,7 @@ void HU_AddChatText(const char *text, boolean playsound)
|
||||||
|
|
||||||
static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags)
|
static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags)
|
||||||
{
|
{
|
||||||
char buf[254];
|
char buf[2 + HU_MAXMSGLEN + 1];
|
||||||
size_t numwords, ix;
|
size_t numwords, ix;
|
||||||
char *msg = &buf[2];
|
char *msg = &buf[2];
|
||||||
const size_t msgspace = sizeof buf - 2;
|
const size_t msgspace = sizeof buf - 2;
|
||||||
|
|
@ -567,7 +567,7 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags)
|
||||||
}
|
}
|
||||||
buf[0] = target;
|
buf[0] = target;
|
||||||
newmsg = msg+5+spc;
|
newmsg = msg+5+spc;
|
||||||
strlcpy(msg, newmsg, 252);
|
strlcpy(msg, newmsg, HU_MAXMSGLEN + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SendNetXCmd(XD_SAY, buf, strlen(msg) + 1 + msg-buf);
|
SendNetXCmd(XD_SAY, buf, strlen(msg) + 1 + msg-buf);
|
||||||
|
|
@ -697,7 +697,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
|
||||||
target = READSINT8(*p);
|
target = READSINT8(*p);
|
||||||
flags = READUINT8(*p);
|
flags = READUINT8(*p);
|
||||||
msg = (char *)*p;
|
msg = (char *)*p;
|
||||||
SKIPSTRING(*p);
|
SKIPSTRINGL(*p, HU_MAXMSGLEN + 1);
|
||||||
|
|
||||||
if ((cv_mute.value || flags & (HU_CSAY|HU_SHOUT)) && playernum != serverplayer && !(IsPlayerAdmin(playernum)))
|
if ((cv_mute.value || flags & (HU_CSAY|HU_SHOUT)) && playernum != serverplayer && !(IsPlayerAdmin(playernum)))
|
||||||
{
|
{
|
||||||
|
|
@ -916,71 +916,6 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handles key input and string input
|
|
||||||
//
|
|
||||||
static inline boolean HU_keyInChatString(char *s, char ch)
|
|
||||||
{
|
|
||||||
size_t l;
|
|
||||||
|
|
||||||
if ((ch >= HU_FONTSTART && ch <= HU_FONTEND && fontv[HU_FONT].font[ch-HU_FONTSTART])
|
|
||||||
|| ch == ' ') // Allow spaces, of course
|
|
||||||
{
|
|
||||||
l = strlen(s);
|
|
||||||
if (l < HU_MAXMSGLEN - 1)
|
|
||||||
{
|
|
||||||
if (c_input >= strlen(s)) // don't do anything complicated
|
|
||||||
{
|
|
||||||
s[l++] = ch;
|
|
||||||
s[l]=0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// move everything past c_input for new characters:
|
|
||||||
size_t m = HU_MAXMSGLEN-1;
|
|
||||||
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.
|
|
||||||
}
|
|
||||||
c_input++;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (ch == KEY_BACKSPACE)
|
|
||||||
{
|
|
||||||
size_t i = c_input;
|
|
||||||
|
|
||||||
if (c_input <= 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!s[i-1])
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (i >= strlen(s)-1)
|
|
||||||
{
|
|
||||||
s[strlen(s)-1] = 0;
|
|
||||||
c_input--;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (; (i < HU_MAXMSGLEN); i++)
|
|
||||||
{
|
|
||||||
s[i-1] = s[i];
|
|
||||||
}
|
|
||||||
c_input--;
|
|
||||||
}
|
|
||||||
else if (ch != KEY_ENTER)
|
|
||||||
return false; // did not eat key
|
|
||||||
|
|
||||||
return true; // ate the key
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
static void HU_TickSongCredits(void)
|
static void HU_TickSongCredits(void)
|
||||||
|
|
@ -1096,154 +1031,125 @@ void HU_Ticker(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean teamtalk = false;
|
static boolean teamtalk = false;
|
||||||
|
static boolean justscrolleddown;
|
||||||
|
static boolean justscrolledup;
|
||||||
|
static INT16 typelines = 1; // number of drawfill lines we need when drawing the chat. it's some weird hack and might be one frame off but I'm lazy to make another loop.
|
||||||
|
// It's up here since it has to be reset when we open the chat.
|
||||||
|
|
||||||
// Clear spaces so we don't end up with messages only made out of emptiness
|
static boolean HU_chatboxContainsOnlySpaces(void)
|
||||||
static boolean HU_clearChatSpaces(void)
|
|
||||||
{
|
{
|
||||||
size_t i = 0; // Used to just check our message
|
size_t i;
|
||||||
char c; // current character we're iterating.
|
|
||||||
boolean nothingbutspaces = true;
|
|
||||||
|
|
||||||
for (; i < strlen(w_chat); i++) // iterate through message and eradicate all spaces that don't belong.
|
for (i = 0; w_chat[i]; i++)
|
||||||
{
|
if (w_chat[i] != ' ')
|
||||||
c = w_chat[i];
|
return false;
|
||||||
if (!c)
|
|
||||||
break; // if there's nothing, it's safe to assume our message has ended, so let's not waste any more time here.
|
|
||||||
|
|
||||||
if (c != ' ') // Isn't a space
|
return true;
|
||||||
{
|
|
||||||
nothingbutspaces = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nothingbutspaces;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
static void HU_sendChatMessage(void)
|
||||||
//
|
|
||||||
static void HU_queueChatChar(INT32 c)
|
|
||||||
{
|
{
|
||||||
// send automaticly the message (no more chat char)
|
char buf[2 + HU_MAXMSGLEN + 1];
|
||||||
if (c == KEY_ENTER)
|
char *msg = &buf[2];
|
||||||
|
size_t ci;
|
||||||
|
INT32 target = 0;
|
||||||
|
|
||||||
|
// if our message was nothing but spaces, don't send it.
|
||||||
|
if (HU_chatboxContainsOnlySpaces())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// copy printable characters and terminating '\0' only.
|
||||||
|
for (ci = 2; w_chat[ci-2]; ci++)
|
||||||
{
|
{
|
||||||
char buf[2+256];
|
char c = w_chat[ci-2];
|
||||||
char *msg = &buf[2];
|
if (c >= ' ' && !(c & 0x80))
|
||||||
size_t i;
|
buf[ci] = c;
|
||||||
size_t ci = 2;
|
};
|
||||||
INT32 target = 0;
|
buf[ci] = '\0';
|
||||||
|
|
||||||
if (HU_clearChatSpaces()) // Avoids being able to send empty messages, or something.
|
memset(w_chat, '\0', sizeof(w_chat));
|
||||||
return; // If this returns true, that means our message was NOTHING but spaces, so don't send it period.
|
c_input = 0;
|
||||||
|
|
||||||
do {
|
// last minute mute check
|
||||||
c = w_chat[-2+ci++];
|
if (CHAT_MUTE)
|
||||||
if (!c || (c >= ' ' && !(c & 0x80))) // copy printable characters and terminating '\0' only.
|
{
|
||||||
buf[ci-1]=c;
|
HU_AddChatText(va("%s>ERROR: The chat is muted. You can't say anything.", "\x85"), false);
|
||||||
} while (c);
|
return;
|
||||||
i = 0;
|
}
|
||||||
for (;(i<HU_MAXMSGLEN);i++)
|
|
||||||
w_chat[i] = 0; // reset this.
|
|
||||||
|
|
||||||
c_input = 0;
|
if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm
|
||||||
|
{
|
||||||
|
INT32 spc = 1; // used if playernum[1] is a space.
|
||||||
|
char playernum[3];
|
||||||
|
const char *newmsg;
|
||||||
|
|
||||||
for (;(i<HU_MAXMSGLEN);i++)
|
// what we're gonna do now is check if the player exists
|
||||||
w_chat[i] = 0; // reset this.
|
// with that logic, characters 4 and 5 are our numbers:
|
||||||
|
|
||||||
c_input = 0;
|
// teamtalk can't send PMs, just don't send it, else everyone would be able to see it, and no one wants to see your sex RP sicko.
|
||||||
|
if (teamtalk)
|
||||||
// last minute mute check
|
|
||||||
if (CHAT_MUTE)
|
|
||||||
{
|
{
|
||||||
HU_AddChatText(va("%s>ERROR: The chat is muted. You can't say anything.", "\x85"), false);
|
HU_AddChatText(va("%sCannot send sayto in Say-Team.", "\x85"), false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm
|
strncpy(playernum, msg+3, 3);
|
||||||
|
// check for undesirable characters in our "number"
|
||||||
|
if (!(isdigit(playernum[0]) && isdigit(playernum[1])))
|
||||||
{
|
{
|
||||||
INT32 spc = 1; // used if playernum[1] is a space.
|
// check if playernum[1] is a space
|
||||||
char playernum[3];
|
if (playernum[1] == ' ')
|
||||||
const char *newmsg;
|
spc = 0;
|
||||||
|
// let it slide
|
||||||
// what we're gonna do now is check if the player exists
|
|
||||||
// with that logic, characters 4 and 5 are our numbers:
|
|
||||||
|
|
||||||
// teamtalk can't send PMs, just don't send it, else everyone would be able to see it, and no one wants to see your sex RP sicko.
|
|
||||||
if (teamtalk)
|
|
||||||
{
|
|
||||||
HU_AddChatText(va("%sCannot send sayto in Say-Team.", "\x85"), false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
strncpy(playernum, msg+3, 3);
|
|
||||||
|
|
||||||
// check for undesirable characters in our "number"
|
|
||||||
if (((playernum[0] < '0') || (playernum[0] > '9')) || ((playernum[1] < '0') || (playernum[1] > '9')))
|
|
||||||
{
|
|
||||||
// check if playernum[1] is a space
|
|
||||||
if (playernum[1] == ' ')
|
|
||||||
spc = 0;
|
|
||||||
// let it slide
|
|
||||||
else
|
|
||||||
{
|
|
||||||
HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm<player num> \'.", false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// I'm very bad at C, I swear I am, additional checks eww!
|
|
||||||
if (spc != 0)
|
|
||||||
{
|
|
||||||
if (msg[5] != ' ')
|
|
||||||
{
|
|
||||||
HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm<player num> \'.", false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
target = atoi(playernum); // turn that into a number
|
|
||||||
//CONS_Printf("%d\n", target);
|
|
||||||
|
|
||||||
// check for target player, if it doesn't exist then we can't send the message!
|
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
HU_AddChatText(va("\x82NOTICE: \x80Player %d does not exist.", target), false); // same
|
HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm<player num> \'.", false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we need to get rid of the /pm<player num>
|
|
||||||
newmsg = msg+5+spc;
|
|
||||||
strlcpy(msg, newmsg, 255);
|
|
||||||
}
|
}
|
||||||
if (ci > 3) // don't send target+flags+empty message.
|
// I'm very bad at C, I swear I am, additional checks eww!
|
||||||
|
if (spc != 0 && msg[5] != ' ')
|
||||||
{
|
{
|
||||||
if (teamtalk)
|
HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm<player num> \'.", false);
|
||||||
buf[0] = -1; // target
|
return;
|
||||||
else
|
|
||||||
buf[0] = target;
|
|
||||||
|
|
||||||
buf[1] = ((server || IsPlayerAdmin(consoleplayer)) && cv_autoshout.value) ? HU_SHOUT : 0; // flags
|
|
||||||
SendNetXCmd(XD_SAY, buf, 2 + strlen(&buf[2]) + 1);
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
target = atoi(playernum); // turn that into a number
|
||||||
|
|
||||||
|
// check for target player, if it doesn't exist then we can't send the message!
|
||||||
|
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
|
||||||
|
{
|
||||||
|
HU_AddChatText(va("\x82NOTICE: \x80Player %d does not exist.", target), false); // same
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// we need to get rid of the /pm<player num>
|
||||||
|
newmsg = msg+5+spc;
|
||||||
|
strlcpy(msg, newmsg, HU_MAXMSGLEN + 1);
|
||||||
|
}
|
||||||
|
if (ci > 2) // don't send target+flags+empty message.
|
||||||
|
{
|
||||||
|
if (teamtalk)
|
||||||
|
buf[0] = -1; // target
|
||||||
|
else
|
||||||
|
buf[0] = target;
|
||||||
|
|
||||||
|
buf[1] = ((server || IsPlayerAdmin(consoleplayer)) && cv_autoshout.value) ? HU_SHOUT : 0; // flags
|
||||||
|
SendNetXCmd(XD_SAY, buf, 2 + strlen(&buf[2]) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HU_clearChatChars(void)
|
void HU_clearChatChars(void)
|
||||||
{
|
{
|
||||||
size_t i = 0;
|
memset(w_chat, '\0', sizeof(w_chat));
|
||||||
for (;i<HU_MAXMSGLEN;i++)
|
|
||||||
w_chat[i] = 0; // reset this.
|
|
||||||
chat_on = false;
|
chat_on = false;
|
||||||
c_input = 0;
|
c_input = 0;
|
||||||
|
|
||||||
I_UpdateMouseGrab();
|
I_UpdateMouseGrab();
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean justscrolleddown;
|
|
||||||
static boolean justscrolledup;
|
|
||||||
static INT16 typelines = 1; // number of drawfill lines we need when drawing the chat. it's some weird hack and might be one frame off but I'm lazy to make another loop.
|
|
||||||
// It's up here since it has to be reset when we open the chat.
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Returns true if key eaten
|
// Returns true if key eaten
|
||||||
//
|
//
|
||||||
|
|
@ -1327,14 +1233,16 @@ boolean HU_Responder(event_t *ev)
|
||||||
c = CON_ShiftChar(c);
|
c = CON_ShiftChar(c);
|
||||||
|
|
||||||
// pasting. pasting is cool. chat is a bit limited, though :(
|
// pasting. pasting is cool. chat is a bit limited, though :(
|
||||||
if (((c == 'v' || c == 'V') && ctrldown) && !CHAT_MUTE)
|
if ((c == 'v' || c == 'V') && ctrldown)
|
||||||
{
|
{
|
||||||
const char *paste = I_ClipboardPaste();
|
const char *paste;
|
||||||
size_t chatlen;
|
size_t chatlen;
|
||||||
size_t pastelen;
|
size_t pastelen;
|
||||||
|
|
||||||
// create a dummy string real quickly
|
if (CHAT_MUTE)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
paste = I_ClipboardPaste();
|
||||||
if (paste == NULL)
|
if (paste == NULL)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
@ -1343,40 +1251,16 @@ boolean HU_Responder(event_t *ev)
|
||||||
if (chatlen+pastelen > HU_MAXMSGLEN)
|
if (chatlen+pastelen > HU_MAXMSGLEN)
|
||||||
return true; // we can't paste this!!
|
return true; // we can't paste this!!
|
||||||
|
|
||||||
if (c_input >= strlen(w_chat)) // add it at the end of the string.
|
memmove(&w_chat[c_input + pastelen], &w_chat[c_input], pastelen);
|
||||||
{
|
memcpy(&w_chat[c_input], paste, pastelen); // copy all of that.
|
||||||
memcpy(&w_chat[chatlen], paste, pastelen); // copy all of that.
|
c_input += pastelen;
|
||||||
c_input += pastelen;
|
return true;
|
||||||
/*size_t i = 0;
|
|
||||||
for (;i<pastelen;i++)
|
|
||||||
{
|
|
||||||
HU_queueChatChar(paste[i]); // queue it so that it's actually sent. (this chat write thing is REALLY messy.)
|
|
||||||
}*/
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else // otherwise, we need to shift everything and make space, etc etc
|
|
||||||
{
|
|
||||||
size_t i = HU_MAXMSGLEN-1;
|
|
||||||
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;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (c == KEY_ENTER)
|
||||||
|
{
|
||||||
|
if (!CHAT_MUTE)
|
||||||
|
HU_sendChatMessage();
|
||||||
|
|
||||||
if (!CHAT_MUTE && HU_keyInChatString(w_chat,c))
|
|
||||||
{
|
|
||||||
HU_queueChatChar(c);
|
|
||||||
}
|
|
||||||
if (c == KEY_ENTER)
|
|
||||||
{
|
|
||||||
chat_on = false;
|
chat_on = false;
|
||||||
c_input = 0; // reset input cursor
|
c_input = 0; // reset input cursor
|
||||||
chat_scrollmedown = true; // you hit enter, so you might wanna autoscroll to see what you just sent. :)
|
chat_scrollmedown = true; // you hit enter, so you might wanna autoscroll to see what you just sent. :)
|
||||||
|
|
@ -1417,6 +1301,32 @@ boolean HU_Responder(event_t *ev)
|
||||||
else
|
else
|
||||||
c_input++;
|
c_input++;
|
||||||
}
|
}
|
||||||
|
else if ((c >= HU_FONTSTART && c <= HU_FONTEND && fontv[HU_FONT].font[c-HU_FONTSTART])
|
||||||
|
|| c == ' ') // Allow spaces, of course
|
||||||
|
{
|
||||||
|
if (CHAT_MUTE || strlen(w_chat) >= HU_MAXMSGLEN)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
memmove(&w_chat[c_input + 1], &w_chat[c_input], strlen(w_chat) - c_input + 1);
|
||||||
|
w_chat[c_input] = c;
|
||||||
|
c_input++;
|
||||||
|
}
|
||||||
|
else if (c == KEY_BACKSPACE)
|
||||||
|
{
|
||||||
|
if (CHAT_MUTE || c_input <= 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
memmove(&w_chat[c_input - 1], &w_chat[c_input], strlen(w_chat) - c_input + 1);
|
||||||
|
c_input--;
|
||||||
|
}
|
||||||
|
else if (c == KEY_DEL)
|
||||||
|
{
|
||||||
|
if (CHAT_MUTE || c_input >= strlen(w_chat))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
memmove(&w_chat[c_input], &w_chat[c_input + 1], strlen(w_chat) - c_input);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1962,8 +1872,8 @@ static void HU_DrawChat_Old(void)
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
const char *ntalk = "Say: ", *ttalk = "Say-Team: ";
|
const char *ntalk = "Say: ", *ttalk = "Say-Team: ";
|
||||||
const char *talk = ntalk;
|
const char *talk = ntalk;
|
||||||
INT32 charwidth = 8 * con_scalefactor; //(hu_font['A'-HU_FONTSTART]->width) * con_scalefactor;
|
INT32 charwidth = 8 * con_scalefactor; //(fontv[HU_FONT].font['A'-HU_FONTSTART]->width) * con_scalefactor;
|
||||||
INT32 charheight = 8 * con_scalefactor; //(hu_font['A'-HU_FONTSTART]->height) * con_scalefactor;
|
INT32 charheight = 8 * con_scalefactor; //(fontv[HU_FONT].font['A'-HU_FONTSTART]->height) * con_scalefactor;
|
||||||
if (teamtalk)
|
if (teamtalk)
|
||||||
{
|
{
|
||||||
talk = ttalk;
|
talk = ttalk;
|
||||||
|
|
@ -1984,7 +1894,7 @@ static void HU_DrawChat_Old(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//charwidth = (hu_font[talk[i]-HU_FONTSTART]->width) * con_scalefactor;
|
//charwidth = (fontv[HU_FONT].font[talk[i]-HU_FONTSTART]->width) * con_scalefactor;
|
||||||
V_DrawCharacter(HU_INPUTX + c, y, talk[i++] | cv_constextsize.value | V_NOSCALESTART, true);
|
V_DrawCharacter(HU_INPUTX + c, y, talk[i++] | cv_constextsize.value | V_NOSCALESTART, true);
|
||||||
}
|
}
|
||||||
c += charwidth;
|
c += charwidth;
|
||||||
|
|
@ -2012,7 +1922,7 @@ static void HU_DrawChat_Old(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//charwidth = (hu_font[w_chat[i]-HU_FONTSTART]->width) * con_scalefactor;
|
//charwidth = (fontv[HU_FONT].font[w_chat[i]-HU_FONTSTART]->width) * con_scalefactor;
|
||||||
V_DrawCharacter(HU_INPUTX + c, y, w_chat[i++] | cv_constextsize.value | V_NOSCALESTART | t, true);
|
V_DrawCharacter(HU_INPUTX + c, y, w_chat[i++] | cv_constextsize.value | V_NOSCALESTART | t, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,8 @@ typedef struct
|
||||||
//------------------------------------
|
//------------------------------------
|
||||||
// chat stuff
|
// chat stuff
|
||||||
//------------------------------------
|
//------------------------------------
|
||||||
#define HU_MAXMSGLEN 224
|
#define HU_MAXMSGLEN 223
|
||||||
#define CHAT_BUFSIZE 64 // that's enough messages, right? We'll delete the older ones when that gets out of hand.
|
#define CHAT_BUFSIZE 64 // that's enough messages, right? We'll delete the older ones when that gets out of hand.
|
||||||
#define NETSPLITSCREEN // why the hell WOULDN'T we want this?
|
#define NETSPLITSCREEN // why the hell WOULDN'T we want this?
|
||||||
#ifdef NETSPLITSCREEN
|
#ifdef NETSPLITSCREEN
|
||||||
#define OLDCHAT (cv_consolechat.value == 1 || dedicated || vid.width < 640)
|
#define OLDCHAT (cv_consolechat.value == 1 || dedicated || vid.width < 640)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue