mirror of
https://github.com/Cesarus85/ringfall-mjolnir-vr.git
synced 2026-10-17 14:00:25 +02:00
Count death and co-op respawn delays in game ticks
This commit is contained in:
1 parent
7e00135d31
commit
cd345aac7c
1 file changed
+55
-14
+55
-14
@@ -700,6 +700,9 @@ static char const *scenario_paths[10] =
|
||||
};
|
||||
|
||||
static struct _main_globals main_globals = { 0 };
|
||||
/* Keep the original globals layout; these clocks belong to pending requests. */
|
||||
static long main_loss_last_tick;
|
||||
static long main_respawn_last_tick;
|
||||
boolean debug_force_frame_rate_update = FALSE;
|
||||
boolean debug_no_drawing = FALSE;
|
||||
boolean debug_game_save = FALSE;
|
||||
@@ -903,6 +906,11 @@ void main_won_map(
|
||||
void main_lost_map(
|
||||
void)
|
||||
{
|
||||
if (!main_globals.lost_map)
|
||||
{
|
||||
main_globals.loss_timer = 0;
|
||||
main_loss_last_tick = game_time_get();
|
||||
}
|
||||
main_globals.saving_map = FALSE;
|
||||
main_globals.lost_map = TRUE;
|
||||
return;
|
||||
@@ -963,9 +971,14 @@ void main_save_map_nonsafe(
|
||||
void main_respawn(
|
||||
boolean in_multiplayer)
|
||||
{
|
||||
if (!main_globals.respawn)
|
||||
{
|
||||
main_globals.respawn_timer = 0;
|
||||
main_respawn_last_tick = game_time_get();
|
||||
}
|
||||
main_globals.respawn = TRUE;
|
||||
if (in_multiplayer)
|
||||
main_globals.respawn_timer = 91;
|
||||
main_globals.respawn_timer = 92;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1944,17 +1957,45 @@ static void main_switch_to_structure_bsp_private(
|
||||
return;
|
||||
}
|
||||
|
||||
/* The original post-increment test expires on its 92nd 30 Hz update.
|
||||
Render-only frames must not advance it. Saturate so blocked co-op
|
||||
respawns can retry indefinitely without overflowing the short counter. */
|
||||
static boolean main_death_timer_expired(
|
||||
short *timer,
|
||||
long *last_tick,
|
||||
boolean advance)
|
||||
{
|
||||
long current_tick = game_time_get();
|
||||
unsigned long elapsed_ticks = 0;
|
||||
|
||||
if (current_tick < *last_tick)
|
||||
{
|
||||
/* A checkpoint/core load can move the simulation clock backwards. */
|
||||
*timer = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
elapsed_ticks = (unsigned long)current_tick - (unsigned long)*last_tick;
|
||||
}
|
||||
*last_tick = current_tick;
|
||||
|
||||
if (!advance)
|
||||
return FALSE;
|
||||
|
||||
*timer = (short)MIN(92, (unsigned long)*timer + elapsed_ticks);
|
||||
return *timer >= 92;
|
||||
}
|
||||
|
||||
static void main_lost_map_private(
|
||||
void)
|
||||
{
|
||||
if (!game_time_get_paused())
|
||||
if (main_death_timer_expired(
|
||||
&main_globals.loss_timer, &main_loss_last_tick,
|
||||
!game_time_get_paused()))
|
||||
{
|
||||
if (main_globals.loss_timer++ > 90)
|
||||
{
|
||||
main_globals.lost_map = FALSE;
|
||||
main_globals.loss_timer = 0;
|
||||
game_state_revert();
|
||||
}
|
||||
main_globals.lost_map = FALSE;
|
||||
main_globals.loss_timer = 0;
|
||||
game_state_revert();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1962,13 +2003,13 @@ static void main_lost_map_private(
|
||||
static void main_respawn_private(
|
||||
void)
|
||||
{
|
||||
if (!game_time_get_paused() && !cinematic_in_progress())
|
||||
if (main_death_timer_expired(
|
||||
&main_globals.respawn_timer, &main_respawn_last_tick,
|
||||
!game_time_get_paused() && !cinematic_in_progress()) &&
|
||||
players_respawn_coop())
|
||||
{
|
||||
if (main_globals.respawn_timer++ > 90 && players_respawn_coop())
|
||||
{
|
||||
main_globals.respawn = FALSE;
|
||||
main_globals.respawn_timer = 0;
|
||||
}
|
||||
main_globals.respawn = FALSE;
|
||||
main_globals.respawn_timer = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user