Sacrifice fun for readability :(

This commit is contained in:
James R 2021-02-16 10:48:24 -08:00
parent dd5223f4d7
commit 196d310052
3 changed files with 23 additions and 23 deletions

View file

@ -697,8 +697,8 @@ typedef struct player_s
tic_t jointime; // Timer when player joins game to change skin/color
tic_t quittime; // Time elapsed since user disconnected, zero if connected
UINT8 typing_timer : 4; // Counts down while keystrokes are not emitted
UINT8 typing_duration : 6; // How long since resumed timer
UINT8 typing_timer; // Counts down while keystrokes are not emitted
UINT8 typing_duration; // How long since resumed timer
#ifdef HWRENDER
fixed_t fovadd; // adjust FOV for hw rendering

View file

@ -2605,20 +2605,15 @@ static void K_DrawRivalTagForPlayer(fixed_t x, fixed_t y)
V_DrawFixedPatch(x, y, FRACUNIT, V_HUDTRANS|V_SPLITSCREEN, kp_rival[blink], NULL);
}
static boolean K_DrawTypingDot(fixed_t x, fixed_t y, UINT8 duration, player_t *p)
static void K_DrawTypingDot(fixed_t x, fixed_t y, UINT8 duration, player_t *p)
{
if (p->typing_duration > duration)
{
V_DrawFixedPatch(x, y, FRACUNIT, V_HUDTRANS|V_SPLITSCREEN, kp_typdot, NULL);
return true;
}
else
{
return false;
}
}
static boolean K_DrawTypingNotifier(fixed_t x, fixed_t y, player_t *p)
static void K_DrawTypingNotifier(fixed_t x, fixed_t y, player_t *p)
{
if (p->cmd.flags & TICCMD_TYPING)
{
@ -2627,18 +2622,9 @@ static boolean K_DrawTypingNotifier(fixed_t x, fixed_t y, player_t *p)
y += 4*FRACUNIT;
/* spacing closer with the last two looks a better most of the time */
(void)
(
K_DrawTypingDot(x + 3*FRACUNIT, y, 15, p) &&
K_DrawTypingDot(x + 6*FRACUNIT - FRACUNIT/3, y, 31, p) &&
K_DrawTypingDot(x + 9*FRACUNIT - FRACUNIT/3, y, 47, p)
);
return true;
}
else
{
return false;
K_DrawTypingDot(x + 3*FRACUNIT, y, 15, p);
K_DrawTypingDot(x + 6*FRACUNIT - FRACUNIT/3, y, 31, p);
K_DrawTypingDot(x + 9*FRACUNIT - FRACUNIT/3, y, 47, p);
}
}

View file

@ -4590,6 +4590,12 @@ void P_PlayerThink(player_t *player)
if (cmd->flags & TICCMD_TYPING)
{
/*
typing_duration is slow to start and slow to stop.
typing_timer counts down a grace period before the player is not
actually considered typing anymore.
*/
if (cmd->flags & TICCMD_KEYSTROKE)
{
player->typing_timer = 15;
@ -4599,18 +4605,26 @@ void P_PlayerThink(player_t *player)
player->typing_timer--;
}
/* if we are in the grace period (including currently typing) */
if (player->typing_timer + player->typing_duration > 0)
{
/* lag a little bit so we always get more than just a singular dot */
/*
If one dot was already displayed, let the duration continue to
display two dots for a bit, before actually resetting.
*/
if (player->typing_timer == 0 &&
(player->typing_duration < 16 || player->typing_duration > 39))
{
player->typing_duration = 0;
}
else
else if (player->typing_duration < 63)
{
player->typing_duration++;
}
else
{
player->typing_duration = 0;
}
}
}
else