Show last lap time on HUD
god this is kinda ass lol doesent work when you join midgame so disabled for there
This commit is contained in:
1 parent
fec72732e5
commit
60d7b0272e
5 files changed
+103
-42
No files matched your search
@@ -347,6 +347,14 @@ typedef enum
|
||||
RW_RAIL = 32
|
||||
} ringweapons_t;
|
||||
|
||||
// enum for saved lap times
|
||||
typedef enum
|
||||
{
|
||||
LAP_CUR,
|
||||
LAP_LAST,
|
||||
LAP__MAX
|
||||
} laptime_e;
|
||||
|
||||
// ========================================================================
|
||||
// PLAYER STRUCTURE
|
||||
// ========================================================================
|
||||
@@ -465,6 +473,7 @@ typedef struct player_s
|
||||
INT16 numboxes; // Number of item boxes obtained for Race Mode
|
||||
INT16 totalring; // Total number of rings obtained for Race Mode
|
||||
tic_t realtime; // integer replacement for leveltime
|
||||
tic_t laptime[LAP__MAX];
|
||||
UINT8 laps; // Number of laps (optional)
|
||||
|
||||
////////////////////
|
||||
|
||||
@@ -2502,6 +2502,10 @@ void G_PlayerReborn(INT32 player)
|
||||
boolean fade;
|
||||
boolean playing;
|
||||
|
||||
tic_t laptime[LAP__MAX];
|
||||
|
||||
INT32 i;
|
||||
|
||||
score = players[player].score;
|
||||
marescore = players[player].marescore;
|
||||
lives = players[player].lives;
|
||||
@@ -2543,6 +2547,21 @@ void G_PlayerReborn(INT32 player)
|
||||
bot = players[player].bot;
|
||||
pity = players[player].pity;
|
||||
|
||||
if (leveltime <= starttime) // man i really hope this crap works kek but need to reset this somehow at mapstart
|
||||
{
|
||||
for (i = 0; i < LAP__MAX; i++)
|
||||
{
|
||||
laptime[i] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < LAP__MAX; i++)
|
||||
{
|
||||
laptime[i] = players[player].laptime[i];
|
||||
}
|
||||
}
|
||||
|
||||
// SRB2kart
|
||||
if (leveltime <= starttime || spectator == true)
|
||||
{
|
||||
@@ -2634,6 +2653,11 @@ void G_PlayerReborn(INT32 player)
|
||||
p->laps = laps;
|
||||
p->totalring = totalring;
|
||||
|
||||
for (i = 0; i < LAP__MAX; i++)
|
||||
{
|
||||
p->laptime[i] = laptime[i];
|
||||
}
|
||||
|
||||
p->mare = mare;
|
||||
if (bot)
|
||||
p->bot = 1; // reset to AI-controlled
|
||||
|
||||
+50
-42
@@ -16,6 +16,7 @@
|
||||
#include "m_random.h"
|
||||
#include "m_menu.h" // ffdhidshfuisduifigergho9igj89dgodhfih AAAAAAAAAA
|
||||
#include "p_local.h"
|
||||
#include "p_setup.h"
|
||||
#include "p_slopes.h"
|
||||
#include "r_defs.h"
|
||||
#include "r_draw.h"
|
||||
@@ -38,6 +39,7 @@
|
||||
#include "lua_hook.h" // For MobjDamage and ShouldDamage
|
||||
#include "d_main.h" // found_extra_kart
|
||||
|
||||
|
||||
#include "i_video.h"
|
||||
|
||||
#ifdef HWRENDER
|
||||
@@ -8366,8 +8368,6 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI
|
||||
{
|
||||
// TIME_X = BASEVIDWIDTH-124; // 196
|
||||
// TIME_Y = 6; // 6
|
||||
|
||||
tic_t worktime;
|
||||
|
||||
INT32 splitflags = 0;
|
||||
if (!mode)
|
||||
@@ -8392,63 +8392,54 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI
|
||||
|
||||
TX += 33;
|
||||
|
||||
worktime = drawtime/(60*TICRATE);
|
||||
|
||||
if (mode && !drawtime)
|
||||
V_DrawKartString(TX, TY+3, splitflags, va("--'--\"--"));
|
||||
else if (worktime < 100) // 99:99:99 only
|
||||
if (drawtime == UINT32_MAX)
|
||||
;
|
||||
else if (mode && !drawtime)
|
||||
{
|
||||
// apostrophe location _'__ __
|
||||
V_DrawKartString(TX+24, TY+3, splitflags, va("'"));
|
||||
|
||||
// quotation mark location _ __"__
|
||||
V_DrawKartString(TX+60, TY+3, splitflags, va("\""));
|
||||
}
|
||||
else
|
||||
{
|
||||
tic_t worktime = drawtime/(60*TICRATE);
|
||||
|
||||
if (worktime >= 100)
|
||||
{
|
||||
worktime = 99;
|
||||
drawtime = (100*(60*TICRATE))-1;
|
||||
}
|
||||
|
||||
if ((cv_timelimit.value && G_BattleGametype()) && (!players[consoleplayer].exiting && (leveltime > (timelimitintics + starttime + TICRATE/2)) && cv_overtime.value)) // i hate this so much
|
||||
{
|
||||
V_DrawKartString(TX, TY+3, splitflags, va("OVERTIME"));
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
// zero minute
|
||||
if (worktime < 10)
|
||||
{
|
||||
V_DrawKartString(TX, TY+3, splitflags, va("0"));
|
||||
// minutes time 0 __ __
|
||||
V_DrawKartString(TX+12, TY+3, splitflags, va("%d", worktime));
|
||||
}
|
||||
// minutes time 0 __ __
|
||||
else
|
||||
V_DrawKartString(TX, TY+3, splitflags, va("%d", worktime));
|
||||
|
||||
// minutes time 00 __ __
|
||||
V_DrawKartString(TX, TY+3, splitflags, va("%d", worktime/10));
|
||||
V_DrawKartString(TX+12, TY+3, splitflags, va("%d", worktime%10));
|
||||
|
||||
// apostrophe location _'__ __
|
||||
V_DrawKartString(TX+24, TY+3, splitflags, va("'"));
|
||||
|
||||
worktime = (drawtime/TICRATE % 60);
|
||||
|
||||
// zero second _ 0_ __
|
||||
if (worktime < 10)
|
||||
{
|
||||
V_DrawKartString(TX+36, TY+3, splitflags, va("0"));
|
||||
// seconds time _ _0 __
|
||||
V_DrawKartString(TX+48, TY+3, splitflags, va("%d", worktime));
|
||||
}
|
||||
// zero second _ 00 __
|
||||
else
|
||||
V_DrawKartString(TX+36, TY+3, splitflags, va("%d", worktime));
|
||||
// seconds time _ 00 __
|
||||
V_DrawKartString(TX+36, TY+3, splitflags, va("%d", worktime/10));
|
||||
V_DrawKartString(TX+48, TY+3, splitflags, va("%d", worktime%10));
|
||||
|
||||
// quotation mark location _ __"__
|
||||
V_DrawKartString(TX+60, TY+3, splitflags, va("\""));
|
||||
|
||||
worktime = G_TicsToCentiseconds(drawtime);
|
||||
|
||||
// zero tick _ __ 0_
|
||||
if (worktime < 10)
|
||||
{
|
||||
V_DrawKartString(TX+72, TY+3, splitflags, va("0"));
|
||||
// tics _ __ _0
|
||||
V_DrawKartString(TX+84, TY+3, splitflags, va("%d", worktime));
|
||||
}
|
||||
// zero tick _ __ 00
|
||||
else
|
||||
V_DrawKartString(TX+72, TY+3, splitflags, va("%d", worktime));
|
||||
// tics _ __ 00
|
||||
V_DrawKartString(TX+72, TY+3, splitflags, va("%d", worktime/10));
|
||||
V_DrawKartString(TX+84, TY+3, splitflags, va("%d", worktime%10));
|
||||
}
|
||||
else if ((drawtime/TICRATE) & 1)
|
||||
V_DrawKartString(TX, TY+3, splitflags, va("99'59\"99"));
|
||||
|
||||
if (emblemmap && (modeattacking || (mode == 1)) && !demo.playback) // emblem time!
|
||||
{
|
||||
@@ -10747,9 +10738,26 @@ void K_drawKartHUD(void)
|
||||
// If not splitscreen, draw...
|
||||
if (!splitscreen && !demo.title)
|
||||
{
|
||||
tic_t realtime = stplyr->realtime;
|
||||
|
||||
if (stplyr->kartstuff[k_lapanimation]
|
||||
&& !stplyr->exiting
|
||||
&& stplyr->laptime[LAP_LAST] != 0
|
||||
&& !midgamejoin)
|
||||
{
|
||||
if ((stplyr->kartstuff[k_lapanimation] / 5) & 1)
|
||||
{
|
||||
realtime = stplyr->laptime[LAP_LAST];
|
||||
}
|
||||
else
|
||||
{
|
||||
realtime = UINT32_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the timestamp
|
||||
if (LUA_HudEnabled(hud_time))
|
||||
K_drawKartTimestamp(stplyr->realtime, TIME_X, TIME_Y, gamemap, 0);
|
||||
K_drawKartTimestamp(realtime, TIME_X, TIME_Y, gamemap, 0);
|
||||
|
||||
if (!modeattacking)
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "z_zone.h"
|
||||
#include "r_main.h" //Two extra includes.
|
||||
#include "r_sky.h"
|
||||
#include "st_stuff.h"
|
||||
#include "p_polyobj.h"
|
||||
#include "p_slopes.h"
|
||||
#include "hu_stuff.h"
|
||||
@@ -3949,6 +3950,11 @@ DoneSection2:
|
||||
curlap = 0;
|
||||
}
|
||||
|
||||
// ONLY FOR HUD
|
||||
player->laptime[LAP_LAST] = player->laptime[LAP_CUR];
|
||||
player->laptime[LAP_CUR] = 0;
|
||||
//
|
||||
|
||||
player->starposttime = player->realtime;
|
||||
player->starpostnum = 0;
|
||||
|
||||
|
||||
@@ -2975,12 +2975,19 @@ static void P_DeathThink(player_t *player)
|
||||
else
|
||||
curlap++; // This is too complicated to sync to realtime, just sorta hope for the best :V
|
||||
}
|
||||
|
||||
if (player->spectator)
|
||||
player->laptime[LAP_CUR] = 0;
|
||||
else
|
||||
player->laptime[LAP_CUR]++; // This is too complicated to sync to realtime, just sorta hope for the best :V
|
||||
}
|
||||
else
|
||||
{
|
||||
player->realtime = 0;
|
||||
if (player == &players[consoleplayer])
|
||||
curlap = 0;
|
||||
|
||||
player->laptime[LAP_CUR] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4522,12 +4529,19 @@ void P_PlayerThink(player_t *player)
|
||||
else
|
||||
curlap++; // This is too complicated to sync to realtime, just sorta hope for the best :V
|
||||
}
|
||||
|
||||
if (player->spectator)
|
||||
player->laptime[LAP_CUR] = 0;
|
||||
else
|
||||
player->laptime[LAP_CUR]++; // This is too complicated to sync to realtime, just sorta hope for the best :V
|
||||
}
|
||||
else
|
||||
{
|
||||
player->realtime = 0;
|
||||
if (player == &players[consoleplayer])
|
||||
curlap = 0;
|
||||
|
||||
player->laptime[LAP_CUR] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user