From 4a3c3a29b7cee1b1f78dd67ec25c28c292b8ac8f Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sun, 26 Nov 2023 21:15:47 +0100 Subject: [PATCH] port: measure nbomb age based on timestamps makes them last the same amount of time regardless of fps --- src/game/nbomb.c | 10 +++++++++- src/include/types.h | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/game/nbomb.c b/src/game/nbomb.c index 28bbb643a..b5f4fa72b 100644 --- a/src/game/nbomb.c +++ b/src/game/nbomb.c @@ -281,6 +281,9 @@ void nbombReset(struct nbomb *nbomb) #if VERSION >= VERSION_PAL_BETA nbomb->radius = 0; #endif +#ifndef PLATFORM_N64 + nbomb->spawnframe240 = g_Vars.lvframe240; +#endif } /** @@ -523,9 +526,14 @@ void nbombTick(struct nbomb *nbomb) { if (nbomb->age240 >= 0) { s32 age60; +#ifdef PLATFORM_N64 s32 increment = (g_Vars.lvupdate240 + 2) >> 2; - nbomb->age240 += increment; +#else + s32 oldage240 = nbomb->age240; + nbomb->age240 = (g_Vars.lvframe240 - nbomb->spawnframe240) >> 2; + s32 increment = nbomb->age240 - oldage240; +#endif if (nbomb->age240 < TICKS(80)) { nbomb->radius = nbomb->age240 / (PAL ? 66.0f : 80.0f); diff --git a/src/include/types.h b/src/include/types.h index 159558c67..67a8eddaf 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -5510,6 +5510,9 @@ struct nbomb { struct prop *ownerprop; struct sndstate *audiohandle20; struct sndstate *audiohandle24; +#ifndef PLATFORM_N64 + s32 spawnframe240; // spawned on this frame +#endif }; struct roomacousticdata {