mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-12 12:51:21 +00:00
Deduplicate character shifting code
This commit is contained in:
parent
c0ea785900
commit
c65ff70faf
4 changed files with 20 additions and 29 deletions
|
@ -544,6 +544,22 @@ static void CON_MoveConsole(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INT32 CON_ShiftChar(INT32 ch)
|
||||||
|
{
|
||||||
|
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
|
||||||
|
{
|
||||||
|
if (shiftdown ^ capslock)
|
||||||
|
ch = shiftxform[ch];
|
||||||
|
}
|
||||||
|
else // if we're holding shift we should still shift non letter symbols
|
||||||
|
{
|
||||||
|
if (shiftdown)
|
||||||
|
ch = shiftxform[ch];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
// Clear time of console heads up messages
|
// Clear time of console heads up messages
|
||||||
//
|
//
|
||||||
void CON_ClearHUD(void)
|
void CON_ClearHUD(void)
|
||||||
|
|
|
@ -44,6 +44,8 @@ extern UINT8 *yellowmap, *purplemap, *greenmap, *bluemap, *graymap, *redmap, *or
|
||||||
// Console bg color (auto updated to match)
|
// Console bg color (auto updated to match)
|
||||||
extern UINT8 *consolebgmap;
|
extern UINT8 *consolebgmap;
|
||||||
|
|
||||||
|
INT32 CON_ShiftChar(INT32 ch);
|
||||||
|
|
||||||
void CON_SetupBackColormap(void);
|
void CON_SetupBackColormap(void);
|
||||||
void CON_ClearHUD(void); // clear heads up messages
|
void CON_ClearHUD(void); // clear heads up messages
|
||||||
|
|
||||||
|
|
|
@ -2228,24 +2228,8 @@ boolean CL_Responder(event_t *ev)
|
||||||
len = strlen(cl_challengepassword);
|
len = strlen(cl_challengepassword);
|
||||||
if (len < 64)
|
if (len < 64)
|
||||||
{
|
{
|
||||||
|
|
||||||
// shifting code stolen from lat by fickle, thx :)
|
|
||||||
|
|
||||||
// I know this looks very messy but this works. If it ain't broke, don't fix it!
|
|
||||||
// shift LETTERS to uppercase if we have capslock or are holding shift
|
|
||||||
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
|
|
||||||
{
|
|
||||||
if (shiftdown ^ capslock)
|
|
||||||
ch = shiftxform[ch];
|
|
||||||
}
|
|
||||||
else // if we're holding shift we should still shift non letter symbols
|
|
||||||
{
|
|
||||||
if (shiftdown)
|
|
||||||
ch = shiftxform[ch];
|
|
||||||
}
|
|
||||||
|
|
||||||
cl_challengepassword[len+1] = 0;
|
cl_challengepassword[len+1] = 0;
|
||||||
cl_challengepassword[len] = ch;
|
cl_challengepassword[len] = CON_ShiftChar(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_challengeattempted = 0;
|
cl_challengeattempted = 0;
|
||||||
|
|
|
@ -1293,18 +1293,7 @@ boolean HU_Responder(event_t *ev)
|
||||||
&& ev->data1 != gamecontrol[gc_talkkey][1]))
|
&& ev->data1 != gamecontrol[gc_talkkey][1]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// I know this looks very messy but this works. If it ain't broke, don't fix it!
|
c = CON_ShiftChar(c);
|
||||||
// shift LETTERS to uppercase if we have capslock or are holding shift
|
|
||||||
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
|
|
||||||
{
|
|
||||||
if (shiftdown ^ capslock)
|
|
||||||
c = shiftxform[c];
|
|
||||||
}
|
|
||||||
else // if we're holding shift we should still shift non letter symbols
|
|
||||||
{
|
|
||||||
if (shiftdown)
|
|
||||||
c = shiftxform[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) && !CHAT_MUTE)
|
||||||
|
|
Loading…
Reference in a new issue