mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-28 04:51:42 +00:00
Let level darkness be changed per splitscreen, use player_t variables
Modifies netsave. - Add darkness_start, darkness_end to player_t
This commit is contained in:
parent
8430489673
commit
df0d342e04
5 changed files with 52 additions and 23 deletions
|
|
@ -982,6 +982,9 @@ struct player_t
|
||||||
icecubevars_t icecube;
|
icecubevars_t icecube;
|
||||||
|
|
||||||
level_tally_t tally;
|
level_tally_t tally;
|
||||||
|
|
||||||
|
tic_t darkness_start;
|
||||||
|
tic_t darkness_end;
|
||||||
};
|
};
|
||||||
|
|
||||||
// WARNING FOR ANYONE ABOUT TO ADD SOMETHING TO THE PLAYER STRUCT, G_PlayerReborn WANTS YOU TO SUFFER
|
// WARNING FOR ANYONE ABOUT TO ADD SOMETHING TO THE PLAYER STRUCT, G_PlayerReborn WANTS YOU TO SUFFER
|
||||||
|
|
|
||||||
|
|
@ -807,7 +807,7 @@ extern exitcondition_t g_exit;
|
||||||
extern struct darkness_t
|
extern struct darkness_t
|
||||||
{
|
{
|
||||||
tic_t start, end;
|
tic_t start, end;
|
||||||
fixed_t value;
|
fixed_t value[MAXSPLITSCREENPLAYERS];
|
||||||
} g_darkness;
|
} g_darkness;
|
||||||
|
|
||||||
#define DEFAULT_GRAVITY (4*FRACUNIT/5)
|
#define DEFAULT_GRAVITY (4*FRACUNIT/5)
|
||||||
|
|
|
||||||
|
|
@ -787,6 +787,10 @@ static void P_NetArchivePlayers(savebuffer_t *save)
|
||||||
WRITEUINT8(save->p, players[i].icecube.wiggle);
|
WRITEUINT8(save->p, players[i].icecube.wiggle);
|
||||||
WRITEUINT32(save->p, players[i].icecube.frozenat);
|
WRITEUINT32(save->p, players[i].icecube.frozenat);
|
||||||
WRITEUINT8(save->p, players[i].icecube.shaketimer);
|
WRITEUINT8(save->p, players[i].icecube.shaketimer);
|
||||||
|
|
||||||
|
// darkness
|
||||||
|
WRITEUINT32(save->p, players[i].darkness_start);
|
||||||
|
WRITEUINT32(save->p, players[i].darkness_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
TracyCZoneEnd(__zone);
|
TracyCZoneEnd(__zone);
|
||||||
|
|
@ -1358,6 +1362,10 @@ static void P_NetUnArchivePlayers(savebuffer_t *save)
|
||||||
players[i].icecube.frozenat = READUINT32(save->p);
|
players[i].icecube.frozenat = READUINT32(save->p);
|
||||||
players[i].icecube.shaketimer = READUINT8(save->p);
|
players[i].icecube.shaketimer = READUINT8(save->p);
|
||||||
|
|
||||||
|
// darkness
|
||||||
|
players[i].darkness_start = READUINT32(save->p);
|
||||||
|
players[i].darkness_end = READUINT32(save->p);
|
||||||
|
|
||||||
//players[i].viewheight = P_GetPlayerViewHeight(players[i]); // scale cannot be factored in at this point
|
//players[i].viewheight = P_GetPlayerViewHeight(players[i]); // scale cannot be factored in at this point
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
59
src/p_tick.c
59
src/p_tick.c
|
|
@ -768,6 +768,43 @@ void P_RunChaseCameras(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static fixed_t P_GetDarkness(tic_t start, tic_t end)
|
||||||
|
{
|
||||||
|
if (leveltime <= end)
|
||||||
|
{
|
||||||
|
tic_t fade = end - DARKNESS_FADE_TIME;
|
||||||
|
tic_t t;
|
||||||
|
|
||||||
|
if (leveltime < fade) // dark or darkening
|
||||||
|
{
|
||||||
|
t = leveltime - start;
|
||||||
|
t = min(t, DARKNESS_FADE_TIME);
|
||||||
|
}
|
||||||
|
else // lightening
|
||||||
|
{
|
||||||
|
t = end - leveltime;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Easing_Linear((t * FRACUNIT) / DARKNESS_FADE_TIME, 0, FRACUNIT/7);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void P_TickDarkness(void)
|
||||||
|
{
|
||||||
|
const fixed_t globalValue = P_GetDarkness(g_darkness.start, g_darkness.end);
|
||||||
|
UINT8 i;
|
||||||
|
|
||||||
|
for (i = 0; i <= r_splitscreen; ++i)
|
||||||
|
{
|
||||||
|
const player_t *p = &players[displayplayers[i]];
|
||||||
|
fixed_t value = P_GetDarkness(p->darkness_start, p->darkness_end);
|
||||||
|
|
||||||
|
g_darkness.value[i] = value ? value : globalValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// P_Ticker
|
// P_Ticker
|
||||||
//
|
//
|
||||||
|
|
@ -1046,27 +1083,7 @@ void P_Ticker(boolean run)
|
||||||
if (racecountdown > 1)
|
if (racecountdown > 1)
|
||||||
racecountdown--;
|
racecountdown--;
|
||||||
|
|
||||||
if (leveltime <= g_darkness.end)
|
P_TickDarkness();
|
||||||
{
|
|
||||||
tic_t fade = g_darkness.end - DARKNESS_FADE_TIME;
|
|
||||||
tic_t t;
|
|
||||||
|
|
||||||
if (leveltime < fade) // dark or darkening
|
|
||||||
{
|
|
||||||
t = leveltime - g_darkness.start;
|
|
||||||
t = min(t, DARKNESS_FADE_TIME);
|
|
||||||
}
|
|
||||||
else // lightening
|
|
||||||
{
|
|
||||||
t = g_darkness.end - leveltime;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_darkness.value = Easing_Linear((t * FRACUNIT) / DARKNESS_FADE_TIME, 0, FRACUNIT/7);
|
|
||||||
}
|
|
||||||
else // light
|
|
||||||
{
|
|
||||||
g_darkness.value = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exitcountdown >= 1)
|
if (exitcountdown >= 1)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#include "i_time.h"
|
#include "i_time.h"
|
||||||
#include "m_fixed.h"
|
#include "m_fixed.h"
|
||||||
#include "r_draw.h"
|
#include "r_draw.h"
|
||||||
|
#include "r_fps.h"
|
||||||
#include "r_main.h"
|
#include "r_main.h"
|
||||||
#include "g_game.h"
|
#include "g_game.h"
|
||||||
|
|
||||||
|
|
@ -43,7 +44,7 @@ INT32 R_AdjustLightLevel(INT32 light)
|
||||||
|
|
||||||
if (!debugrender_highlight && cv_debugrender_contrast.value == 0)
|
if (!debugrender_highlight && cv_debugrender_contrast.value == 0)
|
||||||
{
|
{
|
||||||
const fixed_t darken = FixedMul(FixedMul(g_darkness.value, mapheaderinfo[gamemap-1]->darkness), kRange);
|
const fixed_t darken = FixedMul(FixedMul(g_darkness.value[R_GetViewNumber()], mapheaderinfo[gamemap-1]->darkness), kRange);
|
||||||
return std::clamp((light * FRACUNIT) - darken, 0, kRange) / FRACUNIT;
|
return std::clamp((light * FRACUNIT) - darken, 0, kRange) / FRACUNIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue