From f8b9c8290eab14ebb5a627b280f2aeac1bc1c232 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 2 May 2025 10:53:36 +0200 Subject: [PATCH 01/10] let squishy speed be player choosable idk why i just didnt do that lel also adds stuff to the menus --- src/g_game.h | 2 +- src/k_kart.c | 4 ++++ src/m_menu.c | 31 +++++++++++++++++++------------ src/p_user.c | 3 ++- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/g_game.h b/src/g_game.h index 8027d86f2..bde892309 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -187,7 +187,7 @@ extern consvar_t cv_sloperolldist; extern consvar_t cv_sparkroll; extern consvar_t cv_spinoutroll; -extern consvar_t cv_squishdance; +extern consvar_t cv_squishdance, cv_squishdancespeed; extern consvar_t cv_playerblendeffects; diff --git a/src/k_kart.c b/src/k_kart.c index 0a15189a1..9178aaf58 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -156,6 +156,9 @@ consvar_t cv_saltyroll = {"hardcodehoproll", "Off", CV_SAVE, CV_OnOff, NULL, 0, consvar_t cv_squishdance = {"squishdance", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t squishdancespeed_cons_t[] = {{20, "MIN"}, {280, "MAX"}, {0, NULL}}; +consvar_t cv_squishdancespeed = {"squishdance_speed", "140", CV_SAVE, squishdancespeed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + static void saltyhop_onchange(void) { // reset everything when toggling saltyhop @@ -1031,6 +1034,7 @@ void K_RegisterClientKartStuff(void) CV_RegisterVar(&cv_slamsound); CV_RegisterVar(&cv_squishdance); + CV_RegisterVar(&cv_squishdancespeed); CV_RegisterVar(&cv_lessflicker); diff --git a/src/m_menu.c b/src/m_menu.c index 63ad0c1e2..17bbdd65d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2370,21 +2370,24 @@ static menuitem_t OP_PlayerDistortMenu[] = { {IT_HEADER, NULL, "Sprite Distortion", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Sprite Slope Rotation", &cv_sloperoll, 10}, - {IT_STRING | IT_CVAR, NULL, "Slope Rotation Distance", &cv_sloperolldist, 15}, + {IT_STRING | IT_CVAR, NULL, "Sprite Slope Rotation", &cv_sloperoll, 10}, + {IT_STRING | IT_CVAR, NULL, "Slope Rotation Distance", &cv_sloperolldist, 15}, - {IT_STRING | IT_CVAR, NULL, "Rotate Players when Sliptiding", &cv_sliptideroll, 25}, - {IT_STRING | IT_CVAR, NULL, "Rotate Sparks and Boost Trails", &cv_sparkroll, 30}, - {IT_STRING | IT_CVAR, NULL, "Rotate Bananas on Throw", &cv_bananthrowroll, 35}, + {IT_STRING | IT_CVAR, NULL, "Rotate Players when Sliptiding", &cv_sliptideroll, 25}, + {IT_STRING | IT_CVAR, NULL, "Rotate Sparks and Boost Trails", &cv_sparkroll, 30}, + {IT_STRING | IT_CVAR, NULL, "Rotate Bananas on Throw", &cv_bananthrowroll, 35}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Player Stretch Factor", &cv_gravstretch, 45}, - {IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 50}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Player Stretch Factor", &cv_gravstretch, 45}, + {IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 50}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 60}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saltyhop Height", &cv_saltyheight, 65}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 70}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 75}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Roll", &cv_saltyroll, 80}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 60}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saltyhop Height", &cv_saltyheight, 65}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 70}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 75}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Roll", &cv_saltyroll, 80}, + + {IT_STRING | IT_CVAR, NULL, "Squishdance", &cv_squishdance, 90}, + {IT_STRING | IT_CVAR, NULL, "Squishdance Speed", &cv_squishdancespeed, 96}, }; static const char* OP_PlayerDistortTooltips[] = @@ -2402,6 +2405,8 @@ static const char* OP_PlayerDistortTooltips[] = "Player hop sound effect.", "Player hop squash and stretch.", "Should the player rotation be kept during player hop.", + "Do a funny squishy dance when holding CUSTOM 3.", + "Speed of the Squishy dance in BPM.", }; enum @@ -2419,6 +2424,8 @@ enum saltsound, saltsquishy, saltroll, + squishdance, + squishdancespd, }; static menuitem_t OP_SaturnHudMenu[] = diff --git a/src/p_user.c b/src/p_user.c index d9f398949..e6680657f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4444,7 +4444,7 @@ DoABarrelRoll (player_t *player) // TODO: make this sane lmao static void P_DoFunnyDance(player_t *player) { - static const fixed_t bpm = 983040; // 140bpm ish + fixed_t bpm; // 140bpm ish if (player->spectator || !player->mo || player->kartstuff[k_respawn] || player->mo->salty_jump) // this looks jank as hell during hop return; @@ -4452,6 +4452,7 @@ static void P_DoFunnyDance(player_t *player) player->squishdance.bounce = 0; // bpm = FixedDiv((60*TICRATE)<squishdance.work = (player->squishdance.time << FRACBITS) % bpm; From e025404bbfdf239944229c92bf9f4a643df891f3 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 2 May 2025 11:12:04 +0200 Subject: [PATCH 02/10] forgor casting this --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index e6680657f..569f93b63 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4452,7 +4452,7 @@ static void P_DoFunnyDance(player_t *player) player->squishdance.bounce = 0; // bpm = FixedDiv((60*TICRATE)<squishdance.work = (player->squishdance.time << FRACBITS) % bpm; From 7abee5ae1175b3d1c0d186ce289dc213047f3058 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 May 2025 17:21:04 +0200 Subject: [PATCH 03/10] add USELTO and USEASAN make flags to compile with LTO or Address sanitizer --- src/Makefile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Makefile b/src/Makefile index 0bd0c565b..0abc7c318 100644 --- a/src/Makefile +++ b/src/Makefile @@ -451,7 +451,24 @@ else # build a normal optimised version WINDRESFLAGS = -DNDEBUG CFLAGS+=-O3 + CPPFLAGS+=-O3 endif + +ifndef DEBUGMODE +ifdef USELTO + # compile with LTO + CFLAGS+=-flto=auto + CPPFLAGS+=-flto=auto +endif +endif + +ifdef USEASAN + # compile with asan + CFLAGS+=-fsanitize=address + CPPFLAGS+=-fsanitize=address + LDFLAGS+=-fsanitize=address +endif + CFLAGS+=-g $(OPTS) $(ARCHOPTS) $(WINDRESFLAGS) ifdef PROFILEMODE From d2d0e0c97967156813623835fd6ebfa4123673b9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 May 2025 20:45:40 +0200 Subject: [PATCH 04/10] smol cleanup m_perfstats --- src/m_perfstats.c | 223 +++++++++++++++++++++++++++------------------- src/m_perfstats.h | 1 - 2 files changed, 130 insertions(+), 94 deletions(-) diff --git a/src/m_perfstats.c b/src/m_perfstats.c index e54d1df06..6b6a7f7db 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -214,6 +214,7 @@ void PS_SetPreThinkFrameHookInfo(int index, precise_t time_taken, char* short_sr // array needs to be initialized prethinkframe_hooks = Z_Calloc(sizeof(ps_hookinfo_t) * prethinkframe_hooks_capacity, PU_STATIC, NULL); } + if (index >= prethinkframe_hooks_capacity) { // array needs more space, realloc with double size @@ -225,6 +226,7 @@ void PS_SetPreThinkFrameHookInfo(int index, precise_t time_taken, char* short_sr sizeof(ps_hookinfo_t) * prethinkframe_hooks_capacity); prethinkframe_hooks_capacity = new_capacity; } + prethinkframe_hooks[index].time_taken.value.p = time_taken; memcpy(prethinkframe_hooks[index].short_src, short_src, LUA_IDSIZE * sizeof(char)); // since the values are set sequentially from begin to end, the last call should leave @@ -239,6 +241,7 @@ void PS_SetThinkFrameHookInfo(int index, precise_t time_taken, char* short_src) // array needs to be initialized thinkframe_hooks = Z_Calloc(sizeof(ps_hookinfo_t) * thinkframe_hooks_capacity, PU_STATIC, NULL); } + if (index >= thinkframe_hooks_capacity) { // array needs more space, realloc with double size @@ -250,6 +253,7 @@ void PS_SetThinkFrameHookInfo(int index, precise_t time_taken, char* short_src) sizeof(ps_hookinfo_t) * thinkframe_hooks_capacity); thinkframe_hooks_capacity = new_capacity; } + thinkframe_hooks[index].time_taken.value.p = time_taken; memcpy(thinkframe_hooks[index].short_src, short_src, LUA_IDSIZE * sizeof(char)); // since the values are set sequentially from begin to end, the last call should leave @@ -264,6 +268,7 @@ void PS_SetPostThinkFrameHookInfo(int index, precise_t time_taken, char* short_s // array needs to be initialized postthinkframe_hooks = Z_Calloc(sizeof(ps_hookinfo_t) * postthinkframe_hooks_capacity, PU_STATIC, NULL); } + if (index >= postthinkframe_hooks_capacity) { // array needs more space, realloc with double size @@ -275,6 +280,7 @@ void PS_SetPostThinkFrameHookInfo(int index, precise_t time_taken, char* short_s sizeof(ps_hookinfo_t) * postthinkframe_hooks_capacity); postthinkframe_hooks_capacity = new_capacity; } + postthinkframe_hooks[index].time_taken.value.p = time_taken; memcpy(postthinkframe_hooks[index].short_src, short_src, LUA_IDSIZE * sizeof(char)); // since the values are set sequentially from begin to end, the last call should leave @@ -282,8 +288,6 @@ void PS_SetPostThinkFrameHookInfo(int index, precise_t time_taken, char* short_s postthinkframe_hooks_length = index + 1; } - - static boolean PS_HighResolution(void) { return (vid.width >= 640 && vid.height >= 400); @@ -349,6 +353,7 @@ static INT32 PS_GetMetricMinOrMax(ps_metric_t *metric, boolean time_metric, bool for (i = 0; i < cv_ps_samplesize.value; i++) { INT32 value; + if (time_metric) value = (*((precise_t*)history_read_pos)) / (I_GetPrecisePrecision() / 1000000); else @@ -359,6 +364,7 @@ static INT32 PS_GetMetricMinOrMax(ps_metric_t *metric, boolean time_metric, bool { found_value = value; } + history_read_pos += value_size; } @@ -377,6 +383,7 @@ static INT32 PS_GetMetricSD(ps_metric_t *metric, boolean time_metric) for (i = 0; i < cv_ps_samplesize.value; i++) { INT64 value; + if (time_metric) value = (*((precise_t*)history_read_pos)) / (I_GetPrecisePrecision() / 1000000); else @@ -396,14 +403,17 @@ static INT32 PS_GetMetricScreenValue(ps_metric_t *metric, boolean time_metric) { if (cv_ps_samplesize.value > 1 && metric->history) { - if (cv_ps_descriptor.value == 1) - return PS_GetMetricAverage(metric, time_metric); - else if (cv_ps_descriptor.value == 2) - return PS_GetMetricSD(metric, time_metric); - else if (cv_ps_descriptor.value == 3) - return PS_GetMetricMinOrMax(metric, time_metric, false); - else - return PS_GetMetricMinOrMax(metric, time_metric, true); + switch (cv_ps_descriptor.value) + { + case 1: + return PS_GetMetricAverage(metric, time_metric); + case 2: + return PS_GetMetricSD(metric, time_metric); + case 3: + return PS_GetMetricMinOrMax(metric, time_metric, false); + default: + return PS_GetMetricMinOrMax(metric, time_metric, true); + } } else { @@ -575,6 +585,7 @@ static void PS_CountThinkers(void) ps_precipcount.value.i = 0; ps_otherthcount.value.i = 0; ps_removecount.value.i = 0; + for (thinker = thinkercap.next; thinker != &thinkercap; thinker = thinker->next) { ps_thinkercount.value.i++; @@ -644,6 +655,7 @@ void PS_UpdateTickStats(void) { PS_UpdateRowHistories(gamelogicbrief_row, false); } + if (cv_perfstats.value == 2) { if (PS_IsLevelActive()) @@ -656,8 +668,6 @@ void PS_UpdateTickStats(void) ps_lua_thinkframe_time.value.p - ps_lua_postthinkframe_time.value.p; - - PS_CountThinkers(); } @@ -668,37 +678,47 @@ void PS_UpdateTickStats(void) PS_UpdateRowHistories(misc_calls_rows, false); } } + if (cv_ps_samplesize.value > 1) { - if(cv_perfstats.value >= 3 && PS_IsLevelActive()) + if (cv_perfstats.value >= 3 && PS_IsLevelActive()) { - int i; - if (cv_perfstats.value == 3) + int i; + + switch (cv_perfstats.value) { - for (i = 0; i < thinkframe_hooks_length; i++) - PS_UpdateMetricHistory(&thinkframe_hooks[i].time_taken, true, false); - } - else if (cv_perfstats.value == 4) - { - for (i = 0; i < prethinkframe_hooks_length; i++) - PS_UpdateMetricHistory(&prethinkframe_hooks[i].time_taken, true, false); - } - else if (cv_perfstats.value == 5) - { - for (i = 0; i < postthinkframe_hooks_length; i++) - PS_UpdateMetricHistory(&postthinkframe_hooks[i].time_taken, true, false); + case 3: + for (i = 0; i < thinkframe_hooks_length; i++) + { + PS_UpdateMetricHistory(&thinkframe_hooks[i].time_taken, true, false); + } + break; + case 4: + for (i = 0; i < prethinkframe_hooks_length; i++) + { + PS_UpdateMetricHistory(&prethinkframe_hooks[i].time_taken, true, false); + } + break; + case 5: + for (i = 0; i < postthinkframe_hooks_length; i++) + { + PS_UpdateMetricHistory(&postthinkframe_hooks[i].time_taken, true, false); + } + break; + default: + break; } } if (cv_perfstats.value) { ps_tick_index++; + if (ps_tick_index >= cv_ps_samplesize.value) ps_tick_index = 0; + if (ps_tick_samples_left) ps_tick_samples_left--; - } - } } @@ -712,6 +732,7 @@ static void PS_DrawDescriptorHeader(void) "minimum", "maximum" }; + const boolean hires = PS_HighResolution(); char* str; INT32 flags = V_MONOSPACE | V_ALLOWLOWERCASE; @@ -819,12 +840,12 @@ static void PS_DrawGameLogicStats(void) static void draw_think_frame_stats(int hook_length, ps_hookinfo_t *hook) { - char s[100]; + char s[100]; int i; int maxpage = 0; - int page = 0; - int pagestart = 0; - int pageend = 0; + int page = 0; + int pagestart = 0; + int pageend = 0; // text writing position int x = START_X; int y = START_Y; @@ -832,57 +853,69 @@ static void draw_think_frame_stats(int hook_length, ps_hookinfo_t *hook) char tempbuffer[LUA_IDSIZE]; char last_mod_name[LUA_IDSIZE]; last_mod_name[0] = '\0'; - INT32 total = 0; + INT32 total = 0; //Decide page length based and drawn text on choosen thinker type - if (cv_perfstats.value == 3){ - maxpage = thinkframe_hooks_length/PAGE_ENTRIES + 1; - page = max(1, min(cv_ps_thinkframe_page.value, maxpage)); - pagestart = min((page - 1)*PAGE_ENTRIES, thinkframe_hooks_length); - pageend = min(pagestart + PAGE_ENTRIES, thinkframe_hooks_length); - - V_DrawSmallString(MAX_X-50, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, "ThinkFrame"); - } - else if (cv_perfstats.value == 4){ - maxpage = prethinkframe_hooks_length/PAGE_ENTRIES + 1; - page = max(1, min(cv_ps_thinkframe_page.value, maxpage)); - pagestart = min((page - 1)*PAGE_ENTRIES, prethinkframe_hooks_length); - pageend = min(pagestart + PAGE_ENTRIES, prethinkframe_hooks_length); - V_DrawSmallString(MAX_X-60, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, "PreThinkFrame"); - } - else if (cv_perfstats.value == 5){ - maxpage = postthinkframe_hooks_length/PAGE_ENTRIES + 1; - page = max(1, min(cv_ps_thinkframe_page.value, maxpage)); - pagestart = min((page - 1)*PAGE_ENTRIES, postthinkframe_hooks_length); - pageend = min(pagestart + PAGE_ENTRIES, postthinkframe_hooks_length); - V_DrawSmallString(MAX_X-65, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, "PostThinkFrame"); + switch (cv_perfstats.value) + { + case 3: + { + maxpage = thinkframe_hooks_length/PAGE_ENTRIES + 1; + page = max(1, min(cv_ps_thinkframe_page.value, maxpage)); + pagestart = min((page - 1)*PAGE_ENTRIES, thinkframe_hooks_length); + pageend = min(pagestart + PAGE_ENTRIES, thinkframe_hooks_length); + V_DrawSmallString(MAX_X-50, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, "ThinkFrame"); + } + break; + case 4: + { + maxpage = prethinkframe_hooks_length/PAGE_ENTRIES + 1; + page = max(1, min(cv_ps_thinkframe_page.value, maxpage)); + pagestart = min((page - 1)*PAGE_ENTRIES, prethinkframe_hooks_length); + pageend = min(pagestart + PAGE_ENTRIES, prethinkframe_hooks_length); + V_DrawSmallString(MAX_X-60, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, "PreThinkFrame"); + } + break; + case 5: + { + maxpage = postthinkframe_hooks_length/PAGE_ENTRIES + 1; + page = max(1, min(cv_ps_thinkframe_page.value, maxpage)); + pagestart = min((page - 1)*PAGE_ENTRIES, postthinkframe_hooks_length); + pageend = min(pagestart + PAGE_ENTRIES, postthinkframe_hooks_length); + V_DrawSmallString(MAX_X-65, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, "PostThinkFrame"); + } + break; + default: + break; } - + PS_DrawDescriptorHeader(); for (i = 0; i < hook_length; i++) { - #define NEXT_ROW() y += HEIGHT; - INT32 value = PS_GetMetricScreenValue(&hook[i].time_taken, true); - total += value; + INT32 value = PS_GetMetricScreenValue(&hook[i].time_taken, true); + total += value; - if (i < pagestart || i >= pageend) continue; + if (i < pagestart || i >= pageend) continue; char* str = hook[i].short_src; char* tempstr = tempbuffer; int len = (int)strlen(str); char* str_ptr; + if (strcmp(".lua", str + len - 4) == 0) { str[len-4] = '\0'; // remove .lua at end len -= 4; } + // Print wad name first. strcpy(tempstr, str); str_ptr = strrchr(tempstr, '|'); + if (str_ptr) { *str_ptr = '\0'; @@ -891,12 +924,12 @@ static void draw_think_frame_stats(int hook_length, ps_hookinfo_t *hook) if (str_ptr) tempstr = str_ptr + 1; // tempstr should now point to the mod name, (wad/pk3) possibly truncated - strcpy(last_mod_name, tempstr); - len = (int)strlen(tempstr); - if (len > 30) - tempstr += len - 30; - snprintf(s, sizeof s - 1, "%s", tempstr); - V_DrawSmallString(x, y, V_MONOSPACE | V_ALLOWLOWERCASE | V_GRAYMAP, s); + strcpy(last_mod_name, tempstr); + len = (int)strlen(tempstr); + if (len > 30) + tempstr += len - 30; + snprintf(s, sizeof s - 1, "%s", tempstr); + V_DrawSmallString(x, y, V_MONOSPACE | V_ALLOWLOWERCASE | V_GRAYMAP, s); text_color = V_YELLOWMAP; } else @@ -908,35 +941,35 @@ static void draw_think_frame_stats(int hook_length, ps_hookinfo_t *hook) str = str_ptr + 1; text_color = 0; // white } + len = (int)strlen(str); + if (len > 40) str += len - 40; + snprintf(s, sizeof s - 1, "%40s: %d", str, value); V_DrawSmallString(x + WIDTH, y, V_MONOSPACE | V_ALLOWLOWERCASE | text_color, s); NEXT_ROW() #undef NEXT_ROW - } - snprintf(s, sizeof s - 1, "TOTAL %d", total); - V_DrawSmallString(MAX_X, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, s); + snprintf(s, sizeof s - 1, "TOTAL %d", total); + V_DrawSmallString(MAX_X, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, s); - if (maxpage > 1) { - snprintf(s, sizeof s - 1, "PAGE %d", page); - V_DrawSmallString(START_X, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, s); - } - - + if (maxpage > 1) + { + snprintf(s, sizeof s - 1, "PAGE %d", page); + V_DrawSmallString(START_X, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, s); + } } void PS_ThinkFrame_Page_OnChange(void) { - int maxpage = thinkframe_hooks_length/PAGE_ENTRIES + 1; + int maxpage = thinkframe_hooks_length/PAGE_ENTRIES + 1; - if (cv_ps_thinkframe_page.value > maxpage) { - CV_StealthSetValue(&cv_ps_thinkframe_page, maxpage); - } + if (cv_ps_thinkframe_page.value > maxpage) + CV_StealthSetValue(&cv_ps_thinkframe_page, maxpage); } #undef WIDTH @@ -948,8 +981,6 @@ void PS_ThinkFrame_Page_OnChange(void) #undef PAGE_ENTRIES - - static void PS_DrawPreThinkFrameStats(void) { draw_think_frame_stats(prethinkframe_hooks_length, prethinkframe_hooks); @@ -983,6 +1014,7 @@ void M_DrawPerfStats(void) { if (!PS_IsLevelActive()) return; + if (!PS_HighResolution()) { // Low resolutions can't really use V_DrawSmallString that is used by thinkframe stats. @@ -992,19 +1024,21 @@ void M_DrawPerfStats(void) V_DrawThinString(80, 100, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, "for resolutions below 640x400."); return; } - if (cv_perfstats.value == 3) - { - PS_DrawThinkFrameStats(); - } - else if (cv_perfstats.value == 4) - { - PS_DrawPreThinkFrameStats(); - } - else if (cv_perfstats.value == 5) - { - PS_DrawPostThinkFrameStats(); - } + switch (cv_perfstats.value) + { + case 3: + PS_DrawThinkFrameStats(); + break; + case 4: + PS_DrawPreThinkFrameStats(); + break; + case 5: + PS_DrawPostThinkFrameStats(); + break; + default: + break; + } } } @@ -1014,15 +1048,18 @@ static void PS_ClearHistory(void) int i; Z_FreeTags(PU_PERFSTATS, PU_PERFSTATS); + // thinkframe hook metric history pointers need to be cleared manually for (i = 0; i < prethinkframe_hooks_length; i++) { prethinkframe_hooks[i].time_taken.history = NULL; } + for (i = 0; i < thinkframe_hooks_length; i++) { thinkframe_hooks[i].time_taken.history = NULL; } + for (i = 0; i < postthinkframe_hooks_length; i++) { postthinkframe_hooks[i].time_taken.history = NULL; diff --git a/src/m_perfstats.h b/src/m_perfstats.h index ade7efd33..083656d61 100644 --- a/src/m_perfstats.h +++ b/src/m_perfstats.h @@ -55,7 +55,6 @@ void PS_SetPreThinkFrameHookInfo(int index, precise_t time_taken, char* short_sr void PS_SetThinkFrameHookInfo(int index, precise_t time_taken, char* short_src); void PS_SetPostThinkFrameHookInfo(int index, precise_t time_taken, char* short_src); - void PS_UpdateTickStats(void); void M_DrawPerfStats(void); From 880db98961ca079bbc38efc8915abbd2d585490b Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 May 2025 23:10:34 +0200 Subject: [PATCH 05/10] dont mindelay when record attacking theres a few places that do not "lag compensate" at all in RA so this would completely mess things up --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7047c7a69..83e68a944 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -232,7 +232,7 @@ consvar_t cv_kicktime = {"kicktime", "10", CV_SAVE, CV_Unsigned, NULL, 0, NULL, static boolean UseLocalDelay(void) { - if (dedicated || (server && server_lagless && !cv_mindelay.value)) + if (dedicated || (server && server_lagless && !cv_mindelay.value) || modeattacking == ATTACKING_RECORD) return false; return (cv_mindelay.value || (server && !server_lagless)); From ce99a3f5a6e99f08eb84ad4afd458fbd3d4c55db Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 May 2025 23:16:16 +0200 Subject: [PATCH 06/10] print previously supressed warnings into log instead of console --- src/g_game.c | 18 +++++++++++++++--- src/lua_baselib.c | 2 ++ src/lua_script.h | 9 +++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 0712a49e5..d1a5a440c 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1573,7 +1573,8 @@ boolean G_CouldView(INT32 playernum) // SRB2Kart: Only go through players who are actually playing if (player->exiting) return false; - if (( player->pflags & PF_TIMEOVER )) + + if (player->pflags & PF_TIMEOVER) return false; // I don't know if we want this actually, but I'll humor the suggestion anyway @@ -1609,6 +1610,7 @@ boolean G_CanView(INT32 playernum, UINT8 viewnum, boolean onlyactive) if ((*displayplayerp) == playernum) return false; } + for (viewd = viewnum + 1; viewd <= splits; ++viewd) { displayplayerp = (&displayplayers[viewd-1]); @@ -1628,16 +1630,19 @@ INT32 G_FindView(INT32 startview, UINT8 viewnum, boolean onlyactive, boolean rev { INT32 i, dir = reverse ? -1 : 1; startview = min(max(startview, 0), MAXPLAYERS); + for (i = startview; i < MAXPLAYERS && i >= 0; i += dir) { if (G_CanView(i, viewnum, onlyactive)) return i; } + for (i = (reverse ? MAXPLAYERS-1 : 0); i != startview; i += dir) { if (G_CanView(i, viewnum, onlyactive)) return i; } + return -1; } @@ -1703,6 +1708,7 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) if (viewnum > playersviewable) viewnum = playersviewable; + splitscreen = viewnum-1; R_ExecuteSetViewSize(); @@ -1807,6 +1813,7 @@ void G_Ticker(boolean run) // also the -1 is to ensure that the thinker runs in the loop below. P_MapStart(); + // do player reborns if needed if (gamestate == GS_LEVEL) { @@ -1821,10 +1828,12 @@ void G_Ticker(boolean run) if (playeringame[i] && players[i].playerstate == PST_REBORN) G_DoReborn(i); } + P_MapEnd(); // do things to change the game state while (gameaction != ga_nothing) + { switch (gameaction) { case ga_completed: G_DoCompleted(); break; @@ -1835,6 +1844,7 @@ void G_Ticker(boolean run) case ga_nothing: break; default: I_Error("gameaction = %d\n", gameaction); } + } buf = gametic % TICQUEUE; @@ -3163,6 +3173,7 @@ static void G_DoCompleted(void) while (!mapheaderinfo[cm] || !(mapheaderinfo[cm]->typeoflevel & tolflag)) { visitedmap[cm/8] |= (1<<(cm&7)); + if (!mapheaderinfo[cm]) cm = -1; // guarantee error execution else @@ -3172,10 +3183,11 @@ static void G_DoCompleted(void) { cm = nextmap; //Start the loop again so that the error checking below is executed. - //Make sure the map actually exists before you try to go to it! + // Make sure the map actually exists before you try to go to it! if ((W_CheckNumForName(G_BuildMapName(cm + 1)) == LUMPERROR)) { //CONS_Alert(CONS_ERROR, M_GetText("Next map given (MAP %d) doesn't exist! Reverting to MAP01.\n"), cm+1); + CON_LogMessage(va(M_GetText("Next map given (MAP %d) doesn't exist! Reverting to MAP01.\n"), cm+1)); cm = 0; break; } @@ -3187,6 +3199,7 @@ static void G_DoCompleted(void) // without finding one supporting the current gametype. // Thus, print a warning, and just use this map anyways. //CONS_Alert(CONS_WARNING, M_GetText("Can't find a compatible map after map %d; using map %d anyway\n"), prevmap+1, cm+1); + CON_LogMessage(va(M_GetText("Can't find a compatible map after map %d; using map %d anyway\n"), prevmap+1, cm+1)); break; } } @@ -3236,7 +3249,6 @@ static void G_DoCompleted(void) nextmap = G_RandMap(G_TOLFlag(gametype), prevmap, false, 0, false, NULL); } - // We are committed to this map now. // We may as well allocate its header if it doesn't exist // (That is, if it's a real map) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 43ca81325..10da0d1a3 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -240,6 +240,7 @@ static int lib_pAproxDistance(lua_State *L) fixed_t dy = luaL_checkfixed(L, 2); //HUDSAFE //LUA_Deprecated(L, "P_AproxDistance", "FixedHypot"); + LUA_LogDeprecated(L, "P_AproxDistance", "FixedHypot"); lua_pushfixed(L, FixedHypot(dx, dy)); return 1; } @@ -1040,6 +1041,7 @@ static int lib_pTeleportMove(lua_State *L) if (!thing) return LUA_ErrInvalid(L, "mobj_t"); //LUA_Deprecated(L, "P_TeleportMove", "P_SetOrigin\" or \"P_MoveOrigin"); + LUA_LogDeprecated(L, "P_TeleportMove", "P_SetOrigin\" or \"P_MoveOrigin"); lua_pushboolean(L, P_MoveOrigin(thing, x, y, z)); LUA_PushUserdata(L, tmthing, META_MOBJ); P_SetTarget(&tmthing, ptmthing); diff --git a/src/lua_script.h b/src/lua_script.h index 47dfd245b..14f5f08ef 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -81,6 +81,15 @@ void COM_Lua_f(void); }\ } +#define LUA_LogDeprecated(L,this_func,use_instead)\ +{\ + static UINT8 seen = 0;\ + if (!seen) {\ + seen = 1;\ + CON_LogMessage(va("\"%s\" is deprecated and will be removed.\nUse \"%s\" instead.\n", this_func, use_instead));\ + }\ +} + // Warnings about incorrect function usage. // Shows once, then never again, like deprecation #define LUA_UsageWarning(L, warningmsg)\ From 46f3529165def8469c4975deef94f680942ece12 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 4 May 2025 00:48:01 +0200 Subject: [PATCH 07/10] simplify this slightly --- src/p_user.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 569f93b63..af1e5c2fc 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1247,38 +1247,24 @@ void P_DoPlayerExit(player_t *player) player->exiting = raceexittime+2; K_KartUpdatePosition(player); - if (!P_MobjWasRemoved(player->mo) && cv_kartvoices.value) + if (cv_kartvoices.value && !P_MobjWasRemoved(player->mo)) { + const int soundid = K_IsPlayerLosing(player) ? sfx_klose: sfx_kwin; // fix godjjsa win sounds + if (P_IsLocalPlayer(player)) { - sfxenum_t sfx_id; - // fix godjjsa win sounds - if (K_IsPlayerLosing(player)) - { - sfx_id = K_GetMobjSkin(player->mo)->soundsid[S_sfx[sfx_klose].skinsound]; - } - else - { - sfx_id = K_GetMobjSkin(player->mo)->soundsid[S_sfx[sfx_kwin].skinsound]; - } + sfxenum_t sfx_id = K_GetMobjSkin(player->mo)->soundsid[S_sfx[soundid].skinsound]; S_StartSound(NULL, sfx_id); } else { - if (K_IsPlayerLosing(player)) - S_StartSound(player->mo, sfx_klose); - else - S_StartSound(player->mo, sfx_kwin); + S_StartSound(player->mo, soundid); } } if (cv_inttime.value > 0) P_EndingMusic(player); - // SRB2kart 120217 - //if (!exitcountdown) - //exitcountdown = racecountdown + 8*TICRATE; - if (P_CheckRacers()) player->exiting = raceexittime+1; } From b71c1152c62bfbd827e9898df56e29f184cceb04 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 4 May 2025 01:36:01 +0200 Subject: [PATCH 08/10] skinlocal deez nuts --- src/k_kart.c | 5 ++--- src/p_enemy.c | 24 ++++++++---------------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 9178aaf58..96b3cb7b2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -10655,7 +10655,6 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) const skin_t *skin; player_t *player = mo->player; - const boolean skinlocal = mo->skinlocal; fixed_t amnumxpos, amnumypos; INT32 amxpos, amypos, wntdamxpos, wntdamypos; @@ -10668,7 +10667,7 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) #endif skin = K_GetMobjSkin(mo); - minimaphead = (skinlocal ? localfacemmapprefix : facemmapprefix)[K_GetMobjSkinNum(skin, skinlocal)]; + minimaphead = R_GetSkinFaceMini(player); amnumxpos = (FixedMul(lerp(mo->old_x, mo->x), minimapinfo.zoom) - minimapinfo.offs_x); amnumypos = -(FixedMul(lerp(mo->old_y, mo->y), minimapinfo.zoom) - minimapinfo.offs_y); @@ -10718,7 +10717,7 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) if (mo->colorized) colormap = R_GetTranslationColormap(TC_RAINBOW, mo->color, GTC_CACHE); else - colormap = R_GetLocalTranslationColormap(mo->skin, mo->localskin, mo->color, GTC_CACHE, skinlocal); + colormap = R_GetLocalTranslationColormap(mo->skin, mo->localskin, mo->color, GTC_CACHE, mo->skinlocal); V_DrawFixedPatch(amxpos, amypos, scale, flags, minimaphead, colormap); diff --git a/src/p_enemy.c b/src/p_enemy.c index ba263ccce..195df59b0 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3996,10 +3996,7 @@ void A_SignPlayer(mobj_t *actor) if (LUA_CallAction(A_SIGNPLAYER, actor)) return; - if (!actor->target) - return; - - if (!actor->target->player) + if (!actor->target || !actor->target->player) return; // Set the sign to be an appropriate background color for this player's skincolor. @@ -4011,18 +4008,13 @@ void A_SignPlayer(mobj_t *actor) P_SetTarget(&ov->target, actor); ov->color = actor->target->player->skincolor; ov->skin = &skins[actor->target->player->skin]; - if (actor->target->skinlocal) { - // needs - 1 or else it pukes an error out - // same thing happens on p_mobj.c - ov->localskin = &localskins[actor->target->player->localskin - 1]; - ov->skinlocal = actor->target->skinlocal; - } else { - // needs - 1 or else it pukes an error out - // same thing happens on p_mobj.c - if (actor->target->player->localskin) - ov->localskin = &skins[actor->target->player->localskin - 1]; - ov->skinlocal = actor->target->skinlocal; - } + + // needs - 1 or else it pukes an error out + // same thing happens on p_mobj.c + ov->skinlocal = actor->target->skinlocal; + if (ov->skinlocal || actor->target->player->localskin) + ov->localskin = &K_GetSkinArray(ov->skinlocal)[actor->target->player->localskin - 1]; + P_SetMobjState(ov, actor->info->seestate); // S_PLAY_SIGN } From cf1abbd17629638e8f67248d375ed1f368cb61ed Mon Sep 17 00:00:00 2001 From: chromaticpipe <127907268+chromaticpipe@users.noreply.github.com> Date: Sun, 4 May 2025 12:13:02 -0500 Subject: [PATCH 09/10] Add interpolation related stats to perfstats These were commented out for some reason.. --- src/d_main.c | 5 +++++ src/m_perfstats.c | 18 +++++++++--------- src/r_fps.c | 3 +++ src/r_fps.h | 4 ++++ 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index ced90b261..8aff70d97 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -827,6 +827,11 @@ void D_SRB2Loop(void) { renderdeltatics = FloatToFixed(deltatics); + // I looked at the possibility of putting in a float drawer for + // perfstats and it's very complicated, so we'll just do this instead... + ps_interp_frac.value.p = (precise_t)((FIXED_TO_FLOAT(g_time.timefrac)) * 1000.0f); + ps_interp_lag.value.p = (precise_t)((deltasecs) * 1000.0f); + if (!(paused || P_AutoPause()) && deltatics < 1.0 && !hu_stopped) { rendertimefrac = g_time.timefrac; diff --git a/src/m_perfstats.c b/src/m_perfstats.c index 6b6a7f7db..28a385fd1 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -126,11 +126,11 @@ perfstatrow_t commoncounter_rows[] = { {0} }; -/*perfstatrow_t interpolation_rows[] = { +perfstatrow_t interpolation_rows[] = { {"intpfrc", "Interp frac: ", &ps_interp_frac, PS_TIME}, {"intplag", "Interp lag: ", &ps_interp_lag, PS_TIME}, {0} -};*/ +}; #ifdef HWRENDER perfstatrow_t batchcount_rows[] = { @@ -553,8 +553,8 @@ static void PS_UpdateFrameStats(void) if (PS_IsLevelActive()) PS_UpdateRowHistories(commoncounter_rows, true); - /*if (R_UsingFrameInterpolation()) - PS_UpdateRowHistories(interpolation_rows, true);*/ + if (R_UsingFrameInterpolation()) + PS_UpdateRowHistories(interpolation_rows, true); #ifdef HWRENDER if (rendermode == render_opengl && cv_glbatching.value) @@ -773,7 +773,7 @@ static void PS_DrawRenderStats(void) { const boolean hires = PS_HighResolution(); const int half_row = hires ? 5 : 4; - int x, y = 10; //, cy = 10; + int x, y, cy = 10; PS_DrawDescriptorHeader(); @@ -784,7 +784,7 @@ static void PS_DrawRenderStats(void) if (PS_IsLevelActive()) { x = hires ? 115 : 90; - /*cy = */PS_DrawPerfRows(x, 10, V_BLUEMAP, commoncounter_rows);// + half_row; + cy = PS_DrawPerfRows(x, 10, V_BLUEMAP, commoncounter_rows);// + half_row; #ifdef HWRENDER if (rendermode == render_opengl && cv_glbatching.value) @@ -799,11 +799,11 @@ static void PS_DrawRenderStats(void) #endif } - /*if (R_UsingFrameInterpolation()) + if (R_UsingFrameInterpolation()) { x = hires ? 115 : 90; - PS_DrawPerfRows(x, cy, V_ROSYMAP, interpolation_rows); - }*/ + PS_DrawPerfRows(x, cy, V_PEACHMAP, interpolation_rows); + } } static void PS_DrawGameLogicStats(void) diff --git a/src/r_fps.c b/src/r_fps.c index b9daabe06..5dbae1e9f 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -45,6 +45,9 @@ consvar_t cv_fpscap = {"fpscap", "Match refresh rate", CV_SAVE, fpscap_cons_t, N consvar_t cv_precipinterp = {"precipinterpolation", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +ps_metric_t ps_interp_frac = {0}; +ps_metric_t ps_interp_lag = {0}; + UINT32 R_GetFramerateCap(void) { if (rendermode == render_none) diff --git a/src/r_fps.h b/src/r_fps.h index 006f80b67..2ca6f1bf3 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -18,10 +18,14 @@ #include "m_fixed.h" #include "p_local.h" #include "r_state.h" +#include "m_perfstats.h" extern consvar_t cv_fpscap; extern consvar_t cv_precipinterp; +extern ps_metric_t ps_interp_frac; +extern ps_metric_t ps_interp_lag; + UINT32 R_GetFramerateCap(void); boolean R_UsingFrameInterpolation(void); From 763485950388294c7751896ab8e6ea0d091f166b Mon Sep 17 00:00:00 2001 From: chromaticpipe <127907268+chromaticpipe@users.noreply.github.com> Date: Sun, 4 May 2025 18:29:23 -0500 Subject: [PATCH 10/10] Use more correct flags for interpolation stats + misc fixes --- src/m_perfstats.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/m_perfstats.c b/src/m_perfstats.c index 28a385fd1..52d65b020 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -127,8 +127,8 @@ perfstatrow_t commoncounter_rows[] = { }; perfstatrow_t interpolation_rows[] = { - {"intpfrc", "Interp frac: ", &ps_interp_frac, PS_TIME}, - {"intplag", "Interp lag: ", &ps_interp_lag, PS_TIME}, + {"intpfrc", "Interp frac: ", &ps_interp_frac, 0}, + {"intplag", "Interp lag: ", &ps_interp_lag, 0}, {0} }; @@ -784,7 +784,7 @@ static void PS_DrawRenderStats(void) if (PS_IsLevelActive()) { x = hires ? 115 : 90; - cy = PS_DrawPerfRows(x, 10, V_BLUEMAP, commoncounter_rows);// + half_row; + cy = PS_DrawPerfRows(x, 10, V_BLUEMAP, commoncounter_rows) + half_row; #ifdef HWRENDER if (rendermode == render_opengl && cv_glbatching.value)