From 30f11e4e463208e8e0b3d482050dd78321d11c34 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 25 Jan 2025 01:09:43 +0300 Subject: [PATCH 001/350] Fix 'total podium' stat display using totalwins --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 0c1882fef..e1b00d4ac 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8829,7 +8829,7 @@ static void M_DrawStatsExtra(void) DRAWTIMESTAT(52, "Time spent in spinout:", spinouttime); DRAWAMOUNTSTAT(72, "Total wins:", totalwins); - DRAWAMOUNTSTAT(82, "Total podium (2nd/3rd place):", totalwins); + DRAWAMOUNTSTAT(82, "Total podium (2nd/3rd place):", totalpodium); DRAWAMOUNTSTAT(102, "Hits landed:", hits); DRAWAMOUNTSTAT(112, "Self-hits landed:", selfhits); From 58fd729bec7ab409b3be16e120708681702d3a04 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 3 Mar 2025 00:14:25 +0100 Subject: [PATCH 002/350] temp revert nanosleep for nix --- src/sdl/i_system.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 353fd0f82..337f24de3 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2130,16 +2130,7 @@ void I_Sleep(UINT32 ms) void I_SleepDuration(precise_t duration) { -#if defined(__linux__) || defined(__FreeBSD__) || defined(__HAIKU__) - UINT64 precision = I_GetPrecisePrecision(); - struct timespec ts = { - .tv_sec = duration / precision, - .tv_nsec = duration * 1000000000 / precision % 1000000000, - }; - int status; - do status = clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, &ts); - while (status == EINTR); -#elif defined (MIN_SLEEP_DURATION_MS) +#if defined (MIN_SLEEP_DURATION_MS) UINT64 precision = I_GetPrecisePrecision(); INT32 sleepvalue = cv_sleep.value; UINT64 delaygranularity; From fac2e8ec9837fcc57c149adced523be815456021 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 3 Mar 2025 09:56:49 +0100 Subject: [PATCH 003/350] tiny cleanup keyboard stuff --- src/sdl/i_video.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 83564bfab..bca0a7840 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -417,13 +417,15 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code) } // Get the equivalent ASCII (Unicode?) character for a keypress. -static INT32 GetTypedChar(SDL_Scancode code, SDL_Keysym *sym) +static INT32 GetTypedChar(SDL_Keysym keysym) { SDL_Event next_event; - boolean Text_Input_Only = (chat_on || CON_Ready() || (menu_text_input && menuactive)); //only use this this if on chat or console or the current menu wants inputs from us (except if its the control setup menu ig) + SDL_Keycode keycode = keysym.sym; + SDL_Scancode scancode = keysym.scancode; + const boolean Text_Input_Only = (chat_on || CON_Ready() || (menu_text_input && menuactive)); // only use this this if on chat or console or the current menu wants inputs from us (except if its the control setup menu ig) // Special cases, where we always return a fixed value. - switch (sym->sym) + switch (keycode) { case SDLK_BACKSPACE: return KEY_BACKSPACE; case SDLK_RETURN: return KEY_ENTER; @@ -440,13 +442,13 @@ static INT32 GetTypedChar(SDL_Scancode code, SDL_Keysym *sym) } } - return Impl_SDL_Scancode_To_Keycode(code); //fallback + return Impl_SDL_Scancode_To_Keycode(scancode); // fallback } static INT32 Impl_SDL_Keysym_To_Keycode(SDL_Keysym keysym) { - SDL_Keycode keycode= keysym.sym; - SDL_Scancode scancode= keysym.scancode; + SDL_Keycode keycode = keysym.sym; + SDL_Scancode scancode = keysym.scancode; if (keycode >= SDLK_a && keycode <= SDLK_z) { @@ -457,15 +459,14 @@ static INT32 Impl_SDL_Keysym_To_Keycode(SDL_Keysym keysym) { return KEY_F1 + (keycode - SDLK_F1); } - if(scancode == SDL_SCANCODE_APOSTROPHE) + + switch (scancode) { - return KEY_FR_U_GRAVE; - } - switch(scancode){ case SDL_SCANCODE_APOSTROPHE: return KEY_FR_U_GRAVE; case SDL_SCANCODE_LEFTBRACKET: return '^'; default: break; } + switch (keycode) { // F11 and F12 are separated from the rest of the function keys @@ -858,6 +859,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) { event_t event; + if (type == SDL_KEYUP) { event.type = ev_keyup; @@ -871,12 +873,18 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) return; } - if (cv_keyboardlayout.value == 2) - event.data1 = GetTypedChar(evt.keysym.scancode, &evt.keysym); - else if (cv_keyboardlayout.value == 3) - event.data1 = Impl_SDL_Keysym_To_Keycode(evt.keysym); - else - event.data1 = Impl_SDL_Scancode_To_Keycode(evt.keysym.scancode); + switch (cv_keyboardlayout.value) + { + case 2: // "native" + event.data1 = GetTypedChar(evt.keysym); + break; + case 3: // AZERTY + event.data1 = Impl_SDL_Keysym_To_Keycode(evt.keysym); + break; + default: + event.data1 = Impl_SDL_Scancode_To_Keycode(evt.keysym.scancode); + break; + } if (event.data1) D_PostEvent(&event); } From 341d592001501da67c704dde0460b433fcd380c4 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 7 Mar 2025 14:45:28 +0100 Subject: [PATCH 004/350] show smol notice in stat and ra menu when game is modded --- src/m_menu.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index e1b00d4ac..be0b3131f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -475,6 +475,12 @@ static void Dummystaff_OnChange(void); // crap to force hud to show when in saturns hud options boolean forceshowhud = false; +// smol text indicating if game is modified +// so ppl dont wonder where their ra times went and stuff +#define SHOWMODDEDGAME \ + if (savemoddata) \ + V_DrawThinString(0, 0, V_REDMAP|V_SNAPTOTOP|V_SNAPTOLEFT|V_TRANSLUCENT|V_ALLOWLOWERCASE, ("Modified Game")); + // ========================================================================== // CONSOLE VARIABLES AND THEIR POSSIBLE VALUES GO HERE. // ========================================================================== @@ -8673,6 +8679,8 @@ static void M_DrawStatsMaps(void) extraemblem_t *exemblem; boolean dotopname = true, dobottomarrow = (location < statsMax); + SHOWMODDEDGAME + for (j = 0; j < NUMMAPS; j++) { if (!mapheaderinfo[j] || !(mapheaderinfo[j]->menuflags & LF2_RECORDATTACK)) @@ -8816,6 +8824,8 @@ static void M_DrawStatsPlaytime(void) if (kartstats.vanilla) return; + SHOWMODDEDGAME + DRAWTIMESTAT(82, "RA Play Time:", raplaytime); DRAWTIMESTAT(92, "Online Play Time:", onlineplaytime); DRAWTIMESTAT(102, "Race Play Time:", raceplaytime); @@ -8825,6 +8835,8 @@ static void M_DrawStatsPlaytime(void) // Note: only available with non-vanilla stats loaded, so it doesn't check for that static void M_DrawStatsExtra(void) { + SHOWMODDEDGAME + DRAWTIMESTAT(42, "Time being SPB target:", spbtargettime); DRAWTIMESTAT(52, "Time spent in spinout:", spinouttime); @@ -8946,6 +8958,8 @@ void M_DrawTimeAttackMenu(void) x = currentMenu->x; y = currentMenu->y; + SHOWMODDEDGAME + // Character face! if (W_CheckNumForName(skins[cv_chooseskin.value-1].facewant) != LUMPERROR) { From 1df7d07abc0c84e5941a4fa8b597aaddda8bd2a8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 16 Mar 2025 12:23:51 +0100 Subject: [PATCH 005/350] oops --- src/hardware/hw_glob.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index f66f10c37..e4659c0e6 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -43,7 +43,7 @@ typedef struct gl_vissprite_s INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing } gl_vissprite_t; -void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model, const boolean papersprite); +void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model); // -------- // hw_bsp.c From 2b1eb51d947f0f319969231c9f101a8b9e300ab9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 16 Mar 2025 12:24:38 +0100 Subject: [PATCH 006/350] goddamit --- src/hardware/hw_md2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 611871a9a..cefbde5b7 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1143,7 +1143,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) colormap = sector->extra_colormap; } - HWR_ObjectLightLevelPost(spr, sector, &lightlevel, true, false); + HWR_ObjectLightLevelPost(spr, sector, &lightlevel, true); HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !(spr->mobj->frame & FF_FULLBRIGHT)); } From cefad321810b41b24361df0e29583336c5a5af33 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 16 Mar 2025 13:19:28 +0100 Subject: [PATCH 007/350] dont I_Error when direct downloader failed to open a file just cancle the transfer and kick the receiving client lel --- src/d_netfil.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index e488e083e..4a648b176 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -867,8 +867,12 @@ void SV_FileSendTicker(void) if (!transferFiles[f->fileid].file) { - I_Error("Can't open file %s: %s", + CONS_Alert(CONS_ERROR, "Can't open file %s: %s\n", f->id.filename, strerror(errno)); + + SV_EndFileSend(i); + HSendPacket(i, true, 0, PT_SERVERREFUSE); + break; } } @@ -973,7 +977,7 @@ void Got_Filetxpak(void) if (filenum >= fileneedednum) { - DEBFILE(va("fileframent not needed %d>%d\n", filenum, fileneedednum)); + DEBFILE(va("filefragment not needed %d>%d\n", filenum, fileneedednum)); //I_Error("Received an unneeded file fragment (file id received: %d, file id needed: %d)\n", filenum, fileneedednum); return; } From 0af6c133c52e94347ff806cdbdf7f4f918334be2 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 16 Mar 2025 13:23:49 +0100 Subject: [PATCH 008/350] only do the nvidia fbo hack when sdl_renderer is "x11" we dont need this on the wayland renderer anymore --- src/sdl/ogl_sdl.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index f590d2a0f..dde5c269b 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -46,8 +46,6 @@ #include "../i_video.h" #include "../f_finale.h" -#include "../f_finale.h" - #ifdef DEBUG_TO_FILE #include #if defined (_WIN32) && !defined (__CYGWIN__) @@ -192,14 +190,25 @@ boolean OglSdlSurface(INT32 w, INT32 h) #if defined (__unix__) #ifdef USE_FBO_OGL - if (supportFBO && strstr((const char*)gl_renderer, "NVIDIA")) + char videodriver[4] = {'S','D','L',0}; + if (supportFBO && strstr((const char*)gl_renderer, "NVIDIA") + && (*strncpy(videodriver, SDL_GetCurrentVideoDriver(), 4) != '\0') + && (strncasecmp("x11",videodriver,4) == 0)) xwaylandcrap = true; #endif #endif } - SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0); - + if (cv_vidwait.value) + { + if (SDL_GL_SetSwapInterval(-1) == -1) // try async vsync + SDL_GL_SetSwapInterval(1); // normal vsync + } + else + SDL_GL_SetSwapInterval(0); + + //SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0); + // The screen textures need to be flushed if the width or height change so that they be remade for the correct size if (screen_width != w || screen_height != h) { From 74ee853b49a39bd8203574297ef445b332e3e247 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 16 Mar 2025 13:27:13 +0100 Subject: [PATCH 009/350] just skip this loop if P_RemoveThinkerDelayed we cant do anything there anyways, so this might be ever so slightly faster --- src/p_saveg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index d7e592431..394db050f 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1680,8 +1680,10 @@ static void P_NetArchiveThinkers(savebuffer_t *save) // save off the current thinkers for (th = thinkercap.next; th != &thinkercap; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_RemoveThinkerDelayed) - numsaved++; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + numsaved++; if (th->function.acp1 == (actionf_p1)P_MobjThinker) { From 11f5d2fb078fc3f83fb91ffa2355e584c653035a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 16 Mar 2025 14:15:24 +0100 Subject: [PATCH 010/350] disable jit compilation for now --- src/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Makefile b/src/Makefile index 4e9f3d7cf..ebbd97fa8 100644 --- a/src/Makefile +++ b/src/Makefile @@ -93,7 +93,10 @@ ifeq ($(OS),Windows_NT) # all windows are Windows_NT... WINDOWSHELL=1 NOOBJDUMP=1 + NOBLUAJIT=1 + else # if you on the *nix + NOBLUAJIT=1 system:=$(shell uname -s) ifeq ($(system),Linux) From 2c5c08e562af560c2fc037eede4861c8362b0d90 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 16 Mar 2025 15:25:28 +0100 Subject: [PATCH 011/350] did not mean to push this --- src/sdl/ogl_sdl.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index dde5c269b..c60a78962 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -199,15 +199,7 @@ boolean OglSdlSurface(INT32 w, INT32 h) #endif } - if (cv_vidwait.value) - { - if (SDL_GL_SetSwapInterval(-1) == -1) // try async vsync - SDL_GL_SetSwapInterval(1); // normal vsync - } - else - SDL_GL_SetSwapInterval(0); - - //SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0); + SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0); // The screen textures need to be flushed if the width or height change so that they be remade for the correct size if (screen_width != w || screen_height != h) From 6d7035afacfdd0f06bd5ea20ddadbc5d6b516275 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 16 Mar 2025 17:27:14 +0300 Subject: [PATCH 012/350] Fix gl_extensions being truncated when there are too many extensions --- src/sdl/ogl_sdl.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index c60a78962..1cfaf4c45 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -157,7 +157,28 @@ boolean OglSdlSurface(INT32 w, INT32 h) GL_DBG_Printf("OpenGL %s\n", gl_version); GL_DBG_Printf("GPU: %s\n", gl_renderer); - GL_DBG_Printf("Extensions: %s\n", gl_extensions); + GL_DBG_Printf("Extensions:"); + + { + // Need to do it with strtok for same reason its done like that in gr_glinfo command + + char *copy = strdup((const char*)gl_extensions); + char *ext = strtok(copy, " "); + + if (copy == NULL) + { + GL_DBG_Printf("Ran out of memory listing extensions?!?!"); + } + else + { + do + { + GL_DBG_Printf(" %s", ext); + } while ((ext = strtok(NULL, " ")) != NULL); + + free(copy); + } + } if (strcmp((const char*)gl_renderer, "GDI Generic") == 0 && strcmp((const char*)gl_version, "1.1.0") == 0) From f6535c8ad3ae9120cef1f680e812588393376270 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 16 Mar 2025 21:05:52 +0100 Subject: [PATCH 013/350] noo dont free our realpatch randomly this used to be Z_Unlock which did nothing checked against srb2 and rr and this should not be freed normally --- src/hardware/hw_cache.c | 10 ++++------ src/w_wad.c | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index c06db3891..3822ae37b 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -77,9 +77,6 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm (void)patchheight; // This parameter is unused - if (!mipmap) - return; - if (originPatch) // originPatch can be NULL here, unlike in the software version originy = originPatch->originy; @@ -118,11 +115,11 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm alpha = 0xFF; // Make pixel transparent if chroma keyed - if ((mipmap && mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX)) + if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX)) alpha = 0x00; //Hurdler: 25/04/2000: now support colormap in hardware mode - if (mipmap && mipmap->colormap) + if (mipmap->colormap) texel = mipmap->colormap[texel]; // hope compiler will get this switch out of the loops (dreams...) @@ -387,10 +384,11 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + if (realpatch != NULL) { HWR_DrawTexturePatchInCache(&gltex->mipmap, blockwidth, blockheight, texture, patch, realpatch); - Z_ChangeTag(realpatch, PU_HWRCACHE_UNLOCKED); + //Z_ChangeTag(realpatch, PU_HWRCACHE_UNLOCKED); } } diff --git a/src/w_wad.c b/src/w_wad.c index 37c992d29..6432c3223 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1780,7 +1780,7 @@ void W_UnlockCachedPatch(void *patch) // The hardware code does its own memory management, as its patches // have different lifetimes from software's. #ifdef HWRENDER - if (rendermode != render_soft && rendermode != render_none) + if (rendermode == render_opengl) HWR_UnlockCachedPatch((GLPatch_t*)patch); else #endif From 3efb6c0241441f8426b040395bc2008a6a83c9d7 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Mar 2025 11:15:12 +0100 Subject: [PATCH 014/350] dont let saltyhop stop our drift sounds for 1 tic if you disable its sound effects --- src/k_kart.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index f3a2cbee3..e13e318cd 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3482,13 +3482,14 @@ static void K_QuiteSaltyHop(player_t *p) if (p->mo->salty_zoffset <= 0) { - if (!(p->mo->eflags & MFE_JUSTHITFLOOR) && P_IsObjectOnGround(p->mo) && cv_saltyhopsfx.value) + if (cv_saltyhopsfx.value && !(p->mo->eflags & MFE_JUSTHITFLOOR) && P_IsObjectOnGround(p->mo)) S_StartSound(p->mo, sfx_s268); p->mo->salty_jump = false; p->mo->salty_zoffset = 0; p->mo->salty_momz = 0; // shlamma damma - p->mo->stretchslam += cv_saltysquish.value ? (8*mos) : 0; + if (cv_saltysquish.value) + p->mo->stretchslam += 8*mos; } else if (p->mo->salty_zoffset >= 0 && cv_saltysquish.value) { @@ -3499,10 +3500,13 @@ static void K_QuiteSaltyHop(player_t *p) p->mo->spriteyoffset = p->mo->salty_zoffset; - if (S_SoundPlaying(p->mo, sfx_screec)) - S_StopSoundByID(p->mo, sfx_screec); - if (S_SoundPlaying(p->mo, sfx_drift)) - S_StopSoundByID(p->mo, sfx_drift); + if (cv_saltyhopsfx.value) + { + if (S_SoundPlaying(p->mo, sfx_screec)) + S_StopSoundByID(p->mo, sfx_screec); + if (S_SoundPlaying(p->mo, sfx_drift)) + S_StopSoundByID(p->mo, sfx_drift); + } } else if (p->mo->salty_tapping && P_IsObjectOnGround(p->mo) && !p->kartstuff[k_spinouttimer] && !p->kartstuff[k_squishedtimer]) { From 53a73e989308f270f88d66296518134c47df4f2b Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Mar 2025 12:38:43 +0100 Subject: [PATCH 015/350] safe some time by returning early in K_RollMobjBySlopes in case those mobjs are out of our set distance --- src/k_kart.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index e13e318cd..daa2c8fe7 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3530,13 +3530,20 @@ void K_RollMobjBySlopes(mobj_t* mo, pslope_t *slope) // lifted from hw_md2 if (slope) { - angle_t an; - const boolean flip = (mo->eflags & MFE_VERTICALFLIP); const boolean usedistance = cv_sloperolldist.value && !splitscreen; const fixed_t rolldist = cv_sloperolldist.value * mapobjectscale; const fixed_t m_dist = usedistance ? R_PointToDist(mo->x, mo->y) : 0; const boolean usepitchnroll = (!usedistance || (m_dist <= rolldist)); + if (!usepitchnroll) + { + mo->pitch_sprite = mo->roll_sprite = 0; + mo->sloperoll = mo->slopepitch = 0; + return; + } + + angle_t an; + const boolean flip = (mo->eflags & MFE_VERTICALFLIP); fixed_t tempz = slope->normal.z; fixed_t tempy = slope->normal.y; fixed_t tempx = slope->normal.x; @@ -3545,29 +3552,14 @@ void K_RollMobjBySlopes(mobj_t* mo, pslope_t *slope) // admittedly this is a very hacky way to do the pitch and roll easing // pitch - if (usepitchnroll) - { - an = (INT32)((angle_t)tempangle - mo->pitch_sprite) / SLOPEROLL_DIV; - - mo->pitch_sprite = an ? mo->pitch_sprite + an : (angle_t)tempangle; - } - else - mo->pitch_sprite = 0; - + an = (INT32)((angle_t)tempangle - mo->pitch_sprite) / SLOPEROLL_DIV; + mo->pitch_sprite = an ? mo->pitch_sprite + an : (angle_t)tempangle; mo->slopepitch = flip ? InvAngle(mo->pitch_sprite) : mo->pitch_sprite; // roll - tempangle = (R_PointToAngle2(0, 0, tempz, tempy)); - - if (usepitchnroll) - { - an = (INT32)((angle_t)tempangle - mo->roll_sprite) / SLOPEROLL_DIV; - - mo->roll_sprite = an ? mo->roll_sprite + an : (angle_t)tempangle; - } - else - mo->roll_sprite = 0; - + tempangle = R_PointToAngle2(0, 0, tempz, tempy); + an = (INT32)((angle_t)tempangle - mo->roll_sprite) / SLOPEROLL_DIV; + mo->roll_sprite = an ? mo->roll_sprite + an : (angle_t)tempangle; mo->sloperoll = flip ? InvAngle(mo->roll_sprite) : mo->roll_sprite; } else if (P_IsObjectOnGround(mo)) From d86179f1a47ffa8bb253b3ac669763c250efcc62 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Mar 2025 13:06:06 +0100 Subject: [PATCH 016/350] kill bunch of redundant calcs for some kart visual effects --- src/k_kart.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index daa2c8fe7..0f271d9f5 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3268,8 +3268,12 @@ static void K_SpawnDriftSparks(player_t *player) for (i = 0; i < 2; i++) { fixed_t driftExtraScale = 0; - newx = player->mo->x + P_ReturnThrustX(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(32*FRACUNIT, player->mo->scale)); - newy = player->mo->y + P_ReturnThrustY(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(32*FRACUNIT, player->mo->scale)); + + angle_t thrustangle = (travelangle + ((i&1) ? -1 : 1)*ANGLE_135); + fixed_t smolscale = FixedMul(32*FRACUNIT, player->mo->scale); + + newx = player->mo->x + P_ReturnThrustX(player->mo, thrustangle, smolscale); + newy = player->mo->y + P_ReturnThrustY(player->mo, thrustangle, smolscale); spark = P_SpawnMobj(newx, newy, player->mo->z, MT_DRIFTSPARK); P_SetTarget(&spark->target, player->mo); @@ -3278,7 +3282,7 @@ static void K_SpawnDriftSparks(player_t *player) // scale increase while driftspark level gained timer is running driftExtraScale = FixedDiv(player->driftsparkGrowTimer, DRIFTSPARKGROWTICS); spark->destscale = FixedMul(player->mo->scale, FRACUNIT + FixedMul(driftExtraScale, cv_driftsparkpulse.value)); - P_SetScale(spark, FixedMul(player->mo->scale, FRACUNIT + FixedMul(driftExtraScale, cv_driftsparkpulse.value))); + P_SetScale(spark, spark->destscale); // why not use what we calculated above? spark->momx = player->mo->momx/2; spark->momy = player->mo->momy/2; @@ -3342,8 +3346,11 @@ static void K_SpawnAIZDust(player_t *player) //S_StartSound(player->mo, sfx_s3k47); { - newx = player->mo->x + P_ReturnThrustX(player->mo, travelangle - (player->kartstuff[k_aizdriftstrat]*ANGLE_45), FixedMul(24*FRACUNIT, player->mo->scale)); - newy = player->mo->y + P_ReturnThrustY(player->mo, travelangle - (player->kartstuff[k_aizdriftstrat]*ANGLE_45), FixedMul(24*FRACUNIT, player->mo->scale)); + angle_t thrustangle = (travelangle - (player->kartstuff[k_aizdriftstrat]*ANGLE_45)); + fixed_t smolscale = FixedMul(24*FRACUNIT, player->mo->scale); + + newx = player->mo->x + P_ReturnThrustX(player->mo, thrustangle, smolscale); + newy = player->mo->y + P_ReturnThrustY(player->mo, thrustangle, smolscale); spark = P_SpawnMobj(newx, newy, player->mo->z, MT_AIZDRIFTSTRAT); spark->angle = travelangle+(player->kartstuff[k_aizdriftstrat]*ANGLE_90); @@ -3599,14 +3606,19 @@ void K_SpawnBoostTrail(player_t *player) for (i = 0; i < 2; i++) { - newx = player->mo->x + P_ReturnThrustX(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale)); - newy = player->mo->y + P_ReturnThrustY(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale)); + angle_t thrustangle = (travelangle + ((i&1) ? -1 : 1)*ANGLE_135); + fixed_t smolscale = FixedMul(24*FRACUNIT, player->mo->scale); + + newx = player->mo->x + P_ReturnThrustX(player->mo, thrustangle, smolscale); + newy = player->mo->y + P_ReturnThrustY(player->mo, thrustangle, smolscale); + if (player->mo->standingslope) { ground = P_GetZAt(player->mo->standingslope, newx, newy); if (player->mo->eflags & MFE_VERTICALFLIP) ground -= FixedMul(mobjinfo[MT_SNEAKERTRAIL].height, player->mo->scale); } + flame = P_SpawnMobj(newx, newy, ground, MT_SNEAKERTRAIL); P_SetTarget(&flame->target, player->mo); From dc53fac53d72ba858a3287dfcd6c22cdfd86619d Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Mar 2025 13:42:31 +0100 Subject: [PATCH 017/350] fix midair driftsparks somehow accidentally ended up doing what RR does lmao hope this doesent do anything funky synchwise --- src/k_kart.c | 94 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 40 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 0f271d9f5..c5f6df388 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3257,9 +3257,14 @@ static void K_SpawnDriftSparks(player_t *player) if (leveltime % 2 == 1) return; - if (!cv_airsparks.value && !P_IsObjectOnGround(player->mo)) + if (cv_airsparks.value) + goto skipground; + + if (!P_IsObjectOnGround(player->mo)) return; +skipground: // idk im sleepy + if (!player->kartstuff[k_drift] || player->kartstuff[k_driftcharge] < K_GetKartDriftSparkValue(player)) return; @@ -6051,59 +6056,68 @@ static void K_KartDrift(player_t *player, boolean onground) } // Incease/decrease the drift value to continue drifting in that direction - if (player->kartstuff[k_spinouttimer] == 0 && player->kartstuff[k_jmp] == 1 && onground && player->kartstuff[k_drift] != 0) + if (player->kartstuff[k_spinouttimer] == 0 && player->kartstuff[k_jmp] == 1 && player->kartstuff[k_drift] != 0) { fixed_t driftadditive = 24; - if (player->kartstuff[k_drift] >= 1) // Drifting to the left + // well this is kinda dumb but we cannot modify a drift in midair so + if (onground) { - player->kartstuff[k_drift]++; - if (player->kartstuff[k_drift] > 5) - player->kartstuff[k_drift] = 5; + if (player->kartstuff[k_drift] >= 1) // Drifting to the left + { + player->kartstuff[k_drift]++; + if (player->kartstuff[k_drift] > 5) + player->kartstuff[k_drift] = 5; - if (player->cmd.driftturn > 0) // Inward - driftadditive += abs(player->cmd.driftturn)/100; - if (player->cmd.driftturn < 0) // Outward - driftadditive -= abs(player->cmd.driftturn)/75; + if (player->cmd.driftturn > 0) // Inward + driftadditive += abs(player->cmd.driftturn)/100; + if (player->cmd.driftturn < 0) // Outward + driftadditive -= abs(player->cmd.driftturn)/75; + } + else if (player->kartstuff[k_drift] <= -1) // Drifting to the right + { + player->kartstuff[k_drift]--; + if (player->kartstuff[k_drift] < -5) + player->kartstuff[k_drift] = -5; + + if (player->cmd.driftturn < 0) // Inward + driftadditive += abs(player->cmd.driftturn)/100; + if (player->cmd.driftturn > 0) // Outward + driftadditive -= abs(player->cmd.driftturn)/75; + } + + // Disable drift-sparks until you're going fast enough + if (player->kartstuff[k_getsparks] == 0 || (player->kartstuff[k_offroad] && !player->kartstuff[k_invincibilitytimer] && !player->kartstuff[k_hyudorotimer] && !player->kartstuff[k_sneakertimer])) + driftadditive = 0; + if (player->speed > minspeed*2) + player->kartstuff[k_getsparks] = 1; + + // Sound whenever you get a different tier of sparks + if ((player->kartstuff[k_driftcharge] < dsone && player->kartstuff[k_driftcharge]+driftadditive >= dsone) + || (player->kartstuff[k_driftcharge] < dstwo && player->kartstuff[k_driftcharge]+driftadditive >= dstwo) + || (player->kartstuff[k_driftcharge] < dsthree && player->kartstuff[k_driftcharge]+driftadditive >= dsthree)) + { + //S_StartSound(player->mo, sfx_s3ka2); + if (P_IsLocalPlayer(player)) // UGHGHGH... + S_StartSoundAtVolume(player->mo, sfx_s3ka2, 192); // Ugh... + + player->driftsparkGrowTimer = DRIFTSPARKGROWTICS; + } } - else if (player->kartstuff[k_drift] <= -1) // Drifting to the right + else { - player->kartstuff[k_drift]--; - if (player->kartstuff[k_drift] < -5) - player->kartstuff[k_drift] = -5; - - if (player->cmd.driftturn < 0) // Inward - driftadditive += abs(player->cmd.driftturn)/100; - if (player->cmd.driftturn > 0) // Outward - driftadditive -= abs(player->cmd.driftturn)/75; - } - - // Disable drift-sparks until you're going fast enough - if (player->kartstuff[k_getsparks] == 0 || (player->kartstuff[k_offroad] && !player->kartstuff[k_invincibilitytimer] && !player->kartstuff[k_hyudorotimer] && !player->kartstuff[k_sneakertimer])) driftadditive = 0; - if (player->speed > minspeed*2) - player->kartstuff[k_getsparks] = 1; - - // Sound whenever you get a different tier of sparks - if ((player->kartstuff[k_driftcharge] < dsone && player->kartstuff[k_driftcharge]+driftadditive >= dsone) - || (player->kartstuff[k_driftcharge] < dstwo && player->kartstuff[k_driftcharge]+driftadditive >= dstwo) - || (player->kartstuff[k_driftcharge] < dsthree && player->kartstuff[k_driftcharge]+driftadditive >= dsthree)) - { - //S_StartSound(player->mo, sfx_s3ka2); - if (P_IsLocalPlayer(player)) // UGHGHGH... - S_StartSoundAtVolume(player->mo, sfx_s3ka2, 192); // Ugh... - - player->driftsparkGrowTimer = DRIFTSPARKGROWTICS; } - - // moved this below sounds to help with scaling // This spawns the drift sparks if (player->kartstuff[k_driftcharge] + driftadditive >= dsone) K_SpawnDriftSparks(player); - player->kartstuff[k_driftcharge] += driftadditive; - player->kartstuff[k_driftend] = 0; + if (onground) + { + player->kartstuff[k_driftcharge] += driftadditive; + player->kartstuff[k_driftend] = 0; + } } if (player->driftsparkGrowTimer) From 0119eeb575f945cac725f52a7cba7ff35be54964 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Mar 2025 14:21:08 +0100 Subject: [PATCH 018/350] use quickcamdist for K_RollMobjBySlopes we dont need this to be accurate at all and its slightly faster so --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index c5f6df388..771f251e2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3544,7 +3544,7 @@ void K_RollMobjBySlopes(mobj_t* mo, pslope_t *slope) { const boolean usedistance = cv_sloperolldist.value && !splitscreen; const fixed_t rolldist = cv_sloperolldist.value * mapobjectscale; - const fixed_t m_dist = usedistance ? R_PointToDist(mo->x, mo->y) : 0; + const fixed_t m_dist = usedistance ? (R_QuickCamDist(mo->x, mo->y)*FRACUNIT) : 0; const boolean usepitchnroll = (!usedistance || (m_dist <= rolldist)); if (!usepitchnroll) From c7473ddf427cac33f53a00753c7a1392ddc3e2b0 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Mar 2025 15:56:11 +0100 Subject: [PATCH 019/350] add function to check if mobj should sloperoll makes things slightly cleaner and we can apply sloperoll dist to everything should probably save some time esp with the trailing item z calc + P_MobjPitchAndRoll should be able to be called always since it also does stuff seperate from sloperoll --- src/k_kart.c | 52 ++++++++++++++++++++++++++++++++-------------------- src/k_kart.h | 1 + src/p_mobj.c | 22 +++------------------- 3 files changed, 36 insertions(+), 39 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 771f251e2..1f345881e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3530,30 +3530,47 @@ static void K_QuiteSaltyHop(player_t *p) } } +// checks if slope rotation should be applied +boolean K_ShouldSlopeRoll(mobj_t *mobj) +{ + if (!cv_sloperoll.value || (!mobj->player && cv_sloperoll.value != 2)) // not a player and sloperoll not set to "Everything" + return false; + + const boolean usedistance = cv_sloperolldist.value && !splitscreen; + + // always roll from any distance + if (!usedistance) + return true; + + const fixed_t rolldist = cv_sloperolldist.value * mapobjectscale; + const fixed_t m_dist = (R_QuickCamDist(mobj->x, mobj->y)*FRACUNIT); + + return (m_dist <= rolldist); +} + #define SLOPEROLL_DIV 3 void K_RollMobjBySlopes(mobj_t* mo, pslope_t *slope) { + // save one P_MobjWasRemoved check for dedis lel + if (rendermode == render_none) + return; + if (P_MobjWasRemoved(mo)) return; I_Assert(mo->subsector != NULL); I_Assert(mo->subsector->sector != NULL); + if (!K_ShouldSlopeRoll(mo)) + { + mo->pitch_sprite = mo->roll_sprite = 0; + mo->sloperoll = mo->slopepitch = 0; + return; + } + // lifted from hw_md2 if (slope) { - const boolean usedistance = cv_sloperolldist.value && !splitscreen; - const fixed_t rolldist = cv_sloperolldist.value * mapobjectscale; - const fixed_t m_dist = usedistance ? (R_QuickCamDist(mo->x, mo->y)*FRACUNIT) : 0; - const boolean usepitchnroll = (!usedistance || (m_dist <= rolldist)); - - if (!usepitchnroll) - { - mo->pitch_sprite = mo->roll_sprite = 0; - mo->sloperoll = mo->slopepitch = 0; - return; - } - angle_t an; const boolean flip = (mo->eflags & MFE_VERTICALFLIP); fixed_t tempz = slope->normal.z; @@ -3953,7 +3970,7 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map if (mo->eflags & MFE_UNDERWATER) mo->momz = (117 * mo->momz) / 200; - if (cv_sloperoll.value == 2 && cv_bananthrowroll.value && mapthing == MT_BANANA) + if (cv_bananthrowroll.value && (mapthing == MT_BANANA) && K_ShouldSlopeRoll(mo)) { //mo->angle = FixedAngle(M_RandomRange(-180, 180) << FRACBITS); if (cv_bananthrowroll.value == 1) @@ -5035,7 +5052,7 @@ static void K_MoveHeldObjects(player_t *player) if (R_PointToDist2(cur->x, cur->y, targx, targy) > 768*FRACUNIT) P_MoveOrigin(cur, targx, targy, cur->z); - if (cv_sloperoll.value == 2 && P_IsObjectOnGround(cur)) + if (P_IsObjectOnGround(cur) && K_ShouldSlopeRoll(cur)) { K_CalculateBananaSlope(cur, cur->x, cur->y, cur->z, cur->radius, cur->height, (cur->eflags & MFE_VERTICALFLIP), false); @@ -6920,15 +6937,10 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_StretchPlayerGravity(player); - if (cv_sloperoll.value && !player->mo->salty_jump) // seeing a character rotate mid-hop looks really janky + if (!player->mo->salty_jump) // seeing a character rotate mid-hop looks really janky { K_RollMobjBySlopes(player->mo, player->mo->standingslope); } - else - { - player->mo->sloperoll = 0; - player->mo->slopepitch = 0; - } // Quick Turning // You can't turn your kart when you're not moving. diff --git a/src/k_kart.h b/src/k_kart.h index d3d335517..4f432aca1 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -62,6 +62,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor); void K_StealBumper(player_t *player, player_t *victim, boolean force); void K_SpawnKartExplosion(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 number, mobjtype_t type, angle_t rotangle, boolean spawncenter, boolean ghostit, mobj_t *source); void K_SpawnMineExplosion(mobj_t *source, UINT8 color); +boolean K_ShouldSlopeRoll(mobj_t *mobj); void K_RollMobjBySlopes(mobj_t *mo, pslope_t *slope); void K_SpawnBoostTrail(player_t *player); void K_SpawnSparkleTrail(mobj_t *mo); diff --git a/src/p_mobj.c b/src/p_mobj.c index 111dc6558..610ecbe9a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6038,20 +6038,6 @@ static void P_KoopaThinker(mobj_t *koopa) // void P_RollPitchMobj(mobj_t* mobj) { - // we dont need this in dedi do we? - if (rendermode == render_none) - return; - - if (P_MobjWasRemoved(mobj)) - return; - - if (cv_sloperoll.value != 2) - { - mobj->sloperoll = 0; - mobj->slopepitch = 0; - return; - } - K_RollMobjBySlopes(mobj, mobj->standingslope); } @@ -6063,9 +6049,6 @@ angle_t P_MobjPitchAndRoll(mobj_t *mobj) angle_t camang = 0; angle_t return_angle = 0; - if (!cv_sloperoll.value) - return 0; - if (P_MobjWasRemoved(mobj)) return 0; @@ -6269,6 +6252,7 @@ void P_MobjThinker(mobj_t *mobj) return; } + // dont need to extra check with K_ShouldSlopeRoll if (cv_sloperoll.value == 2 && mobj->state == &states[S_SHADOW]) { mobj->slopepitch = mobj->target->slopepitch; @@ -7064,7 +7048,7 @@ void P_MobjThinker(mobj_t *mobj) break; //{ SRB2kart Items - Death States case MT_BANANA: - if (cv_sloperoll.value == 2 && cv_bananthrowroll.value) + if (cv_bananthrowroll.value && K_ShouldSlopeRoll(mobj)) { angle_t spin = FixedMul(FixedDiv(abs(mobj->momz), 8 * mobj->scale), ANGLE_67h); //mobj->angle -= spin; @@ -7819,7 +7803,7 @@ void P_MobjThinker(mobj_t *mobj) } case MT_BANANA: case MT_EGGMANITEM: - if (cv_sloperoll.value == 2 && cv_bananthrowroll.value && !P_IsObjectOnGround(mobj)) + if (cv_bananthrowroll.value && !P_IsObjectOnGround(mobj) && K_ShouldSlopeRoll(mobj)) { // tilt n tumble angle_t spin = FixedMul(FixedDiv(mobj->momz, 8 * mobj->scale), ANGLE_67h); From 5ab7e8dd80353ee482eecdffb9ae5b635e0c2649 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Mar 2025 15:24:49 +0100 Subject: [PATCH 020/350] forgor about saltyhop condition --- src/k_kart.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 1f345881e..0ca12a72a 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3536,6 +3536,10 @@ boolean K_ShouldSlopeRoll(mobj_t *mobj) if (!cv_sloperoll.value || (!mobj->player && cv_sloperoll.value != 2)) // not a player and sloperoll not set to "Everything" return false; + // seeing a character rotate mid-hop looks really janky + if (mobj->player && mobj->player->mo->salty_jump) + return false; + const boolean usedistance = cv_sloperolldist.value && !splitscreen; // always roll from any distance @@ -6935,12 +6939,9 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->sliproll -= (4*ANG1); } + // funneh Saturn sprite stuff K_StretchPlayerGravity(player); - - if (!player->mo->salty_jump) // seeing a character rotate mid-hop looks really janky - { - K_RollMobjBySlopes(player->mo, player->mo->standingslope); - } + K_RollMobjBySlopes(player->mo, player->mo->standingslope); // Quick Turning // You can't turn your kart when you're not moving. From dd70743baecc08ab5e86f808fc322ba0a96e12de Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Mar 2025 15:56:22 +0100 Subject: [PATCH 021/350] make the banana throw speen be seperate from sloperoll toggle were technically not rolling by slopes here --- src/k_kart.c | 31 ++++++++++++++++++------------- src/k_kart.h | 1 + src/p_mobj.c | 18 ++++++++---------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 0ca12a72a..e4e5d051e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3530,16 +3530,8 @@ static void K_QuiteSaltyHop(player_t *p) } } -// checks if slope rotation should be applied -boolean K_ShouldSlopeRoll(mobj_t *mobj) +boolean K_CheckSlopeRollDist(mobj_t *mobj) { - if (!cv_sloperoll.value || (!mobj->player && cv_sloperoll.value != 2)) // not a player and sloperoll not set to "Everything" - return false; - - // seeing a character rotate mid-hop looks really janky - if (mobj->player && mobj->player->mo->salty_jump) - return false; - const boolean usedistance = cv_sloperolldist.value && !splitscreen; // always roll from any distance @@ -3552,6 +3544,19 @@ boolean K_ShouldSlopeRoll(mobj_t *mobj) return (m_dist <= rolldist); } +// checks if slope rotation should be applied +boolean K_ShouldSlopeRoll(mobj_t *mobj) +{ + if (!cv_sloperoll.value || (!mobj->player && cv_sloperoll.value != 2)) // not a player and sloperoll not set to "Everything" + return false; + + // seeing a character rotate mid-hop looks really janky + if (mobj->player && mobj->player->mo->salty_jump) + return false; + + return K_CheckSlopeRollDist(mobj); +} + #define SLOPEROLL_DIV 3 void K_RollMobjBySlopes(mobj_t* mo, pslope_t *slope) { @@ -3974,13 +3979,13 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map if (mo->eflags & MFE_UNDERWATER) mo->momz = (117 * mo->momz) / 200; - if (cv_bananthrowroll.value && (mapthing == MT_BANANA) && K_ShouldSlopeRoll(mo)) + if (cv_bananthrowroll.value && (mapthing == MT_BANANA)) { //mo->angle = FixedAngle(M_RandomRange(-180, 180) << FRACBITS); - if (cv_bananthrowroll.value == 1) - mo->sloperoll = FixedAngle(M_RandomRange(-180, 180) << FRACBITS); // im lazy but this makes sure the banan goes back to upright when it lands lmao + if (cv_bananthrowroll.value == 1 && K_CheckSlopeRollDist(mo)) + mo->sloperoll = (angle_t)FixedAngle(M_RandomRange(-180, 180) << FRACBITS); // im lazy but this makes sure the banan goes back to upright when it lands lmao else if (cv_bananthrowroll.value == 2) - mo->rollangle = FixedAngle(M_RandomRange(-180, 180) << FRACBITS); + mo->rollangle = (angle_t)FixedAngle(M_RandomRange(-180, 180) << FRACBITS); } } diff --git a/src/k_kart.h b/src/k_kart.h index 4f432aca1..9a530703e 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -62,6 +62,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor); void K_StealBumper(player_t *player, player_t *victim, boolean force); void K_SpawnKartExplosion(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 number, mobjtype_t type, angle_t rotangle, boolean spawncenter, boolean ghostit, mobj_t *source); void K_SpawnMineExplosion(mobj_t *source, UINT8 color); +boolean K_CheckSlopeRollDist(mobj_t *mobj); boolean K_ShouldSlopeRoll(mobj_t *mobj); void K_RollMobjBySlopes(mobj_t *mo, pslope_t *slope); void K_SpawnBoostTrail(player_t *player); diff --git a/src/p_mobj.c b/src/p_mobj.c index 610ecbe9a..06105d18c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7048,15 +7048,14 @@ void P_MobjThinker(mobj_t *mobj) break; //{ SRB2kart Items - Death States case MT_BANANA: - if (cv_bananthrowroll.value && K_ShouldSlopeRoll(mobj)) + if (cv_bananthrowroll.value) { - angle_t spin = FixedMul(FixedDiv(abs(mobj->momz), 8 * mobj->scale), ANGLE_67h); //mobj->angle -= spin; - if (cv_bananthrowroll.value == 1) - mobj->sloperoll += spin; // im lazy but this makes sure the banan goes back to upright when it lands lmao + if (cv_bananthrowroll.value == 1 && K_CheckSlopeRollDist(mobj)) + mobj->sloperoll += (angle_t)FixedMul(FixedDiv(abs(mobj->momz), 8 * mobj->scale), ANGLE_67h); // im lazy but this makes sure the banan goes back to upright when it lands lmao else if (cv_bananthrowroll.value == 2) - mobj->rollangle += spin; + mobj->rollangle += (angle_t)FixedMul(FixedDiv(abs(mobj->momz), 8 * mobj->scale), ANGLE_67h); //if (P_IsObjectOnGround(mobj) && mobj->momz * P_MobjFlip(mobj) <= 0) } @@ -7803,16 +7802,15 @@ void P_MobjThinker(mobj_t *mobj) } case MT_BANANA: case MT_EGGMANITEM: - if (cv_bananthrowroll.value && !P_IsObjectOnGround(mobj) && K_ShouldSlopeRoll(mobj)) + if (cv_bananthrowroll.value && !P_IsObjectOnGround(mobj)) { // tilt n tumble - angle_t spin = FixedMul(FixedDiv(mobj->momz, 8 * mobj->scale), ANGLE_67h); //mobj->angle += spin; - if (cv_bananthrowroll.value == 1) - mobj->sloperoll -= spin; // im lazy but this makes sure the banan goes back to upright when it lands lmao + if (cv_bananthrowroll.value == 1 && K_CheckSlopeRollDist(mobj)) + mobj->sloperoll -= (angle_t)FixedMul(FixedDiv(mobj->momz, 8 * mobj->scale), ANGLE_67h); // im lazy but this makes sure the banan goes back to upright when it lands lmao else if (cv_bananthrowroll.value == 2) - mobj->rollangle -= spin; + mobj->rollangle -= (angle_t)FixedMul(FixedDiv(mobj->momz, 8 * mobj->scale), ANGLE_67h); } mobj->friction = ORIG_FRICTION/4; From ece1122733270765c4cc0add8a0d8311eb32e978 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Mon, 17 Mar 2025 16:00:57 +0100 Subject: [PATCH 022/350] Fix tonumber leaking doubles when JITted --- src/bluajit/lj_ffrecord.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bluajit/lj_ffrecord.c b/src/bluajit/lj_ffrecord.c index 3ac6d802a..fb230a1e4 100644 --- a/src/bluajit/lj_ffrecord.c +++ b/src/bluajit/lj_ffrecord.c @@ -378,6 +378,10 @@ static void LJ_FASTCALL recff_tonumber(jit_State *J, RecordFFData *rd) return; } tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); +#if LJ_INTONLY + /* x86 assembler can't handle STRTO with int type, have to CONV it instead */ + tr = emitir(IRTI(IR_CONV), tr, IRCONV_INT_NUM); +#endif } #if LJ_HASFFI } else if (tref_iscdata(tr)) { From 56ddb5da2344215f76dc63105551b60efe4d084c Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Mar 2025 18:26:32 +0100 Subject: [PATCH 023/350] revert this too just in case --- src/hardware/hw_cache.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 3822ae37b..c4fa211e6 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -1005,8 +1005,7 @@ void HWR_GetMappedPatch(GLPatch_t *glPatch, const UINT8 *colormap) { GLMipmap_t *glMipmap, *newMipmap; - // Blatant hack for encore colormapping aside... - if (colormap == colormaps || colormap == NULL || colormap == (const UINT8*)(COLORMAP_REMAPOFFSET)) + if (colormap == colormaps || colormap == NULL) { // Load the default (green) color in doom cache (temporary?) AND hardware cache HWR_GetPatch(glPatch); From 635b4110a485532688c77cf10702f84811c9f3cd Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Mar 2025 18:39:49 +0100 Subject: [PATCH 024/350] move patch null checks into the patch drawers instead --- src/lua_hudlib_drawlist.c | 6 ------ src/v_video.c | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index e06244411..d64722f0c 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -651,18 +651,12 @@ void LUA_HUD_DrawList(huddrawlist_h list) switch (item->type) { case DI_Draw: - if (!item->patch || item->patch == NULL) - return; V_DrawBlendingFixedPatch(LERPS(x), LERPS(y), FRACUNIT, item->flags, item->patch, item->colormap, item->blend); break; case DI_DrawScaled: - if (!item->patch || item->patch == NULL) - return; V_DrawBlendingFixedPatch(LERPS(x), LERPS(y), LERP(scale), item->flags, item->patch, item->colormap, item->blend); break; case DI_DrawStretched: - if (!item->patch || item->patch == NULL) - return; V_DrawStretchyFixedPatch(LERPS(x), LERPS(y), LERP(hscale), LERP(vscale), item->flags, item->patch, item->colormap, item->blend); break; case DI_DrawNum: diff --git a/src/v_video.c b/src/v_video.c index a8f351b59..3dcd3323b 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -627,6 +627,9 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca if (rendermode == render_none) return; + if (!patch) + return; + #ifdef HWRENDER //if (rendermode != render_soft && !con_startup) // Why? if (rendermode == render_opengl) @@ -857,6 +860,9 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ if (rendermode == render_none) return; + if (!patch) + return; + #ifdef HWRENDER if (rendermode == render_opengl) { From 24e149634ddab6a55dd430a5cf0eadbaf55b8fa2 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Mar 2025 18:41:12 +0100 Subject: [PATCH 025/350] remove this again --- src/hardware/hw_cache.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index c4fa211e6..e995df244 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -412,16 +412,6 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe // patch may be NULL if glMipmap has been initialised already and makebitmap is false void HWR_MakePatch (patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipmap, boolean makebitmap) { - if (glMipmap == NULL) - return; - - if (patch == NULL || glPatch == NULL) - { - Z_Free(glMipmap->data); - glMipmap->data = NULL; - return; - } - // don't do it twice (like a cache) if (glMipmap->width == 0) { From 5aa081a01bf7994fa8e6080bf65ff2fe9664e413 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Mar 2025 18:43:45 +0100 Subject: [PATCH 026/350] Revert "Use PU_LEVEL for texture caching" This reverts commit 5ecfc5e09d912164c68a3d62184bc3a823f02cc9. --- src/r_data.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index d1ed5e6ef..ddac60598 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -323,7 +323,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) { boolean holey = false; patch = texture->patches; - realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_LEVEL); + realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); // Check the patch for holes. if (texture->width > SHORT(realpatch->width) || texture->height > SHORT(realpatch->height)) @@ -353,7 +353,8 @@ static UINT8 *R_GenerateTexture(size_t texnum) { texture->holes = true; blocksize = W_LumpLengthPwad(patch->wad, patch->lump); - block = Z_Calloc(blocksize, PU_LEVEL, &texturecache[texnum]); + block = Z_Calloc(blocksize, PU_STATIC, // will change tag at end of this function + &texturecache[texnum]); M_Memcpy(block, realpatch, blocksize); texturememory += blocksize; @@ -373,7 +374,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) texture->holes = false; blocksize = (texture->width * 4) + (texture->width * texture->height); texturememory += blocksize; - block = Z_Malloc(blocksize+1, PU_LEVEL, &texturecache[texnum]); + block = Z_Malloc(blocksize+1, PU_STATIC, &texturecache[texnum]); memset(block, 0xF7, blocksize+1); // Transparency hack @@ -387,7 +388,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) // Composite the columns together. for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { - realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_LEVEL); + realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); // Well, it's not valid... if (realpatch == NULL) @@ -415,6 +416,8 @@ static UINT8 *R_GenerateTexture(size_t texnum) } done: + // Now that the texture has been built in column cache, it is purgable from zone memory. + Z_ChangeTag(block, PU_CACHE); return blocktex; } @@ -464,7 +467,7 @@ UINT8 *R_GetColumn(fixed_t tex, INT32 col) // UINT8 *R_GetFlat(lumpnum_t flatlumpnum) { - return W_CacheLumpNum(flatlumpnum, PU_LEVEL); + return W_CacheLumpNum(flatlumpnum, PU_CACHE); } // From a662a0a68f52ddbf8851356353570ac93fdb2f9e Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Mar 2025 18:52:27 +0100 Subject: [PATCH 027/350] Revert "disable jit compilation for now" This reverts commit 11f5d2fb078fc3f83fb91ffa2355e584c653035a. --- src/Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Makefile b/src/Makefile index ebbd97fa8..4e9f3d7cf 100644 --- a/src/Makefile +++ b/src/Makefile @@ -93,10 +93,7 @@ ifeq ($(OS),Windows_NT) # all windows are Windows_NT... WINDOWSHELL=1 NOOBJDUMP=1 - NOBLUAJIT=1 - else # if you on the *nix - NOBLUAJIT=1 system:=$(shell uname -s) ifeq ($(system),Linux) From 28af4e52775f1ca0fe4d0c17791ce23c1d4c74fd Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 20 Mar 2025 01:16:57 +0300 Subject: [PATCH 028/350] Only reset replay query in M_ReplayHut if replay hut wasn't open previously --- src/m_menu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 18c72f9ca..efd6a276a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6887,10 +6887,9 @@ void M_ReplayHut(INT32 choice) { snprintf(menupath, 1024, "%s"PATHSEP"replay"PATHSEP"online"PATHSEP, srb2home); menupathindex[(menudepthleft = menudepth-1)] = strlen(menupath); + ResetReplayQuery(); } - ResetReplayQuery(); - if (!preparefilemenu(false, true)) { M_StartMessage("No replays found.\n\n(Press a key)\n", NULL, MM_NOTHING); From aba138447c03a8536a7485b8b8f3d5e13f76d4c3 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 20 Mar 2025 17:31:57 +0100 Subject: [PATCH 029/350] =?UTF-8?q?continue=20in=20P=5FNetArchiveThinkers?= =?UTF-8?q?=20l=C3=B6=C3=B6p?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit if thinker is P_RemoveThinkerDelayed --- src/p_saveg.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 3525f58e3..ea3ed47b6 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1680,8 +1680,10 @@ static void P_NetArchiveThinkers(savebuffer_t *save) // save off the current thinkers for (th = thinkercap.next; th != &thinkercap; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_RemoveThinkerDelayed) - numsaved++; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + numsaved++; if (th->function.acp1 == (actionf_p1)P_MobjThinker) { @@ -1864,7 +1866,7 @@ static void P_NetArchiveThinkers(savebuffer_t *save) continue; } #ifdef PARANOIA - else if (th->function.acp1 != P_RemoveThinkerDelayed) // wait garbage collection + else // wait garbage collection I_Error("unknown thinker type %p", th->function.acp1); #endif } @@ -3459,7 +3461,7 @@ void P_SaveNetGame(savebuffer_t *save, boolean resending) { thinker_t *th; mobj_t *mobj; - INT32 i = 1; // don't start from 0, it'd be confused with a blank pointer otherwise + UINT32 i = 1; // don't start from 0, it'd be confused with a blank pointer otherwise CV_SaveNetVars(&save->p, false); P_NetArchiveMisc(save, resending); From a90c44c7d88dd3048e2ef99360412b77537c1cd1 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 20 Mar 2025 18:13:53 +0100 Subject: [PATCH 030/350] delet player_joining --- src/d_clisrv.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c8a66e3a0..f8f3b4ee0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -151,7 +151,6 @@ static UINT32 resynch_status[MAXNETNODES]; // 0 bit means synched for that playe static UINT8 resynch_sent[MAXNETNODES][MAXPLAYERS]; // what synch packets have we attempted to send to the player static UINT8 resynch_inprogress[MAXNETNODES]; static UINT8 resynch_local_inprogress = false; // WE are desynched and getting packets to fix it. -static UINT8 player_joining = false; UINT8 hu_resynching = 0; #ifdef SATURNSYNCH @@ -4882,7 +4881,6 @@ static void HandleConnect(SINT8 node) DEBFILE("send savegame\n"); } SV_AddWaitingPlayers(); - player_joining = true; } #else #ifndef NONET @@ -5843,8 +5841,6 @@ static void GetPackets(void) { SINT8 node; // The packet sender - player_joining = false; - while (HGetPacket()) { node = (SINT8)doomcom->remotenode; @@ -6492,21 +6488,12 @@ boolean TryRunTics(tic_t realtics) } #endif - if (neededtic > gametic) - { - hu_stopped = false; - } - - if (player_joining) - { - hu_stopped = true; - return false; - } - ticking = neededtic > gametic; if (ticking) { + hu_stopped = false; + // run the count * tics while (neededtic > gametic) { From e02288b6892a84ff28fd0b2108acc3792ad56b0e Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 20 Mar 2025 18:32:55 +0100 Subject: [PATCH 031/350] kill this, i want vanilla behaviour --- src/d_clisrv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index f8f3b4ee0..fb4964122 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6522,8 +6522,7 @@ boolean TryRunTics(tic_t realtics) } else { - if (realtics) - hu_stopped = true; + hu_stopped = true; } return ticking; From 189a28f34953bb4398f4f04d859b8fe189be10aa Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 20 Mar 2025 18:13:53 +0100 Subject: [PATCH 032/350] delet player_joining --- src/d_clisrv.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1b5478b62..f8bf58efb 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -151,7 +151,6 @@ static UINT32 resynch_status[MAXNETNODES]; // 0 bit means synched for that playe static UINT8 resynch_sent[MAXNETNODES][MAXPLAYERS]; // what synch packets have we attempted to send to the player static UINT8 resynch_inprogress[MAXNETNODES]; static UINT8 resynch_local_inprogress = false; // WE are desynched and getting packets to fix it. -static UINT8 player_joining = false; UINT8 hu_resynching = 0; #ifdef SATURNSYNCH @@ -4877,7 +4876,6 @@ static void HandleConnect(SINT8 node) DEBFILE("send savegame\n"); } SV_AddWaitingPlayers(); - player_joining = true; } #else #ifndef NONET @@ -5838,8 +5836,6 @@ static void GetPackets(void) { SINT8 node; // The packet sender - player_joining = false; - while (HGetPacket()) { node = (SINT8)doomcom->remotenode; @@ -6487,21 +6483,12 @@ boolean TryRunTics(tic_t realtics) } #endif - if (neededtic > gametic) - { - hu_stopped = false; - } - - if (player_joining) - { - hu_stopped = true; - return false; - } - ticking = neededtic > gametic; if (ticking) { + hu_stopped = false; + // run the count * tics while (neededtic > gametic) { From 9283b443c146fe6575e08caa607151615986d029 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 20 Mar 2025 18:32:55 +0100 Subject: [PATCH 033/350] kill this, i want vanilla behaviour --- src/d_clisrv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index f8bf58efb..14ee18d17 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6517,8 +6517,7 @@ boolean TryRunTics(tic_t realtics) } else { - if (realtics) - hu_stopped = true; + hu_stopped = true; } return ticking; From 9e3dcbd041adabc0fadd08f1765612351ae66d16 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 20 Mar 2025 23:47:42 +0100 Subject: [PATCH 034/350] dont update sounds every frame if this would break ppl on 35fps cap wouldve been always screwed lel --- src/d_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index fb7a98a6e..b2411e96c 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -862,7 +862,8 @@ void D_SRB2Loop(void) M_DoScreenShot(); // consoleplayer -> displayplayers (hear sounds from viewpoint) - S_UpdateSounds(); // move positional sounds + if (renderisnewtic) + S_UpdateSounds(); // move positional sounds LUA_Step(); From b0d6ccf5727c0ca09b03f51884d48b0e047445e5 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 20 Mar 2025 23:48:09 +0100 Subject: [PATCH 035/350] dont run discord rpc callbacks every frame ditto --- src/d_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index b2411e96c..216fde85b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -868,7 +868,7 @@ void D_SRB2Loop(void) LUA_Step(); #ifdef HAVE_DISCORDRPC - if (!dedicated) + if (!dedicated && renderisnewtic) { Discord_RunCallbacks(); } From 0af6703c0878391c1442479ca8bda722f7c42f6b Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 21 Mar 2025 15:53:10 +0100 Subject: [PATCH 036/350] hack for stick input display if you watch some other player Zzz.... --- src/k_kart.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index e4e5d051e..0804e2c49 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -10769,7 +10769,12 @@ static void K_drawInput(void) // during normal gameplay, so replicate shit here INT32 hudforward = 0; // for the stick input display :chaosleep: - if (!demo.playback) + // this is horrid but we cant get actual input in replays so uhh + if (demo.playback || stplyr != &players[consoleplayer]) // yeah........... + { + hudforward = stplyr->kartstuff[k_throwdir] * KART_FULLTURN; + } + else { const boolean analogjoystickmove = cv_usejoystick[stplyrnum].value && !Joystick[stplyrnum].bGamepadStyle; const boolean gamepadjoystickmove = cv_usejoystick[stplyrnum].value && Joystick[stplyrnum].bGamepadStyle; @@ -10794,10 +10799,6 @@ static void K_drawInput(void) } } } - else // this is horrid but we cant get actual input in replays so uhh - { - hudforward = stplyr->kartstuff[k_throwdir] * KART_FULLTURN; - } hudforward = CLAMP(hudforward, -KART_FULLTURN, KART_FULLTURN); From dee640d32f3ce95ec416df61cb0c6d86cb1e582c Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 21 Mar 2025 15:56:10 +0100 Subject: [PATCH 037/350] forger P_IsLocalPlayer exists --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 0804e2c49..d6d8618b2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -10770,7 +10770,7 @@ static void K_drawInput(void) INT32 hudforward = 0; // for the stick input display :chaosleep: // this is horrid but we cant get actual input in replays so uhh - if (demo.playback || stplyr != &players[consoleplayer]) // yeah........... + if (demo.playback || !P_IsLocalPlayer(stplyr)) // yeah........... { hudforward = stplyr->kartstuff[k_throwdir] * KART_FULLTURN; } From 8fce9e39a0923b332cce73a1f540e2855174072e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 23 Mar 2025 16:18:18 +0100 Subject: [PATCH 038/350] changable saltyhop height dunno, it looks a bit off on higher values since the animation duration is always the same also cv_float is weird --- src/g_game.h | 1 + src/k_kart.c | 33 ++++++++++++++++++++++++++++++--- src/m_menu.c | 7 +++++-- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/g_game.h b/src/g_game.h index deec04226..7b8e73175 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -170,6 +170,7 @@ extern consvar_t cv_smallposnum; extern consvar_t cv_newspeedometer; extern consvar_t cv_saltyhop; +extern consvar_t cv_saltyheight; extern consvar_t cv_saltyhopsfx; extern consvar_t cv_saltysquish; diff --git a/src/k_kart.c b/src/k_kart.c index d6d8618b2..5773dbe9b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -144,9 +144,12 @@ consvar_t cv_spinoutroll = {"spinoutroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NU //hardcode saltyhop mhhm static void saltyhop_onchange(void); +static void saltyheight_onchange(void); consvar_t cv_saltyhop = {"hardcodehop", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, saltyhop_onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_saltyhopsfx = {"hardcodehopsfx", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_saltysquish = {"hardcodehopsquish", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t saltyheight_t[] = {{FRACUNIT/4, "MIN"}, {2*FRACUNIT, "MAX"}, {0, NULL}}; +consvar_t cv_saltyheight = {"hardcodehopheight", "1", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, saltyheight_t, saltyheight_onchange, 0, NULL, NULL, 0, 0, NULL}; static void saltyhop_onchange(void) { @@ -160,7 +163,7 @@ static void saltyhop_onchange(void) { player_t *player = &players[i]; - if (!playeringame[i] || P_MobjWasRemoved(player->mo)) + if (!player || !playeringame[i] || P_MobjWasRemoved(player->mo)) continue; player->mo->salty_jump = false; @@ -174,7 +177,30 @@ static void saltyhop_onchange(void) } } -//Colourized HUD +static void saltyheight_onchange(void) +{ + // reset everything when toggling saltyhop height + if (gamestate != GS_LEVEL) + return; + + for (INT32 i = 0; i < MAXPLAYERS; i++) + { + player_t *player = &players[i]; + + if (!player || !playeringame[i] || P_MobjWasRemoved(player->mo)) + continue; + + player->mo->salty_jump = false; + player->mo->salty_zoffset = 0; + player->mo->salty_momz = 0; + + player->mo->salty_ready = false; + player->mo->salty_tapping = false; + player->mo->init_salty = false; + } +} + +// Colourized HUD consvar_t cv_colorizedhud = {"colorizedhud", "Off", CV_SAVE|CV_CALL, CV_OnOff, SaturnHud_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_colorizeditembox = {"colorizeditembox", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -913,6 +939,7 @@ void K_RegisterClientKartStuff(void) CV_RegisterVar(&cv_saltyhop); CV_RegisterVar(&cv_saltyhopsfx); CV_RegisterVar(&cv_saltysquish); + CV_RegisterVar(&cv_saltyheight); CV_RegisterVar(&cv_slamsound); CV_RegisterVar(&cv_lessflicker); @@ -3510,7 +3537,7 @@ static void K_QuiteSaltyHop(player_t *p) p->mo->spritexscale -= (mos/8); } - p->mo->spriteyoffset = p->mo->salty_zoffset; + p->mo->spriteyoffset = FixedMul(p->mo->salty_zoffset, cv_saltyheight.value); if (cv_saltyhopsfx.value) { diff --git a/src/m_menu.c b/src/m_menu.c index efd6a276a..2993c2c44 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2298,8 +2298,9 @@ static menuitem_t OP_PlayerDistortMenu[] = {IT_STRING | IT_CVAR, NULL, "Player Stretch Factor", &cv_gravstretch, 90}, {IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 105}, {IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 120}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 135}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 150}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Height", &cv_saltyheight, 135}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 150}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 175}, }; static const char* OP_PlayerDistortTooltips[] = @@ -2313,6 +2314,7 @@ static const char* OP_PlayerDistortTooltips[] = "Player squash and stretch.", "Player landing sound effect.", "Kart hopping while drifting. This is purely visual.", + "Jump Height for Kart hopping.", "Player hop sound effect.", "Player hop squash and stretch.", }; @@ -2328,6 +2330,7 @@ enum stretchyplayer, squishsound, salthmmm, + saltheight, saltsound, saltsquishy, }; From f7fbb8b8595ffe8f1028cc56a2dcfef4c572d56b Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 23 Mar 2025 16:38:34 +0100 Subject: [PATCH 039/350] make menu sliders work on CV_FLOAT --- src/m_menu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 2993c2c44..923a02374 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3589,9 +3589,10 @@ static void M_ChangeCvar(INT32 choice) choice = (choice<<1) - 1; - if (((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_SLIDER) + if (!(cv->flags & CV_FLOAT) && + (((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_SLIDER) ||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_INVISSLIDER) - ||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_NOMOD)) + ||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_NOMOD))) { CV_SetValue(cv,cv->value+choice); } @@ -3600,10 +3601,9 @@ static void M_ChangeCvar(INT32 choice) char s[20]; float increment; - increment = (currentMenu->menuitems[itemOn].status & IT_CV_BIGFLOAT) ? 0.5 : (1.f/16); - - sprintf(s,"%f",FIXED_TO_FLOAT(cv->value)+(choice)*increment); - CV_Set(cv,s); + increment = (currentMenu->menuitems[itemOn].status & IT_CV_BIGFLOAT) ? 0.5f : (1.0f/16.0f); + sprintf(s, "%f",FIXED_TO_FLOAT(cv->value)+(choice)*increment); + CV_Set(cv, s); } else { From dc8b9ffc7c56187b0451a9531aa5773b235b1638 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 23 Mar 2025 16:43:53 +0100 Subject: [PATCH 040/350] make saltyhop height use slider --- src/m_menu.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 923a02374..cbb6fb068 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2288,19 +2288,19 @@ static menuitem_t OP_PlayerDistortMenu[] = { {IT_HEADER, NULL, "Sprite Distortion", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Sprite Slope Rotation", &cv_sloperoll, 15}, - {IT_STRING | IT_CVAR, NULL, "Slope Rotation Distance", &cv_sloperolldist, 30}, + {IT_STRING | IT_CVAR, NULL, "Sprite Slope Rotation", &cv_sloperoll, 15}, + {IT_STRING | IT_CVAR, NULL, "Slope Rotation Distance", &cv_sloperolldist, 30}, - {IT_STRING | IT_CVAR, NULL, "Rotate Players when Sliptiding", &cv_sliptideroll, 45}, - {IT_STRING | IT_CVAR, NULL, "Rotate Sparks and Boost Trails", &cv_sparkroll, 60}, - {IT_STRING | IT_CVAR, NULL, "Rotate Bananas on Throw", &cv_bananthrowroll, 75}, + {IT_STRING | IT_CVAR, NULL, "Rotate Players when Sliptiding", &cv_sliptideroll, 45}, + {IT_STRING | IT_CVAR, NULL, "Rotate Sparks and Boost Trails", &cv_sparkroll, 60}, + {IT_STRING | IT_CVAR, NULL, "Rotate Bananas on Throw", &cv_bananthrowroll, 75}, - {IT_STRING | IT_CVAR, NULL, "Player Stretch Factor", &cv_gravstretch, 90}, - {IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 105}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 120}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Height", &cv_saltyheight, 135}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 150}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 175}, + {IT_STRING | IT_CVAR, NULL, "Player Stretch Factor", &cv_gravstretch, 90}, + {IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 105}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 120}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saltyhop Height", &cv_saltyheight, 135}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 150}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 175}, }; static const char* OP_PlayerDistortTooltips[] = From 184d171b74a565ac0a3e97f1d37a1a9a007213e4 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 23 Mar 2025 16:54:51 +0100 Subject: [PATCH 041/350] make stretchfactor a cv_float again for easier handling now that we can use sliders this should hopefully work without issues --- src/k_kart.c | 9 +++------ src/m_menu.c | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 5773dbe9b..73025b24c 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -120,11 +120,8 @@ consvar_t cv_battlespeedo = {"battlespeedo", "Off", CV_SAVE, CV_OnOff, NULL, 0, consvar_t cv_blendeffects = {"testblendeffects", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // funn-E streeetch -static CV_PossibleValue_t stretchfactor_t[] = { - {0, "Off"}, {FRACUNIT/4, "0.250"}, - {3*FRACUNIT/8, "0.375"}, {FRACUNIT/2, "0.500"}, {5*FRACUNIT/8, "0.625"}, - {3*FRACUNIT/4, "0.750"}, {7*FRACUNIT/8, "0.875"}, {FRACUNIT, "Max"}, {0, NULL}}; -consvar_t cv_gravstretch = {"gravstretch", "0", CV_SAVE, stretchfactor_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t stretchfactor_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}}; +consvar_t cv_gravstretch = {"gravstretch", "MIN", CV_SAVE|CV_FLOAT, stretchfactor_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t slamsound_t[] = {{0, "Off"}, {1, "On"}, {0, NULL}}; consvar_t cv_slamsound = {"slamsound", "1", CV_SAVE, slamsound_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -3412,7 +3409,7 @@ static void K_StretchPlayerGravity(player_t *p) fixed_t mos = FRACUNIT; fixed_t rzs = abs(p->mo->momz); fixed_t zspd = abs(rzs/mos); - fixed_t stretchScaleFactor = FixedDiv(FRACUNIT*60, cv_gravstretch.value); + fixed_t stretchScaleFactor = FixedDiv(FRACUNIT*60, FLOAT_TO_FIXED(cv_gravstretch.value)); fixed_t rzsDiv, slamDiv; fixed_t dxs = p->mo->realxscale; diff --git a/src/m_menu.c b/src/m_menu.c index cbb6fb068..71d281462 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2295,7 +2295,7 @@ static menuitem_t OP_PlayerDistortMenu[] = {IT_STRING | IT_CVAR, NULL, "Rotate Sparks and Boost Trails", &cv_sparkroll, 60}, {IT_STRING | IT_CVAR, NULL, "Rotate Bananas on Throw", &cv_bananthrowroll, 75}, - {IT_STRING | IT_CVAR, NULL, "Player Stretch Factor", &cv_gravstretch, 90}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Player Stretch Factor", &cv_gravstretch, 90}, {IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 105}, {IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 120}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saltyhop Height", &cv_saltyheight, 135}, From eb936a6f941ca43ad42a67c7f60626884714a5d2 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 23 Mar 2025 16:56:56 +0100 Subject: [PATCH 042/350] simplify the slider stuff slightly --- src/m_menu.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 71d281462..72b7e24d4 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3589,14 +3589,7 @@ static void M_ChangeCvar(INT32 choice) choice = (choice<<1) - 1; - if (!(cv->flags & CV_FLOAT) && - (((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_SLIDER) - ||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_INVISSLIDER) - ||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_NOMOD))) - { - CV_SetValue(cv,cv->value+choice); - } - else if (cv->flags & CV_FLOAT) + if (cv->flags & CV_FLOAT) { char s[20]; float increment; @@ -3607,13 +3600,22 @@ static void M_ChangeCvar(INT32 choice) } else { + if (((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_SLIDER) + ||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_INVISSLIDER) + ||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_NOMOD)) + { + CV_SetValue(cv,cv->value+choice); + } + else + { #ifndef NONET - if (cv == &cv_nettimeout || cv == &cv_jointimeout) - choice *= (TICRATE/7); - else if (cv == &cv_maxsend) - choice *= 512; + if (cv == &cv_nettimeout || cv == &cv_jointimeout) + choice *= (TICRATE/7); + else if (cv == &cv_maxsend) + choice *= 512; #endif - CV_AddValue(cv,choice); + CV_AddValue(cv,choice); + } } } From fd9902afd609cdde9e2d67363e171490abb2e2f2 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 23 Mar 2025 16:58:53 +0100 Subject: [PATCH 043/350] 15 step increment Zzz... --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 72b7e24d4..72d0e2ad6 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2300,7 +2300,7 @@ static menuitem_t OP_PlayerDistortMenu[] = {IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 120}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saltyhop Height", &cv_saltyheight, 135}, {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 150}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 175}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 165}, }; static const char* OP_PlayerDistortTooltips[] = From 475ba7ca1086c6da0cbd25bb70f8fac4a57c94fa Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 23 Mar 2025 18:13:52 +0100 Subject: [PATCH 044/350] change "verticallook" and "cameralookbackmom" to be per splitscreen player --- src/d_netcmd.c | 12 ++++++++++-- src/d_netcmd.h | 2 -- src/m_menu.c | 33 ++++++++++++++++++++++++--------- src/p_local.h | 4 +++- src/p_tick.c | 2 +- src/p_user.c | 18 ++++++++++++------ src/r_main.c | 4 ++-- 7 files changed, 52 insertions(+), 23 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 5d316aff2..0639dd00d 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -298,7 +298,12 @@ consvar_t cv_mouseturn = {"mouseturn", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, // Lagless camera! Yay! consvar_t cv_laglesscam = {"laglesscamera", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_verticallook = {"verticallook", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_verticallook[MAXSPLITSCREENPLAYERS] = { + {"verticallook", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"verticallook2", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"verticallook3", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"verticallook4", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} +}; #if defined(HAVE_SDL) || defined(_WINDOWS) //joystick 1 and 2 consvar_t cv_usejoystick[MAXSPLITSCREENPLAYERS] = { @@ -1077,7 +1082,10 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_laglesscam); - CV_RegisterVar(&cv_verticallook); + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + CV_RegisterVar(&cv_verticallook[i]); + } // ingame object placing COM_AddCommand("objectplace", Command_ObjectPlace_f); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 9e1744e00..4ec6f43ba 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -198,8 +198,6 @@ extern consvar_t cv_betainterscreen; extern consvar_t cv_laglesscam; -extern consvar_t cv_verticallook; - typedef enum { SKINMENUTYPE_SCROLL = 0, diff --git a/src/m_menu.c b/src/m_menu.c index 72d0e2ad6..e96d922de 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1892,12 +1892,11 @@ static menuitem_t OP_CamOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Lagless Camera", &cv_laglesscam, 50}, {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom, 60}, - {IT_STRING | IT_CVAR, NULL, "Camera Vertical Look", &cv_verticallook, 70}, - {IT_STRING | IT_SUBMENU, NULL, "Player 1 Camera options...", &OP_Player1CamOptionsDef, 90}, - {IT_STRING | IT_SUBMENU, NULL, "Player 2 Camera options...", &OP_Player2CamOptionsDef, 100}, - {IT_STRING | IT_SUBMENU, NULL, "Player 3 Camera options...", &OP_Player3CamOptionsDef, 110}, - {IT_STRING | IT_SUBMENU, NULL, "Player 4 Camera options...", &OP_Player4CamOptionsDef, 120}, + {IT_STRING | IT_SUBMENU, NULL, "Player 1 Camera options...", &OP_Player1CamOptionsDef, 80}, + {IT_STRING | IT_SUBMENU, NULL, "Player 2 Camera options...", &OP_Player2CamOptionsDef, 90}, + {IT_STRING | IT_SUBMENU, NULL, "Player 3 Camera options...", &OP_Player3CamOptionsDef, 100}, + {IT_STRING | IT_SUBMENU, NULL, "Player 4 Camera options...", &OP_Player4CamOptionsDef, 110}, }; static const char* OP_CamOptionsTooltips[] = @@ -1905,8 +1904,6 @@ static const char* OP_CamOptionsTooltips[] = NULL, "Player field of view.", "Removes Camera Lag in netgames\nMay cause Camera stutters in poor net conditions.", - "Should looking back inherit the Players Momentum?\nEither inherit Player Momentum or double of it\nmay make looking back while boosting or going in high speed less jarring", - "Allows looking up/down by holding aim forward/backward while standing still.", NULL, NULL, NULL, @@ -1922,6 +1919,10 @@ static menuitem_t OP_Player1CamOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[0], 60}, {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[0], 70}, + {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom[0], 80}, + + {IT_STRING | IT_CVAR, NULL, "Camera Vertical Look", &cv_verticallook[0], 90}, + {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[0], 90}, {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[0], 105}, @@ -1936,6 +1937,10 @@ static menuitem_t OP_Player2CamOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[1], 60}, {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[1], 70}, + {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom[1], 80}, + + {IT_STRING | IT_CVAR, NULL, "Camera Vertical Look", &cv_verticallook[1], 90}, + {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[1], 90}, {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[1], 105}, @@ -1950,6 +1955,10 @@ static menuitem_t OP_Player3CamOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[2], 60}, {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[2], 70}, + {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom[2], 80}, + + {IT_STRING | IT_CVAR, NULL, "Camera Vertical Look", &cv_verticallook[2], 90}, + {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[2], 90}, {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[2], 105}, @@ -1964,9 +1973,13 @@ static menuitem_t OP_Player4CamOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[3], 60}, {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[3], 70}, - {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[3], 90}, + {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom[3], 80}, - {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[3], 105}, + {IT_STRING | IT_CVAR, NULL, "Camera Vertical Look", &cv_verticallook[3], 90}, + + {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[3], 100}, + + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[3], 115}, }; static const char* OP_PlayerCamOptionsTooltips[] = @@ -1976,6 +1989,8 @@ static const char* OP_PlayerCamOptionsTooltips[] = "Camera distance relative to the Player.", "Height of the Camera", "Speed of the Camera", + "Should looking back inherit the Players Momentum?\nEither inherit Player Momentum or double of it\nmay make looking back while boosting or going in high speed less jarring", + "Allows looking up/down by holding aim forward/backward while standing still.", "Speed of the Freecam/Spectator Camera", "Toggle between Third or First Person camera", }; diff --git a/src/p_local.h b/src/p_local.h index ae72fee77..9ac7a063c 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -158,7 +158,9 @@ extern consvar_t cv_tiltsmoothing; extern consvar_t cv_actionmovie; -extern consvar_t cv_lookbackmom; +extern consvar_t cv_lookbackmom[MAXSPLITSCREENPLAYERS]; + +extern consvar_t cv_verticallook[MAXSPLITSCREENPLAYERS]; extern fixed_t t_cam_rotate[MAXSPLITSCREENPLAYERS]; diff --git a/src/p_tick.c b/src/p_tick.c index a36f34c28..2f4bc02a2 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -464,7 +464,7 @@ void P_RunChaseCameras(void) player_t *p = &players[displayplayers[i]]; camera_t *cam = &camera[i]; - if (cv_verticallook.value && leveltime > starttime && p->mo && p->kartstuff[k_respawn] == 0 && p->kartstuff[k_throwdir] != 0) + if (cv_verticallook[i].value && leveltime > starttime && p->mo && p->kartstuff[k_respawn] == 0 && p->kartstuff[k_throwdir] != 0) { if (p->speed < 6 * p->mo->scale && abs(cam->dpad_y_held) < 2*TICRATE) cam->dpad_y_held += intsign(p->kartstuff[k_throwdir]); diff --git a/src/p_user.c b/src/p_user.c index dacd18868..79e2d2379 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3095,7 +3095,7 @@ consvar_t cv_cam_timeover[MAXSPLITSCREENPLAYERS] = { {"cam_timeover", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, {"cam2_timeover", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, {"cam3_timeover", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam4_timeover", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam4_timeover", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} }; static CV_PossibleValue_t freecam_speed_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}}; @@ -3103,7 +3103,7 @@ consvar_t cv_freecam_speed[MAXSPLITSCREENPLAYERS] = { {"freecam_speed", "1", CV_SAVE, freecam_speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, {"freecam2_speed", "1", CV_SAVE, freecam_speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, {"freecam3_speed", "1", CV_SAVE, freecam_speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"freecam4_speed", "1", CV_SAVE, freecam_speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"freecam4_speed", "1", CV_SAVE, freecam_speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} }; consvar_t cv_tilting = {"tilting", "Off", CV_SAVE|CV_CALL, CV_OnOff, Bird_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; @@ -3113,7 +3113,13 @@ consvar_t cv_tiltsmoothing = {"tiltsmoothing", "32", CV_SAVE, CV_Natural, NULL, consvar_t cv_actionmovie = {"actionmovie", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t lookbackmom_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Double"}, {0, NULL}}; -consvar_t cv_lookbackmom = {"cameralookbackmom", "Off", CV_SAVE, lookbackmom_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_lookbackmom[MAXSPLITSCREENPLAYERS] = { + {"cameralookbackmom", "Off", CV_SAVE, lookbackmom_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cameralookbackmom2", "Off", CV_SAVE, lookbackmom_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cameralookbackmom3", "Off", CV_SAVE, lookbackmom_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cameralookbackmom4", "Off", CV_SAVE, lookbackmom_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} +}; fixed_t t_cam_rotate[MAXSPLITSCREENPLAYERS] = {-42, -42, -42, -42}; @@ -4000,10 +4006,10 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall // when looking back, camera's momentum // should inherit the momentum of the player // if value is 2, add extra - if (cv_lookbackmom.value && lookback && lookbackdelay[num]) + if (cv_lookbackmom[num].value && lookback && lookbackdelay[num]) { - thiscam->momx += cv_lookbackmom.value*mo->momx; - thiscam->momy += cv_lookbackmom.value*mo->momy; + thiscam->momx += cv_lookbackmom[num].value*mo->momx; + thiscam->momy += cv_lookbackmom[num].value*mo->momy; } thiscam->momz = FixedMul(z - thiscam->z, camspeed/2); diff --git a/src/r_main.c b/src/r_main.c index aa28078ae..08b478fff 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1551,6 +1551,8 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_cam_rotate[i]); CV_RegisterVar(&cv_cam_timeover[i]); CV_RegisterVar(&cv_freecam_speed[i]); + + CV_RegisterVar(&cv_lookbackmom[i]); } CV_RegisterVar(&cv_tilting); @@ -1558,8 +1560,6 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_tiltsmoothing); CV_RegisterVar(&cv_actionmovie); - CV_RegisterVar(&cv_lookbackmom); - CV_RegisterVar(&cv_driftsparkpulse); CV_RegisterVar(&cv_gravstretch); CV_RegisterVar(&cv_sloperoll); From f3d8b2b3d1928fed5615a2d8720777eeb433c053 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 23 Mar 2025 18:15:06 +0100 Subject: [PATCH 045/350] add player blendeffects to menu + change when they apply most of them now apply during sneakerboost sparkles may also get add blendmode when you go really fast with them (like the speedlines) --- src/g_game.h | 2 ++ src/k_kart.c | 17 ++++++++--------- src/m_menu.c | 22 +++++++++++++--------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/g_game.h b/src/g_game.h index 7b8e73175..1ac5323f5 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -183,6 +183,8 @@ extern consvar_t cv_sloperolldist; extern consvar_t cv_sparkroll; extern consvar_t cv_spinoutroll; +extern consvar_t cv_playerblendeffects; + extern consvar_t cv_cechotoggle; #ifndef NONET diff --git a/src/k_kart.c b/src/k_kart.c index 73025b24c..8bf9c6abf 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -117,7 +117,7 @@ CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; consvar_t cv_newspeedometer = {"newspeedometer", "Default", CV_SAVE, speedo_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_battlespeedo = {"battlespeedo", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // toggle for showing the speedometer in battlemode -consvar_t cv_blendeffects = {"testblendeffects", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_playerblendeffects = {"playerblendeffects", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // funn-E streeetch static CV_PossibleValue_t stretchfactor_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}}; @@ -241,6 +241,7 @@ consvar_t cv_smallnametags = {"kartnametagsmall", "Off", CV_SAVE, nametagsize_co consvar_t cv_nametagscore = {"kartnametagscore", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_shownametagspectator = {"kartshownametagspectator", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +static boolean K_SpeedLinesShouldBlend(player_t *player); // SOME IMPORTANT VARIABLES DEFINED IN DOOMDEF.H: // gamespeed is cc (0 for easy, 1 for normal, 2 for hard) @@ -767,8 +768,6 @@ boolean K_UseColorHud(void) return (cv_colorizedhud.value && clr_hud); } -extern consvar_t cv_blendeffects; - //} //{ SRB2kart Net Variables @@ -899,7 +898,7 @@ void K_RegisterClientKartStuff(void) CV_RegisterVar(&cv_stagetitle); - CV_RegisterVar(&cv_blendeffects); + CV_RegisterVar(&cv_playerblendeffects); // Colourized HUD CV_RegisterVar(&cv_colorizedhud); @@ -1701,7 +1700,7 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid) else fx->eflags &= ~MFE_VERTICALFLIP; - if (cv_blendeffects.value) + if (cv_playerblendeffects.value) fx->blendmode = AST_ADD; P_SetScale(fx, mobj1->scale); @@ -3347,7 +3346,7 @@ skipground: // idk im sleepy P_SetMobjState(spark, S_DRIFTSPARK_A1); } - if (cv_blendeffects.value) + if (cv_playerblendeffects.value && player->kartstuff[k_sneakertimer]) spark->blendmode = AST_ADD; K_MatchGenericExtraFlags(spark, player->mo); @@ -3685,7 +3684,7 @@ void K_SpawnBoostTrail(player_t *player) { flame->colorized = true; flame->color = player->skincolor; - if (cv_blendeffects.value) + if (cv_playerblendeffects.value && player->kartstuff[k_sneakertimer]) flame->blendmode = AST_ADD; } @@ -3739,7 +3738,7 @@ void K_SpawnSparkleTrail(mobj_t *mo) P_SetScale(sparkle, mo->scale); sparkle->color = mo->color; - if (mo->player && cv_blendeffects.value) + if (cv_playerblendeffects.value && mo->player && K_SpeedLinesShouldBlend(mo->player)) sparkle->blendmode = AST_ADD; } @@ -5493,7 +5492,7 @@ static boolean K_SpeedLinesShouldBlend(player_t *player) { fixed_t percentspeed = 0; - if (!cv_blendeffects.value) + if (!cv_playerblendeffects.value) return false; if (!player->mo) diff --git a/src/m_menu.c b/src/m_menu.c index e96d922de..1c59aad1a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2247,20 +2247,22 @@ static menuitem_t OP_SaturnMenu[] = {IT_STRING | IT_CVAR, NULL, "Colourized Speedlines", &cv_coloredspeedlines, 30}, {IT_STRING | IT_CVAR, NULL, "Colourized Sneakertrails", &cv_coloredsneakertrail, 35}, - {IT_STRING | IT_CVAR, NULL, "Bananadrag Jitter", &cv_bananajitter, 45}, + {IT_STRING | IT_CVAR, NULL, "Player Blendeffects", &cv_playerblendeffects, 45}, - {IT_STRING | IT_CVAR, NULL, "Midair Driftsparks", &cv_airsparks, 55}, + {IT_STRING | IT_CVAR, NULL, "Bananadrag Jitter", &cv_bananajitter, 55}, - {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 65}, - {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 75}, + {IT_STRING | IT_CVAR, NULL, "Midair Driftsparks", &cv_airsparks, 65}, - {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 80}, + {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 75}, + {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 85}, - {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 90}, + {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 90}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 100}, - {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 105}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 115}, // uwu + {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 100}, + + {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 110}, + {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 115}, + {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 125}, // uwu }; static const char* OP_SaturnTooltips[] = @@ -2270,6 +2272,7 @@ static const char* OP_SaturnTooltips[] = "How much speen do you want?", "Colourize the speedlines in your skincolor if you go fast enough!", "Colourize the sneaker flame trails in your skincolor!", + "Enables blending effects for certain player effects when boosting.", "Makes bananas and other items jump and jitter\nwhen dragged behind.", "Keep your driftsparks going while in air.", "Show Localskin Menus.", @@ -2288,6 +2291,7 @@ enum sm_skinselspeed, sm_colorlines, sm_colorflames, + sm_blendeffects, sm_bananjumpy, sm_airsparks, sm_showlocalskin, From 3e80554a0e079c8746180ebe1ad6a939b6db6c3c Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 23 Mar 2025 18:17:49 +0100 Subject: [PATCH 046/350] k_throwdir already returns just -1, 0 and 1 --- src/p_tick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_tick.c b/src/p_tick.c index 2f4bc02a2..77a386a2d 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -467,7 +467,7 @@ void P_RunChaseCameras(void) if (cv_verticallook[i].value && leveltime > starttime && p->mo && p->kartstuff[k_respawn] == 0 && p->kartstuff[k_throwdir] != 0) { if (p->speed < 6 * p->mo->scale && abs(cam->dpad_y_held) < 2*TICRATE) - cam->dpad_y_held += intsign(p->kartstuff[k_throwdir]); + cam->dpad_y_held += p->kartstuff[k_throwdir]; } else cam->dpad_y_held = 0; From 4e13febeaf6533ee63e7d13e108c34d8f260e8e1 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 23 Mar 2025 18:24:46 +0100 Subject: [PATCH 047/350] this does not need be checked here --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 8bf9c6abf..41ad04939 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3684,7 +3684,7 @@ void K_SpawnBoostTrail(player_t *player) { flame->colorized = true; flame->color = player->skincolor; - if (cv_playerblendeffects.value && player->kartstuff[k_sneakertimer]) + if (cv_playerblendeffects.value) flame->blendmode = AST_ADD; } From d2838c2780054e287dd370c0eb2436d08aec769c Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 23 Mar 2025 18:31:38 +0100 Subject: [PATCH 048/350] i hate menus --- src/m_menu.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 1c59aad1a..de6be9197 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1891,12 +1891,11 @@ static menuitem_t OP_CamOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Field of View",&cv_fov, 30}, {IT_STRING | IT_CVAR, NULL, "Lagless Camera", &cv_laglesscam, 50}, - {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom, 60}, - {IT_STRING | IT_SUBMENU, NULL, "Player 1 Camera options...", &OP_Player1CamOptionsDef, 80}, - {IT_STRING | IT_SUBMENU, NULL, "Player 2 Camera options...", &OP_Player2CamOptionsDef, 90}, - {IT_STRING | IT_SUBMENU, NULL, "Player 3 Camera options...", &OP_Player3CamOptionsDef, 100}, - {IT_STRING | IT_SUBMENU, NULL, "Player 4 Camera options...", &OP_Player4CamOptionsDef, 110}, + {IT_STRING | IT_SUBMENU, NULL, "Player 1 Camera options...", &OP_Player1CamOptionsDef, 70}, + {IT_STRING | IT_SUBMENU, NULL, "Player 2 Camera options...", &OP_Player2CamOptionsDef, 80}, + {IT_STRING | IT_SUBMENU, NULL, "Player 3 Camera options...", &OP_Player3CamOptionsDef, 90}, + {IT_STRING | IT_SUBMENU, NULL, "Player 4 Camera options...", &OP_Player4CamOptionsDef, 100}, }; static const char* OP_CamOptionsTooltips[] = @@ -1919,13 +1918,13 @@ static menuitem_t OP_Player1CamOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[0], 60}, {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[0], 70}, - {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom[0], 80}, + {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom[0], 90}, - {IT_STRING | IT_CVAR, NULL, "Camera Vertical Look", &cv_verticallook[0], 90}, + {IT_STRING | IT_CVAR, NULL, "Camera Vertical Look", &cv_verticallook[0], 100}, - {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[0], 90}, + {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[0], 120}, - {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[0], 105}, + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[0], 135}, }; static menuitem_t OP_Player2CamOptionsMenu[] = @@ -1937,13 +1936,13 @@ static menuitem_t OP_Player2CamOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[1], 60}, {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[1], 70}, - {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom[1], 80}, + {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom[1], 90}, - {IT_STRING | IT_CVAR, NULL, "Camera Vertical Look", &cv_verticallook[1], 90}, + {IT_STRING | IT_CVAR, NULL, "Camera Vertical Look", &cv_verticallook[1], 100}, - {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[1], 90}, + {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[1], 120}, - {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[1], 105}, + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[1], 135}, }; static menuitem_t OP_Player3CamOptionsMenu[] = @@ -1955,13 +1954,13 @@ static menuitem_t OP_Player3CamOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[2], 60}, {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[2], 70}, - {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom[2], 80}, + {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom[2], 90}, - {IT_STRING | IT_CVAR, NULL, "Camera Vertical Look", &cv_verticallook[2], 90}, + {IT_STRING | IT_CVAR, NULL, "Camera Vertical Look", &cv_verticallook[2], 100}, - {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[2], 90}, + {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[2], 120}, - {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[2], 105}, + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[2], 135}, }; static menuitem_t OP_Player4CamOptionsMenu[] = @@ -1973,13 +1972,13 @@ static menuitem_t OP_Player4CamOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[3], 60}, {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[3], 70}, - {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom[3], 80}, + {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom[3], 90}, - {IT_STRING | IT_CVAR, NULL, "Camera Vertical Look", &cv_verticallook[3], 90}, + {IT_STRING | IT_CVAR, NULL, "Camera Vertical Look", &cv_verticallook[3], 100}, - {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[3], 100}, + {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[3], 120}, - {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[3], 115}, + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[3], 135}, }; static const char* OP_PlayerCamOptionsTooltips[] = From c6cc7d3d29fa180e34c9e108b5f1ef74fa1d45c3 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 24 Mar 2025 15:35:26 +0100 Subject: [PATCH 049/350] Replace all instances of XD_KICK with a SendKick function --- src/command.c | 6 +-- src/d_clisrv.c | 97 +++++++++------------------------- src/d_clisrv.h | 1 + src/d_netcmd.c | 121 +++++++------------------------------------ src/hu_stuff.c | 13 ++--- src/lua_consolelib.c | 6 +-- src/p_user.c | 6 +-- 7 files changed, 51 insertions(+), 199 deletions(-) diff --git a/src/command.c b/src/command.c index fa84626fb..eb38a0f6a 100644 --- a/src/command.c +++ b/src/command.c @@ -1493,11 +1493,7 @@ static void Got_NetVar(UINT8 **p, INT32 playernum) if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } diff --git a/src/d_clisrv.c b/src/d_clisrv.c index fb4964122..94cca18ac 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -488,11 +488,7 @@ static void ExtraDataTicker(void) { if (server) { - UINT8 buf[3]; - - buf[0] = (UINT8)i; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(i, KICK_MSG_CON_FAIL); DEBFILE(va("player %d kicked [gametic=%u] reason as follows:\n", i, gametic)); } CONS_Alert(CONS_WARNING, M_GetText("Got unknown net command [%s]=%d (max %d)\n"), sizeu1(curpos - bufferstart), *curpos, bufferstart[0]); @@ -544,6 +540,15 @@ ticcmd_t *D_LocalTiccmd(UINT8 ss) return &localcmds[ss][0]; } +void SendKick(UINT8 playernum, UINT8 msg) +{ + UINT8 buf[2]; + + buf[0] = playernum; + buf[1] = msg; + SendNetXCmd(XD_KICK, &buf, 2); +} + // ----------------------------------------------------------------- // end of extra data function // ----------------------------------------------------------------- @@ -1117,10 +1122,7 @@ static void SV_SendResynch(INT32 node) if (resynch_score[node] > (unsigned)cv_resynchattempts.value*250) { - UINT8 buf[2]; - buf[0] = (UINT8)nodetoplayer[node]; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(nodetoplayer[node], KICK_MSG_CON_FAIL); resynch_score[node] = 0; } } @@ -4432,11 +4434,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal add player command received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -4520,11 +4518,7 @@ static void Got_RemovePlayer(UINT8 **p, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal remove player command received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -4631,14 +4625,10 @@ void CL_AddSplitscreenPlayer(void) void CL_RemoveSplitscreenPlayer(UINT8 p) { - UINT8 buf[2]; - if (cl_mode != CL_CONNECTED) return; - buf[0] = p; - buf[1] = KICK_MSG_PLAYER_QUIT; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(p, KICK_MSG_PLAYER_QUIT); } // is there a game running @@ -5263,13 +5253,8 @@ static boolean CheckForSpeedHacks(UINT8 p) || netcmds[maketic%TICQUEUE][p].sidemove > MAXPLMOVE || netcmds[maketic%TICQUEUE][p].sidemove < -MAXPLMOVE || netcmds[maketic%TICQUEUE][p].driftturn > KART_FULLTURN || netcmds[maketic%TICQUEUE][p].driftturn < -KART_FULLTURN) { - char buf[2]; CONS_Alert(CONS_WARNING, M_GetText("Illegal movement value received from node %d\n"), playernode[p]); - //D_Clearticcmd(k); - - buf[0] = (char)p; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(p, KICK_MSG_CON_FAIL); return true; } @@ -5482,11 +5467,7 @@ static void HandlePacketFromPlayer(SINT8 node) } else { - UINT8 buf[3]; - - buf[0] = (UINT8)netconsole; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(netconsole, KICK_MSG_CON_FAIL); DEBFILE(va("player %d kicked (synch failure) [%u] %d!=%d\n", netconsole, realstart, consistancy[realstart%TICQUEUE], SHORT(netbuffer->u.clientpak.consistancy))); @@ -5517,11 +5498,7 @@ static void HandlePacketFromPlayer(SINT8 node) } else { - UINT8 buf[3]; - - buf[0] = (UINT8)netconsole; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(netconsole, KICK_MSG_CON_FAIL); DEBFILE(va("player %d kicked (synch failure) [%u] %d!=%d\n", netconsole, realstart, consistancy[realstart%TICQUEUE], SHORT(netbuffer->u.clientpak.consistancy))); @@ -5632,13 +5609,7 @@ static void HandlePacketFromPlayer(SINT8 node) nodewaiting[node] = 0; if (netconsole != -1 && playeringame[netconsole]) { - UINT8 buf[2]; - buf[0] = (UINT8)netconsole; - if (netbuffer->packettype == PT_NODETIMEOUT) - buf[1] = KICK_MSG_TIMEOUT; - else - buf[1] = KICK_MSG_PLAYER_QUIT; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(netconsole, (netbuffer->packettype == PT_NODETIMEOUT) ? KICK_MSG_TIMEOUT : KICK_MSG_PLAYER_QUIT); } Net_CloseConnection(node); nodeingame[node] = false; @@ -5652,10 +5623,7 @@ static void HandlePacketFromPlayer(SINT8 node) if (server) { - UINT8 buf[2]; - buf[0] = (UINT8)node; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(node, KICK_MSG_CON_FAIL); } break; @@ -5677,10 +5645,7 @@ static void HandlePacketFromPlayer(SINT8 node) if (server) { - UINT8 buf[2]; - buf[0] = (UINT8)node; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(node, KICK_MSG_CON_FAIL); } break; @@ -5744,10 +5709,7 @@ static void HandlePacketFromPlayer(SINT8 node) if (server) { - char buf[2]; - buf[0] = (char)node; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(node, KICK_MSG_CON_FAIL); } break; @@ -5763,10 +5725,7 @@ static void HandlePacketFromPlayer(SINT8 node) if (server) { - char buf[2]; - buf[0] = (char)node; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(node, KICK_MSG_CON_FAIL); } break; @@ -5794,10 +5753,7 @@ static void HandlePacketFromPlayer(SINT8 node) if (server) { - UINT8 buf[2]; - buf[0] = (UINT8)node; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(node, KICK_MSG_CON_FAIL); } break; @@ -6594,8 +6550,6 @@ static inline void PingUpdate(void) UINT8 minimumkicklevel = (nonlaggers > 0) ? PINGKICK_LIMIT : PINGKICK_TICQUEUE; for (i = 0; i < MAXPLAYERS; i++) { - char buf[2]; - if (!playeringame[i] || pingkick[i] < minimumkicklevel) continue; @@ -6607,10 +6561,7 @@ static inline void PingUpdate(void) } pingtimeout[i] = 0; - - buf[0] = (char)i; - buf[1] = KICK_MSG_PING_HIGH; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(i, KICK_MSG_PING_HIGH); } } } diff --git a/src/d_clisrv.h b/src/d_clisrv.h index d8a1acc22..06ff4af9b 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -616,6 +616,7 @@ void D_ClientServerInit(void); void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(UINT8 **p, INT32 playernum)); void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_t nparam); #define SendNetXCmd(id, param, nparam) SendNetXCmdForPlayer(0, id, param, nparam) // Shortcut for P1 +void SendKick(UINT8 playernum, UINT8 msg); // Create any new ticcmds and broadcast to other players. void NetKeepAlive(void); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 0639dd00d..fd97b0259 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1432,11 +1432,7 @@ static void SetPlayerName(INT32 playernum, char *newname) CONS_Printf(M_GetText("Player %d sent a bad name change\n"), playernum+1); if (server && netgame) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } } } @@ -2030,12 +2026,8 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) if (kick) { - UINT8 buf[2]; CONS_Alert(CONS_WARNING, M_GetText("Illegal color change received from %s (team: %d), color: %d)\n"), player_names[playernum], p->ctfteam, p->skincolor); - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); return; } } @@ -2916,11 +2908,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal map change received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -3035,11 +3023,7 @@ static void Got_Pause(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal pause command received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -3153,11 +3137,7 @@ static void Got_Respawn(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal respawn command received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -3227,11 +3207,7 @@ static void Got_Clearscores(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal clear scores command received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -3750,11 +3726,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal team change received from player %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } } @@ -3765,11 +3737,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal team change received from player %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -3803,11 +3771,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal team change received from player %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } } return; @@ -3856,12 +3820,8 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) if (server && ((NetPacket.packet.newteam < 0 || NetPacket.packet.newteam > 3) || error)) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; CONS_Alert(CONS_WARNING, M_GetText("Illegal team change received from player %s\n"), player_names[playernum]); - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } //Safety first! @@ -4230,11 +4190,7 @@ static void Got_Verification(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal verification received from %s (serverplayer is %s)\n"), player_names[playernum], player_names[serverplayer]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -4286,11 +4242,7 @@ static void Got_Removal(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal demotion received from %s (serverplayer is %s)\n"), player_names[playernum], player_names[serverplayer]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -4366,11 +4318,7 @@ static void Got_MotD_f(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal motd change received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } Z_Free(mymotd); @@ -4429,11 +4377,7 @@ static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal runsoc command received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -4742,13 +4686,8 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) if ((playernum != serverplayer && !IsPlayerAdmin(playernum)) || kick) { - UINT8 buf[2]; - CONS_Alert(CONS_WARNING, M_GetText("Illegal addfile command received from %s\n"), player_names[playernum]); - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); return; } @@ -4797,11 +4736,7 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal addfile command received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -5611,11 +5546,7 @@ static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal exitlevel command received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -5633,11 +5564,7 @@ static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal vote setup received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -5698,11 +5625,7 @@ static void Got_PickVotecmd(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal vote setup received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -6338,11 +6261,7 @@ void Got_DiscordInfo(UINT8 **p, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal Discord info command received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 8ffcc3743..1142fd637 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -914,12 +914,9 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } + return; } @@ -934,11 +931,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal say command received from %s containing invalid characters\n"), player_names[playernum]); if (server) { - char buf[2]; - - buf[0] = (char)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 12de7fd54..4ac6fb898 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -94,11 +94,7 @@ deny: CONS_Alert(CONS_WARNING, M_GetText("Illegal lua command received from %s\n"), player_names[playernum]); if (server) { - UINT8 bufn[2]; - - bufn[0] = (UINT8)playernum; - bufn[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &bufn, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } } diff --git a/src/p_user.c b/src/p_user.c index 79e2d2379..5d91a1e32 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4736,11 +4736,7 @@ void P_PlayerThink(player_t *player) && !P_IsLocalPlayer(player)) // P_IsMachineLocalPlayer for DRRR { // Send kick - UINT8 buf[2]; - - buf[0] = n; - buf[1] = KICK_MSG_GRIEF; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(n, KICK_MSG_GRIEF); } else { From 5d0a8ff6dd8e9622b5b65836c6d0421062668366 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 24 Mar 2025 16:23:16 +0100 Subject: [PATCH 050/350] Do not error out if we don't have a socket for an address family we have disabled from srb2 --- src/i_tcp.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index 54c446258..fd2d4a1e5 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -770,11 +770,12 @@ static inline ssize_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t *sockaddr return sendto(socket, (char *)&doomcom->data, doomcom->datalength, 0, &sockaddr->any, d); } -#define ALLOWEDERROR(x) ((x) == ECONNREFUSED || (x) == EWOULDBLOCK || (x) == EHOSTUNREACH || (x) == ENETUNREACH) +#define ALLOWEDERROR(x) ((x) == ECONNREFUSED || (x) == EWOULDBLOCK || (x) == EHOSTUNREACH || (x) == ENETUNREACH || (x) == EADDRNOTAVAIL) static void SOCK_Send(void) { ssize_t c = ERRSOCKET; + int e = -1; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once size_t i, j; if (!nodeconnected[doomcom->remotenode]) @@ -789,8 +790,12 @@ static void SOCK_Send(void) if (myfamily[i] == broadcastaddress[j].any.sa_family) { c = SOCK_SendToAddr(mysockets[i], &broadcastaddress[j]); - if (c == ERRSOCKET && !ALLOWEDERROR(errno)) - break; + if (c == ERRSOCKET) + { + e = errno; + if (!ALLOWEDERROR(e)) + break; + } } } } @@ -803,8 +808,12 @@ static void SOCK_Send(void) if (myfamily[i] == clientaddress[doomcom->remotenode].any.sa_family) { c = SOCK_SendToAddr(mysockets[i], &clientaddress[doomcom->remotenode]); - if (c == ERRSOCKET && !ALLOWEDERROR(errno)) - break; + if (c == ERRSOCKET) + { + e = errno; + if (!ALLOWEDERROR(e)) + break; + } } } return; @@ -812,11 +821,14 @@ static void SOCK_Send(void) else { c = SOCK_SendToAddr(nodesocket[doomcom->remotenode], &clientaddress[doomcom->remotenode]); + if (c == ERRSOCKET) + { + e = errno; + } } - if (c == ERRSOCKET) + if (c == ERRSOCKET && e != 0) // 0 means no socket for the address family was found { - int e = errno; // save error code so it can't be modified later if (!ALLOWEDERROR(e)) I_Error("SOCK_Send, error sending to node %d (%s) #%u: %s", doomcom->remotenode, SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e)); From dcc3b1294c0df9afdc99bb60408862353183efef Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 24 Mar 2025 16:30:05 +0100 Subject: [PATCH 051/350] remove the early returns in SOCK_Send othewise it may never error out when it should --- src/i_tcp.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index fd2d4a1e5..80a085a9c 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -775,17 +775,16 @@ static inline ssize_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t *sockaddr static void SOCK_Send(void) { ssize_t c = ERRSOCKET; - int e = -1; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once - size_t i, j; + int e = 0; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once if (!nodeconnected[doomcom->remotenode]) return; if (doomcom->remotenode == BROADCASTADDR) { - for (i = 0; i < mysocketses; i++) + for (size_t i = 0; i < mysocketses; i++) { - for (j = 0; j < broadcastaddresses; j++) + for (size_t j = 0; j < broadcastaddresses; j++) { if (myfamily[i] == broadcastaddress[j].any.sa_family) { @@ -799,11 +798,10 @@ static void SOCK_Send(void) } } } - return; } else if (nodesocket[doomcom->remotenode] == (SOCKET_TYPE)ERRSOCKET) { - for (i = 0; i < mysocketses; i++) + for (size_t i = 0; i < mysocketses; i++) { if (myfamily[i] == clientaddress[doomcom->remotenode].any.sa_family) { @@ -816,7 +814,6 @@ static void SOCK_Send(void) } } } - return; } else { @@ -830,10 +827,11 @@ static void SOCK_Send(void) if (c == ERRSOCKET && e != 0) // 0 means no socket for the address family was found { if (!ALLOWEDERROR(e)) - I_Error("SOCK_Send, error sending to node %d (%s) #%u: %s", doomcom->remotenode, + I_Error("SOCK_Send, error sending to node %d (%s) #%u, %s", doomcom->remotenode, SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e)); } } + #undef ALLOWEDERROR #endif //NONET From fc894d86313bcce48f01b39fd1d0be28a7adff75 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 24 Mar 2025 19:15:43 +0300 Subject: [PATCH 052/350] =?UTF-8?q?No=20need=20to=20FLOAT=5FTO=5FFIXED=20h?= =?UTF-8?q?ere=20:=D0=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 41ad04939..70f99a43a 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3408,7 +3408,7 @@ static void K_StretchPlayerGravity(player_t *p) fixed_t mos = FRACUNIT; fixed_t rzs = abs(p->mo->momz); fixed_t zspd = abs(rzs/mos); - fixed_t stretchScaleFactor = FixedDiv(FRACUNIT*60, FLOAT_TO_FIXED(cv_gravstretch.value)); + fixed_t stretchScaleFactor = FixedDiv(FRACUNIT*60, cv_gravstretch.value); fixed_t rzsDiv, slamDiv; fixed_t dxs = p->mo->realxscale; From 792806c20dbb470b6066581f3cef1042cbf5e96f Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 24 Mar 2025 19:15:43 +0300 Subject: [PATCH 053/350] =?UTF-8?q?No=20need=20to=20FLOAT=5FTO=5FFIXED=20h?= =?UTF-8?q?ere=20:=D0=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 41ad04939..70f99a43a 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3408,7 +3408,7 @@ static void K_StretchPlayerGravity(player_t *p) fixed_t mos = FRACUNIT; fixed_t rzs = abs(p->mo->momz); fixed_t zspd = abs(rzs/mos); - fixed_t stretchScaleFactor = FixedDiv(FRACUNIT*60, FLOAT_TO_FIXED(cv_gravstretch.value)); + fixed_t stretchScaleFactor = FixedDiv(FRACUNIT*60, cv_gravstretch.value); fixed_t rzsDiv, slamDiv; fixed_t dxs = p->mo->realxscale; From e369fbded4d13276e763715ac79b02f3c635a3f9 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 24 Mar 2025 18:20:16 +0100 Subject: [PATCH 054/350] toggle for saltyhop sloperoll behaviour --- src/g_game.h | 1 + src/k_kart.c | 5 ++++- src/m_menu.c | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/g_game.h b/src/g_game.h index 1ac5323f5..39b266b5a 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -173,6 +173,7 @@ extern consvar_t cv_saltyhop; extern consvar_t cv_saltyheight; extern consvar_t cv_saltyhopsfx; extern consvar_t cv_saltysquish; +extern consvar_t cv_saltyroll; extern consvar_t cv_driftsparkpulse; extern consvar_t cv_gravstretch; diff --git a/src/k_kart.c b/src/k_kart.c index 70f99a43a..eb9b81a38 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -147,6 +147,7 @@ consvar_t cv_saltyhopsfx = {"hardcodehopsfx", "On", CV_SAVE, CV_OnOff, NULL, 0, consvar_t cv_saltysquish = {"hardcodehopsquish", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t saltyheight_t[] = {{FRACUNIT/4, "MIN"}, {2*FRACUNIT, "MAX"}, {0, NULL}}; consvar_t cv_saltyheight = {"hardcodehopheight", "1", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, saltyheight_t, saltyheight_onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_saltyroll = {"hardcodehoproll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static void saltyhop_onchange(void) { @@ -936,6 +937,8 @@ void K_RegisterClientKartStuff(void) CV_RegisterVar(&cv_saltyhopsfx); CV_RegisterVar(&cv_saltysquish); CV_RegisterVar(&cv_saltyheight); + CV_RegisterVar(&cv_saltyroll); + CV_RegisterVar(&cv_slamsound); CV_RegisterVar(&cv_lessflicker); @@ -3574,7 +3577,7 @@ boolean K_ShouldSlopeRoll(mobj_t *mobj) return false; // seeing a character rotate mid-hop looks really janky - if (mobj->player && mobj->player->mo->salty_jump) + if (!cv_saltyroll.value && mobj->player && mobj->player->mo->salty_jump) return false; return K_CheckSlopeRollDist(mobj); diff --git a/src/m_menu.c b/src/m_menu.c index de6be9197..46692943c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2319,6 +2319,7 @@ static menuitem_t OP_PlayerDistortMenu[] = {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saltyhop Height", &cv_saltyheight, 135}, {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 150}, {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 165}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Roll", &cv_saltyroll, 180}, }; static const char* OP_PlayerDistortTooltips[] = @@ -2335,6 +2336,7 @@ static const char* OP_PlayerDistortTooltips[] = "Jump Height for Kart hopping.", "Player hop sound effect.", "Player hop squash and stretch.", + "Should the player rotation be kept during player hop.", }; enum @@ -2351,6 +2353,7 @@ enum saltheight, saltsound, saltsquishy, + saltroll, }; static menuitem_t OP_SaturnHudMenu[] = From aea03cc2b769b12ad8fed6c4a8f5e52e11bc8444 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 24 Mar 2025 18:22:07 +0100 Subject: [PATCH 055/350] grey saltroll out in menu if sloperoll disabled --- src/m_menu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 46692943c..096f6e141 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3506,8 +3506,16 @@ void Moviemode_option_Onchange(void) void PDistort_menu_Onchange(void) { - OP_PlayerDistortMenu[slrotatedist].status = - (cv_sloperoll.value) ? IT_STRING | IT_CVAR : IT_GRAYEDOUT; + if (cv_sloperoll.value) + { + OP_PlayerDistortMenu[slrotatedist].status = IT_STRING | IT_CVAR; + OP_PlayerDistortMenu[saltroll].status = IT_STRING | IT_CVAR; + } + else + { + OP_PlayerDistortMenu[slrotatedist].status = IT_GRAYEDOUT; + OP_PlayerDistortMenu[saltroll].status = IT_GRAYEDOUT; + } } void Bird_menu_Onchange(void) From c425400480240e0c9856ef94f8de2086ab68094e Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 24 Mar 2025 19:18:34 +0100 Subject: [PATCH 056/350] Revert "clean up some net stuff" This reverts commit f8903e7ce7a6dc0a4184ef743ed684a2164a3cea. --- src/d_net.c | 27 ++++++++++++++++++++++++++- src/d_netfil.c | 1 + src/i_net.h | 20 ++++++++++++++++++++ src/i_tcp.c | 6 ++++++ 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/d_net.c b/src/d_net.c index d6b0e2f80..f05cc407f 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -64,6 +64,9 @@ static doomdata_t reboundstore[MAXREBOUND]; static INT16 reboundsize[MAXREBOUND]; static INT32 rebound_head, rebound_tail; +/// \brief bandwith of netgame +INT32 net_bandwidth; + /// \brief max length per packet INT16 hardware_MAXPACKETLENGTH; @@ -1264,7 +1267,10 @@ void D_SetDoomcom(void) { if (doomcom) return; doomcom = Z_Calloc(sizeof (doomcom_t), PU_STATIC, NULL); + doomcom->id = DOOMCOM_ID; doomcom->numslots = doomcom->numnodes = 1; + doomcom->gametype = 0; + doomcom->consoleplayer = 0; doomcom->extratics = 0; } @@ -1288,6 +1294,7 @@ boolean D_CheckNetGame(void) I_NetMakeNodewPort = NULL; hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; + net_bandwidth = 30000; // I_InitNetwork sets doomcom and netgame // check and initialize the network driver multiplayer = false; @@ -1307,6 +1314,7 @@ boolean D_CheckNetGame(void) server = true; // WTF? server always true??? // no! The deault mode is server. Client is set elsewhere // when the client executes connect command. + doomcom->ticdup = 1; if (M_CheckParm("-extratic")) { @@ -1317,6 +1325,21 @@ boolean D_CheckNetGame(void) CONS_Printf(M_GetText("Set extratics to %d\n"), doomcom->extratics); } + if (M_CheckParm("-bandwidth")) + { + if (M_IsNextParm()) + { + net_bandwidth = atoi(M_GetNextParm()); + if (net_bandwidth < 1000) + net_bandwidth = 1000; + if (net_bandwidth > 100000) + hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; + CONS_Printf(M_GetText("Network bandwidth set to %d\n"), net_bandwidth); + } + else + I_Error("usage: -bandwidth "); + } + software_MAXPACKETLENGTH = hardware_MAXPACKETLENGTH; if (M_CheckParm("-packetsize")) { @@ -1336,6 +1359,8 @@ boolean D_CheckNetGame(void) if (netgame) multiplayer = true; + if (doomcom->id != DOOMCOM_ID) + I_Error("Doomcom buffer invalid!"); if (doomcom->numnodes > MAXNETNODES) I_Error("Too many nodes (%d), max:%d", doomcom->numnodes, MAXNETNODES); @@ -1348,7 +1373,7 @@ boolean D_CheckNetGame(void) if (M_CheckParm("-debugfile")) { char filename[21]; - INT32 k = consoleplayer - 1; + INT32 k = doomcom->consoleplayer - 1; if (M_IsNextParm()) k = atoi(M_GetNextParm()) - 1; while (!debugfile && k < MAXPLAYERS) diff --git a/src/d_netfil.c b/src/d_netfil.c index 4a648b176..9cdffab2e 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -837,6 +837,7 @@ void SV_FileSendTicker(void) netbuffer->packettype = PT_FILEFRAGMENT; + // (((sendbytes-nowsentbyte)*TICRATE)/(I_GetTime()-starttime)<(UINT32)net_bandwidth) while (packetsent-- && filestosend != 0) { for (i = currentnode, j = 0; j < MAXNETNODES; diff --git a/src/i_net.h b/src/i_net.h index 504936a3b..931392580 100644 --- a/src/i_net.h +++ b/src/i_net.h @@ -34,6 +34,7 @@ #define NO_BAN_TIME (time_t)(-1) extern INT16 hardware_MAXPACKETLENGTH; +extern INT32 net_bandwidth; // in byte/s #if defined(_MSC_VER) #pragma pack(1) @@ -41,17 +42,36 @@ extern INT16 hardware_MAXPACKETLENGTH; typedef struct { + /// Supposed to be DOOMCOM_ID + INT32 id; + + /// SRB2 executes an INT32 to execute commands. + INT16 intnum; + /// Communication between SRB2 and the driver. + /// Is CMD_SEND or CMD_GET. + INT16 command; /// Is dest for send, set by get (-1 = no packet). INT16 remotenode; + /// Number of bytes in doomdata to be sent INT16 datalength; /// Info common to all nodes. /// Console is always node 0. INT16 numnodes; + /// Flag: 1 = no duplication, 2-5 = dup for slow nets. + INT16 ticdup; /// Flag: 1 = send a backup tic in every packet. INT16 extratics; + /// kind of game + INT16 gametype; + /// Flag: -1 = new game, 0-5 = load savegame + INT16 savegame; + /// currect map + INT16 map; + /// Info specific to this node. + INT16 consoleplayer; /// Number of "slots": the highest player number in use plus one. INT16 numslots; diff --git a/src/i_tcp.c b/src/i_tcp.c index 54c446258..add396730 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -1642,6 +1642,8 @@ boolean I_InitTcpNetwork(void) // FIXME: for dedicated server, numnodes needs to be set to 0 upon start if (dedicated) doomcom->numnodes = 0; +/* else if (M_IsNextParm()) + doomcom->numnodes = (INT16)atoi(M_GetNextParm());*/ else doomcom->numnodes = 1; @@ -1655,6 +1657,7 @@ boolean I_InitTcpNetwork(void) // FIXME: // ??? and now ? // server on a big modem ??? 4*isdn + net_bandwidth = 16000; hardware_MAXPACKETLENGTH = INETPACKETLENGTH; ret = true; @@ -1681,6 +1684,7 @@ boolean I_InitTcpNetwork(void) // so we're on a LAN COM_BufAddText("connect any\n"); + net_bandwidth = 800000; hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; } } @@ -1705,6 +1709,8 @@ boolean I_InitTcpNetwork(void) { // so we're on a LAN COM_BufAddText("connect any\n"); + + net_bandwidth = 800000; hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; } } From f7e5f9f5b6534dbc6c1055b6f000601d2d622d98 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 24 Mar 2025 19:21:26 +0100 Subject: [PATCH 057/350] delet this --- src/d_net.c | 20 +------------------- src/i_net.h | 1 - src/i_tcp.c | 4 ---- 3 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/d_net.c b/src/d_net.c index f05cc407f..820da034a 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -64,9 +64,6 @@ static doomdata_t reboundstore[MAXREBOUND]; static INT16 reboundsize[MAXREBOUND]; static INT32 rebound_head, rebound_tail; -/// \brief bandwith of netgame -INT32 net_bandwidth; - /// \brief max length per packet INT16 hardware_MAXPACKETLENGTH; @@ -1294,7 +1291,7 @@ boolean D_CheckNetGame(void) I_NetMakeNodewPort = NULL; hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; - net_bandwidth = 30000; + // I_InitNetwork sets doomcom and netgame // check and initialize the network driver multiplayer = false; @@ -1325,21 +1322,6 @@ boolean D_CheckNetGame(void) CONS_Printf(M_GetText("Set extratics to %d\n"), doomcom->extratics); } - if (M_CheckParm("-bandwidth")) - { - if (M_IsNextParm()) - { - net_bandwidth = atoi(M_GetNextParm()); - if (net_bandwidth < 1000) - net_bandwidth = 1000; - if (net_bandwidth > 100000) - hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; - CONS_Printf(M_GetText("Network bandwidth set to %d\n"), net_bandwidth); - } - else - I_Error("usage: -bandwidth "); - } - software_MAXPACKETLENGTH = hardware_MAXPACKETLENGTH; if (M_CheckParm("-packetsize")) { diff --git a/src/i_net.h b/src/i_net.h index 931392580..098a6563d 100644 --- a/src/i_net.h +++ b/src/i_net.h @@ -34,7 +34,6 @@ #define NO_BAN_TIME (time_t)(-1) extern INT16 hardware_MAXPACKETLENGTH; -extern INT32 net_bandwidth; // in byte/s #if defined(_MSC_VER) #pragma pack(1) diff --git a/src/i_tcp.c b/src/i_tcp.c index add396730..2b7af0e12 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -1657,7 +1657,6 @@ boolean I_InitTcpNetwork(void) // FIXME: // ??? and now ? // server on a big modem ??? 4*isdn - net_bandwidth = 16000; hardware_MAXPACKETLENGTH = INETPACKETLENGTH; ret = true; @@ -1684,7 +1683,6 @@ boolean I_InitTcpNetwork(void) // so we're on a LAN COM_BufAddText("connect any\n"); - net_bandwidth = 800000; hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; } } @@ -1709,8 +1707,6 @@ boolean I_InitTcpNetwork(void) { // so we're on a LAN COM_BufAddText("connect any\n"); - - net_bandwidth = 800000; hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; } } From ea3974d47e2ca6c6c951c20cda5e34b6ca7c3049 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 24 Mar 2025 19:18:34 +0100 Subject: [PATCH 058/350] Revert "clean up some net stuff" This reverts commit f8903e7ce7a6dc0a4184ef743ed684a2164a3cea. --- src/d_net.c | 27 ++++++++++++++++++++++++++- src/d_netfil.c | 1 + src/i_net.h | 20 ++++++++++++++++++++ src/i_tcp.c | 6 ++++++ 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/d_net.c b/src/d_net.c index d6b0e2f80..f05cc407f 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -64,6 +64,9 @@ static doomdata_t reboundstore[MAXREBOUND]; static INT16 reboundsize[MAXREBOUND]; static INT32 rebound_head, rebound_tail; +/// \brief bandwith of netgame +INT32 net_bandwidth; + /// \brief max length per packet INT16 hardware_MAXPACKETLENGTH; @@ -1264,7 +1267,10 @@ void D_SetDoomcom(void) { if (doomcom) return; doomcom = Z_Calloc(sizeof (doomcom_t), PU_STATIC, NULL); + doomcom->id = DOOMCOM_ID; doomcom->numslots = doomcom->numnodes = 1; + doomcom->gametype = 0; + doomcom->consoleplayer = 0; doomcom->extratics = 0; } @@ -1288,6 +1294,7 @@ boolean D_CheckNetGame(void) I_NetMakeNodewPort = NULL; hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; + net_bandwidth = 30000; // I_InitNetwork sets doomcom and netgame // check and initialize the network driver multiplayer = false; @@ -1307,6 +1314,7 @@ boolean D_CheckNetGame(void) server = true; // WTF? server always true??? // no! The deault mode is server. Client is set elsewhere // when the client executes connect command. + doomcom->ticdup = 1; if (M_CheckParm("-extratic")) { @@ -1317,6 +1325,21 @@ boolean D_CheckNetGame(void) CONS_Printf(M_GetText("Set extratics to %d\n"), doomcom->extratics); } + if (M_CheckParm("-bandwidth")) + { + if (M_IsNextParm()) + { + net_bandwidth = atoi(M_GetNextParm()); + if (net_bandwidth < 1000) + net_bandwidth = 1000; + if (net_bandwidth > 100000) + hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; + CONS_Printf(M_GetText("Network bandwidth set to %d\n"), net_bandwidth); + } + else + I_Error("usage: -bandwidth "); + } + software_MAXPACKETLENGTH = hardware_MAXPACKETLENGTH; if (M_CheckParm("-packetsize")) { @@ -1336,6 +1359,8 @@ boolean D_CheckNetGame(void) if (netgame) multiplayer = true; + if (doomcom->id != DOOMCOM_ID) + I_Error("Doomcom buffer invalid!"); if (doomcom->numnodes > MAXNETNODES) I_Error("Too many nodes (%d), max:%d", doomcom->numnodes, MAXNETNODES); @@ -1348,7 +1373,7 @@ boolean D_CheckNetGame(void) if (M_CheckParm("-debugfile")) { char filename[21]; - INT32 k = consoleplayer - 1; + INT32 k = doomcom->consoleplayer - 1; if (M_IsNextParm()) k = atoi(M_GetNextParm()) - 1; while (!debugfile && k < MAXPLAYERS) diff --git a/src/d_netfil.c b/src/d_netfil.c index e488e083e..223a74066 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -837,6 +837,7 @@ void SV_FileSendTicker(void) netbuffer->packettype = PT_FILEFRAGMENT; + // (((sendbytes-nowsentbyte)*TICRATE)/(I_GetTime()-starttime)<(UINT32)net_bandwidth) while (packetsent-- && filestosend != 0) { for (i = currentnode, j = 0; j < MAXNETNODES; diff --git a/src/i_net.h b/src/i_net.h index 504936a3b..931392580 100644 --- a/src/i_net.h +++ b/src/i_net.h @@ -34,6 +34,7 @@ #define NO_BAN_TIME (time_t)(-1) extern INT16 hardware_MAXPACKETLENGTH; +extern INT32 net_bandwidth; // in byte/s #if defined(_MSC_VER) #pragma pack(1) @@ -41,17 +42,36 @@ extern INT16 hardware_MAXPACKETLENGTH; typedef struct { + /// Supposed to be DOOMCOM_ID + INT32 id; + + /// SRB2 executes an INT32 to execute commands. + INT16 intnum; + /// Communication between SRB2 and the driver. + /// Is CMD_SEND or CMD_GET. + INT16 command; /// Is dest for send, set by get (-1 = no packet). INT16 remotenode; + /// Number of bytes in doomdata to be sent INT16 datalength; /// Info common to all nodes. /// Console is always node 0. INT16 numnodes; + /// Flag: 1 = no duplication, 2-5 = dup for slow nets. + INT16 ticdup; /// Flag: 1 = send a backup tic in every packet. INT16 extratics; + /// kind of game + INT16 gametype; + /// Flag: -1 = new game, 0-5 = load savegame + INT16 savegame; + /// currect map + INT16 map; + /// Info specific to this node. + INT16 consoleplayer; /// Number of "slots": the highest player number in use plus one. INT16 numslots; diff --git a/src/i_tcp.c b/src/i_tcp.c index 54c446258..add396730 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -1642,6 +1642,8 @@ boolean I_InitTcpNetwork(void) // FIXME: for dedicated server, numnodes needs to be set to 0 upon start if (dedicated) doomcom->numnodes = 0; +/* else if (M_IsNextParm()) + doomcom->numnodes = (INT16)atoi(M_GetNextParm());*/ else doomcom->numnodes = 1; @@ -1655,6 +1657,7 @@ boolean I_InitTcpNetwork(void) // FIXME: // ??? and now ? // server on a big modem ??? 4*isdn + net_bandwidth = 16000; hardware_MAXPACKETLENGTH = INETPACKETLENGTH; ret = true; @@ -1681,6 +1684,7 @@ boolean I_InitTcpNetwork(void) // so we're on a LAN COM_BufAddText("connect any\n"); + net_bandwidth = 800000; hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; } } @@ -1705,6 +1709,8 @@ boolean I_InitTcpNetwork(void) { // so we're on a LAN COM_BufAddText("connect any\n"); + + net_bandwidth = 800000; hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; } } From 3b43df0214d89dae1e3d1f0f0f442b1433898c83 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 24 Mar 2025 19:21:26 +0100 Subject: [PATCH 059/350] delet this --- src/d_net.c | 20 +------------------- src/i_net.h | 1 - src/i_tcp.c | 4 ---- 3 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/d_net.c b/src/d_net.c index f05cc407f..820da034a 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -64,9 +64,6 @@ static doomdata_t reboundstore[MAXREBOUND]; static INT16 reboundsize[MAXREBOUND]; static INT32 rebound_head, rebound_tail; -/// \brief bandwith of netgame -INT32 net_bandwidth; - /// \brief max length per packet INT16 hardware_MAXPACKETLENGTH; @@ -1294,7 +1291,7 @@ boolean D_CheckNetGame(void) I_NetMakeNodewPort = NULL; hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; - net_bandwidth = 30000; + // I_InitNetwork sets doomcom and netgame // check and initialize the network driver multiplayer = false; @@ -1325,21 +1322,6 @@ boolean D_CheckNetGame(void) CONS_Printf(M_GetText("Set extratics to %d\n"), doomcom->extratics); } - if (M_CheckParm("-bandwidth")) - { - if (M_IsNextParm()) - { - net_bandwidth = atoi(M_GetNextParm()); - if (net_bandwidth < 1000) - net_bandwidth = 1000; - if (net_bandwidth > 100000) - hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; - CONS_Printf(M_GetText("Network bandwidth set to %d\n"), net_bandwidth); - } - else - I_Error("usage: -bandwidth "); - } - software_MAXPACKETLENGTH = hardware_MAXPACKETLENGTH; if (M_CheckParm("-packetsize")) { diff --git a/src/i_net.h b/src/i_net.h index 931392580..098a6563d 100644 --- a/src/i_net.h +++ b/src/i_net.h @@ -34,7 +34,6 @@ #define NO_BAN_TIME (time_t)(-1) extern INT16 hardware_MAXPACKETLENGTH; -extern INT32 net_bandwidth; // in byte/s #if defined(_MSC_VER) #pragma pack(1) diff --git a/src/i_tcp.c b/src/i_tcp.c index add396730..2b7af0e12 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -1657,7 +1657,6 @@ boolean I_InitTcpNetwork(void) // FIXME: // ??? and now ? // server on a big modem ??? 4*isdn - net_bandwidth = 16000; hardware_MAXPACKETLENGTH = INETPACKETLENGTH; ret = true; @@ -1684,7 +1683,6 @@ boolean I_InitTcpNetwork(void) // so we're on a LAN COM_BufAddText("connect any\n"); - net_bandwidth = 800000; hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; } } @@ -1709,8 +1707,6 @@ boolean I_InitTcpNetwork(void) { // so we're on a LAN COM_BufAddText("connect any\n"); - - net_bandwidth = 800000; hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; } } From 3614efa965098c561ce7b743ce61033d0b314f35 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 24 Mar 2025 22:42:30 +0100 Subject: [PATCH 060/350] fix server lan discovery which just returned EINVAL and triggered the I_Error in SOCK_Send more information at: https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2219 --- src/i_tcp.c | 87 ++++++++++++++++++++----------------------------- src/sdl/i_net.c | 1 + 2 files changed, 36 insertions(+), 52 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index d9c5c22ad..b75a7413c 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -183,6 +183,8 @@ typedef unsigned long SOCKET_TYPE; #define ERRSOCKET (-1) #endif +#define IPV6_MULTICAST_ADDRESS "ff15::57e1:1a12" + #ifdef USE_WINSOCK1 typedef int socklen_t; #endif @@ -935,6 +937,24 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen return (SOCKET_TYPE)ERRSOCKET; } +#ifdef HAVE_IPV6 + if (family == AF_INET6) + { + // we need to set all of this *after* binding to an address! + if (memcmp(&straddr.ip6.sin6_addr, &in6addr_any, sizeof(in6addr_any)) == 0) //IN6_ARE_ADDR_EQUAL + { + struct ipv6_mreq maddr; + + inet_pton(AF_INET6, IPV6_MULTICAST_ADDRESS, &maddr.ipv6mr_multiaddr); + maddr.ipv6mr_interface = 0; + if (setsockopt(s, IPPROTO_IPV6, IPV6_JOIN_GROUP, (const char *)&maddr, sizeof(maddr)) != 0) + { + CONS_Alert(CONS_WARNING, M_GetText("Could not register multicast address\n")); + } + } + } +#endif + #ifdef FIONBIO // make it non blocking opt = true; @@ -1103,65 +1123,28 @@ static boolean UDP_Socket(void) // ip + udp packetheaderlength = 20 + 8; // for stats - hints.ai_family = AF_INET; - gaie = I_getaddrinfo("127.0.0.1", "0", &hints, &ai); - if (gaie == 0) - { - runp = ai; - while (runp != NULL && s < MAXNETNODES+1) - { - memcpy(&clientaddress[s], runp->ai_addr, runp->ai_addrlen); - s++; - runp = runp->ai_next; - } - I_freeaddrinfo(ai); - } - else - { - clientaddress[s].any.sa_family = AF_INET; - clientaddress[s].ip4.sin_port = htons(0); - clientaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_LOOPBACK); //GetLocalAddress(); // my own ip - s++; - } + clientaddress[s].any.sa_family = AF_INET; + clientaddress[s].ip4.sin_port = htons(0); + clientaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_LOOPBACK); //GetLocalAddress(); // my own ip + s++; s = 0; // setup broadcast adress to BROADCASTADDR entry - gaie = I_getaddrinfo("255.255.255.255", "0", &hints, &ai); - if (gaie == 0) - { - runp = ai; - while (runp != NULL && s < MAXNETNODES+1) - { - memcpy(&broadcastaddress[s], runp->ai_addr, runp->ai_addrlen); - s++; - runp = runp->ai_next; - } - I_freeaddrinfo(ai); - } - else - { - broadcastaddress[s].any.sa_family = AF_INET; - broadcastaddress[s].ip4.sin_port = htons(0); - broadcastaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_BROADCAST); - s++; - } + broadcastaddress[s].any.sa_family = AF_INET; + broadcastaddress[s].ip4.sin_port = htons(atoi(DEFAULTPORT)); + broadcastaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_BROADCAST); + s++; + #ifdef HAVE_IPV6 if (b_ipv6) { - hints.ai_family = AF_INET6; - gaie = I_getaddrinfo("ff02::1", "0", &hints, &ai); - if (gaie == 0) - { - runp = ai; - while (runp != NULL && s < MAXNETNODES+1) - { - memcpy(&broadcastaddress[s], runp->ai_addr, runp->ai_addrlen); - s++; - runp = runp->ai_next; - } - I_freeaddrinfo(ai); - } + broadcastaddress[s].any.sa_family = AF_INET6; + broadcastaddress[s].ip6.sin6_port = htons(atoi(DEFAULTPORT)); + broadcastaddress[s].ip6.sin6_flowinfo = 0; + inet_pton(AF_INET6, IPV6_MULTICAST_ADDRESS, &broadcastaddress[s].ip6.sin6_addr); + broadcastaddress[s].ip6.sin6_scope_id = 0; + s++; } #endif diff --git a/src/sdl/i_net.c b/src/sdl/i_net.c index ee4a34c13..9fcc1fd38 100644 --- a/src/sdl/i_net.c +++ b/src/sdl/i_net.c @@ -436,6 +436,7 @@ boolean I_InitNetwork(void) I_Error("-net not supported, use -server and -connect\n" "see docs for more\n"); } + return false; #endif } From 434048afade1d846da4ad1a3f81fb8821c242e15 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 24 Mar 2025 19:01:02 +0100 Subject: [PATCH 061/350] potentially fix "Received a file not requested" error in poor net conditions needs a bit of testing --- src/d_netfil.c | 6 +++++- src/d_netfil.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 9cdffab2e..fc03a6ab3 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -222,6 +222,7 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 fi for (i = firstfile; i < fileneedednum; i++) { fileneeded[i].status = FS_NOTCHECKED; // We haven't even started looking for the file yet + fileneeded[i].justdownloaded = false; filestatus = READUINT8(p); // The first byte is the file status fileneeded[i].willsend = (UINT8)(filestatus >> 4); fileneeded[i].totalsize = READUINT32(p); // The four next bytes are the file size @@ -238,6 +239,7 @@ void CL_PrepareDownloadSaveGame(const char *tmpsave) #endif fileneedednum = 1; fileneeded[0].status = FS_REQUESTED; + fileneeded[0].justdownloaded = false; fileneeded[0].totalsize = UINT32_MAX; fileneeded[0].file = NULL; memset(fileneeded[0].md5sum, 0, 16); @@ -999,6 +1001,7 @@ void Got_Filetxpak(void) { UINT32 pos = LONG(netbuffer->u.filetxpak.position); UINT16 size = SHORT(netbuffer->u.filetxpak.size); + // Use a special trick to know when the file is complete (not always used) // WARNING: file fragments can arrive out of order so don't stop yet! if (pos & 0x80000000) @@ -1018,6 +1021,7 @@ void Got_Filetxpak(void) fclose(file->file); file->file = NULL; file->status = FS_FOUND; + file->justdownloaded = true; CONS_Printf(M_GetText("Downloading %s...(done)\n"), filename); #ifndef NONET @@ -1026,7 +1030,7 @@ void Got_Filetxpak(void) #endif } } - else + else if (!file->justdownloaded) { const char *s; switch(file->status) diff --git a/src/d_netfil.h b/src/d_netfil.h index bd54b7661..a44c35139 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -45,6 +45,7 @@ typedef struct UINT32 currentsize; UINT32 totalsize; filestatus_t status; // The value returned by recsearch + boolean justdownloaded; // To prevent late fragments from causing an I_Error } fileneeded_t; extern INT32 fileneedednum; From d94b443ecaff523e43bbd660a13955bf3f6b3a33 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 25 Mar 2025 19:35:55 +0100 Subject: [PATCH 062/350] put all the "game focus" options into a seperate menu --- src/m_menu.c | 90 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 34 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 096f6e141..94b0bbe98 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -343,6 +343,8 @@ menu_t OP_SoundOptionsDef; menu_t OP_SoundAdvancedDef; //static void M_RestartAudio(void); +menu_t OP_FocusOptionsDef; + //Misc menu_t OP_DataOptionsDef, OP_ScreenshotOptionsDef, OP_EraseDataDef; menu_t OP_ProtocolDef; @@ -1142,22 +1144,23 @@ static menuitem_t OP_MainMenu[] = {IT_SUBMENU|IT_STRING, NULL, "Video Options...", &OP_VideoOptionsDef, 15}, {IT_SUBMENU|IT_STRING, NULL, "Sound Options...", &OP_SoundOptionsDef, 25}, + {IT_SUBMENU|IT_STRING, NULL, "Game Focus Options...", &OP_FocusOptionsDef, 35}, - {IT_SUBMENU|IT_STRING, NULL, "HUD Options...", &OP_HUDOptionsDef, 40}, - {IT_SUBMENU|IT_STRING, NULL, "Camera Options...", &OP_CamOptionsDef, 50}, - {IT_SUBMENU|IT_STRING, NULL, "Gameplay Options...", &OP_GameOptionsDef, 60}, - {IT_SUBMENU|IT_STRING, NULL, "Server Options...", &OP_ServerOptionsDef, 70}, + {IT_SUBMENU|IT_STRING, NULL, "HUD Options...", &OP_HUDOptionsDef, 50}, + {IT_SUBMENU|IT_STRING, NULL, "Camera Options...", &OP_CamOptionsDef, 60}, + {IT_SUBMENU|IT_STRING, NULL, "Gameplay Options...", &OP_GameOptionsDef, 70}, + {IT_SUBMENU|IT_STRING, NULL, "Server Options...", &OP_ServerOptionsDef, 80}, - {IT_SUBMENU|IT_STRING, NULL, "Data Options...", &OP_DataOptionsDef, 85}, - {IT_CALL|IT_STRING, NULL, "Custom Options...", M_CustomCvarMenu, 95}, + {IT_SUBMENU|IT_STRING, NULL, "Data Options...", &OP_DataOptionsDef, 95}, + {IT_CALL|IT_STRING, NULL, "Custom Options...", M_CustomCvarMenu, 105}, - {IT_CALL|IT_STRING, NULL, "Tricks & Secrets (F1)", M_Manual, 105}, - {IT_CALL|IT_STRING, NULL, "Play Credits", M_Credits, 115}, + {IT_CALL|IT_STRING, NULL, "Tricks & Secrets (F1)", M_Manual, 115}, + {IT_CALL|IT_STRING, NULL, "Play Credits", M_Credits, 125}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Options...", &OP_SaturnDef, 135}, + {IT_SUBMENU|IT_STRING, NULL, "Saturn Options...", &OP_SaturnDef, 145}, - {IT_SUBMENU|IT_STRING, NULL, "Bird...", &OP_BirdDef, 145}, - {IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 155}, + {IT_SUBMENU|IT_STRING, NULL, "Bird...", &OP_BirdDef, 155}, + {IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 165}, }; static menuitem_t OP_ControlsMenu[] = @@ -1673,9 +1676,7 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 105}, {IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 115}, - {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, - {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, - {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 145} + {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 125} #else {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 60}, @@ -1687,9 +1688,7 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 115}, {IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 125}, - {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 135}, - {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 145}, - {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 155} + {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 135} #endif }; @@ -1710,8 +1709,6 @@ static const char* OP_SoundTooltips[] = "Should the powerup warning be a sound effect or music?", "Testing sounds...", "Testing music...", - "Should the games music play while unfocused?", - "Should the games sound play while unfocused?", "Options for advanced sound settings.", }; @@ -1760,6 +1757,30 @@ static const char* OP_SoundAdvancedTooltips[] = "Size of the Audio Buffer\nreducing it will result in less sound latency\nbut may cause issues such as crackling or distorted Sound.", }; +static menuitem_t OP_FocusOptionsMenu[] = +{ + {IT_HEADER, NULL, "Game Focus Options", NULL, 0}, + + {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 30}, + {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 40}, + + {IT_STRING|IT_CVAR, NULL, "Pause Game While Unfocused", &cv_pauseifunfocused, 60}, + + {IT_STRING|IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 80}, + + {IT_STRING|IT_CVAR, NULL, "Hide mouse While Focused", &cv_alwaysgrabmouse, 100}, +}; + +static const char* OP_FocusOptionsTooltips[] = +{ + NULL, + "Should music play while the game is unfocused?", + "Should soundeffects play while the game is unfocused?", + "Should the game pause while the game is unfocused?", + "Should the FOCUS LOST window appear\n while the game is unfocused?", + "Should the mouse cursor be grabbed and hidden\n while the game is in focus?", +}; + static menuitem_t OP_DataOptionsMenu[] = { {IT_STRING | IT_CALL, NULL, "Screenshot Options...", M_ScreenshotOptions, 10}, @@ -1858,30 +1879,28 @@ static menuitem_t OP_DiscordOptionsMenu[] = static menuitem_t OP_HUDOptionsMenu[] = { - {IT_STRING | IT_CVAR, NULL, "Show HUD (F3)", &cv_showhud, 10}, + {IT_STRING | IT_CVAR, NULL, "Show HUD (F3)", &cv_showhud, 10}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "HUD Visibility", &cv_translucenthud, 20}, + NULL, "HUD Visibility", &cv_translucenthud, 20}, - {IT_STRING | IT_SUBMENU, NULL, "Online HUD options...", &OP_ChatOptionsDef, 35}, - {IT_STRING | IT_CVAR, NULL, "Background Glass", &cons_backcolor, 45}, + {IT_STRING | IT_SUBMENU, NULL, "Online HUD options...", &OP_ChatOptionsDef, 35}, + {IT_STRING | IT_CVAR, NULL, "Background Glass", &cons_backcolor, 45}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Minimap Visibility", &cv_kartminimap, 60}, - {IT_STRING | IT_CVAR, NULL, "Speedometer Display", &cv_kartspeedometer, 70}, - {IT_STRING | IT_CVAR, NULL, "Show \"CHECK\"", &cv_kartcheck, 80}, + NULL, "Minimap Visibility", &cv_kartminimap, 60}, + {IT_STRING | IT_CVAR, NULL, "Speedometer Display", &cv_kartspeedometer, 70}, + {IT_STRING | IT_CVAR, NULL, "Show \"CHECK\"", &cv_kartcheck, 80}, - {IT_STRING | IT_CVAR, NULL, "Menu Highlights", &cons_menuhighlight, 95}, + {IT_STRING | IT_CVAR, NULL, "Menu Highlights", &cons_menuhighlight, 95}, // highlight info - (GOOD HIGHLIGHT, WARNING HIGHLIGHT) - 110 (see M_DrawHUDOptions) - {IT_STRING | IT_CVAR, NULL, "Console Text Size", &cv_constextsize, 120}, + {IT_STRING | IT_CVAR, NULL, "Console Text Size", &cv_constextsize, 120}, - {IT_STRING | IT_CVAR, NULL, "Show Track Addon Name", &cv_showtrackaddon, 135}, + {IT_STRING | IT_CVAR, NULL, "Show Track Addon Name", &cv_showtrackaddon, 135}, - {IT_STRING | IT_CVAR, NULL, "Show All Maps", &cv_showallmaps, 145}, + {IT_STRING | IT_CVAR, NULL, "Show All Maps", &cv_showallmaps, 145}, - {IT_STRING | IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 155}, - - {IT_STRING | IT_CVAR, NULL, "2D character select", &cv_skinselectmenu, 165}, + {IT_STRING | IT_CVAR, NULL, "2D character select", &cv_skinselectmenu, 155}, }; static menuitem_t OP_CamOptionsMenu[] = @@ -1895,7 +1914,7 @@ static menuitem_t OP_CamOptionsMenu[] = {IT_STRING | IT_SUBMENU, NULL, "Player 1 Camera options...", &OP_Player1CamOptionsDef, 70}, {IT_STRING | IT_SUBMENU, NULL, "Player 2 Camera options...", &OP_Player2CamOptionsDef, 80}, {IT_STRING | IT_SUBMENU, NULL, "Player 3 Camera options...", &OP_Player3CamOptionsDef, 90}, - {IT_STRING | IT_SUBMENU, NULL, "Player 4 Camera options...", &OP_Player4CamOptionsDef, 100}, + {IT_STRING | IT_SUBMENU, NULL, "Player 4 Camera options...", &OP_Player4CamOptionsDef, 100}, }; static const char* OP_CamOptionsTooltips[] = @@ -3190,6 +3209,8 @@ menu_t OP_ChatOptionsDef = DEFAULTMENUSTYLE("M_HUD", OP_ChatOptionsMenu, &OP_HUD menu_t OP_SoundAdvancedDef = DEFAULTMENUSTYLE("M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30); +menu_t OP_FocusOptionsDef = DEFAULTMENUSTYLE(NULL, OP_FocusOptionsMenu, &OP_MainDef, 30, 30); + menu_t OP_GameOptionsDef = DEFAULTMENUSTYLE("M_GAME", OP_GameOptionsMenu, &OP_MainDef, 30, 20); menu_t OP_ServerOptionsDef = DEFAULTMENUSTYLE("M_SERVER", OP_ServerOptionsMenu, &OP_MainDef, 24, 20); #ifndef NONET @@ -5362,6 +5383,7 @@ static void M_DrawGenericMenu(void) DoToolTips(OP_VideoOptionsDef, OP_VideoTooltips); DoToolTips(OP_SoundOptionsDef, OP_SoundTooltips); DoToolTips(OP_SoundAdvancedDef, OP_SoundAdvancedTooltips); + DoToolTips(OP_FocusOptionsDef, OP_FocusOptionsTooltips); DoToolTips(OP_ChatOptionsDef, OP_ChatOptionsTooltips); DoToolTips(OP_GameOptionsDef, OP_GameTooltips); DoToolTips(OP_ServerOptionsDef, OP_ServerOptionsTooltips); From e7eca015ac603bcdd28f15174523ee87dacfd427 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 25 Mar 2025 19:57:02 +0100 Subject: [PATCH 063/350] add onchange for "alwaysgrabmouse" --- src/m_menu.c | 2 +- src/sdl/i_video.c | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 94b0bbe98..edf53662e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3209,7 +3209,7 @@ menu_t OP_ChatOptionsDef = DEFAULTMENUSTYLE("M_HUD", OP_ChatOptionsMenu, &OP_HUD menu_t OP_SoundAdvancedDef = DEFAULTMENUSTYLE("M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30); -menu_t OP_FocusOptionsDef = DEFAULTMENUSTYLE(NULL, OP_FocusOptionsMenu, &OP_MainDef, 30, 30); +menu_t OP_FocusOptionsDef = DEFAULTMENUSTYLE(NULL, OP_FocusOptionsMenu, &OP_MainDef, 10, 30); menu_t OP_GameOptionsDef = DEFAULTMENUSTYLE("M_GAME", OP_GameOptionsMenu, &OP_MainDef, 30, 20); menu_t OP_ServerOptionsDef = DEFAULTMENUSTYLE("M_SERVER", OP_ServerOptionsMenu, &OP_MainDef, 24, 20); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index d2de09128..4754df855 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -138,7 +138,8 @@ static void I_CheckDesktopRes(void); consvar_t cv_vidwait = {"vid_wait", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Impl_SetVsync, 0, NULL, NULL, 0, 0, NULL}; static consvar_t cv_stretch = {"stretch", "Off", CV_SAVE|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_alwaysgrabmouse = {"alwaysgrabmouse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static void mousegrabOnChange(void); +consvar_t cv_alwaysgrabmouse = {"alwaysgrabmouse", "Off", CV_SAVE|CV_CALL, CV_OnOff, mousegrabOnChange, 0, NULL, NULL, 0, 0, NULL}; // these cant be used since config is read after window creation, so need to use command line parameter instead //static CV_PossibleValue_t msaa_cons_t[] = {{0, "Off"}, {2, "2X"}, {4, "4X"}, {8, "8X"}, {16, "16X"}, {0, NULL}}; @@ -224,6 +225,9 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen); //static void Impl_SetWindowName(const char *title); static void Impl_SetWindowIcon(void); +static void SDLdoGrabMouse(void); +static void SDLdoUngrabMouse(void); + #ifdef USE_FBO_OGL boolean downsample = false; void RefreshOGLSDLSurface(void) @@ -233,6 +237,23 @@ void RefreshOGLSDLSurface(void) } #endif +static void mousegrabOnChange(void) +{ + static SDL_bool firsttimeonmouse = SDL_TRUE; + + if (!firsttimeonmouse) + { + HalfWarpMouse(realwidth, realheight); // warp to center + } + else + firsttimeonmouse = SDL_FALSE; + + if (cv_usemouse.value || cv_alwaysgrabmouse.value) + SDLdoGrabMouse(); + else + SDLdoUngrabMouse(); +} + static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) { static SDL_bool wasfullscreen = SDL_FALSE; From 064032175e3fac366dce0afd834d3653a25f1b42 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 25 Mar 2025 20:04:59 +0100 Subject: [PATCH 064/350] grey out mouse grab when use_mouse is enabled --- src/d_netcmd.c | 9 ++++++++- src/m_menu.c | 7 ++++++- src/m_menu.h | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index fd97b0259..6495ad7c3 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -290,7 +290,14 @@ consvar_t cv_skipmapcheck = {"skipmapcheck", "Off", CV_SAVE, CV_OnOff, NULL, 0, INT32 cv_debug; -consvar_t cv_usemouse = {"use_mouse", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse, 0, NULL, NULL, 0, 0, NULL}; +static void UseMouse_OnChange(void); +consvar_t cv_usemouse = {"use_mouse", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, UseMouse_OnChange, 0, NULL, NULL, 0, 0, NULL}; + +static void UseMouse_OnChange(void) +{ + GameFocus_menu_Onchange(); + I_StartupMouse(); +} //WTF consvar_t cv_mouseturn = {"mouseturn", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; diff --git a/src/m_menu.c b/src/m_menu.c index edf53662e..6c74cc27f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1768,7 +1768,7 @@ static menuitem_t OP_FocusOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 80}, - {IT_STRING|IT_CVAR, NULL, "Hide mouse While Focused", &cv_alwaysgrabmouse, 100}, + {IT_STRING|IT_CVAR, NULL, "Always Grab Mouse While Focused", &cv_alwaysgrabmouse, 100}, }; static const char* OP_FocusOptionsTooltips[] = @@ -3590,6 +3590,11 @@ void SaturnHud_menu_Onchange(void) OP_SaturnHudMenu[sh_colorhud_customcolor].status = status; } +void GameFocus_menu_Onchange(void) +{ + OP_FocusOptionsMenu[5].status = cv_usemouse.value ? IT_GRAYEDOUT : IT_STRING | IT_CVAR; +} + #ifdef HWRENDER void M_UpdateOGLMenu(void) { diff --git a/src/m_menu.h b/src/m_menu.h index 4ee8615ce..45f0fbbf9 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -298,6 +298,8 @@ void Bird_menu_Onchange(void); // Saturn Hud menu updating void SaturnHud_menu_Onchange(void); +void GameFocus_menu_Onchange (void); + #ifdef HWRENDER void M_UpdateOGLMenu(void); #endif From cbcfed133cfaf0385250693e8f4312cb9e705978 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 25 Mar 2025 20:39:48 +0100 Subject: [PATCH 065/350] change version string for testing "RC1" were close to being done with v8, its now mostly just about catching any remaining bugs and regressions --- src/doomdef.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index ca9d8cacd..5b7165404 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -113,8 +113,8 @@ extern char logfilename[1024]; #else #define VERSION 1 // Game version #define SUBVERSION 6 // more precise version number -#define VERSIONSTRING "Saturn v8 - Testing" -#define VERSIONSTRINGW L"Saturn v8 - Testing" +#define VERSIONSTRING "Saturn v8 - Testing RC1" +#define VERSIONSTRINGW L"Saturn v8 - Testing RC1" // Hey! If you change this, add 1 to the MODVERSION below! Otherwise we can't force updates! // And change CMakeLists.txt (not src/, but in root), for CMake users! // AND appveyor.yml, for the build bots! From 5422ab4daf723b8183db3dcb6a29ebb779682b47 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 25 Mar 2025 23:14:10 +0100 Subject: [PATCH 066/350] tab hell --- src/d_main.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 216fde85b..84f9a79a1 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1061,18 +1061,21 @@ static void D_AutoloadFile(const char *file, char **filearray) COM_BufAddText(va("exec %s\n", newfile)); } -static char *strremove(char *str, const char *sub) { - char *p, *q, *r; - if (*sub && (q = r = strstr(str, sub)) != NULL) { - size_t len = strlen(sub); - while ((r = strstr(p = r + len, sub)) != NULL) { - while (p < r) - *q++ = *p++; - } - while ((*q++ = *p++) != '\0') - continue; - } - return str; +static char *strremove(char *str, const char *sub) +{ + char *p, *q, *r; + if (*sub && (q = r = strstr(str, sub)) != NULL) + { + size_t len = strlen(sub); + while ((r = strstr(p = r + len, sub)) != NULL) + { + while (p < r) + *q++ = *p++; + } + while ((*q++ = *p++) != '\0') + continue; + } + return str; } // FIND THEM From 6b16d27576d85ab359007a19be142748f9e0ec42 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Mar 2025 14:54:10 +0100 Subject: [PATCH 067/350] brazil --- src/hu_stuff.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 1142fd637..faa46ae37 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2350,7 +2350,7 @@ Ping_gfx_num (int lag) } static int -Ping_gfx_color (int lag) +Ping_gfx_color (UINT32 lag) { if (lag < 2) return SKINCOLOR_JAWZ; @@ -2360,8 +2360,17 @@ Ping_gfx_color (int lag) return SKINCOLOR_GOLD; else if (lag < 10) return SKINCOLOR_RED; + else if (lag < servermaxping) + { + if (hu_tick & 2) + return SKINCOLOR_GREEN; + else if (hu_tick & 4) + return SKINCOLOR_YELLOW; + else + return SKINCOLOR_BLUEBERRY; + } else - return SKINCOLOR_WHITE; // SKINCOLOR_MAGENTA + return SKINCOLOR_WHITE; // to make the flashing work } static const UINT8 * From 2d064d61a9c789771c7a699c4c22bce4f4a1358a Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Mar 2025 15:34:57 +0100 Subject: [PATCH 068/350] change menu autoload button to "END" instead of right shift too many ppl accidentally press right shift and end up putting things they didnt intend into their autoload file which sometimes caused alot of issues in online play --- src/m_menu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 6c74cc27f..81c537f6d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6492,7 +6492,7 @@ static void M_AddonAutoLoad(INT32 ch) FILE *autoloadconfigfile; // check our controls // - if (ch != 'y' && ch != KEY_ENTER && ch != KEY_RSHIFT) + if (ch != 'y' && ch != KEY_ENTER && ch != KEY_END) { S_StartSound(NULL, sfx_s26d); return; @@ -6679,7 +6679,7 @@ static void M_HandleAddons(INT32 choice) } break; - case KEY_RSHIFT: + case KEY_END: { boolean refresh = true; if (!dirmenu[dir_on[menudepthleft]]) From 25a80e378de5c44f25ec46b33d30ce6b20ed6e68 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Mar 2025 15:35:13 +0100 Subject: [PATCH 069/350] add smol text indicating the autoload button --- src/m_menu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index 81c537f6d..b5d273dbd 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6471,6 +6471,8 @@ static void M_DrawAddons(void) if (modifiedgame) V_DrawSmallScaledPatch(x, y + 4, 0, addonsp[NUM_EXT+2]); + + V_DrawThinString(0, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_TRANSLUCENT|V_ALLOWLOWERCASE, ("END Key - Add addon to autoload")); } static void M_AddonExec(INT32 ch) From e671cfebcf759a4edde4374275cb1e9fb123d663 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Mar 2025 15:54:18 +0100 Subject: [PATCH 070/350] lel --- src/m_menu.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index b5d273dbd..ff5cb7075 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5585,16 +5585,15 @@ static void M_DrawCenteredMenu(void) case IT_PATCH: if (currentMenu->menuitems[i].patch && currentMenu->menuitems[i].patch[0]) { + patch_t *p = W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE); + if (currentMenu->menuitems[i].status & IT_CENTER) { - patch_t *p; - p = W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE); V_DrawScaledPatch((BASEVIDWIDTH - SHORT(p->width))/2, y, 0, p); } else { - V_DrawScaledPatch(x, y, 0, - W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE)); + V_DrawScaledPatch(x, y, 0, p); } } /* FALLTHRU */ From 480c4111f9a0a51a021be3a073f1325fbc5aee32 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Mar 2025 17:13:54 +0100 Subject: [PATCH 071/350] fix bird menu from crashing (again) finally add an enum so this wont happen again --- src/m_menu.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index ff5cb7075..5db91a966 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1163,6 +1163,25 @@ static menuitem_t OP_MainMenu[] = {IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 165}, }; +enum +{ + ctrlsetup, + vidopt, + soundopt, + focusopt, + hudopt, + camopt, + gameopt, + serveropt, + dataopt, + addonopt, + tricksandshit, + credits, + satopt, + bird, + localskin +}; + static menuitem_t OP_ControlsMenu[] = { {IT_CALL | IT_STRING, NULL, "Player 1 Controls...", M_Setup1PControlsMenu, 10}, @@ -7959,11 +7978,11 @@ static void M_Options(INT32 choice) (void)choice; // if the player is not admin or server, disable gameplay & server options - OP_MainMenu[5].status = OP_MainMenu[6].status = (Playing() && !(server || IsPlayerAdmin(consoleplayer))) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU); + OP_MainMenu[gameopt].status = OP_MainMenu[serveropt].status = (Playing() && !(server || IsPlayerAdmin(consoleplayer))) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU); - OP_MainMenu[10].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_CALL); // Play credits + OP_MainMenu[credits].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_CALL); // Play credits - OP_MainMenu[13].status = (!cv_showlocalskinmenus.value) ? (IT_DISABLED) : (IT_CALL|IT_STRING); + OP_MainMenu[localskin].status = (!cv_showlocalskinmenus.value) ? (IT_DISABLED) : (IT_CALL|IT_STRING); #ifdef HAVE_DISCORDRPC OP_DataOptionsMenu[4].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU); // Erase data @@ -7971,8 +7990,7 @@ static void M_Options(INT32 choice) OP_DataOptionsMenu[3].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU); // Erase data #endif - OP_GameOptionsMenu[3].status = - (M_SecretUnlocked(SECRET_ENCORE)) ? (IT_CVAR|IT_STRING) : IT_SECRET; // cv_kartencore + OP_GameOptionsMenu[3].status = (M_SecretUnlocked(SECRET_ENCORE)) ? (IT_CVAR|IT_STRING) : IT_SECRET; // cv_kartencore OP_MainDef.prevMenu = currentMenu; M_SetupNextMenu(&OP_MainDef); From a35362f0edf1def82f1cdbf106fb5ca183333bfa Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Mar 2025 17:27:09 +0100 Subject: [PATCH 072/350] move everything around in main options menu to fit stuff for green res --- src/m_menu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 5db91a966..e28aca9a5 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1157,10 +1157,10 @@ static menuitem_t OP_MainMenu[] = {IT_CALL|IT_STRING, NULL, "Tricks & Secrets (F1)", M_Manual, 115}, {IT_CALL|IT_STRING, NULL, "Play Credits", M_Credits, 125}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Options...", &OP_SaturnDef, 145}, + {IT_SUBMENU|IT_STRING, NULL, "Saturn Options...", &OP_SaturnDef, 140}, - {IT_SUBMENU|IT_STRING, NULL, "Bird...", &OP_BirdDef, 155}, - {IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 165}, + {IT_SUBMENU|IT_STRING, NULL, "Bird...", &OP_BirdDef, 150}, + {IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 160}, }; enum @@ -3125,7 +3125,7 @@ menu_t OP_MainDef = &MainDef, OP_MainMenu, M_DrawGenericMenu, - 60, 30, + 60, 25, 0, NULL, {NULL} From 2075587980fc3802cea9877b5c4eef946bdd64c3 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Mar 2025 17:31:48 +0100 Subject: [PATCH 073/350] fix focus options for green res --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index e28aca9a5..db26b20b4 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3228,7 +3228,7 @@ menu_t OP_ChatOptionsDef = DEFAULTMENUSTYLE("M_HUD", OP_ChatOptionsMenu, &OP_HUD menu_t OP_SoundAdvancedDef = DEFAULTMENUSTYLE("M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30); -menu_t OP_FocusOptionsDef = DEFAULTMENUSTYLE(NULL, OP_FocusOptionsMenu, &OP_MainDef, 10, 30); +menu_t OP_FocusOptionsDef = DEFAULTMENUSTYLE(NULL, OP_FocusOptionsMenu, &OP_MainDef, 25, 30); menu_t OP_GameOptionsDef = DEFAULTMENUSTYLE("M_GAME", OP_GameOptionsMenu, &OP_MainDef, 30, 20); menu_t OP_ServerOptionsDef = DEFAULTMENUSTYLE("M_SERVER", OP_ServerOptionsMenu, &OP_MainDef, 24, 20); From 14df21a2ae8a7ec66721e19d8d94623a97854dd4 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Mar 2025 17:45:31 +0100 Subject: [PATCH 074/350] turn screenshot options into a scoll menu cause of green res --- src/m_menu.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index db26b20b4..c34459957 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1818,25 +1818,25 @@ static menuitem_t OP_DataOptionsMenu[] = static menuitem_t OP_ScreenshotOptionsMenu[] = { {IT_HEADER, NULL, "Screenshots (F8)", NULL, 5}, - {IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_screenshot_option, 15}, - {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_screenshot_folder, 25}, - {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memory, 55}, - {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_level, 65}, - {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategy, 75}, - {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bits, 85}, + {IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_screenshot_option, 10}, + {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_screenshot_folder, 15}, + {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memory, 30}, + {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_level, 35}, + {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategy, 40}, + {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bits, 45}, - {IT_HEADER, NULL, "Movie Mode (F9)", NULL, 100}, - {IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_movie_option, 110}, - {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_movie_folder, 120}, - {IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 150}, + {IT_HEADER, NULL, "Movie Mode (F9)", NULL, 55}, + {IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_movie_option, 60}, + {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_movie_folder, 65}, + {IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 80}, - {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 160}, - {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 170}, + {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 90}, + {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 95}, - {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 160}, - {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 170}, - {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategya, 180}, - {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bitsa, 190}, + {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 90}, + {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 95}, + {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategya, 100}, + {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bitsa, 105}, }; enum @@ -3259,7 +3259,7 @@ menu_t OP_OpenGLOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_OpenGLOptionsMenu, menu_t OP_ExpOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_ExpOptionsMenu, &OP_VideoOptionsDef, 30, 25); menu_t OP_DataOptionsDef = DEFAULTMENUSTYLE("M_DATA", OP_DataOptionsMenu, &OP_MainDef, 60, 30); -menu_t OP_ScreenshotOptionsDef = DEFAULTMENUSTYLE("M_SCSHOT", OP_ScreenshotOptionsMenu, &OP_DataOptionsDef, 30, 30); +menu_t OP_ScreenshotOptionsDef = DEFAULTSCROLLSTYLE("M_SCSHOT", OP_ScreenshotOptionsMenu, &OP_DataOptionsDef, 30, 30); menu_t OP_AddonsOptionsDef = DEFAULTMENUSTYLE("M_ADDONS", OP_AddonsOptionsMenu, &OP_DataOptionsDef, 30, 30); menu_t OP_ProtocolDef = DEFAULTMENUSTYLE(NULL, OP_ProtocolMenu, &OP_DataOptionsDef, 30, 30); #ifdef HAVE_DISCORDRPC From 856cdbda6bb49b31c023373f69f870dbbe5d1fcb Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Mar 2025 17:45:56 +0100 Subject: [PATCH 075/350] rename "Custom Options" to "Custom Addon Options" to make it clear wtf this is even for --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index c34459957..2b1ce3094 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1152,7 +1152,7 @@ static menuitem_t OP_MainMenu[] = {IT_SUBMENU|IT_STRING, NULL, "Server Options...", &OP_ServerOptionsDef, 80}, {IT_SUBMENU|IT_STRING, NULL, "Data Options...", &OP_DataOptionsDef, 95}, - {IT_CALL|IT_STRING, NULL, "Custom Options...", M_CustomCvarMenu, 105}, + {IT_CALL|IT_STRING, NULL, "Custom Addon Options...", M_CustomCvarMenu, 105}, {IT_CALL|IT_STRING, NULL, "Tricks & Secrets (F1)", M_Manual, 115}, {IT_CALL|IT_STRING, NULL, "Play Credits", M_Credits, 125}, From e159a5f206dd30d2840cf0dd098741697e0231b2 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Mar 2025 18:00:00 +0100 Subject: [PATCH 076/350] turn sprite distortion menu into scoll menu due to green res --- src/m_menu.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 2b1ce3094..a4df64b8d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2344,20 +2344,21 @@ static menuitem_t OP_PlayerDistortMenu[] = { {IT_HEADER, NULL, "Sprite Distortion", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Sprite Slope Rotation", &cv_sloperoll, 15}, - {IT_STRING | IT_CVAR, NULL, "Slope Rotation Distance", &cv_sloperolldist, 30}, + {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, 45}, - {IT_STRING | IT_CVAR, NULL, "Rotate Sparks and Boost Trails", &cv_sparkroll, 60}, - {IT_STRING | IT_CVAR, NULL, "Rotate Bananas on Throw", &cv_bananthrowroll, 75}, + {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, 90}, - {IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 105}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 120}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saltyhop Height", &cv_saltyheight, 135}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 150}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 165}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Roll", &cv_saltyroll, 180}, + {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}, }; static const char* OP_PlayerDistortTooltips[] = @@ -3268,7 +3269,7 @@ menu_t OP_DiscordOptionsDef = DEFAULTMENUSTYLE(NULL, OP_DiscordOptionsMenu, &OP_ menu_t OP_EraseDataDef = DEFAULTMENUSTYLE("M_DATA", OP_EraseDataMenu, &OP_DataOptionsDef, 30, 30); menu_t OP_SaturnDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnMenu, &OP_MainDef, 30, 30); -menu_t OP_PlayerDistortDef = DEFAULTMENUSTYLE("M_VIDEO", OP_PlayerDistortMenu, &OP_SaturnDef, 30, 30); +menu_t OP_PlayerDistortDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_PlayerDistortMenu, &OP_SaturnDef, 30, 30); menu_t OP_HudOffsetDef = DEFAULTSCROLLSTYLE(NULL, OP_HudOffsetMenu, &OP_SaturnHudDef, 30, 30); menu_t OP_SaturnHudDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnHudMenu, &OP_SaturnDef, 30, 30); From 4b1110921bc96127d50d91e64c8f8ed2e09c9848 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Mar 2025 18:04:47 +0100 Subject: [PATCH 077/350] turn advanced sound ioptions into scoll menu --- src/m_menu.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index a4df64b8d..112a226fc 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1737,23 +1737,23 @@ static menuitem_t OP_SoundAdvancedMenu[] = #ifdef HAVE_OPENMPT {IT_HEADER, NULL, "Tracker Module Options", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Instrument Filter", &cv_modfilter, 20}, - {IT_STRING | IT_CVAR, NULL, "Amiga Resampler", &cv_amigafilter, 30}, + {IT_STRING | IT_CVAR, NULL, "Instrument Filter", &cv_modfilter, 10}, + {IT_STRING | IT_CVAR, NULL, "Amiga Resampler", &cv_amigafilter, 20}, #if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 - {IT_STRING | IT_CVAR, NULL, "Amiga Type", &cv_amigatype, 40}, + {IT_STRING | IT_CVAR, NULL, "Amiga Type", &cv_amigatype, 25}, #endif - {IT_STRING | IT_CVAR, NULL, "Stereo Seperation", &cv_stereosep, 50}, + {IT_STRING | IT_CVAR, NULL, "Stereo Seperation", &cv_stereosep, 35}, #endif - {IT_HEADER, NULL, "Misc", NULL, 70}, + {IT_HEADER, NULL, "Misc", NULL, 45}, - {IT_STRING | IT_CVAR, NULL, "Grow Music", &cv_growmusic, 90}, - {IT_STRING | IT_CVAR, NULL, "Invulnerability Music", &cv_supermusic, 100}, + {IT_STRING | IT_CVAR, NULL, "Grow Music", &cv_growmusic, 55}, + {IT_STRING | IT_CVAR, NULL, "Invulnerability Music", &cv_supermusic, 60}, - {IT_STRING | IT_CVAR, NULL, "Keep Map Music", &cv_keepmusic, 120}, - {IT_STRING | IT_CVAR, NULL, "Skip Intro Music", &cv_skipintromusic, 130}, + {IT_STRING | IT_CVAR, NULL, "Keep Map Music", &cv_keepmusic, 70}, + {IT_STRING | IT_CVAR, NULL, "Skip Intro Music", &cv_skipintromusic, 75}, - {IT_STRING | IT_CVAR, NULL, "Audio Buffer Size", &cv_audbuffersize, 150}, + {IT_STRING | IT_CVAR, NULL, "Audio Buffer Size", &cv_audbuffersize, 80}, }; static const char* OP_SoundAdvancedTooltips[] = @@ -3227,7 +3227,7 @@ menu_t OP_Player4CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player4CamOptionsMenu menu_t OP_ChatOptionsDef = DEFAULTMENUSTYLE("M_HUD", OP_ChatOptionsMenu, &OP_HUDOptionsDef, 30, 30); -menu_t OP_SoundAdvancedDef = DEFAULTMENUSTYLE("M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30); +menu_t OP_SoundAdvancedDef = DEFAULTSCROLLSTYLE("M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30); menu_t OP_FocusOptionsDef = DEFAULTMENUSTYLE(NULL, OP_FocusOptionsMenu, &OP_MainDef, 25, 30); @@ -5407,7 +5407,6 @@ static void M_DrawGenericMenu(void) DoToolTips(OP_MouseOptionsDef, OP_MouseTooltips); DoToolTips(OP_VideoOptionsDef, OP_VideoTooltips); DoToolTips(OP_SoundOptionsDef, OP_SoundTooltips); - DoToolTips(OP_SoundAdvancedDef, OP_SoundAdvancedTooltips); DoToolTips(OP_FocusOptionsDef, OP_FocusOptionsTooltips); DoToolTips(OP_ChatOptionsDef, OP_ChatOptionsTooltips); DoToolTips(OP_GameOptionsDef, OP_GameTooltips); @@ -5559,6 +5558,7 @@ static void M_DrawGenericScrollMenu(void) DoToolTips(OP_SaturnDef, OP_SaturnTooltips); DoToolTips(OP_SaturnHudDef, OP_SaturnHudTooltips); DoToolTips(OP_AdvServerOptionsDef, OP_AdvServerOptionsTooltips); + DoToolTips(OP_SoundAdvancedDef, OP_SoundAdvancedTooltips); } static void M_DrawPauseMenu(void) From 4a8a83bf0951734cca8759379a3f59c0300e2d76 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Mar 2025 18:05:17 +0100 Subject: [PATCH 078/350] fix sprite distort tooltips Zzzzzzzzzz...... --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 112a226fc..53131d12c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5411,7 +5411,6 @@ static void M_DrawGenericMenu(void) DoToolTips(OP_ChatOptionsDef, OP_ChatOptionsTooltips); DoToolTips(OP_GameOptionsDef, OP_GameTooltips); DoToolTips(OP_ServerOptionsDef, OP_ServerOptionsTooltips); - DoToolTips(OP_PlayerDistortDef, OP_PlayerDistortTooltips); DoToolTips(OP_SaturnCreditsDef, OP_CreditTooltips); // C: DoToolTips(OP_BirdDef, OP_BirdTooltips); DoToolTips(OP_TiltDef, OP_TiltTooltips); @@ -5559,6 +5558,7 @@ static void M_DrawGenericScrollMenu(void) DoToolTips(OP_SaturnHudDef, OP_SaturnHudTooltips); DoToolTips(OP_AdvServerOptionsDef, OP_AdvServerOptionsTooltips); DoToolTips(OP_SoundAdvancedDef, OP_SoundAdvancedTooltips); + DoToolTips(OP_PlayerDistortDef, OP_PlayerDistortTooltips); } static void M_DrawPauseMenu(void) From c5638d8dbb44d33c0efc52cd9e53aaa806a76d08 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Mar 2025 18:17:29 +0100 Subject: [PATCH 079/350] fix advanced video options in green res god bruh also removes the directional light entry since its planned to be deprecated --- src/m_menu.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 53131d12c..350c1d6e7 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1541,25 +1541,25 @@ static menuitem_t OP_ColorOptionsMenu[] = static menuitem_t OP_ExpOptionsMenu[] = { - {IT_HEADER, NULL, "Advanced Video Options", NULL, 15}, - {IT_STRING|IT_CVAR, NULL, "Interpolation Distance", &cv_maxinterpdist, 25}, - {IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 30}, + {IT_HEADER, NULL, "Advanced Video Options", NULL, 0}, + {IT_STRING|IT_CVAR, NULL, "Interpolation Distance", &cv_maxinterpdist, 10}, + {IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 15}, - {IT_STRING | IT_CVAR, NULL, "Scale Weather with Mobjscale", &cv_mobjscaleprecip, 40}, - {IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 45}, + {IT_STRING | IT_CVAR, NULL, "Scale Weather with Mobjscale", &cv_mobjscaleprecip, 25}, + {IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 30}, - {IT_STRING | IT_CVAR, NULL, "Randomized Directional Light", &cv_randomdirlight, 55}, + //{IT_STRING | IT_CVAR, NULL, "Randomized Directional Light", &cv_randomdirlight, 55}, // should this ever come back - {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 65}, + {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 40}, - {IT_STRING | IT_CVAR, NULL, "FPS counter sampling", &cv_accuratefps, 75}, + {IT_STRING | IT_CVAR, NULL, "FPS counter sampling", &cv_accuratefps, 50}, #ifdef HWRENDER - {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 85}, + {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 60}, #ifdef USE_FBO_OGL - {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_glframebuffer, 90}, + {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_glframebuffer, 65}, #endif - {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 100}, + {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 75}, #endif }; @@ -1570,7 +1570,7 @@ static const char* OP_ExpTooltips[] = "Should weather be interpolated? Weather should look about the\nsame but perform a bit better when disabled.", "Should weather be scaled with Mapobjectscale?.", "When weather is on this will cut the object amount used in half.", - "Should the directional lightning be randomized each map?\nTakes effect on next map load.", + //"Should the directional lightning be randomized each map?\nTakes effect on next map load.", "Toggle being able to see the sky.", "Change the FPS counter sampling method\nInaccurate updates slower and might miss frame drops and such\nAccurate updates faster and is more accurate, but might be less readable", // how to ingles?? #ifdef HWRENDER @@ -1578,7 +1578,7 @@ static const char* OP_ExpTooltips[] = #ifdef USE_FBO_OGL "Allows the game to downsample from a higher resolution than your display\nin OpenGL renderer mode. Requires a GPU with atleast OpenGL 3.0 support.", #endif - "Change the depth of the Palette in Palette rendering mode\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.", + "Change the bit depth of the Lookup Palette in Palette rendering mode.", #endif }; From 35db2b0c8ed59f90d821a727476a60cf09a9c300 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Mar 2025 17:21:25 +0100 Subject: [PATCH 080/350] muh huh durr hurr is above array bounds of deez nuts --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 350c1d6e7..04ff3134d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1589,7 +1589,7 @@ enum op_exp_precipinter, op_exp_precipmoscale, op_exp_lessprecip, - op_exp_dirlight, + //op_exp_dirlight, op_exp_skybox, op_exp_accuratefps, #ifdef HWRENDER From bf9edef146f29b52195e7fd0f9f83feb6a5021a0 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Mar 2025 19:32:35 +0100 Subject: [PATCH 081/350] add dummy entries so the tooltips dont fucking cutoff stuff in green res if i only knew of this dumb hack earlier --- src/m_menu.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 04ff3134d..d4d49ff79 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1560,6 +1560,7 @@ static menuitem_t OP_ExpOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_glframebuffer, 65}, #endif {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 75}, + {IT_DISABLED, NULL, "", NULL, 85}, // dummy text #endif }; @@ -1578,7 +1579,7 @@ static const char* OP_ExpTooltips[] = #ifdef USE_FBO_OGL "Allows the game to downsample from a higher resolution than your display\nin OpenGL renderer mode. Requires a GPU with atleast OpenGL 3.0 support.", #endif - "Change the bit depth of the Lookup Palette in Palette rendering mode.", + "Change the bit depth of the Lookup Palette in Palette rendering mode\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.", #endif }; @@ -1745,15 +1746,16 @@ static menuitem_t OP_SoundAdvancedMenu[] = {IT_STRING | IT_CVAR, NULL, "Stereo Seperation", &cv_stereosep, 35}, #endif - {IT_HEADER, NULL, "Misc", NULL, 45}, + {IT_HEADER, NULL, "Misc", NULL, 45}, - {IT_STRING | IT_CVAR, NULL, "Grow Music", &cv_growmusic, 55}, - {IT_STRING | IT_CVAR, NULL, "Invulnerability Music", &cv_supermusic, 60}, + {IT_STRING | IT_CVAR, NULL, "Grow Music", &cv_growmusic, 55}, + {IT_STRING | IT_CVAR, NULL, "Invulnerability Music", &cv_supermusic, 60}, - {IT_STRING | IT_CVAR, NULL, "Keep Map Music", &cv_keepmusic, 70}, - {IT_STRING | IT_CVAR, NULL, "Skip Intro Music", &cv_skipintromusic, 75}, + {IT_STRING | IT_CVAR, NULL, "Keep Map Music", &cv_keepmusic, 70}, + {IT_STRING | IT_CVAR, NULL, "Skip Intro Music", &cv_skipintromusic, 75}, - {IT_STRING | IT_CVAR, NULL, "Audio Buffer Size", &cv_audbuffersize, 80}, + {IT_STRING | IT_CVAR, NULL, "Audio Buffer Size", &cv_audbuffersize, 80}, + {IT_DISABLED, NULL, "", NULL, 90}, // dummy text }; static const char* OP_SoundAdvancedTooltips[] = From 850272e7836c0e299707deeff3161b662e36d6dd Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Mar 2025 18:38:07 +0100 Subject: [PATCH 082/350] fix spacing when compiled withou fbo support --- src/m_menu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index d4d49ff79..ff2a28396 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1558,9 +1558,12 @@ static menuitem_t OP_ExpOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 60}, #ifdef USE_FBO_OGL {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_glframebuffer, 65}, -#endif {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 75}, {IT_DISABLED, NULL, "", NULL, 85}, // dummy text +#else + {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 70}, + {IT_DISABLED, NULL, "", NULL, 80}, // dummy text +#endif #endif }; From 1e8716450fc826dcf70a6cb105a4de21de3b3b9b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Mar 2025 19:51:31 +0100 Subject: [PATCH 083/350] better slope rotation for shadows instead of copieng the target mobjs rotation we just use its standingslope instead, this means shadows properly rotate according to which slope theire on should make them visually more cohesive if a player or other mobj is rotated midair --- src/p_mobj.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 06105d18c..1b7d5a786 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6252,12 +6252,8 @@ void P_MobjThinker(mobj_t *mobj) return; } - // dont need to extra check with K_ShouldSlopeRoll - if (cv_sloperoll.value == 2 && mobj->state == &states[S_SHADOW]) - { - mobj->slopepitch = mobj->target->slopepitch; - mobj->sloperoll = mobj->target->sloperoll; - } + K_RollMobjBySlopes(mobj, mobj->target->standingslope); + P_AddShadow(mobj); break; //{ SRB2kart mobs From 0d6b42cc3f82d874eedf0f24a8ee5ed35cd0cc02 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 26 Mar 2025 22:11:45 +0300 Subject: [PATCH 084/350] Fix limit_dist overflowing for some mapobjectscale values --- src/hardware/hw_main.c | 8 ++++---- src/r_things.c | 6 +++--- src/r_things.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 61a6e63fa..db22e8124 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4430,7 +4430,7 @@ static void HWR_DrawModels(void) static void HWR_AddSprites(sector_t *sec) { mobj_t *thing; - fixed_t limit_dist; + INT32 limit_dist; // BSP is traversed by subsector. // A sector might have been split into several @@ -4446,12 +4446,12 @@ static void HWR_AddSprites(sector_t *sec) { // Use the smaller setting if (cv_drawdist.value) - limit_dist = min((fixed_t)current_bsp_culling_distance, (fixed_t)(cv_drawdist.value) * mapobjectscale); + limit_dist = min(current_bsp_culling_distance/mapobjectscale, cv_drawdist.value); else - limit_dist = (fixed_t)current_bsp_culling_distance; + limit_dist = current_bsp_culling_distance/mapobjectscale; } else - limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale; + limit_dist = cv_drawdist.value; // Handle all things in sector. for (thing = sec->thinglist; thing; thing = thing->snext) diff --git a/src/r_things.c b/src/r_things.c index 144c1a4ec..b8e5ab5ba 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2061,7 +2061,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) // Handle all things in sector. // If a limit exists, handle things a tiny bit different. - const fixed_t limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale; + const INT32 limit_dist = cv_drawdist.value; for (thing = sec->thinglist; thing; thing = thing->snext) { @@ -2900,11 +2900,11 @@ boolean R_ThingVisible (mobj_t *thing) return true; } -boolean R_ThingWithinDist(mobj_t *thing, fixed_t limit_dist) +boolean R_ThingWithinDist(mobj_t *thing, INT32 limit_dist) { if (limit_dist) { - if (P_AproxDistance(viewx-thing->x, viewy-thing->y) > limit_dist) + if (P_AproxDistance(viewx-thing->x, viewy-thing->y)/mapobjectscale > limit_dist) { return false; } diff --git a/src/r_things.h b/src/r_things.h index c594c26cb..1db265f4b 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -77,7 +77,7 @@ void R_ClearSprites(void); void R_DrawMasked(void); boolean R_ThingVisible (mobj_t *thing); -boolean R_ThingWithinDist (mobj_t *thing, fixed_t limit_dist); +boolean R_ThingWithinDist (mobj_t *thing, INT32 limit_dist); boolean R_ThingIsFullBright (mobj_t *thing); boolean R_ThingIsSemiBright (mobj_t *thing); From 884c5d25782ef39e8db72fc3e4887be52cfcd798 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Mar 2025 19:48:17 +0100 Subject: [PATCH 085/350] fix vertical patch scale not working when horizontal scale is also not changed in opengl patch drawer --- src/hardware/hw_draw.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index c24fbdb56..d677af281 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -252,16 +252,8 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t } } - if (pscale != FRACUNIT) - { - fwidth = (float)SHORT(gpatch->width) * fscalew * dupx; - fheight = (float)SHORT(gpatch->height) * fscaleh * dupy; - } - else - { - fwidth = (float)SHORT(gpatch->width) * dupx; - fheight = (float)SHORT(gpatch->height) * dupy; - } + fwidth = (float)SHORT(gpatch->width) * fscalew * dupx; + fheight = (float)SHORT(gpatch->height) * fscaleh * dupy; // positions of the cx, cy, are between 0 and vid.width/vid.height now, we need them to be between -1 and 1 cx = -1.0f + (cx / (vid.width / 2.0f)); From 15f9bf181a956cacd530d7be67bbae79b32ac15a Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Mar 2025 20:24:56 +0100 Subject: [PATCH 086/350] that comment belongs to this lmao --- src/d_main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.h b/src/d_main.h index d5b5189eb..faa52edc0 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -17,9 +17,9 @@ #include "d_event.h" #include "w_wad.h" // for MAX_WADFILES -// make sure not to write back the config until it's been correctly loaded extern tic_t rendergametic; +// make sure not to write back the config until it's been correctly loaded extern boolean loaded_config; extern char srb2home[256]; //Alam: My Home From edf545c9a1a53ee9f452031546ba042bcb89c263 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Mar 2025 20:41:14 +0100 Subject: [PATCH 087/350] add support for sprite joystick knob still needs proper toggle --- src/d_main.c | 6 ++++ src/d_main.h | 1 + src/k_kart.c | 95 ++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 73 insertions(+), 29 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 84f9a79a1..29988ccab 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1216,6 +1216,7 @@ boolean statdp; // stat display for extended player setup boolean nametaggfx; // Nametag stuffs boolean driftgaugegfx; // Driftgauge stuffs boolean multiitem_icon; // Extra icons for Sneakers, Banana and Jawz +boolean joystickicon; // Extra icons for the joystick input display // static void IdentifyVersion(void) @@ -1650,6 +1651,11 @@ void D_SRB2Main(void) if (W_CheckMultipleLumps("K_DGAU","K_DCAU","K_DGSU","K_DCSU", NULL)) driftgaugegfx = true; + if (W_CheckMultipleLumps("JOYBCK","JOYKNB","JOYSHD", NULL)) + { + joystickicon = true; + } + // extra item icons if (W_CheckMultipleLumps("K_ITSHO2", "K_ITSHO3", "K_ITBAN2", "K_ITBAN3", "K_ITBAN4", "K_ITJAW2", NULL)) multiitem_icon = true; diff --git a/src/d_main.h b/src/d_main.h index faa52edc0..2ca97839c 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -47,6 +47,7 @@ extern boolean statdp; // stat display for extended player setup extern boolean nametaggfx; // Nametag stuffs extern boolean driftgaugegfx; // Driftgauge stuffs extern boolean multiitem_icon; // Extra icons for Sneakers, Banana and Jawz +extern boolean joystickicon; // Extra icons for the joystick input display // // autoload stuff diff --git a/src/k_kart.c b/src/k_kart.c index eb9b81a38..f62b7353f 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7541,6 +7541,10 @@ static patch_t *skp_speedpatchesachi[5]; static patch_t *skp_smallstickerachiclr; static patch_t *skp_speedpatchesachiclr[5]; +static patch_t *joybacking; +static patch_t *joyknob; +static patch_t *joyshadow; + void K_LoadKartHUDGraphics(void) { INT32 i, j; @@ -7667,6 +7671,13 @@ void K_LoadKartHUDGraphics(void) driftgaugesmallcolor = W_CachePatchName("K_DCSU", PU_HUDGFX); } + if (joystickicon) + { + joybacking = W_CachePatchName("JOYBCK", PU_HUDGFX); + joyknob = W_CachePatchName("JOYKNB", PU_HUDGFX); + joyshadow = W_CachePatchName("JOYSHD", PU_HUDGFX); + } + // Starting countdown kp_startcountdown[0] = W_CachePatchName("K_CNT3A", PU_HUDGFX); kp_startcountdown[1] = W_CachePatchName("K_CNT2A", PU_HUDGFX); @@ -10725,20 +10736,25 @@ static void K_drawKartFirstPerson(void) // doesn't need to ever support 4p static void K_drawInput(void) { + static INT32 pn = 0; + INT32 offs, col; + if (!cv_showinput.value && !modeattacking) // dont bother return; - static INT32 pn = 0; - INT32 target = 0, splitflags = (V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS); - INT32 x = (BASEVIDWIDTH - 32 + cv_wheel_xoffset.value)*FRACUNIT, y = (BASEVIDHEIGHT - 24 + cv_wheel_yoffset.value)*FRACUNIT; - INT32 offs, col; - const INT32 accent1 = splitflags|colortranslations[K_GetHudColor()][5]; - const INT32 accent2 = splitflags|colortranslations[K_GetHudColor()][9]; - ticcmd_t *cmd = &stplyr->cmd; - if (timeinmap <= 105) return; + INT32 target = 0, splitflags = (V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS); + INT32 x = (BASEVIDWIDTH - 32 + cv_wheel_xoffset.value)*FRACUNIT, y = (BASEVIDHEIGHT - 24 + cv_wheel_yoffset.value)*FRACUNIT; + + const UINT8 hudcolor = K_GetHudColor(); + const INT32 accent1 = splitflags|colortranslations[hudcolor][5]; + const INT32 accent2 = splitflags|colortranslations[hudcolor][9]; + const UINT8 *hudcolormap = R_GetTranslationColormap(0, hudcolor, GTC_CACHE); + + ticcmd_t *cmd = &stplyr->cmd; + if (timeinmap < 113) { INT32 count = ((INT32)(timeinmap) - 105); @@ -10785,10 +10801,19 @@ static void K_drawInput(void) INT32 joyx, joyxoffs, joyy, joyyoffs, axis; joyxoffs = -8, joyyoffs = -24; joyx = x>>FRACBITS, joyy = y>>FRACBITS; + UINT8 *shadowcolormap = NULL; // O backing - V_DrawFill(joyx+joyxoffs, joyy+joyyoffs-1, 16, 16, splitflags|accent2); - V_DrawFill(joyx+joyxoffs, joyy+joyyoffs+15, 16, 1, splitflags|31); + if (joystickicon) + { + shadowcolormap = R_GetTranslationColormap(0, SKINCOLOR_BLACK, GTC_CACHE); + V_DrawFixedPatch((joyx+joyxoffs)<driftturn || hudforward) { INT16 turning = encoremode ? -cmd->driftturn : cmd->driftturn; - // joystick hole - V_DrawFill(joyx+joyxoffs+5, joyy+joyyoffs+4, 6, 6, splitflags|accent1); - // joystick top and back - V_DrawFill(joyx+joyxoffs+3-turning/80, - joyy+joyyoffs+2-hudforward/80, - 10, 10, splitflags|31); - V_DrawFill(joyx+joyxoffs+3-turning/64, - joyy+joyyoffs+1-hudforward/64, - 10, 10, splitflags|accent1); + + if (joystickicon) + { + V_DrawFixedPatch((joyx+joyxoffs+3-turning/80)<driftturn) // no turn target = 0; else // turning of multiple strengths! @@ -10884,10 +10924,7 @@ static void K_drawInput(void) if (target > 4) target = 4; - if (K_GetHudColor()) - colormap = R_GetTranslationColormap(0, K_GetHudColor(), GTC_CACHE); - - V_DrawFixedPatch(x, y, FRACUNIT, splitflags, kp_inputwheel[target], colormap); + V_DrawFixedPatch(x, y, FRACUNIT, splitflags, kp_inputwheel[target], hudcolormap); } } From d4f97f61c2571676e4f75df00b89d6ba7d69703c Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Mar 2025 20:44:19 +0100 Subject: [PATCH 088/350] no need to check for this --- src/k_kart.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index f62b7353f..426c9c905 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8381,8 +8381,7 @@ static void K_drawKartItem(void) if (stplyr->kartstuff[k_itemroulette]) { - if (K_GetHudColor()) - localcolor = K_GetHudColor(); + localcolor = K_GetHudColor(); switch((stplyr->kartstuff[k_itemroulette] % (14*3)) / 3) { From 3963943904d0bb9bad36bf37534dcd9e4097f1ac Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Mar 2025 20:58:17 +0100 Subject: [PATCH 089/350] actually initalise those lmao --- src/d_main.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 29988ccab..7cdfdb784 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1197,34 +1197,31 @@ static boolean AddIWAD(void) } // extra graphic patches for saturn specific thingies -boolean found_extra_kart; -boolean found_extra2_kart; -boolean found_extra3_kart; +boolean found_extra_kart = false; +boolean found_extra2_kart = false; +boolean found_extra3_kart = false; -boolean xtra_speedo; // extra speedometer check -boolean xtra_speedo_clr; // extra speedometer colour check -boolean xtra_speedo3; // 80x 11 extra speedometer check -boolean xtra_speedo_clr3; // 80x 11 extra speedometer colour check -boolean achi_speedo; // achiiro speedometer check -boolean achi_speedo_clr; // extra speedometer colour check -boolean kartz_speedo; // kartZ speedo +boolean xtra_speedo = false; // extra speedometer check +boolean xtra_speedo_clr = false; // extra speedometer colour check +boolean xtra_speedo3 = false; // 80x 11 extra speedometer check +boolean xtra_speedo_clr3 = false; // 80x 11 extra speedometer colour check +boolean achi_speedo = false; // achiiro speedometer check +boolean achi_speedo_clr = false; // extra speedometer colour check +boolean kartz_speedo = false; // kartZ speedo -boolean clr_hud; // colour hud check -boolean big_lap; // bigger lap counter -boolean big_lap_color; // bigger lap counter but colour -boolean statdp; // stat display for extended player setup -boolean nametaggfx; // Nametag stuffs -boolean driftgaugegfx; // Driftgauge stuffs -boolean multiitem_icon; // Extra icons for Sneakers, Banana and Jawz -boolean joystickicon; // Extra icons for the joystick input display +boolean clr_hud = false; // colour hud check +boolean big_lap = false; // bigger lap counter +boolean big_lap_color = false; // bigger lap counter but colour +boolean statdp = false; // stat display for extended player setup +boolean nametaggfx = false; // Nametag stuffs +boolean driftgaugegfx = false; // Driftgauge stuffs +boolean multiitem_icon = false; // Extra icons for Sneakers, Banana and Jawz +boolean joystickicon = false; // Extra icons for the joystick input display // static void IdentifyVersion(void) { const char *srb2waddir = NULL; - found_extra_kart = false; - found_extra2_kart = false; - found_extra3_kart = false; #if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) // change to the directory where 'srb2.srb' is found From 1fb34eb71cfcf4a76bf400d779fb6f151c49cc81 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Mar 2025 21:43:14 +0100 Subject: [PATCH 090/350] Add 'StickGFX' option for showinput cvar if graphics for it exist --- src/d_main.c | 5 +++++ src/k_kart.c | 4 ++-- src/k_kart.h | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 7cdfdb784..80a30ebdc 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1579,8 +1579,11 @@ void D_SRB2Main(void) // Possible value that changes depending on whether required files for speedometer are found or not CV_PossibleValue_t speedo_cons_temp[NUMSPEEDOSTUFF] = {{1, "Default"}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}}; CV_PossibleValue_t driftgaugestyle_cons_temp[NUMSPEEDOSTUFF] = {{1, "Default"}, {2, "Small"}, {3, "Big Numbers"}, {4, "Numbers Only"}, {0, NULL}, {0, NULL}}; // ugh i dont want this but bleh + CV_PossibleValue_t inputdisplay_cons_temp[NUMINPUTDISPLAYSTUFF] = {{0, "Off"}, {1, "Wheel"}, {2, "Stick"}, {0, NULL}, {0, NULL}}; + unsigned last_speedo_i = 0; unsigned last_driftgauge_i = 0; + unsigned last_inputdisplay_i = 2; #define PUSHCONS(cons, i, id, name) { ++i; cons[i].value = id; cons[i].strvalue = name; } if (found_extra_kart || found_extra2_kart || found_extra3_kart) // found the funny, add it in! @@ -1651,6 +1654,7 @@ void D_SRB2Main(void) if (W_CheckMultipleLumps("JOYBCK","JOYKNB","JOYSHD", NULL)) { joystickicon = true; + PUSHCONS(inputdisplay_cons_temp, last_inputdisplay_i, 3, "StickGFX"); } // extra item icons @@ -1675,6 +1679,7 @@ void D_SRB2Main(void) #undef PUSHCONS memcpy(speedo_cons_t, speedo_cons_temp, sizeof(speedo_cons_t)); memcpy(driftgaugestyle_cons_t, driftgaugestyle_cons_temp, sizeof(driftgaugestyle_cons_t)); + memcpy(inputdisplay_cons_t, inputdisplay_cons_temp, sizeof(inputdisplay_cons_t)); // Do it before P_InitMapData because PNG patch // conversion sometimes needs the palette diff --git a/src/k_kart.c b/src/k_kart.c index 426c9c905..dcb614a8b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -91,7 +91,7 @@ consvar_t cv_airsparks = {"airdriftsparks", "Off", CV_SAVE, CV_OnOff, NULL, 0, N //extra hud things consvar_t cv_showstats = {"showstats", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -static CV_PossibleValue_t inputdisplay_cons_t[] = {{0, "Off"}, {1, "Wheel"}, {2, "Stick"}, {0, NULL}}; +CV_PossibleValue_t inputdisplay_cons_t[NUMINPUTDISPLAYSTUFF]; consvar_t cv_showinput = {"showinput", "Off", CV_SAVE, inputdisplay_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showlaptimes = {"showlaptimes", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -10795,7 +10795,7 @@ static void K_drawInput(void) y -= FRACUNIT; - if (cv_showinput.value == 2) + if (cv_showinput.value == 3) { INT32 joyx, joyxoffs, joyy, joyyoffs, axis; joyxoffs = -8, joyyoffs = -24; diff --git a/src/k_kart.h b/src/k_kart.h index 9a530703e..51176db88 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -44,6 +44,9 @@ extern consvar_t cv_huditemamount; extern CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; extern CV_PossibleValue_t driftgaugestyle_cons_t[NUMSPEEDOSTUFF]; +#define NUMINPUTDISPLAYSTUFF 5 +extern CV_PossibleValue_t inputdisplay_cons_t[NUMINPUTDISPLAYSTUFF]; + boolean K_IsPlayerLosing(player_t *player); boolean K_IsPlayerWanted(player_t *player); void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid); From 4c4efdfd11e865f4f19d1d087da3f5eb6e822464 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Mar 2025 21:29:50 +0100 Subject: [PATCH 091/350] just make the input display global toggle for it mostly done so i can shorten the entry in the menu cause i cba to mangle stuff again --- src/k_kart.c | 2 +- src/m_menu.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index dcb614a8b..c0c58eeaa 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -10738,7 +10738,7 @@ static void K_drawInput(void) static INT32 pn = 0; INT32 offs, col; - if (!cv_showinput.value && !modeattacking) // dont bother + if (!cv_showinput.value) // dont bother return; if (timeinmap <= 105) diff --git a/src/m_menu.c b/src/m_menu.c index ff2a28396..85f2e7365 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2411,7 +2411,7 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 30}, {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 35}, - {IT_STRING | IT_CVAR, NULL, "Input Display outside of RA", &cv_showinput, 45}, + {IT_STRING | IT_CVAR, NULL, "Input Display", &cv_showinput, 45}, {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 55}, @@ -2451,7 +2451,7 @@ static const char* OP_SaturnHudTooltips[] = "Enable colourized hud.", "Enable the colourized itembox when colourized hud is enabled.", "The color to use instead of the player color when\ncolourized hud is enabled.", - "Displays the input display outside of Record Attack. Also adjusts the\nposition scale to match.", + "Displays the input display and lets you choose its style.", "Enable the stat display.", "Enable the use of the higher resolution want icons instead of rank\nfor some places.", "Make the Postionnumber half the size.", From 825ab0afc0fd5eed87df3931e3abb1465dabf779 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Mar 2025 21:35:24 +0100 Subject: [PATCH 092/350] make beta interscreen cvar also affect tab rankings --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index c0c58eeaa..e2545ae46 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9157,7 +9157,7 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I { INT32 i, rightoffset = 240; const UINT8 *colormap; - INT32 dupadjust = (vid.width/vid.dupx), duptweak = (dupadjust - BASEVIDWIDTH)/2; + INT32 dupadjust = cv_betainterscreen.value ? 314 : (vid.width/vid.dupx), duptweak = cv_betainterscreen.value ? -3 : (dupadjust - BASEVIDWIDTH)/2; boolean (*_isHighlightedPlayer)(const player_t *) = (demo.playback ? P_IsDisplayPlayer : P_IsLocalPlayer); From f6e5d09ffe96b5923d35847682d84b2025b3d23a Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Mar 2025 21:36:44 +0100 Subject: [PATCH 093/350] fix stick setting showing wheel --- src/k_kart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index e2545ae46..116e8fcad 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -10795,7 +10795,7 @@ static void K_drawInput(void) y -= FRACUNIT; - if (cv_showinput.value == 3) + if (cv_showinput.value == 2 || cv_showinput.value == 3) { INT32 joyx, joyxoffs, joyy, joyyoffs, axis; joyxoffs = -8, joyyoffs = -24; @@ -10803,7 +10803,7 @@ static void K_drawInput(void) UINT8 *shadowcolormap = NULL; // O backing - if (joystickicon) + if (cv_showinput.value == 3 && joystickicon) { shadowcolormap = R_GetTranslationColormap(0, SKINCOLOR_BLACK, GTC_CACHE); V_DrawFixedPatch((joyx+joyxoffs)<driftturn : cmd->driftturn; - if (joystickicon) + if (cv_showinput.value == 3 && joystickicon) { V_DrawFixedPatch((joyx+joyxoffs+3-turning/80)< Date: Thu, 27 Mar 2025 22:00:12 +0100 Subject: [PATCH 094/350] move saturn extra file checking into its own function and also properly seperate all patch checks so they only get checked if you have the right file may actually slightly speedup startup in some cases --- src/d_main.c | 244 +++++++++++++++++++++++++++++---------------------- 1 file changed, 137 insertions(+), 107 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 80a30ebdc..ba343ec07 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1269,18 +1269,21 @@ static void IdentifyVersion(void) D_AddFile(va(pandf,srb2waddir,"patch.kart"), startupwadfiles); #endif // completely optional - if (FIL_ReadFileOK(va(pandf,srb2waddir,"extra.kart"))) { + if (FIL_ReadFileOK(va(pandf,srb2waddir,"extra.kart"))) + { D_AddFile(va(pandf,srb2waddir,"extra.kart"), startupwadfiles); found_extra_kart = true; } // completely optional 2: Back with a vengence - if (FIL_ReadFileOK(va(pandf,srb2waddir,"extra2.kart"))) { + if (FIL_ReadFileOK(va(pandf,srb2waddir,"extra2.kart"))) + { D_AddFile(va(pandf,srb2waddir,"extra2.kart"), startupwadfiles); found_extra2_kart = true; } - if (FIL_ReadFileOK(va(pandf,srb2waddir,"extra3.kart"))) { + if (FIL_ReadFileOK(va(pandf,srb2waddir,"extra3.kart"))) + { D_AddFile(va(pandf,srb2waddir,"extra3.kart"), startupwadfiles); found_extra3_kart = true; } @@ -1328,6 +1331,136 @@ static inline void D_MakeTitleString(char *s) strcpy(s, temp); } +static void D_CheckSaturnExtraFiles(void) +{ + // Possible value that changes depending on whether required files for speedometer are found or not + CV_PossibleValue_t speedo_cons_temp[NUMSPEEDOSTUFF] = {{1, "Default"}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}}; + CV_PossibleValue_t driftgaugestyle_cons_temp[NUMSPEEDOSTUFF] = {{1, "Default"}, {2, "Small"}, {3, "Big Numbers"}, {4, "Numbers Only"}, {0, NULL}, {0, NULL}}; + CV_PossibleValue_t inputdisplay_cons_temp[NUMINPUTDISPLAYSTUFF] = {{0, "Off"}, {1, "Wheel"}, {2, "Stick"}, {0, NULL}, {0, NULL}}; + + unsigned last_speedo_i = 0; + unsigned last_driftgauge_i = 0; + unsigned last_inputdisplay_i = 2; +#define PUSHCONS(cons, i, id, name) { ++i; cons[i].value = id; cons[i].strvalue = name; } + + // found the funny, add it in! + if (found_extra_kart) + { + mainwads++; + + // now check for extra speedometer stuff + if (W_CheckMultipleLumps("SP_SMSTC", "K_TRNULL", "SP_MKMH", "SP_MMPH", "SP_MFRAC", "SP_MPERC", NULL)) + { + xtra_speedo = true; + PUSHCONS(speedo_cons_temp, last_speedo_i, 2, "Small"); + } + + // now check for achii speedometer stuff + if (W_CheckMultipleLumps("SP_AMSTC", "K_TRNULL", "SP_AKMH", "SP_AMPH", "SP_AFRAC", "SP_APERC", NULL)) + { + achi_speedo = true; + PUSHCONS(speedo_cons_temp, last_speedo_i, 3, "Achii"); + } + + // check for bigger lap count + if (W_CheckMultipleLumps("K_STLAPB", "K_STLA2B", NULL)) + { + big_lap = true; + } + + // kartzspeedo + if (W_CheckMultipleLumps("K_KZSP1", "K_KZSP2", "K_KZSP3", "K_KZSP4", "K_KZSP5", + "K_KZSP6", "K_KZSP7", "K_KZSP8", "K_KZSP9", "K_KZSP10", "K_KZSP11", "K_KZSP12", + "K_KZSP13", "K_KZSP14", "K_KZSP15", "K_KZSP16", "K_KZSP17", "K_KZSP18", "K_KZSP19", + "K_KZSP20", "K_KZSP21", "K_KZSP22", "K_KZSP23", "K_KZSP24", "K_KZSP25", NULL)) + { + kartz_speedo = true; + PUSHCONS(speedo_cons_temp, last_speedo_i, 4, "P-Meter"); + } + + // stat display for extended player setup + if (W_CheckMultipleLumps("K_STATNB", "K_STATN1", "K_STATN2", + "K_STATN3", "K_STATN4", "K_STATN5", "K_STATN6", NULL)) + { + statdp = true; + } + + // Nametag stuffs + if (W_CheckMultipleLumps("NTLINE", "NTLINEV", "NTSP", "NTWH", NULL)) + { + nametaggfx = true; + } + + if (W_CheckMultipleLumps("K_DGAU","K_DCAU","K_DGSU","K_DCSU", NULL)) + { + driftgaugegfx = true; + } + + // extra item icons + if (W_CheckMultipleLumps("K_ITSHO2", "K_ITSHO3", "K_ITBAN2", "K_ITBAN3", "K_ITBAN4", "K_ITJAW2", NULL)) + { + multiitem_icon = true; + } + + if (W_CheckMultipleLumps("JOYBCK","JOYKNB","JOYSHD", NULL)) + { + joystickicon = true; + PUSHCONS(inputdisplay_cons_temp, last_inputdisplay_i, 3, "StickGFX"); + } + } + + if (found_extra2_kart) + { + mainwads++; + + if (W_LumpExists("SC_SMSTC")) + { + xtra_speedo_clr = true; + } + + if (W_CheckMultipleLumps("SC_AMSTC", "K_TRNULL", "SC_AKMH", "SC_AMPH", "SC_AFRAC", "SC_APERC", NULL)) + { + achi_speedo_clr = true; + } + + // now check for colour hud stuff + if (W_CheckMultipleLumps("K_SCTIME", "K_SCTIMW", "K_SCLAPS", "K_SCLAPW","K_SCBALN", "K_SCBALW", + "K_SCKARM", "K_SCTOUT", "K_ISMULC", "K_ITMULC", "K_ITBC", "K_ITBCD", "K_ISBC", "K_ISBCD", NULL)) + { + clr_hud = true; + } + + // check for bigger lap count but color** its color bitch + if (W_CheckMultipleLumps("K_SCLAPB", "K_SCLA2B", NULL)) + { + big_lap_color = true; + } + } + + if (found_extra3_kart) + { + mainwads++; + + // 80x11 speedometer crap + if (W_LumpExists("SP_SM3TC")) + { + xtra_speedo3 = true; + PUSHCONS(speedo_cons_temp, last_speedo_i, 5, "Extra"); + PUSHCONS(driftgaugestyle_cons_temp, last_driftgauge_i, 5, "Extra"); + } + + if (W_LumpExists("SC_SM3TC")) + { + xtra_speedo_clr3 = true; + } + } + +#undef PUSHCONS + memcpy(speedo_cons_t, speedo_cons_temp, sizeof(speedo_cons_t)); + memcpy(driftgaugestyle_cons_t, driftgaugestyle_cons_temp, sizeof(driftgaugestyle_cons_t)); + memcpy(inputdisplay_cons_t, inputdisplay_cons_temp, sizeof(inputdisplay_cons_t)); +} + // // D_SRB2Main // @@ -1576,110 +1709,7 @@ void D_SRB2Main(void) #endif //ifndef DEVELOP - // Possible value that changes depending on whether required files for speedometer are found or not - CV_PossibleValue_t speedo_cons_temp[NUMSPEEDOSTUFF] = {{1, "Default"}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}}; - CV_PossibleValue_t driftgaugestyle_cons_temp[NUMSPEEDOSTUFF] = {{1, "Default"}, {2, "Small"}, {3, "Big Numbers"}, {4, "Numbers Only"}, {0, NULL}, {0, NULL}}; // ugh i dont want this but bleh - CV_PossibleValue_t inputdisplay_cons_temp[NUMINPUTDISPLAYSTUFF] = {{0, "Off"}, {1, "Wheel"}, {2, "Stick"}, {0, NULL}, {0, NULL}}; - - unsigned last_speedo_i = 0; - unsigned last_driftgauge_i = 0; - unsigned last_inputdisplay_i = 2; -#define PUSHCONS(cons, i, id, name) { ++i; cons[i].value = id; cons[i].strvalue = name; } - - if (found_extra_kart || found_extra2_kart || found_extra3_kart) // found the funny, add it in! - { - // HAYA: These are seperated for a reason lmao - if (found_extra_kart) - mainwads++; - if (found_extra2_kart) - mainwads++; - if (found_extra3_kart) - mainwads++; - - // now check for extra speedometer stuff - if (W_CheckMultipleLumps("SP_SMSTC", "K_TRNULL", "SP_MKMH", "SP_MMPH", "SP_MFRAC", "SP_MPERC", NULL)) - { - xtra_speedo = true; - PUSHCONS(speedo_cons_temp, last_speedo_i, 2, "Small"); - } - - if (W_LumpExists("SC_SMSTC")) - xtra_speedo_clr = true; - - // now check for achii speedometer stuff - if (W_CheckMultipleLumps("SP_AMSTC", "K_TRNULL", "SP_AKMH", "SP_AMPH", "SP_AFRAC", "SP_APERC", NULL)) - { - achi_speedo = true; - PUSHCONS(speedo_cons_temp, last_speedo_i, 3, "Achii"); - } - - if (W_CheckMultipleLumps("SC_AMSTC", "K_TRNULL", "SC_AKMH", "SC_AMPH", "SC_AFRAC", "SC_APERC", NULL)) - achi_speedo_clr = true; - - // check for bigger lap count - if (W_CheckMultipleLumps("K_STLAPB", "K_STLA2B", NULL)) - big_lap = true; - - // now check for colour hud stuff - if (W_CheckMultipleLumps("K_SCTIME", "K_SCTIMW", "K_SCLAPS", "K_SCLAPW", \ - "K_SCBALN", "K_SCBALW", "K_SCKARM", "K_SCTOUT", "K_ISMULC", "K_ITMULC", "K_ITBC", "K_ITBCD", "K_ISBC", "K_ISBCD", NULL)) - clr_hud = true; - - // check for bigger lap count but color** its color bitch - if (W_CheckMultipleLumps("K_SCLAPB", "K_SCLA2B", NULL)) - big_lap_color = true; - - // kartzspeedo - if (W_CheckMultipleLumps("K_KZSP1", "K_KZSP2", "K_KZSP3", "K_KZSP4", "K_KZSP5", \ - "K_KZSP6", "K_KZSP7", "K_KZSP8", "K_KZSP9", "K_KZSP10", "K_KZSP11", "K_KZSP12", \ - "K_KZSP13", "K_KZSP14", "K_KZSP15", "K_KZSP16", "K_KZSP17", "K_KZSP18", "K_KZSP19", \ - "K_KZSP20", "K_KZSP21", "K_KZSP22", "K_KZSP23", "K_KZSP24", "K_KZSP25", NULL)) - { - kartz_speedo = true; - PUSHCONS(speedo_cons_temp, last_speedo_i, 4, "P-Meter"); - } - - // stat display for extended player setup - if (W_CheckMultipleLumps("K_STATNB", "K_STATN1", "K_STATN2", "K_STATN3", "K_STATN4", \ - "K_STATN5", "K_STATN6", NULL)) - statdp = true; - - // Nametag stuffs - if (W_CheckMultipleLumps("NTLINE", "NTLINEV", "NTSP", "NTWH", NULL)) - nametaggfx = true; - - if (W_CheckMultipleLumps("K_DGAU","K_DCAU","K_DGSU","K_DCSU", NULL)) - driftgaugegfx = true; - - if (W_CheckMultipleLumps("JOYBCK","JOYKNB","JOYSHD", NULL)) - { - joystickicon = true; - PUSHCONS(inputdisplay_cons_temp, last_inputdisplay_i, 3, "StickGFX"); - } - - // extra item icons - if (W_CheckMultipleLumps("K_ITSHO2", "K_ITSHO3", "K_ITBAN2", "K_ITBAN3", "K_ITBAN4", "K_ITJAW2", NULL)) - multiitem_icon = true; - - if (found_extra3_kart) - { - // 80x11 speedometer crap - if (W_LumpExists("SP_SM3TC")) - { - xtra_speedo3 = true; - PUSHCONS(speedo_cons_temp, last_speedo_i, 5, "Extra"); - PUSHCONS(driftgaugestyle_cons_temp, last_driftgauge_i, 5, "Extra"); - } - - if (W_LumpExists("SC_SM3TC")) - xtra_speedo_clr3 = true; - } - } - -#undef PUSHCONS - memcpy(speedo_cons_t, speedo_cons_temp, sizeof(speedo_cons_t)); - memcpy(driftgaugestyle_cons_t, driftgaugestyle_cons_temp, sizeof(driftgaugestyle_cons_t)); - memcpy(inputdisplay_cons_t, inputdisplay_cons_temp, sizeof(inputdisplay_cons_t)); + D_CheckSaturnExtraFiles(); // check all the saturn stuff :3 // Do it before P_InitMapData because PNG patch // conversion sometimes needs the palette From 53d698573ec5f066c07d7e4b3248bd2c4ba74425 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Mar 2025 22:12:22 +0100 Subject: [PATCH 095/350] fix driftgauge value "small" value being overwritten when having extra3 loaded --- src/d_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index ba343ec07..f9af30674 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1339,7 +1339,7 @@ static void D_CheckSaturnExtraFiles(void) CV_PossibleValue_t inputdisplay_cons_temp[NUMINPUTDISPLAYSTUFF] = {{0, "Off"}, {1, "Wheel"}, {2, "Stick"}, {0, NULL}, {0, NULL}}; unsigned last_speedo_i = 0; - unsigned last_driftgauge_i = 0; + unsigned last_driftgauge_i = 3; unsigned last_inputdisplay_i = 2; #define PUSHCONS(cons, i, id, name) { ++i; cons[i].value = id; cons[i].strvalue = name; } From 2582f6fe931fdd935b678e81ede6bc4d56b106a3 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Mar 2025 22:21:35 +0100 Subject: [PATCH 096/350] seperate the driftgauge colour patches into extra2 + add some more comments was an oversight, extra2 should be for all colour hud patches --- src/d_main.c | 25 ++++++++++++++++++++----- src/d_main.h | 3 ++- src/k_kart.c | 4 ++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index f9af30674..8057b57ae 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1210,6 +1210,7 @@ boolean achi_speedo_clr = false; // extra speedometer colour check boolean kartz_speedo = false; // kartZ speedo boolean clr_hud = false; // colour hud check +boolean driftgaugegfx_clr = false; // driftgauge colour check boolean big_lap = false; // bigger lap counter boolean big_lap_color = false; // bigger lap counter but colour boolean statdp = false; // stat display for extended player setup @@ -1391,7 +1392,8 @@ static void D_CheckSaturnExtraFiles(void) nametaggfx = true; } - if (W_CheckMultipleLumps("K_DGAU","K_DCAU","K_DGSU","K_DCSU", NULL)) + // driftgauge + if (W_CheckMultipleLumps("K_DGAU","K_DGSU", NULL)) { driftgaugegfx = true; } @@ -1402,6 +1404,7 @@ static void D_CheckSaturnExtraFiles(void) multiitem_icon = true; } + // extra round joystick inputdisplay sprites if (W_CheckMultipleLumps("JOYBCK","JOYKNB","JOYSHD", NULL)) { joystickicon = true; @@ -1409,25 +1412,34 @@ static void D_CheckSaturnExtraFiles(void) } } + // now check for colour hud stuff if (found_extra2_kart) { mainwads++; + // kart vanilla hud patches but colourizable + if (W_CheckMultipleLumps("K_SCTIME", "K_SCTIMW", "K_SCLAPS", "K_SCLAPW","K_SCBALN", "K_SCBALW", + "K_SCKARM", "K_SCTOUT", "K_ISMULC", "K_ITMULC", "K_ITBC", "K_ITBCD", "K_ISBC", "K_ISBCD", NULL)) + { + clr_hud = true; + } + + // extra speedo but colour if (W_LumpExists("SC_SMSTC")) { xtra_speedo_clr = true; } + // achii speedo but colour if (W_CheckMultipleLumps("SC_AMSTC", "K_TRNULL", "SC_AKMH", "SC_AMPH", "SC_AFRAC", "SC_APERC", NULL)) { achi_speedo_clr = true; } - // now check for colour hud stuff - if (W_CheckMultipleLumps("K_SCTIME", "K_SCTIMW", "K_SCLAPS", "K_SCLAPW","K_SCBALN", "K_SCBALW", - "K_SCKARM", "K_SCTOUT", "K_ISMULC", "K_ITMULC", "K_ITBC", "K_ITBCD", "K_ISBC", "K_ISBCD", NULL)) + // driftgauge but colour + if (W_CheckMultipleLumps("K_DCAU","K_DCSU", NULL)) { - clr_hud = true; + driftgaugegfx_clr = true; } // check for bigger lap count but color** its color bitch @@ -1437,6 +1449,8 @@ static void D_CheckSaturnExtraFiles(void) } } + // can be used for custom hud stuff + // currently used for the v1 beta hud if (found_extra3_kart) { mainwads++; @@ -1449,6 +1463,7 @@ static void D_CheckSaturnExtraFiles(void) PUSHCONS(driftgaugestyle_cons_temp, last_driftgauge_i, 5, "Extra"); } + // 80x11 speedometer crap but colour if (W_LumpExists("SC_SM3TC")) { xtra_speedo_clr3 = true; diff --git a/src/d_main.h b/src/d_main.h index 2ca97839c..2c3b6cf54 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -38,9 +38,10 @@ extern boolean xtra_speedo3; // 80x11 extra speedometer check extern boolean xtra_speedo_clr3; // 80x11 extra speedometer colour check extern boolean achi_speedo; // achiiro speedometer check extern boolean achi_speedo_clr; // extra speedometer colour check -extern boolean kartz_speedo; // kartZ speedo +extern boolean kartz_speedo; // kartZ speedo extern boolean clr_hud; // colour hud check +extern boolean driftgaugegfx_clr; // driftgauge colour check extern boolean big_lap; // bigger lap counter extern boolean big_lap_color; // bigger lap counter but colour extern boolean statdp; // stat display for extended player setup diff --git a/src/k_kart.c b/src/k_kart.c index 116e8fcad..8e1c83121 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7667,6 +7667,10 @@ void K_LoadKartHUDGraphics(void) { driftgauge = W_CachePatchName("K_DGAU", PU_HUDGFX); driftgaugecolor = W_CachePatchName("K_DCAU", PU_HUDGFX); + } + + if (driftgaugegfx_clr) + { driftgaugesmall = W_CachePatchName("K_DGSU", PU_HUDGFX); driftgaugesmallcolor = W_CachePatchName("K_DCSU", PU_HUDGFX); } From d323b78d3fe54e4a54e7f51a96d05668b2db0928 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Mar 2025 22:48:29 +0100 Subject: [PATCH 097/350] seperate the colour hud patches out of here so they can be used without the vanilla colour hud --- src/k_kart.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 8e1c83121..f8a6d063c 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7614,27 +7614,28 @@ void K_LoadKartHUDGraphics(void) kp_itembgclr[3] = W_CachePatchName("K_ISBCD", PU_HUDGFX); kp_itemmulstickerclr[1] = W_CachePatchName("K_ISMULC", PU_HUDGFX); kp_itemmulstickerclr[0] = W_CachePatchName("K_ITMULC", PU_HUDGFX); + } - if (big_lap_color){ - kp_lapstickerbigclr = W_CachePatchName("K_SCLAPB", PU_HUDGFX); - kp_lapstickerbig2clr = W_CachePatchName("K_SCLA2B", PU_HUDGFX); - } + if (big_lap_color) + { + kp_lapstickerbigclr = W_CachePatchName("K_SCLAPB", PU_HUDGFX); + kp_lapstickerbig2clr = W_CachePatchName("K_SCLA2B", PU_HUDGFX); + } - if (xtra_speedo && xtra_speedo_clr) - skp_smallstickerclr = W_CachePatchName("SC_SMSTC", PU_HUDGFX); + if (xtra_speedo && xtra_speedo_clr) + skp_smallstickerclr = W_CachePatchName("SC_SMSTC", PU_HUDGFX); - if (xtra_speedo3 && xtra_speedo_clr3) // 80x11 patch scaled to size - skp_smallstickerclr3 = W_CachePatchName("SC_SM3TC", PU_HUDGFX); + if (xtra_speedo3 && xtra_speedo_clr3) // 80x11 patch scaled to size + skp_smallstickerclr3 = W_CachePatchName("SC_SM3TC", PU_HUDGFX); - if (achi_speedo && achi_speedo_clr) - { - skp_smallstickerachiclr = W_CachePatchName("SC_AMSTC", PU_HUDGFX); - skp_speedpatchesachiclr[0] = W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd - skp_speedpatchesachiclr[1] = W_CachePatchName("SC_AKMH", PU_HUDGFX); - skp_speedpatchesachiclr[2] = W_CachePatchName("SC_AMPH", PU_HUDGFX); - skp_speedpatchesachiclr[3] = W_CachePatchName("SC_AFRAC", PU_HUDGFX); - skp_speedpatchesachiclr[4] = W_CachePatchName("SC_APERC", PU_HUDGFX); - } + if (achi_speedo && achi_speedo_clr) + { + skp_smallstickerachiclr = W_CachePatchName("SC_AMSTC", PU_HUDGFX); + skp_speedpatchesachiclr[0] = W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd + skp_speedpatchesachiclr[1] = W_CachePatchName("SC_AKMH", PU_HUDGFX); + skp_speedpatchesachiclr[2] = W_CachePatchName("SC_AMPH", PU_HUDGFX); + skp_speedpatchesachiclr[3] = W_CachePatchName("SC_AFRAC", PU_HUDGFX); + skp_speedpatchesachiclr[4] = W_CachePatchName("SC_APERC", PU_HUDGFX); } // KartZ speedo From ac181e238deb331a0cb88dda7d73b62e81f3234c Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Mar 2025 23:27:20 +0100 Subject: [PATCH 098/350] add smol P-Meter patches thx jin for those --- src/d_main.c | 16 +++++++++++++--- src/d_main.h | 1 + src/k_kart.c | 40 ++++++++++++++++++++++++++++++++-------- src/k_kart.h | 6 +++--- 4 files changed, 49 insertions(+), 14 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 8057b57ae..541b9830a 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1208,6 +1208,7 @@ boolean xtra_speedo_clr3 = false; // 80x 11 extra speedometer colour check boolean achi_speedo = false; // achiiro speedometer check boolean achi_speedo_clr = false; // extra speedometer colour check boolean kartz_speedo = false; // kartZ speedo +boolean kartz_speedo_smol = false; // kartZ speedo but smol boolean clr_hud = false; // colour hud check boolean driftgaugegfx_clr = false; // driftgauge colour check @@ -1335,8 +1336,8 @@ static inline void D_MakeTitleString(char *s) static void D_CheckSaturnExtraFiles(void) { // Possible value that changes depending on whether required files for speedometer are found or not - CV_PossibleValue_t speedo_cons_temp[NUMSPEEDOSTUFF] = {{1, "Default"}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}}; - CV_PossibleValue_t driftgaugestyle_cons_temp[NUMSPEEDOSTUFF] = {{1, "Default"}, {2, "Small"}, {3, "Big Numbers"}, {4, "Numbers Only"}, {0, NULL}, {0, NULL}}; + CV_PossibleValue_t speedo_cons_temp[NUMSPEEDOSTUFF] = {{1, "Default"}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}}; + CV_PossibleValue_t driftgaugestyle_cons_temp[NUMDGAUGESTUFF] = {{1, "Default"}, {2, "Small"}, {3, "Big Numbers"}, {4, "Numbers Only"}, {0, NULL}, {0, NULL}}; CV_PossibleValue_t inputdisplay_cons_temp[NUMINPUTDISPLAYSTUFF] = {{0, "Off"}, {1, "Wheel"}, {2, "Stick"}, {0, NULL}, {0, NULL}}; unsigned last_speedo_i = 0; @@ -1379,6 +1380,15 @@ static void D_CheckSaturnExtraFiles(void) PUSHCONS(speedo_cons_temp, last_speedo_i, 4, "P-Meter"); } + if (W_CheckMultipleLumps("K_KZSS1", "K_KZSS2", "K_KZSS3", "K_KZSS4", "K_KZSS5", + "K_KZSS6", "K_KZSS7", "K_KZSS8", "K_KZSS9", "K_KZSS10", "K_KZSS11", "K_KZSS12", + "K_KZSS13", "K_KZSS14", "K_KZSS15", "K_KZSS16", "K_KZSS17", "K_KZSS18", "K_KZSS19", + "K_KZSS20", "K_KZSS21", "K_KZSS22", "K_KZSS23", "K_KZSS24", "K_KZSS25", NULL)) + { + kartz_speedo_smol = true; + PUSHCONS(speedo_cons_temp, last_speedo_i, 5, "P-Meter Small"); + } + // stat display for extended player setup if (W_CheckMultipleLumps("K_STATNB", "K_STATN1", "K_STATN2", "K_STATN3", "K_STATN4", "K_STATN5", "K_STATN6", NULL)) @@ -1459,7 +1469,7 @@ static void D_CheckSaturnExtraFiles(void) if (W_LumpExists("SP_SM3TC")) { xtra_speedo3 = true; - PUSHCONS(speedo_cons_temp, last_speedo_i, 5, "Extra"); + PUSHCONS(speedo_cons_temp, last_speedo_i, 6, "Extra"); PUSHCONS(driftgaugestyle_cons_temp, last_driftgauge_i, 5, "Extra"); } diff --git a/src/d_main.h b/src/d_main.h index 2c3b6cf54..84c19e6e5 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -39,6 +39,7 @@ extern boolean xtra_speedo_clr3; // 80x11 extra speedometer colour check extern boolean achi_speedo; // achiiro speedometer check extern boolean achi_speedo_clr; // extra speedometer colour check extern boolean kartz_speedo; // kartZ speedo +extern boolean kartz_speedo_smol; // kartZ speedo but smol extern boolean clr_hud; // colour hud check extern boolean driftgaugegfx_clr; // driftgauge colour check diff --git a/src/k_kart.c b/src/k_kart.c index f8a6d063c..899e82ffb 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -208,7 +208,7 @@ consvar_t cv_colorizedhudcolor = {"colorizedhudcolor", "Skin Color", CV_SAVE, Hu // driftgauge stuffs static CV_PossibleValue_t driftgaugeoffset_cons_t[] = { {-FRACUNIT*128, "MIN"}, {FRACUNIT*128, "MAX"}, {0, NULL}}; -CV_PossibleValue_t driftgaugestyle_cons_t[NUMSPEEDOSTUFF]; +CV_PossibleValue_t driftgaugestyle_cons_t[NUMDGAUGESTUFF]; consvar_t cv_driftgauge = {"kartdriftgauge", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_driftgaugeofs = {"kartdriftgaugeoffset", "-20", CV_FLOAT|CV_SAVE, driftgaugeoffset_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -7456,6 +7456,7 @@ static patch_t *kp_itembgclr[4]; //Kartz speedo static patch_t *kp_kartzspeedo[25]; +static patch_t *kp_kartzspeedo_smol[25]; static patch_t *kp_startcountdown[16]; static patch_t *kp_racefinish[6]; @@ -7630,7 +7631,7 @@ void K_LoadKartHUDGraphics(void) if (achi_speedo && achi_speedo_clr) { - skp_smallstickerachiclr = W_CachePatchName("SC_AMSTC", PU_HUDGFX); + skp_smallstickerachiclr = W_CachePatchName("SC_AMSTC", PU_HUDGFX); skp_speedpatchesachiclr[0] = W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd skp_speedpatchesachiclr[1] = W_CachePatchName("SC_AKMH", PU_HUDGFX); skp_speedpatchesachiclr[2] = W_CachePatchName("SC_AMPH", PU_HUDGFX); @@ -7655,6 +7656,22 @@ void K_LoadKartHUDGraphics(void) } } + if (kartz_speedo_smol) + { + const char* patchNames[] = { + "K_KZSS1", "K_KZSS2", "K_KZSS3", "K_KZSS4", "K_KZSS5", + "K_KZSS6", "K_KZSS7", "K_KZSS8", "K_KZSS9", "K_KZSS10", + "K_KZSS11", "K_KZSS12", "K_KZSS13", "K_KZSS14", "K_KZSS15", + "K_KZSS16", "K_KZSS17", "K_KZSS18", "K_KZSS19", "K_KZSS20", + "K_KZSS21", "K_KZSS22", "K_KZSS23", "K_KZSS24", "K_KZSS25" + }; + + for (size_t m = 0; m < sizeof(patchNames) / sizeof(patchNames[0]); ++m) + { + kp_kartzspeedo_smol[m] = W_CachePatchName(patchNames[m], PU_HUDGFX); + } + } + // Nametags if (nametaggfx) { @@ -8271,7 +8288,7 @@ static void K_drawKartStats(void) //Internal offset for speedometer if (cv_kartspeedometer.value) { - if ((cv_newspeedometer.value == 2 && xtra_speedo) || (cv_newspeedometer.value == 3 && achi_speedo) || (cv_newspeedometer.value == 5 && xtra_speedo3)) + if ((cv_newspeedometer.value == 2 && xtra_speedo) || (cv_newspeedometer.value == 3 && achi_speedo) || (cv_newspeedometer.value == 6 && xtra_speedo3)) spdoffset = -10; else spdoffset = -14; @@ -9339,7 +9356,7 @@ static void K_drawKartSpeedometer(void) INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); // man. - const boolean useoldspeedo = ((cv_newspeedometer.value == 1) || (cv_newspeedometer.value == 2 && !xtra_speedo) || (cv_newspeedometer.value == 3 && !achi_speedo) || (cv_newspeedometer.value == 4 && !kartz_speedo) || (cv_newspeedometer.value == 5 && !xtra_speedo3)); + const boolean useoldspeedo = ((cv_newspeedometer.value == 1) || (cv_newspeedometer.value == 2 && !xtra_speedo) || (cv_newspeedometer.value == 3 && !achi_speedo) || (cv_newspeedometer.value == 4 && !kartz_speedo) || (cv_newspeedometer.value == 5 && !kartz_speedo_smol) ||(cv_newspeedometer.value == 6 && !xtra_speedo3)); switch (cv_kartspeedometer.value) { @@ -9417,7 +9434,7 @@ static void K_drawKartSpeedometer(void) V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatchesachi[cv_kartspeedometer.value]); } } - else if (cv_newspeedometer.value == 5 && xtra_speedo3) // why bother if we dont? + else if (cv_newspeedometer.value == 6 && xtra_speedo3) // why bother if we dont? { if (K_UseColorHud() && xtra_speedo_clr3) //Colourized hud { @@ -9432,7 +9449,7 @@ static void K_drawKartSpeedometer(void) } // Kart Z speedo bullshit... // Draw the Speed counter. - else if (cv_newspeedometer.value == 4 && kartz_speedo) + else if ((cv_newspeedometer.value == 4 && kartz_speedo) || (cv_newspeedometer.value == 5 && kartz_speedo_smol)) { fixed_t fuspeed = 0; INT32 spdpatch = 0; @@ -9457,7 +9474,14 @@ static void K_drawKartSpeedometer(void) else if (((fuspeed < 57 && fuspeed > 54) || (fuspeed < 60 && fuspeed > 56) || (fuspeed > 59)) && !(leveltime & 4)) spdpatch = 23; - V_DrawScaledPatch(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, kp_kartzspeedo[spdpatch]); + patch_t *patch = NULL; + + if (cv_newspeedometer.value == 4 && kartz_speedo) + patch = kp_kartzspeedo[spdpatch]; + else if (cv_newspeedometer.value == 5 && kartz_speedo_smol) + patch = kp_kartzspeedo_smol[spdpatch]; + + V_DrawScaledPatch(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, patch); } } @@ -9477,7 +9501,7 @@ static void K_drawKartBumpersOrKarma(void) if (cv_battlespeedo.value && !splitscreen) { - if ((cv_newspeedometer.value == 2 && xtra_speedo) || (cv_newspeedometer.value == 3 && achi_speedo) || (cv_newspeedometer.value == 5 && xtra_speedo3)) + if ((cv_newspeedometer.value == 2 && xtra_speedo) || (cv_newspeedometer.value == 3 && achi_speedo) || (cv_newspeedometer.value == 6 && xtra_speedo3)) fy += 5; else fy += 7; diff --git a/src/k_kart.h b/src/k_kart.h index 51176db88..8032d5cd7 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -40,10 +40,10 @@ extern consvar_t cv_battlespeedo; extern consvar_t cv_multiitemicon; extern consvar_t cv_huditemamount; -#define NUMSPEEDOSTUFF 6 +#define NUMSPEEDOSTUFF 7 extern CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; -extern CV_PossibleValue_t driftgaugestyle_cons_t[NUMSPEEDOSTUFF]; - +#define NUMDGAUGESTUFF 6 +extern CV_PossibleValue_t driftgaugestyle_cons_t[NUMDGAUGESTUFF]; #define NUMINPUTDISPLAYSTUFF 5 extern CV_PossibleValue_t inputdisplay_cons_t[NUMINPUTDISPLAYSTUFF]; From 4a62b4452681e50bd8e162cee22d4761bff708a7 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Mar 2025 23:33:11 +0100 Subject: [PATCH 099/350] remove pointless function --- src/k_kart.c | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 899e82ffb..e4a7cc726 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -141,43 +141,16 @@ consvar_t cv_spinoutroll = {"spinoutroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NU //hardcode saltyhop mhhm static void saltyhop_onchange(void); -static void saltyheight_onchange(void); consvar_t cv_saltyhop = {"hardcodehop", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, saltyhop_onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_saltyhopsfx = {"hardcodehopsfx", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_saltysquish = {"hardcodehopsquish", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t saltyheight_t[] = {{FRACUNIT/4, "MIN"}, {2*FRACUNIT, "MAX"}, {0, NULL}}; -consvar_t cv_saltyheight = {"hardcodehopheight", "1", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, saltyheight_t, saltyheight_onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_saltyheight = {"hardcodehopheight", "1", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, saltyheight_t, saltyhop_onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_saltyroll = {"hardcodehoproll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static void saltyhop_onchange(void) { - // reset everything when toggling saltyhop off - if (!cv_saltyhop.value) - { - if (gamestate != GS_LEVEL) - return; - - for (INT32 i = 0; i < MAXPLAYERS; i++) - { - player_t *player = &players[i]; - - if (!player || !playeringame[i] || P_MobjWasRemoved(player->mo)) - continue; - - player->mo->salty_jump = false; - player->mo->salty_zoffset = 0; - player->mo->salty_momz = 0; - - player->mo->salty_ready = false; - player->mo->salty_tapping = false; - player->mo->init_salty = false; - } - } -} - -static void saltyheight_onchange(void) -{ - // reset everything when toggling saltyhop height + // reset everything when toggling saltyhop if (gamestate != GS_LEVEL) return; From 6919e3cdc8ee6f701476583517ba7d11575788d2 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Mar 2025 23:37:50 +0100 Subject: [PATCH 100/350] turn this into a switch for no reason --- src/k_kart.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index e4a7cc726..04a402526 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2476,14 +2476,19 @@ void K_SpawnBattlePoints(player_t *source, player_t *victim, UINT8 amount) if (!source || !source->mo) return; - if (amount == 1) - st = S_BATTLEPOINT1A; - else if (amount == 2) - st = S_BATTLEPOINT2A; - else if (amount == 3) - st = S_BATTLEPOINT3A; - else - return; // NO STATE! + switch (amount) + { + case 1: + st = S_BATTLEPOINT1A; + break; + case 2: + st = S_BATTLEPOINT2A; + break; + case 3: + st = S_BATTLEPOINT3A; + default: + return; // NO STATE! + } pt = P_SpawnMobj(source->mo->x, source->mo->y, source->mo->z, MT_BATTLEPOINT); P_SetTarget(&pt->target, source->mo); From c2e0e56a804ce6b7922e5fe9e6becb3fb5e7000d Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 28 Mar 2025 01:12:14 +0100 Subject: [PATCH 101/350] optimize director by checking for finishline waypoint on mapload instead of every time this is called --- src/k_director.c | 88 +++++++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 39 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index c8cf4dbeb..7c0dfc2c1 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -64,6 +64,48 @@ static boolean K_DirectorIsEnabled(void) return (cv_director.value && K_DirectorIsAvailable()); } +static mobj_t *finishmo = NULL; + +// scan for the waypoint on the finish line +// used to get a very approximate distance from player to finishline +// we probably should like, do some maths to find the middle point between multiplayer +// waypoints with the same values, but idk if its really worth it +static void K_SetupFinishMo(void) +{ + INT16 maxMoveCount = -1; + INT16 maxAngle = -1; + + P_SetTarget(&finishmo, NULL); + + if (!(mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE)) // not a sprint map + { + // waypoint with angle 0 should always be at the finish line + for (finishmo = waypointcap; finishmo != NULL; finishmo = finishmo->tracer) + { + if (finishmo->spawnpoint->angle == 0) + break; + } + } + else // crappy optimization weeeee + { + // sprint maps finishline waypoint is the one with highest movecount AND angle + for (finishmo = waypointcap; finishmo != NULL; finishmo = finishmo->tracer) + { + if (finishmo->movecount > maxMoveCount) + maxMoveCount = finishmo->movecount; + if (finishmo->spawnpoint->angle > maxAngle) + maxAngle = finishmo->spawnpoint->angle; + } + + // now actually get the one + for (finishmo = waypointcap; finishmo != NULL; finishmo = finishmo->tracer) + { + if (finishmo->movecount == maxMoveCount && finishmo->spawnpoint->angle == maxAngle) + break; // found it + } + } +} + void K_InitDirector(void) { INT32 playernum; @@ -80,50 +122,18 @@ void K_InitDirector(void) directorinfo.gap[playernum] = INT32_MAX; directorinfo.boredom[playernum] = 0; } + + K_SetupFinishMo(); } static fixed_t K_GetDistanceToFinish(player_t player) { - mobj_t *mo; - fixed_t dist = 0; - INT16 maxMoveCount = -1; - INT16 maxAngle = -1; + if (P_MobjWasRemoved(finishmo)) + return 0; - if (!(mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE)) - { - for (mo = waypointcap; mo != NULL; mo = mo->tracer) - { - if (mo->spawnpoint->angle != 0) - continue; - - dist = P_AproxDistance(P_AproxDistance(mo->x - player.mo->x, - mo->y - player.mo->y), - mo->z - player.mo->z) / FRACUNIT; - - break; - } - } - else // crappy optimization weeeee - { - for (mo = waypointcap; mo != NULL; mo = mo->tracer) - { - if (mo->movecount > maxMoveCount) - maxMoveCount = mo->movecount; - if (mo->spawnpoint->angle > maxAngle) - maxAngle = mo->spawnpoint->angle; - - if (!(mo->movecount == maxMoveCount && mo->spawnpoint->angle == maxAngle)) // sprint maps finishline waypoint is the one with highest movecount AND angle - continue; - - dist = P_AproxDistance(P_AproxDistance(mo->x - player.mo->x, - mo->y - player.mo->y), - mo->z - player.mo->z) / FRACUNIT; - - break; - } - } - - return dist; + return P_AproxDistance(P_AproxDistance(finishmo->x - player.mo->x, + finishmo->y - player.mo->y), + finishmo->z - player.mo->z) / FRACUNIT; } static fixed_t K_GetFinishGap(INT32 leader, INT32 follower) From 72821f0f16d8b19313edd7901bc1809230f5d27d Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 28 Mar 2025 01:36:46 +0100 Subject: [PATCH 102/350] you cant memset this to -1 lel prob fixes the director never switching when only one player was left --- src/k_director.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/k_director.c b/src/k_director.c index 7c0dfc2c1..ab8a76f03 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -156,8 +156,12 @@ static void K_UpdateDirectorPositions(void) INT32 playernum; INT32 position; player_t* target; + INT32 i; - memset(directorinfo.sortedplayers, -1, sizeof(directorinfo.sortedplayers)); + for (i = 0; i < MAXPLAYERS; i++) + { + directorinfo.sortedplayers[i] = -1; + } for (playernum = 0; playernum < MAXPLAYERS; playernum++) { From 5e8624c79c8f8b9813f00fe0cdf1673f94dc971d Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 28 Mar 2025 02:13:04 +0100 Subject: [PATCH 103/350] only count actually playing players for director otherwise you could enable it if theres more than 1 person in the server but only 1 person is actually playing --- src/k_director.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/k_director.c b/src/k_director.c index ab8a76f03..d3e74786e 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -42,6 +42,19 @@ struct directorinfo INT32 boredom[MAXPLAYERS]; // how long has a given position had no credible attackers? } directorinfo; +static INT32 K_PlayersPlaying(void) +{ + INT32 num = 0, i; + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].spectator || !players[i].mo) + continue; + + num++; + } + return num; +} + static inline boolean race_rules(void) { return gametype == GT_RACE; @@ -56,7 +69,7 @@ boolean K_DirectorIsAvailable(void) { if (splitscreen || (demo.playback && demo.title) || modeattacking) return false; - return ((gamestate == GS_LEVEL) && ((demo.playback && !camera[0].freecam) || (players[consoleplayer].spectator && (D_NumPlayers() > 1)))); + return ((gamestate == GS_LEVEL) && ((demo.playback && !camera[0].freecam) || (players[consoleplayer].spectator && (K_PlayersPlaying() > 1)))); } static boolean K_DirectorIsEnabled(void) From 5f5c67601e3700f02b51bab84495ac41e2d4437f Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 28 Mar 2025 02:14:30 +0100 Subject: [PATCH 104/350] instant switch if the player we watch is finishing i dont need to watch the finishline for 5 seconds everytime lmao --- src/k_director.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/k_director.c b/src/k_director.c index d3e74786e..a3f3c3f45 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -258,6 +258,25 @@ static void K_DirectorForceSwitch(INT32 player, INT32 time) directorinfo.freeze = time; } +static void K_DirectorSwitchRandom(void) +{ + INT32 randomplayer = -1; + + // kinda dumb but just check if the random player is existing lmao + for (INT32 h = 0; h < MAXPLAYERS; h++) + { + randomplayer = directorinfo.sortedplayers[M_RandomRange(0, K_PlayersPlaying()-1)]; // switch to someone random + + if (randomplayer != -1 && randomplayer != displayplayers[0]) // dont switch to ourselves Zzz... + { + break; + } + } + + if (randomplayer != -1) + K_DirectorSwitch(randomplayer, true); +} + void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source) { if (!K_DirectorIsEnabled()) @@ -344,7 +363,8 @@ void K_UpdateDirector(void) K_UpdateDirectorPositions(); - if (directorinfo.cooldown > 0) { + if (directorinfo.cooldown > 0) + { directorinfo.cooldown--; } @@ -366,6 +386,13 @@ void K_UpdateDirector(void) return; } + // insta switch if the player were watching finishes + if (players[displayplayers[0]].exiting) + { + K_DirectorSwitchRandom(); + return; + } + // aaight, time to walk through the standings to find the first interesting pair // NB: targetposition/sortedplayers is 0-indexed, aiming at the "back half" of a given pair by default. // we adjust for this when comparing to player->position or when looking at the leading player, Don't Freak Out From 089984968172909311acb44d9305e22bcb5bb7b6 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 28 Mar 2025 02:14:44 +0100 Subject: [PATCH 105/350] forgor the header file --- src/k_director.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/k_director.c b/src/k_director.c index a3f3c3f45..3127debbe 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -14,6 +14,7 @@ #include "doomdef.h" #include "doomstat.h" #include "g_game.h" +#include "m_random.h" #include "v_video.h" #include "k_director.h" #include "d_netcmd.h" From 7f59674ea837b1ba621503995c3bdb0e2d5c27f5 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 28 Mar 2025 02:16:12 +0100 Subject: [PATCH 106/350] force switch player after 15 seconds max not sure if its too strict but it gets really boring just watching the same person for ages --- src/k_director.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/k_director.c b/src/k_director.c index 3127debbe..add5f773d 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -34,6 +34,7 @@ struct directorinfo { player_t* viewplayer; tic_t cooldown; // how long has it been since we last switched? + tic_t chaosleep;// how long did we watch the same player? tic_t freeze; // when nonzero, fixed switch pending, freeze logic! INT32 attacker; // who to switch to when freeze delay elapses INT32 maxdist; // how far is the closest player from finishing? @@ -129,6 +130,7 @@ void K_InitDirector(void) directorinfo.attacker = 0; directorinfo.maxdist = 0; directorinfo.viewplayer = NULL; + directorinfo.chaosleep = 0; for (playernum = 0; playernum < MAXPLAYERS; playernum++) { @@ -246,6 +248,7 @@ static void K_DirectorSwitch(INT32 player, boolean force) G_ResetView(1, player, true); directorinfo.cooldown = SWITCHTIME; + directorinfo.chaosleep = 0; } static void K_DirectorForceSwitch(INT32 player, INT32 time) @@ -257,6 +260,7 @@ static void K_DirectorForceSwitch(INT32 player, INT32 time) directorinfo.attacker = player; directorinfo.freeze = time; + directorinfo.chaosleep = 0; } static void K_DirectorSwitchRandom(void) @@ -318,6 +322,7 @@ void K_DrawDirectorDebugger(void) V_DrawThinString(120, 0, V_70TRANS, va("BORED")); V_DrawThinString(150, 0, V_70TRANS, va("COOLDOWN: %d", directorinfo.cooldown)); V_DrawThinString(230, 0, V_70TRANS, va("MAXDIST: %d", directorinfo.maxdist)); + V_DrawThinString(310, 0, V_70TRANS, va("SLEEPTIME: %d", directorinfo.chaosleep)); for (position = 0; position < MAXPLAYERS - 1; position++) { @@ -394,6 +399,20 @@ void K_UpdateDirector(void) return; } + // begin counting when cooldown wore off + if (!directorinfo.cooldown) + { + directorinfo.chaosleep++; + } + + // force switch 10 seconds after the cooldown has ended + // otherwise i fall asleeb zzz... + if (directorinfo.chaosleep > TICRATE*10) + { + K_DirectorSwitchRandom(); + return; + } + // aaight, time to walk through the standings to find the first interesting pair // NB: targetposition/sortedplayers is 0-indexed, aiming at the "back half" of a given pair by default. // we adjust for this when comparing to player->position or when looking at the leading player, Don't Freak Out From 42f1a55fa734a165ce3923c51eb0985aef16d792 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 28 Mar 2025 02:35:53 +0100 Subject: [PATCH 107/350] can just reset this here --- src/k_director.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index add5f773d..0e65bdd22 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -172,15 +172,11 @@ static void K_UpdateDirectorPositions(void) INT32 playernum; INT32 position; player_t* target; - INT32 i; - - for (i = 0; i < MAXPLAYERS; i++) - { - directorinfo.sortedplayers[i] = -1; - } for (playernum = 0; playernum < MAXPLAYERS; playernum++) { + directorinfo.sortedplayers[playernum] = -1; + target = &players[playernum]; if (playeringame[playernum] && !target->spectator && target->kartstuff[k_position] > 0) From e540cc901c2ef481be72947a303d7fbae7ace327 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 28 Mar 2025 07:10:26 +0100 Subject: [PATCH 108/350] tiny cleanup inputdisplay just use V_DrawMappedPatch, it does the same but looks better in code lel --- src/k_kart.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 04a402526..5d018049a 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -10808,12 +10808,13 @@ static void K_drawInput(void) joyxoffs = -8, joyyoffs = -24; joyx = x>>FRACBITS, joyy = y>>FRACBITS; UINT8 *shadowcolormap = NULL; + const boolean usejoysprite = (cv_showinput.value == 3 && joystickicon); // O backing - if (cv_showinput.value == 3 && joystickicon) + if (usejoysprite) { shadowcolormap = R_GetTranslationColormap(0, SKINCOLOR_BLACK, GTC_CACHE); - V_DrawFixedPatch((joyx+joyxoffs)<driftturn : cmd->driftturn; - if (cv_showinput.value == 3 && joystickicon) + if (usejoysprite) { - V_DrawFixedPatch((joyx+joyxoffs+3-turning/80)< Date: Fri, 28 Mar 2025 07:12:37 +0100 Subject: [PATCH 109/350] make a function that returns the newspeedometer style if its availible makes stuff alot easier to read than constantly checking for if stuff exists everywhere --- src/k_kart.c | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 5d018049a..b80293ff4 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -742,6 +742,32 @@ boolean K_UseColorHud(void) return (cv_colorizedhud.value && clr_hud); } +enum +{ + SPEEDO_VANILLA, + SPEEDO_EXTRA, + SPEEDO_ACHII, + SPEEDO_PMETER, + SPEEDO_PMETERSMOL, + SPEEDO_EXTRA3, +}; + +static UINT8 K_GetSpeedometerStyle(void) +{ + if (cv_newspeedometer.value == 2 && xtra_speedo) + return SPEEDO_EXTRA; + else if (cv_newspeedometer.value == 3 && achi_speedo) + return SPEEDO_ACHII; + else if (cv_newspeedometer.value == 4 && kartz_speedo) + return SPEEDO_PMETER; + else if (cv_newspeedometer.value == 5 && kartz_speedo_smol) + return SPEEDO_PMETERSMOL; + else if (cv_newspeedometer.value == 6 && xtra_speedo3) + return SPEEDO_EXTRA3; + else + return SPEEDO_VANILLA; +} + //} //{ SRB2kart Net Variables @@ -8266,7 +8292,9 @@ static void K_drawKartStats(void) //Internal offset for speedometer if (cv_kartspeedometer.value) { - if ((cv_newspeedometer.value == 2 && xtra_speedo) || (cv_newspeedometer.value == 3 && achi_speedo) || (cv_newspeedometer.value == 6 && xtra_speedo3)) + const UINT8 speedostyle = K_GetSpeedometerStyle(); + + if ((speedostyle == SPEEDO_EXTRA) || (speedostyle == SPEEDO_ACHII) || (speedostyle == SPEEDO_EXTRA3)) spdoffset = -10; else spdoffset = -14; @@ -9334,7 +9362,7 @@ static void K_drawKartSpeedometer(void) INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); // man. - const boolean useoldspeedo = ((cv_newspeedometer.value == 1) || (cv_newspeedometer.value == 2 && !xtra_speedo) || (cv_newspeedometer.value == 3 && !achi_speedo) || (cv_newspeedometer.value == 4 && !kartz_speedo) || (cv_newspeedometer.value == 5 && !kartz_speedo_smol) ||(cv_newspeedometer.value == 6 && !xtra_speedo3)); + const UINT8 speedostyle = K_GetSpeedometerStyle(); switch (cv_kartspeedometer.value) { @@ -9355,7 +9383,7 @@ static void K_drawKartSpeedometer(void) break; } - if (useoldspeedo) + if (speedostyle == SPEEDO_VANILLA) { const char *metric = ""; @@ -9383,7 +9411,7 @@ static void K_drawKartSpeedometer(void) V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, metric); } - else if (cv_newspeedometer.value == 2 && xtra_speedo) // why bother if we dont? + else if (speedostyle == SPEEDO_EXTRA) // why bother if we dont? { if (K_UseColorHud() && xtra_speedo_clr) //Colourized hud { @@ -9396,7 +9424,7 @@ static void K_drawKartSpeedometer(void) V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed, 3, NULL); V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatches[cv_kartspeedometer.value]); } - else if (cv_newspeedometer.value == 3 && achi_speedo) // why bother if we dont? + else if (speedostyle == SPEEDO_ACHII) // why bother if we dont? { if (K_UseColorHud() && achi_speedo_clr) //Colourized hud { @@ -9412,7 +9440,7 @@ static void K_drawKartSpeedometer(void) V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatchesachi[cv_kartspeedometer.value]); } } - else if (cv_newspeedometer.value == 6 && xtra_speedo3) // why bother if we dont? + else if (speedostyle == SPEEDO_EXTRA3) // why bother if we dont? { if (K_UseColorHud() && xtra_speedo_clr3) //Colourized hud { @@ -9427,7 +9455,7 @@ static void K_drawKartSpeedometer(void) } // Kart Z speedo bullshit... // Draw the Speed counter. - else if ((cv_newspeedometer.value == 4 && kartz_speedo) || (cv_newspeedometer.value == 5 && kartz_speedo_smol)) + else if ((speedostyle == SPEEDO_PMETER) || (speedostyle == SPEEDO_PMETERSMOL)) { fixed_t fuspeed = 0; INT32 spdpatch = 0; @@ -9454,9 +9482,9 @@ static void K_drawKartSpeedometer(void) patch_t *patch = NULL; - if (cv_newspeedometer.value == 4 && kartz_speedo) + if (speedostyle == SPEEDO_PMETER) patch = kp_kartzspeedo[spdpatch]; - else if (cv_newspeedometer.value == 5 && kartz_speedo_smol) + else if (speedostyle == SPEEDO_PMETERSMOL) patch = kp_kartzspeedo_smol[spdpatch]; V_DrawScaledPatch(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, patch); @@ -9479,7 +9507,9 @@ static void K_drawKartBumpersOrKarma(void) if (cv_battlespeedo.value && !splitscreen) { - if ((cv_newspeedometer.value == 2 && xtra_speedo) || (cv_newspeedometer.value == 3 && achi_speedo) || (cv_newspeedometer.value == 6 && xtra_speedo3)) + const UINT8 speedostyle = K_GetSpeedometerStyle(); + + if ((speedostyle == SPEEDO_EXTRA) || (speedostyle == SPEEDO_ACHII) || (speedostyle == SPEEDO_EXTRA3)) fy += 5; else fy += 7; From 014c06a7978ea39fe70c9bf3c42fe6025bb93607 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 28 Mar 2025 17:01:43 +0100 Subject: [PATCH 110/350] dont run anything director in dedi we dont need to even init its stuff --- src/k_director.c | 2 +- src/p_setup.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index 0e65bdd22..6ec1cc65d 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -69,7 +69,7 @@ static fixed_t ScaleFromMap(fixed_t n, fixed_t scale) boolean K_DirectorIsAvailable(void) { - if (splitscreen || (demo.playback && demo.title) || modeattacking) + if (splitscreen || dedicated || (demo.playback && demo.title) || modeattacking) return false; return ((gamestate == GS_LEVEL) && ((demo.playback && !camera[0].freecam) || (players[consoleplayer].spectator && (K_PlayersPlaying() > 1)))); } diff --git a/src/p_setup.c b/src/p_setup.c index 2af8e37a9..2400bc2e0 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3134,7 +3134,9 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) { P_InitCamera(); memset(localaiming, 0, sizeof(localaiming)); - K_InitDirector(); + + if (!dedicated) + K_InitDirector(); } // clear special respawning que From 8476e11065b41cf99ec21e8d0ab9c8413a2785da Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 28 Mar 2025 17:13:03 +0100 Subject: [PATCH 111/350] can just set it to null directly --- src/k_director.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_director.c b/src/k_director.c index 6ec1cc65d..8fd5ab960 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -90,7 +90,7 @@ static void K_SetupFinishMo(void) INT16 maxMoveCount = -1; INT16 maxAngle = -1; - P_SetTarget(&finishmo, NULL); + finishmo = NULL; if (!(mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE)) // not a sprint map { From 0a9ae254c88712998e5dcc3c253ddcefbefba1b8 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 28 Mar 2025 20:59:48 +0300 Subject: [PATCH 112/350] Uncap S_UpdateSounds back Some effects that rely on S_SoundPlaying don't work perfectly if S_UpdateSounds is capped at 35 fps --- src/d_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 541b9830a..23db8e890 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -862,8 +862,7 @@ void D_SRB2Loop(void) M_DoScreenShot(); // consoleplayer -> displayplayers (hear sounds from viewpoint) - if (renderisnewtic) - S_UpdateSounds(); // move positional sounds + S_UpdateSounds(); // move positional sounds LUA_Step(); From 1762765c2fcefd667627f1b30e2955bd29517a58 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 29 Mar 2025 16:56:31 +0100 Subject: [PATCH 113/350] better and more errors for the tcp/udp stuff --- src/i_tcp.c | 104 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 83 insertions(+), 21 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index b75a7413c..1aa2e7b61 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -381,6 +381,7 @@ static const char *SOCK_AddrToStr(mysockaddr_t *sk) static char s[64]; // 255.255.255.255:65535 or IPv6:65535 #ifdef HAVE_NTOP void *addr; + int e = 0; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once if(sk->any.sa_family == AF_INET) addr = &sk->ip4.sin_addr; @@ -394,7 +395,10 @@ static const char *SOCK_AddrToStr(mysockaddr_t *sk) if(addr == NULL) sprintf(s, "No address"); else if(inet_ntop(sk->any.sa_family, addr, s, sizeof (s)) == NULL) - sprintf(s, "Unknown family type, error #%u", errno); + { + e = errno; + sprintf(s, "Unknown family type, error #%u: %s", e, strerror(e)); + } #ifdef HAVE_IPV6 else if(sk->any.sa_family == AF_INET6 && sk->ip6.sin6_port != 0) strcat(s, va(":%d", ntohs(sk->ip6.sin6_port))); @@ -778,15 +782,16 @@ static void SOCK_Send(void) { ssize_t c = ERRSOCKET; int e = 0; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once + size_t i, j; if (!nodeconnected[doomcom->remotenode]) return; if (doomcom->remotenode == BROADCASTADDR) { - for (size_t i = 0; i < mysocketses; i++) + for (i = 0; i < mysocketses; i++) { - for (size_t j = 0; j < broadcastaddresses; j++) + for (j = 0; j < broadcastaddresses; j++) { if (myfamily[i] == broadcastaddress[j].any.sa_family) { @@ -803,7 +808,7 @@ static void SOCK_Send(void) } else if (nodesocket[doomcom->remotenode] == (SOCKET_TYPE)ERRSOCKET) { - for (size_t i = 0; i < mysocketses; i++) + for (i = 0; i < mysocketses; i++) { if (myfamily[i] == clientaddress[doomcom->remotenode].any.sa_family) { @@ -833,7 +838,6 @@ static void SOCK_Send(void) SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e)); } } - #undef ALLOWEDERROR #endif //NONET @@ -864,6 +868,8 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen { SOCKET_TYPE s = socket(family, SOCK_DGRAM, IPPROTO_UDP); int opt; + int rc; + int e = 0; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once socklen_t opts; #ifdef FIONBIO unsigned long trueval = true; @@ -879,12 +885,17 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen #ifdef USE_WINSOCK2 DWORD dwBytesReturned = 0; BOOL bfalse = FALSE; - WSAIoctl(s, SIO_UDP_CONNRESET, &bfalse, sizeof(bfalse), + rc = WSAIoctl(s, SIO_UDP_CONNRESET, &bfalse, sizeof(bfalse), NULL, 0, &dwBytesReturned, NULL, NULL); #else unsigned long falseval = false; - ioctl(s, SIO_UDP_CONNRESET, &falseval); + rc = ioctl(s, SIO_UDP_CONNRESET, &falseval); #endif + if (rc == -1) + { + e = errno; + I_OutputMsg("SIO_UDP_CONNRESET failed: #%u, %s\n", e, strerror(e)); + } } #endif @@ -899,14 +910,22 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen { opt = true; opts = (socklen_t)sizeof(opt); - setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, opts); + rc = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, opts); + if (rc <= -1) + { + e = errno; + I_OutputMsg("setting SO_REUSEADDR failed: #%u, %s\n", e, strerror(e)); + } } // make it broadcastable opt = true; opts = (socklen_t)sizeof(opt); - if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, (char *)&opt, opts)) + rc = setsockopt(s, SOL_SOCKET, SO_BROADCAST, (char *)&opt, opts); + if (rc <= -1) { + e = errno; CONS_Alert(CONS_WARNING, M_GetText("Could not get broadcast rights\n")); // I do not care anymore + I_OutputMsg("setting SO_BROADCAST failed: #%u, %s\n", e, strerror(e)); } } #ifdef HAVE_IPV6 @@ -916,24 +935,34 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen { opt = true; opts = (socklen_t)sizeof(opt); - setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, opts); + rc = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, opts); + if (rc <= -1) + { + e = errno; + I_OutputMsg("setting SO_REUSEADDR failed: #%u, %s\n", e, strerror(e)); + } } #ifdef IPV6_V6ONLY // make it IPv6 ony opt = true; opts = (socklen_t)sizeof(opt); - if (setsockopt(s, SOL_SOCKET, IPV6_V6ONLY, (char *)&opt, opts)) + rc = setsockopt(s, SOL_SOCKET, IPV6_V6ONLY, (char *)&opt, opts); + if (rc <= -1) { + e = errno; CONS_Alert(CONS_WARNING, M_GetText("Could not limit IPv6 bind\n")); // I do not care anymore + I_OutputMsg("setting IPV6_V6ONLY failed: #%u, %s\n", e, strerror(e)); } #endif } #endif - if (bind(s, addr, addrlen) == ERRSOCKET) + rc = bind(s, addr, addrlen); + if (rc == ERRSOCKET) { + e = errno; close(s); - I_OutputMsg("Binding failed\n"); + I_OutputMsg("Binding failed: #%u, %s\n", e, strerror(e)); return (SOCKET_TYPE)ERRSOCKET; } @@ -947,9 +976,18 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen inet_pton(AF_INET6, IPV6_MULTICAST_ADDRESS, &maddr.ipv6mr_multiaddr); maddr.ipv6mr_interface = 0; - if (setsockopt(s, IPPROTO_IPV6, IPV6_JOIN_GROUP, (const char *)&maddr, sizeof(maddr)) != 0) + rc = setsockopt(s, SOL_SOCKET, IPV6_JOIN_GROUP, (const char *)&maddr, sizeof(maddr)); + if (rc <= -1) { + e = errno; CONS_Alert(CONS_WARNING, M_GetText("Could not register multicast address\n")); + if (e == ENODEV) + { + close(s); + I_OutputMsg("Binding failed: no IPv6 device\n"); + return (SOCKET_TYPE)ERRSOCKET; + } + I_OutputMsg("setting IPV6_JOIN_GROUP failed: #%u, %s \n", e, strerror(e)); } } } @@ -957,33 +995,57 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen #ifdef FIONBIO // make it non blocking - opt = true; - if (ioctl(s, FIONBIO, &trueval) != 0) + rc = ioctl(s, FIONBIO, &trueval); + if (rc == -1) { + e = errno; close(s); - I_OutputMsg("Seting FIOBIO on failed\n"); + I_OutputMsg("FIOBIO failed: #%u, %s\n", e, strerror(e)); return (SOCKET_TYPE)ERRSOCKET; } #endif + opt = 0; opts = (socklen_t)sizeof(opt); - getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&opt, &opts); + rc = getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&opt, &opts); + if (rc <= -1) + { + e = errno; + I_OutputMsg("getting SO_RCVBUF failed: #%u, %s\n", e, strerror(e)); + } CONS_Printf(M_GetText("Network system buffer: %dKb\n"), opt>>10); if (opt < 64<<10) // 64k { opt = 64<<10; opts = (socklen_t)sizeof(opt); - setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&opt, opts); - getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&opt, &opts); + rc = setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&opt, opts); + if (rc <= -1) + { + e = errno; + I_OutputMsg("setting SO_RCVBUF failed: #%u, %s\n", e, strerror(e)); + } + opt = 0; + rc = getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&opt, &opts); + if (rc <= -1) + { + e = errno; + I_OutputMsg("getting SO_RCVBUF failed: #%u, %s\n", e, strerror(e)); + } + if (opt < 64<<10) CONS_Alert(CONS_WARNING, M_GetText("Can't set buffer length to 64k, file transfer will be bad\n")); else CONS_Printf(M_GetText("Network system buffer set to: %dKb\n"), opt>>10); } - if (getsockname(s, (struct sockaddr *)&sin, &len) == -1) + rc = getsockname(s, (struct sockaddr *)&sin, &len); + if (rc != 0) + { + e = errno; CONS_Alert(CONS_WARNING, M_GetText("Failed to get port number\n")); + I_OutputMsg("getsockname failed: #%u, %s\n", e, strerror(e)); + } else current_port = (UINT16)ntohs(sin.sin_port); From 501df0763b678f9c2ec588359d2c2543199ab39a Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 29 Mar 2025 17:33:07 +0100 Subject: [PATCH 114/350] update ping only once per second again read the comment on why --- src/d_clisrv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 94cca18ac..44ca7534f 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6603,7 +6603,8 @@ static void UpdatePingTable(void) if (server) { - if (Playing() && !(gametime % 8)) // Value chosen based on _my vibes man_ + //if (Playing() && !(gametime % 8)) // Value chosen based on _my vibes man_ << dont do this for v8 atleast, this is placeboeing ppl to hell and back + if (netgame && !(gametime % 35)) // update once per second. PingUpdate(); fastest = 0; From 0cb18e2058f30dcf5b5ca7730e82ab78d3d6e139 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 29 Mar 2025 17:57:44 +0100 Subject: [PATCH 115/350] only do localdelay stuff at all if we intend to use it shizo sanity check --- src/d_clisrv.c | 61 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 44ca7534f..8995e4f56 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -234,6 +234,14 @@ consvar_t cv_httpsource = {"http_source", "", CV_SAVE, NULL, NULL, 0, NULL, NULL consvar_t cv_kicktime = {"kicktime", "10", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +static boolean UseLocalDelay(void) +{ + if (dedicated || (server && server_lagless && !cv_mindelay.value)) + return false; + + return (cv_mindelay.value || (server && !server_lagless)); +} + static inline void *G_DcpyTiccmd(void* dest, const ticcmd_t* src, const size_t n) { const size_t d = n / sizeof(ticcmd_t); @@ -6058,7 +6066,7 @@ static void CL_SendClientCmd(void) { UINT8 lagDelay = 0; - if (lowest_lag > 0) + if (UseLocalDelay() && (lowest_lag > 0)) { // Gentlemens' ping. lagDelay = min(lowest_lag, MAXGENTLEMENDELAY); @@ -6305,9 +6313,12 @@ static inline void CreateNewLocalCMD(UINT8 p, INT32 realtics) { INT32 i; - for (i = MAXGENTLEMENDELAY-1; i > 0; i--) + if (UseLocalDelay()) { - G_MoveTiccmd(&localcmds[p][i], &localcmds[p][i-1], 1); + for (i = MAXGENTLEMENDELAY-1; i > 0; i--) + { + G_MoveTiccmd(&localcmds[p][i], &localcmds[p][i-1], 1); + } } G_BuildTiccmd(&localcmds[p][0], realtics, p+1); @@ -6625,30 +6636,40 @@ static void UpdatePingTable(void) } } - if (server_lagless) - lowest_lag = 0; + if (UseLocalDelay()) + { + if (server_lagless) + lowest_lag = 0; + else + lowest_lag = fastest; + + // Don't gentleman below your mindelay + if (lowest_lag < (tic_t)cv_mindelay.value) + lowest_lag = (tic_t)cv_mindelay.value; + + simulated_lag = lowest_lag; + } else - lowest_lag = fastest; - - // Don't gentleman below your mindelay - if (lowest_lag < (tic_t)cv_mindelay.value) - lowest_lag = (tic_t)cv_mindelay.value; - - simulated_lag = lowest_lag; + lowest_lag = simulated_lag = 0; pingmeasurecount++; } else // We're a client, handle mindelay on the way out. { - // Previously (neededtic - gametic) - WRONG VALUE! - // Pretty sure that's measuring jitter, not RTT. - // Stable connections would be punished by adding their mindelay to network delay! - tic_t mydelay = playerpingtable[consoleplayer]; - - if (mydelay < (tic_t)cv_mindelay.value) + if (UseLocalDelay()) { - lowest_lag = ((tic_t)cv_mindelay.value - mydelay); - simulated_lag = (tic_t)cv_mindelay.value; + // Previously (neededtic - gametic) - WRONG VALUE! + // Pretty sure that's measuring jitter, not RTT. + // Stable connections would be punished by adding their mindelay to network delay! + tic_t mydelay = playerpingtable[consoleplayer]; + + if (mydelay < (tic_t)cv_mindelay.value) + { + lowest_lag = ((tic_t)cv_mindelay.value - mydelay); + simulated_lag = (tic_t)cv_mindelay.value; + } + else + lowest_lag = simulated_lag = 0; } else lowest_lag = simulated_lag = 0; From 5971e12ea911a5d79accc17416ecbd052e12c9a8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 29 Mar 2025 18:00:01 +0100 Subject: [PATCH 116/350] oop still need to update this --- 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 8995e4f56..eed0fbba1 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6615,7 +6615,7 @@ static void UpdatePingTable(void) if (server) { //if (Playing() && !(gametime % 8)) // Value chosen based on _my vibes man_ << dont do this for v8 atleast, this is placeboeing ppl to hell and back - if (netgame && !(gametime % 35)) // update once per second. + if (Playing() && !(gametime % 35)) // update once per second. PingUpdate(); fastest = 0; From 92cdc78ddafad557d37b940fbcfb1657f66c52bf Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 29 Mar 2025 18:01:45 +0100 Subject: [PATCH 117/350] also dont do this without localdelay --- 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 eed0fbba1..b3ba405bd 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6627,7 +6627,7 @@ static void UpdatePingTable(void) { realpingtable[i] += GetLag(playernode[i]); - if (!server_lagless && !players[i].spectator) + if (UseLocalDelay() && !server_lagless && !players[i].spectator) { lag = playerpingtable[i]; if (! fastest || lag < fastest) From c81e0d5816cd9572e727448c9204188bff36a3b1 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 29 Mar 2025 18:45:39 +0100 Subject: [PATCH 118/350] put back networking shit into rendering code just like vanilla yaaay --- src/d_main.c | 2 ++ src/hardware/hw_main.c | 6 ++++++ src/r_main.c | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index 23db8e890..71541c2cc 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -641,6 +641,8 @@ static boolean D_Display(void) } } + NetUpdate(); // send out any new accumulation + // It's safe to end the game now. if (G_GetExitGameFlag()) { diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index db22e8124..a69e166bd 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5502,6 +5502,9 @@ static void HWR_RenderFrame(player_t *player, boolean skybox) } } + // check for new console commands. + NetUpdate(); + // Clear view, set viewport (glViewport), set perspective... HWR_ClearView(); @@ -5535,6 +5538,9 @@ static void HWR_RenderFrame(player_t *player, boolean skybox) if (!skybox) HWR_DoPostProcessor(player); + // Check for new console commands. + NetUpdate(); + // added by Hurdler for correct splitscreen // moved here by hurdler so it works with the new near clipping plane GL_GClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT); diff --git a/src/r_main.c b/src/r_main.c index 08b478fff..e4a4994ac 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1425,6 +1425,9 @@ void R_RenderPlayerView(player_t *player) R_ClearVisibleFloorSplats(); #endif + // check for new console commands. + NetUpdate(); + // The head node is the last node output. ps_numbspcalls.value.i = ps_numpolyobjects.value.i = ps_numdrawnodes.value.i = 0; @@ -1486,6 +1489,9 @@ void R_RenderPlayerView(player_t *player) R_DrawMasked(); PS_STOP_TIMING(ps_sw_maskedtime); + // Check for new console commands. + NetUpdate(); + // save value to skyVisiblePerPlayer // this is so that P1 can't affect whether P2 can see a skybox or not, or vice versa for (i = 0; i <= splitscreen; i++) From dfcba501c4c0828aa7b8943029a6a5560991fa1a Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 31 Mar 2025 08:11:10 +0200 Subject: [PATCH 119/350] remove unused stuff d_net --- src/d_net.c | 51 ++++++--------------------------------------------- src/d_net.h | 1 - 2 files changed, 6 insertions(+), 46 deletions(-) diff --git a/src/d_net.c b/src/d_net.c index 820da034a..06b0d0e4b 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -220,7 +220,7 @@ FUNCMATH static INT32 cmpack(UINT8 a, UINT8 b) * \param lowtimer ??? * \return True if a free acknum was found */ -static boolean GetFreeAcknum(UINT8 *freeack, boolean lowtimer) +static boolean GetFreeAcknum(UINT8 *freeack) { node_t *node = &nodes[doomcom->remotenode]; INT32 i, numfreeslot = 0; @@ -249,17 +249,8 @@ static boolean GetFreeAcknum(UINT8 *freeack, boolean lowtimer) node->nextacknum++; ackpak[i].destinationnode = (UINT8)(node - nodes); ackpak[i].length = doomcom->datalength; - if (lowtimer) - { - // Lowtime means can't be sent now so try it as soon as possible - ackpak[i].senttime = 0; - ackpak[i].resentnum = 1; - } - else - { - ackpak[i].senttime = I_GetTime(); - ackpak[i].resentnum = 0; - } + ackpak[i].senttime = I_GetTime(); + ackpak[i].resentnum = 0; M_Memcpy(ackpak[i].pak.raw, netbuffer, ackpak[i].length); *freeack = ackpak[i].acknum; @@ -268,6 +259,7 @@ static boolean GetFreeAcknum(UINT8 *freeack, boolean lowtimer) return true; } + #ifdef PARANOIA CONS_Debug(DBG_NETPLAY, "No more free ackpacket\n"); #endif @@ -276,38 +268,6 @@ static boolean GetFreeAcknum(UINT8 *freeack, boolean lowtimer) return false; } -/** Counts how many acks are free - * - * \param urgent True if the type of the packet meant to - * use an ack is lower than PT_CANFAIL - * If for some reason you don't want use it - * for any packet type in particular, - * just set to false - * \return The number of free acks - * - */ -INT32 Net_GetFreeAcks(boolean urgent) -{ - INT32 i, numfreeslot = 0; - INT32 n = 0; // Number of free acks found - - for (i = 0; i < MAXACKPACKETS; i++) - if (!ackpak[i].acknum) - { - // For low priority packets, make sure to let freeslots so urgent packets can be sent - if (!urgent) - { - numfreeslot++; - if (numfreeslot <= URGENTFREESLOTNUM) - continue; - } - - n++; - } - - return n; -} - // Get a ack to send in the queue of this node static UINT8 GetAcktosend(INT32 node) { @@ -1084,9 +1044,10 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen netbuffer->ackreturn = GetAcktosend(node); else netbuffer->ackreturn = 0; + if (reliable) { - if (!GetFreeAcknum(&netbuffer->ack, false)) + if (!GetFreeAcknum(&netbuffer->ack)) return false; } else diff --git a/src/d_net.h b/src/d_net.h index 471881847..f29edb1aa 100644 --- a/src/d_net.h +++ b/src/d_net.h @@ -45,7 +45,6 @@ extern boolean nodeingame[MAXNETNODES]; // Set false as nodes leave game extern boolean serverrunning; -INT32 Net_GetFreeAcks(boolean urgent); void Net_AckTicker(void); // If reliable return true if packet sent, 0 else From 588ec05c807895ee549df1167eef5b79b530b514 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 31 Mar 2025 20:34:06 +0200 Subject: [PATCH 120/350] disable compiling with ipv6 its non functional and disabling it just removes more things that could break --- src/i_tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index 1aa2e7b61..79373abc8 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -24,7 +24,7 @@ #endif // __OS2__ #ifndef NO_IPV6 -#define HAVE_IPV6 +//#define HAVE_IPV6 #endif #ifdef _WIN32 From 633e9474b8cd2ae1aff5e781fb507c8681ea0e55 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 31 Mar 2025 22:30:25 +0200 Subject: [PATCH 121/350] texfomats without alpha should have maxlod of 5 --- src/hardware/r_opengl/r_opengl.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index ae4d6c813..54102ebf5 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1658,6 +1658,7 @@ static void GL_UpdateTexture(GLMipmap_t *pTexInfo) RGBA_t *tex = NULL; GLint texformat = 0; + GLTextureFormat_t texinfoformat = 0; // Generate a new texture name. if (!num) @@ -1670,8 +1671,9 @@ static void GL_UpdateTexture(GLMipmap_t *pTexInfo) //GL_DBG_Printf("UpdateTexture %d %x\n", (INT32)num, pImgData); texformat = textureformatGL; + texinfoformat = pTexInfo->format; - switch (pTexInfo->format) + switch (texinfoformat) { case GL_TEXFMT_P_8: case GL_TEXFMT_AP_88: @@ -1696,7 +1698,7 @@ static void GL_UpdateTexture(GLMipmap_t *pTexInfo) pImgData++; - if (pTexInfo->format != GL_TEXFMT_AP_88) + if (texinfoformat != GL_TEXFMT_AP_88) continue; if (chromakeyed) continue; @@ -1744,7 +1746,7 @@ static void GL_UpdateTexture(GLMipmap_t *pTexInfo) } break; default: - GL_MSG_Warning("UpdateTexture: bad format %d\n", pTexInfo->format); + GL_MSG_Warning("UpdateTexture: bad format %d\n", texinfoformat); break; } @@ -1767,6 +1769,8 @@ static void GL_UpdateTexture(GLMipmap_t *pTexInfo) if (MipMap && !transparent) // No mipmaps on transparent stuff { + int maxlod = (texformat == GL_LUMINANCE_ALPHA || texformat == GL_ALPHA) ? 4 : 5; + pglTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); if (update) @@ -1776,7 +1780,7 @@ static void GL_UpdateTexture(GLMipmap_t *pTexInfo) // Control the mipmap level of detail pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); - pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4); + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, maxlod); } else { From bd39a9c2f8093fad90f37f23e7cade5ea5a32ee9 Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 1 Apr 2025 01:19:16 +0300 Subject: [PATCH 122/350] Add pageup and pagedown support in replay hut --- src/m_menu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 85f2e7365..0a479a30e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7029,14 +7029,19 @@ static void M_HandleReplayHutList(INT32 choice) if (M_HandleReplayHutQuery(choice)) return; + size_t scrollamt = 1; + switch (choice) { + case KEY_PGUP: + scrollamt = 8; + /* FALLTHRU */ case KEY_UPARROW: if (!replaynamesloaded) return; if (dir_on[menudepthleft]) - dir_on[menudepthleft]--; + dir_on[menudepthleft] -= min(dir_on[menudepthleft], scrollamt); else return; //M_PrevOpt(); @@ -7045,12 +7050,15 @@ static void M_HandleReplayHutList(INT32 choice) replayScrollTitle = 0; replayScrollDelay = TICRATE; replayScrollDir = 1; break; + case KEY_PGDN: + scrollamt = 8; + /* FALLTHRU */ case KEY_DOWNARROW: if (!replaynamesloaded) return; if (dir_on[menudepthleft] < replayqueryfound-1) - dir_on[menudepthleft]++; + dir_on[menudepthleft] = min(replayqueryfound-1, dir_on[menudepthleft] + scrollamt); else return; //itemOn = 0; // Not M_NextOpt because that would take us to the extra dummy item From 8033348aa128a730f6d16e52947b212bf45ec50d Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 31 Mar 2025 22:54:34 +0200 Subject: [PATCH 123/350] change scr_depth to gr_texturedepth and allow it to change stuff midgame its not used for software renderer anymore and before you had to restart the game to be able to see a change in gl 8bits and 24bits options have been removed since they had no effect and it also allowed me to unglobal things --- src/d_netcmd.c | 1 - src/hardware/hw_defs.h | 2 ++ src/hardware/hw_main.c | 13 +++++++++++++ src/hardware/hw_main.h | 2 ++ src/hardware/r_opengl/r_opengl.c | 26 +++++++++++++++----------- src/hardware/r_opengl/r_opengl.h | 1 - src/m_menu.c | 2 +- src/screen.c | 7 +------ src/screen.h | 2 +- src/sdl/ogl_sdl.c | 2 -- 10 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 6495ad7c3..dc658880b 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1069,7 +1069,6 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_renderview); CV_RegisterVar(&cv_vhseffect); CV_RegisterVar(&cv_shittyscreen); - CV_RegisterVar(&cv_scr_depth); CV_RegisterVar(&cv_scr_width); CV_RegisterVar(&cv_scr_height); diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index a99db6acc..b554776a7 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -319,6 +319,8 @@ enum hwdsetspecialstate HWD_SET_PORTAL_MODE,// new portal thing HWD_SET_STENCIL_LEVEL, + HWD_SET_TEXTURE_FORMAT, + HWD_NUMSTATE }; typedef enum hwdsetspecialstate hwdspecialstate_t; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index a69e166bd..722b262fd 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -156,6 +156,7 @@ static void CV_glshaders_OnChange(void); static void CV_gllightdithering_OnChange(void); static void CV_filtermode_OnChange(void); static void CV_anisotropic_OnChange(void); +static void CV_gltextureformat_OnChange(void); static void CV_glpaletterendering_OnChange(void); static void CV_glpalettedepth_OnChange(void); @@ -178,6 +179,8 @@ static CV_PossibleValue_t glrenderdistance_cons_t[] = { {0, "Max"}, {1, "1024"}, {2, "2048"}, {3, "4096"}, {4, "6144"}, {5, "8192"}, {6, "12288"}, {7, "16384"}, {0, NULL}}; +static CV_PossibleValue_t gltexdepth_cons_t[] = {{16, "16 bits"}, {32, "32 bits"}, {0, NULL}}; + static CV_PossibleValue_t glpalettedepth_cons_t[] = {{16, "16 bits"}, {24, "24 bits"}, {0, NULL}}; // @@ -227,6 +230,8 @@ consvar_t cv_glpaletterendering = {"gr_paletteshader", "Off", CV_CALL|CV_SAVE, C consvar_t cv_glpalettedepth = {"gr_palettedepth", "16 bits", CV_SAVE|CV_CALL, glpalettedepth_cons_t, CV_glpalettedepth_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glflashpal = {"gr_flashpal", "On", CV_CALL|CV_SAVE, CV_OnOff, CV_glpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_gltexturedepth = {"gr_texturedepth", "32 bits", CV_CALL|CV_SAVE, gltexdepth_cons_t, CV_gltextureformat_OnChange, 0, NULL, NULL, 0, 0, NULL}; + #define ONLY_IF_GL_LOADED if (vid.glstate != VID_GL_LIBRARY_LOADED) return; static void CV_screentextures_OnChange(void) @@ -280,6 +285,12 @@ static void CV_gllightdithering_OnChange(void) } } +static void CV_gltextureformat_OnChange(void) +{ + ONLY_IF_GL_LOADED + GL_SetSpecialState(HWD_SET_TEXTURE_FORMAT, cv_gltexturedepth.value); +} + static void CV_filtermode_OnChange(void) { ONLY_IF_GL_LOADED @@ -5680,6 +5691,8 @@ static void HWR_TogglePaletteRendering(void) //added by Hurdler: console varibale that are saved void HWR_AddCommands(void) { + CV_RegisterVar(&cv_gltexturedepth); + CV_RegisterVar(&cv_glscreentextures); #ifdef USE_FBO_OGL diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 8ccb1b2a1..ba093c6ca 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -178,6 +178,8 @@ RGBA_t *HWR_GetTexturePalette(void); // Console variables extern CV_PossibleValue_t glanisotropicmode_cons_t[]; +extern consvar_t cv_gltexturedepth; + extern consvar_t cv_glscreentextures; #ifdef USE_FBO_OGL extern consvar_t cv_glframebuffer; diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 54102ebf5..b5bb031e0 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -99,14 +99,14 @@ static GLuint screenPaletteTex = 0; // 1D texture containing the screen palette static GLuint paletteLookupTex = 0; // 3D texture containing RGB -> palette index lookup table RGBA_t myPaletteData[256]; // the palette for converting textures to RGBA -GLint screen_width = 0; // used by Draw2DLine() -GLint screen_height = 0; -GLbyte screen_depth = 0; -GLint textureformatGL = 0; -GLint maximumAnisotropy = 0; -static GLboolean MipMap = GL_FALSE; -static GLint min_filter = GL_LINEAR; -static GLint mag_filter = GL_LINEAR; +static GLint gltexformat = GL_RGB5_A1; +GLint screen_width = 0; // used by Draw2DLine() +GLint screen_height = 0; +GLbyte screen_depth = 0; +GLint maximumAnisotropy = 0; +static GLboolean MipMap = GL_FALSE; +static GLint min_filter = GL_LINEAR; +static GLint mag_filter = GL_LINEAR; static GLint anisotropic_filter = 0; boolean supportMipMap = false; @@ -1658,7 +1658,6 @@ static void GL_UpdateTexture(GLMipmap_t *pTexInfo) RGBA_t *tex = NULL; GLint texformat = 0; - GLTextureFormat_t texinfoformat = 0; // Generate a new texture name. if (!num) @@ -1670,8 +1669,8 @@ static void GL_UpdateTexture(GLMipmap_t *pTexInfo) //GL_DBG_Printf("UpdateTexture %d %x\n", (INT32)num, pImgData); - texformat = textureformatGL; - texinfoformat = pTexInfo->format; + texformat = gltexformat; + const GLTextureFormat_t texinfoformat = pTexInfo->format; switch (texinfoformat) { @@ -2309,6 +2308,11 @@ void GL_SetSpecialState(hwdspecialstate_t IdState, INT32 Value) GL_Flush(); //??? if we want to change filter mode by texture, remove this break; + + case HWD_SET_TEXTURE_FORMAT: + gltexformat = (Value == 32) ? GL_RGBA : GL_RGB5_A1; + GL_Flush(); + break; case HWD_SET_MSAA: if (Value) diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index dfbae7f6d..2f2b9ba98 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -136,7 +136,6 @@ extern boolean supportMipMap; /** \brief OpenGL flags for video driver */ extern INT32 oglflags; -extern GLint textureformatGL; extern GLfloat projMatrix[16]; diff --git a/src/m_menu.c b/src/m_menu.c index 0a479a30e..cec9ef69d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1616,7 +1616,7 @@ static menuitem_t OP_OpenGLOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Palette Rendering Flashpals",&cv_glflashpal, 35}, {IT_STRING | IT_CVAR, NULL, "Min Shader Brightness", &cv_glsecbright, 40}, - {IT_STRING | IT_CVAR, NULL, "Texture Quality", &cv_scr_depth, 50}, + {IT_STRING | IT_CVAR, NULL, "Texture Quality", &cv_gltexturedepth, 50}, {IT_STRING | IT_CVAR, NULL, "Texture Filter", &cv_glfiltermode, 55}, {IT_STRING | IT_CVAR, NULL, "Anisotropic", &cv_glanisotropicmode, 60}, {IT_STRING | IT_CVAR, NULL, "Visual Portals", &cv_glportals, 65}, diff --git a/src/screen.c b/src/screen.c index f6a94c052..1d83a409d 100644 --- a/src/screen.c +++ b/src/screen.c @@ -56,14 +56,11 @@ void (*twosmultipatchtransfunc)(void); // for cols with transparent pixels AND t viddef_t vid; INT32 setmodeneeded; //video mode change needed if > 0 (the mode number to set + 1) -static CV_PossibleValue_t scr_depth_cons_t[] = {{8, "8 bits"}, {16, "16 bits"}, {24, "24 bits"}, {32, "32 bits"}, {0, NULL}}; - static CV_PossibleValue_t shittyscreen_cons_t[] = {{0, "Okay"}, {1, "Shitty"}, {2, "Extra Shitty"}, {0, NULL}}; //added : 03-02-98: default screen mode, as loaded/saved in config consvar_t cv_scr_width = {"scr_width", "1280", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_scr_height = {"scr_height", "800", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_scr_depth = {"scr_depth", "16 bits", CV_SAVE, scr_depth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_renderview = {"renderview", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_vhseffect = {"vhspause", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_shittyscreen = {"televisionsignal", "Okay", CV_NOSHOWHELP, shittyscreen_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -322,8 +319,7 @@ void SCR_CheckDefaultMode(void) } else { - CONS_Printf(M_GetText("Default resolution: %d x %d (%d bits)\n"), cv_scr_width.value, - cv_scr_height.value, cv_scr_depth.value); + CONS_Printf(M_GetText("Default resolution: %d x %d\n"), cv_scr_width.value, cv_scr_height.value); // see note above setmodeneeded = VID_GetModeForSize(cv_scr_width.value, cv_scr_height.value) + 1; } @@ -335,7 +331,6 @@ void SCR_SetDefaultMode(void) // remember the default screen size CV_SetValue(&cv_scr_width, vid.width); CV_SetValue(&cv_scr_height, vid.height); - //CV_SetValue(&cv_scr_depth, vid.bpp*8); } // Change fullscreen on/off according to cv_fullscreen diff --git a/src/screen.h b/src/screen.h index b8eeb560f..4a97e159b 100644 --- a/src/screen.h +++ b/src/screen.h @@ -145,7 +145,7 @@ extern double averageFPS; extern INT32 scr_bpp; extern UINT8 *scr_borderpatch; // patch used to fill the view borders -extern consvar_t cv_scr_width, cv_scr_height, cv_scr_depth, cv_renderview, cv_fullscreen, cv_vhseffect, cv_shittyscreen; +extern consvar_t cv_scr_width, cv_scr_height, cv_renderview, cv_fullscreen, cv_vhseffect, cv_shittyscreen; extern consvar_t cv_highreshudscale; // wait for page flipping to end or not extern consvar_t cv_vidwait; diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 1cfaf4c45..73f6635e3 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -128,7 +128,6 @@ static boolean first_init = false; boolean OglSdlSurface(INT32 w, INT32 h) { - INT32 cbpp = cv_scr_depth.value < 16 ? 16 : cv_scr_depth.value; const char *gllogdir = NULL; oglflags = 0; @@ -248,7 +247,6 @@ boolean OglSdlSurface(INT32 w, INT32 h) if (!first_init) HWR_Startup(); - textureformatGL = cbpp > 16 ? GL_RGBA : GL_RGB5_A1; first_init = true; From 42b2e0622fa26eea49c12b1e58dad8d1cbee97ee Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 2 Apr 2025 18:42:35 +0200 Subject: [PATCH 124/350] slight cleanup drawOnMinimap --- src/k_kart.c | 39 +++++++++++------ src/k_kart.h | 1 + src/lua_hudlib.c | 112 ++++++++++++++++++----------------------------- 3 files changed, 68 insertions(+), 84 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index b80293ff4..1390f361d 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8256,6 +8256,25 @@ void K_getMinimapDrawinfo(drawinfo_t *out) out->flags = fflags; } +INT32 K_getMinimapTrans(void) +{ + INT32 minimaptrans = cv_kartminimap.value; + + if (!minimaptrans) + return 0; + + if (forceshowhud) + return (10-minimaptrans)<width)/2); y = info.y - (SHORT(minimapinfo.minimap_pic->height)/2); splitflags = info.flags; - if (forceshowhud) - minimaptrans = cv_kartminimap.value; - else if (timeinmap > 105) - { - minimaptrans = cv_kartminimap.value; - if (timeinmap <= 113) - minimaptrans = ((((INT32)timeinmap) - 105)*minimaptrans)/(113-105); - if (!minimaptrans) - return; - } - else - return; - - minimaptrans = ((10-minimaptrans)< 1) // 3P : bottom right - { - MM_X = (3*BASEVIDWIDTH/4) + cv_mini_xoffset.value; - MM_Y = (3*BASEVIDHEIGHT/4) + cv_mini_yoffset.value; - - if (splitscreen > 2) // 4P: centered - { - MM_X = (BASEVIDWIDTH/2) + cv_mini_xoffset.value; - MM_Y = (BASEVIDHEIGHT/2) + cv_mini_yoffset.value; - } - } - } - - // splitscreen flags - splitflags = (splitscreen == 3 ? 0 : V_SNAPTORIGHT); // flags should only be 0 when it's centered (4p split) - - // translucency: - if (timeinmap > 105) - { - minimaptrans = cv_kartminimap.value; - if (timeinmap <= 113) - minimaptrans = ((((INT32)timeinmap) - 105)*minimaptrans)/(113-105); - if (!minimaptrans) - return 0; - } - else - return 0; - - minimaptrans = ((10-minimaptrans)<width)/2); - mm_y = MM_Y - (SHORT(AutomapPic->height)/2); + mm_x = info.x - (SHORT(AutomapPic->width)/2); + mm_y = info.y - (SHORT(AutomapPic->height)/2); // let offsets transfer to the heads, too! if (encoremode) @@ -696,13 +669,12 @@ static int libd_drawOnMinimap(lua_State *L) mm_y -= SHORT(AutomapPic->topoffset); - // scale patch coords - patchw = (SHORT(patch->width) * scale / 2); - patchh = (SHORT(patch->height) * scale / 2); - - if (centered) + // patch is supposedly already centered, don't butt in. + if (!centered) { - patchw = patchh = 0; // patch is supposedly already centered, don't butt in. + // scale patch coords + patchw = (SHORT(patch->width) * scale / 2); + patchh = (SHORT(patch->height) * scale / 2); } amnumxpos = (FixedMul(x, minimapinfo.zoom) - minimapinfo.offs_x); @@ -716,11 +688,6 @@ static int libd_drawOnMinimap(lua_State *L) amxpos = amnumxpos + ((mm_x + SHORT(AutomapPic->width) / 2)<height) / 2)< Date: Wed, 2 Apr 2025 09:56:07 +0200 Subject: [PATCH 125/350] smol cleanup skyspecial handling for ogl --- src/hardware/hw_cache.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index e995df244..ed73de2ec 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -320,36 +320,27 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe INT32 blockwidth, blockheight, blocksize; INT32 i, idx; - boolean skyspecial = false; //poor hack for Legacy large skies.. + boolean skyspecial = false; // poor hack for Legacy large skies.. RGBA_t *palette; palette = HWR_GetTexturePalette(); texture = textures[texnum]; - // hack the Legacy skies.. - if (texture->name[0] == 'S' && - texture->name[1] == 'K' && - texture->name[2] == 'Y' && - (texture->name[4] == 0 || - texture->name[5] == 0) - ) - { - skyspecial = true; - gltex->mipmap.flags = TF_WRAPXY; // don't use the chromakey for sky - } - else - gltex->mipmap.flags = TF_CHROMAKEYED | TF_WRAPXY; - + gltex->mipmap.flags = TF_CHROMAKEYED | TF_WRAPXY; gltex->mipmap.width = (UINT16)(texture->width); gltex->mipmap.height = (UINT16)(texture->height); - - if (skyspecial) - gltex->mipmap.format = GL_TEXFMT_RGBA; // that skyspecial code below assumes this format ... - else - gltex->mipmap.format = textureformat; - gltex->mipmap.colormap = colormaps; + gltex->mipmap.format = textureformat; + + // hack the Legacy skies.. + if (strncmp(texture->name, "SKY", 3) == 0 && + (texture->name[4] == 0 || texture->name[5] == 0)) + { + skyspecial = true; + gltex->mipmap.flags &= ~TF_CHROMAKEYED; // don't use the chromakey for sky + gltex->mipmap.format = GL_TEXFMT_RGBA; // that skyspecial code below assumes this format ... + } #ifdef GLENCORE if (encoremap && !noencore) @@ -361,7 +352,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe blocksize = (blockwidth * blockheight); block = MakeBlock(&gltex->mipmap); - if (skyspecial) //Hurdler: not efficient, but better than holes in the sky (and it's done only at level loading) + if (skyspecial) // Hurdler: not efficient, but better than holes in the sky (and it's done only at level loading) { INT32 j; RGBA_t col; @@ -939,6 +930,7 @@ static void HWR_LoadMappedPatch(GLMipmap_t *glMipmap, GLPatch_t *glPatch) patch_t *patch = glPatch->rawpatch; if (!patch) patch = W_CacheLumpNumPwad(glPatch->wadnum, glPatch->lumpnum, PU_STATIC); + HWR_MakePatch(patch, glPatch, glMipmap, true); // You can't free rawpatch for some reason? @@ -970,6 +962,7 @@ void HWR_GetPatch(GLPatch_t *glPatch) patch_t *ptr = glPatch->rawpatch; if (!ptr) ptr = W_CacheLumpNumPwad(glPatch->wadnum, glPatch->lumpnum, PU_STATIC); + HWR_MakePatch(ptr, glPatch, glPatch->mipmap, true); // this is inefficient.. but the hardware patch in heap is purgeable so it should @@ -1331,6 +1324,7 @@ UINT32 HWR_GetLightTableID(extracolormap_t *colormap) colormap_pointer = colormaps; // don't actually use the data from the "default colormap" else colormap_pointer = colormap->colormap; + colormap->gl_lighttable_id = HWR_CreateLightTable(colormap_pointer); } From 75d1b49aed1a8a00ffed28455f715a617065dec2 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 2 Apr 2025 09:58:05 +0200 Subject: [PATCH 126/350] check if texture exists first --- src/hardware/hw_main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 722b262fd..8085bc4fb 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1480,10 +1480,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } gl_toptexture = R_GetTextureNum(gl_sidedef->toptexture); - gl_bottomtexture = R_GetTextureNum(gl_sidedef->bottomtexture); // check TOP TEXTURE - if ((worldhighslope < worldtopslope || worldhigh < worldtop) && gl_toptexture) + if (gl_toptexture && (worldhighslope < worldtopslope || worldhigh < worldtop)) { // PEGGING if (gl_linedef->flags & ML_DONTPEGTOP) @@ -1542,8 +1541,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } + gl_bottomtexture = R_GetTextureNum(gl_sidedef->bottomtexture); + // check BOTTOM TEXTURE - if ((worldlowslope > worldbottomslope || worldlow > worldbottom) && gl_bottomtexture) + if (gl_bottomtexture && (worldlowslope > worldbottomslope || worldlow > worldbottom)) { // PEGGING if (!(gl_linedef->flags & ML_DONTPEGBOTTOM)) From 2980a87d0924f806d7596e5cdb8b1d11b5a0aa80 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 2 Apr 2025 10:01:38 +0200 Subject: [PATCH 127/350] use max --- src/hardware/hw_cache.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index ed73de2ec..824fd08e7 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -98,10 +98,7 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm position = 0; } - position = ((position * scale_y) + (FRACUNIT/2)) >> FRACBITS; - - if (position < 0) - position = 0; + position = max(((position * scale_y) + (FRACUNIT/2)) >> FRACBITS, 0); if (position + count >= pblockheight) count = pblockheight - position; From 87447e934421477748865f4299111974d5a1844a Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 2 Apr 2025 09:57:17 +0200 Subject: [PATCH 128/350] fix the wonky rendering issues on that one si-ht map saturn regression introduced by the fof slope cutoff fix hopefully this has no weiird side effects, but so far everything seemed fine --- src/hardware/hw_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 8085bc4fb..03ca72f74 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1893,7 +1893,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight) - if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) + if ((high1 < lowcut || highslope1 < lowcutslope) || (low1 > highcut || lowslope1 > highcutslope)) continue; texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); @@ -2041,7 +2041,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight) - if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) + if ((high1 < lowcut || highslope1 < lowcutslope) || (low1 > highcut || lowslope1 > highcutslope)) continue; texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); From 2970ab6ae32bc673d12a479309ae5f0d0b32b2ac Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 2 Apr 2025 19:48:43 +0200 Subject: [PATCH 129/350] drift only option for coloured speelines man --- src/k_kart.c | 68 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 1390f361d..497d96e16 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -78,7 +78,7 @@ IMPL_HUD_OFFSET(stat); // Stats #undef IMPL_HUD_OFFSET_Y // extra colourisation stuff -static CV_PossibleValue_t colorspeedlines_cons_t[] = {{0, "Off"}, {1, "Normal"}, {2, "+Driftcharge"}, {0, NULL}}; +static CV_PossibleValue_t colorspeedlines_cons_t[] = {{0, "Off"}, {1, "Normal"}, {2, "+Driftcharge"}, {3, "Drift only"}, {0, NULL}}; consvar_t cv_coloredspeedlines = {"colorizedspeedlines", "Off", CV_SAVE, colorspeedlines_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_coloredsneakertrail = {"sneakertrailcolor", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -5517,6 +5517,41 @@ static boolean K_SpeedLinesShouldBlend(player_t *player) return false; } +static UINT8 K_GetSpeedLineColor(player_t *player, boolean colorSpeed) +{ + UINT8 speedcolor = SKINCOLOR_NONE; + + if (colorSpeed) + { + if (cv_coloredspeedlines.value >= 2 && player->kartstuff[k_driftboost]) + { + if (player->kartstuff[k_driftboost] <= 20) + speedcolor = SKINCOLOR_SAPPHIRE; + else if (player->kartstuff[k_driftboost] <= 50) + speedcolor = SKINCOLOR_RASPBERRY; + else if (player->kartstuff[k_driftboost] <= 125) + speedcolor = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); + } + + speedcolor = (leveltime & 1) ? ((cv_coloredspeedlines.value == 3) ? SKINCOLOR_NONE : player->mo->color) : speedcolor; + } + + if (cv_coloredspeedlines.value != 3) + { + if (player->kartstuff[k_eggmanexplode]) + { + // Make it red when you have the eggman speed boost + speedcolor = SKINCOLOR_RED; + } + else if (player->kartstuff[k_invincibilitytimer]) + { + speedcolor = player->mo->color; + } + } + + return speedcolor; +} + typedef INT32 (*randomFunc)(INT32 min, INT32 max); FUNCINLINE static ATTRINLINE void K_SpawnNormalSpeedLines(player_t *player, boolean synched) @@ -5536,36 +5571,13 @@ FUNCINLINE static ATTRINLINE void K_SpawnNormalSpeedLines(player_t *player, bool K_MatchGenericExtraFlags(fast, player->mo); - if (cv_coloredspeedlines.value) + if (cv_coloredspeedlines.value || cv_playerblendeffects.value) { const boolean colorSpeed = (player->speed >= (3*K_GetKartSpeed(player, false))/4); - if (player->kartstuff[k_eggmanexplode]) + if (cv_coloredspeedlines.value) { - // Make it red when you have the eggman speed boost - fast->color = SKINCOLOR_RED; - fast->colorized = true; - } - else if (player->kartstuff[k_invincibilitytimer]) - { - fast->color = player->mo->color; - fast->colorized = true; - } - else if (colorSpeed) - { - UINT8 driftcolor = SKINCOLOR_NONE; - - if (cv_coloredspeedlines.value == 2 && player->kartstuff[k_driftboost]) - { - if (player->kartstuff[k_driftboost] <= 20) - driftcolor = SKINCOLOR_SAPPHIRE; - else if (player->kartstuff[k_driftboost] <= 50) - driftcolor = SKINCOLOR_RASPBERRY; - else if (player->kartstuff[k_driftboost] <= 125) - driftcolor = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); - } - - fast->color = (leveltime & 1) ? player->mo->color : driftcolor; + fast->color = K_GetSpeedLineColor(player, colorSpeed); fast->colorized = true; } @@ -5597,7 +5609,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) { K_SpawnNormalSpeedLines(player, true); } - else if (cv_coloredspeedlines.value && player->kartstuff[k_eggmanexplode]) // gotta love the speedlines calling synched rng :chaosleep: + else if ((cv_coloredspeedlines.value == 1 || cv_coloredspeedlines.value == 2) && player->kartstuff[k_eggmanexplode]) // gotta love the speedlines calling synched rng :chaosleep: { K_SpawnNormalSpeedLines(player, false); } From 6a973418352921a5b353483bca174b4c6d37129a Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 3 Apr 2025 00:13:45 +0200 Subject: [PATCH 130/350] update saturn credtis baaaaaaaaaaarely fits now on greenres had to kill the tooltip too :/ we should prob think of smth else than abusing a menu for this --- src/f_finale.c | 8 +++++++- src/m_menu.c | 35 ++++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index 18eab51eb..209c3e55a 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -534,8 +534,14 @@ static const char *credits[] = { "\"Sunflower\" aka \"AnimeSonic\"", "\"Yuz\" aka \"Yuzler\"", "\"Democrab\"", - "\"Expand\" aka \"Maver\"", + "\"EXpand\"", "\"Nexit\"", + "\"Spee\"", + "\"Jin\"", + "\"chromaticpipe\"", + "\"Achii\"", + "\"Anonimus\"", + "\"scizor300\"", "", "\1Special Thanks", "SEGA", diff --git a/src/m_menu.c b/src/m_menu.c index cec9ef69d..ea5043bcf 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2548,7 +2548,7 @@ static menuitem_t OP_SaturnCreditsMenu[] = { {IT_HEADER, NULL, "Saturn Credits", NULL, 0}, - {IT_HEADER, NULL, "Thanks to all contributers <3", NULL, 15}, + {IT_HEADER, NULL, "Thanks to all contributers <3", NULL, 10}, {IT_STRING2+IT_SPACE, NULL, "Alug", NULL, 20}, {IT_STRING2+IT_SPACE, NULL, "Indev", NULL, 30}, @@ -2558,29 +2558,34 @@ static menuitem_t OP_SaturnCreditsMenu[] = {IT_STRING2+IT_SPACE, NULL, "xyzzy", NULL, 70}, {IT_STRING2+IT_SPACE, NULL, "Chearii", NULL, 80}, - {IT_STRING+IT_SPACE, NULL, "", NULL, 83}, // dummy text - {IT_STRING2+IT_SPACE, NULL, "Sunflower aka AnimeSonic", NULL, 90}, {IT_STRING2+IT_SPACE, NULL, "Yuz aka Yuzler", NULL, 100}, {IT_STRING2+IT_SPACE, NULL, "Democrab", NULL, 110}, - {IT_STRING2+IT_SPACE, NULL, "EXpand aka Maver", NULL, 120}, + {IT_STRING2+IT_SPACE, NULL, "EXpand", NULL, 120}, {IT_STRING2+IT_SPACE, NULL, "Nexit", NULL, 130}, + {IT_STRING2+IT_SPACE, NULL, "Spee", NULL, 140}, + {IT_STRING2+IT_SPACE, NULL, "Jin", NULL, 150}, + {IT_STRING2+IT_SPACE, NULL, "chromaticpipe", NULL, 160}, + {IT_STRING2+IT_SPACE, NULL, "Achii", NULL, 170}, + {IT_STRING2+IT_SPACE, NULL, "Anonimus", NULL, 180}, + {IT_STRING2+IT_SPACE, NULL, "scizor300", NULL, 190}, - {IT_HEADER, NULL, "Special Thanks <3", NULL, 140}, + {IT_HEADER, NULL, "Special Thanks <3", NULL, 163}, - {IT_STRING2+IT_SPACE, NULL, "All of Sunflower's Garden", NULL, 160}, - {IT_STRING2+IT_SPACE, NULL, "The Moe Mansion and Birdhouse Team", NULL, 170}, - {IT_STRING2+IT_SPACE, NULL, "Galactice for Galaxy", NULL, 180}, + {IT_STRING2+IT_SPACE, NULL, "All of Sunflower's Garden", NULL, 173}, + {IT_STRING2+IT_SPACE, NULL, "The Moe Mansion and Birdhouse Team", NULL, 183}, + {IT_STRING2+IT_SPACE, NULL, "Galactice for Galaxy", NULL, 193}, - {IT_STRING+IT_SPACE, NULL, "", NULL, 190}, // dummy text II - {IT_STRING, NULL, "", NULL, 250}, // dummy text III + {IT_STRING+IT_SPACE, NULL, "", NULL, 203}, // dummy text I + {IT_STRING, NULL, "", NULL, 263}, // dummy text II }; -static const char* OP_CreditTooltips[] = +// sry we dont have space for this anymore :/ +/*static const char* OP_CreditTooltips[] = { - NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, + NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, "Thanks everyone! <3" -}; +};*/ static menuitem_t OP_BirdMenu[] = @@ -3278,7 +3283,7 @@ menu_t OP_PlayerDistortDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_PlayerDistortMenu, menu_t OP_HudOffsetDef = DEFAULTSCROLLSTYLE(NULL, OP_HudOffsetMenu, &OP_SaturnHudDef, 30, 30); menu_t OP_SaturnHudDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnHudMenu, &OP_SaturnDef, 30, 30); -menu_t OP_SaturnCreditsDef = DEFAULTMENUSTYLE(NULL, OP_SaturnCreditsMenu, &OP_SaturnDef, 30, 10); +menu_t OP_SaturnCreditsDef = DEFAULTMENUSTYLE(NULL, OP_SaturnCreditsMenu, &OP_SaturnDef, 30, 3); menu_t OP_BirdDef = DEFAULTMENUSTYLE(NULL, OP_BirdMenu, &OP_MainDef, 30, 30); @@ -5416,7 +5421,7 @@ static void M_DrawGenericMenu(void) DoToolTips(OP_ChatOptionsDef, OP_ChatOptionsTooltips); DoToolTips(OP_GameOptionsDef, OP_GameTooltips); DoToolTips(OP_ServerOptionsDef, OP_ServerOptionsTooltips); - DoToolTips(OP_SaturnCreditsDef, OP_CreditTooltips); // C: + //DoToolTips(OP_SaturnCreditsDef, OP_CreditTooltips); // C: DoToolTips(OP_BirdDef, OP_BirdTooltips); DoToolTips(OP_TiltDef, OP_TiltTooltips); DoToolTips(OP_AdvancedBirdDef, OP_AdvancedBirdTooltips); From ba7d3324e6df976a11bd3f82efbb35168da0e5e1 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 3 Apr 2025 20:41:36 +0200 Subject: [PATCH 131/350] kill SATURNSYNCH and can_receive_gamestate, change the detection of synch method before we unconditionally sent PT_WILLRESENDGAMESTATE to every connected node that didnt desynch before, in a big lobby this could mean having to send out alot of reliable packets to potentially clients that couldnt use it anyways, like this we just check if a client is saturn, which gets set the moment a saturn client v7.1 and onwards joins (it sends a special packet to the server during connect) this makes sure we only even attempt the new resynch system with clients WE KNOW can use it anyways this is backwards compatible until v7.1, v7 when this was introduced did not send the special packet on join and relied on the willreceivegamestate packet, so they wont benefit from the better resynching anymore --- src/Makefile | 5 ---- src/d_clisrv.c | 70 +++++++++++++++++--------------------------------- src/d_clisrv.h | 7 +++-- src/d_net.c | 5 ++-- src/d_netcmd.c | 2 +- src/doomdef.h | 9 ++----- src/hu_stuff.c | 4 +-- src/m_menu.c | 4 +-- 8 files changed, 35 insertions(+), 71 deletions(-) diff --git a/src/Makefile b/src/Makefile index 4e9f3d7cf..bd762fb8d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -195,8 +195,6 @@ endif endif ifndef NONET -ifndef NOSATURNSYNCH -DOSATURNSYNCH=1 ifndef NOSATURNJOIN DOSATURNJOIN=1 endif @@ -391,8 +389,6 @@ endif endif ifndef NONET -ifndef NOSATURNSYNCH -OPTS+=-DDOSATURNSYNCH ifndef NOSATURNJOIN OPTS+=-DDOSATURNJOIN endif @@ -400,7 +396,6 @@ ifndef NOSATURNPAK OPTS+=-DDOSATURNPAK endif endif -endif ifdef HAVE_MINIUPNPC ifdef NONET diff --git a/src/d_clisrv.c b/src/d_clisrv.c index b3ba405bd..b66e35ab6 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -94,7 +94,7 @@ UINT8 playernode[MAXPLAYERS]; // The actual timeout will be longer depending on the savegame length tic_t jointimeout = (3*TICRATE); static boolean sendingsavegame[MAXNETNODES]; // Are we sending the savegame? -#ifdef SATURNSYNCH +#ifdef SATURNPAK static boolean resendingsavegame[MAXNETNODES]; // Are we resending the savegame? static tic_t savegameresendcooldown[MAXNETNODES]; // How long before we can resend again? #endif @@ -153,9 +153,8 @@ static UINT8 resynch_inprogress[MAXNETNODES]; static UINT8 resynch_local_inprogress = false; // WE are desynched and getting packets to fix it. UINT8 hu_resynching = 0; -#ifdef SATURNSYNCH +#ifdef SATURNPAK UINT8 hu_redownloadinggamestate = 0; -static boolean can_receive_gamestate[MAXNETNODES]; static UINT8 gamestate_resend_counter[MAXNETNODES]; #endif @@ -168,11 +167,8 @@ static boolean cl_packetmissed; // here it is for the secondary local player (splitscreen) static UINT8 mynode; // my address pointofview server -#ifdef SATURNSYNCH -static boolean cl_redownloadinggamestate = false; -#endif - #ifdef SATURNPAK +static boolean cl_redownloadinggamestate = false; boolean is_client_saturn[MAXNETNODES]; #endif @@ -1836,7 +1832,7 @@ static boolean SV_SendServerConfig(INT32 node) #ifdef JOININGAME #define SAVEGAMESIZE (768*1024) -#ifdef SATURNSYNCH +#ifdef SATURNPAK static boolean SV_ResendingSavegameToAnyone(void) { INT32 i; @@ -2023,7 +2019,7 @@ static void CL_LoadReceivedSavegame(boolean reloading) consistancy[gametic%TICQUEUE] = Consistancy(); CON_ToggleOff(); -#ifdef SATURNSYNCH +#ifdef SATURNPAK // Tell the server we have received and reloaded the gamestate // so they know they can resume the game if (reloading) @@ -2034,7 +2030,7 @@ static void CL_LoadReceivedSavegame(boolean reloading) #endif } -#ifdef SATURNSYNCH +#ifdef SATURNPAK static void CL_ReloadReceivedSavegame(void) { INT32 i; @@ -4097,7 +4093,7 @@ static void Command_list_http_logins (void) } #endif/*HAVE_CURL*/ -#ifdef SATURNSYNCH +#ifdef SATURNPAK static void Command_ResendGamestate(void) { SINT8 playernum; @@ -4154,7 +4150,7 @@ consvar_t cv_discordinvites = {"discordinvites", "Everyone", CV_SAVE|CV_CALL, di static CV_PossibleValue_t resynchattempts_cons_t[] = {{0, "MIN"}, {20, "MAX"}, {0, NULL}}; consvar_t cv_resynchattempts = {"resynchattempts", "2", CV_SAVE, resynchattempts_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#ifdef SATURNSYNCH +#ifdef SATURNPAK static CV_PossibleValue_t gamestateattempts_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}}; consvar_t cv_gamestateattempts = {"gamestateresendattempts", "10", CV_SAVE, gamestateattempts_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -4218,7 +4214,7 @@ void D_ClientServerInit(void) COM_AddCommand("reloadbans", Command_ReloadBan); COM_AddCommand("connect", Command_connect); COM_AddCommand("nodes", Command_Nodes); -#ifdef SATURNSYNCH +#ifdef SATURNPAK COM_AddCommand("resendgamestate", Command_ResendGamestate); #endif COM_AddCommand("listplayers", Command_Listplayers); @@ -4278,11 +4274,7 @@ static void ResetNode(INT32 node) // SATURN #ifdef SATURNPAK is_client_saturn[node] = false; -#endif - -#ifdef SATURNSYNCH resendingsavegame[node] = false; - can_receive_gamestate[node] = false; savegameresendcooldown[node] = 0; gamestate_resend_counter[node] = 0; #endif @@ -4328,7 +4320,7 @@ void SV_ResetServer(void) mynode = 0; cl_packetmissed = false; -#ifdef SATURNSYNCH +#ifdef SATURNPAK cl_redownloadinggamestate = false; #endif @@ -4946,7 +4938,7 @@ static void HandleServerInfo(SINT8 node) } #endif -#ifdef SATURNSYNCH +#ifdef SATURNPAK static void PT_WillResendGamestate(void) { char tmpsave[264]; @@ -5413,7 +5405,7 @@ static void HandlePacketFromPlayer(SINT8 node) break; } -#ifdef SATURNSYNCH +#ifdef SATURNPAK // this decreases by one point at twice the cooldown time (ex cooldown of 2 seconds means, this counter decreases by one every 4 seconds), pretty much there to prevent a resynch loop if ((gamestate_resend_counter[node] != 0) && (I_GetTime() % ((max(cv_resynchcooldown.value, 1) * TICRATE) *2) == 0)) { @@ -5425,27 +5417,16 @@ static void HandlePacketFromPlayer(SINT8 node) if (gamestate == GS_LEVEL && (realstart > gametic - TICQUEUE+1 && realstart <= gametic) && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy) - && (!can_receive_gamestate[node] || (!resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime() && !SV_ResendingSavegameToAnyone()))) + && (!is_client_saturn[node] || (!resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime() && !SV_ResendingSavegameToAnyone()))) { -//#ifndef SATURNPAK // lug: keep this behaviour for v7.1 atleast - // we need to send this so the client can tell us if it can receive the savegame - netbuffer->packettype = PT_WILLRESENDGAMESTATE; - HSendPacket(node, true, 0, 0); - - if (can_receive_gamestate[node]) - resendingsavegame[node] = true; - else - { - SV_RequireResynch(node); - resendingsavegame[node] = false; - } -/*#else - if (can_receive_gamestate[node]) + // Check if a client is saturn before sending ANYTHING! + // this way we only send stuff to clients we know can use the gamestate resend + // and dont have to wait for a response from clients that never would send a response back + if (is_client_saturn[node]) { // Tell the client we are about to resend them the gamestate netbuffer->packettype = PT_WILLRESENDGAMESTATE; HSendPacket(node, true, 0, 0); - resendingsavegame[node] = true; } else @@ -5453,11 +5434,10 @@ static void HandlePacketFromPlayer(SINT8 node) SV_RequireResynch(node); resendingsavegame[node] = false; } -#endif*/ - if ((!can_receive_gamestate[node] && (cv_resynchattempts.value && resynch_score[node] <= (unsigned)cv_resynchattempts.value*250)) || (can_receive_gamestate[node] && (gamestate_resend_counter[node] < cv_gamestateattempts.value))) + if ((!is_client_saturn[node] && (cv_resynchattempts.value && resynch_score[node] <= (unsigned)cv_resynchattempts.value*250)) || (is_client_saturn[node] && (gamestate_resend_counter[node] < cv_gamestateattempts.value))) { - if (can_receive_gamestate[node] && resendingsavegame[node]) + if (is_client_saturn[node] && resendingsavegame[node]) { gamestate_resend_counter[node]++; DEBFILE(va("gamestate counter %d for node %d\n", gamestate_resend_counter[node], netconsole)); @@ -5769,9 +5749,8 @@ static void HandlePacketFromPlayer(SINT8 node) if (client) Got_Filetxpak(); break; -#ifdef SATURNSYNCH +#ifdef SATURNPAK case PT_CANRECEIVEGAMESTATE: - can_receive_gamestate[node] = true; PT_CanReceiveGamestate(node); break; case PT_RECEIVEDGAMESTATE: @@ -5782,12 +5761,9 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_WILLRESENDGAMESTATE: PT_WillResendGamestate(); break; -#endif -#ifdef SATURNPAK case PT_ISSATURN: DEBFILE(va("hi im on saturn! node = %d\n", node)); is_client_saturn[node] = true; - can_receive_gamestate[node] = true; break; #endif default: @@ -6854,7 +6830,7 @@ void NetUpdate(void) if (client) { -#ifdef SATURNSYNCH +#ifdef SATURNPAK // If the client just finished redownloading the game state, load it if (cl_redownloadinggamestate && fileneeded[0].status == FS_FOUND) CL_ReloadReceivedSavegame(); @@ -6863,7 +6839,7 @@ void NetUpdate(void) CL_SendClientCmd(); // Send tic cmd hu_resynching = resynch_local_inprogress; -#ifdef SATURNSYNCH +#ifdef SATURNPAK hu_redownloadinggamestate = cl_redownloadinggamestate; #endif } @@ -6874,7 +6850,7 @@ void NetUpdate(void) INT32 counts; hu_resynching = false; -#ifdef SATURNSYNCH +#ifdef SATURNPAK hu_redownloadinggamestate = false; #endif // Don't erase tics not acknowledged diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 06ff4af9b..b0cce98e3 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -108,12 +108,11 @@ typedef enum PT_PING, // Packet sent to tell clients the other client's latency to server. -#ifdef SATURNSYNCH +#ifdef SATURNPAK PT_WILLRESENDGAMESTATE, // Hey Client, I am about to resend you the gamestate! PT_CANRECEIVEGAMESTATE, // Okay Server, I'm ready to receive it, you can go ahead. PT_RECEIVEDGAMESTATE, // Thank you Server, I am ready to play again! - // we will reserve this for now even if unused, so order wont get mangled PT_ISSATURN, // Saturn specific identifier packet #endif @@ -599,7 +598,7 @@ extern consvar_t cv_allownewsaturnplayer, #endif cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, -#ifdef SATURNSYNCH +#ifdef SATURNPAK cv_resynchcooldown, cv_gamestateattempts, #endif cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; @@ -668,7 +667,7 @@ tic_t GetLag(INT32 node); //UINT8 GetFreeXCmdSize(UINT8 playerid); extern UINT8 hu_resynching; -#ifdef SATURNSYNCH +#ifdef SATURNPAK extern UINT8 hu_redownloadinggamestate; #endif extern boolean hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player diff --git a/src/d_net.c b/src/d_net.c index 06b0d0e4b..8565fb6b1 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -792,15 +792,14 @@ const char *packettypename[NUMPACKETTYPE] = "MOREFILESNEEDED", "PING" -#ifdef SATURNSYNCH +#ifdef SATURNPAK , "WILLRESENDGAMESTATE", "CANRECEIVEGAMESTATE", "RECEIVEDGAMESTATE", - // we will reserve this for now even if unused, so order wont get mangled - "ISSATURN" + "ISSATURN" // special packet to identify saturn clients #endif }; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index dc658880b..3f7641af8 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -754,7 +754,7 @@ void D_RegisterServerCommands(void) // d_clisrv CV_RegisterVar(&cv_maxplayers); CV_RegisterVar(&cv_resynchattempts); -#ifdef SATURNSYNCH +#ifdef SATURNPAK CV_RegisterVar(&cv_gamestateattempts); CV_RegisterVar(&cv_resynchcooldown); #endif diff --git a/src/doomdef.h b/src/doomdef.h index 5b7165404..12b76fc3e 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -571,12 +571,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; #ifndef NONET //-- SATURN __ -/// Enable gamestate resynching between Saturn servers and clients -/// Like SRB2 and RR does -/// Still highly experimental -#ifdef DOSATURNSYNCH -#define SATURNSYNCH - /// Detect if a client is on Saturn in the clientconfig. /// To seperately allow them to join or block joining from vanilla clients. #ifdef DOSATURNJOIN @@ -585,7 +579,8 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; #endif /// Server detection for if a connecting client is on Saturn. -/// For stuff like extra synching, etc. +/// This also enables gamestate resynching between Saturn servers and clients +/// Like SRB2 and RR does #ifdef DOSATURNPAK #define SATURNPAK #endif diff --git a/src/hu_stuff.c b/src/hu_stuff.c index faa46ae37..e41badda9 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1143,7 +1143,7 @@ void HU_Ticker(void) // Animate the desynch dots if (hu_resynching -#ifdef SATURNSYNCH +#ifdef SATURNPAK || hu_redownloadinggamestate #endif ) @@ -2244,7 +2244,7 @@ void HU_Drawer(void) // draw desynch text if (hu_resynching -#ifdef SATURNSYNCH +#ifdef SATURNPAK || hu_redownloadinggamestate #endif ) diff --git a/src/m_menu.c b/src/m_menu.c index ea5043bcf..5f88ce0b5 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2162,7 +2162,7 @@ static menuitem_t OP_AdvServerOptionsMenu[] = NULL, "Server Browser Address", &cv_masterserver, 10}, #endif {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 25}, -#ifdef SATURNSYNCH +#ifdef SATURNPAK {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Cooldown", &cv_resynchcooldown, 35}, {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Attempts", &cv_gamestateattempts, 40}, @@ -2196,7 +2196,7 @@ static const char* OP_AdvServerOptionsTooltips[] = { "Server used for master server.", "Attempts to resynchronise player to server.", -#ifdef SATURNSYNCH +#ifdef SATURNPAK "Cooldown in seconds before the Server attempts\nto resend the gamestate to a Saturn Client\nbetween resending attempts.", "Attempts to resend the Gamestate to player\nThis increments a Counter everytime a gamestate resend occurs\nThis Counter decrements at double the time of the Cooldown\nonce the Counter reaches the threshold, the client gets kicked.", #endif From ac85797a4ff2871ef13d52e2b0e164a8b1d8eb0f Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 3 Apr 2025 21:22:16 +0200 Subject: [PATCH 132/350] erronous endifma balls --- src/Makefile | 1 - src/doomdef.h | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index bd762fb8d..0da69a2ce 100644 --- a/src/Makefile +++ b/src/Makefile @@ -202,7 +202,6 @@ ifndef NOSATURNPAK DOSATURNPAK=1 endif endif -endif ifdef MINGW include win32/Makefile.cfg diff --git a/src/doomdef.h b/src/doomdef.h index 12b76fc3e..9eb991da0 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -576,7 +576,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; #ifdef DOSATURNJOIN #define SATURNJOIN #endif -#endif /// Server detection for if a connecting client is on Saturn. /// This also enables gamestate resynching between Saturn servers and clients From 086caa80bbac1a6531d147443bcc207423d953c8 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 3 Apr 2025 20:25:02 +0200 Subject: [PATCH 133/350] fix OOB read of "playeringame" not too sure if this is completely save, but it should technically --- 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 b66e35ab6..07cb54ecd 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3347,7 +3347,7 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) // remove avatar of player playeringame[playernum] = false; playernode[playernum] = UINT8_MAX; - while (!playeringame[doomcom->numslots-1] && doomcom->numslots > 1) + while ((doomcom->numslots > 1) && !playeringame[doomcom->numslots-1]) doomcom->numslots--; // Reset the name From 2bc675459844fe839093021e50d58fc84cc9a46c Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 4 Apr 2025 00:28:16 +0200 Subject: [PATCH 134/350] fix oopsie in R_Render2sidedMultiPatchColumn --- src/r_segs.c | 7 +++---- src/r_things.c | 8 ++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index e3f464ab8..41d22e56d 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -248,14 +248,13 @@ static void R_DrawWallSplats(void) // way we don't have to store extra post_t info with each column for // multi-patch textures. They are not normally needed as multi-patch // textures don't have holes in it. At least not for now. -static INT32 column2s_length; // column->length : for multi-patch on 2sided wall = texture->height static void R_Render2sidedMultiPatchColumn(column_t *column) { INT32 topscreen, bottomscreen; topscreen = sprtopscreen; // + spryscale*column->topdelta; topdelta is 0 for the wall - bottomscreen = topscreen + spryscale * column2s_length; + bottomscreen = topscreen + spryscale * lengthcol; dc_yl = (sprtopscreen+FRACUNIT-1)>>FRACBITS; dc_yh = (bottomscreen-1)>>FRACBITS; @@ -388,7 +387,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) else { colfunc_2s = R_Render2sidedMultiPatchColumn; // render multipatch with no holes (no post_t info) - column2s_length = textures[texnum]->height; + lengthcol = textures[texnum]->height; } // Setup lighting based on the presence/lack-of 3D floors. @@ -959,7 +958,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) else { colfunc_2s = R_Render2sidedMultiPatchColumn; //render multipatch with no holes (no post_t info) - column2s_length = textures[texnum]->height; + lengthcol = textures[texnum]->height; } // Set heights according to plane, or slope, whichever diff --git a/src/r_things.c b/src/r_things.c index b8e5ab5ba..2600ee72e 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -689,13 +689,13 @@ static void R_DrawFlippedMaskedColumn(column_t *column) dc_yl = mceilingclip[dc_x]+1; if (dc_yl < 0) dc_yl = 0; - if (dc_yh >= vid.height) + if (dc_yh >= vid.height) // dc_yl must be < vid.height, so reduces number of checks in tight loop dc_yh = vid.height - 1; if (dc_yl <= dc_yh && dc_yh > 0 && column->length != 0) { dc_source = ZZ_Alloc(column->length); - dc_sourcelength = column->length; + dc_sourcelength = dc_texheight = column->length; for (s = (UINT8 *)column+2+column->length, d = dc_source; d < dc_source+column->length; --s) *d++ = *s; @@ -704,6 +704,10 @@ static void R_DrawFlippedMaskedColumn(column_t *column) // Still drawn by R_DrawColumn. if (ylookup[dc_yl]) colfunc(); +#ifdef PARANOIA + else + I_Error("R_DrawMaskedColumn: Invalid ylookup for dc_yl %d", dc_yl); +#endif Z_Free(dc_source); } column = (column_t *)((UINT8 *)column + column->length + 4); From 2e34d71af688e9ae919955eee416c77f9e62119a Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 4 Apr 2025 00:29:07 +0200 Subject: [PATCH 135/350] bruh --- src/r_segs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_segs.c b/src/r_segs.c index 41d22e56d..66ba42441 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -276,7 +276,7 @@ static void R_Render2sidedMultiPatchColumn(column_t *column) if (dc_yl <= dc_yh && dc_yh < vid.height && dc_yh > 0) { dc_source = (UINT8 *)column + 3; - dc_sourcelength = column2s_length; + dc_sourcelength = lengthcol; if (colfunc == wallcolfunc) twosmultipatchfunc(); From 33e904632c88f2d2642107b7473f35ae21dd6ef5 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 4 Apr 2025 02:02:07 +0200 Subject: [PATCH 136/350] fix software crash on sparkcup due to invalid blendmode also simplifies R_GetLinedefTransTable it now just returns a normal translucency table in case of an invalid blendmode, similar to what vanilla got not sure if this is 100% correct X) --- src/r_draw.c | 16 +++++++--------- src/r_segs.c | 21 ++------------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/r_draw.c b/src/r_draw.c index ef4496349..b91ffa918 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -214,14 +214,12 @@ const UINT8 Color_Opposite[MAXSKINCOLORS*2] = CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1]; -#define TRANSTAB_AMTMUL10 (256.0f / 10.0f) - /** \brief Initializes the translucency tables used by the Software renderer. */ void R_InitTranslucencyTables(void) { - // Load here the transparency lookup tables 'TINTTAB' - // NOTE: the TINTTAB resource MUST BE aligned on 64k for the asm + // Load here the transparency lookup tables 'TRANSx0' + // NOTE: the TRANSx0 resources MUST BE aligned on 64k for the asm // optimised code (in other words, transtables pointer low word is 0) transtables = Z_MallocAlign(NUMTRANSTABLES*0x10000, PU_STATIC, NULL, 16); @@ -317,7 +315,7 @@ static void BlendTab_Modulative(UINT8 *table) static INT32 BlendTab_Count[NUMBLENDMAPS] = { - NUMTRANSTABLES, // blendtab_add + NUMTRANSTABLES+1, // blendtab_add NUMTRANSTABLES+1, // blendtab_subtract NUMTRANSTABLES+1, // blendtab_reversesubtract 1 // blendtab_modulate @@ -337,7 +335,7 @@ static INT32 BlendTab_FromStyle[] = static void BlendTab_GenerateMaps(INT32 tab, INT32 style, void (*genfunc)(UINT8 *, int, UINT8)) { INT32 i = 0, num = BlendTab_Count[tab]; - const float amtmul = (256.0f / (float)(NUMTRANSTABLES)); + const float amtmul = (256.0f / (float)(NUMTRANSTABLES + 1)); for (; i < num; i++) { const size_t offs = (0x10000 * i); @@ -384,8 +382,8 @@ UINT8 *R_GetBlendTable(int style, INT32 alphalevel) { size_t offs; - if (style == AST_COPY || style == AST_OVERLAY) - return NULL; + if (style <= AST_COPY || style >= AST_OVERLAY) + return transtables + (ClipTransLevel(alphalevel) << FF_TRANSSHIFT); offs = (ClipBlendLevel(style, alphalevel) << FF_TRANSSHIFT); @@ -414,7 +412,7 @@ UINT8 *R_GetBlendTable(int style, INT32 alphalevel) boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel) { - if (blendmode == AST_COPY || blendmode == AST_SUBTRACT || blendmode == AST_MODULATE || blendmode == AST_OVERLAY) + if (blendmode <= AST_COPY || blendmode == AST_SUBTRACT || blendmode == AST_MODULATE || blendmode >= AST_OVERLAY) return true; return (alphalevel < BlendTab_Count[BlendTab_FromStyle[blendmode]]); diff --git a/src/r_segs.c b/src/r_segs.c index 66ba42441..c27492680 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -289,24 +289,7 @@ static void R_Render2sidedMultiPatchColumn(column_t *column) transnum_t R_GetLinedefTransTable(fixed_t alpha) { - if (alpha < 9830) - return tr_trans90; - else if (alpha < 16384) - return tr_trans80; - else if (alpha < 22937) - return tr_trans70; - else if (alpha < 29491) - return tr_trans60; - else if (alpha < 36044) - return tr_trans50; - else if (alpha < 42598) - return tr_trans40; - else if (alpha < 49152) - return tr_trans30; - else if (alpha < 55705) - return tr_trans20; - else - return tr_trans10; + return (20*(FRACUNIT - alpha - 1) + FRACUNIT) >> (FRACBITS+1); } void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) @@ -350,7 +333,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) } else if (ldef->alpha > 0 && ldef->alpha < FRACUNIT) { - dc_transmap = transtables + ((R_GetLinedefTransTable(ldef->alpha) - 1) << FF_TRANSSHIFT); + dc_transmap = R_GetTranslucencyTable(R_GetLinedefTransTable(ldef->alpha)); colfunc = fuzzcolfunc; } else if (ldef->special == 909) From f2d2307fcc38469485817329d4f85290960f50fc Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 4 Apr 2025 08:15:44 +0200 Subject: [PATCH 137/350] didnt mean to change that lel --- src/r_draw8.c | 10 +++++----- src/r_things.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/r_draw8.c b/src/r_draw8.c index 1a6e45a5a..36dc15576 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -62,7 +62,7 @@ void R_DrawColumn_8(void) register INT32 heightmask = dc_sourcelength-1; npow2min = -1; - npow2max = dc_sourcelength-1; + npow2max = dc_sourcelength; if (dc_sourcelength & heightmask) // not a power of 2 -- killough { @@ -183,7 +183,7 @@ void R_Draw2sMultiPatchColumn_8(void) register INT32 heightmask = dc_sourcelength-1; register UINT8 val; npow2min = -1; - npow2max = dc_sourcelength-1; + npow2max = dc_sourcelength; if (dc_sourcelength & heightmask) // not a power of 2 -- killough { @@ -322,7 +322,7 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) register INT32 heightmask = dc_sourcelength-1; register UINT8 val; npow2min = -1; - npow2max = dc_sourcelength-1; + npow2max = dc_sourcelength; if (dc_sourcelength & heightmask) // not a power of 2 -- killough { @@ -501,7 +501,7 @@ void R_DrawTranslucentColumn_8(void) register const lighttable_t *colormap = dc_colormap; register INT32 heightmask = dc_sourcelength-1; npow2min = -1; - npow2max = dc_sourcelength-1; + npow2max = dc_sourcelength; if (dc_sourcelength & heightmask) { @@ -607,7 +607,7 @@ void R_DrawTranslatedTranslucentColumn_8(void) // This is as fast as it gets. register INT32 heightmask = dc_sourcelength-1; npow2min = -1; - npow2max = dc_sourcelength-1; + npow2max = dc_sourcelength; if (dc_sourcelength & heightmask) { diff --git a/src/r_things.c b/src/r_things.c index 2600ee72e..881f5c2ed 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -695,7 +695,7 @@ static void R_DrawFlippedMaskedColumn(column_t *column) if (dc_yl <= dc_yh && dc_yh > 0 && column->length != 0) { dc_source = ZZ_Alloc(column->length); - dc_sourcelength = dc_texheight = column->length; + dc_sourcelength = column->length; for (s = (UINT8 *)column+2+column->length, d = dc_source; d < dc_source+column->length; --s) *d++ = *s; From 2550f1bee5bb20d95e58599baa90efc8cfcff049 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 4 Apr 2025 18:13:12 +0200 Subject: [PATCH 138/350] no need to scale the volume for splitscreen if we dont play a sound lol --- src/s_sound.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/s_sound.c b/src/s_sound.c index cc8e3b2a2..fc77fdacf 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -430,7 +430,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) { const mobj_t *origin = (const mobj_t *)origin_p; const boolean reverse = (stereoreverse.value ^ encoremode); - const INT32 initial_volume = (origin ? S_ScaleVolumeWithSplitscreen(volume) : volume); + INT32 initial_volume; sfxinfo_t *sfx; INT32 sep, pitch, priority, cnum; @@ -448,6 +448,8 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) if (sfx_id == sfx_None) return; + initial_volume = (origin ? S_ScaleVolumeWithSplitscreen(volume) : volume); + for (i = 0; i <= splitscreen; i++) { player_t *player = &players[displayplayers[i]]; From 01bf367ce1388286bbb286a23b7e253974223805 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 5 Apr 2025 18:36:48 +0300 Subject: [PATCH 139/350] Add 'inputdisplay' option for hud.enable, hud.enabled, hud.disable and hud.getOffsets --- src/k_kart.c | 8 +------- src/lua_hud.h | 1 + src/lua_hudlib.c | 6 +++++- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 497d96e16..35d3699aa 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -11286,7 +11286,7 @@ void K_drawKartHUD(void) { if (!(splitscreen || demo.title)) { - if (LUA_HudEnabled(hud_position)) + if (LUA_HudEnabled(hud_inputdisplay)) K_drawInput(); } @@ -11343,12 +11343,6 @@ void K_drawKartHUD(void) if (LUA_HudEnabled(hud_position)) K_DrawKartPositionNum(stplyr->kartstuff[k_position]); } - else //if (!(demo.playback && hu_showscores)) - { - // Draw the input UI - if (LUA_HudEnabled(hud_position)) - K_drawInput(); - } } else if (G_BattleGametype()) // Battle-only { diff --git a/src/lua_hud.h b/src/lua_hud.h index 76ce9eb48..ea4d8ee02 100644 --- a/src/lua_hud.h +++ b/src/lua_hud.h @@ -32,6 +32,7 @@ enum hud { hud_wanted, hud_speedometer, hud_statdisplay, + hud_inputdisplay, hud_nametags, hud_driftgauge, hud_freeplay, diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index d19e678bd..f071f8eba 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -61,6 +61,7 @@ static const char *const hud_disable_options[] = { "wanted", "speedometer", "statdisplay", + "inputdisplay", "nametags", "driftgauge", "freeplay", @@ -187,7 +188,8 @@ enum hudoffsets { hudoffsets_check, hudoffsets_minimap, hudoffsets_wanted, - hudoffsets_statdisplay + hudoffsets_statdisplay, + hudoffsets_inputdisplay, }; static const char *const hud_offsets_options[] = { @@ -203,6 +205,7 @@ static const char *const hud_offsets_options[] = { "minimap", "wanted", "statdisplay", + "inputdisplay", NULL}; enum huddrawinfo { @@ -1290,6 +1293,7 @@ static int lib_hudgetoffsets(lua_State *L) case hudoffsets_minimap: OFS(mini) case hudoffsets_wanted: OFS(want) case hudoffsets_statdisplay: OFS(stat) + case hudoffsets_inputdisplay: OFS(wheel) default: return 0; // unreachable } From 5f2a8acfa22e628d5e2dfdd3b26e407f7254dacc Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Apr 2025 08:43:40 +0200 Subject: [PATCH 140/350] Optimze horizonline check noticed during profiling due to how it was checked R_PointOnSegSide was called extremely often even if the less expensive check returned false --- src/hardware/hw_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 03ca72f74..7515ef493 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -734,7 +734,10 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool for (i = 0; i < subsector->numlines; i++, line++) { - if (!(line->linedef->special == HORIZONSPECIAL && R_PointOnSegSide(viewx, viewy, line) == 0)) + if (line->linedef->special != HORIZONSPECIAL) + continue; + + if (R_PointOnSegSide(viewx, viewy, line) != 0) continue; P_ClosestPointOnLine(viewx, viewy, line->linedef, &v); From d57438bf8c83bf7ccd813426f5f4363398e0f988 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Apr 2025 08:45:08 +0200 Subject: [PATCH 141/350] check for horizonlines on mapload on opengl this saves iterating through a crapton of lines every frame in ogl --- src/hardware/hw_main.c | 44 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 7515ef493..53b61778d 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -94,6 +94,8 @@ line_t *gl_linedef; sector_t *gl_frontsector; sector_t *gl_backsector; +static boolean gl_maphashorizonlines = false; + // values for the far clipping plane static float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f, 12288.0f, 16384.0f}; // values for bsp culling @@ -718,7 +720,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, PolyFlags, shader, false); - if (subsector && cv_glhorizonlines.value) + if (gl_maphashorizonlines && subsector && cv_glhorizonlines.value) { // Horizon lines FOutVector horizonpts[6]; @@ -5626,6 +5628,42 @@ void HWR_RenderPlayerView(void) HWR_RenderFrame(player, false); } +static void HWR_CheckForHorizonLines(void) +{ + size_t i; + INT32 h; + + gl_maphashorizonlines = false; + + if (!cv_glhorizonlines.value) + return; + + for (i = 0; i < numsubsectors; i++) + { + subsector_t *subsec = &subsectors[i]; + + // sector checked already? + if (subsec->validcount == validcount) + continue; + + subsec->validcount = validcount; + + seg_t *line = &segs[subsec->firstline]; + + for (h = 0; h < subsec->numlines; h++, line++) + { + if (line->linedef->special != HORIZONSPECIAL) + continue; + + if (R_PointOnSegSide(viewx, viewy, line) != 0) + continue; + + gl_maphashorizonlines = true; + break; + } + } +} + void HWR_LoadLevel(void) { // Lactozilla (December 8, 2019) @@ -5645,6 +5683,8 @@ void HWR_LoadLevel(void) HWR_ClearSkyDome(); HWR_BuildSkyDome(); + HWR_CheckForHorizonLines(); + if (HWR_ShouldUsePaletteRendering()) HWR_SetMapPalette(); } @@ -5796,7 +5836,7 @@ static void COM_HWR_glinfo(void) CONS_Printf("Unrecognized argument: %s\n", argv); return; } - + } CONS_Printf("\x88OpenGL %s\x80\n", gl_version); From 5ff2b525220f167a75b209d524c2700a8b45314f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Apr 2025 09:36:48 +0200 Subject: [PATCH 142/350] more smoller optimizations save some unneeded floattofixed calls and move the linedef check earlier --- src/hardware/hw_cache.c | 2 +- src/hardware/hw_main.c | 20 ++++++++++++++------ src/r_things.c | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 824fd08e7..e67428920 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -994,7 +994,7 @@ void HWR_GetMappedPatch(GLPatch_t *glPatch, const UINT8 *colormap) // search for the mipmap // skip the first (no colormap translated) - for (glMipmap = glPatch->mipmap; glMipmap->nextcolormap; ) + for (glMipmap = glPatch->mipmap; glMipmap->nextcolormap;) { glMipmap = glMipmap->nextcolormap; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 53b61778d..4bc74eca5 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1330,28 +1330,32 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { vs.x = ((polyvertex_t *)gl_curline->pv1)->x; vs.y = ((polyvertex_t *)gl_curline->pv1)->y; + v1x = FLOAT_TO_FIXED(vs.x); + v1y = FLOAT_TO_FIXED(vs.y); } else { vs.x = FIXED_TO_FLOAT(gl_curline->v1->x); vs.y = FIXED_TO_FLOAT(gl_curline->v1->y); + v1x = gl_curline->v1->x; + v1y = gl_curline->v1->y; } + if (gl_curline->pv2) { ve.x = ((polyvertex_t *)gl_curline->pv2)->x; ve.y = ((polyvertex_t *)gl_curline->pv2)->y; + v2x = FLOAT_TO_FIXED(ve.x); + v2y = FLOAT_TO_FIXED(ve.y); } else { ve.x = FIXED_TO_FLOAT(gl_curline->v2->x); ve.y = FIXED_TO_FLOAT(gl_curline->v2->y); + v2x = gl_curline->v2->x; + v2y = gl_curline->v2->y; } - v1x = FLOAT_TO_FIXED(vs.x); - v1y = FLOAT_TO_FIXED(vs.y); - v2x = FLOAT_TO_FIXED(ve.x); - v2y = FLOAT_TO_FIXED(ve.y); - #define SLOPEPARAMS(slope, end1, end2, normalheight) \ if (slope) { \ end1 = P_GetZAt(slope, v1x, v1y); \ @@ -2315,6 +2319,9 @@ static void HWR_AddLine(seg_t *line) gl_curline = line; + if (!gl_curline->linedef) + return; + if (gl_curline->pv1) { v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x); @@ -2325,6 +2332,7 @@ static void HWR_AddLine(seg_t *line) v1x = gl_curline->v1->x; v1y = gl_curline->v1->y; } + if (gl_curline->pv2) { v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x); @@ -2341,7 +2349,7 @@ static void HWR_AddLine(seg_t *line) angle2 = R_PointToAngle64(v2x, v2y); // PrBoom: Back side, i.e. backface culling - read: endAngle >= startAngle! - if (angle2 - angle1 < ANGLE_180 || !gl_curline->linedef) + if (angle2 - angle1 < ANGLE_180) return; // PrBoom: use REAL clipping math YAYYYYYYY!!! diff --git a/src/r_things.c b/src/r_things.c index 881f5c2ed..23bd7d21a 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2889,7 +2889,7 @@ void R_ClipSprites(void) /* Check if thing may be drawn from our current view. */ boolean R_ThingVisible (mobj_t *thing) { - if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) + if (thing->sprite == SPR_NULL || (thing->flags2 & MF2_DONTDRAW)) return false; if (splitscreen) From fe3ad3487d9bed400dc5faf2a0257cc690ef23bc Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Apr 2025 09:58:58 +0200 Subject: [PATCH 143/350] delet this --- src/hardware/hw_main.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 4bc74eca5..2e8b0315e 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2319,9 +2319,6 @@ static void HWR_AddLine(seg_t *line) gl_curline = line; - if (!gl_curline->linedef) - return; - if (gl_curline->pv1) { v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x); From b706c55ed82acb01253ddcf32fdd507e557f2ea7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Apr 2025 10:29:28 +0200 Subject: [PATCH 144/350] cache this somehow this was unusually expensive lol --- src/hardware/hw_main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 2e8b0315e..4dd91cc8a 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -544,11 +544,13 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool static FOutVector *planeVerts = NULL; static UINT16 numAllocedPlaneVerts = 0; + poly_t *planepoly = xsub->planepoly; + // no convex poly were generated for this subsector - if (!xsub->planepoly) + if (!planepoly) return; - nrPlaneVerts = xsub->planepoly->numpts; + nrPlaneVerts = planepoly->numpts; if (nrPlaneVerts < 3) //not even a triangle ? return; @@ -617,7 +619,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool break; } - pv = xsub->planepoly->pts; + pv = planepoly->pts; // reference point for flat texture coord for each vertex around the polygon flatxref = (float)(((fixed_t)pv->x & (~flatflag)) / fflatsize); From 744e17a0d68141953c3464ecadb4c3aad31078cf Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Apr 2025 10:59:59 +0200 Subject: [PATCH 145/350] somehow this is slightly faster --- src/hardware/hw_cache.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index e67428920..7634906e2 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -998,11 +998,11 @@ void HWR_GetMappedPatch(GLPatch_t *glPatch, const UINT8 *colormap) { glMipmap = glMipmap->nextcolormap; - if (glMipmap->colormap != colormap) - continue; - - HWR_LoadMappedPatch(glMipmap, glPatch); - return; + if (glMipmap->colormap == colormap) + { + HWR_LoadMappedPatch(glMipmap, glPatch); + return; + } } // not found, create it! // If we are here, the sprite with the current colormap is not already in hardware memory From 4880177e6587a402890635116ab129fcd430e6ad Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Apr 2025 11:24:38 +0200 Subject: [PATCH 146/350] cache the fofflags too --- src/hardware/hw_main.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 4dd91cc8a..32379c3c9 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1898,7 +1898,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { for (rover = gl_backsector->ffloors; rover; rover = rover->next) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERSIDES) || (rover->flags & FF_INVERTSIDES)) + const ffloortype_e roverflags = rover->flags; + + if (!(roverflags & FF_EXISTS) || !(roverflags & FF_RENDERSIDES) || (roverflags & FF_INVERTSIDES)) continue; SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) @@ -1942,7 +1944,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[0].y = FIXED_TO_FLOAT(l); wallVerts[1].y = FIXED_TO_FLOAT(lS); - if (rover->flags & FF_FOG) + if (roverflags & FF_FOG) { wallVerts[3].t = wallVerts[2].t = 0; wallVerts[0].t = wallVerts[1].t = 0; @@ -2003,7 +2005,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } FBITFIELD blendmode; - if (rover->flags & FF_FOG) + if (roverflags & FF_FOG) { blendmode = PF_Fog|PF_NoTexture; @@ -2015,7 +2017,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gl_curline); if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, 0, false, &Surf, rover->flags, rover, blendmode); + HWR_SplitWall(gl_frontsector, wallVerts, 0, false, &Surf, roverflags, rover, blendmode); else HWR_AddTransparentWall(wallVerts, &Surf, 0, false, blendmode, true, lightnum, colormap); } @@ -2023,14 +2025,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { blendmode = PF_Masked; - if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) + if ((roverflags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { blendmode = rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent; Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255); } if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, texnum, noencore, &Surf, rover->flags, rover, blendmode); + HWR_SplitWall(gl_frontsector, wallVerts, texnum, noencore, &Surf, roverflags, rover, blendmode); else { if (blendmode != PF_Masked) @@ -2046,7 +2048,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { for (rover = gl_frontsector->ffloors; rover; rover = rover->next) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERSIDES) || !(rover->flags & FF_ALLSIDES)) + const ffloortype_e roverflags = rover->flags; + + if (!(roverflags & FF_EXISTS) || !(roverflags & FF_RENDERSIDES) || !(roverflags & FF_ALLSIDES)) continue; SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) @@ -2090,7 +2094,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[0].y = FIXED_TO_FLOAT(l); wallVerts[1].y = FIXED_TO_FLOAT(lS); - if (rover->flags & FF_FOG) + if (roverflags & FF_FOG) { wallVerts[3].t = wallVerts[2].t = 0; wallVerts[0].t = wallVerts[1].t = 0; @@ -2118,7 +2122,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom FBITFIELD blendmode; - if (rover->flags & FF_FOG) + if (roverflags & FF_FOG) { blendmode = PF_Fog|PF_NoTexture; @@ -2130,7 +2134,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gl_curline); if (gl_backsector->numlights) - HWR_SplitWall(gl_backsector, wallVerts, 0, false, &Surf, rover->flags, rover, blendmode); + HWR_SplitWall(gl_backsector, wallVerts, 0, false, &Surf, roverflags, rover, blendmode); else HWR_AddTransparentWall(wallVerts, &Surf, 0, false, blendmode, true, lightnum, colormap); } @@ -2138,14 +2142,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { blendmode = PF_Masked; - if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) + if ((roverflags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { blendmode = rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent; Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255); } if (gl_backsector->numlights) - HWR_SplitWall(gl_backsector, wallVerts, texnum, noencore, &Surf, rover->flags, rover, blendmode); + HWR_SplitWall(gl_backsector, wallVerts, texnum, noencore, &Surf, roverflags, rover, blendmode); else { if (blendmode != PF_Masked) From 4a703a4288530fda914377bc6fdc4410f5629cd8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Apr 2025 15:14:49 +0200 Subject: [PATCH 147/350] use the float vid dimensions forgor here --- src/hardware/hw_draw.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index d677af281..bc655e935 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -256,8 +256,8 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t fheight = (float)SHORT(gpatch->height) * fscaleh * dupy; // positions of the cx, cy, are between 0 and vid.width/vid.height now, we need them to be between -1 and 1 - cx = -1.0f + (cx / (vid.width / 2.0f)); - cy = 1.0f - (cy / (vid.height / 2.0f)); + cx = -1.0f + (cx / (fvw / 2.0f)); + cy = 1.0f - (cy / (fvh / 2.0f)); // fwidth and fheight are similar fwidth /= fvw / 2.0f; @@ -301,7 +301,7 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t { FSurfaceInfo Surf; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; - + if (alphalevel == 13) Surf.PolyColor.s.alpha = softwaretranstogl_lo[hudtrans]; else if (alphalevel == 14) Surf.PolyColor.s.alpha = softwaretranstogl[hudtrans]; else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[hudtrans]; @@ -430,8 +430,8 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal } // positions of the cx, cy, are between 0 and vid.width/vid.height now, we need them to be between -1 and 1 - cx = -1.0f + (cx / (vid.width / 2.0f)); - cy = 1.0f - (cy / (vid.height / 2.0f)); + cx = -1.0f + (cx / (fvw / 2.0f)); + cy = 1.0f - (cy / (fvh / 2.0f)); // fwidth and fheight are similar fwidth /= fvw / 2.0f; @@ -468,7 +468,7 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal else if (alphalevel == 14) Surf.PolyColor.s.alpha = softwaretranstogl[cv_translucenthud.value]; else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[cv_translucenthud.value]; else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; - + flags |= PF_Modulated; GL_DrawPolygon(&Surf, v, 4, flags); } From 3aff53647d9da15e87aeab6a5a2af37f21fee6b2 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Apr 2025 15:14:57 +0200 Subject: [PATCH 148/350] reorder those a little --- src/hardware/hw_main.c | 21 +++++++++++---------- src/m_aatree.c | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 32379c3c9..0af1e54e3 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3843,15 +3843,13 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) INT32 shader = SHADER_NONE; - if (P_MobjWasRemoved(spr->mobj)) - return; - - if (!spr->mobj->subsector) + if (!spr->mobj || !spr->mobj->subsector) return; const boolean papersprite = (spr->mobj->frame & FF_PAPERSPRITE); + sector_t *sector = spr->mobj->subsector->sector; - if (spr->mobj->subsector->sector->numlights) + if (sector->numlights) { HWR_SplitSprite(spr, papersprite); return; @@ -3887,7 +3885,9 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) { wallVerts[0].s = wallVerts[3].s = gpatch->max_s; wallVerts[2].s = wallVerts[1].s = 0; - }else{ + } + else + { wallVerts[0].s = wallVerts[3].s = 0; wallVerts[2].s = wallVerts[1].s = gpatch->max_s; } @@ -3897,7 +3897,9 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) { wallVerts[3].t = wallVerts[2].t = gpatch->max_t; wallVerts[0].t = wallVerts[1].t = 0; - }else{ + } + else + { wallVerts[3].t = wallVerts[2].t = 0; wallVerts[0].t = wallVerts[1].t = gpatch->max_t; } @@ -3927,17 +3929,16 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) /// \todo coloured // colormap test - sector_t *sector = spr->mobj->subsector->sector; INT32 lightlevel = 255; boolean lightset = HWR_OverrideObjectLightLevel(spr->mobj, &lightlevel); extracolormap_t *colormap = sector->extra_colormap; const boolean fullbright = R_ThingIsFullBright(spr->mobj); if (!lightset) + { lightlevel = min(sector->lightlevel, 255); - - if (!lightset) HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false); + } HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !fullbright); diff --git a/src/m_aatree.c b/src/m_aatree.c index f19fa1dc0..5e7117a5c 100644 --- a/src/m_aatree.c +++ b/src/m_aatree.c @@ -138,7 +138,7 @@ static void *M_AATreeGet_Node(aatree_node_t *node, INT32 key) { if (node->key == key) return node->value; - else if(node->key < key) + else if (node->key < key) return M_AATreeGet_Node(node->right, key); else return M_AATreeGet_Node(node->left, key); From 3261fd12dbfd5ee9e5996ca98c30d65452d1e955 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Apr 2025 16:25:01 +0200 Subject: [PATCH 149/350] dont need this --- src/hardware/hw_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 0af1e54e3..ffeae84f0 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -757,6 +757,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool x1 = FIXED_TO_FLOAT(line->v1->x); y1 = FIXED_TO_FLOAT(line->v1->x); } + if (line->pv2) { xd = ((polyvertex_t *)line->pv2)->x - x1; @@ -4589,7 +4590,7 @@ static void HWR_ProjectSprite(mobj_t *thing) angle_t sliptiderollangle = 0; #endif - if (P_MobjWasRemoved(thing) || thing->subsector == NULL) + if (!thing || thing->subsector == NULL) return; // uncapped/interpolation From bd77b17c1c8087acfd4710a6a44403190f43f860 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Apr 2025 17:13:04 +0200 Subject: [PATCH 150/350] whoopy copy paste --- src/hardware/hw_main.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index ffeae84f0..f5bbdfa9f 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5668,9 +5668,6 @@ static void HWR_CheckForHorizonLines(void) if (line->linedef->special != HORIZONSPECIAL) continue; - if (R_PointOnSegSide(viewx, viewy, line) != 0) - continue; - gl_maphashorizonlines = true; break; } From 27653381d3e15f6179391cf610c2b257b6fa80ca Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Apr 2025 17:03:23 +0200 Subject: [PATCH 151/350] try to rectify some branch mispredictions adds "LIKELY" and "UNLIKELY" macros those can be used to tell the compiler which path is more likely to happen --- src/doomdef.h | 13 +++++++++++++ src/hardware/hw_cache.c | 10 +++++----- src/hardware/hw_main.c | 23 ++++++++++++----------- src/r_things.c | 2 +- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 9eb991da0..d004d43bf 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -547,6 +547,19 @@ UINT32 quickncasehash (const char *p, size_t n) #define DBL_EPSILON 2.2204460492503131e-16l #endif +#if defined(__GNUC__) || defined(__clang__) +#ifndef LIKELY +#define LIKELY(x) __builtin_expect(!!(x), 1) +#endif + +#ifndef UNLIKELY +#define UNLIKELY(x) __builtin_expect(!!(x), 0) +#endif +#else +#define LIKELY(x) (x) +#define UNLIKELY(x) (x) +#endif + // An assert-type mechanism. #ifdef PARANOIA #define I_Assert(e) ((e) ? (void)0 : I_Error("assert failed: %s, file %s, line %d", #e, __FILE__, __LINE__)) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 7634906e2..5ba8655b8 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -331,8 +331,8 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe gltex->mipmap.format = textureformat; // hack the Legacy skies.. - if (strncmp(texture->name, "SKY", 3) == 0 && - (texture->name[4] == 0 || texture->name[5] == 0)) + if (UNLIKELY(strncmp(texture->name, "SKY", 3) == 0 && + (texture->name[4] == 0 || texture->name[5] == 0))) { skyspecial = true; gltex->mipmap.flags &= ~TF_CHROMAKEYED; // don't use the chromakey for sky @@ -349,7 +349,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe blocksize = (blockwidth * blockheight); block = MakeBlock(&gltex->mipmap); - if (skyspecial) // Hurdler: not efficient, but better than holes in the sky (and it's done only at level loading) + if (UNLIKELY(skyspecial)) // Hurdler: not efficient, but better than holes in the sky (and it's done only at level loading) { INT32 j; RGBA_t col; @@ -994,11 +994,11 @@ void HWR_GetMappedPatch(GLPatch_t *glPatch, const UINT8 *colormap) // search for the mipmap // skip the first (no colormap translated) - for (glMipmap = glPatch->mipmap; glMipmap->nextcolormap;) + for (glMipmap = glPatch->mipmap; LIKELY(glMipmap->nextcolormap);) { glMipmap = glMipmap->nextcolormap; - if (glMipmap->colormap == colormap) + if (UNLIKELY(glMipmap->colormap == colormap)) { HWR_LoadMappedPatch(glMipmap, glPatch); return; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index f5bbdfa9f..ef4ea1afb 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1247,7 +1247,7 @@ static inline boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf) pSurf->PolyColor.s.alpha = 0xFF; - if (!gl_curline->polyseg) + if (LIKELY(!gl_curline->polyseg)) { // set alpha for transparent walls switch (gl_linedef->special) @@ -1329,7 +1329,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom const boolean noencore = (gl_linedef->flags & ML_TFERLINE); - if (gl_curline->pv1) + if (LIKELY(gl_curline->pv1)) { vs.x = ((polyvertex_t *)gl_curline->pv1)->x; vs.y = ((polyvertex_t *)gl_curline->pv1)->y; @@ -1344,7 +1344,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom v1y = gl_curline->v1->y; } - if (gl_curline->pv2) + if (LIKELY(gl_curline->pv2)) { ve.x = ((polyvertex_t *)gl_curline->pv2)->x; ve.y = ((polyvertex_t *)gl_curline->pv2)->y; @@ -2185,7 +2185,7 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) { fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t - if (gl_curline->pv1) + if (LIKELY(gl_curline->pv1)) { v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x); v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y); @@ -2195,7 +2195,8 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) v1x = gl_curline->v1->x; v1y = gl_curline->v1->y; } - if (gl_curline->pv2) + + if (LIKELY(gl_curline->pv2)) { v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x); v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y); @@ -2326,7 +2327,7 @@ static void HWR_AddLine(seg_t *line) gl_curline = line; - if (gl_curline->pv1) + if (LIKELY(gl_curline->pv1)) { v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x); v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y); @@ -2337,7 +2338,7 @@ static void HWR_AddLine(seg_t *line) v1y = gl_curline->v1->y; } - if (gl_curline->pv2) + if (LIKELY(gl_curline->pv2)) { v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x); v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y); @@ -2364,7 +2365,7 @@ static void HWR_AddLine(seg_t *line) gl_backsector = line->backsector; - if (!cv_glportals.value || !gl_maphasportals) + if (!cv_glportals.value || LIKELY(!gl_maphasportals)) goto doaddline; // do extra checks on the seg when rendering portals: @@ -2425,7 +2426,7 @@ doaddline: return; } - if (gl_portal_state != GLPORTAL_SEARCH && !dont_draw)// no need to do this during the portal check + if (LIKELY(gl_portal_state != GLPORTAL_SEARCH && !dont_draw))// no need to do this during the portal check HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D return; @@ -2913,7 +2914,7 @@ static void HWR_Subsector(size_t num) sector_t *controlSec = §ors[rover->secnum]; - if (controlSec->moved != true) + if (!controlSec->moved) continue; anyMoved = true; @@ -3144,7 +3145,7 @@ doaddline: while (count--) { - if (!line->polyseg) // ignore segs that belong to polyobjects + if (LIKELY(!line->polyseg)) // ignore segs that belong to polyobjects HWR_AddLine(line); line++; } diff --git a/src/r_things.c b/src/r_things.c index 23bd7d21a..7c921835e 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2889,7 +2889,7 @@ void R_ClipSprites(void) /* Check if thing may be drawn from our current view. */ boolean R_ThingVisible (mobj_t *thing) { - if (thing->sprite == SPR_NULL || (thing->flags2 & MF2_DONTDRAW)) + if (UNLIKELY(thing->sprite == SPR_NULL) || UNLIKELY((thing->flags2 & MF2_DONTDRAW))) return false; if (splitscreen) From f159b18e96fc70130237f2325cdf741cea3f7ee4 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 7 Apr 2025 06:46:26 +0200 Subject: [PATCH 152/350] this is unlikely --- src/m_aatree.c | 4 ++-- src/r_bsp.c | 4 ++-- src/r_main.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/m_aatree.c b/src/m_aatree.c index 5e7117a5c..ece4f0acb 100644 --- a/src/m_aatree.c +++ b/src/m_aatree.c @@ -134,9 +134,9 @@ void M_AATreeSet(aatree_t *aatree, INT32 key, void* value) // and nodes with value == NULL. static void *M_AATreeGet_Node(aatree_node_t *node, INT32 key) { - if (node) + if (LIKELY(node)) { - if (node->key == key) + if (UNLIKELY(node->key == key)) return node->value; else if (node->key < key) return M_AATreeGet_Node(node->right, key); diff --git a/src/r_bsp.c b/src/r_bsp.c index d3dcb94ae..278bafb82 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -374,7 +374,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, boolean R_IsEmptyLine(seg_t *line, const sector_t *front, const sector_t *back) { - return (!line->polyseg && !line->sidedef->midtexture + return (!line->sidedef->midtexture && !line->polyseg && ((!front->ffloors && !back->ffloors) || front->tag == back->tag) && (memcmp(front, back, (offsetof(sector_t, extra_colormap) + sizeof(extracolormap_t *))) == 0)); } @@ -794,7 +794,7 @@ static void R_AddPolyObjects(subsector_t *sub) ++numpolys; po = (polyobj_t *)(po->link.next); } - + // for render stats ps_numpolyobjects.value.i += numpolys; diff --git a/src/r_main.c b/src/r_main.c index e4a4994ac..4ff9a96ff 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1374,7 +1374,7 @@ void R_RenderPlayerView(player_t *player) } Portal_InitList(); - + PS_START_TIMING(ps_skyboxtime); if (skybox && skyVisible) { @@ -1438,7 +1438,7 @@ void R_RenderPlayerView(player_t *player) PS_START_TIMING(ps_sw_spritecliptime); R_ClipSprites(); PS_STOP_TIMING(ps_sw_spritecliptime); - + ps_numsprites.value.i = numvisiblesprites; PS_START_TIMING(ps_sw_portaltime); From 4b8d07215379f062bb0b4a2a4b2f95c15ceda8e8 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 7 Apr 2025 07:45:05 +0200 Subject: [PATCH 153/350] free ogl lighttables earlier ogl lighttable data is owned by extracolormaps apparently, so it has to be freed ealier --- src/p_setup.c | 9 +++++++-- src/r_data.c | 14 ++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 2400bc2e0..e6e46edd6 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1444,7 +1444,7 @@ static void P_LoadRawSideDefs2(void *data) // encore mode colormaps! // do it like software by aproximating a color to a palette index, and then convert it to its encore variant and then back to a color code. // do this for both the start and fade colormaps. - + color.s.red = (HEX2INT(col[1]) << 4) + HEX2INT(col[2]); color.s.green = (HEX2INT(col[3]) << 4) + HEX2INT(col[4]); color.s.blue = (HEX2INT(col[5]) << 4) + HEX2INT(col[6]); @@ -1485,7 +1485,7 @@ static void P_LoadRawSideDefs2(void *data) col = msd->bottomtexture; // do the exact same thing as above here. - + color.s.red = (HEX2INT(col[1]) << 4) + HEX2INT(col[2]); color.s.green = (HEX2INT(col[3]) << 4) + HEX2INT(col[4]); color.s.blue = (HEX2INT(col[5]) << 4) + HEX2INT(col[6]); @@ -3047,6 +3047,11 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) // Clear pointers that would be left dangling by the purge R_FlushTranslationColormapCache(); +#ifdef HWRENDER + // Delete light table textures + HWR_ClearLightTables(); +#endif + Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1); #if defined (WALLSPLATS) || defined (FLOORSPLATS) diff --git a/src/r_data.c b/src/r_data.c index ddac60598..6b4bef3d0 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -28,7 +28,6 @@ #ifdef HWRENDER #include "hardware/hw_main.h" -#include "hardware/hw_glob.h" // HWR_ClearLightTables #endif #ifdef _WIN32 @@ -1266,11 +1265,6 @@ void R_ClearColormaps(void) foundcolormaps[i] = LUMPERROR; memset(extra_colormaps, 0, sizeof (extra_colormaps)); - -#ifdef HWRENDER - if (rendermode == render_opengl) - HWR_ClearLightTables(); -#endif } /*INT32 R_ColormapNumForName(char *name) @@ -1451,13 +1445,13 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) extra_colormaps[mapnum].fadestart = (UINT16)fadestart; extra_colormaps[mapnum].fadeend = (UINT16)fadeend; extra_colormaps[mapnum].fog = fog; - + if (rendermode != render_none) - { + { double r, g, b, cbrightness; int p; lighttable_t *colormap_p; - + // Initialise the map and delta arrays // map[i] stores an RGB color (as double) for index i, // which is then converted to SRB2's palette later @@ -1537,7 +1531,7 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) } } } - + return (INT32)mapnum; } From 6b12c553936713732c11133e85e07fb4f9b68afb Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 7 Apr 2025 08:40:37 +0200 Subject: [PATCH 154/350] some software optimizations from: https://git.do.srb2.org/Hanicef/SRB2Classic/-/merge_requests/6#d4bba40be8388ccd557d03ef4e4a36d0728c7751_645_587 minus the buffer flipping change, karts resolution stuff is hell and even worse due to birdmod things maybe will look into that sometime --- src/r_draw8.c | 129 +++++++++++++++++++++++-------------------------- src/r_segs.c | 12 ++--- src/r_things.c | 2 +- 3 files changed, 68 insertions(+), 75 deletions(-) diff --git a/src/r_draw8.c b/src/r_draw8.c index 36dc15576..685810c80 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -25,9 +25,9 @@ void R_DrawColumn_8(void) { INT32 count; - register UINT8 *dest; - register fixed_t frac; - fixed_t fracstep; + UINT8 *restrict dest; + intptr_t frac; + intptr_t fracstep; INT32 npow2min; INT32 npow2max; @@ -57,10 +57,10 @@ void R_DrawColumn_8(void) // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. - register const UINT8 *source = dc_source; - register const lighttable_t *colormap = dc_colormap; + const UINT8 *restrict source = dc_source; + const lighttable_t *restrict colormap = dc_colormap; - register INT32 heightmask = dc_sourcelength-1; + intptr_t heightmask = dc_sourcelength-1; npow2min = -1; npow2max = dc_sourcelength; @@ -77,10 +77,7 @@ void R_DrawColumn_8(void) } else { - while (frac >= heightmask) - { - frac -= heightmask; - } + frac %= heightmask; } do @@ -105,20 +102,20 @@ void R_DrawColumn_8(void) dest += vid.width; + +#if __SIZEOF_POINTER__ < 8 // 64-bit systems have large enough numbers for this to be a non-issue // Avoid overflow. if (fracstep > 0x7FFFFFFF - frac) { frac += fracstep - heightmask; } else +#endif { frac += fracstep; } - while (frac >= heightmask) - { - frac -= heightmask; - } + frac %= heightmask; } while (--count); } else @@ -147,9 +144,10 @@ void R_DrawColumn_8(void) void R_Draw2sMultiPatchColumn_8(void) { INT32 count; - register UINT8 *dest; - register fixed_t frac; - fixed_t fracstep; + UINT8 *restrict dest; + intptr_t frac; + intptr_t fracstep; + INT32 npow2min; INT32 npow2max; @@ -178,10 +176,11 @@ void R_Draw2sMultiPatchColumn_8(void) // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. - register const UINT8 *source = dc_source; - register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_sourcelength-1; - register UINT8 val; + const UINT8 *restrict source = dc_source; + const lighttable_t *restrict colormap = dc_colormap; + intptr_t heightmask = dc_sourcelength-1; + UINT8 val; + npow2min = -1; npow2max = dc_sourcelength; @@ -198,10 +197,7 @@ void R_Draw2sMultiPatchColumn_8(void) } else { - while (frac >= heightmask) - { - frac -= heightmask; - } + frac %= heightmask; } do @@ -233,19 +229,18 @@ void R_Draw2sMultiPatchColumn_8(void) dest += vid.width; // Avoid overflow. +#if __SIZEOF_POINTER__ < 8 if (fracstep > 0x7FFFFFFF - frac) { frac += fracstep - heightmask; } else +#endif { frac += fracstep; } - while (frac >= heightmask) - { - frac -= heightmask; - } + frac %= heightmask; } while (--count); } else @@ -285,9 +280,10 @@ void R_Draw2sMultiPatchColumn_8(void) void R_Draw2sMultiPatchTranslucentColumn_8(void) { INT32 count; - register UINT8 *dest; - register fixed_t frac; - fixed_t fracstep; + UINT8 *restrict dest; + intptr_t frac; + intptr_t fracstep; + INT32 npow2min; INT32 npow2max; @@ -316,11 +312,12 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. - register const UINT8 *source = dc_source; - register const UINT8 *transmap = dc_transmap; - register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_sourcelength-1; + const UINT8 *restrict source = dc_source; + const UINT8 *transmap = dc_transmap; + const lighttable_t *restrict colormap = dc_colormap; + intptr_t heightmask = dc_sourcelength-1; register UINT8 val; + npow2min = -1; npow2max = dc_sourcelength; @@ -337,10 +334,7 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) } else { - while (frac >= heightmask) - { - frac -= heightmask; - } + frac %= heightmask; } do @@ -372,19 +366,18 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) dest += vid.width; // Avoid overflow. +#if __SIZEOF_POINTER__ < 8 if (fracstep > 0x7FFFFFFF - frac) { frac += fracstep - heightmask; } else +#endif { frac += fracstep; } - while (frac >= heightmask) - { - frac -= heightmask; - } + frac %= heightmask; } while (--count); } else @@ -470,8 +463,10 @@ void R_DrawShadeColumn_8(void) void R_DrawTranslucentColumn_8(void) { register INT32 count; - register UINT8 *dest; - register fixed_t frac, fracstep; + UINT8 *restrict dest; + intptr_t frac; + intptr_t fracstep; + INT32 npow2min; INT32 npow2max; @@ -496,10 +491,11 @@ void R_DrawTranslucentColumn_8(void) // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. - register const UINT8 *source = dc_source; - register const UINT8 *transmap = dc_transmap; - register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_sourcelength-1; + const UINT8 *restrict source = dc_source; + const UINT8 *transmap = dc_transmap; + const lighttable_t *restrict colormap = dc_colormap; + intptr_t heightmask = dc_sourcelength-1; + npow2min = -1; npow2max = dc_sourcelength; @@ -516,10 +512,7 @@ void R_DrawTranslucentColumn_8(void) } else { - while (frac >= heightmask) - { - frac -= heightmask; - } + frac %= heightmask; } do @@ -579,8 +572,10 @@ void R_DrawTranslucentColumn_8(void) void R_DrawTranslatedTranslucentColumn_8(void) { register INT32 count; - register UINT8 *dest; - register fixed_t frac, fracstep; + UINT8 *restrict dest; + intptr_t frac; + intptr_t fracstep; + INT32 npow2min; INT32 npow2max; @@ -605,7 +600,8 @@ void R_DrawTranslatedTranslucentColumn_8(void) // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. - register INT32 heightmask = dc_sourcelength-1; + intptr_t heightmask = dc_sourcelength-1; + npow2min = -1; npow2max = dc_sourcelength; @@ -622,10 +618,7 @@ void R_DrawTranslatedTranslucentColumn_8(void) } else { - while (frac >= heightmask) - { - frac -= heightmask; - } + frac %= heightmask; } do @@ -739,15 +732,15 @@ void R_DrawTranslatedColumn_8(void) */ void R_DrawSpan_8 (void) { - fixed_t xposition; - fixed_t yposition; - fixed_t xstep, ystep; + uintptr_t xposition; + uintptr_t yposition; + uintptr_t xstep, ystep; register UINT32 bit; - const UINT8 *source = ds_source; - const UINT8 *colormap = ds_colormap; - register UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1]; - const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; + UINT8 *restrict source; + UINT8 *restrict colormap; + UINT8 *restrict dest; + const UINT8 *restrict deststop = screens[0] + vid.rowbytes * vid.height; register size_t count = (ds_x2 - ds_x1 + 1); size_t i; diff --git a/src/r_segs.c b/src/r_segs.c index c27492680..8a9f0dc29 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -322,7 +322,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (!ldef->alpha) return; - + if (ldef->blendmode) { if (ldef->alpha == NUMTRANSMAPS || ldef->blendmode == AST_MODULATE) @@ -628,7 +628,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) // draw the texture col = (column_t *)((UINT8 *)R_GetColumn(texnum, maskedtexturecol[dc_x]) - 3); - + colfunc_2s(col); } spryscale += rw_scalestep; @@ -1581,7 +1581,7 @@ static void R_RenderSegLoop (void) { if (curline->polyseg && (ffloor[i].polyobj != curline->polyseg)) continue; - + ffloor[i].f_clip[rw_x] = ffloor[i].c_clip[rw_x] = (INT16)((ffloor[i].b_frac >> HEIGHTBITS) & 0xFFFF); ffloor[i].b_frac += ffloor[i].b_step; } @@ -1590,7 +1590,7 @@ static void R_RenderSegLoop (void) topfrac += topstep; bottomfrac += bottomstep; } - + //colfunc = wallcolfunc; } @@ -1690,7 +1690,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) while (need > maxopenings); openings = Z_Realloc(openings, maxopenings * sizeof (*openings), PU_STATIC, NULL); lastopening = openings + pos; - + if (oldopenings == NULL) return; @@ -2817,7 +2817,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) R_ExpandPlane(ffloor[i].plane, rw_x, rw_stopx - 1); } } - + rw_silhouette = &(ds_p->silhouette); rw_tsilheight = &(ds_p->tsilheight); rw_bsilheight = &(ds_p->bsilheight); diff --git a/src/r_things.c b/src/r_things.c index 7c921835e..ca9d570c0 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -897,7 +897,7 @@ static void R_DrawVisSprite(vissprite_t *vis) else { // Non-paper drawing loop - for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) + for (dc_x = vis->x1; dc_x <= vis->x2 && (frac>>FRACBITS) < patch->width; dc_x++, frac += vis->xiscale) { texturecolumn = CLAMP(frac >> FRACBITS, 0, SHORT(patch->width) - 1); column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); From dd93e1f7b06fd8e0fa6b7f092068e7482702dc9a Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 7 Apr 2025 08:39:43 +0200 Subject: [PATCH 155/350] use optimized P_DivlineSide instead of R_PointOnSideFast --- src/p_sight.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/p_sight.c b/src/p_sight.c index 84b96da16..31c82823a 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -39,10 +39,19 @@ static INT32 sightcounts[2]; // Returns side 0 (front), 1 (back), or 2 (on). // // killough 4/19/98: made static, cleaned up -static INT32 P_DivlineSide(fixed_t x, fixed_t y, const divline_t *node) +static INT32 P_DivlineSide(fixed_t x, fixed_t y, const divline_t *node, boolean fast) { fixed_t left, right; + if (fast) + { + INT64 v = ((INT64)y - node->y) * node->dx - ((INT64)x - node->x) * node->dy; + + if (v == 0) + return 2; + return v > 0; + } + return( !node->dx ? x == node->x ? 2 : x <= node->x ? node->dy > 0 : node->dy < 0 : !node->dy ? y == node->y ? 2 : y <= node->y ? node->dx < 0 : node->dx > 0 : @@ -53,7 +62,7 @@ static INT32 P_DivlineSide(fixed_t x, fixed_t y, const divline_t *node) static inline INT32 P_DivlineCrossed(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, const divline_t *node) { - return (P_DivlineSide(x1, y1, node) == P_DivlineSide(x2, y2, node)); + return (P_DivlineSide(x1, y1, node, false) == P_DivlineSide(x2, y2, node, false)); } static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los) @@ -296,8 +305,8 @@ static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los, boolean fast) { register node_t *bsp = nodes + bspnum; - INT32 side = (fast ? R_PointOnSideFast(los->strace.x, los->strace.y, bsp) : (P_DivlineSide(los->strace.x, los->strace.y, (divline_t *)bsp) & 1)); - INT32 side2 = (fast ? R_PointOnSideFast(los->t2x, los->t2y, bsp) : P_DivlineSide(los->t2x, los->t2y, (divline_t *) bsp)); + INT32 side = P_DivlineSide(los->strace.x, los->strace.y, (divline_t *)bsp, fast) & 1; + INT32 side2 = P_DivlineSide(los->t2x, los->t2y, (divline_t *) bsp, fast); if (side == side2) { From f99794884b35163ae5021b1c39ba90acc40df9ce Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 7 Apr 2025 09:10:10 +0200 Subject: [PATCH 156/350] =?UTF-8?q?avoid=20branching=20inside=20the=20whil?= =?UTF-8?q?e=20l=C3=B6=C3=B6p?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/p_sight.c | 30 +++++++++++++++++------------- src/v_video.c | 1 + 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/p_sight.c b/src/p_sight.c index 31c82823a..5dfc796b8 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -33,25 +33,18 @@ typedef struct { static INT32 sightcounts[2]; +typedef INT32 (*divlinefunc)(fixed_t x, fixed_t y, const divline_t *node); + // // P_DivlineSide // // Returns side 0 (front), 1 (back), or 2 (on). // // killough 4/19/98: made static, cleaned up -static INT32 P_DivlineSide(fixed_t x, fixed_t y, const divline_t *node, boolean fast) +static INT32 P_DivlineSide(fixed_t x, fixed_t y, const divline_t *node) { fixed_t left, right; - if (fast) - { - INT64 v = ((INT64)y - node->y) * node->dx - ((INT64)x - node->x) * node->dy; - - if (v == 0) - return 2; - return v > 0; - } - return( !node->dx ? x == node->x ? 2 : x <= node->x ? node->dy > 0 : node->dy < 0 : !node->dy ? y == node->y ? 2 : y <= node->y ? node->dx < 0 : node->dx > 0 : @@ -60,9 +53,18 @@ static INT32 P_DivlineSide(fixed_t x, fixed_t y, const divline_t *node, boolean right == left ? 2 : 1); } +static inline INT32 P_DivlineSideFast(fixed_t x, fixed_t y, const divline_t *node) +{ + INT64 v = ((INT64)y - node->y) * node->dx - ((INT64)x - node->x) * node->dy; + + if (v == 0) + return 2; + return v > 0; +} + static inline INT32 P_DivlineCrossed(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, const divline_t *node) { - return (P_DivlineSide(x1, y1, node, false) == P_DivlineSide(x2, y2, node, false)); + return (P_DivlineSide(x1, y1, node) == P_DivlineSide(x2, y2, node)); } static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los) @@ -301,12 +303,14 @@ static boolean P_CrossSubsector(size_t num, register los_t *los) // killough 4/20/98: rewritten to remove tail recursion, clean up, and optimize static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los, boolean fast) { + const divlinefunc divlineFunc = fast ? P_DivlineSideFast : P_DivlineSide; + while (!(bspnum & NF_SUBSECTOR)) { register node_t *bsp = nodes + bspnum; - INT32 side = P_DivlineSide(los->strace.x, los->strace.y, (divline_t *)bsp, fast) & 1; - INT32 side2 = P_DivlineSide(los->t2x, los->t2y, (divline_t *) bsp, fast); + INT32 side = divlineFunc(los->strace.x, los->strace.y, (divline_t *)bsp) & 1; + INT32 side2 = divlineFunc(los->t2x, los->t2y, (divline_t *) bsp); if (side == side2) { diff --git a/src/v_video.c b/src/v_video.c index 3dcd3323b..4018ec98a 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1695,6 +1695,7 @@ void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed) c -= HU_FONTSTART; else c = toupper(c) - HU_FONTSTART; + if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) return; From 8251ac9ca81e88b0851d7e39b9b1942ff0208478 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 7 Apr 2025 16:20:45 +0200 Subject: [PATCH 157/350] sat credits a --- src/f_finale.c | 3 ++- src/m_menu.c | 61 +++++++++++++++++++++++++------------------------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index 209c3e55a..fbee630b6 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -538,6 +538,7 @@ static const char *credits[] = { "\"Nexit\"", "\"Spee\"", "\"Jin\"", + "\"riomccloud\"", "\"chromaticpipe\"", "\"Achii\"", "\"Anonimus\"", @@ -1012,7 +1013,7 @@ void F_TitleScreenDrawer(void) else { INT32 transval = 0; - + if (finalecount <= (50+(9<<1))) transval = (finalecount - 50)>>1; diff --git a/src/m_menu.c b/src/m_menu.c index 5f88ce0b5..251eebf25 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2286,8 +2286,8 @@ static menuitem_t OP_SaturnMenu[] = {IT_STRING | IT_CVAR, NULL, "Skin Select Spinning Speed", &cv_skinselectspin, 20}, - {IT_STRING | IT_CVAR, NULL, "Colourized Speedlines", &cv_coloredspeedlines, 30}, - {IT_STRING | IT_CVAR, NULL, "Colourized Sneakertrails", &cv_coloredsneakertrail, 35}, + {IT_STRING | IT_CVAR, NULL, "Colorized Speedlines", &cv_coloredspeedlines, 30}, + {IT_STRING | IT_CVAR, NULL, "Colorized Sneakertrails", &cv_coloredsneakertrail, 35}, {IT_STRING | IT_CVAR, NULL, "Player Blendeffects", &cv_playerblendeffects, 45}, @@ -2300,7 +2300,7 @@ static menuitem_t OP_SaturnMenu[] = {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 90}, - {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 100}, + {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 100}, {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 110}, {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 115}, @@ -2548,36 +2548,37 @@ static menuitem_t OP_SaturnCreditsMenu[] = { {IT_HEADER, NULL, "Saturn Credits", NULL, 0}, - {IT_HEADER, NULL, "Thanks to all contributers <3", NULL, 10}, + {IT_HEADER, NULL, "Thanks to all contributers <3", NULL, 7}, - {IT_STRING2+IT_SPACE, NULL, "Alug", NULL, 20}, - {IT_STRING2+IT_SPACE, NULL, "Indev", NULL, 30}, - {IT_STRING2+IT_SPACE, NULL, "Haya", NULL, 40}, - {IT_STRING2+IT_SPACE, NULL, "Nepdisk", NULL, 50}, - {IT_STRING2+IT_SPACE, NULL, "GenericHeroGuy", NULL, 60}, - {IT_STRING2+IT_SPACE, NULL, "xyzzy", NULL, 70}, - {IT_STRING2+IT_SPACE, NULL, "Chearii", NULL, 80}, + {IT_STRING2+IT_SPACE, NULL, "Alug", NULL, 17}, + {IT_STRING2+IT_SPACE, NULL, "Indev", NULL, 27}, + {IT_STRING2+IT_SPACE, NULL, "Haya", NULL, 37}, + {IT_STRING2+IT_SPACE, NULL, "Nepdisk", NULL, 47}, + {IT_STRING2+IT_SPACE, NULL, "GenericHeroGuy", NULL, 57}, + {IT_STRING2+IT_SPACE, NULL, "xyzzy", NULL, 67}, + {IT_STRING2+IT_SPACE, NULL, "Chearii", NULL, 77}, - {IT_STRING2+IT_SPACE, NULL, "Sunflower aka AnimeSonic", NULL, 90}, - {IT_STRING2+IT_SPACE, NULL, "Yuz aka Yuzler", NULL, 100}, - {IT_STRING2+IT_SPACE, NULL, "Democrab", NULL, 110}, - {IT_STRING2+IT_SPACE, NULL, "EXpand", NULL, 120}, - {IT_STRING2+IT_SPACE, NULL, "Nexit", NULL, 130}, - {IT_STRING2+IT_SPACE, NULL, "Spee", NULL, 140}, - {IT_STRING2+IT_SPACE, NULL, "Jin", NULL, 150}, - {IT_STRING2+IT_SPACE, NULL, "chromaticpipe", NULL, 160}, - {IT_STRING2+IT_SPACE, NULL, "Achii", NULL, 170}, - {IT_STRING2+IT_SPACE, NULL, "Anonimus", NULL, 180}, - {IT_STRING2+IT_SPACE, NULL, "scizor300", NULL, 190}, + {IT_STRING2+IT_SPACE, NULL, "Sunflower aka AnimeSonic", NULL, 87}, + {IT_STRING2+IT_SPACE, NULL, "Yuz aka Yuzler", NULL, 97}, + {IT_STRING2+IT_SPACE, NULL, "Democrab", NULL, 107}, + {IT_STRING2+IT_SPACE, NULL, "EXpand", NULL, 117}, + {IT_STRING2+IT_SPACE, NULL, "Nexit", NULL, 127}, + {IT_STRING2+IT_SPACE, NULL, "Spee", NULL, 137}, + {IT_STRING2+IT_SPACE, NULL, "Jin", NULL, 147}, + {IT_STRING2+IT_SPACE, NULL, "riomccloud", NULL, 157}, + {IT_STRING2+IT_SPACE, NULL, "chromaticpipe", NULL, 167}, + {IT_STRING2+IT_SPACE, NULL, "Achii", NULL, 177}, + {IT_STRING2+IT_SPACE, NULL, "Anonimus", NULL, 187}, + {IT_STRING2+IT_SPACE, NULL, "scizor300", NULL, 197}, - {IT_HEADER, NULL, "Special Thanks <3", NULL, 163}, + {IT_HEADER, NULL, "Special Thanks <3", NULL, 167}, - {IT_STRING2+IT_SPACE, NULL, "All of Sunflower's Garden", NULL, 173}, - {IT_STRING2+IT_SPACE, NULL, "The Moe Mansion and Birdhouse Team", NULL, 183}, - {IT_STRING2+IT_SPACE, NULL, "Galactice for Galaxy", NULL, 193}, + {IT_STRING2+IT_SPACE, NULL, "All of Sunflower's Garden", NULL, 177}, + {IT_STRING2+IT_SPACE, NULL, "The Moe Mansion and Birdhouse Team", NULL, 187}, + {IT_STRING2+IT_SPACE, NULL, "Galactice for Galaxy", NULL, 197}, - {IT_STRING+IT_SPACE, NULL, "", NULL, 203}, // dummy text I - {IT_STRING, NULL, "", NULL, 263}, // dummy text II + {IT_STRING+IT_SPACE, NULL, "", NULL, 207}, // dummy text I + {IT_STRING, NULL, "", NULL, 267}, // dummy text II }; // sry we dont have space for this anymore :/ @@ -3283,7 +3284,7 @@ menu_t OP_PlayerDistortDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_PlayerDistortMenu, menu_t OP_HudOffsetDef = DEFAULTSCROLLSTYLE(NULL, OP_HudOffsetMenu, &OP_SaturnHudDef, 30, 30); menu_t OP_SaturnHudDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnHudMenu, &OP_SaturnDef, 30, 30); -menu_t OP_SaturnCreditsDef = DEFAULTMENUSTYLE(NULL, OP_SaturnCreditsMenu, &OP_SaturnDef, 30, 3); +menu_t OP_SaturnCreditsDef = DEFAULTMENUSTYLE(NULL, OP_SaturnCreditsMenu, &OP_SaturnDef, 30, 0); menu_t OP_BirdDef = DEFAULTMENUSTYLE(NULL, OP_BirdMenu, &OP_MainDef, 30, 30); @@ -4618,7 +4619,7 @@ void M_StartControlPanel(void) { MPauseMenu[mpause_switchmap].status = IT_STRING | IT_CALL; MPauseMenu[mpause_addons].status = IT_STRING | IT_CALL; - + if (G_GametypeHasTeams()) MPauseMenu[mpause_scramble].status = IT_STRING | IT_SUBMENU; } From a0739e59e4433b7e873280bcf3832a86442720f2 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 7 Apr 2025 15:07:50 +0100 Subject: [PATCH 158/350] oops this needs be initialized --- src/r_draw8.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_draw8.c b/src/r_draw8.c index 685810c80..d55663368 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -737,9 +737,9 @@ void R_DrawSpan_8 (void) uintptr_t xstep, ystep; register UINT32 bit; - UINT8 *restrict source; - UINT8 *restrict colormap; - UINT8 *restrict dest; + UINT8 *restrict source = ds_source; + UINT8 *restrict colormap = ds_colormap; + UINT8 *restrict dest = ylookup[ds_y] + columnofs[ds_x1]; const UINT8 *restrict deststop = screens[0] + vid.rowbytes * vid.height; register size_t count = (ds_x2 - ds_x1 + 1); From 2b6f5077856c674e586dc02a5e255a2e739f040b Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 7 Apr 2025 17:54:09 +0200 Subject: [PATCH 159/350] reuse pwidth --- src/r_things.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index ca9d570c0..a3d8b500f 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -865,6 +865,7 @@ static void R_DrawVisSprite(vissprite_t *vis) localcolfunc = (vis->vflip) ? R_DrawFlippedMaskedColumn : R_DrawMaskedColumn; lengthcol = SHORT(patch->height); + pwidth = SHORT(patch->width); // Split drawing loops for paper and non-paper to reduce conditional checks per sprite if (vis->scalestep) @@ -872,8 +873,6 @@ static void R_DrawVisSprite(vissprite_t *vis) fixed_t horzscale = FixedMul(vis->spritexscale, this_scale); fixed_t scalestep = FixedMul(vis->scalestep, vis->spriteyscale); - pwidth = SHORT(patch->width); - // Papersprite drawing loop for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, spryscale += scalestep) { @@ -897,9 +896,9 @@ static void R_DrawVisSprite(vissprite_t *vis) else { // Non-paper drawing loop - for (dc_x = vis->x1; dc_x <= vis->x2 && (frac>>FRACBITS) < patch->width; dc_x++, frac += vis->xiscale) + for (dc_x = vis->x1; dc_x <= vis->x2 && (frac>>FRACBITS) < pwidth; dc_x++, frac += vis->xiscale) { - texturecolumn = CLAMP(frac >> FRACBITS, 0, SHORT(patch->width) - 1); + texturecolumn = CLAMP(frac >> FRACBITS, 0, pwidth - 1); column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); localcolfunc (column); From bd9f436227561ecb9a83403bca4a928428c8ce02 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 7 Apr 2025 19:40:17 +0200 Subject: [PATCH 160/350] let item button also change skin grid sorting type --- src/m_menu.c | 49 ++++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 251eebf25..08394c2c9 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -11376,9 +11376,9 @@ static void M_DrawSetupMultiPlayerMenu(void) //this is a very shitty solution for checking if a sprite needs flipping //but it works - if ((sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe]) && (speenframe > 4)) { + if ((sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe]) && (speenframe > 4)) flags = V_FLIP; // This sprite is left/right flipped! - } + patch = W_CachePatchNum(sprframe->lumppat[speenframe], PU_CACHE); // draw box around guy @@ -11405,9 +11405,10 @@ static void M_DrawSetupMultiPlayerMenu(void) // Handle 1P/2P MP Setup static void M_HandleSetupMultiPlayer(INT32 choice) { - boolean exitmenu = false; // exit to previous menu and send name change + boolean exitmenu = false; // exit to previous menu and send name change + const boolean gridselect = (cv_skinselectmenu.value == SKINMENUTYPE_GRID || cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED); // menus with "grids" - if ((choice == gamecontrol[gc_fire][0] || choice == gamecontrol[gc_fire][1]) && itemOn == 2) + if ((choice == gamecontrol[gc_fire][0] || choice == gamecontrol[gc_fire][1]) && (itemOn == 2 || (gridselect && itemOn == 1))) choice = KEY_BACKSPACE; // Hack to allow resetting prefcolor on controllers #define BREAKWHENLOCKED {\ @@ -11432,7 +11433,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) S_StartSound(NULL,sfx_menu1); // Tails break; } - else if (cv_skinselectmenu.value == SKINMENUTYPE_GRID || cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED) //grid skin select menu + else if (gridselect) //grid skin select menu { if (itemOn == 1) //if we are on the skin select menu { @@ -11440,11 +11441,13 @@ static void M_HandleSetupMultiPlayer(INT32 choice) { setupm_skinselect += SKINGRIDWIDTH; - if (cv_skinselectmenu.value == SKINMENUTYPE_GRID){ + if (cv_skinselectmenu.value == SKINMENUTYPE_GRID) + { if (setupm_skinselect >= ((setupm_skinypos-1)+SKINGRIDHEIGHT)*8 && setupm_skinypos < (ROUNDSKINSUPTO8/8)-SKINGRIDHEIGHT) setupm_skinypos++; } - else if (cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED){ + else if (cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED) + { if (setupm_skinselect >= ((setupm_skinypos-1)+SKINGRIDHEIGHT)*8+24 && setupm_skinypos < (ROUNDSKINSUPTO8/8)-SKINGRIDHEIGHT+24) setupm_skinypos++; } @@ -11486,13 +11489,14 @@ static void M_HandleSetupMultiPlayer(INT32 choice) S_StartSound(NULL,sfx_menu1); // Tails break; } - else if (cv_skinselectmenu.value == SKINMENUTYPE_GRID || cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED) + else if (gridselect) { if (itemOn == 1) { if (setupm_skinselect >= SKINGRIDWIDTH) //if we arent at the top of the menu { setupm_skinselect -= SKINGRIDWIDTH; + if (setupm_skinselect < ((setupm_skinypos+1)*SKINGRIDWIDTH) && setupm_skinypos > 0) setupm_skinypos--; } @@ -11505,14 +11509,15 @@ static void M_HandleSetupMultiPlayer(INT32 choice) else if (itemOn == 2) { setupm_skinselect = numskins - 1; - if (cv_skinselectmenu.value == SKINMENUTYPE_GRID){ + if (cv_skinselectmenu.value == SKINMENUTYPE_GRID) + { setupm_skinypos = (((numskins / SKINGRIDWIDTH) - (SKINGRIDHEIGHT-1)) > 0 ? ((numskins / SKINGRIDWIDTH) - (SKINGRIDHEIGHT-1)) : 0); M_PrevOpt(); } - else if (cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED){ - setupm_skinypos = (((numskins / SKINGRIDWIDTH) - (SKINGRIDHEIGHT-1)-2) > 0 ? ((numskins / SKINGRIDWIDTH) - (SKINGRIDHEIGHT-1)-2) : 0); - M_PrevOpt(); - + else if (cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED) + { + setupm_skinypos = (((numskins / SKINGRIDWIDTH) - (SKINGRIDHEIGHT-1)-2) > 0 ? ((numskins / SKINGRIDWIDTH) - (SKINGRIDHEIGHT-1)-2) : 0); + M_PrevOpt(); } } @@ -11544,6 +11549,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) else //player skin { S_StartSound(NULL,sfx_menu1); // Tails + if (setupm_skinxpos > 0) setupm_skinxpos--; else @@ -11551,11 +11557,12 @@ static void M_HandleSetupMultiPlayer(INT32 choice) } break; } - else if ((cv_skinselectmenu.value == SKINMENUTYPE_GRID || cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED) && itemOn == 1) + else if (gridselect && itemOn == 1) { if (setupm_skinselect > 0) { setupm_skinselect--; + if (setupm_skinselect < ((setupm_skinypos+1)*SKINGRIDWIDTH) && setupm_skinypos > 0) setupm_skinypos--; } @@ -11563,6 +11570,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) { INT32 roundedskins = ROUNDSKINSUPTO8; setupm_skinselect = roundedskins-1; + if (cv_skinselectmenu.value == SKINMENUTYPE_GRID) setupm_skinypos = (((roundedskins/8) - SKINGRIDHEIGHT) > 0 ? (roundedskins/8) - SKINGRIDHEIGHT : 0); else if (cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED) @@ -11610,16 +11618,19 @@ static void M_HandleSetupMultiPlayer(INT32 choice) } break; } - else if ((cv_skinselectmenu.value == SKINMENUTYPE_GRID || cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED) && itemOn == 1) + else if (gridselect && itemOn == 1) { if (setupm_skinselect < ROUNDSKINSUPTO8 - 1) { setupm_skinselect++; - if (cv_skinselectmenu.value == SKINMENUTYPE_GRID){ + + if (cv_skinselectmenu.value == SKINMENUTYPE_GRID) + { if (setupm_skinselect >= ((setupm_skinypos-1)+SKINGRIDHEIGHT)*8 && setupm_skinypos < (ROUNDSKINSUPTO8/8)-SKINGRIDHEIGHT) setupm_skinypos++; } - else if (cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED){ + else if (cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED) + { if (setupm_skinselect >= ((setupm_skinypos-1)+SKINGRIDHEIGHT)*8+24 && setupm_skinypos < (ROUNDSKINSUPTO8/8)-SKINGRIDHEIGHT+24) setupm_skinypos++; } @@ -11662,7 +11673,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) M_TextInputHandle(&setupm_input, choice); S_StartSound(NULL,sfx_menu1); // Tails } - else if ((cv_skinselectmenu.value == SKINMENUTYPE_GRID || cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED) && itemOn == 1) + else if (gridselect && itemOn == 1) { // change sort for select menu (damn now i have to add another cvar...) // now we have the cvar @@ -11717,7 +11728,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) S_StartSound(NULL,sfx_menu1); } } - else if ((cv_skinselectmenu.value == SKINMENUTYPE_GRID || cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED ) && itemOn == 1 && setupm_skinselect < numskins) + else if (gridselect && itemOn == 1 && setupm_skinselect < numskins) { setupm_fakeskin = skinsorted[setupm_skinselect]; S_StartSound(NULL, sfx_s221); From 29462b082ba7599bfbafa9e7ec48b74fa121050f Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 9 Apr 2025 22:44:23 +0200 Subject: [PATCH 161/350] remove unused variables from FTransform struct --- src/hardware/hw_defs.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index b554776a7..43e320fc0 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -128,7 +128,6 @@ typedef struct { FLOAT x,y,z; // position FLOAT anglex, angley, anglez; // aimingangle / viewangle - FLOAT anglex2, anglez2; // secondaries FLOAT scalex, scaley, scalez; FLOAT fovangle; UINT8 splitscreen; @@ -311,7 +310,7 @@ enum hwdsetspecialstate HWD_SET_TEXTUREFILTERMODE, HWD_SET_TEXTUREANISOTROPICMODE, - + HWD_SET_MSAA, HWD_SET_SCREEN_TEXTURES, From 92f08de1f6dd418df21104e7157792da59b09f15 Mon Sep 17 00:00:00 2001 From: Chearii Date: Wed, 9 Apr 2025 16:51:45 -0400 Subject: [PATCH 162/350] Dial speedometer --- src/d_main.c | 31 +++++- src/d_main.h | 2 + src/k_kart.c | 283 ++++++++++++++++++++++++++++++++++++++++++++++----- src/k_kart.h | 2 +- src/m_menu.c | 2 +- 5 files changed, 288 insertions(+), 32 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 71541c2cc..b7fafe53c 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1208,6 +1208,8 @@ boolean xtra_speedo3 = false; // 80x 11 extra speedometer check boolean xtra_speedo_clr3 = false; // 80x 11 extra speedometer colour check boolean achi_speedo = false; // achiiro speedometer check boolean achi_speedo_clr = false; // extra speedometer colour check +boolean dial_speedo = false; // dial speedometer check +boolean dial_speedo_clr = false; // dial speedometer colour check boolean kartz_speedo = false; // kartZ speedo boolean kartz_speedo_smol = false; // kartZ speedo but smol @@ -1337,7 +1339,7 @@ static inline void D_MakeTitleString(char *s) static void D_CheckSaturnExtraFiles(void) { // Possible value that changes depending on whether required files for speedometer are found or not - CV_PossibleValue_t speedo_cons_temp[NUMSPEEDOSTUFF] = {{1, "Default"}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}}; + CV_PossibleValue_t speedo_cons_temp[NUMSPEEDOSTUFF] = {{1, "Default"}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}}; CV_PossibleValue_t driftgaugestyle_cons_temp[NUMDGAUGESTUFF] = {{1, "Default"}, {2, "Small"}, {3, "Big Numbers"}, {4, "Numbers Only"}, {0, NULL}, {0, NULL}}; CV_PossibleValue_t inputdisplay_cons_temp[NUMINPUTDISPLAYSTUFF] = {{0, "Off"}, {1, "Wheel"}, {2, "Stick"}, {0, NULL}, {0, NULL}}; @@ -1365,6 +1367,17 @@ static void D_CheckSaturnExtraFiles(void) PUSHCONS(speedo_cons_temp, last_speedo_i, 3, "Achii"); } + // now check for dial speedometer stuff + if (W_CheckMultipleLumps("K_DSPBS1", "K_DSPBS2", "K_DSDIAL", + "K_TRNULL", "SP_DKMH", "SP_DMPH", "SP_DFRAC", "SP_DPERC", + "K_DSPNM0", "K_DSPNM1", "K_DSPNM2", "K_DSPNM3", "K_DSPNM4", + "K_DSPNM5", "K_DSPNM6", "K_DSPNM7", "K_DSPNM8", "K_DSPNM9", + "RANKFIN", NULL)) + { + dial_speedo = true; + PUSHCONS(speedo_cons_temp, last_speedo_i, 4, "Dial"); + } + // check for bigger lap count if (W_CheckMultipleLumps("K_STLAPB", "K_STLA2B", NULL)) { @@ -1378,7 +1391,7 @@ static void D_CheckSaturnExtraFiles(void) "K_KZSP20", "K_KZSP21", "K_KZSP22", "K_KZSP23", "K_KZSP24", "K_KZSP25", NULL)) { kartz_speedo = true; - PUSHCONS(speedo_cons_temp, last_speedo_i, 4, "P-Meter"); + PUSHCONS(speedo_cons_temp, last_speedo_i, 5, "P-Meter"); } if (W_CheckMultipleLumps("K_KZSS1", "K_KZSS2", "K_KZSS3", "K_KZSS4", "K_KZSS5", @@ -1387,7 +1400,7 @@ static void D_CheckSaturnExtraFiles(void) "K_KZSS20", "K_KZSS21", "K_KZSS22", "K_KZSS23", "K_KZSS24", "K_KZSS25", NULL)) { kartz_speedo_smol = true; - PUSHCONS(speedo_cons_temp, last_speedo_i, 5, "P-Meter Small"); + PUSHCONS(speedo_cons_temp, last_speedo_i, 6, "P-Meter Small"); } // stat display for extended player setup @@ -1447,6 +1460,16 @@ static void D_CheckSaturnExtraFiles(void) achi_speedo_clr = true; } + // dial speedo but colour + if (W_CheckMultipleLumps("K_DSPBC1", "K_DSPBC2", "K_DSDIAL", + "K_TRNULL", "SC_DKMH", "SC_DMPH", "SC_DFRAC", "SC_DPERC", + "K_DSPNC0", "K_DSPNC1", "K_DSPNC2", "K_DSPNC3", "K_DSPNC4", + "K_DSPNC5", "K_DSPNC6", "K_DSPNC7", "K_DSPNC8", "K_DSPNC9", + "RANKFIN", NULL)) + { + dial_speedo_clr = true; + } + // driftgauge but colour if (W_CheckMultipleLumps("K_DCAU","K_DCSU", NULL)) { @@ -1470,7 +1493,7 @@ static void D_CheckSaturnExtraFiles(void) if (W_LumpExists("SP_SM3TC")) { xtra_speedo3 = true; - PUSHCONS(speedo_cons_temp, last_speedo_i, 6, "Extra"); + PUSHCONS(speedo_cons_temp, last_speedo_i, 7, "Extra"); PUSHCONS(driftgaugestyle_cons_temp, last_driftgauge_i, 5, "Extra"); } diff --git a/src/d_main.h b/src/d_main.h index 84c19e6e5..41ccce20f 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -38,6 +38,8 @@ extern boolean xtra_speedo3; // 80x11 extra speedometer check extern boolean xtra_speedo_clr3; // 80x11 extra speedometer colour check extern boolean achi_speedo; // achiiro speedometer check extern boolean achi_speedo_clr; // extra speedometer colour check +extern boolean dial_speedo; // dial speedometer check +extern boolean dial_speedo_clr; // dial speedometer colour check extern boolean kartz_speedo; // kartZ speedo extern boolean kartz_speedo_smol; // kartZ speedo but smol diff --git a/src/k_kart.c b/src/k_kart.c index 35d3699aa..1bf23661c 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -747,6 +747,7 @@ enum SPEEDO_VANILLA, SPEEDO_EXTRA, SPEEDO_ACHII, + SPEEDO_DIAL, SPEEDO_PMETER, SPEEDO_PMETERSMOL, SPEEDO_EXTRA3, @@ -758,11 +759,13 @@ static UINT8 K_GetSpeedometerStyle(void) return SPEEDO_EXTRA; else if (cv_newspeedometer.value == 3 && achi_speedo) return SPEEDO_ACHII; - else if (cv_newspeedometer.value == 4 && kartz_speedo) + else if (cv_newspeedometer.value == 4 && dial_speedo) + return SPEEDO_DIAL; + else if (cv_newspeedometer.value == 5 && kartz_speedo) return SPEEDO_PMETER; - else if (cv_newspeedometer.value == 5 && kartz_speedo_smol) + else if (cv_newspeedometer.value == 6 && kartz_speedo_smol) return SPEEDO_PMETERSMOL; - else if (cv_newspeedometer.value == 6 && xtra_speedo3) + else if (cv_newspeedometer.value == 7 && xtra_speedo3) return SPEEDO_EXTRA3; else return SPEEDO_VANILLA; @@ -7558,6 +7561,16 @@ static patch_t *skp_speedpatchesachi[5]; static patch_t *skp_smallstickerachiclr; static patch_t *skp_speedpatchesachiclr[5]; +// dial speedometer +static patch_t *skp_rankfinish; +static patch_t *skp_dialbase[2]; +static patch_t *skp_speedpatchesdial[5]; +static patch_t *skp_dialnum[10]; +//static patch_t *skp_dialclr; +static patch_t *skp_dialbaseclr[2]; +static patch_t *skp_speedpatchesdialclr[5]; +static patch_t *skp_dialnumclr[10]; + static patch_t *joybacking; static patch_t *joyknob; static patch_t *joyshadow; @@ -7608,6 +7621,26 @@ void K_LoadKartHUDGraphics(void) skp_speedpatchesachi[4] = W_CachePatchName("SP_APERC", PU_HUDGFX); } + if (dial_speedo) + { + skp_rankfinish = W_CachePatchName("RANKFIN", PU_HUDGFX); + skp_dialbase[0] = W_CachePatchName("K_DSPBS1", PU_HUDGFX); + skp_dialbase[1] = W_CachePatchName("K_DSPBS2", PU_HUDGFX); + + skp_speedpatchesdial[0] = W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd + skp_speedpatchesdial[1] = W_CachePatchName("SP_DKMH", PU_HUDGFX); + skp_speedpatchesdial[2] = W_CachePatchName("SP_DMPH", PU_HUDGFX); + skp_speedpatchesdial[3] = W_CachePatchName("SP_DFRAC", PU_HUDGFX); + skp_speedpatchesdial[4] = W_CachePatchName("SP_DPERC", PU_HUDGFX); + + sprintf(buffer, "K_DSPNMx"); + for (i = 0; i < 10; i++) + { + buffer[7] = '0'+(i%10); + skp_dialnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + } + } + if (big_lap) { kp_lapstickerbig = W_CachePatchName("K_STLAPB", PU_HUDGFX); @@ -7655,6 +7688,25 @@ void K_LoadKartHUDGraphics(void) skp_speedpatchesachiclr[4] = W_CachePatchName("SC_APERC", PU_HUDGFX); } + if (dial_speedo && dial_speedo_clr) + { + skp_dialbaseclr[0] = W_CachePatchName("K_DSPBC1", PU_HUDGFX); + skp_dialbaseclr[1] = W_CachePatchName("K_DSPBC2", PU_HUDGFX); + + skp_speedpatchesdialclr[0] = W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd + skp_speedpatchesdialclr[1] = W_CachePatchName("SC_DKMH", PU_HUDGFX); + skp_speedpatchesdialclr[2] = W_CachePatchName("SC_DMPH", PU_HUDGFX); + skp_speedpatchesdialclr[3] = W_CachePatchName("SC_DFRAC", PU_HUDGFX); + skp_speedpatchesdialclr[4] = W_CachePatchName("SC_DPERC", PU_HUDGFX); + + sprintf(buffer, "K_DSPNCx"); + for (i = 0; i < 10; i++) + { + buffer[7] = '0'+(i%10); + skp_dialnumclr[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + } + } + // KartZ speedo if (kartz_speedo) { @@ -8301,12 +8353,14 @@ patch_t *K_getItemMulPatch(boolean small) static void K_drawKartStats(void) { - INT32 x, y, spdoffset, flags; + INT32 x, y, spdxoffset, spdoffset, flags; // For 1-player display x = 15; y = 150; + spdxoffset = 0; spdoffset = 0; + flags = V_SNAPTOBOTTOM|V_SNAPTOLEFT; UINT8 splitnum = 0; @@ -8321,29 +8375,38 @@ static void K_drawKartStats(void) return; //Internal offset for speedometer - if (cv_kartspeedometer.value) - { - const UINT8 speedostyle = K_GetSpeedometerStyle(); + const UINT8 speedostyle = K_GetSpeedometerStyle(); + + if (cv_kartspeedometer.value && (!splitscreen)) + { if ((speedostyle == SPEEDO_EXTRA) || (speedostyle == SPEEDO_ACHII) || (speedostyle == SPEEDO_EXTRA3)) spdoffset = -10; + else if (speedostyle == SPEEDO_DIAL) + { + spdxoffset = 11; + spdoffset = 14; + } else spdoffset = -14; } else spdoffset = 0; + if (speedostyle != SPEEDO_DIAL) + spdoffset += (G_BattleGametype() ? (stplyr->kartstuff[k_bumper] ? -5 : -8) : 0); + // Customizations c: if (!splitscreen) { - x += 18 + cv_stat_xoffset.value; - y += cv_stat_yoffset.value + (G_BattleGametype() ? (stplyr->kartstuff[k_bumper] ? -5 : -8) : 0) + spdoffset; + x += 18 + cv_stat_xoffset.value + spdxoffset; + y += cv_stat_yoffset.value + spdoffset; } else if (splitscreen == 1) // I tried my best, but this is still mess :/ < :Blobcatpats: c: { x -= 10; y -= 40; - y += (G_BattleGametype() ? (stplyr->kartstuff[k_bumper] ? -5 : -8) : 0); + y += spdoffset; // If we are in 2-player splitscreen, for player 1 we move hud to up and remove snapping // to bottom @@ -9383,13 +9446,163 @@ static void K_drawKartLaps(void) } } +#ifdef ROTSPRITE + +#define DIALSPDDIV 97090 // 1.48148; converts 200 to 135 + +static void K_DrawDialNum(INT32 x, INT32 y, boolean colorized, INT32 flags, INT32 num, INT32 digits, const UINT8 *colormap) +{ + INT32 w; + + if (colorized) + w = SHORT(skp_dialnumclr[0]->width); + else + w = SHORT(skp_dialnum[0]->width); + + if (flags & V_NOSCALESTART) + w *= vid.dupx; + + if (num < 0) + num = -num; + + // draw the number + do + { + x -= (w); + + if (colorized) + V_DrawFixedPatch(x << FRACBITS, y << FRACBITS, FRACUNIT, flags, skp_dialnumclr[num % 10], colormap); + else + V_DrawFixedPatch(x << FRACBITS, y << FRACBITS, FRACUNIT, flags, skp_dialnum[num % 10], colormap); + + num /= 10; + } while (--digits); +} + +static void K_DrawDialLaps(INT32 x, INT32 y, INT32 num, INT32 total, INT32 flags) +{ + INT32 fx; + fx = x + ((num < 10) ? 0 : 6); + V_DrawRankNum(fx, y, flags, num, (num < 10) ? 1 : 2, NULL); + V_DrawScaledPatch(fx + 2, y, flags, frameslash); + V_DrawRankNum(fx + 13 + ((total < 10) ? 0 : 6), y, flags, total, (total < 10) ? 1 : 2, NULL); +} + +static void K_DrawDialSpeedometer(fixed_t speed, + INT32 splitflags, + boolean battlemode, + boolean infoactive, + boolean colorized) +{ + UINT8* colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + + INT32 rot = 0; + UINT8 infoidx = (infoactive) ? 1 : 0; + patch_t* dialpatch; + + angle_t speedangle = + FixedAngle(((FixedDiv(min(200 * FRACUNIT, speed), DIALSPDDIV) - (45 * FRACUNIT)))); + + rot = R_GetRollAngle(speedangle); + + if (rot) + { + dialpatch = W_CachePatchNameRotated("K_DSDIAL", rot, PU_STATIC); + } + else + { + dialpatch = W_CachePatchName("K_DSDIAL", PU_STATIC); + } + + if (colorized) // Colourized hud + { + V_DrawMappedPatch( + SPDM_X, SPDM_Y - 9, (V_HUDTRANS | splitflags), skp_dialbaseclr[infoidx], colormap); + V_DrawMappedPatch(SPDM_X, + SPDM_Y + 30, + V_HUDTRANS | splitflags, + skp_speedpatchesdialclr[cv_kartspeedometer.value], + colormap); + } + else + { + V_DrawScaledPatch(SPDM_X, SPDM_Y - 9, (V_HUDTRANS | splitflags), skp_dialbase[infoidx]); + V_DrawScaledPatch(SPDM_X, + SPDM_Y + 30, + V_HUDTRANS | splitflags, + skp_speedpatchesdial[cv_kartspeedometer.value]); + } + + K_DrawDialNum(SPDM_X + 10, + SPDM_Y + 25, + colorized, + V_HUDTRANS | splitflags, + speed / FRACUNIT, + 3, + colormap); + + // gotta center the dial manually + V_DrawMappedPatch(SPDM_X - 19, SPDM_Y + 15, (V_HUDTRANS | splitflags), (dialpatch), colormap); + + if (!infoactive) + { + // no need to draw info if we're not supposed to + return; + } + + // draw the info + if (battlemode) + { + if (stplyr->kartstuff[k_bumper] <= 0) + { + V_DrawMappedPatch( + SPDM_X + 28, SPDM_Y + 27, V_HUDTRANS | splitflags, kp_splitkarmabomb, colormap); + K_DrawDialLaps(SPDM_X + 46, + SPDM_Y + 29, + stplyr->kartstuff[k_comebackpoints], + 2, + V_HUDTRANS | splitflags); + } + else // the above doesn't need to account for weird stuff since the max amount of karma + // necessary is always 2 ^^^^ + { + V_DrawMappedPatch( + SPDM_X + 28, SPDM_Y + 27, V_HUDTRANS | splitflags, kp_rankbumper, colormap); + K_DrawDialLaps(SPDM_X + 46, + SPDM_Y + 29, + stplyr->kartstuff[k_bumper], + cv_kartbumpers.value, + V_HUDTRANS | splitflags); + } + } + else + { + V_DrawScaledPatch(SPDM_X + 28, SPDM_Y + 27, V_HUDTRANS | splitflags, kp_splitlapflag); + + if (stplyr->exiting) + V_DrawScaledPatch(SPDM_X + 39, SPDM_Y + 29, V_HUDTRANS | splitflags, skp_rankfinish); + else + K_DrawDialLaps(SPDM_X + 46, + SPDM_Y + 29, + stplyr->laps + 1, + cv_numlaps.value, + V_HUDTRANS | splitflags); + } +} + +#undef DIALSPDDIV + +#endif + static void K_drawKartSpeedometer(void) { // why? if (cv_kartspeedometer.value == 0) return; - fixed_t convSpeed = 0; + // index 0 is the raw value, index 1 is the converted value + fixed_t convSpeed[2] = {0,0}; + INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); // man. @@ -9398,17 +9611,23 @@ static void K_drawKartSpeedometer(void) switch (cv_kartspeedometer.value) { case 1: - convSpeed = FixedDiv(FixedMul(stplyr->speed, 142371), mapobjectscale)/FRACUNIT; // 2.172409058 + convSpeed[0] = FixedDiv(FixedMul(stplyr->speed, 142371), mapobjectscale); // 2.172409058 + convSpeed[1] = convSpeed[0] / FRACUNIT; break; case 2: - convSpeed = FixedDiv(FixedMul(stplyr->speed, 88465), mapobjectscale)/FRACUNIT; // 1.349868774 + convSpeed[0] = FixedDiv(FixedMul(stplyr->speed, 88465), mapobjectscale); // 1.349868774 + convSpeed[1] = convSpeed[0] / FRACUNIT; break; case 3: - convSpeed = FixedDiv(stplyr->speed, mapobjectscale)/FRACUNIT; + convSpeed[0] = FixedDiv(stplyr->speed, mapobjectscale); + convSpeed[1] = convSpeed[0] / FRACUNIT; break; case 4: if (stplyr->mo) - convSpeed = (FixedDiv(stplyr->speed, FixedMul(K_GetKartSpeed(stplyr, false), ORIG_FRICTION))*100)>>FRACBITS; + { + convSpeed[0] = (FixedDiv(stplyr->speed, FixedMul(K_GetKartSpeed(stplyr, false), ORIG_FRICTION))*100); + convSpeed[1] = convSpeed[0] >> FRACBITS; + } break; default: break; @@ -9421,20 +9640,20 @@ static void K_drawKartSpeedometer(void) switch (cv_kartspeedometer.value) { case 1: - metric = va("%3d km/h", convSpeed); + metric = va("%3d km/h", convSpeed[1]); break; case 2: - metric = va("%3d mph", convSpeed); + metric = va("%3d mph", convSpeed[1]); break; case 3: - metric = va("%3d fu/t", convSpeed); + metric = va("%3d fu/t", convSpeed[1]); break; case 4: // if extra.kart is found, use its included % symbol if (!xtra_speedo) - metric = va("%4d P", convSpeed); + metric = va("%4d P", convSpeed[1]); else - metric = va("%4d %%", convSpeed); + metric = va("%4d %%", convSpeed[1]); break; default: break; @@ -9452,7 +9671,7 @@ static void K_drawKartSpeedometer(void) else V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, (V_HUDTRANS|splitflags), (skp_smallsticker)); - V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed, 3, NULL); + V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatches[cv_kartspeedometer.value]); } else if (speedostyle == SPEEDO_ACHII) // why bother if we dont? @@ -9461,16 +9680,26 @@ static void K_drawKartSpeedometer(void) { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); V_DrawMappedPatch(SPDM_X + 1, SPDM_Y + 4, (V_HUDTRANS|splitflags), (skp_smallstickerachiclr), colormap); - V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed, 3, NULL); + V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); V_DrawMappedPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatchesachiclr[cv_kartspeedometer.value], colormap); } else { V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, (V_HUDTRANS|splitflags), (skp_smallstickerachi)); - V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed, 3, NULL); + V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatchesachi[cv_kartspeedometer.value]); } } +#ifdef ROTSPRITE + else if (speedostyle == SPEEDO_DIAL) // why bother if we dont? + { + K_DrawDialSpeedometer(convSpeed[0], + splitflags, + (boolean)(G_BattleGametype()), + (LUA_HudEnabled(hud_gametypeinfo)), + (boolean)(K_UseColorHud() && dial_speedo_clr)); + } +#endif else if (speedostyle == SPEEDO_EXTRA3) // why bother if we dont? { if (K_UseColorHud() && xtra_speedo_clr3) //Colourized hud @@ -9481,7 +9710,7 @@ static void K_drawKartSpeedometer(void) else V_DrawStretchyFixedPatch((SPDM_X-1)<exiting || (stplyr->kartstuff[k_bumper] <= 0 @@ -11324,7 +11555,7 @@ void K_drawKartHUD(void) else if (G_RaceGametype()) // Race-only elements { // Draw the lap counter - if (LUA_HudEnabled(hud_gametypeinfo)) + if ((LUA_HudEnabled(hud_gametypeinfo)) && ((!cv_kartspeedometer.value) || (speedostyle != SPEEDO_DIAL))) K_drawKartLaps(); if (!splitscreen) @@ -11347,7 +11578,7 @@ void K_drawKartHUD(void) else if (G_BattleGametype()) // Battle-only { // Draw the hits left! - if (LUA_HudEnabled(hud_gametypeinfo)) + if ((LUA_HudEnabled(hud_gametypeinfo)) && ((!cv_battlespeedo.value) || (speedostyle != SPEEDO_DIAL))) K_drawKartBumpersOrKarma(); if ((!splitscreen) && cv_battlespeedo.value) diff --git a/src/k_kart.h b/src/k_kart.h index be97e93a7..c0c99961d 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -40,7 +40,7 @@ extern consvar_t cv_battlespeedo; extern consvar_t cv_multiitemicon; extern consvar_t cv_huditemamount; -#define NUMSPEEDOSTUFF 7 +#define NUMSPEEDOSTUFF 8 extern CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; #define NUMDGAUGESTUFF 6 extern CV_PossibleValue_t driftgaugestyle_cons_t[NUMDGAUGESTUFF]; diff --git a/src/m_menu.c b/src/m_menu.c index 08394c2c9..e42b7b679 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4925,7 +4925,7 @@ void M_Init(void) } #endif - if (!xtra_speedo && !kartz_speedo && !achi_speedo) // why bother? + if (!xtra_speedo && !kartz_speedo && !achi_speedo && !dial_speedo) // why bother? OP_SaturnHudMenu[sh_speedometer].status = IT_GRAYEDOUT; //if (!xtra_speedo && kartz_speedo) From ff6a13f042b71220bb592c6a01de8a4776680e1f Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 9 Apr 2025 23:18:31 +0200 Subject: [PATCH 163/350] simplify those --- src/hardware/hw_main.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index ef4ea1afb..b15e1bbd9 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4473,16 +4473,16 @@ static void HWR_AddSprites(sector_t *sec) // Well, now it will be done. sec->validcount = validcount; + limit_dist = cv_drawdist.value; + if (current_bsp_culling_distance) { // Use the smaller setting - if (cv_drawdist.value) - limit_dist = min(current_bsp_culling_distance/mapobjectscale, cv_drawdist.value); + if (limit_dist) + limit_dist = min(current_bsp_culling_distance/mapobjectscale, limit_dist); else limit_dist = current_bsp_culling_distance/mapobjectscale; } - else - limit_dist = cv_drawdist.value; // Handle all things in sector. for (thing = sec->thinglist; thing; thing = thing->snext) @@ -4516,13 +4516,7 @@ static void HWR_AddPrecipitationSprites(void) return; } - const fixed_t precipscale = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); - //const fixed_t drawdist = cv_drawdist_precip.value * mapobjectscale; - - if (current_bsp_culling_distance) - drawdist = min((fixed_t)current_bsp_culling_distance, (fixed_t)(cv_drawdist_precip.value) * precipscale); - else - drawdist = ((fixed_t)(cv_drawdist_precip.value) * precipscale); + drawdist = ((fixed_t)(cv_drawdist_precip.value) * (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT)); // No to infinite precipitation draw distance. if (drawdist == 0) @@ -4530,6 +4524,9 @@ static void HWR_AddPrecipitationSprites(void) return; } + if (current_bsp_culling_distance) + drawdist = min((fixed_t)current_bsp_culling_distance, drawdist); + R_GetRenderBlockMapDimensions(drawdist, &xl, &xh, &yl, &yh); for (bx = xl; bx <= xh; bx++) From 90475c11285b57c22871a2984c4a04eef8470292 Mon Sep 17 00:00:00 2001 From: Chearii Date: Thu, 10 Apr 2025 01:08:15 -0400 Subject: [PATCH 164/350] Adjust dial rotation for MPH and FU/T --- src/k_kart.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 1bf23661c..43c50889e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9449,6 +9449,7 @@ static void K_drawKartLaps(void) #ifdef ROTSPRITE #define DIALSPDDIV 97090 // 1.48148; converts 200 to 135 +#define MPHDIV 68283 // 1.04192; converts 141 to 135 static void K_DrawDialNum(INT32 x, INT32 y, boolean colorized, INT32 flags, INT32 num, INT32 digits, const UINT8 *colormap) { @@ -9489,6 +9490,7 @@ static void K_DrawDialLaps(INT32 x, INT32 y, INT32 num, INT32 total, INT32 flags } static void K_DrawDialSpeedometer(fixed_t speed, + fixed_t divisor, INT32 splitflags, boolean battlemode, boolean infoactive, @@ -9501,7 +9503,7 @@ static void K_DrawDialSpeedometer(fixed_t speed, patch_t* dialpatch; angle_t speedangle = - FixedAngle(((FixedDiv(min(200 * FRACUNIT, speed), DIALSPDDIV) - (45 * FRACUNIT)))); + FixedAngle(((min(135 * FRACUNIT, FixedDiv(speed, divisor)) - (45 * FRACUNIT)))); rot = R_GetRollAngle(speedangle); @@ -9590,8 +9592,6 @@ static void K_DrawDialSpeedometer(fixed_t speed, } } -#undef DIALSPDDIV - #endif static void K_drawKartSpeedometer(void) @@ -9602,6 +9602,7 @@ static void K_drawKartSpeedometer(void) // index 0 is the raw value, index 1 is the converted value fixed_t convSpeed[2] = {0,0}; + fixed_t dial_divisor = DIALSPDDIV; INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); @@ -9617,10 +9618,12 @@ static void K_drawKartSpeedometer(void) case 2: convSpeed[0] = FixedDiv(FixedMul(stplyr->speed, 88465), mapobjectscale); // 1.349868774 convSpeed[1] = convSpeed[0] / FRACUNIT; + dial_divisor = MPHDIV; break; case 3: convSpeed[0] = FixedDiv(stplyr->speed, mapobjectscale); convSpeed[1] = convSpeed[0] / FRACUNIT; + dial_divisor = MPHDIV; break; case 4: if (stplyr->mo) @@ -9694,6 +9697,7 @@ static void K_drawKartSpeedometer(void) else if (speedostyle == SPEEDO_DIAL) // why bother if we dont? { K_DrawDialSpeedometer(convSpeed[0], + dial_divisor, splitflags, (boolean)(G_BattleGametype()), (LUA_HudEnabled(hud_gametypeinfo)), @@ -9751,6 +9755,11 @@ static void K_drawKartSpeedometer(void) } } +#ifdef ROTSPRITE +#undef DIALSPDDIV +#undef MPHDIV +#endif + static void K_drawKartBumpersOrKarma(void) { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); From bc228301365d1a1f3e049abff675f31e9c6a0f7b Mon Sep 17 00:00:00 2001 From: Chearii Date: Thu, 10 Apr 2025 01:59:59 -0400 Subject: [PATCH 165/350] Fix up several HUD issues ughhhh splitscreeeeeen --- src/k_kart.c | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 43c50889e..cfeb3bee7 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8393,7 +8393,7 @@ static void K_drawKartStats(void) else spdoffset = 0; - if (speedostyle != SPEEDO_DIAL) + if ((speedostyle != SPEEDO_DIAL) || (splitscreen)) spdoffset += (G_BattleGametype() ? (stplyr->kartstuff[k_bumper] ? -5 : -8) : 0); // Customizations c: @@ -11412,11 +11412,45 @@ static void K_drawCheckpointDebugger(void) V_DrawString(8, 192, 0, va("Waypoint dist: Prev %d, Next %d", stplyr->kartstuff[k_prevcheck], stplyr->kartstuff[k_nextcheck])); } +// determines if gametype info (laps/bumpers) should be hidden +static boolean K_DisableGametypeInfo(void) +{ + if (!LUA_HudEnabled(hud_gametypeinfo)) + { + return true; + } + +#ifdef ROTSPRITE + if (splitscreen || (!cv_kartspeedometer.value)) + { + // don't need to run checks if we're in splitscreen, or not using the speedometer + return false; + } + + const UINT8 speedostyle = K_GetSpeedometerStyle(); + + if (G_RaceGametype()) + { + if (speedostyle == SPEEDO_DIAL) + return true; + } + else if (G_BattleGametype()) + { + if ((cv_battlespeedo.value) && (speedostyle == SPEEDO_DIAL)) + return true; + } +#endif + + return false; +} + + void K_drawKartHUD(void) { boolean isfreeplay = false; boolean battlefullscreen = false; boolean freecam = camera[stplyrnum].freecam; //disable some hud elements w/ freecam + boolean gameinfovisible = false; // Define the X and Y for each drawn object // This is handled by console/menu values @@ -11433,8 +11467,6 @@ void K_drawKartHUD(void) return; } - const UINT8 speedostyle = K_GetSpeedometerStyle(); - battlefullscreen = ((G_BattleGametype()) && (stplyr->exiting || (stplyr->kartstuff[k_bumper] <= 0 @@ -11524,6 +11556,9 @@ void K_drawKartHUD(void) if (!stplyr->spectator && !freecam) // Bottom of the screen elements, don't need in spectate mode { + // get gametype info visibility ahead of time + gameinfovisible = (!K_DisableGametypeInfo()); + if (!(splitscreen || demo.title)) { if (LUA_HudEnabled(hud_inputdisplay)) @@ -11564,7 +11599,7 @@ void K_drawKartHUD(void) else if (G_RaceGametype()) // Race-only elements { // Draw the lap counter - if ((LUA_HudEnabled(hud_gametypeinfo)) && ((!cv_kartspeedometer.value) || (speedostyle != SPEEDO_DIAL))) + if (gameinfovisible) K_drawKartLaps(); if (!splitscreen) @@ -11587,7 +11622,7 @@ void K_drawKartHUD(void) else if (G_BattleGametype()) // Battle-only { // Draw the hits left! - if ((LUA_HudEnabled(hud_gametypeinfo)) && ((!cv_battlespeedo.value) || (speedostyle != SPEEDO_DIAL))) + if (gameinfovisible) K_drawKartBumpersOrKarma(); if ((!splitscreen) && cv_battlespeedo.value) From 5b3edc21310b1e110b0411c8ce8630ecfd70b9e5 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 10 Apr 2025 21:16:15 +0200 Subject: [PATCH 166/350] handle highres portraits and statdisplay text more gracefully on low resolutions below 640x400 the highres portraits become an absolute mess so itll now fallback to the lowres portraits the statdisplay name text also became completely unreadable so itll use V_DrawThinString instead on low resolutions --- src/hu_stuff.c | 40 ++++++++++++++++-------------------- src/k_kart.c | 55 ++++++++++++++++++++++++++++++++------------------ src/k_kart.h | 1 + src/y_inter.c | 10 ++++----- 4 files changed, 58 insertions(+), 48 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index e41badda9..4192c5811 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -169,7 +169,7 @@ char french_shiftxform[] = 31, ' ','$', //shift-! '3', //shift-" - '#', '$', '%', + '#', '$', '%', '1', //shift-& '4', // shift-' '5', // shift-( @@ -179,7 +179,7 @@ char french_shiftxform[] = '6', // shift-- '.', '/', '0', '1', '2', '3', '4', '5', - '6', '7', '8', '9', + '6', '7', '8', '9', '/', // shitf-: '.', // shift-; '>', // shift-< @@ -222,7 +222,7 @@ char french_altgrxform[] = '|', //altg-- '.', '/', '0', '1', '2', '3', '4', '5', - '6', '7', '8', '9', + '6', '7', '8', '9', ':', ';', '<', '}', //altgr-= '>', '?', '@', @@ -1140,7 +1140,7 @@ void HU_Ticker(void) } if (cechotimer > 0) --cechotimer; - + // Animate the desynch dots if (hu_resynching #ifdef SATURNPAK @@ -2434,7 +2434,7 @@ void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags) if (measureid == 1) V_DrawScaledPatch(x+11 - pingmeasure[measureid]->width, y+9, flags, pingmeasure[measureid]); - + if (cv_pingicon.value) V_DrawScaledPatch(x+2, y, flags, pinggfx[gfxnum]); @@ -2563,24 +2563,19 @@ static inline void HU_DrawSpectatorTicker(void) if (cv_showspecstuff.value) { - if (players[i].mo) + player_t *player; + player = &players[i]; + + if (player->mo && player->mo->color) { - player_t *p; - p = &players[i]; + const UINT8 *colormap = R_GetTranslationColormap(player->skin, player->mo->color, GTC_CACHE); + if (player->mo->colorized) + colormap = R_GetTranslationColormap(TC_RAINBOW, player->mo->color, GTC_CACHE); - if (players[i].mo->color) - { - const UINT8 *colormap; - if (players[i].mo->colorized) - colormap = R_GetTranslationColormap(TC_RAINBOW, players[i].mo->color, GTC_CACHE); - else - colormap = R_GetTranslationColormap(players[i].skin, players[i].mo->color, GTC_CACHE); - - if (cv_highresportrait.value) - V_DrawSmallMappedPatch((templength - duptweak), height+10, V_TRANSLUCENT, R_GetSkinFaceWant(p), colormap); - else - V_DrawMappedPatch((templength - duptweak), height+10, V_TRANSLUCENT, R_GetSkinFaceRank(p), colormap); - } + if (K_UseHighResPortraits()) + V_DrawSmallMappedPatch((templength - duptweak), height+10, V_TRANSLUCENT, R_GetSkinFaceWant(player), colormap); + else + V_DrawMappedPatch((templength - duptweak), height+10, V_TRANSLUCENT, R_GetSkinFaceRank(player), colormap); } if ((netgame && i != serverplayer) || (cv_mindelay.value && P_IsLocalPlayer(&players[i]))) @@ -2595,7 +2590,6 @@ static inline void HU_DrawSpectatorTicker(void) } } - // // HU_DrawRankings // @@ -2781,7 +2775,7 @@ void HU_DoCEcho(const char *msg) { if (!cv_cechotoggle.value) return - + I_OutputMsg("%s\n", msg); // print to log #pragma GCC diagnostic push diff --git a/src/k_kart.c b/src/k_kart.c index 35d3699aa..248c7235d 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -768,6 +768,16 @@ static UINT8 K_GetSpeedometerStyle(void) return SPEEDO_VANILLA; } +static boolean K_IsHighResolution(void) +{ + return (vid.width >= 640 && vid.height >= 400); +} + +boolean K_UseHighResPortraits(void) +{ + return (cv_highresportrait.value && K_IsHighResolution()); +} + //} //{ SRB2kart Net Variables @@ -8392,10 +8402,17 @@ static void K_drawKartStats(void) if (!splitscreen) { // Skin name - V_DrawSmallString(x+20, y+12, flags|V_ALLOWLOWERCASE|V_SkinColorToHighlightcolor(stplyr->skincolor), fakeskin->realname); + if (K_IsHighResolution()) // V_DrawSmallString becomes a mess at low resolutions lel + { + V_DrawSmallString(x+20, y+12, flags|V_ALLOWLOWERCASE|V_SkinColorToHighlightcolor(stplyr->skincolor), fakeskin->realname); + } + else + { + V_DrawThinString(x+20, y+7, flags|V_ALLOWLOWERCASE|V_SkinColorToHighlightcolor(stplyr->skincolor), fakeskin->realname); + } // Icon and stats - if (cv_highresportrait.value) + if (K_UseHighResPortraits()) V_DrawSmallMappedPatch(x, y, flags, R_GetSkinFaceWant(stplyr), R_GetLocalTranslationColormap(fakeskin, fakeskin, stplyr->skincolor, GTC_CACHE, stplyr->skinlocal)); else V_DrawMappedPatch(x, y, flags, R_GetSkinFaceRank(stplyr), R_GetLocalTranslationColormap(fakeskin, fakeskin, stplyr->skincolor, GTC_CACHE, stplyr->skinlocal)); @@ -9148,39 +9165,37 @@ static boolean K_drawKartPositionFaces(void) for (; i < ranklines; i++) { + player_t *player; + player = &players[rankplayer[i]]; + if (!playeringame[rankplayer[i]]) continue; - if (players[rankplayer[i]].spectator) + if (player->spectator) continue; - if (!players[rankplayer[i]].mo) + if (!player->mo) continue; - const UINT8 mocolor = players[rankplayer[i]].mo->color; + const UINT8 mocolor = player->mo->color; bumperx = FACE_X+19; if (mocolor) { - player_t *p; - - colormap = R_GetTranslationColormap(players[rankplayer[i]].skin, mocolor, GTC_CACHE); - - if (players[rankplayer[i]].mo->colorized) + colormap = R_GetTranslationColormap(player->skin, mocolor, GTC_CACHE); + if (player->mo->colorized) colormap = R_GetTranslationColormap(TC_RAINBOW, mocolor, GTC_CACHE); - p = &players[rankplayer[i]]; - - if (cv_highresportrait.value) - V_DrawSmallMappedPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, R_GetSkinFaceWant(p), colormap); + if (K_UseHighResPortraits()) + V_DrawSmallMappedPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, R_GetSkinFaceWant(player), colormap); else - V_DrawMappedPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, R_GetSkinFaceRank(p), colormap); + V_DrawMappedPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, R_GetSkinFaceRank(player), colormap); if (LUA_HudEnabled(hud_battlebumpers)) { - if (G_BattleGametype() && players[rankplayer[i]].kartstuff[k_bumper] > 0) + if (G_BattleGametype() && player->kartstuff[k_bumper] > 0) { V_DrawMappedPatch(bumperx-2, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_tinybumper[0], colormap); - for (j = 1; j < players[rankplayer[i]].kartstuff[k_bumper]; j++) + for (j = 1; j < player->kartstuff[k_bumper]; j++) { bumperx += 5; V_DrawMappedPatch(bumperx, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_tinybumper[1], colormap); @@ -9192,11 +9207,11 @@ static boolean K_drawKartPositionFaces(void) if (i == strank) V_DrawScaledPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_facehighlight[(leveltime / 4) % 8]); - if (G_BattleGametype() && players[rankplayer[i]].kartstuff[k_bumper] <= 0) + if (G_BattleGametype() && player->kartstuff[k_bumper] <= 0) V_DrawScaledPatch(FACE_X-4, Y-3, V_HUDTRANS|V_SNAPTOLEFT, kp_ranknobumpers); else { - INT32 pos = players[rankplayer[i]].kartstuff[k_position]; + INT32 pos = player->kartstuff[k_position]; if (pos < 0 || pos > MAXPLAYERS) pos = 0; // Draws the little number over the face @@ -9262,7 +9277,7 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I else colormap = R_GetTranslationColormap(player->skin, player->mo->color, GTC_CACHE); - if (cv_highresportrait.value) + if (K_UseHighResPortraits()) V_DrawSmallMappedPatch(x, y-4, 0, R_GetSkinFaceWant(player), colormap); else V_DrawMappedPatch(x, y-4, 0, R_GetSkinFaceRank(player), colormap); diff --git a/src/k_kart.h b/src/k_kart.h index be97e93a7..b92facbf8 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -20,6 +20,7 @@ void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color, bo UINT8 K_GetKartColorByName(const char *name); UINT8 K_GetHudColor(void); boolean K_UseColorHud(void); +boolean K_UseHighResPortraits(void); void K_RegisterServerKartStuff(void); void K_RegisterClientKartStuff(void); diff --git a/src/y_inter.c b/src/y_inter.c index 2ea913927..01611e568 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -412,11 +412,11 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) patch_t *faceprefix = NULL; if (!player->skinlocal) - faceprefix = (cv_highresportrait.value ? facewantprefix[skinnum] : facerankprefix[skinnum]); + faceprefix = (K_UseHighResPortraits() ? facewantprefix[skinnum] : facerankprefix[skinnum]); else - faceprefix = (cv_highresportrait.value ? localfacewantprefix[skinnum] : localfacerankprefix[skinnum]); + faceprefix = (K_UseHighResPortraits() ? localfacewantprefix[skinnum] : localfacerankprefix[skinnum]); - if (cv_highresportrait.value) + if (K_UseHighResPortraits()) V_DrawSmallMappedPatch(x + 16, y - 4, 0, faceprefix, colormap); else V_DrawMappedPatch(x + 16, y - 4, 0, faceprefix, colormap); @@ -513,7 +513,7 @@ void Y_IntermissionDrawer(void) return; if (cv_betainterscreen.value == 1 -#ifdef HWRENDER +#ifdef HWRENDER || (rendermode == render_opengl && cv_glscreentextures.value != 2) // use the neato kart bg for intermission on disabled screen textures #endif ) @@ -1178,7 +1178,7 @@ void Y_VoteDrawer(void) if (players[i].skincolor) { UINT8 *colormap = R_GetTranslationColormap(players[i].skin, players[i].skincolor, GTC_CACHE); - if (cv_highresportrait.value) + if (K_UseHighResPortraits()) V_DrawSmallMappedPatch(x+24, y+9, V_SNAPTOLEFT, (players[i].skinlocal ? localfacewantprefix : facewantprefix)[((players[i].localskin) ? players[i].localskin-1 : players[i].skin)], colormap); else V_DrawMappedPatch(x+24, y+9, V_SNAPTOLEFT, (players[i].skinlocal ? localfacerankprefix : facerankprefix)[((players[i].localskin) ? players[i].localskin-1 : players[i].skin)], colormap); From 1ddc663e8c132574fd9ce73857fd229cde36f2c7 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 10 Apr 2025 22:01:44 +0200 Subject: [PATCH 167/350] add setting for cecho toggle to print to console instead idk i hate doing string stuff, hope this doesent explode lmao also ensures even if disabled all cecho stuff is printed to log file again --- src/g_game.c | 3 ++- src/hu_stuff.c | 25 ++++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 2cb8a93bc..3cbe4bfb8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -517,7 +517,8 @@ consvar_t cv_ydeadzone[MAXSPLITSCREENPLAYERS] = { static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}}; consvar_t cv_driftsparkpulse = {"driftsparkpulse", "1.4", CV_FLOAT | CV_SAVE, driftsparkpulse_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cechotoggle = {"show_cecho", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t cechotoggle_t[] = {{0, "Off"}, {1, "On"}, {2, "Console"}, {0, NULL}}; +consvar_t cv_cechotoggle = {"show_cecho", "On", CV_SAVE, cechotoggle_t, NULL, 0, NULL, NULL, 0, 0, NULL}; #if MAXPLAYERS > 16 #error "please update player_name table using the new value for MAXPLAYERS" diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 4192c5811..268059d06 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2773,16 +2773,31 @@ void HU_SetCEchoFlags(INT32 flags) void HU_DoCEcho(const char *msg) { - if (!cv_cechotoggle.value) - return - - I_OutputMsg("%s\n", msg); // print to log - #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-truncation" // This is fine, we set null byte later strncpy(cechotext, msg, sizeof(cechotext)); #pragma GCC diagnostic pop strncat(cechotext, "\\", sizeof(cechotext) - strlen(cechotext) - 1); cechotext[sizeof(cechotext) - 1] = '\0'; + + // just print it to console + if (cv_cechotoggle.value == 2) + { + char temp[1024]; + strncpy(temp, cechotext, sizeof(temp)); + + for (char *p = temp; *p != '\0'; ++p) + if (*p == '\\') + *p = '\n'; + + CONS_Printf("%s\n", temp); + return; + } + + I_OutputMsg("%s\n", msg); // print to log + + if (!cv_cechotoggle.value) + return; + cechotimer = cechoduration; } From 1ebebb5690086a6ebc888ff1af521a256b44451c Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 05:00:07 +0200 Subject: [PATCH 168/350] extract the date out of replay + display em in replay hut this is kinda horrid, but essentially, the number at the start of replay names is actually the time when the replay was recorded, so i can extract that and convert it to a readable format this probably can be done alot cleaner lmao --- src/d_main.c | 3 ++ src/d_netcmd.c | 29 ++++++++++++-------- src/g_game.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/g_game.h | 1 + src/m_menu.c | 16 +++++++++-- 5 files changed, 110 insertions(+), 13 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 71541c2cc..49da3bb01 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1487,6 +1487,8 @@ static void D_CheckSaturnExtraFiles(void) memcpy(inputdisplay_cons_t, inputdisplay_cons_temp, sizeof(inputdisplay_cons_t)); } +#include + // // D_SRB2Main // @@ -1684,6 +1686,7 @@ void D_SRB2Main(void) CONS_Printf("I_InitializeTime()...\n"); I_InitializeTime(); + setlocale(LC_TIME, ""); // Make backups of some SOCcable tables. P_BackupTables(); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 3f7641af8..9e7190c81 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -954,7 +954,7 @@ void D_RegisterClientCommands(void) COM_AddCommand("displayplayer", Command_Displayplayer_f); - CV_RegisterVar(&cv_audbuffersize); + CV_RegisterVar(&cv_audbuffersize); // m_menu.c CV_RegisterVar(&cv_chatheight); @@ -965,10 +965,10 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_chatnotifications); CV_RegisterVar(&cv_chatbacktint); CV_RegisterVar(&cv_songcredits); - CV_RegisterVar(&cv_showfreeplay); + CV_RegisterVar(&cv_showfreeplay); CV_RegisterVar(&cv_skinselectspin); CV_RegisterVar(&cv_showallmaps); - + CV_RegisterVar(&cv_growmusic); CV_RegisterVar(&cv_supermusic); @@ -1054,7 +1054,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_midimusicvolume); #endif CV_RegisterVar(&cv_numChannels); - + #ifdef HAVE_OPENMPT CV_RegisterVar(&cv_modfilter); CV_RegisterVar(&cv_stereosep); @@ -3074,18 +3074,25 @@ static void Command_ReplayMarker(void) CONS_Printf(M_GetText("You must be in a level to use this.\n")); return; } - if (demo.savemode == DSM_WILLAUTOSAVE) { + if (demo.savemode == DSM_WILLAUTOSAVE) + { demo.savemode = DSM_NOTSAVING; CONS_Printf("Replay unmarked.\n"); - } else { - int adjustedleveltime = leveltime - starttime; + } + else + { demo.savemode = DSM_WILLAUTOSAVE; + + int adjustedleveltime = leveltime - starttime; + if (adjustedleveltime < 0) adjustedleveltime = 0; + char *title = G_BuildMapTitle(gamemap); snprintf(demo.titlename, 64, "%s [%i:%02d/%.5s]", title, G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); if (title) Z_Free(title); + CONS_Printf("Replay will be saved!\n"); } } @@ -4545,7 +4552,7 @@ Command_Addskins (void) /* if (fasticmp(COM_Argv(2), "-force") || fasticmp(COM_Argv(2), "-f")) { CONS_Alert(CONS_NOTICE, M_GetText("Adding file %s. May or may not be a skin.\n"), COM_Argv(1)); - P_AddWadFile(COM_Argv(1), 0, true); + P_AddWadFile(COM_Argv(1), 0, true); } else { if (DumbStartsWith("KC_", COM_Argv(1))) { P_AddWadFile(COM_Argv(1), 0, true); @@ -4625,7 +4632,7 @@ static void Command_GLocalSkin (void) { int i; - for (i = 0; i < MAXPLAYERS; ++i) + for (i = 0; i < MAXPLAYERS; ++i) { if (!playeringame[i]) continue; @@ -6012,7 +6019,7 @@ static void Command_ListSkins(void) } static void Command_SkinSearch(void) -{ +{ size_t i; UINT16 s; UINT16 ic = 0; @@ -6022,7 +6029,7 @@ static void Command_SkinSearch(void) { skin_t *skininput = &skins[s]; if (strcasestr(skininput->realname,COM_Argv(i))) - { + { ic++; CONS_Printf("%d. %s%s:\x80 %s\n", ic,HU_SkinColorToConsoleColor(skininput->prefcolor),skininput->realname,skininput->name); } diff --git a/src/g_game.c b/src/g_game.c index 3cbe4bfb8..3dbba7d51 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6794,6 +6794,71 @@ void G_LoadDemoInfo(menudemo_t *pdemo) Z_Free(infobuffer); } +#include +#include + +static char *G_GetDemoDate(menudemo_t *pdemo) +{ + char *datetime; + datetime = malloc(sizeof(pdemo->date)); // mallocma balls + + // no mallocma balls... :c + if (!datetime) + { + free(datetime); + return NULL; + } + + // get the actual filename Zzz... + const char *filename; + + filename = strrchr(pdemo->filepath, '/'); + if (!filename) + filename = strrchr(pdemo->filepath, '\\'); + + if (!filename) + { + free(datetime); + return NULL; + } + + filename = filename + 1; // filename, filename, filename, filename..... + + // get only the first 10 characters (time before conversion) + char timestr[10]; + strncpy(timestr , filename, 10); + + // convert it to long Zzz.... + long longtime = 0; + longtime = strtol(timestr, NULL, 10); + + // then throw it into localtime to get an actual human readable format lmao + struct tm tm_buf; + time_t demo_date = 0; + + demo_date = longtime; + localtime_r(&demo_date, &tm_buf); + + // cant believe we ended up in 1970 + if (tm_buf.tm_year == 70) + { + free(datetime); + return NULL; + } + + const char *format; + + // US ppl are special (: + if (strstr(setlocale(LC_TIME, NULL), "en_US")) + format = "%m.%d.%Y"; + else + format = "%d.%m.%Y"; + + strftime(datetime, sizeof(pdemo->date), format, &tm_buf); + + return datetime; +} + void G_LoadDemoTitle(menudemo_t *pdemo) { UINT8 infobuffer[96], *info_p; @@ -6827,11 +6892,20 @@ void G_LoadDemoTitle(menudemo_t *pdemo) READUINT8(info_p); pdemoversion = READUINT16(info_p); + memset(pdemo->date, 0, sizeof(pdemo->date)); + switch(pdemoversion) { case DEMOVERSION: // latest always supported // demo title M_Memcpy(pdemo->title, info_p, 64); + + // demo date + char *demodate; + demodate = G_GetDemoDate(pdemo); + if (demodate) + strncpy(pdemo->date, demodate, sizeof(pdemo->date)); + free(demodate); break; #ifdef DEMO_COMPAT_100 case 0x0001: diff --git a/src/g_game.h b/src/g_game.h index 39b266b5a..aa89a6368 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -83,6 +83,7 @@ typedef struct menudemo_s { menudemotype_e type; char title[65]; // Null-terminated for string prints + char date[11]; // date when replay was recorded UINT16 map; UINT8 addonstatus; // What do we need to do addon-wise to play this demo? UINT8 gametype; diff --git a/src/m_menu.c b/src/m_menu.c index 08394c2c9..098f55e29 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6826,7 +6826,15 @@ static void ReplayNamesLoadThread(void* userdata) for (size_t i = 0; i < demolist_all_size; ++i) { if (demolist_all_local[i].type != MD_SUBDIR) + { G_LoadDemoTitle(&demolist_all_local[i]); + + // this is fucking horrid, but i wanna be able to search for dates + /*if (demolist_all_local[i].date[0] != '\0') + { + snprintf(demolist_all_local[i].title, sizeof(demolist_all_local[i].title), "%s %s", demolist_all_local[i].title, demolist_all_local[i].date); + }*/ + } } Lock_search_state(); @@ -7236,8 +7244,12 @@ static void DrawReplayHutReplayInfo(void) else V_DrawString(x, y, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT, "Level is not loaded."); - if (demolist[dir_on[menudepthleft]].numlaps) - V_DrawThinString(x, y+9, V_SNAPTOTOP|V_ALLOWLOWERCASE, va("(%d laps)", demolist[dir_on[menudepthleft]].numlaps)); + //if (demolist[dir_on[menudepthleft]].numlaps) + //V_DrawThinString(x, y+9, V_SNAPTOTOP|V_ALLOWLOWERCASE, va("(%d laps)", demolist[dir_on[menudepthleft]].numlaps)); + + // not the final place for this + if (demolist[dir_on[menudepthleft]].date[0] != '\0') + V_DrawThinString(x, y+9, V_SNAPTOTOP|V_ALLOWLOWERCASE, va("%s", demolist[dir_on[menudepthleft]].date)); V_DrawString(x, y+20, V_SNAPTOTOP|V_ALLOWLOWERCASE, demolist[dir_on[menudepthleft]].gametype == GT_RACE ? va("Race (%s speed)", kartspeed_cons_t[demolist[dir_on[menudepthleft]].kartspeed & ~DF_ENCORE].strvalue) : From f1bcdaf68feec85d086e107b8a921765ad2a0b05 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 05:07:18 +0200 Subject: [PATCH 169/350] do pathseperator check like this --- src/g_game.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 3dbba7d51..d4195dedc 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6797,6 +6797,12 @@ void G_LoadDemoInfo(menudemo_t *pdemo) #include #include +#if defined (_WIN32) +#define PATHSEPSTR '\\' +#else +#define PATHSEPSTR '/' +#endif + static char *G_GetDemoDate(menudemo_t *pdemo) { char *datetime; @@ -6812,9 +6818,7 @@ static char *G_GetDemoDate(menudemo_t *pdemo) // get the actual filename Zzz... const char *filename; - filename = strrchr(pdemo->filepath, '/'); - if (!filename) - filename = strrchr(pdemo->filepath, '\\'); + filename = strrchr(pdemo->filepath, PATHSEPSTR); if (!filename) { @@ -6858,6 +6862,7 @@ static char *G_GetDemoDate(menudemo_t *pdemo) return datetime; } +#undef PATHSEPSTR void G_LoadDemoTitle(menudemo_t *pdemo) { From b7542a2106341806f5e93efcde90be67c1b1fb11 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 11:51:58 +0200 Subject: [PATCH 170/350] try to catch more bad demo dates i mean this game did not exist in 2010 lmao but occasionally it actually returned dates other than 1970 depending on what was passed to it lmao --- src/g_game.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index d4195dedc..2d9452ba1 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6815,6 +6815,8 @@ static char *G_GetDemoDate(menudemo_t *pdemo) return NULL; } + time_t file_time = 0; + // get the actual filename Zzz... const char *filename; @@ -6833,18 +6835,14 @@ static char *G_GetDemoDate(menudemo_t *pdemo) strncpy(timestr , filename, 10); // convert it to long Zzz.... - long longtime = 0; - longtime = strtol(timestr, NULL, 10); + file_time = strtol(timestr, NULL, 10); // then throw it into localtime to get an actual human readable format lmao struct tm tm_buf; - time_t demo_date = 0; - - demo_date = longtime; - localtime_r(&demo_date, &tm_buf); + localtime_r(&file_time, &tm_buf); // cant believe we ended up in 1970 - if (tm_buf.tm_year == 70) + if (tm_buf.tm_year <= 110) { free(datetime); return NULL; From 2201d58f7de1d939f9b6ea8900e000577bd300c3 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 12:35:14 +0200 Subject: [PATCH 171/350] try and get file creation time in some cases on windoze builds untested as of right now --- src/g_game.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 2d9452ba1..754182e6e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6799,6 +6799,17 @@ void G_LoadDemoInfo(menudemo_t *pdemo) #if defined (_WIN32) #define PATHSEPSTR '\\' +// return the file creation time +// useful for demos that were renamed +static long G_GetCreationTime(char *filepath) +{ + struct stat fileinfo; + + if (stat(filepath, &fileinfo) == 0) + return fileinfo.st_ctime; + + return 0; +} #else #define PATHSEPSTR '/' #endif @@ -6811,7 +6822,6 @@ static char *G_GetDemoDate(menudemo_t *pdemo) // no mallocma balls... :c if (!datetime) { - free(datetime); return NULL; } @@ -6822,11 +6832,20 @@ static char *G_GetDemoDate(menudemo_t *pdemo) filename = strrchr(pdemo->filepath, PATHSEPSTR); +#if defined (_WIN32) + if (!filename) + { + // if we cant get a filename try just getting the file create time + file_time = G_GetCreationTime(pdemo->filepath); + goto skipfilenametime; + } +#else if (!filename) { free(datetime); return NULL; } +#endif filename = filename + 1; // filename, filename, filename, filename..... @@ -6837,6 +6856,10 @@ static char *G_GetDemoDate(menudemo_t *pdemo) // convert it to long Zzz.... file_time = strtol(timestr, NULL, 10); +#if defined (_WIN32) +skipfilenametime: +#endif + // then throw it into localtime to get an actual human readable format lmao struct tm tm_buf; localtime_r(&file_time, &tm_buf); @@ -6844,10 +6867,29 @@ static char *G_GetDemoDate(menudemo_t *pdemo) // cant believe we ended up in 1970 if (tm_buf.tm_year <= 110) { +#if defined (_WIN32) + // uh ohh, we got an invalid time + // try one more time getting the creation time + file_time = G_GetCreationTime(pdemo->filepath); + localtime_r(&file_time, &tm_buf); + + if (tm_buf.tm_year <= 110) + { + free(datetime); + return NULL; + } + else + goto gotcreationtime; +#else free(datetime); return NULL; +#endif } +#if defined (_WIN32) +gotcreationtime: +#endif + const char *format; // US ppl are special (: From 02c1a9a58ded214102d79d2b846826600d36eba6 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 13:03:57 +0200 Subject: [PATCH 172/350] apparently we have "nameonly" ty indev <3 --- src/g_game.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 754182e6e..7887bb434 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6798,7 +6798,6 @@ void G_LoadDemoInfo(menudemo_t *pdemo) #include #if defined (_WIN32) -#define PATHSEPSTR '\\' // return the file creation time // useful for demos that were renamed static long G_GetCreationTime(char *filepath) @@ -6810,8 +6809,6 @@ static long G_GetCreationTime(char *filepath) return 0; } -#else -#define PATHSEPSTR '/' #endif static char *G_GetDemoDate(menudemo_t *pdemo) @@ -6827,10 +6824,9 @@ static char *G_GetDemoDate(menudemo_t *pdemo) time_t file_time = 0; - // get the actual filename Zzz... - const char *filename; - - filename = strrchr(pdemo->filepath, PATHSEPSTR); + // get le filepath + char *filename; + filename = strdup(pdemo->filepath); #if defined (_WIN32) if (!filename) @@ -6847,11 +6843,13 @@ static char *G_GetDemoDate(menudemo_t *pdemo) } #endif - filename = filename + 1; // filename, filename, filename, filename..... + // get the actual filename Zzz... + nameonly(filename); // get only the first 10 characters (time before conversion) char timestr[10]; strncpy(timestr , filename, 10); + free(filename); // dont need this anymore a // convert it to long Zzz.... file_time = strtol(timestr, NULL, 10); From e8c6dca8c167189455612b623d31b09aba7544a8 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 13:07:14 +0200 Subject: [PATCH 173/350] dont need le strncpy --- src/g_game.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 7887bb434..b1963a7ab 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6846,13 +6846,9 @@ static char *G_GetDemoDate(menudemo_t *pdemo) // get the actual filename Zzz... nameonly(filename); - // get only the first 10 characters (time before conversion) - char timestr[10]; - strncpy(timestr , filename, 10); - free(filename); // dont need this anymore a - // convert it to long Zzz.... - file_time = strtol(timestr, NULL, 10); + file_time = strtol(filename, NULL, 10); + free(filename); // dont need this anymore a #if defined (_WIN32) skipfilenametime: From 9c25d99156899604b44b2c3a6d7bf998c313fa4e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 13:47:05 +0200 Subject: [PATCH 174/350] print demo version on "outdated" demos idk if this is fine lel --- src/g_game.c | 3 +++ src/g_game.h | 1 + src/m_menu.c | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index b1963a7ab..e5355c324 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6653,6 +6653,9 @@ void G_LoadDemoInfo(menudemo_t *pdemo) subversion = READUINT8(info_p); pdemoversion = READUINT16(info_p); + memset(pdemo->version, 0, sizeof(pdemo->version)); + sprintf(pdemo->version, "v%d.%d", version, subversion); + switch(pdemoversion) { case DEMOVERSION: // latest always supported diff --git a/src/g_game.h b/src/g_game.h index aa89a6368..ddc4ff40e 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -84,6 +84,7 @@ typedef struct menudemo_s { char title[65]; // Null-terminated for string prints char date[11]; // date when replay was recorded + char version[6]; // combined version and subversion UINT16 map; UINT8 addonstatus; // What do we need to do addon-wise to play this demo? UINT8 gametype; diff --git a/src/m_menu.c b/src/m_menu.c index 098f55e29..1cf674f6f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7203,7 +7203,7 @@ static void DrawReplayHutReplayInfo(void) break; // Can't think of anything to draw here right now case MD_OUTDATED: - V_DrawThinString(17, 64, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT|highlightflags, "Recorded on an outdated version."); + V_DrawThinString(17, 64, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT|highlightflags, va("Recorded on an outdated version. %s", demolist[dir_on[menudepthleft]].version)); /*fallthru*/ default: // Draw level stuff From 3e60b1b388b09e7d34137ea174220375d6df7ba0 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 13:53:19 +0200 Subject: [PATCH 175/350] bigger buffer for demo version thing --- src/g_game.c | 2 +- src/g_game.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index e5355c324..edd6ed467 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6654,7 +6654,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo) pdemoversion = READUINT16(info_p); memset(pdemo->version, 0, sizeof(pdemo->version)); - sprintf(pdemo->version, "v%d.%d", version, subversion); + snprintf(pdemo->version, sizeof(pdemo->version), "v%d.%d", version, subversion); switch(pdemoversion) { diff --git a/src/g_game.h b/src/g_game.h index ddc4ff40e..39c5027da 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -84,7 +84,7 @@ typedef struct menudemo_s { char title[65]; // Null-terminated for string prints char date[11]; // date when replay was recorded - char version[6]; // combined version and subversion + char version[12]; // combined version and subversion UINT16 map; UINT8 addonstatus; // What do we need to do addon-wise to play this demo? UINT8 gametype; From 892a59ff154e283d6923693bfa61fb6231654611 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 14:18:10 +0200 Subject: [PATCH 176/350] add cvar to change the demo date formatting bruh --- src/d_netcmd.c | 2 ++ src/g_game.c | 9 +++++++-- src/g_game.h | 1 + src/m_menu.c | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 9e7190c81..9b68717db 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1093,6 +1093,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_verticallook[i]); } + CV_RegisterVar(&cv_demodateformat); + // ingame object placing COM_AddCommand("objectplace", Command_ObjectPlace_f); COM_AddCommand("writethings", Command_Writethings_f); diff --git a/src/g_game.c b/src/g_game.c index edd6ed467..363b4caa4 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -341,6 +341,9 @@ consvar_t cv_maxdemosize = {"maxdemosize", "10", CV_SAVE, maxdemosize_cons_t, NU static CV_PossibleValue_t demochangemap_cons_t[] = {{0, "Disabled"}, {1, "Diff Map"}, {2, "Always"}, {0, NULL}}; consvar_t cv_demochangemap = {"netdemo_savemapchange", "Disabled", CV_SAVE, demochangemap_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t demodateformat_cons_t[] = {{0, "Automatic"}, {1, "EU"}, {2, "US"}, {0, NULL}}; +consvar_t cv_demodateformat = {"netdemo_dateformat", "Automatic", CV_SAVE, demodateformat_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + // Analog Control void SendWeaponPref(void); void SendWeaponPref2(void); @@ -6890,10 +6893,12 @@ gotcreationtime: const char *format; // US ppl are special (: - if (strstr(setlocale(LC_TIME, NULL), "en_US")) + if (cv_demodateformat.value == 2) format = "%m.%d.%Y"; - else + else if (cv_demodateformat.value == 1) format = "%d.%m.%Y"; + else + format = strstr(setlocale(LC_TIME, NULL), "en_US") ? "%m.%d.%Y" : "%d.%m.%Y"; strftime(datetime, sizeof(pdemo->date), format, &tm_buf); diff --git a/src/g_game.h b/src/g_game.h index 39c5027da..e50557a9d 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -42,6 +42,7 @@ extern savebuffer_t demobuf; // demoplaying back and demo recording extern consvar_t cv_recordmultiplayerdemos, cv_netdemosyncquality, cv_maxdemosize, cv_demochangemap; +extern consvar_t cv_demodateformat; // Publicly-accessible demo vars struct demovars_s { diff --git a/src/m_menu.c b/src/m_menu.c index 1cf674f6f..0248dbaf1 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -647,6 +647,7 @@ static menuitem_t MISC_ReplayOptionsMenu[] = {IT_CVAR|IT_STRING, NULL, "Sync Check Interval", &cv_netdemosyncquality, 20}, {IT_CVAR|IT_STRING, NULL, "Max demo size (MiB)", &cv_maxdemosize, 30}, {IT_CVAR|IT_STRING, NULL, "Replay Search Rate", &cv_replaysearchrate, 40}, + {IT_CVAR|IT_STRING, NULL, "Replay Date Format", &cv_demodateformat, 50}, }; static tic_t playback_last_menu_interaction_leveltime = 0; From 804ca985f3e6ccdeffdaceadad6bdb1dadae90af Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 14:23:21 +0200 Subject: [PATCH 177/350] just make the numlaps draw besides the date idk theres no good place for this otherwise --- src/m_menu.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 0248dbaf1..32e28c888 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7245,12 +7245,16 @@ static void DrawReplayHutReplayInfo(void) else V_DrawString(x, y, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT, "Level is not loaded."); - //if (demolist[dir_on[menudepthleft]].numlaps) - //V_DrawThinString(x, y+9, V_SNAPTOTOP|V_ALLOWLOWERCASE, va("(%d laps)", demolist[dir_on[menudepthleft]].numlaps)); + INT32 datew = 0; - // not the final place for this if (demolist[dir_on[menudepthleft]].date[0] != '\0') + { + datew = V_StringWidth(demolist[dir_on[menudepthleft]].date, 0); V_DrawThinString(x, y+9, V_SNAPTOTOP|V_ALLOWLOWERCASE, va("%s", demolist[dir_on[menudepthleft]].date)); + } + + if (demolist[dir_on[menudepthleft]].numlaps) + V_DrawThinString(x+datew, y+9, V_SNAPTOTOP|V_ALLOWLOWERCASE, va("(%d laps)", demolist[dir_on[menudepthleft]].numlaps)); V_DrawString(x, y+20, V_SNAPTOTOP|V_ALLOWLOWERCASE, demolist[dir_on[menudepthleft]].gametype == GT_RACE ? va("Race (%s speed)", kartspeed_cons_t[demolist[dir_on[menudepthleft]].kartspeed & ~DF_ENCORE].strvalue) : From 705bb4a8ea019b94a006ab56c4de5f698d5123e7 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 16:53:52 +0200 Subject: [PATCH 178/350] dont need to do any of this lel the calloc takes care of those already --- src/p_saveg.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 394db050f..795d612a4 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1991,7 +1991,9 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) } mobj->type = i; } + mobj->info = &mobjinfo[mobj->type]; + if (diff & MD_POS) { mobj->x = READFIXED(save->p); @@ -2004,6 +2006,7 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) mobj->y = mobj->spawnpoint->y << FRACBITS; mobj->angle = FixedAngle(mobj->spawnpoint->angle*FRACUNIT); } + if (diff & MD_MOM) { mobj->momx = READFIXED(save->p); @@ -2135,33 +2138,10 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) mobj->colorized = READUINT8(save->p); //{ Saturn stuff, needs to be set, but shouldnt be synched - - // Sprite Rotation - mobj->rollangle = 0; - mobj->pitch = 0; - mobj->roll = 0; - mobj->sloperoll = 0; - mobj->slopepitch = 0; - mobj->pitch_sprite = 0; - mobj->roll_sprite = 0; - - // Horizontal flip - mobj->mirrored = 0; - // Sprite Rendering stuff mobj->blendmode = AST_TRANSLUCENT; - mobj->spritexoffset = mobj->realxoffset = 0; - mobj->spriteyoffset = mobj->realxoffset = 0; mobj->spritexscale = mobj->realxscale = FRACUNIT; mobj->spriteyscale = mobj->realyscale = FRACUNIT; - mobj->stretchslam = 0; - - // Timer for slam sound effect - mobj->slamsoundtimer = 0; - - // extra mobjlightlevel - mobj->lightlevel = 0; - //} if (diff & MD_REDFLAG) From 2959a84b74e096c5e9b25fb0fbb08d3e28dbed5e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 20:45:46 +0200 Subject: [PATCH 179/350] attempt at unmangling localskin stuff again moved almost all the weird ass ternaries into functions and should also probably fix some remaining issues where stuff was wrong --- src/hardware/hw_main.c | 12 +++--- src/hardware/hw_md2.c | 16 ++++---- src/k_kart.c | 85 +++++++++++++++++++++++++++++------------- src/lua_mobjlib.c | 22 +++++------ src/lua_playerlib.c | 2 +- src/lua_script.c | 1 + src/p_local.h | 1 - src/p_user.c | 29 +++++--------- src/r_draw.c | 10 ++--- src/r_things.c | 33 +++++++--------- src/r_things.h | 10 ++++- src/s_sound.c | 2 +- src/y_inter.c | 22 +++++------ 13 files changed, 136 insertions(+), 109 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index b15e1bbd9..93054e3f0 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3318,11 +3318,11 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, GLPatch_t *gpatch) float offset = 0; // technically this_scale gets multiplied and added to sprite y/x scale, but this thing needs it for some crap so ill just throw it in here again - const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->flags & SF_HIRES); + const boolean hires = (spr->mobj && spr->mobj->skin && K_GetMobjSkin(thing)->flags & SF_HIRES); if (spr->mobj) this_scale = FIXED_TO_FLOAT(spr->mobj->scale); if (hires) - this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->highresscale); + this_scale = this_scale * FIXED_TO_FLOAT(K_GetMobjSkin(thing)->highresscale); R_GetShadowZ(spr->mobj, &floorslope); @@ -4660,9 +4660,9 @@ static void HWR_ProjectSprite(mobj_t *thing) //Fab : 02-08-98: 'skin' override spritedef currently used for skin if ((thing->skin || thing->localskin) && thing->sprite == SPR_PLAY) { - sprdef = &((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->spritedef; + sprdef = &K_GetMobjSkin(thing)->spritedef; #ifdef ROTSPRITE - sprinfo = &((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->sprinfo; + sprinfo = &K_GetMobjSkin(thing)->sprinfo; #endif } else @@ -4741,8 +4741,8 @@ static void HWR_ProjectSprite(mobj_t *thing) flip ^= (1<skin && ((skin_t *)(thing->localskin ? thing->localskin : thing->skin))->flags & SF_HIRES) - this_scale *= FIXED_TO_FLOAT(((skin_t *)(thing->localskin ? thing->localskin : thing->skin))->highresscale); + if ((thing->skin || thing->localskin) && K_GetMobjSkin(thing)->flags & SF_HIRES) + this_scale *= FIXED_TO_FLOAT(K_GetMobjSkin(thing)->highresscale); spr_width = spritecachedinfo[lumpoff].width; spr_height = spritecachedinfo[lumpoff].height; diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index cefbde5b7..f109ddd41 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -403,7 +403,7 @@ static void md2_loadTexture(md2_t *model) glpatch->height = (INT16)h; glpatch->mipmap->width = (UINT16)w; glpatch->mipmap->height = (UINT16)h; - + // for palette rendering, color cube is applied in post-processing instead of here if (!HWR_ShouldUsePaletteRendering()) { @@ -607,7 +607,7 @@ void HWR_AddPlayerMD2(int skin, boolean local) // For MD2's that were added afte // Check for any MD2s that match the names of player skins! while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4) { - if (stricmp(name, ( (local) ? localskins : skins )[skin].name) == 0) + if (stricmp(name, K_GetSkinArray(local)[skin].name) == 0) { md2s[skin].skin = skin; md2s[skin].scale = scale; @@ -1179,13 +1179,13 @@ void HWR_DrawMD2(gl_vissprite_t *spr) // Apparently people don't like jump frames like that, so back it goes //if (tics > durs) //durs = tics; - + INT32 blendmode; if (spr->mobj->frame & FF_BLENDMASK) blendmode = ((spr->mobj->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; else blendmode = spr->mobj->blendmode; - + blendmode = min(AST_MODULATE, blendmode); if (spr->mobj->flags2 & MF2_SHADOW) @@ -1207,7 +1207,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) // dont forget to enabled the depth test because we can't do this like // before: polygons models are not sorted - + /* fuck you */ if (spr->mobj->localskin) { @@ -1298,7 +1298,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) tcskinnum = TC_RAINBOW; else { - tcskinnum = (INT32)((skin_t*)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ) - ( (spr->mobj->skinlocal) ? localskins : skins )); + tcskinnum = (INT32)(K_GetMobjSkinNum(K_GetMobjSkin(spr->mobj), spr->mobj->skinlocal)); } } else tcskinnum = TC_DEFAULT; @@ -1364,8 +1364,8 @@ void HWR_DrawMD2(gl_vissprite_t *spr) else p.z = FIXED_TO_FLOAT(interp.z); - if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) - sprdef = &((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->spritedef; + if ((spr->mobj->skin || spr->mobj->localskin) && spr->mobj->sprite == SPR_PLAY) + sprdef = &K_GetMobjSkin(spr->mobj)->spritedef; else sprdef = &sprites[spr->mobj->sprite]; diff --git a/src/k_kart.c b/src/k_kart.c index 248c7235d..500eb4eaa 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -696,7 +696,7 @@ void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color, bo return; } - starttranscolor = (skinnum != TC_DEFAULT) ? ((local) ? localskins : skins)[skinnum].starttranscolor : DEFAULT_STARTTRANSCOLOR; + starttranscolor = (skinnum != TC_DEFAULT) ? K_GetSkinArray(local)[skinnum].starttranscolor : DEFAULT_STARTTRANSCOLOR; // Fill in the entries of the palette that are fixed for (i = 0; i < starttranscolor; i++) @@ -778,6 +778,51 @@ boolean K_UseHighResPortraits(void) return (cv_highresportrait.value && K_IsHighResolution()); } +// returns the players skinnumber +// accounts for localskins +INT32 K_GetSkinNum(player_t *player) +{ + return player->localskin ? (player->localskin - 1) : player->skin; +} + +// returns the mobj skinnumber +// accounts for localskins +INT32 K_GetMobjSkinNum(const skin_t *skin, boolean local) +{ + return skin - K_GetSkinArray(local); +} + +// returns the players skinnumber +// accounts for localskins +skin_t *K_GetMobjSkin(const mobj_t *mobj) +{ + return mobj->localskin ? mobj->localskin : mobj->skin; +} + +// returns the skin array to use +// accounts for localskins +skin_t *K_GetSkinArray(boolean local) +{ + return local ? localskins : skins; +} + +// returns the players skin +// accounts for localskins +skin_t *K_GetPlayerSkin(player_t *player) +{ + return &K_GetSkinArray(player->skinlocal)[K_GetSkinNum(player)]; +} + +// returns the players faceprefix +// accounts for localskins +patch_t *K_GetFacePrefix(player_t *player, INT32 skinnum) +{ + if (!player->skinlocal) + return (K_UseHighResPortraits() ? facewantprefix[skinnum] : facerankprefix[skinnum]); + else + return (K_UseHighResPortraits() ? localfacewantprefix[skinnum] : localfacerankprefix[skinnum]); +} + //} //{ SRB2kart Net Variables @@ -2109,8 +2154,7 @@ static void K_PlayGenericCombatSound(mobj_t *source, mobj_t *other, sfxenum_t sf // I HATE LOCALSKINS! I HATE LOCALSKINS! :AAAAAAAAAA: if (source->player) { - INT32 skinnum = source->player->skinlocal ? (source->player->localskin - 1) : source->player->skin; - skin = &(source->player->skinlocal ? localskins : skins)[skinnum]; + skin = K_GetPlayerSkin(source->player); } if (!skin) @@ -8388,16 +8432,7 @@ static void K_drawKartStats(void) flags |= V_HUDTRANS; skin_t *fakeskin; - fakeskin = &skins[stplyr->skin]; - - // local skinner - if (stplyr->localskin) - { - if (stplyr->skinlocal) - fakeskin = &localskins[stplyr->localskin - 1]; - else - fakeskin = &skins[stplyr->localskin - 1]; - } + fakeskin = K_GetPlayerSkin(stplyr); if (!splitscreen) { @@ -10276,9 +10311,9 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) // am xpos & ypos are the icon's starting position. Without // it, they wouldn't 'spawn' on the top-right side of the HUD. - UINT8 skinnum = 0; + const skin_t *skin; + player_t *player = mo->player; const boolean skinlocal = mo->skinlocal; - const skin_t *skin = (skin_t*)(mo->localskin ? mo->localskin : mo->skin); fixed_t amnumxpos, amnumypos; INT32 amxpos, amypos, wntdamxpos, wntdamypos; @@ -10290,10 +10325,8 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) INT32 rot = 0; #endif - if (mo->skin) - skinnum = (skin-(skinlocal ? localskins : skins)); - - minimaphead = (skinlocal ? localfacemmapprefix : facemmapprefix)[skinnum]; + skin = K_GetMobjSkin(mo); + minimaphead = (skinlocal ? localfacemmapprefix : facemmapprefix)[K_GetMobjSkinNum(skin, skinlocal)]; 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); @@ -10304,9 +10337,9 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) amxpos = amnumxpos + ((x + (SHORT(minimapinfo.minimap_pic->width)-SHORT(minimaphead->width)) / 2)<height)-SHORT(minimaphead->height)) / 2)<player && !(modeattacking || gamestate == GS_TIMEATTACK)) + if (cv_showminimapnames.value && player && !(modeattacking || gamestate == GS_TIMEATTACK)) { - V_DrawCenteredSmallStringAtFixed(amxpos + (4*FRACUNIT), amypos - (3*FRACUNIT), V_ALLOWLOWERCASE|flags|V_SkinColorToHighlightcolor(mo->color), player_names[mo->player - players]); + V_DrawCenteredSmallStringAtFixed(amxpos + (4*FRACUNIT), amypos - (3*FRACUNIT), V_ALLOWLOWERCASE|flags|V_SkinColorToHighlightcolor(mo->color), player_names[player - players]); } // thx wanted reticle for having weird offsets very cool @@ -10321,10 +10354,10 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) } #ifdef ROTSPRITE - if (cv_spinoutroll.value && mo->player && mo->player->spinoutrot) + if (cv_spinoutroll.value && player && player->spinoutrot) { // Rotate counterclockwise. - rollangle = FixedAngle(mo->player->spinoutrot * -1); + rollangle = FixedAngle(player->spinoutrot * -1); rot = R_GetRollAngle(rollangle); if (rot) @@ -10347,9 +10380,9 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) V_DrawFixedPatch(amxpos, amypos, scale, flags, minimaphead, colormap); - if (mo->player - && ((G_RaceGametype() && mo->player->kartstuff[k_position] == spbplace) - || (G_BattleGametype() && K_IsPlayerWanted(mo->player)))) + if (player + && ((G_RaceGametype() && player->kartstuff[k_position] == spbplace) + || (G_BattleGametype() && K_IsPlayerWanted(player)))) { V_DrawFixedPatch(wntdamxpos, wntdamypos, scale, flags, kp_wantedreticle, NULL); } diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 978f75d01..9498974d5 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -392,16 +392,16 @@ int mobj_skin_getter(lua_State *L) mobj_t *mo = GETMO(); if (!mo->skin) - return 0; + return 0; + + // HUD ONLY!!!!!!!!!! + if (hud_running && cv_luaimmersion.value) + { + lua_pushstring(L, K_GetMobjSkin(mo)->name); + } + else + lua_pushstring(L, ((skin_t *)mo->skin)->name); - if (hud_running && cv_luaimmersion.value) { - if (mo->localskin) // HUD ONLY!!!!!!!!!! - lua_pushstring(L, ((skin_t *)mo->localskin)->name); - else - lua_pushstring(L, ((skin_t *)mo->skin)->name); - } else { - lua_pushstring(L, ((skin_t *)mo->skin)->name); - } return 1; } @@ -502,12 +502,12 @@ int mobj_color_setter(lua_State *L) int mobj_blendmode_setter(lua_State *L) { mobj_t *mo = GETMO(); - + INT32 blendmode = (INT32)luaL_checkinteger(L, 2); if (blendmode < 0 || blendmode > AST_OVERLAY) return luaL_error(L, "mobj.blendmode %d out of range (0 - %d).", blendmode, AST_OVERLAY); mo->blendmode = blendmode; - + return 0; } diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 32b4abfe7..849f42b39 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -295,7 +295,7 @@ int player_localskin_getter(lua_State *L) player_t *plr = GETPLAYER(); if (plr->localskin) - lua_pushstring(L, (plr->skinlocal ? localskins : skins)[plr->localskin - 1].name); + lua_pushstring(L, K_GetPlayerSkin(plr)->name); else lua_pushnil(L); diff --git a/src/lua_script.c b/src/lua_script.c index 4346e483e..580b83ae2 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -749,6 +749,7 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex) } lua_pop(gL, 1); } + if (!found) { t++; diff --git a/src/p_local.h b/src/p_local.h index 9ac7a063c..76506ac87 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -237,7 +237,6 @@ void P_PlayRinglossSound(mobj_t *source, mobj_t *damager); void P_PlayDeathSound(mobj_t *source); void P_PlayVictorySound(mobj_t *source); - // // P_MOBJ // diff --git a/src/p_user.c b/src/p_user.c index 5d91a1e32..1747a84a1 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -557,14 +557,9 @@ void P_PlayRinglossSound(mobj_t *source, mobj_t *damager) { sfxenum_t sfx = sfx_khurt1 + key; - INT32 skinnum = -1; - // I HATE LOCALSKINS! I HATE LOCALSKINS! :AAAAAAAAAA: if (source->player) - skinnum = source->player->skinlocal ? (source->player->localskin - 1) : source->player->skin; - - if (skinnum >= 0) - sfx = (source->player->skinlocal ? localskins : skins)[skinnum].soundsid[SKSKPAN1 + key]; + sfx = K_GetPlayerSkin(source->player)->soundsid[SKSKPAN1 + key]; S_StartSound(NULL, sfx); } @@ -1195,9 +1190,9 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) ghost->tics = -1; ghost->frame &= ~FF_TRANSMASK; ghost->frame |= tr_trans50<slopepitch = mobj->slopepitch; + ghost->slopepitch = mobj->slopepitch; ghost->sloperoll = mobj->sloperoll; - + ghost->fuse = ghost->info->damage; ghost->skin = mobj->skin; ghost->localskin = mobj->localskin; @@ -1254,17 +1249,13 @@ void P_DoPlayerExit(player_t *player) { sfxenum_t sfx_id; // fix godjjsa win sounds - if (K_IsPlayerLosing(player)) { - if (player->mo->localskin) - sfx_id = ((skin_t *)player->mo->localskin)->soundsid[S_sfx[sfx_klose].skinsound]; - else - sfx_id = ((skin_t *)player->mo->skin)->soundsid[S_sfx[sfx_klose].skinsound]; + if (K_IsPlayerLosing(player)) + { + sfx_id = K_GetMobjSkin(player->mo)->soundsid[S_sfx[sfx_klose].skinsound]; } - else { - if (player->mo->localskin) - sfx_id = ((skin_t *)player->mo->localskin)->soundsid[S_sfx[sfx_kwin].skinsound]; - else - sfx_id = ((skin_t *)player->mo->skin)->soundsid[S_sfx[sfx_kwin].skinsound]; + else + { + sfx_id = K_GetMobjSkin(player->mo)->soundsid[S_sfx[sfx_kwin].skinsound]; } S_StartSound(NULL, sfx_id); } @@ -4715,7 +4706,7 @@ void P_PlayerThink(player_t *player) continue; break; } - + if (i < MAXPLAYERS && !player->spectator && !player->exiting && !(player->pflags & PF_TIMEOVER)) { const tic_t griefval = cv_antigrief.value * TICRATE; diff --git a/src/r_draw.c b/src/r_draw.c index b91ffa918..e709c625b 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -484,12 +484,12 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags) UINT8* R_GetLocalTranslationColormap(skin_t *skin, skin_t *localskin, skincolors_t color, UINT8 flags, boolean local) { if (localskin) - return RGetTranslationColormap(( localskin - ( (local) ? localskins : skins ) ), color, flags, local); + return RGetTranslationColormap(localskin - K_GetSkinArray(local), color, flags, local); else - return RGetTranslationColormap(( skin - skins ), color, flags, false); + return RGetTranslationColormap((skin - skins), color, flags, false); } -patch_t* R_GetSkinFaceRank(player_t* ply) +patch_t* R_GetSkinFaceRank(player_t* ply) { if (ply->skinlocal && ply->localskin) return localfacerankprefix[ply->localskin - 1]; @@ -498,7 +498,7 @@ patch_t* R_GetSkinFaceRank(player_t* ply) return facerankprefix[ply->skin]; } -patch_t* R_GetSkinFaceWant(player_t* ply) +patch_t* R_GetSkinFaceWant(player_t* ply) { if (ply->skinlocal && ply->localskin) return localfacewantprefix[ply->localskin - 1]; @@ -507,7 +507,7 @@ patch_t* R_GetSkinFaceWant(player_t* ply) return facewantprefix[ply->skin]; } -patch_t* R_GetSkinFaceMini(player_t* ply) +patch_t* R_GetSkinFaceMini(player_t* ply) { if (ply->skinlocal && ply->localskin) return localfacemmapprefix[ply->localskin - 1]; diff --git a/src/r_things.c b/src/r_things.c index a3d8b500f..1be7bb7c3 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -823,10 +823,8 @@ static void R_DrawVisSprite(vissprite_t *vis) frac = vis->startfrac; windowtop = windowbottom = sprbotscreen = INT32_MAX; - if (vis->mobj->localskin && ((skin_t *)vis->mobj->localskin)->flags & SF_HIRES) - this_scale = FixedMul(this_scale, ((skin_t *)vis->mobj->localskin)->highresscale); - else if (vis->mobj->skin && ((skin_t *)vis->mobj->skin)->flags & SF_HIRES) - this_scale = FixedMul(this_scale, ((skin_t *)vis->mobj->skin)->highresscale); + if ((vis->mobj->skin || vis->mobj->localskin) && K_GetMobjSkin(vis->mobj)->flags & SF_HIRES) + this_scale = FixedMul(this_scale, K_GetMobjSkin(vis->mobj)->highresscale); if (this_scale <= 0) this_scale = 1; @@ -1274,9 +1272,9 @@ static void R_ProjectSprite(mobj_t *thing) //Fab : 02-08-98: 'skin' override spritedef currently used for skin if ((thing->skin || thing->localskin) && thing->sprite == SPR_PLAY) { - sprdef = &((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->spritedef; + sprdef = &K_GetMobjSkin(thing)->spritedef; #ifdef ROTSPRITE - sprinfo = &((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->sprinfo; + sprinfo = &K_GetMobjSkin(thing)->sprinfo; #endif if (rot >= sprdef->numframes) @@ -1357,10 +1355,8 @@ static void R_ProjectSprite(mobj_t *thing) I_Assert(lump < max_spritelumps); - if (thing->localskin && ((skin_t *)thing->localskin)->flags & SF_HIRES) - this_scale = FixedMul(this_scale, ((skin_t *)thing->localskin)->highresscale); - else if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES) - this_scale = FixedMul(this_scale, ((skin_t *)thing->skin)->highresscale); + if ((thing->skin || thing->localskin) && K_GetMobjSkin(thing)->flags & SF_HIRES) + this_scale = FixedMul(this_scale, K_GetMobjSkin(thing)->highresscale); spr_width = spritecachedinfo[lump].width; spr_height = spritecachedinfo[lump].height; @@ -3022,8 +3018,7 @@ static void Sk_SetDefaultValue(skin_t *skin, boolean local) // set default skin values // memset(skin, 0, sizeof (skin_t)); - snprintf(skin->name, - sizeof skin->name, "skin %u", (UINT32)(skin-(local ? localskins : skins))); + snprintf(skin->name, sizeof skin->name, "skin %u", K_GetMobjSkinNum(skin, local)); skin->name[sizeof skin->name - 1] = '\0'; skin->wadnum = INT16_MAX; strcpy(skin->sprite, ""); @@ -3244,8 +3239,9 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) { if (player->localskin > 0) { - CV_StealthSet(&cv_fakelocalskin, (player->skinlocal ? localskins : skins)[player->localskin-1].name); - CV_StealthSet(cvar, (player->skinlocal ? localskins : skins)[player->localskin-1].name); + CV_StealthSet(&cv_fakelocalskin, K_GetSkinArray(player->skinlocal)[player->localskin-1].name); + CV_StealthSet(cvar, K_GetSkinArray(player->skinlocal)[player->localskin-1].name); + } else { @@ -3434,7 +3430,6 @@ void R_AddSkins(UINT16 wadnum, boolean local) skin_t *skin; boolean hudname, realname; -#define lskin (local ? localskins : skins) #define lnumskins (local ? numlocalskins : numskins) // @@ -3468,7 +3463,7 @@ void R_AddSkins(UINT16 wadnum, boolean local) buf2[size] = '\0'; // set defaults - skin = &lskin[lnumskins]; + skin = &K_GetSkinArray(local)[lnumskins]; Sk_SetDefaultValue(skin, local); skin->wadnum = wadnum; hudname = realname = false; @@ -3503,10 +3498,10 @@ void R_AddSkins(UINT16 wadnum, boolean local) else { const size_t stringspace = - strlen(value) + sizeof (( (local) ? numlocalskins : numskins )) + 1; + strlen(value) + sizeof lnumskins + 1; char *value2 = Z_Malloc(stringspace, PU_STATIC, NULL); snprintf(value2, stringspace, - "%s%d", value, ( (local) ? numlocalskins : numskins )); + "%s%d", value, lnumskins); value2[stringspace - 1] = '\0'; if (R_LocalSkinAvailable(value2, local) == -1) { @@ -3727,7 +3722,7 @@ next_token: skinsorted[numskins] = numskins; } - allskins[numallskins] = lskin[lnumskins]; + allskins[numallskins] = K_GetSkinArray(local)[lnumskins]; local ? numlocalskins++ : numskins++; numallskins++; diff --git a/src/r_things.h b/src/r_things.h index 1db265f4b..fe4f532b6 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -118,13 +118,21 @@ typedef struct // specific sounds per skin sfxenum_t soundsid[NUMSKINSOUNDS]; // sound # in S_sfx table - + boolean localskin; INT32 localnum; } skin_t; extern CV_PossibleValue_t Forceskin_cons_t[]; +// had to move those here Zzz... +INT32 K_GetSkinNum(player_t *player); +INT32 K_GetMobjSkinNum(const skin_t *skin, boolean local); +skin_t *K_GetPlayerSkin(player_t *player); +skin_t *K_GetMobjSkin(const mobj_t *mobj); +patch_t *K_GetFacePrefix(player_t *player, INT32 skinnum); +skin_t *K_GetSkinArray(boolean local); + // ----------- // NOT SKINS STUFF ! // ----------- diff --git a/src/s_sound.c b/src/s_sound.c index fc77fdacf..9db004a44 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -509,7 +509,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) if (sfx->skinsound != -1 && origin && origin->skin) { // redirect player sound to the sound in the skin table - sfx_id = ((skin_t *)( (origin->localskin) ? origin->localskin : origin->skin ))->soundsid[sfx->skinsound]; + sfx_id = K_GetMobjSkin(origin)->soundsid[sfx->skinsound]; sfx = &S_sfx[sfx_id]; } diff --git a/src/y_inter.c b/src/y_inter.c index 01611e568..444df52d4 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -409,12 +409,7 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) { UINT8 *colormap = R_GetTranslationColormap(*standings->character[i], *standings->color[i], GTC_CACHE); INT32 skinnum = (player->localskin ? (player->localskin - 1) : *standings->character[i]); - patch_t *faceprefix = NULL; - - if (!player->skinlocal) - faceprefix = (K_UseHighResPortraits() ? facewantprefix[skinnum] : facerankprefix[skinnum]); - else - faceprefix = (K_UseHighResPortraits() ? localfacewantprefix[skinnum] : localfacerankprefix[skinnum]); + patch_t *faceprefix = K_GetFacePrefix(player, skinnum); if (K_UseHighResPortraits()) V_DrawSmallMappedPatch(x + 16, y - 4, 0, faceprefix, colormap); @@ -1143,7 +1138,9 @@ void Y_VoteDrawer(void) if (dedicated && i == 0) // While leaving blank spots for non-existent players is largely intentional, the first spot *always* being blank looks a tad silly :V continue; - if ((playeringame[i] && !players[i].spectator) && votes[i] != -1) + player_t *player = &players[i]; + + if ((playeringame[i] && !player->spectator) && votes[i] != -1) { patch_t *pic; @@ -1175,13 +1172,16 @@ void Y_VoteDrawer(void) V_DrawDiag(x, y, 6, V_SNAPTOLEFT|levelinfo[votes[i]].gtc); } - if (players[i].skincolor) + if (player->skincolor) { - UINT8 *colormap = R_GetTranslationColormap(players[i].skin, players[i].skincolor, GTC_CACHE); + UINT8 *colormap = R_GetTranslationColormap(player->skin, player->skincolor, GTC_CACHE); + + patch_t *faceprefix = K_GetFacePrefix(player, K_GetSkinNum(player)); + if (K_UseHighResPortraits()) - V_DrawSmallMappedPatch(x+24, y+9, V_SNAPTOLEFT, (players[i].skinlocal ? localfacewantprefix : facewantprefix)[((players[i].localskin) ? players[i].localskin-1 : players[i].skin)], colormap); + V_DrawSmallMappedPatch(x+24, y+9, V_SNAPTOLEFT, faceprefix, colormap); else - V_DrawMappedPatch(x+24, y+9, V_SNAPTOLEFT, (players[i].skinlocal ? localfacerankprefix : facerankprefix)[((players[i].localskin) ? players[i].localskin-1 : players[i].skin)], colormap); + V_DrawMappedPatch(x+24, y+9, V_SNAPTOLEFT, faceprefix, colormap); } if (!splitscreen && i == consoleplayer) From 98f35b6e06978541b59993bcde84a20c678d4db2 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Apr 2025 14:33:11 +0100 Subject: [PATCH 180/350] windoze stimky well this atleast should work for everyone, but be noted that the normal "localtime" function is apparently not thread safe --- src/g_game.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 363b4caa4..54e509be6 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -59,6 +59,10 @@ #include "discord.h" #endif +// for replay dates +#include +#include + gameaction_t gameaction; gamestate_t gamestate = GS_NULL; UINT8 ultimatemode = false; @@ -6800,9 +6804,6 @@ void G_LoadDemoInfo(menudemo_t *pdemo) Z_Free(infobuffer); } -#include -#include - #if defined (_WIN32) // return the file creation time // useful for demos that were renamed @@ -6861,25 +6862,25 @@ skipfilenametime: #endif // then throw it into localtime to get an actual human readable format lmao - struct tm tm_buf; - localtime_r(&file_time, &tm_buf); + struct tm *tm_buf = NULL; + tm_buf = localtime(&file_time); // cant believe we ended up in 1970 - if (tm_buf.tm_year <= 110) + if (tm_buf == NULL || tm_buf->tm_year <= 110) { #if defined (_WIN32) // uh ohh, we got an invalid time // try one more time getting the creation time file_time = G_GetCreationTime(pdemo->filepath); - localtime_r(&file_time, &tm_buf); + tm_buf = localtime(&file_time); - if (tm_buf.tm_year <= 110) + if (tm_buf == NULL || tm_buf->tm_year <= 110) { free(datetime); return NULL; } - else - goto gotcreationtime; + + goto gotcreationtime; #else free(datetime); return NULL; @@ -6900,11 +6901,10 @@ gotcreationtime: else format = strstr(setlocale(LC_TIME, NULL), "en_US") ? "%m.%d.%Y" : "%d.%m.%Y"; - strftime(datetime, sizeof(pdemo->date), format, &tm_buf); + strftime(datetime, sizeof(pdemo->date), format, tm_buf); return datetime; } -#undef PATHSEPSTR void G_LoadDemoTitle(menudemo_t *pdemo) { From 48113cb1563768385f99fd486e830a416f1a6693 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Apr 2025 14:36:36 +0100 Subject: [PATCH 181/350] spr->mobj not thing lel --- src/hardware/hw_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 93054e3f0..9e07efa14 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3318,11 +3318,11 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, GLPatch_t *gpatch) float offset = 0; // technically this_scale gets multiplied and added to sprite y/x scale, but this thing needs it for some crap so ill just throw it in here again - const boolean hires = (spr->mobj && spr->mobj->skin && K_GetMobjSkin(thing)->flags & SF_HIRES); + const boolean hires = (spr->mobj && spr->mobj->skin && K_GetMobjSkin(spr->mobj)->flags & SF_HIRES); if (spr->mobj) this_scale = FIXED_TO_FLOAT(spr->mobj->scale); if (hires) - this_scale = this_scale * FIXED_TO_FLOAT(K_GetMobjSkin(thing)->highresscale); + this_scale = this_scale * FIXED_TO_FLOAT(K_GetMobjSkin(spr->mobj)->highresscale); R_GetShadowZ(spr->mobj, &floorslope); From e74340aabf234c2a98697cdbae73572f2c986f85 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Apr 2025 14:36:36 +0100 Subject: [PATCH 182/350] spr->mobj not thing lel --- src/hardware/hw_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 93054e3f0..9e07efa14 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3318,11 +3318,11 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, GLPatch_t *gpatch) float offset = 0; // technically this_scale gets multiplied and added to sprite y/x scale, but this thing needs it for some crap so ill just throw it in here again - const boolean hires = (spr->mobj && spr->mobj->skin && K_GetMobjSkin(thing)->flags & SF_HIRES); + const boolean hires = (spr->mobj && spr->mobj->skin && K_GetMobjSkin(spr->mobj)->flags & SF_HIRES); if (spr->mobj) this_scale = FIXED_TO_FLOAT(spr->mobj->scale); if (hires) - this_scale = this_scale * FIXED_TO_FLOAT(K_GetMobjSkin(thing)->highresscale); + this_scale = this_scale * FIXED_TO_FLOAT(K_GetMobjSkin(spr->mobj)->highresscale); R_GetShadowZ(spr->mobj, &floorslope); From 7e6bde73e1f16a0d0bf113b3858199642c9aeec0 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Apr 2025 15:41:58 +0200 Subject: [PATCH 183/350] make a macro for this --- src/p_saveg.c | 55 ++++++++++++++++----------------------------------- 1 file changed, 17 insertions(+), 38 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 795d612a4..db2c05cb9 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3010,6 +3010,7 @@ static void P_RelinkPointers(void) { thinker_t *currentthinker; mobj_t *mobj; + player_t *player; // use info field (value = oldposition) to relink mobjs for (currentthinker = thinkercap.next; currentthinker != &thinkercap; @@ -3023,46 +3024,24 @@ static void P_RelinkPointers(void) if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) continue; - if (mobj->tracer) +#define RELINK(obj, name) if ((obj) && !RelinkMobj(&(obj))) \ + CONS_Debug(DBG_GAMELOGIC, name " not found on %d\n", obj->type); + + RELINK(mobj->tracer, "tracer"); + RELINK(mobj->target, "target"); + RELINK(mobj->hnext, "hnext"); + RELINK(mobj->hprev, "hprev"); + + player = mobj->player; + + if (player) { - if (!RelinkMobj(&mobj->tracer)) - CONS_Debug(DBG_GAMELOGIC, "tracer not found on %d\n", mobj->type); - } - if (mobj->target) - { - if (!RelinkMobj(&mobj->target)) - CONS_Debug(DBG_GAMELOGIC, "target not found on %d\n", mobj->type); - } - if (mobj->hnext) - { - if (!RelinkMobj(&mobj->hnext)) - CONS_Debug(DBG_GAMELOGIC, "hnext not found on %d\n", mobj->type); - } - if (mobj->hprev) - { - if (!RelinkMobj(&mobj->hprev)) - CONS_Debug(DBG_GAMELOGIC, "hprev not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->capsule) - { - if (!RelinkMobj(&mobj->player->capsule)) - CONS_Debug(DBG_GAMELOGIC, "capsule not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->axis1) - { - if (!RelinkMobj(&mobj->player->axis1)) - CONS_Debug(DBG_GAMELOGIC, "axis1 not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->axis2) - { - if (!RelinkMobj(&mobj->player->axis2)) - CONS_Debug(DBG_GAMELOGIC, "axis2 not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->awayviewmobj) - { - if (!RelinkMobj(&mobj->player->awayviewmobj)) - CONS_Debug(DBG_GAMELOGIC, "awayviewmobj not found on %d\n", mobj->type); + RELINK(player->capsule, "capsule"); + RELINK(player->axis1, "axis1"); + RELINK(player->axis2, "axis2"); + RELINK(player->awayviewmobj, "awayviewmobj"); } +#undef RELINK } } From 94eebd2cd0ffd4edfed83aa04ea9ecd2b6965b62 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Apr 2025 15:42:25 +0200 Subject: [PATCH 184/350] use mobjcache for savegame mobj load --- src/p_saveg.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index db2c05cb9..abbe2fbfb 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1928,6 +1928,25 @@ static inline player_t *LoadPlayer(UINT32 player) // // Loads a mobj_t from a save game // + +FUNCINLINE static ATTRINLINE mobj_t *AllocMobj(void) +{ + mobj_t *mobj; + + if (mobjcache != NULL) + { + mobj = mobjcache; + mobjcache = mobjcache->hnext; + memset(mobj, 0, sizeof(*mobj)); + } + else + { + mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); + } + + return mobj; +} + static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) { thinker_t *next; @@ -1959,13 +1978,12 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) return; } - mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); - + mobj = AllocMobj(); mobj->spawnpoint = &mapthings[spawnpointnum]; mapthings[spawnpointnum].mobj = mobj; } else - mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); + mobj = AllocMobj(); // declare this as a valid mobj as soon as possible. mobj->thinker.function.acp1 = thinker; From fb15cfe9f0670633d3618ef441352dfbd4a27cb9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Apr 2025 15:43:17 +0200 Subject: [PATCH 185/350] convert fixed to float with multiplication instead of division --- src/m_fixed.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/m_fixed.h b/src/m_fixed.h index 3f1acd7ae..8f537b328 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -39,9 +39,11 @@ typedef UINT32 ufixed_t; \brief convert fixed_t into floating number */ +static const float FLOATUNIT = (1.0f / (float)FRACUNIT); + FUNCMATH FUNCINLINE static ATTRINLINE float FixedToFloat(fixed_t x) { - return x / (float)FRACUNIT; + return x * FLOATUNIT; } FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FloatToFixed(float f) From fa757c6695410bac3d32ae950670111d4a84d730 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Apr 2025 15:43:43 +0200 Subject: [PATCH 186/350] throw mobjcache allocation shit into a inline function --- src/p_mobj.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 1b7d5a786..5e28cb0c6 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9386,13 +9386,8 @@ void P_SceneryThinker(mobj_t *mobj) // GAME SPAWN FUNCTIONS // -// -// P_SpawnMobj -// -mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) +FUNCINLINE static ATTRINLINE mobj_t *P_AllocMobj(void) { - const mobjinfo_t *info = &mobjinfo[type]; - state_t *st; mobj_t *mobj; if (mobjcache != NULL) @@ -9406,6 +9401,20 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); } + return mobj; +} + +// +// P_SpawnMobj +// +mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) +{ + const mobjinfo_t *info = &mobjinfo[type]; + state_t *st; + mobj_t *mobj; + + mobj = P_AllocMobj(); + // this is officially a mobj, declared as soon as possible. mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; mobj->type = type; @@ -9870,16 +9879,7 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster) state_t *st; mobj_t *mobj; - if (mobjcache != NULL) - { - mobj = mobjcache; - mobjcache = mobjcache->hnext; - memset(mobj, 0, sizeof(*mobj)); - } - else - { - mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); - } + mobj = P_AllocMobj(); // this is officially a mobj, declared as soon as possible. mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; From b4416c32ed17a36bb17acf27451621abfec77d1b Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Apr 2025 16:01:43 +0200 Subject: [PATCH 187/350] =?UTF-8?q?move=20line=20polyseg=20check=20out=20o?= =?UTF-8?q?f=20the=20l=C3=B6=C3=B6p=20if=20theres=20no=20polyobjs=20on=20l?= =?UTF-8?q?e=20map?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit seems to reduce a hotspot there significantly --- src/hardware/hw_main.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9e07efa14..3892a9d52 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3143,11 +3143,22 @@ doaddline: // without talking about the overdraw of course. sub->sector->validcount = validcount;/// \todo fix that in a better way - while (count--) + if (numPolyObjects) { - if (LIKELY(!line->polyseg)) // ignore segs that belong to polyobjects + while (count--) + { + if (LIKELY(!line->polyseg)) // ignore segs that belong to polyobjects + HWR_AddLine(line); + line++; + } + } + else + { + while (count--) + { HWR_AddLine(line); - line++; + line++; + } } } From 494c6ca80de2e62ea6fbe9dfe44c1bed61a1b1c4 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Apr 2025 09:03:24 +0200 Subject: [PATCH 188/350] move drawnode stuff into a switch i like switches uwu --- src/hardware/hw_main.c | 70 +++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 3892a9d52..9f95c1c26 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4328,12 +4328,15 @@ static void HWR_RenderDrawNodes(void) { if (drawnodes[sortindex[i]].type != DRAWNODE_PLANE) break; } + run_end = i-1; + if (run_end > run_start) // if there are multiple consecutive planes, not just one { // consecutive run of planes found, now sort it qs22j(sortindex + run_start, run_end - run_start + 1, sizeof(INT32), CompareDrawNodePlanes); } + run_start = run_end + 1; // continue looking for runs coming right after this one } else @@ -4354,41 +4357,49 @@ static void HWR_RenderDrawNodes(void) { gl_drawnode_t *drawnode = &drawnodes[sortindex[i]]; - if (drawnode->type == DRAWNODE_PLANE) + switch (drawnode->type) { - planeinfo_t *plane = &drawnode->u.plane; + case DRAWNODE_PLANE: + { + planeinfo_t *plane = &drawnode->u.plane; - // We aren't traversing the BSP tree, so make gl_frontsector null to avoid crashes. - gl_frontsector = NULL; + // We aren't traversing the BSP tree, so make gl_frontsector null to avoid crashes. + gl_frontsector = NULL; - if (!(plane->blend & PF_NoTexture)) - HWR_GetFlat(plane->lumpnum, R_NoEncore(plane->FOFSector, plane->isceiling)); + if (!(plane->blend & PF_NoTexture)) + HWR_GetFlat(plane->lumpnum, R_NoEncore(plane->FOFSector, plane->isceiling)); - HWR_RenderPlane(NULL, plane->xsub, plane->isceiling, plane->fixedheight, plane->blend, plane->lightlevel, - plane->lumpnum, plane->FOFSector, plane->alpha, plane->planecolormap); - } - else if (drawnode->type == DRAWNODE_POLYOBJECT_PLANE) - { - polyplaneinfo_t *polyplane = &drawnode->u.polyplane; + HWR_RenderPlane(NULL, plane->xsub, plane->isceiling, plane->fixedheight, plane->blend, plane->lightlevel, + plane->lumpnum, plane->FOFSector, plane->alpha, plane->planecolormap); + break; + } + case DRAWNODE_POLYOBJECT_PLANE: + { + polyplaneinfo_t *polyplane = &drawnode->u.polyplane; - // We aren't traversing the BSP tree, so make gl_frontsector null to avoid crashes. - gl_frontsector = NULL; + // We aren't traversing the BSP tree, so make gl_frontsector null to avoid crashes. + gl_frontsector = NULL; - if (!(polyplane->blend & PF_NoTexture)) - HWR_GetFlat(polyplane->lumpnum, R_NoEncore(polyplane->FOFSector, polyplane->isceiling)); + if (!(polyplane->blend & PF_NoTexture)) + HWR_GetFlat(polyplane->lumpnum, R_NoEncore(polyplane->FOFSector, polyplane->isceiling)); - HWR_RenderPolyObjectPlane(polyplane->polysector, polyplane->isceiling, polyplane->fixedheight, polyplane->blend, polyplane->lightlevel, - polyplane->lumpnum, polyplane->FOFSector, polyplane->alpha, polyplane->planecolormap); - } - else if (drawnode->type == DRAWNODE_WALL) - { - wallinfo_t *wall = &drawnode->u.wall; + HWR_RenderPolyObjectPlane(polyplane->polysector, polyplane->isceiling, polyplane->fixedheight, polyplane->blend, polyplane->lightlevel, + polyplane->lumpnum, polyplane->FOFSector, polyplane->alpha, polyplane->planecolormap); + break; + } + case DRAWNODE_WALL: + { + wallinfo_t *wall = &drawnode->u.wall; - if (!(wall->blend & PF_NoTexture)) - HWR_GetTexture(wall->texnum, wall->noencore); + if (!(wall->blend & PF_NoTexture)) + HWR_GetTexture(wall->texnum, wall->noencore); - HWR_RenderWall(wall->wallVerts, &wall->Surf, wall->blend, wall->fogwall, - wall->lightlevel, wall->wallcolormap); + HWR_RenderWall(wall->wallVerts, &wall->Surf, wall->blend, wall->fogwall, + wall->lightlevel, wall->wallcolormap); + break; + } + default: + break; } } @@ -4954,15 +4965,15 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) if (!thing) return; - // uncapped/interpolation - interpmobjstate_t interp = {0}; - // okay... this is a hack, but weather isn't networked, so it should be ok if (!P_PrecipThinker(thing)) { return; } + // uncapped/interpolation + interpmobjstate_t interp = {0}; + if (cv_maxinterpdist.value) dist = R_QuickCamDist(thing->x, thing->y); @@ -5027,6 +5038,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) rightsin = FIXED_TO_FLOAT(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); rightcos = FIXED_TO_FLOAT(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); + if (flip) { x1 = FIXED_TO_FLOAT(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset); From e29c1010d3663d4c264aeadfc4188de1d6381059 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Apr 2025 18:42:03 +0200 Subject: [PATCH 189/350] missed this with localskin stuff --- src/p_mobj.c | 2 +- src/sdl/i_system.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 5e28cb0c6..f4f1512ec 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10685,7 +10685,7 @@ void P_SpawnPlayer(INT32 playernum) // the dead body mobj retains the skin through the 'spritedef' override). mobj->skin = &skins[p->skin]; - mobj->localskin = ((p->localskin > 0) ? (p->skinlocal ? &localskins[p->localskin - 1] : &skins[p->localskin - 1]) : 0); + mobj->localskin = (p->localskin ? K_GetPlayerSkin(p) : 0); mobj->skinlocal = p->skinlocal; mobj->health = p->health; diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index e32256a4f..12e194c67 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1095,7 +1095,7 @@ INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev) SDL_Joystick *joystick = NULL; joystick = SDL_GameControllerGetJoystick(dev); - + if (joystick) { return SDL_JoystickInstanceID(joystick); From e5f96231138357f7b66e2acbf11e01ec0a08902f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Apr 2025 09:08:16 +0200 Subject: [PATCH 190/350] move this to make it little more clear what this is for --- src/k_kart.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 500eb4eaa..a67a3fec7 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3669,11 +3669,12 @@ void K_RollMobjBySlopes(mobj_t* mo, pslope_t *slope) fixed_t tempz = slope->normal.z; fixed_t tempy = slope->normal.y; fixed_t tempx = slope->normal.x; - fixed_t tempangle = -(R_PointToAngle2(0, 0, FixedSqrt(FixedMul(tempy, tempy) + FixedMul(tempz, tempz)), tempx)); + fixed_t tempangle = 0; // admittedly this is a very hacky way to do the pitch and roll easing // pitch + tempangle = -(R_PointToAngle2(0, 0, FixedSqrt(FixedMul(tempy, tempy) + FixedMul(tempz, tempz)), tempx)); an = (INT32)((angle_t)tempangle - mo->pitch_sprite) / SLOPEROLL_DIV; mo->pitch_sprite = an ? mo->pitch_sprite + an : (angle_t)tempangle; mo->slopepitch = flip ? InvAngle(mo->pitch_sprite) : mo->pitch_sprite; From 7eb311d99c9eb7fa022195a847863e2e016b0ec5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Apr 2025 09:08:40 +0200 Subject: [PATCH 191/350] we dont need all this stuff for precip --- src/r_fps.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/r_fps.c b/src/r_fps.c index 92eb37a32..c92fb6ab4 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -364,11 +364,7 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst out->z = mobj->z; out->scale = cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT; //out->subsector = mobj->subsector; - out->angle = mobj->angle; - out->spritexscale = mobj->spritexscale; - out->spriteyscale = mobj->spriteyscale; - out->spritexoffset = mobj->spritexoffset; - out->spriteyoffset = mobj->spriteyoffset; + //out->angle = mobj->angle; return; } @@ -376,13 +372,8 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); out->scale = cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT; - out->spritexscale = mobj->spritexscale; - out->spriteyscale = mobj->spriteyscale; - out->spritexoffset = mobj->spritexoffset; - out->spriteyoffset = mobj->spriteyoffset; //out->subsector = R_PointInSubsector(out->x, out->y); // this is unused - - out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac); + //out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac); } static void AddInterpolator(levelinterpolator_t* interpolator) From 561b1c0b925ff83f0984a7d44d5f3197de39ac5f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Apr 2025 09:56:05 +0200 Subject: [PATCH 192/350] calloc takes care of those --- src/p_mobj.c | 12 ------------ src/p_mobj.h | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index f4f1512ec..fa4d2c099 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9426,11 +9426,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->radius = info->radius; mobj->height = info->height; mobj->flags = info->flags; - mobj->sloperoll = 0; - mobj->slopepitch = 0; - - mobj->pitch_sprite = 0; - mobj->roll_sprite = 0; mobj->health = info->spawnhealth; @@ -9468,12 +9463,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->realxscale = mobj->realyscale = mobj->scale; mobj->spritexscale = mobj->realxscale; mobj->spriteyscale = mobj->realyscale; - mobj->realxoffset = mobj->realyoffset = 0; - mobj->spritexoffset = mobj->realxoffset; - mobj->spriteyoffset = mobj->realyoffset; - - // Funni slam sound when landing - mobj->slamsoundtimer = 0; // set subsector and/or block links P_SetThingPosition(mobj); @@ -9929,7 +9918,6 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster) // Sprite rendering mobj->spritexscale = mobj->spriteyscale = mobj->scale; - mobj->spritexoffset = mobj->spriteyoffset = 0; // set subsector and/or block links P_SetThingPosition(mobj); diff --git a/src/p_mobj.h b/src/p_mobj.h index 46c7f6fae..0b380786b 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -397,7 +397,7 @@ typedef struct mobj_s boolean colorized; // Whether the mobj uses the rainbow colormap boolean mirrored; // The object's rotations will be mirrored left to right, e.g., see frame AL from the right and AR from the left - tic_t slamsoundtimer; + tic_t slamsoundtimer; // Funni slam sound when landing // saltyhop! hardcode edition boolean salty_ready; From 2342d92ae3d1e5ad7baebb7575a4ebb669bf51b1 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Apr 2025 10:38:19 +0200 Subject: [PATCH 193/350] refactor K_StretchPlayerGravity mostly just make it more readable lel --- src/k_kart.c | 170 +++++++++++++++++++++++---------------------------- src/p_tick.c | 4 +- 2 files changed, 79 insertions(+), 95 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index a67a3fec7..65956a788 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3422,7 +3422,6 @@ static void K_SpawnAIZDust(player_t *player) angle_t travelangle; I_Assert(player != NULL); - I_Assert(player->mo != NULL); I_Assert(!P_MobjWasRemoved(player->mo)); if (leveltime % 2 == 1) @@ -3455,162 +3454,147 @@ static void K_SpawnAIZDust(player_t *player) #define MAXSTRETCHDIV 17476977 -static void K_StretchPlayerGravity(player_t *p) +static void K_StretchPlayerGravity(player_t *player) { - if (cv_gravstretch.value == 0) - { + if (!cv_gravstretch.value) return; - } - I_Assert(p != NULL); - I_Assert(p->mo != NULL); - I_Assert(!P_MobjWasRemoved(p->mo)); + I_Assert(player != NULL); + I_Assert(!P_MobjWasRemoved(player->mo)); - fixed_t mos = FRACUNIT; - fixed_t rzs = abs(p->mo->momz); - fixed_t zspd = abs(rzs/mos); - fixed_t stretchScaleFactor = FixedDiv(FRACUNIT*60, cv_gravstretch.value); - fixed_t rzsDiv, slamDiv; + mobj_t *pmo = player->mo; - fixed_t dxs = p->mo->realxscale; - fixed_t dys = p->mo->realyscale; + fixed_t tempxscale = pmo->realxscale; + fixed_t tempyscale = pmo->realyscale; - if (stretchScaleFactor > MAXSTRETCHDIV) - rzsDiv = 0; - else - rzsDiv = FixedDiv(rzs, stretchScaleFactor); + const fixed_t stretchScaleFactor = min(FixedDiv(FRACUNIT*60, cv_gravstretch.value), MAXSTRETCHDIV); - //CONS_Printf(M_GetText("div: %d, scale factor: %d, stretch value: %d\n"), rzsDiv, stretchScaleFactor, cv_gravstretch.value); + if (pmo->slamsoundtimer) + pmo->slamsoundtimer--; - if (p->mo->slamsoundtimer) - p->mo->slamsoundtimer--; - - if (cv_slamsound.value && (p->mo->eflags & MFE_JUSTHITFLOOR) && !p->mo->slamsoundtimer && (p->mo->stretchslam > 4*mos)) + if (!P_IsObjectOnGround(pmo)) { - S_StartSound(p->mo, sfx_s3k4c); - p->mo->slamsoundtimer = TICRATE; - } + fixed_t pzmom = abs(pmo->momz); + const fixed_t stretchDiv = FixedDiv(pzmom, stretchScaleFactor); - if (!P_IsObjectOnGround(p->mo)) - { - if (zspd != 0) + if (abs(pzmom/FRACUNIT) != 0) { - if (((dxs-(rzsDiv))) > (dxs/5)) + if (((tempxscale-(stretchDiv))) > (tempxscale/5)) { - p->mo->spritexscale = ((dxs-(rzsDiv))); - p->mo->stretchslam = rzs; + pmo->spritexscale = (tempxscale - stretchDiv); + pmo->stretchslam = pzmom; } else - p->mo->spritexscale = (dxs/5); + pmo->spritexscale = (tempxscale/5); - p->mo->spriteyscale = (dys+((rzsDiv*2)/3)); + pmo->spriteyscale = (tempyscale + ((stretchDiv*2)/3)); } - else + } + else if (pmo->stretchslam > 0) + { + // Funni slam sound when landing + if (cv_slamsound.value && (pmo->eflags & MFE_JUSTHITFLOOR) && !pmo->slamsoundtimer && (pmo->stretchslam > 4*FRACUNIT)) { - p->mo->spritexscale = (dxs); - p->mo->spriteyscale = (dys); + S_StartSound(pmo, sfx_s3k4c); + pmo->slamsoundtimer = TICRATE; } + + const fixed_t slamDiv = FixedDiv(pmo->stretchslam, stretchScaleFactor); + + pmo->spritexscale = (tempxscale + (((slamDiv*2)/3)*2)); + pmo->spriteyscale = (tempyscale - slamDiv); + pmo->stretchslam -= (4*FRACUNIT); } else - { - if (stretchScaleFactor > MAXSTRETCHDIV) - slamDiv = 0; - else - slamDiv = FixedDiv(p->mo->stretchslam, stretchScaleFactor); - - p->mo->spritexscale = (dxs+(((slamDiv*2)/3)*2)); - p->mo->spriteyscale = (dys-(slamDiv)); - if (p->mo->stretchslam > 0) - p->mo->stretchslam -= (4*mos); - else - p->mo->stretchslam = 0; - } + pmo->stretchslam = 0; } -static void K_QuiteSaltyHop(player_t *p) +static void K_QuiteSaltyHop(player_t *player) { if (!cv_saltyhop.value) return; // what the fuck is this haya - fixed_t mos = FRACUNIT; // doesnt work correctly if it isnt :/ + //fixed_t mos = FRACUNIT; // doesnt work correctly if it isnt :/ + mobj_t *pmo = player->mo; + const boolean onground = P_IsObjectOnGround(pmo); // ready? - if (!p->kartstuff[k_jmp]) + if (!player->kartstuff[k_jmp]) { - p->mo->salty_ready = true; - p->mo->salty_tapping = false; + pmo->salty_ready = true; + pmo->salty_tapping = false; } - else if (p->mo->salty_ready) + else if (pmo->salty_ready) { - p->mo->salty_ready = false; - p->mo->salty_tapping = true; + pmo->salty_ready = false; + pmo->salty_tapping = true; } else { - p->mo->salty_tapping = false; + pmo->salty_tapping = false; } // GO! - if (!p->mo->init_salty) + if (!pmo->init_salty) { - p->mo->salty_jump = false; - p->mo->salty_zoffset = 0; - p->mo->salty_momz = 0; - p->mo->init_salty = true; + pmo->salty_jump = false; + pmo->salty_zoffset = 0; + pmo->salty_momz = 0; + pmo->init_salty = true; } - else if (p->mo->salty_jump) + else if (pmo->salty_jump) { - if (p->mo->eflags & MFE_JUSTHITFLOOR) + if (pmo->eflags & MFE_JUSTHITFLOOR) { - p->mo->salty_zoffset = 0; + pmo->salty_zoffset = 0; } - else if (P_IsObjectOnGround(p->mo)) + else if (onground) { - p->mo->salty_zoffset += p->mo->salty_momz; - p->mo->salty_momz -= (mos*3/2); + pmo->salty_zoffset += pmo->salty_momz; + pmo->salty_momz -= (FRACUNIT*3/2); } else { - p->mo->salty_zoffset *= (49/50)*mos; - p->mo->salty_momz = 0; + pmo->salty_zoffset *= (49/50)*FRACUNIT; + pmo->salty_momz = 0; } - if (p->mo->salty_zoffset <= 0) + if (pmo->salty_zoffset <= 0) { - if (cv_saltyhopsfx.value && !(p->mo->eflags & MFE_JUSTHITFLOOR) && P_IsObjectOnGround(p->mo)) - S_StartSound(p->mo, sfx_s268); - p->mo->salty_jump = false; - p->mo->salty_zoffset = 0; - p->mo->salty_momz = 0; + if (cv_saltyhopsfx.value && !(pmo->eflags & MFE_JUSTHITFLOOR) && onground) + S_StartSound(pmo, sfx_s268); + pmo->salty_jump = false; + pmo->salty_zoffset = 0; + pmo->salty_momz = 0; // shlamma damma if (cv_saltysquish.value) - p->mo->stretchslam += 8*mos; + pmo->stretchslam += 8*FRACUNIT; } - else if (p->mo->salty_zoffset >= 0 && cv_saltysquish.value) + else if (cv_saltysquish.value && pmo->salty_zoffset >= 0) { // goofy ahh hack - p->mo->spriteyscale += (mos/8); - p->mo->spritexscale -= (mos/8); + pmo->spriteyscale += (FRACUNIT/8); + pmo->spritexscale -= (FRACUNIT/8); } - p->mo->spriteyoffset = FixedMul(p->mo->salty_zoffset, cv_saltyheight.value); + pmo->spriteyoffset = FixedMul(pmo->salty_zoffset, cv_saltyheight.value); if (cv_saltyhopsfx.value) { - if (S_SoundPlaying(p->mo, sfx_screec)) - S_StopSoundByID(p->mo, sfx_screec); - if (S_SoundPlaying(p->mo, sfx_drift)) - S_StopSoundByID(p->mo, sfx_drift); + if (S_SoundPlaying(pmo, sfx_screec)) + S_StopSoundByID(pmo, sfx_screec); + if (S_SoundPlaying(pmo, sfx_drift)) + S_StopSoundByID(pmo, sfx_drift); } } - else if (p->mo->salty_tapping && P_IsObjectOnGround(p->mo) && !p->kartstuff[k_spinouttimer] && !p->kartstuff[k_squishedtimer]) + else if (pmo->salty_tapping && onground && !player->kartstuff[k_spinouttimer] && !player->kartstuff[k_squishedtimer]) { - p->mo->salty_jump = true; - p->mo->salty_zoffset = 0; - p->mo->salty_momz = 6*mos; + pmo->salty_jump = true; + pmo->salty_zoffset = 0; + pmo->salty_momz = 6*FRACUNIT; if (cv_saltyhopsfx.value) - S_StartSound(p->mo, sfx_s25a); + S_StartSound(pmo, sfx_s25a); } } diff --git a/src/p_tick.c b/src/p_tick.c index 77a386a2d..82e600a03 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -523,7 +523,7 @@ static inline void P_ResetSpriteStuff(void) mo = (mobj_t *)th; - if (mo->sprite == SPR_NULL || mo->flags2 & MF2_DONTDRAW || mo->type == MT_SHADOW) + if (!mo || (mo->sprite == SPR_NULL) || (mo->flags2 & MF2_DONTDRAW) || (mo->type == MT_SHADOW)) continue; mo->spritexscale = mo->realxscale; @@ -629,7 +629,7 @@ void P_Ticker(boolean run) } #endif } - + ps_lua_mobjhooks.value.i = 0; ps_checkposition_calls.value.i = 0; From fd14976a4dabaf83c4a14fb439f42044090bdd7a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Apr 2025 21:46:05 +0200 Subject: [PATCH 194/350] optimize colourcube conditional checks screw u atoi --- src/v_video.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index 4018ec98a..f8196d652 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -129,6 +129,7 @@ static boolean InitCube(void) } } }; + float desatur[3]; // grey float globalgammamul, globalgammaoffs; boolean doinggamma; @@ -136,7 +137,9 @@ static boolean InitCube(void) if (loaded_config == false) return false; -#define diffcons(cv) (cv.value != atoi(cv.defaultvalue)) +#define diffcons(cv) (strcmp(cv.string, cv.defaultvalue)) +#define diffconsgamma(cv) (cv.value != 0) +#define diffconssat(cv) (cv.value != 10) #ifdef BACKWARDSCOMPATCORRECTION doinggamma = (cv_globalgamma.value < 0); //dont mess up gamma when raising brightness pls @@ -156,12 +159,12 @@ static boolean InitCube(void) || diffcons(cv_chue) || diffcons(cv_bhue) || diffcons(cv_mhue) - || diffcons(cv_rgamma) - || diffcons(cv_ygamma) - || diffcons(cv_ggamma) - || diffcons(cv_cgamma) - || diffcons(cv_bgamma) - || diffcons(cv_mgamma)) // set the gamma'd/hued positions (saturation is done later) + || diffconsgamma(cv_rgamma) + || diffconsgamma(cv_ygamma) + || diffconsgamma(cv_ggamma) + || diffconsgamma(cv_cgamma) + || diffconsgamma(cv_bgamma) + || diffconsgamma(cv_mgamma)) // set the gamma'd/hued positions (saturation is done later) { float mod, tempgammamul, tempgammaoffs; @@ -219,7 +222,7 @@ static boolean InitCube(void) #define dosaturation(a, e) a = ((1 - work)*e + work*a) #define docvsat(cv_sat, hue, gamma, r, g, b) \ - if diffcons(cv_sat)\ + if diffconssat(cv_sat)\ {\ float work, mod, tempgammamul, tempgammaoffs;\ apply = true;\ @@ -244,7 +247,7 @@ static boolean InitCube(void) #undef gammascale - if diffcons(cv_globalsaturation) + if diffconssat(cv_globalsaturation) { float work = (cv_globalsaturation.value/10.0); @@ -265,6 +268,8 @@ static boolean InitCube(void) #undef dosaturation #undef diffcons +#undef diffconsgamma +#undef diffconssat if (!apply) return false; @@ -442,10 +447,6 @@ static void LoadPalette(const char *lumpname) pLocalPalette[i].s.alpha = 0xFF; // lerp of colour cubing! if you want, make it smoother yourself - - if (!Cubeapply) - continue; - V_CubeApply(&pLocalPalette[i].s.red, &pLocalPalette[i].s.green, &pLocalPalette[i].s.blue); } } From 0d9ac01fea892a86250d1aacfe115486224477bf Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Apr 2025 22:33:33 +0200 Subject: [PATCH 195/350] disable titlescreen demos if any addon (but musicpacks) are loaded read comment not a fan of this, but better than ppl constantly crashing --- src/f_finale.c | 4 ++-- src/v_video.c | 36 +++++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index fbee630b6..1b8d236fe 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1060,8 +1060,8 @@ void F_TitleScreenTicker(boolean run) return; // are demos disabled? - if (!cv_rollingdemos.value) - return; + if (!cv_rollingdemos.value || modifiedgame) // occasionally mappacks supply invalid replays which means the game crashes almost always when you idle on the titlescreen too long + return; // we check for all addons since added luas/socs and stuff like that makes them desynch like crazy so why would you even watch them? // Wait for a while (for the music to finish, preferably) // before starting demos diff --git a/src/v_video.c b/src/v_video.c index f8196d652..1d0b7ddfb 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -663,6 +663,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca } v_colormap = NULL; + if (colormap) { v_colormap = colormap; @@ -671,21 +672,25 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca dupx = vid.dupx; dupy = vid.dupy; - if (scrn & V_SCALEPATCHMASK) switch ((scrn & V_SCALEPATCHMASK) >> V_SCALEPATCHSHIFT) + + if (scrn & V_SCALEPATCHMASK) { - case 1: // V_NOSCALEPATCH - dupx = dupy = 1; - break; - case 2: // V_SMALLSCALEPATCH - dupx = vid.smalldupx; - dupy = vid.smalldupy; - break; - case 3: // V_MEDSCALEPATCH - dupx = vid.meddupx; - dupy = vid.meddupy; - break; - default: - break; + switch ((scrn & V_SCALEPATCHMASK) >> V_SCALEPATCHSHIFT) + { + case 1: // V_NOSCALEPATCH + dupx = dupy = 1; + break; + case 2: // V_SMALLSCALEPATCH + dupx = vid.smalldupx; + dupy = vid.smalldupy; + break; + case 3: // V_MEDSCALEPATCH + dupx = vid.meddupx; + dupy = vid.meddupy; + break; + default: + break; + } } // only use one dup, to avoid stretching (har har) @@ -910,7 +915,8 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ deststop = desttop + vid.rowbytes * vid.height; - if (scrn & V_NOSCALESTART) { + if (scrn & V_NOSCALESTART) + { x >>= FRACBITS; y >>= FRACBITS; desttop += (y*vid.width) + x; From 69d86e69cb24b5802c2400b923ac8abaff042143 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 14 Apr 2025 11:27:18 +0200 Subject: [PATCH 196/350] bunch of stuff from lugstuff - precalc some float division for ogl transform code - use strlen for the custom lua cvar menu setup - mostly just cleanup --- src/Makefile | 2 +- src/d_main.c | 17 ++++++++-------- src/d_net.c | 16 --------------- src/d_net.h | 3 +-- src/d_netfil.c | 5 +++-- src/hardware/hw_main.c | 9 ++++++--- src/i_time.c | 4 ++-- src/info.c | 2 +- src/k_kart.c | 5 ++++- src/lua_consolelib.c | 9 ++------- src/m_aatree.c | 4 ---- src/r_draw8.c | 44 +++++++++++++++++++++++++++++------------- src/r_fps.c | 12 ++---------- src/sdl/i_system.c | 4 +--- src/sdl/sdlmain.h | 1 - 15 files changed, 62 insertions(+), 75 deletions(-) diff --git a/src/Makefile b/src/Makefile index 0da69a2ce..9244c30fd 100644 --- a/src/Makefile +++ b/src/Makefile @@ -88,7 +88,7 @@ ifeq ($(OS),Windows_NT) # all windows are Windows_NT... $(info Detected a Windows system, compiling for 32-bit MinGW SDL2...) MINGW=1 endif - + SDL=1 WINDOWSHELL=1 NOOBJDUMP=1 diff --git a/src/d_main.c b/src/d_main.c index fc1ce735d..39f354ba5 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -825,7 +825,7 @@ void D_SRB2Loop(void) if (interp) { - renderdeltatics = FLOAT_TO_FIXED(deltatics); + renderdeltatics = FloatToFixed(deltatics); if (!(paused || P_AutoPause()) && deltatics < 1.0 && !hu_stopped) { @@ -929,6 +929,7 @@ void D_SRB2Loop(void) void D_StartTitle(void) { INT32 i; + if (netgame) { if (gametype == GT_RACE) // SRB2kart @@ -1184,17 +1185,15 @@ void D_CleanFile(char **filearray) static boolean AddIWAD(void) { - char * path = va(pandf,srb2path,"srb2.srb"); + char * path = va(pandf, srb2path, "srb2.srb"); if (FIL_ReadFileOK(path)) { D_AddFile(path, startupwadfiles); return true; } - else - { - return false; - } + + return false; } // extra graphic patches for saturn specific thingies @@ -1236,11 +1235,11 @@ static void IdentifyVersion(void) // get the current directory (possible problem on NT with "." as current dir) if (srb2waddir) { - strlcpy(srb2path,srb2waddir,sizeof (srb2path)); + strlcpy(srb2path, srb2waddir, sizeof(srb2path)); } else { - if (getcwd(srb2path, 256) != NULL) + if (getcwd(srb2path, sizeof(srb2path))) srb2waddir = srb2path; else { @@ -1249,7 +1248,7 @@ static void IdentifyVersion(void) } // Load the IWAD - if (! AddIWAD()) + if (!AddIWAD()) { I_Error("SRB2.SRB not found! Expected in %s\n", srb2waddir); } diff --git a/src/d_net.c b/src/d_net.c index 8565fb6b1..8a33bde55 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1118,7 +1118,6 @@ boolean HGetPacket(void) while(true) { - //nodejustjoined = I_NetGet(); I_NetGet(); if (doomcom->remotenode == -1) // No packet received @@ -1147,21 +1146,6 @@ boolean HGetPacket(void) DebugPrintpacket("GET"); #endif - /*// If a new node sends an unexpected packet, just ignore it - if (nodejustjoined && server - && !(netbuffer->packettype == PT_ASKINFO - || netbuffer->packettype == PT_SERVERINFO - || netbuffer->packettype == PT_PLAYERINFO - || netbuffer->packettype == PT_REQUESTFILE - || netbuffer->packettype == PT_ASKINFOVIAMS - || netbuffer->packettype == PT_CLIENTJOIN)) - { - DEBFILE(va("New node sent an unexpected %s packet\n", packettypename[netbuffer->packettype])); - //CONS_Alert(CONS_NOTICE, "New node sent an unexpected %s packet\n", packettypename[netbuffer->packettype]); - Net_CloseConnection(doomcom->remotenode | FORCECLOSE); - continue; - }*/ - // Proceed the ack and ackreturn field if (!Processackpak()) continue; // discarded (duplicated) diff --git a/src/d_net.h b/src/d_net.h index f29edb1aa..1b6cd905c 100644 --- a/src/d_net.h +++ b/src/d_net.h @@ -48,8 +48,7 @@ extern boolean serverrunning; void Net_AckTicker(void); // If reliable return true if packet sent, 0 else -boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, - size_t packetlength); +boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlength); boolean HGetPacket(void); void D_SetDoomcom(void); #ifndef NONET diff --git a/src/d_netfil.c b/src/d_netfil.c index fc03a6ab3..b37fb6d95 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -554,13 +554,13 @@ INT32 CL_CheckFiles(void) { if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD || fileneeded[i].status == FS_FALLBACK) downloadrequired = true; - + if (fileneeded[i].status != FS_OPEN) filestoload++; if (fileneeded[i].status != FS_NOTCHECKED) //since we're running this over multiple tics now, its possible for us to come across files checked in previous tics continue; - + CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename); // Check in already loaded files @@ -1053,6 +1053,7 @@ void Got_Filetxpak(void) } I_Error("Received a file not requested (file id: %d, file status: %s)\n", filenum, s); } + // Send ack back quickly if (++filetime == 3) { diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9f95c1c26..64639c43f 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5237,6 +5237,9 @@ void HWR_BuildSkyDome(void) static boolean drewsky = false; +// precompute to save a bit of division +static const float FINEDEGREE = (360.0f/(float)FINEANGLES); + static void HWR_DrawSkyBackground(void) { FTransform dometransform; @@ -5255,7 +5258,7 @@ static void HWR_DrawSkyBackground(void) //04/01/2000: Hurdler: added for T&L // It should replace all other gl_viewxxx when finished HWR_SetTransformAiming(&dometransform); - dometransform.angley = (float)((viewangle-ANGLE_270)>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); + dometransform.angley = (float)((viewangle-ANGLE_270)>>ANGLETOFINESHIFT)*(FINEDEGREE); HWR_GetTexture(texturetranslation[skytexture], false); @@ -5322,7 +5325,7 @@ static void HWR_SetTransformAiming(FTransform *trans) trans->shearing = false; gl_aimingangle = aimingangle; } - trans->anglex = (float)(gl_aimingangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); + trans->anglex = (float)(gl_aimingangle>>ANGLETOFINESHIFT)*(FINEDEGREE); } void HWR_SetTransform(float fpov) @@ -5348,7 +5351,7 @@ void HWR_SetTransform(float fpov) atransform.scalez = 1; HWR_SetTransformAiming(&atransform); - atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); + atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(FINEDEGREE); gl_viewludsin = FIXED_TO_FLOAT(FINECOSINE(gl_aimingangle>>ANGLETOFINESHIFT)); gl_viewludcos = FIXED_TO_FLOAT(-FINESINE(gl_aimingangle>>ANGLETOFINESHIFT)); diff --git a/src/i_time.c b/src/i_time.c index 931696379..2d136f27e 100644 --- a/src/i_time.c +++ b/src/i_time.c @@ -58,7 +58,7 @@ void I_UpdateTime(fixed_t timescale) tic_t realtics; // get real tics - ticratescaled = (double)TICRATE * FIXED_TO_FLOAT(timescale); + ticratescaled = (double)TICRATE * FixedToFloat(timescale); enterprecise = I_GetPreciseTime(); elapsedseconds = (double)((INT64)enterprecise - oldenterprecise) / I_GetPrecisePrecision(); @@ -77,6 +77,6 @@ void I_UpdateTime(fixed_t timescale) { double fractional, integral; fractional = modf(tictimer * ticratescaled, &integral); - g_time.timefrac = FLOAT_TO_FIXED(fractional); + g_time.timefrac = FloatToFixed(fractional); } } diff --git a/src/info.c b/src/info.c index 7afc76bf6..fcf0029e9 100644 --- a/src/info.c +++ b/src/info.c @@ -2614,7 +2614,7 @@ state_t states[NUMSTATES] = {SPR_KINV, FF_FULLBRIGHT|1, 1, {NULL}, 0, 0, S_KARTINVULN_SMALL3}, // S_KARTINVULN_SMALL2 {SPR_KINV, FF_FULLBRIGHT|2, 1, {NULL}, 0, 0, S_KARTINVULN_SMALL4}, // S_KARTINVULN_SMALL3 {SPR_KINV, FF_FULLBRIGHT|3, 1, {NULL}, 0, 0, S_KARTINVULN_SMALL5}, // S_KARTINVULN_SMALL4 - {SPR_KINV, FF_FULLBRIGHT|4, 1, {NULL}, 0, 0, S_NULL}, // S_KARTINVULN_SMALL5 + {SPR_KINV, FF_FULLBRIGHT|4, 1, {NULL}, 0, 0, S_NULL}, // S_KARTINVULN_SMALL5 {SPR_KINV, FF_FULLBRIGHT|1, 1, {NULL}, 0, 0, S_KARTINVULN_LARGE2}, // S_KARTINVULN_LARGE1 {SPR_KINV, FF_FULLBRIGHT|2, 1, {NULL}, 0, 0, S_KARTINVULN_LARGE3}, // S_KARTINVULN_LARGE2 diff --git a/src/k_kart.c b/src/k_kart.c index 5f45dff2c..1d2bde533 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9123,7 +9123,9 @@ static void K_DrawKartPositionNum(INT32 num) while (num) { if (win) // 1st place winner? You get rainbows!! + { localpatch = kp_winnernum[(leveltime % (NUMWINFRAMES*3)) / 3]; + } else if (stplyr->laps+1 >= cv_numlaps.value || stplyr->exiting) // Check for the final lap, or won { // Alternate frame every three frames @@ -10627,6 +10629,7 @@ static void K_drawKartMinimap(void) if (gamestate != GS_LEVEL) return; + // Only draw for the first player if (stplyrnum != 0) return; @@ -11563,7 +11566,7 @@ void K_drawKartHUD(void) && stplyr->kartstuff[k_lapanimation] && !stplyr->exiting && stplyr->laptime[LAP_LAST] != 0 - && !midgamejoin) + && !midgamejoin) // due to vanilla compat, we cannot synch this oh well { if ((stplyr->kartstuff[k_lapanimation] / 5) & 1) { diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 4ac6fb898..a66f14115 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -476,13 +476,10 @@ static int lib_cvRegisterVar(lua_State *L) if (!(((cvar->flags & CV_HIDEN)) || (cvar->flags & CV_NOSHOWHELP)) && (cvar->PossibleValue || !(cvar->value == 0 && stricmp(cvar->string, "0")))) { - char *temp = NULL; - if (!category) { - temp = strdup(wadfiles[numwadfiles - 1]->filename); - nameonly(temp); - + char *temp = wadfiles[numwadfiles - 1]->filename; + temp += strlen(temp) - nameonlylength(temp); category = temp; } @@ -490,8 +487,6 @@ static int lib_cvRegisterVar(lua_State *L) M_SlotCvarIntoModMenu(cvar, category, menu_name); else M_SlotCvarIntoModMenu(cvar, category, cvar->name); - - free (temp); } // return cvar userdata diff --git a/src/m_aatree.c b/src/m_aatree.c index ece4f0acb..a6178cac1 100644 --- a/src/m_aatree.c +++ b/src/m_aatree.c @@ -20,7 +20,6 @@ typedef struct aatree_node_s { - INT32 level; INT32 key; void* value; @@ -98,9 +97,7 @@ static aatree_node_t *M_AATreeSet_Node(aatree_node_t *node, UINT32 flags, INT32 if (!node) { // Nothing here, so just add where we are - node = Z_Malloc(sizeof (aatree_node_t), PU_STATIC, NULL); - node->level = 1; node->key = key; if (value && (flags & AATREE_ZUSER)) Z_SetUser(value, &node->value); else node->value = value; @@ -152,7 +149,6 @@ void *M_AATreeGet(aatree_t *aatree, INT32 key) return M_AATreeGet_Node(aatree->root, key); } - static void M_AATreeIterate_Node(aatree_node_t *node, aatree_iter_t callback) { if (node->left) M_AATreeIterate_Node(node->left, callback); diff --git a/src/r_draw8.c b/src/r_draw8.c index d55663368..cfc6ac04d 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -745,6 +745,9 @@ void R_DrawSpan_8 (void) register size_t count = (ds_x2 - ds_x1 + 1); size_t i; + xposition = ds_xfrac; yposition = ds_yfrac; + xstep = ds_xstep; ystep = ds_ystep; + // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest // can be used for the fraction part. This allows calculation of the memory address in the // texture with two shifts, an OR and one AND. (see below) @@ -752,8 +755,12 @@ void R_DrawSpan_8 (void) // bit per power of two (obviously) // Ok, because I was able to eliminate the variable spot below, this function is now FASTER // than the original span renderer. Whodathunkit? - xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup; - xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; + xposition <<= nflatshiftup; yposition <<= nflatshiftup; + xstep <<= nflatshiftup; ystep <<= nflatshiftup; + + source = ds_source; + colormap = ds_colormap; + dest = ylookup[ds_y] + columnofs[ds_x1]; if (dest+8 > deststop) { @@ -794,13 +801,14 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end) { // ZDoom uses a different lighting setup to us, and I couldn't figure out how to adapt their version // of this function. Here's my own. - INT32 i; + INT32 left = ds_x1, right = ds_x2; fixed_t step = (end-start)/(ds_x2-ds_x1+1); + INT32 i; // I wanna do some optimizing by checking for out-of-range segments on either side to fill in all at once, // but I'm too bad at coding to not crash the game trying to do that. I guess this is fast enough for now... - for (i = ds_x1; i <= ds_x2; i++) + for (i = left; i <= right; i++) { tiltlighting[i] = (start += step) >> FRACBITS; @@ -1534,14 +1542,17 @@ void R_DrawTranslucentSpan_8 (void) fixed_t xstep, ystep; register UINT32 bit; - const UINT8 *source = ds_source; - const UINT8 *colormap = ds_colormap; - register UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1]; + UINT8 *source; + UINT8 *colormap; + register UINT8 *dest; const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; register size_t count = (ds_x2 - ds_x1 + 1); size_t i; + xposition = ds_xfrac; yposition = ds_yfrac; + xstep = ds_xstep; ystep = ds_ystep; + // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest // can be used for the fraction part. This allows calculation of the memory address in the // texture with two shifts, an OR and one AND. (see below) @@ -1549,8 +1560,12 @@ void R_DrawTranslucentSpan_8 (void) // bit per power of two (obviously) // Ok, because I was able to eliminate the variable spot below, this function is now FASTER // than the original span renderer. Whodathunkit? - xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup; - xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; + xposition <<= nflatshiftup; yposition <<= nflatshiftup; + xstep <<= nflatshiftup; ystep <<= nflatshiftup; + + source = ds_source; + colormap = ds_colormap; + dest = ylookup[ds_y] + columnofs[ds_x1]; while (count >= 8) { @@ -1586,10 +1601,10 @@ void R_DrawTranslucentWaterSpan_8(void) UINT32 xstep, ystep; register UINT32 bit; - const UINT8 *source = ds_source; - const UINT8 *colormap = ds_colormap; - register UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1]; - register UINT8 *dsrc; + UINT8 *source; + UINT8 *colormap; + register UINT8 *dest; + UINT8 *dsrc; register size_t count; size_t i; @@ -1604,6 +1619,9 @@ void R_DrawTranslucentWaterSpan_8(void) xposition = ds_xfrac << nflatshiftup; yposition = (ds_yfrac + ds_waterofs) << nflatshiftup; xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; + source = ds_source; + colormap = ds_colormap; + dest = ylookup[ds_y] + columnofs[ds_x1]; dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; count = ds_x2 - ds_x1 + 1; diff --git a/src/r_fps.c b/src/r_fps.c index c92fb6ab4..3d10449cc 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -171,14 +171,7 @@ void R_InterpolateView(fixed_t frac, boolean forceinvalid) if (frac > FRACUNIT) frac = FRACUNIT; - if (viewcontext >= VIEWCONTEXT_SKY1) - { - i = viewcontext - VIEWCONTEXT_SKY1; - } - else - { - i = viewcontext - VIEWCONTEXT_PLAYER1; - } + i = R_GetViewNumber(); if (oldview_invalid[i] != 0 || forceinvalid) { @@ -211,8 +204,7 @@ void R_UpdateViewInterpolation(void) { pview_old[i] = pview_new[i]; skyview_old[i] = skyview_new[i]; - - if (oldview_invalid[i]) oldview_invalid[i]--; + if (oldview_invalid[i] > 0) oldview_invalid[i]--; } last_view_update = I_GetTime(); diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 12e194c67..1262707a8 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -344,7 +344,7 @@ static void write_backtrace(bt_crash_reason_t reason) fprintf(out, "Program name: %s %s\n", SRB2APPLICATION, VERSIONSTRING); if (compdate && comptime && comprevision && compbranch) - fprintf(out, "Compiled: %s %s, commit %s, branch %s\n", compdate, comptime, comprevision, compbranch); + fprintf(out, "Compiled: %s %s, commit %s, branch %s\n", compdate, comptime, comprevision, compbranch); if (gamestate == GS_LEVEL) { @@ -1248,8 +1248,6 @@ void I_GetJoystickEvents(UINT8 index) \param fname name of joystick \return axises - - */ static int joy_open(int playerIndex, int joyIndex) { diff --git a/src/sdl/sdlmain.h b/src/sdl/sdlmain.h index 0ba8da762..b0def402d 100644 --- a/src/sdl/sdlmain.h +++ b/src/sdl/sdlmain.h @@ -54,7 +54,6 @@ typedef struct SDLJoyInfo_s int hats; /// number of balls int balls; - } SDLJoyInfo_t; /** \brief SDL info about controller 1 From 5c6c46848ead6eee4ad73e6189cf119eba8c587f Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 14 Apr 2025 10:30:26 +0200 Subject: [PATCH 197/350] missed those --- src/hardware/hw_draw.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index bc655e935..70a2e6cc8 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -872,8 +872,8 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color) if (fy + fh > vid.height) fh = fvh - fy; - fx = -1.0f + fx / (vid.width / 2.0f); - fy = 1.0f - fy / (vid.height / 2.0f); + fx = -1.0f + fx / (fvw / 2.0f); + fy = 1.0f - fy / (fvh / 2.0f); fw = fw / (fvw / 2.0f); fh = fh / (fvh / 2.0f); @@ -985,8 +985,8 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 if (fy + fh > vid.height) fh = fvh - fy; - fx = -1.0f + fx / (vid.width / 2.0f); - fy = 1.0f - fy / (vid.height / 2.0f); + fx = -1.0f + fx / (fvw / 2.0f); + fy = 1.0f - fy / (fvh / 2.0f); fw = fw / (fvw / 2.0f); fh = fh / (fvh / 2.0f); @@ -1098,8 +1098,8 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) if (fy + fh > vid.height) fh = fvh - fy; - fx = -1.0f + fx / (vid.width / 2.0f); - fy = 1.0f - fy / (vid.height / 2.0f); + fx = -1.0f + fx / (fvw / 2.0f); + fy = 1.0f - fy / (fvh / 2.0f); fw = fw / (fvw / 2.0f); fh = fh / (fvh / 2.0f); From 8db082501e1e27c48c493992cd3fc3e177291d54 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 14 Apr 2025 11:30:16 +0200 Subject: [PATCH 198/350] only holepunch uses this --- src/i_tcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index 79373abc8..c27fa2480 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -599,6 +599,7 @@ void Command_Numnodes(void) #endif #ifndef NONET +#ifdef HOLEPUNCH /* not one of the reserved "local" addresses */ static boolean is_external_address (UINT32 p) @@ -624,7 +625,6 @@ is_external_address (UINT32 p) } } -#ifdef HOLEPUNCH static boolean hole_punch(ssize_t c) { @@ -650,7 +650,7 @@ static boolean hole_punch(ssize_t c) } } -#endif +#endif //ifdef HOLEPUNCH // Returns true if a packet was received from a new node, false in all other cases static boolean SOCK_Get(void) From c8b318ba8e37d108a30887483dd6e362e1b103eb Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 14 Apr 2025 11:41:09 +0200 Subject: [PATCH 199/350] minor branching stuff --- src/hardware/hw_main.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 64639c43f..43c10745c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1226,7 +1226,7 @@ static void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf) wallVerts[0].s = wallVerts[3].s = 0; wallVerts[2].s = wallVerts[1].s = 0; - if (gl_collect_skywalls) + if (UNLIKELY(gl_collect_skywalls)) { HWR_SkyWallList_Add(wallVerts); } @@ -2229,7 +2229,7 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) } // using this check with portals causes weird culling issues on ante-station - if (!portalclipline && (afrontsector == viewsector || abacksector == viewsector)) + if (LIKELY(!portalclipline) && (afrontsector == viewsector || abacksector == viewsector)) { fixed_t viewf1, viewf2, viewc1, viewc2; if (afrontsector == viewsector) @@ -2259,10 +2259,7 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) if (backc1 <= frontf1 && backc2 <= frontf2) { checkforemptylines = false; - if (portalclipline)// during portal rendering view position may cause undesired culling and the above code has some wrong side effects - return false; - else - return true; + return (!portalclipline); // during portal rendering view position may cause undesired culling and the above code has some wrong side effects } // here we're talking about floors higher than ceilings, don't even bother either. @@ -3143,7 +3140,7 @@ doaddline: // without talking about the overdraw of course. sub->sector->validcount = validcount;/// \todo fix that in a better way - if (numPolyObjects) + if (UNLIKELY(numPolyObjects)) { while (count--) { @@ -5403,7 +5400,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl const boolean skybox = (skyboxmo[0] && cv_skybox.value); const boolean useportals = cv_glportals.value && gl_maphasportals && allow_portals; - bspfunc bspFunc = portalclipline ? HWR_RenderPortalBSPNode : HWR_RenderBSPNode; + bspfunc bspFunc = (useportals && portalclipline) ? HWR_RenderPortalBSPNode : HWR_RenderBSPNode; portallist.base = portallist.cap = NULL; @@ -5506,7 +5503,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl HWR_SortVisSprites(); PS_STOP_TIMING(ps_hw_spritesorttime); PS_START_TIMING(ps_hw_spritedrawtime); - if (!cv_glmdls.value) + if (LIKELY(!cv_glmdls.value)) HWR_DrawSprites(); else HWR_DrawModels(); From b2f22a379fc0c5e899176ed43301fc28f65b597e Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 14 Apr 2025 12:03:37 +0200 Subject: [PATCH 200/350] whoops --- src/m_aatree.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/m_aatree.c b/src/m_aatree.c index a6178cac1..45482f6f3 100644 --- a/src/m_aatree.c +++ b/src/m_aatree.c @@ -20,6 +20,7 @@ typedef struct aatree_node_s { + INT32 level; INT32 key; void* value; @@ -98,6 +99,7 @@ static aatree_node_t *M_AATreeSet_Node(aatree_node_t *node, UINT32 flags, INT32 { // Nothing here, so just add where we are node = Z_Malloc(sizeof (aatree_node_t), PU_STATIC, NULL); + node->level = 1; node->key = key; if (value && (flags & AATREE_ZUSER)) Z_SetUser(value, &node->value); else node->value = value; From b2e0ad58f969f6f4c73eb42462e5654c463621fc Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 14 Apr 2025 22:50:39 +0200 Subject: [PATCH 201/350] revert using modulu for frac calcs for colum drawers this is fucking slow for some reason --- src/r_draw8.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/r_draw8.c b/src/r_draw8.c index cfc6ac04d..f9e3e12e7 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -77,7 +77,10 @@ void R_DrawColumn_8(void) } else { - frac %= heightmask; + while (frac >= heightmask) + { + frac -= heightmask; + } } do @@ -115,7 +118,10 @@ void R_DrawColumn_8(void) frac += fracstep; } - frac %= heightmask; + while (frac >= heightmask) + { + frac -= heightmask; + } } while (--count); } else @@ -197,7 +203,10 @@ void R_Draw2sMultiPatchColumn_8(void) } else { - frac %= heightmask; + while (frac >= heightmask) + { + frac -= heightmask; + } } do @@ -240,7 +249,10 @@ void R_Draw2sMultiPatchColumn_8(void) frac += fracstep; } - frac %= heightmask; + while (frac >= heightmask) + { + frac -= heightmask; + } } while (--count); } else @@ -334,7 +346,10 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) } else { - frac %= heightmask; + while (frac >= heightmask) + { + frac -= heightmask; + } } do @@ -377,7 +392,10 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) frac += fracstep; } - frac %= heightmask; + while (frac >= heightmask) + { + frac -= heightmask; + } } while (--count); } else @@ -512,7 +530,10 @@ void R_DrawTranslucentColumn_8(void) } else { - frac %= heightmask; + while (frac >= heightmask) + { + frac -= heightmask; + } } do @@ -618,7 +639,10 @@ void R_DrawTranslatedTranslucentColumn_8(void) } else { - frac %= heightmask; + while (frac >= heightmask) + { + frac -= heightmask; + } } do From 50656b7afca5cc56a5a7312dd61f7a90f7d9a935 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 15 Apr 2025 03:15:04 +0200 Subject: [PATCH 202/350] Revert "flexible array stuff for columnofs" This reverts commit 37a394ebaa63db043ff11a3526100fcb4938239e. --- src/r_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_defs.h b/src/r_defs.h index b75f9552d..54a6d948d 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -653,7 +653,7 @@ typedef struct INT16 height; INT16 leftoffset; // pixels to the left of origin INT16 topoffset; // pixels below the origin - INT32 columnofs[]; // only [width] used + INT32 columnofs[8]; // only [width] used // the [0] is &columnofs[width] } patch_t; From 13589499f8a22c92a7463dea6530c1b3f54df46c Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 15 Apr 2025 03:51:01 +0200 Subject: [PATCH 203/350] cleanup rotated patch creation kill unused adjustfeet code add missing clamping use malloc since stuff gets filled with 0xFF00 anyways kill rotated sprite "type" since its unused too simplify getpatchpixel a little --- src/hardware/hw_main.c | 2 +- src/lua_hudlib.c | 2 +- src/r_defs.h | 4 +-- src/r_patch.c | 65 ++++++++++++++++++++++++++++-------------- src/r_patch.h | 7 +---- src/r_things.c | 8 ++---- 6 files changed, 50 insertions(+), 38 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 43c10745c..4e6f352ef 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4787,7 +4787,7 @@ static void HWR_ProjectSprite(mobj_t *thing) pitchnroll += rollangle; rollangle = R_GetRollAngle(pitchnroll); - rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle); + rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, sprinfo, rollangle); if (rotsprite != NULL) { diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index f071f8eba..dc2e8f824 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -516,7 +516,7 @@ static int libd_getSpritePatch(lua_State *L) if (rot) { - patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<flip & (1<= 0 && x < SHORT(patch->width)) + if (patch == NULL) + I_Error("GetPatchPixel: patch == NULL"); + + width = SHORT(patch->width); + + if (x >= 0 && x < width) { + INT32 colx = flip ? (width-1)-x : x; INT32 topdelta, prevdelta = -1; - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[flip ? (patch->width-1-x) : x])); + + column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[colx])); + while (column->topdelta != 0xff) { topdelta = column->topdelta; + if (topdelta <= prevdelta) topdelta += prevdelta; + prevdelta = topdelta; - source = (UINT8 *)(column) + 3; - for (ofs = 0; ofs < column->length; ofs++) + + ofs = (y - topdelta); + + if (y >= topdelta && ofs < column->length) { - if ((topdelta + ofs) == y) - return source[ofs]; + source = (UINT8 *)(column) + 3; + return source[ofs]; } + column = (column_t *)((UINT8 *)column + column->length + 4); } } @@ -512,22 +525,21 @@ angle_t R_RotationAngle(angle_t ang, angle_t camang, interpmobjstate_t *interp) FixedMul(FINESINE((camang) >> ANGLETOFINESHIFT), interp->slopepitch); } -patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, boolean adjustfeet, void *info, INT32 rotationangle) +patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, void *info, INT32 rotationangle) { rotsprite_t *rotsprite; spriteinfo_t *sprinfo = (spriteinfo_t *)info; INT32 idx = rotationangle; - UINT8 type = (adjustfeet ? 1 : 0); if (rotationangle < 1 || rotationangle >= ROTANGLES) return NULL; - rotsprite = sprite->rotated[type][spriteangle]; + rotsprite = sprite->rotated[spriteangle]; if (rotsprite == NULL) { rotsprite = RotatedPatch_Create(ROTANGLES); - sprite->rotated[type][spriteangle] = rotsprite; + sprite->rotated[spriteangle] = rotsprite; } if (flip) @@ -557,10 +569,6 @@ patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spri RotatedPatch_DoRotation(rotsprite, patch, rotationangle, xpivot, ypivot, flip); - //BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer - if (adjustfeet) - ((patch_t *)rotsprite->patches[idx])->topoffset += FEETADJUST>>FRACBITS; - // free image data Z_Free(patch); } @@ -576,6 +584,7 @@ rotsprite_t *RotatedPatch_Create(INT32 numangles) return rotsprite; } + static void RotatedPatch_CalculateDimensions( INT32 width, INT32 height, fixed_t ca, fixed_t sa, @@ -601,6 +610,7 @@ static void RotatedPatch_CalculateDimensions( void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip) { UINT32 i; + patch_t *rotated; UINT16 *rawdst, *rawconv; @@ -657,7 +667,7 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle size = (newwidth * newheight); if (!size) size = (width * height); - rawdst = Z_Calloc(size * sizeof(UINT16), PU_STATIC, NULL); + rawdst = Z_Malloc(size * sizeof(UINT16), PU_STATIC, NULL); for (i = 0; i < size; i++) rawdst[i] = 0xFF00; @@ -673,9 +683,20 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle sx >>= FRACBITS; sy >>= FRACBITS; - + if (sx >= 0 && sy >= 0 && sx < width && sy < height) - rawdst[(dy*newwidth)+dx] = GetPatchPixel(patch, sx, sy, bflip); + { + rawdst[(dy * newwidth) + dx] = GetPatchPixel(patch, sx, sy, bflip); + + if (dx < minx) + minx = dx; + if (dy < miny) + miny = dy; + if (dx > maxx) + maxx = dx; + if (dy > maxy) + maxy = dy; + } } } @@ -713,7 +734,7 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle width = newwidth; height = newheight; } - + // make patch rotated = (patch_t *)R_MaskedFlatToPatch(rawconv, width, height, 0, 0, &size); diff --git a/src/r_patch.h b/src/r_patch.h index 447f1b4fc..75347df3c 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -40,7 +40,6 @@ typedef struct // Conversions between patches / flats / textures... boolean R_CheckIfPatch(lumpnum_t lump); -void *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize); // SpriteInfo extern spriteinfo_t spriteinfo[NUMSPRITES]; @@ -52,11 +51,7 @@ void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum); INT32 R_GetRollAngle(angle_t rollangle); angle_t R_RotationAngle(angle_t ang, angle_t camang, interpmobjstate_t *interp); -patch_t *Patch_GetRotatedSprite( - spriteframe_t *sprite, - size_t frame, size_t spriteangle, - boolean flip, boolean adjustfeet, - void *info, INT32 rotationangle); +patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, void *info, INT32 rotationangle); rotsprite_t *RotatedPatch_Create(INT32 numangles); void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip); diff --git a/src/r_things.c b/src/r_things.c index 1be7bb7c3..c70b279cf 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -151,8 +151,7 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch #ifdef ROTSPRITE for (r = 0; r < 16; r++) { - sprtemp[frame].rotated[0][r] = NULL; - sprtemp[frame].rotated[1][r] = NULL; + sprtemp[frame].rotated[r] = NULL; } #endif/*ROTSPRITE*/ @@ -592,9 +591,6 @@ void R_DrawMaskedColumn(column_t *column) basetexturemid = dc_texturemid; - if (column == NULL) - return; - for (; column->topdelta != 0xff ;) { // calculate unclipped screen coordinates @@ -1397,7 +1393,7 @@ static void R_ProjectSprite(mobj_t *thing) pitchnroll += rollangle; rollangle = R_GetRollAngle(pitchnroll); - rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle); + rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, sprinfo, rollangle); if (rotsprite != NULL) { From 8a80f0571ca7994ed789e962a6456fb0ca7f4506 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 15 Apr 2025 01:53:27 +0200 Subject: [PATCH 204/350] cleanup R_ProjectSprite --- src/r_things.c | 98 ++++++++++++++++++++++---------------------------- 1 file changed, 42 insertions(+), 56 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index c70b279cf..83d72b009 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1146,7 +1146,6 @@ fixed_t R_GetSpriteDirectionalLighting(angle_t angle) static void R_ProjectSprite(mobj_t *thing) { fixed_t tr_x, tr_y; - fixed_t gxt, gyt; fixed_t tx, tz; fixed_t xscale, yscale, sortscale; //added : 02-02-98 : aaargll..if I were a math-guy!!! @@ -1226,25 +1225,23 @@ static void R_ProjectSprite(mobj_t *thing) this_scale = interp.scale; + if (this_scale < 1) + return; + // transform the origin point tr_x = interp.x - viewx; tr_y = interp.y - viewy; - gxt = FixedMul(tr_x, viewcos); - gyt = -FixedMul(tr_y, viewsin); - - tz = gxt-gyt; + tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); // near/far distance // thing is behind view plane? if (!papersprite && (tz < FixedMul(MINZ, this_scale))) // papersprite clipping is handled later return; - gxt = -FixedMul(tr_x, viewsin); - gyt = FixedMul(tr_y, viewcos); - tx = -(gyt + gxt); + tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); // sideways distance // too far off the side? - if (!papersprite && abs(tx) > (INT64)tz<<2) // papersprite clipping is handled later + if (!papersprite && abs(tx) > FixedMul(tz, fovtan)<<2) // papersprite clipping is handled later return; // aspect ratio stuff @@ -1351,9 +1348,6 @@ static void R_ProjectSprite(mobj_t *thing) I_Assert(lump < max_spritelumps); - if ((thing->skin || thing->localskin) && K_GetMobjSkin(thing)->flags & SF_HIRES) - this_scale = FixedMul(this_scale, K_GetMobjSkin(thing)->highresscale); - spr_width = spritecachedinfo[lump].width; spr_height = spritecachedinfo[lump].height; spr_offset = spritecachedinfo[lump].offset; @@ -1415,6 +1409,14 @@ static void R_ProjectSprite(mobj_t *thing) // calculate edges of the shape spritexscale = interp.spritexscale; spriteyscale = interp.spriteyscale; + + if ((thing->skin || thing->localskin) && K_GetMobjSkin(thing)->flags & SF_HIRES) + { + fixed_t highresscale = ((skin_t *)thing->skin)->highresscale; + spritexscale = FixedMul(spritexscale, highresscale); + spriteyscale = FixedMul(spriteyscale, highresscale); + } + if (spritexscale < 1 || spriteyscale < 1) return; @@ -1445,16 +1447,9 @@ static void R_ProjectSprite(mobj_t *thing) tr_x += FixedMul(offset, cosmul); tr_y += FixedMul(offset, sinmul); - gxt = FixedMul(tr_x, viewcos); - gyt = -FixedMul(tr_y, viewsin); - tz = gxt-gyt; - yscale = FixedDiv(projectiony, tz); + tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); - gxt = -FixedMul(tr_x, viewsin); - gyt = FixedMul(tr_y, viewcos); - tx = -(gyt + gxt); - xscale = FixedDiv(projection, tz); - x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; + tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); // Get paperoffset (offset) and paperoffset (distance) paperoffset = -FixedMul(tr_x, cosmul) - FixedMul(tr_y, sinmul); @@ -1468,17 +1463,9 @@ static void R_ProjectSprite(mobj_t *thing) tr_x += FixedMul(offset2, cosmul); tr_y += FixedMul(offset2, sinmul); - gxt = FixedMul(tr_x, viewcos); - gyt = -FixedMul(tr_y, viewsin); - tz2 = gxt-gyt; - yscale2 = FixedDiv(projectiony, tz2); - //if (yscale2 < 64) return; // ditto + tz2 = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); - gxt = -FixedMul(tr_x, viewsin); - gyt = FixedMul(tr_y, viewcos); - tx2 = -(gyt + gxt); - xscale2 = FixedDiv(projection, tz2); - x2 = ((centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS); + tx2 = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); if (max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier return; @@ -1497,7 +1484,7 @@ static void R_ProjectSprite(mobj_t *thing) tz2 = FixedMul(MINZ, this_scale); } - if ((tx2 / 4) < -(FixedMul(tz2, fovtan)) || (tx / 4) > FixedMul(tz, fovtan)) // too far off the side? + if (tx2 < -(FixedMul(tz2, fovtan)<<2) || tx > FixedMul(tz, fovtan)<<2) // too far off the side? return; yscale = FixedDiv(projectiony, tz); @@ -1518,9 +1505,7 @@ static void R_ProjectSprite(mobj_t *thing) if (x2 < 0) return; - range = x2 - x1; - - if (range < 0) + if ((range = x2 - x1) <= 0) return; range++; // fencepost problem @@ -1532,9 +1517,9 @@ static void R_ProjectSprite(mobj_t *thing) return; } - scalestep = ((yscale2 - yscale)/range) ?: 1; - - if (scalestep == 0) + // Compatibility with MSVC - SSNTails + scalestep = ((yscale2 - yscale) / range); + if (!scalestep) scalestep = 1; xscale = FixedDiv(range<>FRACBITS; - x1 = centerx + (FixedMul(tx,xscale) / FRACUNIT); + x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; // off the right side? if (x1 > viewwidth) return; tx += offset2; - //x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--; - x2 = (centerx + (FixedMul(tx,xscale) / FRACUNIT)) - 1; + x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--; // off the left side if (x2 < 0) @@ -1689,20 +1672,23 @@ static void R_ProjectSprite(mobj_t *thing) } heightsec = thing->subsector->sector->heightsec; - if (viewplayer && viewplayer->mo && viewplayer->mo->subsector) + if (viewplayer->mo && viewplayer->mo->subsector) phs = viewplayer->mo->subsector->sector->heightsec; else phs = -1; if (heightsec != -1 && phs != -1) // only clip things which are in special sectors { + fixed_t top = gzt; + fixed_t bottom = interp.z; + if (viewz < sectors[phs].floorheight ? - interp.z >= sectors[heightsec].floorheight : - gzt < sectors[heightsec].floorheight) + bottom >= sectors[heightsec].floorheight : + top < sectors[heightsec].floorheight) return; if (viewz > sectors[phs].ceilingheight ? - gzt < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight : - interp.z >= sectors[heightsec].ceilingheight) + top < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight : + bottom >= sectors[heightsec].ceilingheight) return; } @@ -1781,15 +1767,6 @@ static void R_ProjectSprite(mobj_t *thing) else if (R_ThingIsFullDark(oldthing)) vis->cut |= SC_FULLDARK; - //Fab: lumppat is the lump number of the patch to use, this is different - // than lumpid for sprites-in-pwad : the graphics are patched -#ifdef ROTSPRITE - if (rotsprite != NULL) - vis->patch = rotsprite; - else -#endif - vis->patch = W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); - // // determine the colormap (lightlevel & special effects) // @@ -1816,6 +1793,15 @@ static void R_ProjectSprite(mobj_t *thing) vis->colormap = lights_array[lindex]; } + //Fab: lumppat is the lump number of the patch to use, this is different + // than lumpid for sprites-in-pwad : the graphics are patched +#ifdef ROTSPRITE + if (rotsprite != NULL) + vis->patch = rotsprite; + else +#endif + vis->patch = W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); + vis->precip = false; vis->vflip = vflip; From a6bebb2d911243f60b27cfcdb1868c7e4d01a012 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 15 Apr 2025 04:57:00 +0200 Subject: [PATCH 205/350] noooo dont free our lumppat for some reason this occasioncally causes an use after free?? our memory management honestly is a fucking mess ngl --- src/r_patch.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/r_patch.c b/src/r_patch.c index 968898bd1..36d550d3f 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -554,7 +554,7 @@ patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spri if (lump == LUMPERROR) return NULL; - patch = (patch_t *)W_CacheLumpNum(lump, PU_STATIC); + patch = (patch_t *)W_CachePatchNum(lump, PU_CACHE); // PU_LEVEL if (sprinfo->available) { @@ -568,9 +568,6 @@ patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spri } RotatedPatch_DoRotation(rotsprite, patch, rotationangle, xpivot, ypivot, flip); - - // free image data - Z_Free(patch); } return rotsprite->patches[idx]; From 9e53f3f8b0c4ad102eb752da8664bb81603e989c Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 15 Apr 2025 05:08:19 +0200 Subject: [PATCH 206/350] fuck off goddamit --- src/r_patch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_patch.c b/src/r_patch.c index 36d550d3f..ed8d5962d 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -554,7 +554,7 @@ patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spri if (lump == LUMPERROR) return NULL; - patch = (patch_t *)W_CachePatchNum(lump, PU_CACHE); // PU_LEVEL + patch = (patch_t *)W_CacheLumpNum(lump, PU_CACHE); // PU_LEVEL if (sprinfo->available) { From 53f68784fcfe9ec62fcd25014ebec133a1be0dfa Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 15 Apr 2025 12:46:40 +0200 Subject: [PATCH 207/350] fix PARANOIA compile --- src/p_saveg.c | 2 +- src/p_tick.c | 2 +- src/r_things.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index abbe2fbfb..b5f11cedb 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1866,7 +1866,7 @@ static void P_NetArchiveThinkers(savebuffer_t *save) continue; } #ifdef PARANOIA - else if (th->function.acp1 != P_RemoveThinkerDelayed) // wait garbage collection + else if (th->function.acp1 != (actionf_p1)P_RemoveThinkerDelayed) // wait garbage collection I_Error("unknown thinker type %p", th->function.acp1); #endif } diff --git a/src/p_tick.c b/src/p_tick.c index 82e600a03..9406d1be5 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -363,7 +363,7 @@ static inline void P_RunThinkers(void) for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next) { #ifdef PARANOIA - I_Assert(currentthinker->function.acp1 != NULL) + I_Assert(currentthinker->function.acp1 != NULL); #endif currentthinker->function.acp1(currentthinker); } diff --git a/src/r_things.c b/src/r_things.c index 83d72b009..c3a83880c 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -637,7 +637,7 @@ void R_DrawMaskedColumn(column_t *column) colfunc(); #ifdef PARANOIA else - I_Error("R_DrawMaskedColumn: Invalid ylookup for dc_yl %d", dc->yl); + I_Error("R_DrawMaskedColumn: Invalid ylookup for dc_yl %d", dc_yl); #endif } column = (column_t *)((UINT8 *)column + column->length + 4); From 7256fb9d62b86f96edc757247f1d8c5604239ada Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 15:55:06 +0200 Subject: [PATCH 208/350] port srb2s patch refactor still needs all the new purge tags then we should hopefully be free of use after frees and everything --- src/d_main.c | 2 +- src/hardware/hw_cache.c | 255 ++++++++++++++++++++++------------------ src/hardware/hw_data.h | 15 +-- src/hardware/hw_draw.c | 79 +++++++------ src/hardware/hw_glob.h | 33 ++++-- src/hardware/hw_main.c | 68 +++++------ src/hardware/hw_main.h | 10 +- src/hardware/hw_md2.c | 174 ++++++++++++++++----------- src/p_setup.c | 17 ++- src/r_data.c | 33 ++++-- src/r_defs.h | 20 +++- src/r_patch.c | 159 ++++++++++++++++++++----- src/r_patch.h | 9 ++ src/r_segs.c | 2 +- src/r_things.c | 16 +-- src/v_video.c | 10 +- src/w_wad.c | 118 +++++++++++++------ src/w_wad.h | 19 ++- src/y_inter.c | 2 +- 19 files changed, 645 insertions(+), 396 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 39f354ba5..8c986a24e 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -733,7 +733,7 @@ void D_SRB2Loop(void) COM_ImmedExecute("cls;version"); if (rendermode == render_soft) - V_DrawFixedPatch(0, 0, FRACUNIT/2, 0, (patch_t *)W_CacheLumpNum(W_GetNumForName("KARTKREW"), PU_CACHE), NULL); + V_DrawFixedPatch(0, 0, FRACUNIT/2, 0, W_CachePatchNum(W_GetNumForName("KARTKREW"), PU_CACHE), NULL); I_FinishUpdate(); // page flip or blit buffer for (;;) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 5ba8655b8..6fef6d0a9 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -191,7 +191,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap, // Draw each column to the block cache for (; ncols--; block += bpp, xfrac += xfracstep) { - patchcol = (const column_t *)((const UINT8 *)realpatch + LONG(realpatch->columnofs[xfrac>>FRACBITS])); + patchcol = (const column_t *)((const UINT8 *)realpatch->columns + (realpatch->columnofs[xfrac>>FRACBITS])); HWR_DrawColumnInCache(patchcol, block, mipmap, pblockheight, blockmodulo, @@ -205,7 +205,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap, static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32 pblockheight, texture_t *texture, texpatch_t *patch, - const patch_t *realpatch) + const softwarepatch_t *realpatch) { INT32 x, x1, x2; INT32 col, ncols; @@ -313,7 +313,8 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe UINT8 *block; texture_t *texture; texpatch_t *patch; - patch_t *realpatch; + softwarepatch_t *realpatch; + UINT8 *pdata; INT32 blockwidth, blockheight, blocksize; INT32 i, idx; @@ -371,12 +372,12 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe // Composite the columns together. for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { - realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + pdata = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + realpatch = (softwarepatch_t *)pdata; if (realpatch != NULL) { HWR_DrawTexturePatchInCache(&gltex->mipmap, blockwidth, blockheight, texture, patch, realpatch); - //Z_ChangeTag(realpatch, PU_HWRCACHE_UNLOCKED); } } @@ -400,20 +401,11 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe // patch may be NULL if glMipmap has been initialised already and makebitmap is false void HWR_MakePatch (patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipmap, boolean makebitmap) { - // don't do it twice (like a cache) if (glMipmap->width == 0) { - // save the original patch header so that the GLPatch can be casted - // into a standard patch_t struct and the existing code can get the - // orginal patch dimensions and offsets. - glPatch->width = SHORT(patch->width); - glPatch->height = SHORT(patch->height); - glPatch->leftoffset = SHORT(patch->leftoffset); - glPatch->topoffset = SHORT(patch->topoffset); - glMipmap->width = glMipmap->height = 1; - while (glMipmap->width < glPatch->width) glMipmap->width <<= 1; - while (glMipmap->height < glPatch->height) glMipmap->height <<= 1; + while (glMipmap->width < patch->width) glMipmap->width <<= 1; + while (glMipmap->height < patch->height) glMipmap->height <<= 1; // no wrap around, no chroma key glMipmap->flags = 0; @@ -421,9 +413,8 @@ void HWR_MakePatch (patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipmap, bo // setup the texture info glMipmap->format = patchformat; - //glPatch->max_s = glPatch->max_t = 1.0f; - glPatch->max_s = (float)glPatch->width / (float)glMipmap->width; - glPatch->max_t = (float)glPatch->height / (float)glMipmap->height; + glPatch->max_s = (float)patch->width / (float)glMipmap->width; + glPatch->max_t = (float)patch->height / (float)glMipmap->height; } Z_Free(glMipmap->data); @@ -435,7 +426,7 @@ void HWR_MakePatch (patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipmap, bo HWR_DrawPatchInCache(glMipmap, glMipmap->width, glMipmap->height, - glPatch->width, glPatch->height, + patch->width, patch->height, patch); } } @@ -444,22 +435,58 @@ void HWR_MakePatch (patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipmap, bo // CACHING HANDLING // ================================================= -static size_t gl_numtextures; +static size_t gl_numtextures = 0; // Texture count static GLMapTexture_t *gl_textures; // For all textures -void HWR_InitTextureCache(void) +void HWR_FreeTextureData(patch_t *patch) { - gl_numtextures = 0; - gl_textures = NULL; + GLPatch_t *grPatch; + + if (!patch || !patch->hardware) + return; + + grPatch = patch->hardware; + + if (vid.glstate == VID_GL_LIBRARY_LOADED) + GL_DeleteTexture(grPatch->mipmap); + if (grPatch->mipmap->data) + Z_Free(grPatch->mipmap->data); } -// Callback function for HWR_FreeTextureCache. -static void FreeMipmapColormap(INT32 patchnum, void *patch) +void HWR_FreeTexture(patch_t *patch) { - GLPatch_t* const pat = patch; - (void)patchnum; //unused + if (!patch) + return; + + if (patch->hardware) + { + GLPatch_t *glPatch = patch->hardware; + + HWR_FreeTextureColormaps(patch); + + if (glPatch->mipmap) + { + HWR_FreeTextureData(patch); + Z_Free(glPatch->mipmap); + } + + Z_Free(patch->hardware); + } + + patch->hardware = NULL; +} + +// Called by HWR_FreePatchCache. +void HWR_FreeTextureColormaps(patch_t *patch) +{ + GLPatch_t *pat; // The patch must be valid, obviously + if (!patch) + return; + + pat = patch->hardware; + if (!pat) return; @@ -481,9 +508,6 @@ static void FreeMipmapColormap(INT32 patchnum, void *patch) // Set the first colormap to the one that comes after it. next = pat->mipmap->nextcolormap; - if (!next) - break; - pat->mipmap->nextcolormap = next->nextcolormap; // Free image data from memory. @@ -497,28 +521,51 @@ static void FreeMipmapColormap(INT32 patchnum, void *patch) } } -void HWR_FreeMipmapCache(void) +static void HWR_FreePatchCache(boolean freeall) { INT32 i; - // free references to the textures - GL_ClearMipMapCache(); - // free all hardware-converted graphics cached in the heap - // our gool is only the textures since user of the texture is the texture cache - Z_FreeTags(PU_HWRCACHE, PU_HWRCACHE); - Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRCACHE_UNLOCKED); - - // Alam: free the Z_Blocks before freeing it's users - - // free all patch colormaps after each level: must be done after ClearMipMapCache! for (i = 0; i < numwadfiles; i++) - M_AATreeIterate(wadfiles[i]->hwrcache, FreeMipmapColormap); + { + INT32 j = 0; + for (; j < wadfiles[i]->numlumps; j++) + (freeall ? HWR_FreeTexture : HWR_FreeTextureColormaps)(wadfiles[i]->patchcache[j]); + } } -void HWR_FreeTextureCache(void) +// free all textures after each level +void HWR_ClearAllTextures(void) { // free references to the textures - HWR_FreeMipmapCache(); + GL_ClearMipMapCache(); + HWR_FreePatchCache(true); +} + +void HWR_FreeColormapCache(void) +{ + HWR_FreePatchCache(false); +} + +void HWR_InitMapTextures(void) +{ + gl_textures = NULL; +} + +static void FreeMapTexture(GLMapTexture_t *tex) +{ + GL_DeleteTexture(&tex->mipmap); + if (tex->mipmap.data) + Z_Free(tex->mipmap.data); +} + +void HWR_FreeMapTextures(void) +{ + size_t i; + + for (i = 0; i < gl_numtextures; i++) + { + FreeMapTexture(&gl_textures[i]); + } // now the heap don't have any 'user' pointing to our // texturecache info, we can free it @@ -702,7 +749,7 @@ static void HWR_PrecacheLevelTextures(void) static void HWR_PrecacheLevelSprites(void) { - GLPatch_t *spritepatch; + patch_t *spritepatch; char *spritepresent; size_t i, j, k; lumpnum_t lump; @@ -741,7 +788,7 @@ static void HWR_PrecacheLevelSprites(void) #define cacheang(a) {\ lump = sf->lumppat[a];\ - spritepatch = (GLPatch_t *)W_CachePatchNum(lump, PU_CACHE);\ + spritepatch = (patch_t *)W_CachePatchNum(lump, PU_CACHE);\ if (spritepatch != NULL)\ HWR_GetPatch(spritepatch);\ } @@ -782,11 +829,12 @@ void HWR_PrecacheLevel(void) HWR_PrecacheLevelSprites(); } -void HWR_LoadTextures(size_t pnumtextures) +void HWR_LoadMapTextures(size_t pnumtextures) { // we must free it since numtextures changed - HWR_FreeTextureCache(); + HWR_FreeMapTextures(); + // Why not Z_Malloc? gl_numtextures = pnumtextures; #ifdef GLENCORE gl_textures = calloc(pnumtextures, sizeof (*gl_textures)*2); // *2 - 1 for encore-remapped texture and another for noencore texture (unused when not in encore) @@ -794,7 +842,7 @@ void HWR_LoadTextures(size_t pnumtextures) gl_textures = calloc(pnumtextures, sizeof (*gl_textures)); #endif if (gl_textures == NULL) - I_Error("HWR_LoadTextures: ran out of memory for OpenGL textures. Sad!"); + I_Error("HWR_LoadMapTextures: ran out of memory for OpenGL textures. Sad!"); } // -------------------------------------------------------------------------- @@ -812,15 +860,20 @@ GLMapTexture_t *HWR_GetTexture(INT32 tex, boolean noencore) tex = 0; #endif } + + // Every texture in memory, stored in the + // hardware renderer's bit depth format. Wow! #ifdef GLENCORE gltex = &gl_textures[tex*2 + (encoremap && !noencore ? 0 : 1)]; #else gltex = &gl_textures[tex]; #endif + + // Generate texture if missing from the cache if (!gltex->mipmap.data && !gltex->mipmap.downloaded) HWR_GenerateTexture(tex, gltex, noencore); - // If hardware does not have the texture, then call pfnSetTexture to upload it + // If hardware does not have the texture, then call GL_SetTexture to upload it if (!gltex->mipmap.downloaded) GL_SetTexture(&gltex->mipmap); HWR_SetCurrentTexture(&gltex->mipmap); @@ -869,6 +922,7 @@ static void HWR_CacheFlat(GLMipmap_t *glMipmap, lumpnum_t flatlumpnum) pflatsize = 64; break; } + glMipmap->width = (UINT16)pflatsize; glMipmap->height = (UINT16)pflatsize; @@ -891,11 +945,13 @@ static void HWR_CacheFlat(GLMipmap_t *glMipmap, lumpnum_t flatlumpnum) void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap) { GLMipmap_t *glMipmap; + patch_t *patch; if (flatlumpnum == LUMPERROR) return; - glMipmap = HWR_GetCachedGLPatch(flatlumpnum)->mipmap; + patch = HWR_GetCachedGLPatch(flatlumpnum); + glMipmap = ((GLPatch_t *)Patch_AllocateHardwarePatch(patch))->mipmap; glMipmap->colormap = colormaps; @@ -916,27 +972,16 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap) Z_ChangeTag(glMipmap->data, PU_HWRCACHE_UNLOCKED); } -// -// HWR_LoadMappedPatch(): replace the skin color of the sprite in cache -// : load it first in doom cache if not already -// -static void HWR_LoadMappedPatch(GLMipmap_t *glMipmap, GLPatch_t *glPatch) +// --------------------+ +// HWR_LoadPatchMipmap : Generates a patch into a mipmap, usually the mipmap inside the patch itself +// --------------------+ +static void HWR_LoadPatchMipmap(patch_t *patch, GLMipmap_t *glMipmap) { + GLPatch_t *glPatch = patch->hardware; + if (!glMipmap->downloaded && !glMipmap->data) - { - patch_t *patch = glPatch->rawpatch; - if (!patch) - patch = W_CacheLumpNumPwad(glPatch->wadnum, glPatch->lumpnum, PU_STATIC); - HWR_MakePatch(patch, glPatch, glMipmap, true); - // You can't free rawpatch for some reason? - // (Obviously I can't, sprite rotation needs that...) - - if (!glPatch->rawpatch) - Z_Free(patch); - } - // If hardware does not have the texture, then call pfnSetTexture to upload it if (!glMipmap->downloaded) GL_SetTexture(glMipmap); @@ -949,46 +994,29 @@ static void HWR_LoadMappedPatch(GLMipmap_t *glMipmap, GLPatch_t *glPatch) // -----------------+ // HWR_GetPatch : Downloads a patch to the hardware cache and make it ready for use // -----------------+ -void HWR_GetPatch(GLPatch_t *glPatch) +void HWR_GetPatch(patch_t *patch) { - // is it in hardware cache - if (!glPatch->mipmap->downloaded && !glPatch->mipmap->data) - { - // load the software patch, PU_STATIC or the Z_Malloc for hardware patch will - // flush the software patch before the conversion! oh yeah I suffered - patch_t *ptr = glPatch->rawpatch; - if (!ptr) - ptr = W_CacheLumpNumPwad(glPatch->wadnum, glPatch->lumpnum, PU_STATIC); - - HWR_MakePatch(ptr, glPatch, glPatch->mipmap, true); - - // this is inefficient.. but the hardware patch in heap is purgeable so it should - // not fragment memory, and besides the REAL cache here is the hardware memory - if (!glPatch->rawpatch) - Z_Free(ptr); - } - - // If hardware does not have the texture, then call pfnSetTexture to upload it - if (!glPatch->mipmap->downloaded) - GL_SetTexture(glPatch->mipmap); - HWR_SetCurrentTexture(glPatch->mipmap); - - // The system-memory patch data can be purged now. - Z_ChangeTag(glPatch->mipmap->data, PU_HWRCACHE_UNLOCKED); + if (!patch->hardware) + Patch_CreateGL(patch); + HWR_LoadPatchMipmap(patch, ((GLPatch_t *)patch->hardware)->mipmap); } - // -------------------+ // HWR_GetMappedPatch : Same as HWR_GetPatch for sprite color // -------------------+ -void HWR_GetMappedPatch(GLPatch_t *glPatch, const UINT8 *colormap) +void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap) { + GLPatch_t *glPatch; GLMipmap_t *glMipmap, *newMipmap; + if (!patch->hardware) + Patch_CreateGL(patch); + glPatch = patch->hardware; + if (colormap == colormaps || colormap == NULL) { - // Load the default (green) color in doom cache (temporary?) AND hardware cache - HWR_GetPatch(glPatch); + // Load the default (green) color in hardware cache + HWR_GetPatch(patch); return; } @@ -1000,7 +1028,7 @@ void HWR_GetMappedPatch(GLPatch_t *glPatch, const UINT8 *colormap) if (UNLIKELY(glMipmap->colormap == colormap)) { - HWR_LoadMappedPatch(glMipmap, glPatch); + HWR_LoadPatchMipmap(patch, glMipmap); return; } } @@ -1009,7 +1037,7 @@ void HWR_GetMappedPatch(GLPatch_t *glPatch, const UINT8 *colormap) //BP: WARNING: don't free it manually without clearing the cache of harware renderer // (it have a liste of mipmap) - // this malloc is cleared in HWR_FreeTextureCache + // this malloc is cleared in HWR_FreeColormapCache // (...) unfortunately z_malloc fragment alot the memory :(so malloc is better newMipmap = calloc(1, sizeof (*newMipmap)); if (newMipmap == NULL) @@ -1017,7 +1045,7 @@ void HWR_GetMappedPatch(GLPatch_t *glPatch, const UINT8 *colormap) glMipmap->nextcolormap = newMipmap; newMipmap->colormap = colormap; - HWR_LoadMappedPatch(newMipmap, glPatch); + HWR_LoadPatchMipmap(patch, newMipmap); } void HWR_UnlockCachedPatch(GLPatch_t *glPatch) @@ -1028,24 +1056,20 @@ void HWR_UnlockCachedPatch(GLPatch_t *glPatch) Z_ChangeTag(glPatch->mipmap->data, PU_HWRCACHE_UNLOCKED); } -GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wadnum, UINT16 lumpnum) +patch_t *HWR_GetCachedGLPatchPwad(UINT16 wadnum, UINT16 lumpnum) { - aatree_t *hwrcache = wadfiles[wadnum]->hwrcache; - GLPatch_t *glPatch; - - if (!(glPatch = M_AATreeGet(hwrcache, lumpnum))) + lumpcache_t *lumpcache = wadfiles[wadnum]->patchcache; + if (!lumpcache[lumpnum]) { - glPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL); - glPatch->wadnum = wadnum; - glPatch->lumpnum = lumpnum; - glPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL); - M_AATreeSet(hwrcache, lumpnum, glPatch); + void *ptr = Z_Calloc(sizeof(patch_t), PU_CACHE, &lumpcache[lumpnum]); + Patch_Create(NULL, 0, ptr); + Patch_AllocateHardwarePatch(ptr); } - return glPatch; + return (patch_t *)(lumpcache[lumpnum]); } -GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum) +patch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum) { return HWR_GetCachedGLPatchPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum)); } @@ -1139,8 +1163,11 @@ static void HWR_CacheFadeMask(GLMipmap_t *glMipmap, lumpnum_t fademasklumpnum) void HWR_GetFadeMask(lumpnum_t fademasklumpnum) { GLMipmap_t *glMipmap; + patch_t *patch; + + patch = HWR_GetCachedGLPatch(fademasklumpnum); + glMipmap = ((GLPatch_t *)Patch_AllocateHardwarePatch(patch))->mipmap; - glMipmap = HWR_GetCachedGLPatch(fademasklumpnum)->mipmap; if (!glMipmap->downloaded && !glMipmap->data) HWR_CacheFadeMask(glMipmap, fademasklumpnum); diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index 1f16ebf2a..d7c11b2c2 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -62,24 +62,11 @@ struct GLMapTexture_s }; typedef struct GLMapTexture_s GLMapTexture_t; -// a cached patch as converted to hardware format, holding the original patch_t -// header so that the existing code can retrieve ->width, ->height as usual -// This is returned by W_CachePatchNum()/W_CachePatchName(), when rendermode -// is 'render_opengl'. Else it returns the normal patch_t data. +// a cached patch as converted to hardware format struct GLPatch_s { - // the 4 first fields come right away from the original patch_t - INT16 width; - INT16 height; - INT16 leftoffset; // pixels to the left of origin - INT16 topoffset; // pixels below the origin - // float max_s,max_t; - UINT16 wadnum; // the software patch lump num for when the hardware patch - UINT16 lumpnum; // was flushed, and we need to re-create it - void *rawpatch; // :^) GLMipmap_t *mipmap; - boolean notfound; // if the texture file was not found, mark it here (used in model texture loading) }; typedef struct GLPatch_s GLPatch_t; diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 70a2e6cc8..9a7f19995 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -71,10 +71,11 @@ static const float FLOATBASEVIDHEIGHT = (float)BASEVIDHEIGHT; // Notes : x,y : positions relative to the original Doom resolution // : textes(console+score) + menus + status bar // -----------------+ -void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option) +void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option) { FOutVector v[4]; FBITFIELD flags; + GLPatch_t *hwrPatch; // 3--2 // | /| @@ -87,6 +88,7 @@ void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option) // make patch ready in hardware cache HWR_GetPatch(gpatch); + hwrPatch = ((GLPatch_t *)gpatch->hardware); switch (option & V_SCALEPATCHMASK) { @@ -106,17 +108,17 @@ void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option) if (option & V_NOSCALESTART) sdupx = sdupy = 2.0f; - v[0].x = v[3].x = (x*sdupx-SHORT(gpatch->leftoffset)*pdupx)/vid.width - 1; - v[2].x = v[1].x = (x*sdupx+(SHORT(gpatch->width)-SHORT(gpatch->leftoffset))*pdupx)/vid.width - 1; - v[0].y = v[1].y = 1-(y*sdupy-SHORT(gpatch->topoffset)*pdupy)/vid.height; - v[2].y = v[3].y = 1-(y*sdupy+(SHORT(gpatch->height)-SHORT(gpatch->topoffset))*pdupy)/vid.height; + v[0].x = v[3].x = (x*sdupx-(gpatch->leftoffset)*pdupx)/vid.width - 1; + v[2].x = v[1].x = (x*sdupx+((gpatch->width)-(gpatch->leftoffset))*pdupx)/vid.width - 1; + v[0].y = v[1].y = 1-(y*sdupy-(gpatch->topoffset)*pdupy)/vid.height; + v[2].y = v[3].y = 1-(y*sdupy+((gpatch->height)-(gpatch->topoffset))*pdupy)/vid.height; v[0].z = v[1].z = v[2].z = v[3].z = 1.0f; v[0].s = v[3].s = 0.0f; - v[2].s = v[1].s = gpatch->max_s; + v[2].s = v[1].s = hwrPatch->max_s; v[0].t = v[1].t = 0.0f; - v[2].t = v[3].t = gpatch->max_t; + v[2].t = v[3].t = hwrPatch->max_t; flags = PF_Translucent|PF_NoDepthTest; @@ -129,7 +131,7 @@ void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option) GL_DrawPolygon(NULL, v, 4, flags); } -void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap, INT32 bflags) +void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap, INT32 bflags) { FOutVector v[4]; FBITFIELD flags; @@ -137,6 +139,7 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t float cy = FIXED_TO_FLOAT(y); UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT); UINT8 blendmode = ((bflags & V_BLENDMASK) >> V_BLENDSHIFT); + GLPatch_t *hwrPatch; // 3--2 // | /| @@ -156,6 +159,8 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t else HWR_GetMappedPatch(gpatch, colormap); + hwrPatch = ((GLPatch_t *)gpatch->hardware); + dupx = (float)vid.dupx; dupy = (float)vid.dupy; @@ -186,13 +191,13 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t // left offset if (option & V_FLIP) - offsetx = (float)(SHORT(gpatch->width) - SHORT(gpatch->leftoffset)) * fscalew; + offsetx = (float)((gpatch->width) - (gpatch->leftoffset)) * fscalew; else - offsetx = (float)SHORT(gpatch->leftoffset) * fscalew; + offsetx = (float)(gpatch->leftoffset) * fscalew; // top offset // TODO: make some kind of vertical version of V_FLIP, maybe by deprecating V_OFFSET in future?!? - offsety = (float)SHORT(gpatch->topoffset) * fscaleh; + offsety = (float)(gpatch->topoffset) * fscaleh; if ((option & (V_NOSCALESTART|V_OFFSET)) == (V_NOSCALESTART|V_OFFSET)) // Multiply by dupx/dupy for crosshairs { @@ -220,17 +225,15 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t // if it's meant to cover the whole screen, black out the rest // cx and cy are possibly *slightly* off from float maths // This is done before here compared to software because we directly alter cx and cy to centre - if (cx >= -0.1f && cx <= 0.1f && SHORT(gpatch->width) == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && SHORT(gpatch->height) == BASEVIDHEIGHT) + if (cx >= -0.1f && cx <= 0.1f && (gpatch->width) == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && (gpatch->height) == BASEVIDHEIGHT) { - // Need to temporarily cache the real patch to get the colour of the top left pixel - patch_t *realpatch = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC); - const column_t *column = (const column_t *)((const UINT8 *)(realpatch) + LONG((realpatch)->columnofs[0])); + const column_t *column = (const column_t *)((const UINT8 *)(gpatch->columns) + (gpatch->columnofs[0])); + if (!column->topdelta) { const UINT8 *source = (const UINT8 *)(column) + 3; HWR_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0])); } - Z_Free(realpatch); } // centre screen if (fabsf(fvw - FLOATBASEVIDWIDTH * dupx) > 1.0E-36f) @@ -252,8 +255,8 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t } } - fwidth = (float)SHORT(gpatch->width) * fscalew * dupx; - fheight = (float)SHORT(gpatch->height) * fscaleh * dupy; + fwidth = (float)(gpatch->width) * fscalew * dupx; + fheight = (float)(gpatch->height) * fscaleh * dupy; // positions of the cx, cy, are between 0 and vid.width/vid.height now, we need them to be between -1 and 1 cx = -1.0f + (cx / (fvw / 2.0f)); @@ -274,17 +277,17 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t if (option & V_FLIP) { - v[0].s = v[3].s = gpatch->max_s; + v[0].s = v[3].s = hwrPatch->max_s; v[2].s = v[1].s = 0.0f; } else { v[0].s = v[3].s = 0.0f; - v[2].s = v[1].s = gpatch->max_s; + v[2].s = v[1].s = hwrPatch->max_s; } v[0].t = v[1].t = 0.0f; - v[2].t = v[3].t = gpatch->max_t; + v[2].t = v[3].t = hwrPatch->max_t; // clip it since it is used for bunny scroll in doom I if (blendmode) @@ -314,13 +317,14 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t GL_DrawPolygon(NULL, v, 4, flags); } -void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h) +void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h) { FOutVector v[4]; FBITFIELD flags; float cx = FIXED_TO_FLOAT(x); float cy = FIXED_TO_FLOAT(y); UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT); + GLPatch_t *hwrPatch; // 3--2 // | /| @@ -336,6 +340,7 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal // make patch ready in hardware cache HWR_GetPatch(gpatch); + hwrPatch = ((GLPatch_t *)gpatch->hardware); dupx = (float)vid.dupx; dupy = (float)vid.dupy; @@ -358,8 +363,8 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal dupx = dupy = (dupx < dupy ? dupx : dupy); fscale = FIXED_TO_FLOAT(pscale); - cy -= (float)SHORT(gpatch->topoffset) * fscale; - cx -= (float)SHORT(gpatch->leftoffset) * fscale; + cy -= (float)(gpatch->topoffset) * fscale; + cx -= (float)(gpatch->leftoffset) * fscale; if (!(option & V_NOSCALESTART)) { @@ -371,17 +376,15 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal // if it's meant to cover the whole screen, black out the rest // cx and cy are possibly *slightly* off from float maths // This is done before here compared to software because we directly alter cx and cy to centre - if (cx >= -0.1f && cx <= 0.1f && SHORT(gpatch->width) == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && SHORT(gpatch->height) == BASEVIDHEIGHT) + if (cx >= -0.1f && cx <= 0.1f && (gpatch->width) == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && (gpatch->height) == BASEVIDHEIGHT) { - // Need to temporarily cache the real patch to get the colour of the top left pixel - patch_t *realpatch = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC); - const column_t *column = (const column_t *)((const UINT8 *)(realpatch) + LONG((realpatch)->columnofs[0])); + const column_t *column = (const column_t *)((const UINT8 *)(gpatch->columns) + (gpatch->columnofs[0])); + if (!column->topdelta) { const UINT8 *source = (const UINT8 *)(column) + 3; HWR_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0])); } - Z_Free(realpatch); } // centre screen if (fabsf(fvw - FLOATBASEVIDWIDTH * dupx) > 1.0E-36f) @@ -412,11 +415,11 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal if (fheight > h - sy) fheight = h - sy; - if (fwidth > SHORT(gpatch->width)) - fwidth = SHORT(gpatch->width); + if (fwidth > (gpatch->width)) + fwidth = (gpatch->width); - if (fheight > SHORT(gpatch->height)) - fheight = SHORT(gpatch->height); + if (fheight > (gpatch->height)) + fheight = (gpatch->height); if (pscale != FRACUNIT) { @@ -446,10 +449,10 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal v[0].z = v[1].z = v[2].z = v[3].z = 1.0f; - v[0].s = v[3].s = ((sx)/(float)SHORT(gpatch->width) )*gpatch->max_s; - v[2].s = v[1].s = ((w )/(float)SHORT(gpatch->width) )*gpatch->max_s; - v[0].t = v[1].t = ((sy)/(float)SHORT(gpatch->height))*gpatch->max_t; - v[2].t = v[3].t = ((h )/(float)SHORT(gpatch->height))*gpatch->max_t; + v[0].s = v[3].s = ((sx)/(float)(gpatch->width) )*hwrPatch->max_s; + v[2].s = v[1].s = ((w )/(float)(gpatch->width) )*hwrPatch->max_s; + v[0].t = v[1].t = ((sy)/(float)(gpatch->height))*hwrPatch->max_t; + v[2].t = v[3].t = ((h )/(float)(gpatch->height))*hwrPatch->max_t; flags = PF_Translucent|PF_NoDepthTest; @@ -660,7 +663,7 @@ void HWR_DrawViewBorder(INT32 clearlines) INT32 top, side; INT32 baseviewwidth, baseviewheight; INT32 basewindowx, basewindowy; - GLPatch_t *patch; + patch_t *patch; // if (gl_viewwidth == vid.width) // return; diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index e4659c0e6..31ecc7792 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -32,7 +32,7 @@ typedef struct gl_vissprite_s float scale; float spritexscale, spriteyscale; float spritexoffset, spriteyoffset; - GLPatch_t *gpatch; + patch_t *gpatch; boolean flip; UINT8 translucency; //alpha level 0-255 mobj_t *mobj; @@ -56,29 +56,38 @@ void HWR_FreeExtraSubsectors(void); // -------- // hw_cache.c // -------- -void HWR_InitTextureCache(void); -void HWR_FreeTextureCache(void); -void HWR_FreeMipmapCache(void); +void HWR_InitMapTextures(void); +void HWR_LoadMapTextures(size_t pnumtextures); +void HWR_FreeMapTextures(void); + +patch_t *HWR_GetCachedGLPatchPwad(UINT16 wad, UINT16 lump); +patch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum); + +void HWR_GetPatch(patch_t *gpatch); +void HWR_GetMappedPatch(patch_t *gpatch, const UINT8 *colormap); +void HWR_MakePatch(patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipmap, boolean makebitmap); +void HWR_GetFadeMask(lumpnum_t fademasklumpnum); void HWR_PrecacheLevel(void); +GLMapTexture_t *HWR_GetTexture(INT32 tex, boolean noencore); void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap); // ^ some flats must NOT be remapped to encore, since we remap them as we cache them for ease, adding a toggle here seems wise. -GLMapTexture_t *HWR_GetTexture(INT32 tex, boolean noencore); -void HWR_GetPatch(GLPatch_t *gpatch); -void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap); -void HWR_MakePatch(patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipmap, boolean makebitmap); +void HWR_FreeTexture(patch_t *patch); +void HWR_FreeTextureData(patch_t *patch); +void HWR_FreeTextureColormaps(patch_t *patch); +void HWR_ClearAllTextures(void); +void HWR_FreeColormapCache(void); void HWR_UnlockCachedPatch(GLPatch_t *gpatch); -void HWR_SetPalette(RGBA_t *palette); +RGBA_t *HWR_GetTexturePalette(void); +void HWR_SetPalette(RGBA_t *palette); void HWR_SetMapPalette(void); UINT32 HWR_CreateLightTable(UINT8 *lighttable); UINT32 HWR_GetLightTableID(extracolormap_t *colormap); void HWR_ClearLightTables(void); -GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wad, UINT16 lump); -GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum); -void HWR_GetFadeMask(lumpnum_t fademasklumpnum); + // -------- // hw_draw.c diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 4e6f352ef..77e9e598a 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -821,7 +821,7 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) { FOutVector wallVerts[4]; wallsplat_t *splat; - GLPatch_t *gpatch; + patch_t *gpatch; fixed_t i; // seg bbox fixed_t segbbox[4]; @@ -3314,7 +3314,7 @@ static fixed_t HWR_OpaqueFloorAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t hei return floorz; } -static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, GLPatch_t *gpatch) +static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch) { float this_scale = 1.0f; FOutVector swallVerts[4]; @@ -3574,7 +3574,8 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) { FOutVector wallVerts[4]; FOutVector baseWallVerts[4]; // This is what the verts should end up as - GLPatch_t *gpatch; + patch_t *gpatch; + GLPatch_t *hwrpatch; FSurfaceInfo Surf; extracolormap_t *colormap; INT32 lightlevel; @@ -3596,7 +3597,8 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) fixed_t v1x, v1y, v2x, v2y; INT32 shader = SHADER_NONE; - gpatch = spr->gpatch; //W_CachePatchNum(spr->patchlumpnum, PU_CACHE); + gpatch = spr->gpatch; + hwrpatch = (GLPatch_t *)(gpatch->hardware); // cache the patch in the graphics card memory //12/12/99: Hurdler: same comment as above (for md2) @@ -3630,25 +3632,25 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) if (spr->flip) { - baseWallVerts[0].s = baseWallVerts[3].s = gpatch->max_s; + baseWallVerts[0].s = baseWallVerts[3].s = hwrpatch->max_s; baseWallVerts[2].s = baseWallVerts[1].s = 0; } else { baseWallVerts[0].s = baseWallVerts[3].s = 0; - baseWallVerts[2].s = baseWallVerts[1].s = gpatch->max_s; + baseWallVerts[2].s = baseWallVerts[1].s = hwrpatch->max_s; } // flip the texture coords (look familiar?) if (spr->vflip) { - baseWallVerts[3].t = baseWallVerts[2].t = gpatch->max_t; + baseWallVerts[3].t = baseWallVerts[2].t = hwrpatch->max_t; baseWallVerts[0].t = baseWallVerts[1].t = 0; } else { baseWallVerts[3].t = baseWallVerts[2].t = 0; - baseWallVerts[0].t = baseWallVerts[1].t = gpatch->max_t; + baseWallVerts[0].t = baseWallVerts[1].t = hwrpatch->max_t; } // push it toward the camera to mitigate floor-clipping sprites @@ -3847,7 +3849,8 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) static void HWR_DrawSprite(gl_vissprite_t *spr) { FOutVector wallVerts[4]; - GLPatch_t *gpatch; // sprite patch converted to hardware + patch_t *gpatch; // sprite patch converted to hardware + GLPatch_t *hwrpatch; FSurfaceInfo Surf; FBITFIELD blend = 0; @@ -3871,7 +3874,8 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) // sure to do it the right way. So actually, we keep normal sprite // in memory and we add the md2 model if it exists for that sprite - gpatch = spr->gpatch; //W_CachePatchNum(spr->patchlumpnum, PU_CACHE); + gpatch = spr->gpatch; + hwrpatch = (GLPatch_t *)(gpatch->hardware); // create the sprite billboard // @@ -3893,25 +3897,25 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) if (spr->flip) { - wallVerts[0].s = wallVerts[3].s = gpatch->max_s; + wallVerts[0].s = wallVerts[3].s = hwrpatch->max_s; wallVerts[2].s = wallVerts[1].s = 0; } else { wallVerts[0].s = wallVerts[3].s = 0; - wallVerts[2].s = wallVerts[1].s = gpatch->max_s; + wallVerts[2].s = wallVerts[1].s = hwrpatch->max_s; } // flip the texture coords (look familiar?) if (spr->vflip) { - wallVerts[3].t = wallVerts[2].t = gpatch->max_t; + wallVerts[3].t = wallVerts[2].t = hwrpatch->max_t; wallVerts[0].t = wallVerts[1].t = 0; } else { wallVerts[3].t = wallVerts[2].t = 0; - wallVerts[0].t = wallVerts[1].t = gpatch->max_t; + wallVerts[0].t = wallVerts[1].t = hwrpatch->max_t; } // cache the patch in the graphics card memory @@ -3997,7 +4001,8 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) { FBITFIELD blend = 0; FOutVector wallVerts[4]; - GLPatch_t *gpatch; // sprite patch converted to hardware + patch_t *gpatch; // sprite patch converted to hardware + GLPatch_t *hwrpatch; FSurfaceInfo Surf; INT32 shader = SHADER_NONE; @@ -4006,7 +4011,8 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) return; // cache sprite graphics - gpatch = spr->gpatch; //W_CachePatchNum(spr->patchlumpnum, PU_CACHE); + gpatch = spr->gpatch; + hwrpatch = (GLPatch_t *)(gpatch->hardware); // create the sprite billboard // @@ -4027,10 +4033,10 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) HWR_RotateSpritePolyToAim(spr, wallVerts, true, false); wallVerts[0].s = wallVerts[3].s = 0; - wallVerts[2].s = wallVerts[1].s = gpatch->max_s; + wallVerts[2].s = wallVerts[1].s = hwrpatch->max_s; wallVerts[3].t = wallVerts[2].t = 0; - wallVerts[0].t = wallVerts[1].t = gpatch->max_t; + wallVerts[0].t = wallVerts[1].t = hwrpatch->max_t; // cache the patch in the graphics card memory //12/12/99: Hurdler: same comment as above (for md2) @@ -4894,10 +4900,10 @@ static void HWR_ProjectSprite(mobj_t *thing) #ifdef ROTSPRITE if (rotsprite != NULL) - vis->gpatch = (GLPatch_t *)rotsprite; + vis->gpatch = (patch_t *)rotsprite; else #endif - vis->gpatch = (GLPatch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); + vis->gpatch = (patch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); vis->mobj = thing; @@ -5065,7 +5071,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) vis->z2 = z2; vis->tz = tz; vis->dispoffset = 0; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST - vis->gpatch = (GLPatch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); + vis->gpatch = (patch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); vis->flip = flip; vis->mobj = (mobj_t *)thing; @@ -5542,9 +5548,9 @@ static void HWR_RenderFrame(player_t *player, boolean skybox) if (splitscreen == 2 && player == &players[displayplayers[2]]) { // V_DrawPatchFill, but for the fourth screen only - GLPatch_t *gpatch = W_CachePatchName("SRB2BACK", PU_CACHE); + patch_t *gpatch = W_CachePatchName("SRB2BACK", PU_CACHE); INT32 dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); - INT32 x, y, pw = SHORT(gpatch->width) * dupz, ph = SHORT(gpatch->height) * dupz; + INT32 x, y, pw = (gpatch->width) * dupz, ph = (gpatch->height) * dupz; for (x = vid.width>>1; x < vid.width; x += pw) { @@ -5697,17 +5703,6 @@ static void HWR_CheckForHorizonLines(void) void HWR_LoadLevel(void) { - // Lactozilla (December 8, 2019) - // Level setup used to free EVERY mipmap from memory. - // Even mipmaps that aren't related to level textures. - // Presumably, the hardware render code used to store textures as level data. - // Meaning, they had memory allocated and marked with the PU_LEVEL tag. - // Level textures are only reloaded after R_LoadTextures, which is - // when the texture list is loaded. - - // Sal: Unfortunately, NOT freeing them causes the dreaded Color Bug. - HWR_FreeMipmapCache(); - HWR_CreatePlanePolygons((INT32)numnodes - 1); // Build the sky dome @@ -5818,7 +5813,7 @@ void HWR_Startup(void) CONS_Printf("HWR_Startup()...\n"); textureformat = patchformat = GL_TEXFMT_RGBA; - HWR_InitTextureCache(); + HWR_InitMapTextures(); HWR_InitMD2(); gl_shadersavailable = HWR_InitShaders(); @@ -5910,8 +5905,7 @@ void HWR_Shutdown(void) { CONS_Printf("HWR_Shutdown()\n"); HWR_FreeExtraSubsectors(); - HWR_FreeMipmapCache(); - HWR_FreeTextureCache(); + HWR_FreeMapTextures(); GL_FlushScreenTextures(); #ifdef USE_FBO_OGL GL_Framebuffer_Disable(); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index ba093c6ca..b8d6ef939 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -85,9 +85,9 @@ extern ps_metric_t ps_hw_batchdrawtime; extern boolean gl_shadersavailable; // hw_draw.c -void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option); -void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap, INT32 bflags); -void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h); +void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option); +void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap, INT32 bflags); +void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h); void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color); void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options); // Lat: separate flags from color since color needs to be an uint to work right. void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color); @@ -171,10 +171,6 @@ void HWR_ProcessSeg(void); // Sort of like GLWall::Process in GZDoom void HWR_CreatePlanePolygons(INT32 bspnum); extern boolean gl_maphasportals; -// hw_cache.c -void HWR_LoadTextures(size_t pnumtextures); -RGBA_t *HWR_GetTexturePalette(void); - // Console variables extern CV_PossibleValue_t glanisotropicmode_cons_t[]; diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index f109ddd41..2a5643d53 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -366,43 +366,49 @@ static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h, // -----------------+ static void md2_loadTexture(md2_t *model) { - GLPatch_t *glpatch; + patch_t *patch; + GLPatch_t *glPatch = NULL; + const char *filename = model->filename; if (model->glpatch) { - glpatch = model->glpatch; - Z_Free(glpatch->mipmap->data); + patch = model->glpatch; + glPatch = (GLPatch_t *)(patch->hardware); + if (glPatch) + Z_Free(glPatch->mipmap->data); } else - { - glpatch = Z_Calloc(sizeof *glpatch, PU_HWRPATCHINFO, - &(model->glpatch)); - glpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL); - } + model->glpatch = patch = Patch_Create(NULL, 0, NULL); - if (!glpatch->mipmap->downloaded && !glpatch->mipmap->data) + if (!patch->hardware) + Patch_AllocateHardwarePatch(patch); + + if (glPatch == NULL) + glPatch = (GLPatch_t *)(patch->hardware); + + if (!glPatch->mipmap->downloaded && !glPatch->mipmap->data) { int w = 0, h = 0; #ifdef HAVE_PNG - glpatch->mipmap->format = PNG_Load(filename, &w, &h, glpatch); - if (glpatch->mipmap->format == 0) + glPatch->mipmap->format = PNG_Load(filename, &w, &h, glPatch); + if (glPatch->mipmap->format == 0) #endif - glpatch->mipmap->format = PCX_Load(filename, &w, &h, glpatch); - if (glpatch->mipmap->format == 0) + glPatch->mipmap->format = PCX_Load(filename, &w, &h, glPatch); + if (glPatch->mipmap->format == 0) { - glpatch->notfound = true;// mark it so its not searched for again repeatedly + glPatch->notfound = true;// mark it so its not searched for again repeatedly return; } - glpatch->mipmap->downloaded = 0; - glpatch->mipmap->flags = 0; + glPatch->mipmap->downloaded = 0; + glPatch->mipmap->flags = 0; - glpatch->width = (INT16)w; - glpatch->height = (INT16)h; - glpatch->mipmap->width = (UINT16)w; - glpatch->mipmap->height = (UINT16)h; + patch->width = (INT16)w; + patch->height = (INT16)h; + glPatch->mipmap->width = (UINT16)w; + glPatch->mipmap->height = (UINT16)h; // for palette rendering, color cube is applied in post-processing instead of here if (!HWR_ShouldUsePaletteRendering()) @@ -410,7 +416,7 @@ static void md2_loadTexture(md2_t *model) UINT32 size; RGBA_t *image; // Lactozilla: Apply colour cube - image = glpatch->mipmap->data; + image = glPatch->mipmap->data; size = w*h; while (size--) { @@ -419,8 +425,8 @@ static void md2_loadTexture(md2_t *model) } } } - GL_SetTexture(glpatch->mipmap); - HWR_UnlockCachedPatch(glpatch); + GL_SetTexture(glPatch->mipmap); + HWR_UnlockCachedPatch(glPatch); } // -----------------+ @@ -428,49 +434,56 @@ static void md2_loadTexture(md2_t *model) // -----------------+ static void md2_loadBlendTexture(md2_t *model) { - GLPatch_t *glpatch; + patch_t *patch; + GLPatch_t *glPatch = NULL; + char *filename = Z_Malloc(strlen(model->filename)+7, PU_STATIC, NULL); + strcpy(filename, model->filename); FIL_ForceExtension(filename, "_blend.png"); if (model->blendglpatch) { - glpatch = model->blendglpatch; - Z_Free(glpatch->mipmap->data); + patch = model->blendglpatch; + glPatch = (GLPatch_t *)(patch->hardware); + if (glPatch) + Z_Free(glPatch->mipmap->data); } else - { - glpatch = Z_Calloc(sizeof *glpatch, PU_HWRPATCHINFO, - &(model->blendglpatch)); - glpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL); - } + model->blendglpatch = patch = Patch_Create(NULL, 0, NULL); - if (!glpatch->mipmap->downloaded && !glpatch->mipmap->data) + if (!patch->hardware) + Patch_AllocateHardwarePatch(patch); + + if (glPatch == NULL) + glPatch = (GLPatch_t *)(patch->hardware); + + if (!glPatch->mipmap->downloaded && !glPatch->mipmap->data) { int w = 0, h = 0; #ifdef HAVE_PNG - glpatch->mipmap->format = PNG_Load(filename, &w, &h, glpatch); - if (glpatch->mipmap->format == 0) + glPatch->mipmap->format = PNG_Load(filename, &w, &h, glPatch); + if (glPatch->mipmap->format == 0) #endif - glpatch->mipmap->format = PCX_Load(filename, &w, &h, glpatch); - if (glpatch->mipmap->format == 0) + glPatch->mipmap->format = PCX_Load(filename, &w, &h, glPatch); + if (glPatch->mipmap->format == 0) { - glpatch->notfound = true;// mark it so its not searched for again repeatedly + glPatch->notfound = true;// mark it so its not searched for again repeatedly Z_Free(filename); return; } - glpatch->mipmap->downloaded = 0; - glpatch->mipmap->flags = 0; + glPatch->mipmap->downloaded = 0; + glPatch->mipmap->flags = 0; - glpatch->width = (INT16)w; - glpatch->height = (INT16)h; - glpatch->mipmap->width = (UINT16)w; - glpatch->mipmap->height = (UINT16)h; + patch->width = (INT16)w; + patch->height = (INT16)h; + glPatch->mipmap->width = (UINT16)w; + glPatch->mipmap->height = (UINT16)h; } - GL_SetTexture(glpatch->mipmap); // We do need to do this so that it can be cleared and knows to recreate it when necessary - HWR_UnlockCachedPatch(glpatch); + GL_SetTexture(glPatch->mipmap); // We do need to do this so that it can be cleared and knows to recreate it when necessary + HWR_UnlockCachedPatch(glPatch); Z_Free(filename); } @@ -682,8 +695,10 @@ spritemd2found: #define SETBRIGHTNESS(brightness,r,g,b) \ brightness = (UINT8)(((1063*(UINT32)(r))/5000) + ((3576*(UINT32)(g))/5000) + ((361*(UINT32)(b))/5000)) -static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *glMipmap, INT32 skinnum, skincolors_t color) +static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMipmap_t *glMipmap, INT32 skinnum, skincolors_t color) { + GLPatch_t *hwrPatch = gpatch->hardware; + GLPatch_t *hwrBlendPatch = blendgpatch->hardware; UINT16 w = gpatch->width, h = gpatch->height; UINT32 size = w*h; RGBA_t *image, *blendimage, *cur, blendcolor; @@ -718,8 +733,8 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, cur = Z_Malloc(size*4, PU_HWRCACHE, &glMipmap->data); memset(cur, 0x00, size*4); - image = gpatch->mipmap->data; - blendimage = blendgpatch->mipmap->data; + image = hwrPatch->mipmap->data; + blendimage = hwrBlendPatch->mipmap->data; // TC_METALSONIC includes an actual skincolor translation, on top of its flashing. if (skinnum == TC_METALSONIC) @@ -1042,21 +1057,32 @@ skippixel: #undef SETBRIGHTNESS -static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT32 skinnum, const UINT8 *colormap, skincolors_t color) +static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendgpatch, INT32 skinnum, const UINT8 *colormap, skincolors_t color) { // mostly copied from HWR_GetMappedPatch, hence the similarities and comment + GLPatch_t *glPatch = patch->hardware; + GLPatch_t *glBlendPatch = NULL; GLMipmap_t *glMipmap, *newMipmap; - if (colormap == colormaps || colormap == NULL) + + if (blendgpatch == NULL || colormap == colormaps || colormap == NULL) { // Don't do any blending - GL_SetTexture(gpatch->mipmap); + GL_SetTexture(glPatch->mipmap); + return; + } + + if ((blendgpatch && (glBlendPatch = blendgpatch->hardware) && glBlendPatch->mipmap->format) + && (patch->width != blendgpatch->width || patch->height != blendgpatch->height)) + { + // Blend image exists, but it's bad. + GL_SetTexture(glPatch->mipmap); return; } // search for the Mipmap // skip the first (no colormap translated) - for (glMipmap = gpatch->mipmap; glMipmap->nextcolormap; ) + for (glMipmap = glPatch->mipmap; glMipmap->nextcolormap; ) { glMipmap = glMipmap->nextcolormap; @@ -1084,7 +1110,7 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT glMipmap->nextcolormap = newMipmap; newMipmap->colormap = colormap; - HWR_CreateBlendedTexture(gpatch, blendgpatch, newMipmap, skinnum, color); + HWR_CreateBlendedTexture(patch, blendgpatch, newMipmap, skinnum, color); GL_SetTexture(newMipmap); Z_ChangeTag(newMipmap->data, PU_HWRCACHE_UNLOCKED); @@ -1154,7 +1180,8 @@ void HWR_DrawMD2(gl_vissprite_t *spr) // Look at HWR_ProjectSprite for more { - GLPatch_t *gpatch; + patch_t *gpatch, *blendgpatch; + GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL; INT32 durs = spr->mobj->state->tics; INT32 tics = spr->mobj->tics; //mdlframe_t *next = NULL; @@ -1264,21 +1291,33 @@ void HWR_DrawMD2(gl_vissprite_t *spr) } //Hurdler: arf, I don't like that implementation at all... too much crappy gpatch = md2->glpatch; - if (!gpatch || ((!gpatch->mipmap->format || !gpatch->mipmap->downloaded) && !gpatch->notfound)) - md2_loadTexture(md2); - gpatch = md2->glpatch; // Load it again, because it isn't being loaded into gpatch after md2_loadtexture... + if (gpatch) + hwrPatch = ((GLPatch_t *)gpatch->hardware); - if ((gpatch && gpatch->mipmap->format) // don't load the blend texture if the base texture isn't available - && (!md2->blendglpatch - || ((!((GLPatch_t *)md2->blendglpatch)->mipmap->format || !((GLPatch_t *)md2->blendglpatch)->mipmap->downloaded) - && !((GLPatch_t *)md2->blendglpatch)->notfound))) + if (!gpatch || !hwrPatch + || ((!hwrPatch->mipmap->format || !hwrPatch->mipmap->downloaded) && !hwrPatch->notfound)) + md2_loadTexture(md2); + + // Load it again, because it isn't being loaded into gpatch after md2_loadtexture... + gpatch = md2->glpatch; + if (gpatch) + hwrPatch = ((GLPatch_t *)gpatch->hardware); + + // Load blend texture + blendgpatch = md2->blendglpatch; + if (blendgpatch) + hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware); + + if ((gpatch && hwrPatch && hwrPatch->mipmap->format) // don't load the blend texture if the base texture isn't available + && (!blendgpatch || !hwrBlendPatch + || ((!hwrBlendPatch->mipmap->format || !hwrBlendPatch->mipmap->downloaded) && !hwrPatch->notfound))) md2_loadBlendTexture(md2); - if (gpatch && gpatch->mipmap->format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture + if (gpatch && hwrPatch && hwrPatch->mipmap->format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture { if ((skincolors_t)spr->mobj->color != SKINCOLOR_NONE && - md2->blendglpatch && ((GLPatch_t *)md2->blendglpatch)->mipmap->format - && gpatch->width == ((GLPatch_t *)md2->blendglpatch)->width && gpatch->height == ((GLPatch_t *)md2->blendglpatch)->height) + md2->blendglpatch && (hwrBlendPatch->mipmap->format + && gpatch->width == (blendgpatch->width && gpatch->height == (blendgpatch->height)))) { INT32 tcskinnum = TC_DEFAULT; if ((spr->mobj->flags & MF_BOSS) && (spr->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash" @@ -1303,19 +1342,18 @@ void HWR_DrawMD2(gl_vissprite_t *spr) } else tcskinnum = TC_DEFAULT; } - HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendglpatch, tcskinnum, spr->colormap, (skincolors_t)spr->mobj->color); + HWR_GetBlendedTexture(gpatch, blendgpatch, tcskinnum, spr->colormap, (skincolors_t)spr->mobj->color); } else { // This is safe, since we know the texture has been downloaded - GL_SetTexture(gpatch->mipmap); + GL_SetTexture(hwrPatch->mipmap); } } else { // Sprite - gpatch = spr->gpatch; //gpatch = W_CachePatchNum(spr->patchlumpnum, PU_CACHE); - HWR_GetMappedPatch(gpatch, spr->colormap); + HWR_GetMappedPatch(spr->gpatch, spr->colormap); } if (spr->mobj->frame & FF_ANIMATE) diff --git a/src/p_setup.c b/src/p_setup.c index e6e46edd6..5d944e5e2 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3048,6 +3048,10 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) R_FlushTranslationColormapCache(); #ifdef HWRENDER + // Free GPU textures before freeing patches. + if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED)) + HWR_ClearAllTextures(); + // Delete light table textures HWR_ClearLightTables(); #endif @@ -3122,7 +3126,7 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) { HWR_FreeExtraSubsectors(); - // stuff like HWR_CreatePlanePolygons is called there + // Create plane polygons. HWR_LoadLevel(); } #endif @@ -3334,11 +3338,22 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) if (!devparm && digmreplaces) CONS_Printf(M_GetText("%s digital musics replaced\n"), sizeu1(digmreplaces)); +#ifdef HWRENDER + // Free GPU textures before freeing patches. + if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED)) + HWR_ClearAllTextures(); +#endif + // // search for sprite replacements // R_AddSpriteDefs(wadnum); + // Reload it all anyway, just in case they + // added some textures but didn't insert a + // TEXTURES/etc. list. + R_LoadTexturesPwad(wadnum); + // everything from MultiSetupWadFile until ST_Start was here originally // diff --git a/src/r_data.c b/src/r_data.c index 6b4bef3d0..ec84cf3bf 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -302,8 +302,8 @@ static UINT8 *R_GenerateTexture(size_t texnum) UINT8 *blocktex; texture_t *texture; texpatch_t *patch; - patch_t *realpatch; - int x, x1, x2, i; + softwarepatch_t *realpatch; + int x, x1, x2, i, width, height; size_t blocksize; column_t *patchcol; UINT8 *colofs; @@ -322,16 +322,21 @@ static UINT8 *R_GenerateTexture(size_t texnum) { boolean holey = false; patch = texture->patches; - realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + + realpatch = (softwarepatch_t *)W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); // Check the patch for holes. if (texture->width > SHORT(realpatch->width) || texture->height > SHORT(realpatch->height)) holey = true; + colofs = (UINT8 *)realpatch->columnofs; + for (x = 0; x < texture->width && !holey; x++) { column_t *col = (column_t *)((UINT8 *)realpatch + LONG(*(UINT32 *)&colofs[x<<2])); + INT32 topdelta, prevdelta = -1, y = 0; + while (col->topdelta != 0xff) { topdelta = col->topdelta; @@ -343,6 +348,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) y = topdelta + col->length + 1; col = (column_t *)((UINT8 *)col + col->length + 4); } + if (y < texture->height) holey = true; // this texture is HOLEy! D: } @@ -375,7 +381,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) texturememory += blocksize; block = Z_Malloc(blocksize+1, PU_STATIC, &texturecache[texnum]); - memset(block, 0xF7, blocksize+1); // Transparency hack + memset(block, TRANSPARENTPIXEL, blocksize+1); // Transparency hack // columns lookup table colofs = block; @@ -387,20 +393,33 @@ static UINT8 *R_GenerateTexture(size_t texnum) // Composite the columns together. for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { - realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + realpatch = (softwarepatch_t *)W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); // Well, it's not valid... if (realpatch == NULL) continue; x1 = patch->originx; - x2 = x1 + SHORT(realpatch->width); + width = SHORT(realpatch->width); + height = SHORT(realpatch->height); + x2 = x1 + width; + if (x1 > texture->width || x2 < 0) + continue; // patch not located within texture's x bounds, ignore + + if (patch->originy > texture->height || (patch->originy + height) < 0) + continue; // patch not located within texture's y bounds, ignore + + // patch is actually inside the texture! + // now check if texture is partly off-screen and adjust accordingly + + // left edge if (x1 < 0) x = 0; else x = x1; + // right edge if (x2 > texture->width) x2 = texture->width; @@ -649,7 +668,7 @@ void R_LoadTextures(void) #ifdef HWRENDER if (rendermode == render_opengl) - HWR_LoadTextures(numtextures); + HWR_LoadMapTextures(numtextures); #endif } diff --git a/src/r_defs.h b/src/r_defs.h index a1706289f..a168b9c50 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -642,7 +642,23 @@ typedef struct // Patches are used for sprites and all masked pictures, and we compose // textures from the TEXTURE1 list of patches. // -// WARNING: this structure is cloned in GLPatch_t + +typedef struct +{ + INT16 width, height; + INT16 leftoffset, topoffset; + + INT32 *columnofs; // Column offsets. This is relative to patch->columns + UINT8 *columns; // Software column data + + void *hardware; // OpenGL patch, allocated whenever necessary + +#ifdef ROTSPRITE + rotsprite_t *rotated; // Rotated patches +#endif + +} patch_t; + #if defined(_MSC_VER) #pragma pack(1) #endif @@ -655,7 +671,7 @@ typedef struct INT16 topoffset; // pixels below the origin INT32 columnofs[8]; // only [width] used // the [0] is &columnofs[width] -} patch_t; +} ATTRPACK softwarepatch_t; #ifdef _MSC_VER #pragma warning(disable : 4200) diff --git a/src/r_patch.c b/src/r_patch.c index ed8d5962d..2320b9e52 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -329,6 +329,113 @@ void R_LoadSpriteInfoLumps(UINT16 wadnum, UINT16 numlumps) static unsigned char imgbuf[1<<26]; +// +// Creates a patch. +// Assumes a PU_PATCH zone memory tag and no user, but can always be set later +// + +patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest) +{ + patch_t *patch = (dest == NULL) ? Z_Calloc(sizeof(patch_t), PU_CACHE, NULL) : (patch_t *)(dest); + + if (source) + { + INT32 col, colsize; + size_t size = sizeof(INT32) * source->width; + size_t offs = (sizeof(INT16) * 4) + size; + + patch->width = source->width; + patch->height = source->height; + patch->leftoffset = source->leftoffset; + patch->topoffset = source->topoffset; + patch->columnofs = Z_Calloc(size, PU_CACHE, NULL); + + for (col = 0; col < source->width; col++) + { + // This makes the column offsets relative to the column data itself, + // instead of the entire patch data + patch->columnofs[col] = LONG(source->columnofs[col]) - offs; + } + + if (!srcsize) + I_Error("Patch_Create: no source size!"); + + colsize = (INT32)(srcsize) - (INT32)offs; + if (colsize <= 0) + I_Error("Patch_Create: no column data!"); + + patch->columns = Z_Calloc(colsize, PU_CACHE, NULL); + M_Memcpy(patch->columns, ((UINT8 *)source + LONG(source->columnofs[0])), colsize); + } + + return patch; +} + +// +// Frees a patch from memory. +// + +void Patch_Free(patch_t *patch) +{ +#ifdef HWRENDER + if (patch->hardware) + HWR_FreeTexture(patch); +#endif + +#ifdef ROTSPRITE + if (patch->rotated) + { + rotsprite_t *rotsprite = patch->rotated; + INT32 i = 0; + + for (; i < rotsprite->angles; i++) + { + if (rotsprite->patches[i]) + Patch_Free(rotsprite->patches[i]); + } + + Z_Free(rotsprite->patches); + Z_Free(rotsprite); + } +#endif + + if (patch->columnofs) + Z_Free(patch->columnofs); + if (patch->columns) + Z_Free(patch->columns); + + Z_Free(patch); +} + +#ifdef HWRENDER +// +// Allocates a hardware patch. +// + +void *Patch_AllocateHardwarePatch(patch_t *patch) +{ + if (!patch->hardware) + { + GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, &patch->hardware); + grPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, &grPatch->mipmap); + } + return (void *)(patch->hardware); +} + +// +// Creates a hardware patch. +// + +void *Patch_CreateGL(patch_t *patch) +{ + GLPatch_t *grPatch = (GLPatch_t *)Patch_AllocateHardwarePatch(patch); + if (!grPatch->mipmap->data) // Run HWR_MakePatch in all cases, to recalculate some things + HWR_MakePatch(patch, grPatch, grPatch->mipmap, false); + return grPatch; +} +#endif // HWRENDER + + // // R_MaskedFlatToPatch // @@ -440,7 +547,14 @@ static void *R_MaskedFlatToPatch(UINT16 *raw, INT16 width, INT16 height, INT16 l if (destsize != NULL) *destsize = size; - return img; + + patch_t *converted = Patch_Create((softwarepatch_t *)img, size, NULL); +#ifdef HWRENDER + Patch_CreateGL(converted); +#endif + Z_Free(img); + + return converted; } static UINT16 GetPatchPixel(patch_t *patch, INT32 x, INT32 y, boolean flip) @@ -453,14 +567,14 @@ static UINT16 GetPatchPixel(patch_t *patch, INT32 x, INT32 y, boolean flip) if (patch == NULL) I_Error("GetPatchPixel: patch == NULL"); - width = SHORT(patch->width); + width = patch->width; if (x >= 0 && x < width) { INT32 colx = flip ? (width-1)-x : x; INT32 topdelta, prevdelta = -1; - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[colx])); + column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[colx])); while (column->topdelta != 0xff) { @@ -486,17 +600,6 @@ static UINT16 GetPatchPixel(patch_t *patch, INT32 x, INT32 y, boolean flip) return 0xFF00; } -#ifdef HWRENDER -static patch_t *R_CreateHardwarePatch(patch_t *patch) -{ - GLPatch_t *glPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL); - glPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL); - glPatch->rawpatch = patch; - HWR_MakePatch(patch, glPatch, glPatch->mipmap, false); - return (patch_t *)glPatch; -} -#endif - #ifdef ROTSPRITE // // R_GetRollAngle @@ -554,7 +657,8 @@ patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spri if (lump == LUMPERROR) return NULL; - patch = (patch_t *)W_CacheLumpNum(lump, PU_CACHE); // PU_LEVEL + patch = W_CachePatchNum(lump, PU_CACHE); // PU_SPRITE + //patch = W_CachePatchNum(lump, PU_SPRITE); if (sprinfo->available) { @@ -563,8 +667,8 @@ patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spri } else { - xpivot = SHORT(patch->leftoffset); - ypivot = SHORT(patch->height) / 2; + xpivot = patch->leftoffset; + ypivot = patch->height / 2; } RotatedPatch_DoRotation(rotsprite, patch, rotationangle, xpivot, ypivot, flip); @@ -581,7 +685,6 @@ rotsprite_t *RotatedPatch_Create(INT32 numangles) return rotsprite; } - static void RotatedPatch_CalculateDimensions( INT32 width, INT32 height, fixed_t ca, fixed_t sa, @@ -607,16 +710,15 @@ static void RotatedPatch_CalculateDimensions( void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip) { UINT32 i; - patch_t *rotated; UINT16 *rawdst, *rawconv; size_t size; INT32 bflip = (flip != 0x00); - INT32 width = SHORT(patch->width); - INT32 height = SHORT(patch->height); - INT32 leftoffset = SHORT(patch->leftoffset); + INT32 width = patch->width; + INT32 height = patch->height; + INT32 leftoffset = patch->leftoffset; INT32 newwidth, newheight; fixed_t ca = rollcosang[angle]; @@ -735,18 +837,11 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle // make patch rotated = (patch_t *)R_MaskedFlatToPatch(rawconv, width, height, 0, 0, &size); - rotated->leftoffset = ox; - rotated->topoffset = oy; - -#ifdef HWRENDER - if (rendermode == render_opengl) - { - rotated = R_CreateHardwarePatch(rotated); - } -#endif // HWRENDER - //Z_ChangeTag(rotated, PU_LEVEL); Z_SetUser(rotated, (void **)(&rotsprite->patches[idx])); Z_Free(rawconv); + + rotated->leftoffset = ox; + rotated->topoffset = oy; } #endif diff --git a/src/r_patch.h b/src/r_patch.h index 75347df3c..38df76b05 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -38,6 +38,15 @@ typedef struct boolean available; } spriteinfo_t; +// Patch functions +patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest); +void Patch_Free(patch_t *patch); + +#ifdef HWRENDER +void *Patch_AllocateHardwarePatch(patch_t *patch); +void *Patch_CreateGL(patch_t *patch); +#endif + // Conversions between patches / flats / textures... boolean R_CheckIfPatch(lumpnum_t lump); diff --git a/src/r_segs.c b/src/r_segs.c index 8a9f0dc29..313bae9b5 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -229,7 +229,7 @@ static void R_DrawWallSplats(void) continue; // draw the texture - col = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); + col = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); R_DrawSplatColumn(col); } } // next splat diff --git a/src/r_things.c b/src/r_things.c index c3a83880c..164e56814 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -254,7 +254,7 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT8 frame; UINT8 rotation; lumpinfo_t *lumpinfo; - patch_t patch; + softwarepatch_t patch; UINT8 numadded = 0; memset(sprtemp,0xFF, sizeof (sprtemp)); @@ -297,10 +297,10 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, // store sprite info in lookup tables //FIXME : numspritelumps do not duplicate sprite replacements W_ReadLumpHeaderPwad(wadnum, l, &patch, sizeof (patch_t), 0); - spritecachedinfo[numspritelumps].width = SHORT(patch.width)<columnofs[texturecolumn])); + column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); localcolfunc (column); } @@ -893,7 +893,7 @@ static void R_DrawVisSprite(vissprite_t *vis) for (dc_x = vis->x1; dc_x <= vis->x2 && (frac>>FRACBITS) < pwidth; dc_x++, frac += vis->xiscale) { texturecolumn = CLAMP(frac >> FRACBITS, 0, pwidth - 1); - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); + column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); localcolfunc (column); } @@ -961,7 +961,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) break; } - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); + column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); R_DrawMaskedColumn(column); } diff --git a/src/v_video.c b/src/v_video.c index 1d0b7ddfb..e46acb14e 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -635,7 +635,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca //if (rendermode != render_soft && !con_startup) // Why? if (rendermode == render_opengl) { - HWR_DrawStretchyFixedPatch((GLPatch_t *)patch, x, y, pscale, vscale, scrn, colormap, bflags); + HWR_DrawStretchyFixedPatch(patch, x, y, pscale, vscale, scrn, colormap, bflags); return; } #endif @@ -761,7 +761,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca // if it's meant to cover the whole screen, black out the rest (ONLY IF TOP LEFT ISN'T TRANSPARENT) if (x == 0 && SHORT(patch->width) == BASEVIDWIDTH && y == 0 && SHORT(patch->height) == BASEVIDHEIGHT) { - column = (const column_t *)((const UINT8 *)(patch) + LONG(patch->columnofs[0])); + column = (const column_t *)((const UINT8 *)(patch->columns) + (patch->columnofs[0])); if (!column->topdelta) { source = (const UINT8 *)(column) + 3; @@ -825,7 +825,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca if (x+offx >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION) break; } - column = (const column_t *)((const UINT8 *)(patch) + LONG(patch->columnofs[col>>FRACBITS])); + column = (const column_t *)((const UINT8 *)(patch->columns) + (patch->columnofs[col>>FRACBITS])); while (column->topdelta != 0xff) { @@ -872,7 +872,7 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ #ifdef HWRENDER if (rendermode == render_opengl) { - HWR_DrawCroppedPatch((GLPatch_t*)patch,x,y,pscale,scrn,sx,sy,w,h); + HWR_DrawCroppedPatch(patch, x, y, pscale, scrn, sx, sy, w, h); return; } #endif @@ -963,7 +963,7 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ continue; if (x >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION) break; - column = (const column_t *)((const UINT8 *)(patch) + LONG(patch->columnofs[col>>FRACBITS])); + column = (const column_t *)((const UINT8 *)(patch->columns) + (patch->columnofs[col>>FRACBITS])); while (column->topdelta != 0xff) { diff --git a/src/w_wad.c b/src/w_wad.c index 6432c3223..3642efe2f 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -821,11 +821,7 @@ UINT16 W_InitFile(const char *filename, boolean local) // set up caching // Z_Calloc(numlumps * sizeof (*wadfile->lumpcache), PU_STATIC, &wadfile->lumpcache); - -#ifdef HWRENDER - // allocates GLPatch info structures and store them in a tree - wadfile->hwrcache = M_AATreeAlloc(AATREE_ZUSER); -#endif + Z_Calloc(numlumps * sizeof (*wadfile->patchcache), PU_STATIC, &wadfile->patchcache); #ifdef ROTSPRITE // allocates rotsprite structures and store them in a tree @@ -1312,15 +1308,15 @@ UINT8 W_LumpExists(const char *name) return false; } -UINT8 W_CheckMultipleLumps(const char* lump, ...) +UINT8 W_CheckMultipleLumps(const char* lump, ...) { va_list lumps; va_start(lumps, lump); const char* lumpname = lump; - while (lumpname != NULL) + while (lumpname != NULL) { - if (!W_LumpExists(lumpname)) + if (!W_LumpExists(lumpname)) { va_end(lumps); return false; @@ -1629,7 +1625,6 @@ void *W_CacheLumpNumPwad(UINT16 wad, UINT16 lump, INT32 tag) void *W_CacheLumpNum(lumpnum_t lumpnum, INT32 tag) { - return W_CacheLumpNumPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum),tag); } @@ -1687,6 +1682,39 @@ boolean W_IsLumpCached(lumpnum_t lumpnum, void *ptr) return W_IsLumpCachedPWAD(WADFILENUM(lumpnum),LUMPNUM(lumpnum), ptr); } +// +// W_IsPatchCached +// +// If a patch is already cached return true, otherwise +// return false. +// +// no outside code uses the PWAD form, for now +static inline boolean W_IsPatchCachedPWAD(UINT16 wad, UINT16 lump, void *ptr) +{ + void *lcache; + + if (!TestValidLump(wad, lump)) + return false; + + lcache = wadfiles[wad]->patchcache[lump]; + + if (ptr) + { + if (ptr == lcache) + return true; + } + else if (lcache) + return true; + + return false; +} + +boolean W_IsPatchCached(lumpnum_t lumpnum, void *ptr) +{ + return W_IsPatchCachedPWAD(WADFILENUM(lumpnum),LUMPNUM(lumpnum), ptr); +} + + // ========================================================================== // W_CacheLumpName // ========================================================================== @@ -1711,40 +1739,59 @@ void *W_CacheLumpName(const char *name, INT32 tag) // // Software-only compile cache the data without conversion -#ifdef HWRENDER -FUNCINLINE static ATTRINLINE void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) +void *W_CacheSoftwarePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) { - GLPatch_t *glPatch; - - if (rendermode == render_soft || rendermode == render_none) - return W_CacheLumpNumPwad(wad, lump, tag); + lumpcache_t *lumpcache = NULL; if (!TestValidLump(wad, lump)) return NULL; - glPatch = HWR_GetCachedGLPatchPwad(wad, lump); + lumpcache = wadfiles[wad]->patchcache; - if (glPatch->mipmap->data) + if (!lumpcache[lump]) { - if (tag == PU_CACHE) - tag = PU_HWRCACHE; - Z_ChangeTag(glPatch->mipmap->data, tag); - } - else - { - patch_t *ptr = NULL; + size_t len = W_LumpLengthPwad(wad, lump); + void *ptr, *dest, *lumpdata = Z_Malloc(len, PU_STATIC, NULL); - // Only load the patch if we haven't initialised the glPatch yet - if (glPatch->mipmap->width == 0) - ptr = W_CacheLumpNumPwad(glPatch->wadnum, glPatch->lumpnum, PU_STATIC); + // read the lump in full + W_ReadLumpHeaderPwad(wad, lump, lumpdata, 0, 0); + ptr = lumpdata; + + dest = Z_Calloc(sizeof(patch_t), tag, &lumpcache[lump]); + Patch_Create(ptr, len, dest); - // Run HWR_MakePatch in all cases, to recalculate some things - HWR_MakePatch(ptr, glPatch, glPatch->mipmap, false); Z_Free(ptr); } + else + Z_ChangeTag(lumpcache[lump], tag); - // return GLPatch_t, which can be casted to (patch_t) with valid patch header info - return (void *)glPatch; + return lumpcache[lump]; +} + +void *W_CacheSoftwarePatchNum(lumpnum_t lumpnum, INT32 tag) +{ + return W_CacheSoftwarePatchNumPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum),tag); +} + +void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) +{ + patch_t *patch; + + if (!TestValidLump(wad, lump)) + return NULL; + + patch = W_CacheSoftwarePatchNumPwad(wad, lump, tag); + +#ifdef HWRENDER + // Software-only compile cache the data without conversion + if (rendermode == render_soft || rendermode == render_none) +#endif + return (void *)patch; + +#ifdef HWRENDER + Patch_CreateGL(patch); + return (void *)patch; +#endif } void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag) @@ -1752,8 +1799,6 @@ void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag) return W_CachePatchNumPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum),tag); } -#endif // HWRENDER - #ifdef ROTSPRITE // Caches a rotsprite for patch rotation. void *W_GetCachedRotPatchPwad(UINT16 wadnum, UINT16 lumpnum) @@ -1781,7 +1826,7 @@ void W_UnlockCachedPatch(void *patch) // have different lifetimes from software's. #ifdef HWRENDER if (rendermode == render_opengl) - HWR_UnlockCachedPatch((GLPatch_t*)patch); + HWR_UnlockCachedPatch((GLPatch_t *)((patch_t *)patch)->hardware); else #endif Z_ChangeTag(patch, PU_LEVEL); @@ -1826,7 +1871,7 @@ void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag) { INT32 xpivot = 0, ypivot = 0; - ptr = (patch_t *)(W_CacheLumpNum(num, PU_STATIC)); + ptr = W_CachePatchNum(num, PU_STATIC); // PU_PATCH // >y pivot centered // >x pivot not centered @@ -1835,9 +1880,6 @@ void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag) ypivot = SHORT(ptr->height) / 2; RotatedPatch_DoRotation(rspr, ptr, rotationangle, xpivot, ypivot, false); - - // free image data - Z_Free(ptr); } return rspr->patches[idx]; diff --git a/src/w_wad.h b/src/w_wad.h index d0eb28f2f..0de9057b6 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -125,9 +125,7 @@ typedef struct wadfile_s restype_t type; lumpinfo_t *lumpinfo; lumpcache_t *lumpcache; -#ifdef HWRENDER - aatree_t *hwrcache; // patches are cached in renderer's native format -#endif + lumpcache_t *patchcache; #ifdef ROTSPRITE aatree_t *rotcache; // Cache rotsprites for rotating patches. #endif @@ -208,18 +206,19 @@ void *W_CacheLumpNumPwad(UINT16 wad, UINT16 lump, INT32 tag); void *W_CacheLumpNum(lumpnum_t lump, INT32 tag); void *W_CacheLumpNumForce(lumpnum_t lumpnum, INT32 tag); +boolean W_IsPatchCached(lumpnum_t lump, void *ptr); boolean W_IsLumpCached(lumpnum_t lump, void *ptr); void *W_CacheLumpName(const char *name, INT32 tag); void *W_CachePatchName(const char *name, INT32 tag); -#ifdef HWRENDER -//void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag); // return a patch_t -void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag); // return a patch_t -#else -//#define W_CachePatchNumPwad(wad, lump, tag) W_CacheLumpNumPwad(wad, lump, tag) -#define W_CachePatchNum(lumpnum, tag) W_CacheLumpNum(lumpnum, tag) -#endif +// Returns either a Software patch, or an OpenGL patch. +void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag); +void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag); + +// Returns a Software patch. +void *W_CacheSoftwarePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag); +void *W_CacheSoftwarePatchNum(lumpnum_t lumpnum, INT32 tag); #ifdef ROTSPRITE void *W_GetCachedRotPatchPwad(UINT16 wadnum, UINT16 lumpnum); // Get patch-based rotsprites from the cache. diff --git a/src/y_inter.c b/src/y_inter.c index 444df52d4..213bf90d8 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -887,7 +887,7 @@ static void Y_FollowIntermission(void) G_AfterIntermission(); } -#define UNLOAD(x) Z_ChangeTag(x, PU_CACHE); x = NULL +#define UNLOAD(x) if (x) {Patch_Free(x);} x = NULL; // // Y_UnloadData From fe1579e960b1ae297b4fcd09e0438612e897a831 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 15:56:13 +0200 Subject: [PATCH 209/350] fuckit *unshortens your patch dimensions* --- src/console.c | 14 +++---- src/d_main.c | 2 +- src/f_finale.c | 12 +++--- src/hardware/hw_cache.c | 6 +-- src/hardware/hw_draw.c | 22 +++++------ src/hardware/hw_main.c | 8 ++-- src/hu_stuff.c | 18 +++------ src/k_kart.c | 40 ++++++++++---------- src/lua_hudlib.c | 26 ++++++------- src/m_menu.c | 30 +++++++-------- src/r_data.c | 4 +- src/r_patch.c | 10 ++--- src/r_segs.c | 4 +- src/r_things.c | 26 ++++++------- src/v_video.c | 82 ++++++++++++++++++++--------------------- src/w_wad.c | 1 - src/y_inter.c | 8 ++-- 17 files changed, 153 insertions(+), 160 deletions(-) diff --git a/src/console.c b/src/console.c index 3212521b0..8cc04fe93 100644 --- a/src/console.c +++ b/src/console.c @@ -621,11 +621,11 @@ static void CON_MoveConsole(void) con_curlines -= FixedInt(fracmovement); if (con_curlines < con_destlines) con_curlines = con_destlines; - + if (con_destlines == 0) // If the console is being closed, not just moved up... con_tick = 0; // ...don't show the blinking cursor } - + fracmovement %= FRACUNIT; // Reset fracmovement's integer value, but keep the fraction Unlock_state(); @@ -635,7 +635,7 @@ INT32 CON_ShiftChar(INT32 ch) { if (I_UseNativeKeyboard()) return ch; - + if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) { if (cv_keyboardlayout.value == 3) @@ -1244,7 +1244,7 @@ void CONS_Printf(const char *fmt, ...) if (con_started) CON_Print(txt); - + CON_LogMessage(txt); Lock_state(); @@ -1474,7 +1474,7 @@ static void CON_DrawHudlines(void) ;//charwidth = 4 * con_scalefactor; else { - //charwidth = SHORT(hu_font['A'-HU_FONTSTART]->width) * con_scalefactor; + //charwidth = hu_font['A'-HU_FONTSTART]->width * con_scalefactor; V_DrawCharacter(x, y, (INT32)(*p) | charflags | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value); } } @@ -1577,11 +1577,11 @@ void CON_Drawer(void) if (con_recalc) { CON_RecalcSize(); - + if (con_curlines <= 0) CON_ClearHUD(); } - + // console movement if (con_curlines != con_destlines) CON_MoveConsole(); diff --git a/src/d_main.c b/src/d_main.c index 8c986a24e..6f281421a 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -604,7 +604,7 @@ static boolean D_Display(void) else py = viewwindowy + 4; patch = W_CachePatchName("M_PAUSE", PU_CACHE); - V_DrawScaledPatch(viewwindowx + (BASEVIDWIDTH - SHORT(patch->width))/2, py, V_SNAPTOTOP, patch); + V_DrawScaledPatch(viewwindowx + (BASEVIDWIDTH - patch->width)/2, py, V_SNAPTOTOP, patch); } if (rendermode == render_soft && demo.rewinding) diff --git a/src/f_finale.c b/src/f_finale.c index 1b8d236fe..a534eee68 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -170,8 +170,8 @@ static void F_SkyScroll(INT32 scrollspeed) w = (vid.width / vid.dupx)<width)*16))<width)<width)*16))<width*16))<width<width*16))<width)<width<height))<height)<width)<width<width))/2, 32, 0, contsonic); + V_DrawScaledPatch((BASEVIDWIDTH - contsonic->width)/2, 32, 0, contsonic); // Draw the continue markers! Show continues minus one. x -= ncontinues * 6; diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 6fef6d0a9..836d3adac 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -1090,15 +1090,15 @@ static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32 W_ReadLump(fademasklumpnum, Z_Malloc(W_LumpLength(fademasklumpnum), PU_HWRCACHE, &flat)); - stepy = ((INT32)SHORT(fmheight)<width)]; // 1bpp - src = &flat[(posy>>FRACBITS)*SHORT(fmwidth)]; + src = &flat[(posy>>FRACBITS)*fmwidth]; for (i = 0; i < pblockwidth;i++) { // fademask bpp is always 1, and is used just for alpha diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 9a7f19995..d47d58841 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -108,10 +108,10 @@ void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option) if (option & V_NOSCALESTART) sdupx = sdupy = 2.0f; - v[0].x = v[3].x = (x*sdupx-(gpatch->leftoffset)*pdupx)/vid.width - 1; - v[2].x = v[1].x = (x*sdupx+((gpatch->width)-(gpatch->leftoffset))*pdupx)/vid.width - 1; - v[0].y = v[1].y = 1-(y*sdupy-(gpatch->topoffset)*pdupy)/vid.height; - v[2].y = v[3].y = 1-(y*sdupy+((gpatch->height)-(gpatch->topoffset))*pdupy)/vid.height; + v[0].x = v[3].x = (x*sdupx-gpatch->leftoffset*pdupx)/vid.width - 1; + v[2].x = v[1].x = (x*sdupx+(gpatch->width - gpatch->leftoffset)*pdupx)/vid.width - 1; + v[0].y = v[1].y = 1-(y*sdupy-gpatch->topoffset*pdupy)/vid.height; + v[2].y = v[3].y = 1-(y*sdupy+(gpatch->height - gpatch->topoffset)*pdupy)/vid.height; v[0].z = v[1].z = v[2].z = v[3].z = 1.0f; @@ -191,7 +191,7 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p // left offset if (option & V_FLIP) - offsetx = (float)((gpatch->width) - (gpatch->leftoffset)) * fscalew; + offsetx = (float)(gpatch->width - gpatch->leftoffset) * fscalew; else offsetx = (float)(gpatch->leftoffset) * fscalew; @@ -225,7 +225,7 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p // if it's meant to cover the whole screen, black out the rest // cx and cy are possibly *slightly* off from float maths // This is done before here compared to software because we directly alter cx and cy to centre - if (cx >= -0.1f && cx <= 0.1f && (gpatch->width) == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && (gpatch->height) == BASEVIDHEIGHT) + if (cx >= -0.1f && cx <= 0.1f && gpatch->width == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && gpatch->height == BASEVIDHEIGHT) { const column_t *column = (const column_t *)((const UINT8 *)(gpatch->columns) + (gpatch->columnofs[0])); @@ -376,7 +376,7 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, // if it's meant to cover the whole screen, black out the rest // cx and cy are possibly *slightly* off from float maths // This is done before here compared to software because we directly alter cx and cy to centre - if (cx >= -0.1f && cx <= 0.1f && (gpatch->width) == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && (gpatch->height) == BASEVIDHEIGHT) + if (cx >= -0.1f && cx <= 0.1f && gpatch->width == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && gpatch->height == BASEVIDHEIGHT) { const column_t *column = (const column_t *)((const UINT8 *)(gpatch->columns) + (gpatch->columnofs[0])); @@ -415,11 +415,11 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, if (fheight > h - sy) fheight = h - sy; - if (fwidth > (gpatch->width)) - fwidth = (gpatch->width); + if (fwidth > gpatch->width) + fwidth = gpatch->width; - if (fheight > (gpatch->height)) - fheight = (gpatch->height); + if (fheight > gpatch->height) + fheight = gpatch->height; if (pscale != FRACUNIT) { diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 77e9e598a..8e877a044 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4797,10 +4797,10 @@ static void HWR_ProjectSprite(mobj_t *thing) if (rotsprite != NULL) { - spr_width = SHORT(rotsprite->width) << FRACBITS; - spr_height = SHORT(rotsprite->height) << FRACBITS; - spr_offset = SHORT(rotsprite->leftoffset) << FRACBITS; - spr_topoffset = SHORT(rotsprite->topoffset) << FRACBITS; + spr_width = rotsprite->width << FRACBITS; + spr_height = rotsprite->height << FRACBITS; + spr_offset = rotsprite->leftoffset << FRACBITS; + spr_topoffset = rotsprite->topoffset << FRACBITS; spr_topoffset += FEETADJUST; // flip -> rotate, not rotate -> flip diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 268059d06..b7984c1e5 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1949,17 +1949,11 @@ static void HU_DrawChat_Old(void) const char *ntalk = "Say: ", *ttalk = "Say-Team: "; const char *talk = ntalk; size_t select_start = 0, select_end = 0; - INT32 charwidth = 8 * con_scalefactor; //SHORT(hu_font['A'-HU_FONTSTART]->width) * con_scalefactor; - INT32 charheight = 8 * con_scalefactor; //SHORT(hu_font['A'-HU_FONTSTART]->height) * con_scalefactor; + INT32 charwidth = 8 * con_scalefactor; //hu_font['A'-HU_FONTSTART]->width * con_scalefactor; + INT32 charheight = 8 * con_scalefactor; //hu_font['A'-HU_FONTSTART]->height * con_scalefactor; if (teamtalk) { talk = ttalk; -#if 0 - if (players[consoleplayer].ctfteam == 1) - t = 0x500; // Red - else if (players[consoleplayer].ctfteam == 2) - t = 0x400; // Blue -#endif } while (talk[i]) @@ -1971,7 +1965,7 @@ static void HU_DrawChat_Old(void) } else { - //charwidth = SHORT(hu_font[talk[i]-HU_FONTSTART]->width) * con_scalefactor; + //charwidth = hu_font[talk[i]-HU_FONTSTART]->width * con_scalefactor; V_DrawCharacter(HU_INPUTX + c, y, talk[i++] | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value); } c += charwidth; @@ -1999,7 +1993,7 @@ static void HU_DrawChat_Old(void) //Hurdler: isn't it better like that? if (w_chat_buf[i] >= HU_FONTSTART) { - //charwidth = SHORT(hu_font[w_chat[i]-HU_FONTSTART]->width) * con_scalefactor; + //charwidth = hu_font[w_chat[i]-HU_FONTSTART]->width * con_scalefactor; V_DrawCharacter(HU_INPUTX + c, y, w_chat_buf[i] | cv_constextsize.value | V_NOSCALESTART | t, !cv_allcaps.value); } @@ -2638,7 +2632,7 @@ static void HU_DrawRankings(void) else p = bmatcico; - V_DrawSmallScaledPatch(128 - SHORT(p->width)/4, 4, 0, p); + V_DrawSmallScaledPatch(128 - p->width/4, 4, 0, p); V_DrawCenteredString(128, 16, 0, va("%u", bluescore)); if (gametype == GT_CTF) @@ -2646,7 +2640,7 @@ static void HU_DrawRankings(void) else p = rmatcico; - V_DrawSmallScaledPatch(192 - SHORT(p->width)/4, 4, 0, p); + V_DrawSmallScaledPatch(192 - p->width/4, 4, 0, p); V_DrawCenteredString(192, 16, 0, va("%u", redscore)); } diff --git a/src/k_kart.c b/src/k_kart.c index 1d2bde533..fb14741cc 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9045,7 +9045,7 @@ static void K_DrawKartPositionNum(INT32 num) const boolean wheeloffs = (cv_showinput.value && cv_posi_xoffset.value == 0 && cv_posi_yoffset.value == 0 && cv_wheel_xoffset.value == 0 && cv_wheel_yoffset.value == 0); boolean win = (stplyr->exiting && num == 1); //INT32 X = POSI_X; - INT32 W = SHORT(kp_positionnum[0][0]->width); + INT32 W = kp_positionnum[0][0]->width; fixed_t scale = FRACUNIT; patch_t *localpatch = kp_positionnum[0][0]; //INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTORIGHT); @@ -9159,7 +9159,7 @@ static void K_DrawKartPositionNum(INT32 num) localpatch = kp_positionnum[num % 10][0]; } - V_DrawFixedPatch((fx<width)*scale/2) : 0), (fy<height)*scale/2) : 0), scale, V_HUDTRANSHALF|fflags, localpatch, NULL); + V_DrawFixedPatch((fx<width*scale/2) : 0), (fy<height*scale/2) : 0), scale, V_HUDTRANSHALF|fflags, localpatch, NULL); // ^ if we overtake as p1 or p3 in splitscren, we shift it so that it doesn't go off screen. // ^ if we overtake as p1 in 2p splits, shift vertically so that this doesn't happen either. @@ -9493,9 +9493,9 @@ static void K_DrawDialNum(INT32 x, INT32 y, boolean colorized, INT32 flags, INT3 INT32 w; if (colorized) - w = SHORT(skp_dialnumclr[0]->width); + w = skp_dialnumclr[0]->width; else - w = SHORT(skp_dialnum[0]->width); + w = skp_dialnum[0]->width; if (flags & V_NOSCALESTART) w *= vid.dupx; @@ -10436,7 +10436,7 @@ static void K_drawKartWanted(void) } else if (splitscreen == 3) // 4P splitscreen... { - basex = BASEVIDWIDTH/2 - (SHORT(kp_wantedsplit->width)/2); // center on screen + basex = BASEVIDWIDTH/2 - (kp_wantedsplit->width/2); // center on screen basey = BASEVIDHEIGHT - 55; //basey2 = 4; } @@ -10559,8 +10559,8 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) if (encoremode) amnumxpos = -amnumxpos; - amxpos = amnumxpos + ((x + (SHORT(minimapinfo.minimap_pic->width)-SHORT(minimaphead->width)) / 2)<height)-SHORT(minimaphead->height)) / 2)<width-minimaphead->width) / 2)<height-minimaphead->height) / 2)<width) / 4)<height) / 4)<width / 4)<height / 4)<width)/2); - y = info.y - (SHORT(minimapinfo.minimap_pic->height)/2); + x = info.x - (minimapinfo.minimap_pic->width/2); + y = info.y - (minimapinfo.minimap_pic->height/2); splitflags = info.flags; splitflags |= minimaptrans; if (encoremode) - V_DrawScaledPatch(x+SHORT(minimapinfo.minimap_pic->width), y, splitflags|V_FLIP, minimapinfo.minimap_pic); + V_DrawScaledPatch(x+minimapinfo.minimap_pic->width, y, splitflags|V_FLIP, minimapinfo.minimap_pic); else V_DrawScaledPatch(x, y, splitflags, minimapinfo.minimap_pic); @@ -10665,10 +10665,10 @@ static void K_drawKartMinimap(void) // let offsets transfer to the heads, too! if (encoremode) - x += SHORT(minimapinfo.minimap_pic->leftoffset); + x += minimapinfo.minimap_pic->leftoffset; else - x -= SHORT(minimapinfo.minimap_pic->leftoffset); - y -= SHORT(minimapinfo.minimap_pic->topoffset); + x -= minimapinfo.minimap_pic->leftoffset; + y -= minimapinfo.minimap_pic->topoffset; // initialize for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) @@ -10749,7 +10749,7 @@ static void K_drawKartStartCountdown(void) if (splitscreen) // splitscreen pnum += 8; - V_DrawScaledPatch(STCD_X - (SHORT(kp_startcountdown[pnum]->width)/2), STCD_Y - (SHORT(kp_startcountdown[pnum]->height)/2), splitflags, kp_startcountdown[pnum]); + V_DrawScaledPatch(STCD_X - (kp_startcountdown[pnum]->width/2), STCD_Y - (kp_startcountdown[pnum]->height/2), splitflags, kp_startcountdown[pnum]); } static void K_drawKartFinish(void) @@ -10765,7 +10765,7 @@ static void K_drawKartFinish(void) if (splitscreen > 1) // 3/4p, stationary FIN { pnum += 2; - V_DrawScaledPatch(STCD_X - (SHORT(kp_racefinish[pnum]->width)/2), STCD_Y - (SHORT(kp_racefinish[pnum]->height)/2), splitflags, kp_racefinish[pnum]); + V_DrawScaledPatch(STCD_X - (kp_racefinish[pnum]->width/2), STCD_Y - (kp_racefinish[pnum]->height/2), splitflags, kp_racefinish[pnum]); return; } @@ -10777,14 +10777,14 @@ static void K_drawKartFinish(void) pnum += 4; x = ((vid.width<width)<width<kartstuff[k_cardanimation])< x ? xval : x))/TICRATE; if (splitscreen && stplyrnum == 1) x = -x; V_DrawFixedPatch(x + (STCD_X<>1), - (STCD_Y<height)<<(FRACBITS-1)), + (STCD_Y<height<<(FRACBITS-1)), FRACUNIT, splitflags, kp_racefinish[pnum], NULL); } @@ -11705,7 +11705,7 @@ void K_drawKartHUD(void) return; if (G_BattleGametype() && !splitscreen && (stplyr->kartstuff[k_yougotem] % 2)) // * YOU GOT EM * - V_DrawScaledPatch(BASEVIDWIDTH/2 - (SHORT(kp_yougotem->width)/2), 32, V_HUDTRANS, kp_yougotem); + V_DrawScaledPatch(BASEVIDWIDTH/2 - (kp_yougotem->width/2), 32, V_HUDTRANS, kp_yougotem); // Draw FREE PLAY. if (isfreeplay && !stplyr->spectator && timeinmap > 113) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index dc2e8f824..5bfb21e2e 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -303,16 +303,16 @@ static int patch_get(lua_State *L) lua_pushboolean(L, patch != NULL); break; case patch_width: - lua_pushinteger(L, SHORT(patch->width)); + lua_pushinteger(L, patch->width); break; case patch_height: - lua_pushinteger(L, SHORT(patch->height)); + lua_pushinteger(L, patch->height); break; case patch_leftoffset: - lua_pushinteger(L, SHORT(patch->leftoffset)); + lua_pushinteger(L, patch->leftoffset); break; case patch_topoffset: - lua_pushinteger(L, SHORT(patch->topoffset)); + lua_pushinteger(L, patch->topoffset); break; } return 1; @@ -657,27 +657,27 @@ static int libd_drawOnMinimap(lua_State *L) splitflags |= V_HUDTRANS; // Handle offsets and stuff. - mm_x = info.x - (SHORT(AutomapPic->width)/2); - mm_y = info.y - (SHORT(AutomapPic->height)/2); + mm_x = info.x - (AutomapPic->width/2); + mm_y = info.y - (AutomapPic->height/2); // let offsets transfer to the heads, too! if (encoremode) { - mm_x += SHORT(AutomapPic->leftoffset); + mm_x += AutomapPic->leftoffset; } else { - mm_x -= SHORT(AutomapPic->leftoffset); + mm_x -= AutomapPic->leftoffset; } - mm_y -= SHORT(AutomapPic->topoffset); + mm_y -= AutomapPic->topoffset; // patch is supposedly already centered, don't butt in. if (!centered) { // scale patch coords - patchw = (SHORT(patch->width) * scale / 2); - patchh = (SHORT(patch->height) * scale / 2); + patchw = (patch->width * scale / 2); + patchh = (patch->height * scale / 2); } amnumxpos = (FixedMul(x, minimapinfo.zoom) - minimapinfo.offs_x); @@ -688,8 +688,8 @@ static int libd_drawOnMinimap(lua_State *L) amnumxpos = -amnumxpos; } - amxpos = amnumxpos + ((mm_x + SHORT(AutomapPic->width) / 2)<height) / 2)<width / 2)<height / 2)<width) - SHORT(p->leftoffset); + xx += p->width - p->leftoffset; for (i = 0; i < 16; i++) { V_DrawScaledPatch(xx, y, V_WRAPX, W_CachePatchNum(centerlump[i & 1], PU_CACHE)); @@ -5192,8 +5192,8 @@ static void M_DrawMenuTitle(void) if (p->height > 24) // title is larger than normal { - INT32 xtitle = (BASEVIDWIDTH - (SHORT(p->width)/2))/2; - INT32 ytitle = (30 - (SHORT(p->height)/2))/2; + INT32 xtitle = (BASEVIDWIDTH - (p->width/2))/2; + INT32 ytitle = (30 - (p->height/2))/2; if (xtitle < 0) xtitle = 0; @@ -5204,8 +5204,8 @@ static void M_DrawMenuTitle(void) } else { - INT32 xtitle = (BASEVIDWIDTH - SHORT(p->width))/2; - INT32 ytitle = (30 - SHORT(p->height))/2; + INT32 xtitle = (BASEVIDWIDTH - p->width)/2; + INT32 ytitle = (30 - p->height)/2; if (xtitle < 0) xtitle = 0; @@ -5293,7 +5293,7 @@ static void M_DrawGenericMenu(void) { patch_t *p; p = W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE); - V_DrawScaledPatch((BASEVIDWIDTH - SHORT(p->width))/2, y, 0, p); + V_DrawScaledPatch((BASEVIDWIDTH - p->width)/2, y, 0, p); } else { @@ -5621,7 +5621,7 @@ static void M_DrawCenteredMenu(void) if (currentMenu->menuitems[i].status & IT_CENTER) { - V_DrawScaledPatch((BASEVIDWIDTH - SHORT(p->width))/2, y, 0, p); + V_DrawScaledPatch((BASEVIDWIDTH - p->width)/2, y, 0, p); } else { @@ -6052,7 +6052,7 @@ static void M_DrawMessageMenu(void) } V_DrawString((BASEVIDWIDTH - V_StringWidth(string, 0))/2,y,V_ALLOWLOWERCASE,string); - y += 8; //SHORT(hu_font[0]->height); + y += 8; //hu_font[0]->height; } } @@ -7222,8 +7222,8 @@ static void DrawReplayHutReplayInfo(void) V_DrawSmallScaledPatch(x, y, V_SNAPTOTOP, patch); else { - w = SHORT(patch->width); - h = SHORT(patch->height); + w = patch->width; + h = patch->height; V_DrawSmallScaledPatch(x+(w>>1), y, V_SNAPTOTOP|V_FLIP, patch); { @@ -7314,7 +7314,7 @@ static void DrawReplayHutReplayInfo(void) GTC_MENUCACHE); } - V_DrawMappedPatch(BASEVIDWIDTH-15 - SHORT(patch->width), y+20, V_SNAPTOTOP, patch, colormap); + V_DrawMappedPatch(BASEVIDWIDTH-15 - patch->width, y+20, V_SNAPTOTOP, patch, colormap); break; } @@ -7533,7 +7533,7 @@ static void M_DrawReplayStartMenu(void) GTC_MENUCACHE); } - V_DrawMappedPatch(BASEVIDWIDTH-5 - SHORT(patch->width), STARTY + i*20, V_SNAPTOTOP, patch, colormap); + V_DrawMappedPatch(BASEVIDWIDTH-5 - patch->width, STARTY + i*20, V_SNAPTOTOP, patch, colormap); } #undef STARTY @@ -9132,7 +9132,7 @@ void M_DrawTimeAttackMenu(void) if (W_CheckNumForName(skins[cv_chooseskin.value-1].facewant) != LUMPERROR) { UINT8 *colormap = R_GetTranslationColormap(cv_chooseskin.value-1, cv_playercolor.value, GTC_MENUCACHE); - V_DrawMappedPatch(BASEVIDWIDTH-x - SHORT(facewantprefix[cv_chooseskin.value-1]->width), y, 0, facewantprefix[cv_chooseskin.value-1], colormap); + V_DrawMappedPatch(BASEVIDWIDTH-x - facewantprefix[cv_chooseskin.value-1]->width, y, 0, facewantprefix[cv_chooseskin.value-1], colormap); } for (i = 0; i < currentMenu->numitems; ++i) @@ -10254,8 +10254,8 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) else PictureOfLevel = W_CachePatchName("RANDOMLV", PU_CACHE); - w = SHORT(PictureOfLevel->width)/2; - i = SHORT(PictureOfLevel->height)/2; + w = PictureOfLevel->width/2; + i = PictureOfLevel->height/2; x = BASEVIDWIDTH/2 - w/2; y = currentMenu->y + 130 + 8 - i; diff --git a/src/r_data.c b/src/r_data.c index ec84cf3bf..de4d239fa 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -642,8 +642,8 @@ void R_LoadTextures(void) // Set texture properties. M_Memcpy(texture->name, W_CheckNameForNumPwad((UINT16)w, texstart + j), sizeof(texture->name)); - texture->width = SHORT(patchlump->width); - texture->height = SHORT(patchlump->height); + texture->width = patchlump->width; + texture->height = patchlump->height; texture->patchcount = 1; texture->holes = false; diff --git a/src/r_patch.c b/src/r_patch.c index 2320b9e52..665b50122 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -344,10 +344,10 @@ patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest) size_t size = sizeof(INT32) * source->width; size_t offs = (sizeof(INT16) * 4) + size; - patch->width = source->width; - patch->height = source->height; - patch->leftoffset = source->leftoffset; - patch->topoffset = source->topoffset; + patch->width = SHORT(source->width); + patch->height = SHORT(source->height); + patch->leftoffset = SHORT(source->leftoffset); + patch->topoffset = SHORT(source->topoffset); patch->columnofs = Z_Calloc(size, PU_CACHE, NULL); for (col = 0; col < source->width; col++) @@ -800,7 +800,7 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle } ox = (newwidth / 2) + (leftoffset - xpivot); - oy = (newheight / 2) + (SHORT(patch->topoffset) - ypivot); + oy = (newheight / 2) + (patch->topoffset - ypivot); width = (maxx - minx); height = (maxy - miny); diff --git a/src/r_segs.c b/src/r_segs.c index 313bae9b5..d1f46b6e8 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -173,7 +173,7 @@ static void R_DrawWallSplats(void) patch = W_CachePatchNum(splat->patch, PU_CACHE); - dc_texturemid = splat->top + (SHORT(patch->height)<<(FRACBITS-1)) - viewz; + dc_texturemid = splat->top + (patch->height<<(FRACBITS-1)) - viewz; if (splat->yoffset) dc_texturemid += *splat->yoffset; @@ -225,7 +225,7 @@ static void R_DrawWallSplats(void) // FIXME! texturecolumn >>= FRACBITS; - if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width)) + if (texturecolumn < 0 || texturecolumn >= patch->width) continue; // draw the texture diff --git a/src/r_things.c b/src/r_things.c index 164e56814..57ec53e5e 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -297,10 +297,10 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, // store sprite info in lookup tables //FIXME : numspritelumps do not duplicate sprite replacements W_ReadLumpHeaderPwad(wadnum, l, &patch, sizeof (patch_t), 0); - spritecachedinfo[numspritelumps].width = (patch.width)<startfrac < 0 || vis->startfrac > (SHORT(patch->width) << FRACBITS)) + if (vis->startfrac < 0 || vis->startfrac > (patch->width << FRACBITS)) { // never draw vissprites with startfrac out of patch range return; @@ -814,7 +814,7 @@ static void R_DrawVisSprite(vissprite_t *vis) dc_colormap += COLORMAP_REMAPOFFSET; dc_texturemid = vis->texturemid; - dc_texheight = SHORT(patch->height); + dc_texheight = patch->height; frac = vis->startfrac; windowtop = windowbottom = sprbotscreen = INT32_MAX; @@ -858,8 +858,8 @@ static void R_DrawVisSprite(vissprite_t *vis) vis->x2 = vid.width-1; localcolfunc = (vis->vflip) ? R_DrawFlippedMaskedColumn : R_DrawMaskedColumn; - lengthcol = SHORT(patch->height); - pwidth = SHORT(patch->width); + lengthcol = patch->height; + pwidth = patch->width; // Split drawing loops for paper and non-paper to reduce conditional checks per sprite if (vis->scalestep) @@ -938,7 +938,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) dc_iscale = FixedDiv(FRACUNIT, vis->scale); dc_texturemid = FixedDiv(vis->texturemid, this_scale); - dc_texheight = SHORT(patch->height); + dc_texheight = patch->height; frac = vis->startfrac; spryscale = vis->scale; @@ -1391,10 +1391,10 @@ static void R_ProjectSprite(mobj_t *thing) if (rotsprite != NULL) { - spr_width = SHORT(rotsprite->width) << FRACBITS; - spr_height = SHORT(rotsprite->height) << FRACBITS; - spr_offset = SHORT(rotsprite->leftoffset) << FRACBITS; - spr_topoffset = SHORT(rotsprite->topoffset) << FRACBITS; + spr_width = rotsprite->width << FRACBITS; + spr_height = rotsprite->height << FRACBITS; + spr_offset = rotsprite->leftoffset << FRACBITS; + spr_topoffset = rotsprite->topoffset << FRACBITS; spr_topoffset += FEETADJUST; // flip -> rotate, not rotate -> flip diff --git a/src/v_video.c b/src/v_video.c index e46acb14e..413829a8b 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -710,13 +710,13 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca // left offset if (scrn & V_FLIP) - offsetx = FixedMul((SHORT(patch->width) - SHORT(patch->leftoffset))<width - patch->leftoffset)<leftoffset)<leftoffset<topoffset)<topoffset<width) == BASEVIDWIDTH && y == 0 && SHORT(patch->height) == BASEVIDHEIGHT) + if (x == 0 && patch->width == BASEVIDWIDTH && y == 0 && patch->height == BASEVIDHEIGHT) { column = (const column_t *)((const UINT8 *)(patch->columns) + (patch->columnofs[0])); if (!column->topdelta) @@ -797,18 +797,18 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca if (pscale != FRACUNIT) // scale width properly { - pwidth = SHORT(patch->width)<width<>= FRACBITS; } else - pwidth = SHORT(patch->width) * dupx; + pwidth = patch->width * dupx; deststart = desttop; destend = desttop + pwidth; - for (col = 0; (col>>FRACBITS) < SHORT(patch->width); col += colfrac, ++offx, desttop++) + for (col = 0; (col>>FRACBITS) < patch->width; col += colfrac, ++offx, desttop++) { INT32 topdelta, prevdelta = -1; if (scrn & V_FLIP) // offx is measured from right edge instead of left @@ -905,8 +905,8 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ colfrac = FixedDiv(FRACUNIT, fdup); rowfrac = FixedDiv(FRACUNIT, fdup); - y -= FixedMul(SHORT(patch->topoffset)<leftoffset)<topoffset<leftoffset<>FRACBITS) < SHORT(patch->width) && ((col>>FRACBITS) - sx) < w; col += colfrac, ++x, desttop++) + for (col = sx<>FRACBITS) < patch->width && ((col>>FRACBITS) - sx) < w; col += colfrac, ++x, desttop++) { INT32 topdelta, prevdelta = -1; if (x < 0) // don't draw off the left of the screen (WRAP PREVENTION) @@ -1505,7 +1505,7 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum) void V_DrawPatchFill(patch_t *pat) { INT32 dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); - INT32 x, y, pw = SHORT(pat->width) * dupz, ph = SHORT(pat->height) * dupz; + INT32 x, y, pw = pat->width * dupz, ph = pat->height * dupz; for (x = 0; x < vid.width; x += pw) { @@ -1706,7 +1706,7 @@ void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed) if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) return; - w = SHORT(hu_font[c]->width); + w = hu_font[c]->width; if (x + w > vid.width) return; @@ -1733,7 +1733,7 @@ void V_DrawChatCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed, UI if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) return; - w = SHORT(hu_font[c]->width)/2; + w = hu_font[c]->width/2; if (x + w > vid.width) return; @@ -1899,10 +1899,10 @@ void V_DrawString(INT32 x, INT32 y, INT32 option, const char *string) if (charwidth) { w = charwidth * dupx; - center = w/2 - SHORT(hu_font[c]->width)*dupx/2; + center = w/2 - hu_font[c]->width*dupx/2; } else - w = SHORT(hu_font[c]->width) * dupx; + w = hu_font[c]->width * dupx; if (cx > scrwidth) break; @@ -2001,10 +2001,10 @@ void V_DrawKartString(INT32 x, INT32 y, INT32 option, const char *string) if (charwidth) { w = charwidth * dupx; - center = w/2 - SHORT(kart_font[c]->width)*dupx/2; + center = w/2 - kart_font[c]->width*dupx/2; } else - w = SHORT(kart_font[c]->width) * dupx; + w = kart_font[c]->width * dupx; if (cx > scrwidth) break; @@ -2119,10 +2119,10 @@ void V_DrawSmallString(INT32 x, INT32 y, INT32 option, const char *string) if (charwidth) { w = charwidth * dupx; - center = w/2 - SHORT(hu_font[c]->width)*dupx/4; + center = w/2 - hu_font[c]->width*dupx/4; } else - w = SHORT(hu_font[c]->width) * dupx / 2; + w = hu_font[c]->width * dupx / 2; if (cx > scrwidth) break; if (cx+left + w < 0) //left boundary check @@ -2236,8 +2236,8 @@ void V_DrawThinString(INT32 x, INT32 y, INT32 option, const char *string) if (charwidth) w = charwidth * dupx; else - w = ((option & V_6WIDTHSPACE ? max(1, SHORT(tny_font[c]->width)-1) // Reuse this flag for the alternate bunched-up spacing - : SHORT(tny_font[c]->width)) * dupx); + w = ((option & V_6WIDTHSPACE ? max(1, tny_font[c]->width-1) // Reuse this flag for the alternate bunched-up spacing + : tny_font[c]->width) * dupx); if (cx > scrwidth) break; @@ -2337,10 +2337,10 @@ void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) if (charwidth) { w = charwidth * dupx; - center = w/2 - SHORT(hu_font[c]->width)*(dupx/2); + center = w/2 - hu_font[c]->width*(dupx/2); } else - w = SHORT(hu_font[c]->width) * dupx; + w = hu_font[c]->width * dupx; if ((cx>>FRACBITS) > scrwidth) break; @@ -2535,10 +2535,10 @@ void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *str if (charwidth) { w = charwidth * dupx; - center = w/2 - SHORT(tny_font[c]->width)*(dupx/2); + center = w/2 - tny_font[c]->width*(dupx/2); } else - w = SHORT(tny_font[c]->width) * dupx; + w = tny_font[c]->width * dupx; if ((cx>>FRACBITS) > scrwidth) break; @@ -2558,7 +2558,7 @@ void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *str // Draws a tallnum. Replaces two functions in y_inter and st_stuff void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num) { - INT32 w = SHORT(tallnum[0]->width); + INT32 w = tallnum[0]->width; boolean neg; if (flags & V_NOSCALESTART) @@ -2584,7 +2584,7 @@ void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num) // Does not handle negative numbers in a special way, don't try to feed it any. void V_DrawPaddedTallNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits) { - INT32 w = SHORT(tallnum[0]->width); + INT32 w = tallnum[0]->width; if (flags & V_NOSCALESTART) w *= vid.dupx; @@ -2605,7 +2605,7 @@ void V_DrawPaddedTallNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits) // Does not handle negative numbers in a special way, don't try to feed it any. void V_DrawPaddedTallColorNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits, const UINT8 *colormap) { - INT32 w = SHORT(tallnum[0]->width); + INT32 w = tallnum[0]->width; if (flags & V_NOSCALESTART) w *= vid.dupx; @@ -2627,7 +2627,7 @@ void V_DrawPaddedTallColorNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 di INT32 V_DrawPingNum(INT32 x, INT32 y, INT32 flags, INT32 num, const UINT8 *colormap) { - INT32 w = SHORT(pingnum[0]->width); // this SHOULD always be 5 but I guess custom graphics exist. + INT32 w = pingnum[0]->width; // this SHOULD always be 5 but I guess custom graphics exist. if (flags & V_NOSCALESTART) w *= vid.dupx; @@ -2650,7 +2650,7 @@ INT32 V_DrawPingNum(INT32 x, INT32 y, INT32 flags, INT32 num, const UINT8 *color // void V_DrawRankNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits, const UINT8 *colormap) { - INT32 w = SHORT(ranknum[0]->width) - 1; + INT32 w = ranknum[0]->width - 1; if (flags & V_NOSCALESTART) w *= vid.dupx; @@ -2709,7 +2709,7 @@ void V_DrawCreditString(fixed_t x, fixed_t y, INT32 option, const char *string) continue; } - w = SHORT(cred_font[c]->width) * dupx; + w = cred_font[c]->width * dupx; if ((cx>>FRACBITS) > scrwidth) break; @@ -2735,7 +2735,7 @@ INT32 V_CreditStringWidth(const char *string) if (c < 0 || c >= CRED_FONTSIZE) w += 16; else - w += SHORT(cred_font[c]->width); + w += cred_font[c]->width; } return w; @@ -2782,7 +2782,7 @@ void V_DrawLevelTitle(INT32 x, INT32 y, INT32 option, const char *string) continue; } - w = SHORT(lt_font[c]->width) * dupx; + w = lt_font[c]->width * dupx; if (cx > scrwidth) break; if (cx+left + w < 0) //left boundary check @@ -2809,7 +2809,7 @@ INT32 V_LevelNameWidth(const char *string) if (c < 0 || c >= LT_FONTSIZE || !lt_font[c]) w += 12; else - w += SHORT(lt_font[c]->width); + w += lt_font[c]->width; } return w; @@ -2828,8 +2828,8 @@ INT32 V_LevelNameHeight(const char *string) if (c < 0 || c >= LT_FONTSIZE || !lt_font[c]) continue; - if (SHORT(lt_font[c]->height) > w) - w = SHORT(lt_font[c]->height); + if (lt_font[c]->height > w) + w = lt_font[c]->height; } return w; @@ -2871,7 +2871,7 @@ INT32 V_SubStringWidth(const char *string, INT32 length, INT32 option) if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) w += spacewidth; else - w += (charwidth ? charwidth : SHORT(hu_font[c]->width)); + w += (charwidth ? charwidth : hu_font[c]->width); } return w; @@ -2913,7 +2913,7 @@ INT32 V_SmallSubStringWidth(const char *string, INT32 length, INT32 option) if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) w += spacewidth; else - w += (charwidth ? charwidth : SHORT(hu_font[c]->width)/2); + w += (charwidth ? charwidth : hu_font[c]->width/2); } return w; @@ -2965,8 +2965,8 @@ INT32 V_ThinSubStringWidth(const char *string, INT32 length, INT32 option) else { w += (charwidth ? charwidth - : ((option & V_6WIDTHSPACE && i < length-1) ? max(1, SHORT(tny_font[c]->width)-1) // Reuse this flag for the alternate bunched-up spacing - : SHORT(tny_font[c]->width))); + : ((option & V_6WIDTHSPACE && i < length-1) ? max(1, tny_font[c]->width-1) // Reuse this flag for the alternate bunched-up spacing + : tny_font[c]->width)); } } @@ -3007,7 +3007,7 @@ INT32 V_SubStringLengthToFit(const char *string, INT32 width, INT32 option) if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) w += spacewidth; else - w += (charwidth ? charwidth : SHORT(hu_font[c]->width)); + w += (charwidth ? charwidth : hu_font[c]->width); } return max(i-1, 0); diff --git a/src/w_wad.c b/src/w_wad.c index 3642efe2f..0f298067d 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1814,7 +1814,6 @@ void *W_GetCachedRotPatchPwad(UINT16 wadnum, UINT16 lumpnum) return (void *)rspr; } - #endif // ROTSPRITE void W_UnlockCachedPatch(void *patch) diff --git a/src/y_inter.c b/src/y_inter.c index 213bf90d8..68ad7365a 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -923,8 +923,8 @@ static void Y_DrawAnimatedVoteScreenPatch(boolean widePatch) currentAnimFrame = 0; patch_t *background = W_CachePatchName(va("%s%d", tempAnimPrefix, currentAnimFrame + 1), PU_CACHE); - V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(background->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?) - (vid.height / vid.dupy) - SHORT(background->height), + V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (background->width/2), // Keep the width/height adjustments, for screens that are less wide than 320(?) + (vid.height / vid.dupy) - background->height, V_SNAPTOTOP|V_SNAPTOLEFT, background); if (renderisnewtic && votetic % 2 == 0 && !paused) @@ -954,8 +954,8 @@ static void Y_DrawVoteScreenPatch(void) votebg = widebgpatch; } - V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(votebg->width)/2), - (vid.height / vid.dupy) - SHORT(votebg->height), + V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (votebg->width/2), + (vid.height / vid.dupy) - votebg->height, V_SNAPTOTOP|V_SNAPTOLEFT, votebg); } From 39f8fa8d34205e80755b98177004cb1291cda78a Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 15:56:41 +0200 Subject: [PATCH 210/350] add more purge tags refactor patch freeing and stuff currently dies when adding a wad midgame and the loading into another map --- src/console.c | 2 +- src/d_main.c | 4 +- src/f_finale.c | 43 +++--- src/hardware/hw_bsp.c | 6 +- src/hardware/hw_cache.c | 135 ++++++++++++----- src/hardware/hw_data.h | 36 +++-- src/hardware/hw_draw.c | 16 +- src/hardware/hw_gl.h | 1 + src/hardware/hw_glob.h | 2 +- src/hardware/hw_main.c | 14 +- src/hardware/hw_md2.c | 27 +++- src/hardware/r_opengl/r_opengl.c | 44 +++--- src/k_kart.c | 14 +- src/lua_hudlib.c | 6 +- src/m_menu.c | 246 +++++++++++++++---------------- src/p_setup.c | 6 +- src/r_data.c | 9 +- src/r_patch.c | 39 +++-- src/r_patch.h | 3 + src/r_segs.c | 2 +- src/r_splats.c | 2 +- src/r_things.c | 4 +- src/st_stuff.c | 10 +- src/v_video.c | 4 +- src/w_wad.c | 16 +- src/w_wad.h | 2 + src/y_inter.c | 30 ++-- src/z_zone.c | 31 ++-- src/z_zone.h | 7 +- 29 files changed, 447 insertions(+), 314 deletions(-) diff --git a/src/console.c b/src/console.c index 8cc04fe93..e99ea959b 100644 --- a/src/console.c +++ b/src/console.c @@ -1509,7 +1509,7 @@ static void CON_DrawConsole(void) // draw console background if (cons_backpic.value || con_forcepic) { - patch_t *con_backpic = W_CachePatchName("KARTKREW", PU_CACHE); + patch_t *con_backpic = W_CachePatchName("KARTKREW", PU_PATCH_LOWPRIORITY); // Jimita: CON_DrawBackpic just called V_DrawScaledPatch V_DrawFixedPatch(0, 0, FRACUNIT/2, 0, con_backpic, NULL); diff --git a/src/d_main.c b/src/d_main.c index 6f281421a..fd57583d4 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -603,7 +603,7 @@ static boolean D_Display(void) py = 4; else py = viewwindowy + 4; - patch = W_CachePatchName("M_PAUSE", PU_CACHE); + patch = W_CachePatchName("M_PAUSE", PU_PATCH); V_DrawScaledPatch(viewwindowx + (BASEVIDWIDTH - patch->width)/2, py, V_SNAPTOTOP, patch); } @@ -733,7 +733,7 @@ void D_SRB2Loop(void) COM_ImmedExecute("cls;version"); if (rendermode == render_soft) - V_DrawFixedPatch(0, 0, FRACUNIT/2, 0, W_CachePatchNum(W_GetNumForName("KARTKREW"), PU_CACHE), NULL); + V_DrawFixedPatch(0, 0, FRACUNIT/2, 0, W_CachePatchNum(W_GetNumForName("KARTKREW"), PU_PATCH_LOWPRIORITY), NULL); I_FinishUpdate(); // page flip or blit buffer for (;;) diff --git a/src/f_finale.c b/src/f_finale.c index a534eee68..b92291467 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -164,8 +164,8 @@ static void F_SkyScroll(INT32 scrollspeed) patch_t *pat, *pat2; INT32 anim2 = 0; - pat = W_CachePatchName("TITLEBG1", PU_CACHE); - pat2 = W_CachePatchName("TITLEBG2", PU_CACHE); + pat = W_CachePatchName("TITLEBG1", PU_PATCH_LOWPRIORITY); + pat2 = W_CachePatchName("TITLEBG2", PU_PATCH_LOWPRIORITY); w = (vid.width / vid.dupx)<= 5*TICRATE) { if (drawemblem) - V_DrawScaledPatch(120, 192, 0, W_CachePatchName("NWNGA0", PU_CACHE)); + V_DrawScaledPatch(120, 192, 0, W_CachePatchName("NWNGA0", PU_PATCH_LOWPRIORITY)); if (drawchaosemblem) - V_DrawScaledPatch(200, 192, 0, W_CachePatchName("NWNGA0", PU_CACHE)); + V_DrawScaledPatch(200, 192, 0, W_CachePatchName("NWNGA0", PU_PATCH_LOWPRIORITY)); V_DrawString(8, 16, V_YELLOWMAP, "Unlocked:"); @@ -975,10 +972,10 @@ void F_StartTitleScreen(void) demoDelayLeft = demoDelayTime; demoIdleLeft = demoIdleTime; - ttbanner = W_CachePatchName("TTKBANNR", PU_LEVEL); - ttkart = W_CachePatchName("TTKART", PU_LEVEL); - ttcheckers = W_CachePatchName("TTCHECK", PU_LEVEL); - ttkflash = W_CachePatchName("TTKFLASH", PU_LEVEL); + ttbanner = W_CachePatchName("TTKBANNR", PU_PATCH_LOWPRIORITY); + ttkart = W_CachePatchName("TTKART", PU_PATCH_LOWPRIORITY); + ttcheckers = W_CachePatchName("TTCHECK", PU_PATCH_LOWPRIORITY); + ttkflash = W_CachePatchName("TTKFLASH", PU_PATCH_LOWPRIORITY); } // (no longer) De-Demo'd Title Screen @@ -1193,7 +1190,7 @@ void F_StartWaitingPlayers(void) for (i = 0; i < 2; i++) { sprframe = &skins[randskin].spritedef.spriteframes[(6+(i*3)) & FF_FRAMEMASK]; - driver[i] = W_CachePatchNum(sprframe->lumppat[1], PU_LEVEL); + driver[i] = W_CachePatchNum(sprframe->lumppat[1], PU_SPRITE); } } @@ -1262,9 +1259,9 @@ void F_ContinueDrawer(void) ncontinues = 20; if (imcontinuing) - contsonic = W_CachePatchName("CONT2", PU_CACHE); + contsonic = W_CachePatchName("CONT2", PU_PATCH_LOWPRIORITY); else - contsonic = W_CachePatchName("CONT1", PU_CACHE); + contsonic = W_CachePatchName("CONT1", PU_PATCH_LOWPRIORITY); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); V_DrawCenteredString(BASEVIDWIDTH/2, 100, 0, "CONTINUE?"); @@ -1489,10 +1486,10 @@ void F_CutsceneDrawer(void) { if (cutscenes[cutnum]->scene[scenenum].pichires[picnum]) V_DrawSmallScaledPatch(picxpos, picypos, 0, - W_CachePatchName(cutscenes[cutnum]->scene[scenenum].picname[picnum], PU_CACHE)); + W_CachePatchName(cutscenes[cutnum]->scene[scenenum].picname[picnum], PU_PATCH_LOWPRIORITY)); else V_DrawScaledPatch(picxpos,picypos, 0, - W_CachePatchName(cutscenes[cutnum]->scene[scenenum].picname[picnum], PU_CACHE)); + W_CachePatchName(cutscenes[cutnum]->scene[scenenum].picname[picnum], PU_PATCH_LOWPRIORITY)); } if (dofadenow && rendermode != render_none) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 88ef77320..934f13a14 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -369,7 +369,7 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly) { //x,y,dx,dy (like a divline) line_t *line = lseg->linedef; - + // portal check if (!gl_maphasportals && line->special == 40 && lseg->side == 0) { @@ -380,7 +380,7 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly) if (line2 >= 0) // found it! gl_maphasportals = 1; } - + p1.x = FIXED_TO_FLOAT(lseg->side ? line->v2->x : line->v1->x); p1.y = FIXED_TO_FLOAT(lseg->side ? line->v2->y : line->v1->y); p2.x = FIXED_TO_FLOAT(lseg->side ? line->v1->x : line->v2->x); @@ -523,7 +523,7 @@ static void loading_status(void) x = BASEVIDWIDTH/2; y = BASEVIDHEIGHT/2; V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // Black background to match fade in effect - //V_DrawPatchFill(W_CachePatchName("SRB2BACK",PU_CACHE)); // SRB2 background, ehhh too bright. + //V_DrawPatchFill(W_CachePatchName("SRB2BACK", PU_PATCH)); // SRB2 background, ehhh too bright. M_DrawTextBox(x-58, y-8, 13, 1); V_DrawString(x-50, y, V_YELLOWMAP, "Loading..."); V_DrawRightAlignedString(x+50, y, V_YELLOWMAP, s); diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 836d3adac..83a3a2d6b 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -117,7 +117,7 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm //Hurdler: 25/04/2000: now support colormap in hardware mode if (mipmap->colormap) - texel = mipmap->colormap[texel]; + texel = mipmap->colormap->data[texel]; // hope compiler will get this switch out of the loops (dreams...) // gcc do it ! but vcc not ! (why don't use cygwin gcc for win32 ?) @@ -314,9 +314,10 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe texture_t *texture; texpatch_t *patch; softwarepatch_t *realpatch; - UINT8 *pdata; INT32 blockwidth, blockheight, blocksize; + UINT8 *colormap = colormaps; + INT32 i, idx; boolean skyspecial = false; // poor hack for Legacy large skies.. @@ -326,9 +327,6 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe texture = textures[texnum]; gltex->mipmap.flags = TF_CHROMAKEYED | TF_WRAPXY; - gltex->mipmap.width = (UINT16)(texture->width); - gltex->mipmap.height = (UINT16)(texture->height); - gltex->mipmap.colormap = colormaps; gltex->mipmap.format = textureformat; // hack the Legacy skies.. @@ -340,11 +338,18 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe gltex->mipmap.format = GL_TEXFMT_RGBA; // that skyspecial code below assumes this format ... } + gltex->mipmap.width = (UINT16)(texture->width); + gltex->mipmap.height = (UINT16)(texture->height); + #ifdef GLENCORE if (encoremap && !noencore) - gltex->mipmap.colormap += COLORMAP_REMAPOFFSET; + colormap += COLORMAP_REMAPOFFSET; #endif + gltex->mipmap.colormap = Z_Calloc(sizeof(*gltex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL); + gltex->mipmap.colormap->source = colormap; + M_Memcpy(gltex->mipmap.colormap->data, colormap, 256 * sizeof(UINT8)); + blockwidth = texture->width; blockheight = texture->height; blocksize = (blockwidth * blockheight); @@ -372,8 +377,12 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe // Composite the columns together. for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { - pdata = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); - realpatch = (softwarepatch_t *)pdata; + // If this patch has already been loaded, we just use it from the cache. + realpatch = (softwarepatch_t *)W_GetCachedPatchNumPwad(patch->wad, patch->lump); + + // Otherwise, we load it here. + if (realpatch == NULL) + realpatch = (softwarepatch_t *)W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); if (realpatch != NULL) { @@ -399,7 +408,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe } // patch may be NULL if glMipmap has been initialised already and makebitmap is false -void HWR_MakePatch (patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipmap, boolean makebitmap) +void HWR_MakePatch(const patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipmap, boolean makebitmap) { if (glMipmap->width == 0) { @@ -440,17 +449,17 @@ static GLMapTexture_t *gl_textures; // For all textures void HWR_FreeTextureData(patch_t *patch) { - GLPatch_t *grPatch; + GLPatch_t *glPatch; if (!patch || !patch->hardware) return; - grPatch = patch->hardware; + glPatch = patch->hardware; if (vid.glstate == VID_GL_LIBRARY_LOADED) - GL_DeleteTexture(grPatch->mipmap); - if (grPatch->mipmap->data) - Z_Free(grPatch->mipmap->data); + GL_DeleteTexture(glPatch->mipmap); + if (glPatch->mipmap->data) + Z_Free(glPatch->mipmap->data); } void HWR_FreeTexture(patch_t *patch) @@ -486,7 +495,6 @@ void HWR_FreeTextureColormaps(patch_t *patch) return; pat = patch->hardware; - if (!pat) return; @@ -508,12 +516,19 @@ void HWR_FreeTextureColormaps(patch_t *patch) // Set the first colormap to the one that comes after it. next = pat->mipmap->nextcolormap; + + if (!next) + break; + pat->mipmap->nextcolormap = next->nextcolormap; // Free image data from memory. if (next->data) Z_Free(next->data); + if (next->colormap) + Z_Free(next->colormap); next->data = NULL; + next->colormap = NULL; GL_DeleteTexture(next); // Free the old colormap mipmap from memory. @@ -521,16 +536,30 @@ void HWR_FreeTextureColormaps(patch_t *patch) } } +static boolean FreeTextureCallback(void *mem) +{ + patch_t *patch = (patch_t *)mem; + HWR_FreeTexture(patch); + return false; +} + +static boolean FreeColormapsCallback(void *mem) +{ + patch_t *patch = (patch_t *)mem; + HWR_FreeTextureColormaps(patch); + return false; +} + static void HWR_FreePatchCache(boolean freeall) { - INT32 i; + boolean (*callback)(void *mem) = FreeTextureCallback; - for (i = 0; i < numwadfiles; i++) - { - INT32 j = 0; - for (; j < wadfiles[i]->numlumps; j++) - (freeall ? HWR_FreeTexture : HWR_FreeTextureColormaps)(wadfiles[i]->patchcache[j]); - } + if (!freeall) + callback = FreeColormapsCallback; + + Z_IterateTags(PU_PATCH, PU_PATCH_ROTATED, callback); + //Z_IterateTags(PU_SPRITE, PU_HUDGFX, callback); // why would we want to free our hudgfx? + Z_IterateTags(PU_SPRITE, PU_SPRITE, callback); } // free all textures after each level @@ -556,6 +585,7 @@ static void FreeMapTexture(GLMapTexture_t *tex) GL_DeleteTexture(&tex->mipmap); if (tex->mipmap.data) Z_Free(tex->mipmap.data); + tex->mipmap.data = NULL; } void HWR_FreeMapTextures(void) @@ -788,7 +818,7 @@ static void HWR_PrecacheLevelSprites(void) #define cacheang(a) {\ lump = sf->lumppat[a];\ - spritepatch = (patch_t *)W_CachePatchNum(lump, PU_CACHE);\ + spritepatch = (patch_t *)W_CachePatchNum(lump, PU_SPRITE);\ if (spritepatch != NULL)\ HWR_GetPatch(spritepatch);\ } @@ -831,10 +861,9 @@ void HWR_PrecacheLevel(void) void HWR_LoadMapTextures(size_t pnumtextures) { - // we must free it since numtextures changed + // we must free it since numtextures may have changed HWR_FreeMapTextures(); - // Why not Z_Malloc? gl_numtextures = pnumtextures; #ifdef GLENCORE gl_textures = calloc(pnumtextures, sizeof (*gl_textures)*2); // *2 - 1 for encore-remapped texture and another for noencore texture (unused when not in encore) @@ -936,7 +965,7 @@ static void HWR_CacheFlat(GLMipmap_t *glMipmap, lumpnum_t flatlumpnum) if (flat[steppy] == HWR_PATCHES_CHROMAKEY_COLORINDEX) continue; - flat[steppy] = glMipmap->colormap[flat[steppy]]; + flat[steppy] = glMipmap->colormap->source[flat[steppy]]; } #endif } @@ -946,6 +975,7 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap) { GLMipmap_t *glMipmap; patch_t *patch; + UINT8 *colormap = colormaps; if (flatlumpnum == LUMPERROR) return; @@ -953,12 +983,16 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap) patch = HWR_GetCachedGLPatch(flatlumpnum); glMipmap = ((GLPatch_t *)Patch_AllocateHardwarePatch(patch))->mipmap; - glMipmap->colormap = colormaps; - + if (!glMipmap->colormap) + { #ifdef GLENCORE - if (!noencoremap && encoremap) - glMipmap->colormap += COLORMAP_REMAPOFFSET; + if (!noencoremap && encoremap) + colormap += COLORMAP_REMAPOFFSET; #endif + glMipmap->colormap = Z_Calloc(sizeof(*glMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL); + glMipmap->colormap->source = colormap; + M_Memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); + } if (!glMipmap->downloaded && !glMipmap->data) HWR_CacheFlat(glMipmap, flatlumpnum); @@ -991,6 +1025,26 @@ static void HWR_LoadPatchMipmap(patch_t *patch, GLMipmap_t *glMipmap) Z_ChangeTag(glMipmap->data, PU_HWRCACHE_UNLOCKED); } +// ----------------------+ +// HWR_UpdatePatchMipmap : Updates a mipmap. +// ----------------------+ +static void HWR_UpdatePatchMipmap(patch_t *patch, GLMipmap_t *glMipmap) +{ + GLPatch_t *grPatch = patch->hardware; + HWR_MakePatch(patch, grPatch, glMipmap, true); + + // If hardware does not have the texture, then call pfnSetTexture to upload it + // If it does have the texture, then call pfnUpdateTexture to update it + if (!glMipmap->downloaded) + GL_SetTexture(glMipmap); + else + GL_UpdateTexture(glMipmap); + HWR_SetCurrentTexture(glMipmap); + + // The system-memory data can be purged now. + Z_ChangeTag(glMipmap->data, PU_HWRCACHE_UNLOCKED); +} + // -----------------+ // HWR_GetPatch : Downloads a patch to the hardware cache and make it ready for use // -----------------+ @@ -1013,7 +1067,8 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap) Patch_CreateGL(patch); glPatch = patch->hardware; - if (colormap == colormaps || colormap == NULL) + // Blatant hack for encore colormapping aside... + if (colormap == colormaps || colormap == NULL || colormap == (const UINT8*)(COLORMAP_REMAPOFFSET)) { // Load the default (green) color in hardware cache HWR_GetPatch(patch); @@ -1026,9 +1081,16 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap) { glMipmap = glMipmap->nextcolormap; - if (UNLIKELY(glMipmap->colormap == colormap)) + if (UNLIKELY(glMipmap->colormap && glMipmap->colormap->source == colormap)) { - HWR_LoadPatchMipmap(patch, glMipmap); + if (memcmp(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8))) + { + M_Memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); + HWR_UpdatePatchMipmap(patch, glMipmap); + } + else + HWR_LoadPatchMipmap(patch, glMipmap); + return; } } @@ -1044,7 +1106,10 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap) I_Error("%s: Out of memory", "HWR_GetMappedPatch"); glMipmap->nextcolormap = newMipmap; - newMipmap->colormap = colormap; + newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL); + newMipmap->colormap->source = colormap; + M_Memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); + HWR_LoadPatchMipmap(patch, newMipmap); } @@ -1061,7 +1126,7 @@ patch_t *HWR_GetCachedGLPatchPwad(UINT16 wadnum, UINT16 lumpnum) lumpcache_t *lumpcache = wadfiles[wadnum]->patchcache; if (!lumpcache[lumpnum]) { - void *ptr = Z_Calloc(sizeof(patch_t), PU_CACHE, &lumpcache[lumpnum]); + void *ptr = Z_Calloc(sizeof(patch_t), PU_PATCH, &lumpcache[lumpnum]); Patch_Create(NULL, 0, ptr); Patch_AllocateHardwarePatch(ptr); } diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index d7c11b2c2..f253eccb8 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -23,31 +23,39 @@ typedef enum GLTextureFormat_e { - GL_TEXFMT_P_8 = 0x01, /* 8-bit palette */ - GL_TEXFMT_AP_88 = 0x02, /* 8-bit alpha, 8-bit palette */ + GL_TEXFMT_P_8 = 0x01, /* 8-bit palette */ + GL_TEXFMT_AP_88 = 0x02, /* 8-bit alpha, 8-bit palette */ - GL_TEXFMT_RGBA = 0x10, /* 32 bit RGBA! */ + GL_TEXFMT_RGBA = 0x10, /* 32 bit RGBA! */ - GL_TEXFMT_ALPHA_8 = 0x20, /* (0..0xFF) alpha */ - GL_TEXFMT_INTENSITY_8 = 0x21, /* (0..0xFF) intensity */ - GL_TEXFMT_ALPHA_INTENSITY_88 = 0x22, + GL_TEXFMT_ALPHA_8 = 0x20, /* (0..0xFF) alpha */ + GL_TEXFMT_INTENSITY_8 = 0x21, /* (0..0xFF) intensity */ + GL_TEXFMT_ALPHA_INTENSITY_88 = 0x22, } GLTextureFormat_t; +// Colormap structure for mipmaps. +struct GLColormap_s +{ + const UINT8 *source; + UINT8 data[256]; +}; +typedef struct GLColormap_s GLColormap_t; + // Texture information (misleadingly named "mipmap" all over the code.) // The *data pointer holds the address of the graphics data cached in heap memory. // NULL if the texture is not in SRB2's heap cache. struct GLMipmap_s { // for UpdateTexture - GLTextureFormat_t format; - void *data; + GLTextureFormat_t format; + void *data; - UINT32 flags; - UINT16 width, height; + UINT32 flags; + UINT16 width, height; UINT32 downloaded; // The GPU has this texture. - struct GLMipmap_s *nextcolormap; - const UINT8 *colormap; + struct GLMipmap_s *nextcolormap; + struct GLColormap_s *colormap; }; typedef struct GLMipmap_s GLMipmap_t; @@ -62,11 +70,11 @@ struct GLMapTexture_s }; typedef struct GLMapTexture_s GLMapTexture_t; -// a cached patch as converted to hardware format +// Patch information for the hardware renderer. struct GLPatch_s { - float max_s,max_t; GLMipmap_t *mipmap; + float max_s,max_t; boolean notfound; // if the texture file was not found, mark it here (used in model texture loading) }; typedef struct GLPatch_s GLPatch_t; diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index d47d58841..9fd90fb09 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -712,7 +712,7 @@ void HWR_DrawViewBorder(INT32 clearlines) // top edge if (clearlines > basewindowy - 8) { - patch = W_CachePatchNum(viewborderlump[BRDR_T], PU_CACHE); + patch = W_CachePatchNum(viewborderlump[BRDR_T], PU_PATCH); for (x = 0; x < baseviewwidth; x += 8) HWR_DrawPatch(patch, basewindowx + x, basewindowy - 8, 0); @@ -721,7 +721,7 @@ void HWR_DrawViewBorder(INT32 clearlines) // bottom edge if (clearlines > basewindowy + baseviewheight) { - patch = W_CachePatchNum(viewborderlump[BRDR_B], PU_CACHE); + patch = W_CachePatchNum(viewborderlump[BRDR_B], PU_PATCH); for (x = 0; x < baseviewwidth; x += 8) HWR_DrawPatch(patch, basewindowx + x, basewindowy + baseviewheight, 0); @@ -730,7 +730,7 @@ void HWR_DrawViewBorder(INT32 clearlines) // left edge if (clearlines > basewindowy) { - patch = W_CachePatchNum(viewborderlump[BRDR_L], PU_CACHE); + patch = W_CachePatchNum(viewborderlump[BRDR_L], PU_PATCH); for (y = 0; y < baseviewheight && basewindowy + y < clearlines; y += 8) { @@ -742,7 +742,7 @@ void HWR_DrawViewBorder(INT32 clearlines) // right edge if (clearlines > basewindowy) { - patch = W_CachePatchNum(viewborderlump[BRDR_R], PU_CACHE); + patch = W_CachePatchNum(viewborderlump[BRDR_R], PU_PATCH); for (y = 0; y < baseviewheight && basewindowy+y < clearlines; y += 8) { @@ -754,22 +754,22 @@ void HWR_DrawViewBorder(INT32 clearlines) // Draw beveled corners. if (clearlines > basewindowy - 8) HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_TL], - PU_CACHE), + PU_PATCH), basewindowx - 8, basewindowy - 8, 0); if (clearlines > basewindowy - 8) HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_TR], - PU_CACHE), + PU_PATCH), basewindowx + baseviewwidth, basewindowy - 8, 0); if (clearlines > basewindowy+baseviewheight) HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_BL], - PU_CACHE), + PU_PATCH), basewindowx - 8, basewindowy + baseviewheight, 0); if (clearlines > basewindowy + baseviewheight) HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_BR], - PU_CACHE), + PU_PATCH), basewindowx + baseviewwidth, basewindowy + baseviewheight, 0); } diff --git a/src/hardware/hw_gl.h b/src/hardware/hw_gl.h index c2a88854f..44fa28bf2 100644 --- a/src/hardware/hw_gl.h +++ b/src/hardware/hw_gl.h @@ -40,6 +40,7 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics void GL_RenderSkyDome(gl_sky_t *sky); +void GL_UpdateTexture(GLMipmap_t *pTexInfo); void GL_SetTexture(GLMipmap_t *pTexInfo); void GL_DeleteTexture(GLMipmap_t *pTexInfo); diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 31ecc7792..0589ba1d2 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -65,7 +65,7 @@ patch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum); void HWR_GetPatch(patch_t *gpatch); void HWR_GetMappedPatch(patch_t *gpatch, const UINT8 *colormap); -void HWR_MakePatch(patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipmap, boolean makebitmap); +void HWR_MakePatch(const patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipmap, boolean makebitmap); void HWR_GetFadeMask(lumpnum_t fademasklumpnum); void HWR_PrecacheLevel(void); diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 8e877a044..1ec415292 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -844,7 +844,7 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) if (!M_PointInBox(segbbox,splat->v1.x,splat->v1.y) && !M_PointInBox(segbbox,splat->v2.x,splat->v2.y)) continue; - gpatch = W_CachePatchNum(splat->patch, PU_CACHE); + gpatch = W_CachePatchNum(splat->patch, PU_SPRITE); HWR_GetPatch(gpatch); wallVerts[0].x = wallVerts[3].x = FIXED_TO_FLOAT(splat->v1.x); @@ -4903,7 +4903,7 @@ static void HWR_ProjectSprite(mobj_t *thing) vis->gpatch = (patch_t *)rotsprite; else #endif - vis->gpatch = (patch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); + vis->gpatch = (patch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_SPRITE); vis->mobj = thing; @@ -5071,15 +5071,15 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) vis->z2 = z2; vis->tz = tz; vis->dispoffset = 0; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST - vis->gpatch = (patch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); + vis->gpatch = (patch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_SPRITE); vis->flip = flip; vis->mobj = (mobj_t *)thing; - vis->colormap = colormaps; + vis->colormap = NULL; #ifdef GLENCORE - if (encoremap && !(thing->flags & MF_DONTENCOREMAP)) - vis->colormap += COLORMAP_REMAPOFFSET; + //if (encoremap && !(thing->flags & MF_DONTENCOREMAP)) + //vis->colormap += COLORMAP_REMAPOFFSET; #endif // set top/bottom coords @@ -5548,7 +5548,7 @@ static void HWR_RenderFrame(player_t *player, boolean skybox) if (splitscreen == 2 && player == &players[displayplayers[2]]) { // V_DrawPatchFill, but for the fourth screen only - patch_t *gpatch = W_CachePatchName("SRB2BACK", PU_CACHE); + patch_t *gpatch = W_CachePatchName("SRB2BACK", PU_PATCH); INT32 dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); INT32 x, y, pw = (gpatch->width) * dupz, ph = (gpatch->height) * dupz; diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 2a5643d53..d74486ac4 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1086,14 +1086,22 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendgpatch, INT32 sk { glMipmap = glMipmap->nextcolormap; - if (glMipmap->colormap != colormap) - continue; - - if (glMipmap->downloaded && glMipmap->data) + if (glMipmap->colormap && glMipmap->colormap->source == colormap) { - GL_SetTexture(glMipmap); // found the colormap, set it to the correct texture - Z_ChangeTag(glMipmap->data, PU_HWRCACHE_UNLOCKED); - return; + if (glMipmap->downloaded && glMipmap->data) + { + if (memcmp(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8))) + { + M_Memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); + HWR_CreateBlendedTexture(patch, blendgpatch, glMipmap, skinnum, color); + GL_UpdateTexture(glMipmap); + } + else + GL_SetTexture(glMipmap); // found the colormap, set it to the correct texture + + Z_ChangeTag(glMipmap->data, PU_HWRCACHE_UNLOCKED); + return; + } } } @@ -1108,7 +1116,10 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendgpatch, INT32 sk if (newMipmap == NULL) I_Error("%s: Out of memory", "HWR_GetMappedPatch"); glMipmap->nextcolormap = newMipmap; - newMipmap->colormap = colormap; + + newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL); + newMipmap->colormap->source = colormap; + M_Memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); HWR_CreateBlendedTexture(patch, blendgpatch, newMipmap, skinnum, color); diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index b5bb031e0..5c81db186 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -191,7 +191,7 @@ FUNCPRINTF void GL_DBG_Printf(const char *format, ...) if (!gllogstream) gllogstream = fopen("ogllog.txt", "w"); - + va_start(arglist, format); vsnprintf(str, 4096, format, arglist); va_end(arglist); @@ -673,7 +673,7 @@ typedef enum gluniform_light_dir, gluniform_light_contrast, gluniform_light_backlight, - + // palette rendering gluniform_palette_tex, // 1d texture containing a palette gluniform_palette_lookup_tex, // 3d texture containing the rgb->index lookup table @@ -743,7 +743,7 @@ void SetupGLFunc4(void) pglMultiTexCoord2f = GetGLFunc("glMultiTexCoord2f"); pglClientActiveTexture = GetGLFunc("glClientActiveTexture"); pglMultiTexCoord2fv = GetGLFunc("glMultiTexCoord2fv"); - + /* 1.5 funcs */ pglGenBuffers = GetGLFunc("glGenBuffers"); pglBindBuffer = GetGLFunc("glBindBuffer"); @@ -753,7 +753,7 @@ void SetupGLFunc4(void) /* 2.0 funcs */ pglBlendEquation = GetGLFunc("glBlendEquation"); - + pglStencilFuncSeparate = GetGLFunc("glStencilFuncSeparate"); pglStencilOpSeparate = GetGLFunc("glStencilOpSeparate"); @@ -809,7 +809,7 @@ boolean GL_InitShaders(void) { if (!pglUseProgram) return false; - + gl_fallback_shader.vertex_shader = Z_StrDup(GLSL_FALLBACK_VERTEX_SHADER); gl_fallback_shader.fragment_shader = Z_StrDup(GLSL_FALLBACK_FRAGMENT_SHADER); @@ -1643,7 +1643,7 @@ static void GL_AllocTextureBuffer(GLMipmap_t *pTexInfo) // -----------------+ // UpdateTexture : Updates texture data. // -----------------+ -static void GL_UpdateTexture(GLMipmap_t *pTexInfo) +void GL_UpdateTexture(GLMipmap_t *pTexInfo) { // Upload a texture GLuint num = pTexInfo->downloaded; @@ -2024,7 +2024,7 @@ static boolean GL_Shader_CompileProgram(gl_shader_t *shader, GLint i) pglDeleteShader(gl_vertShader); if (frag_shader) pglDeleteShader(gl_fragShader); - + // couldn't link? if (result != GL_TRUE) { @@ -2313,7 +2313,7 @@ void GL_SetSpecialState(hwdspecialstate_t IdState, INT32 Value) gltexformat = (Value == 32) ? GL_RGBA : GL_RGB5_A1; GL_Flush(); break; - + case HWD_SET_MSAA: if (Value) { @@ -2623,7 +2623,7 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics scalex = hscale; scaley = vscale; scalez = hscale; - + if (duration > 0.0 && tics >= 0.0) // don't interpolate if instantaneous or infinite in length { float newtime = (duration - tics); // + 1; @@ -2692,7 +2692,7 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics pglRotatef(pos->anglez, 0.0f, 0.0f, -1.0f); pglRotatef(pos->anglex, 1.0f, 0.0f, 0.0f); pglRotatef(pos->angley, 0.0f, -1.0f, 0.0f); - + if (pos->roll) { pglTranslatef(pos->centerx, pos->centery, 0); @@ -2895,7 +2895,7 @@ INT32 GL_GetTextureUsed(void) res += tmp->height*tmp->width*bpp; tmp = tmp->next; } - + return res; } @@ -2913,8 +2913,8 @@ void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2]) 16.0f, 16.0f, 6.0f, 16.0f, -16.0f, 6.0f }; - - if (gl_enable_screen_textures != 2) + + if (gl_enable_screen_textures != 2) return; // look for power of two that is large enough for the screen @@ -3010,8 +3010,8 @@ void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags) }; float fix[8]; - - if (gl_enable_screen_textures != 2) + + if (gl_enable_screen_textures != 2) return; // look for power of two that is large enough for the screen @@ -3039,7 +3039,7 @@ void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags) pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); pglBindTexture(GL_TEXTURE_2D, screenTextures[tex]); - + GL_PreparePolygon(surf, surf ? polyflags : (PF_NoDepthTest)); if (!surf) pglColor4ubv(white); @@ -3078,7 +3078,7 @@ void GL_DoScreenWipe(int wipeStart, int wipeEnd) 1.0f, 1.0f }; - if (!gl_enable_screen_textures) + if (!gl_enable_screen_textures) return; // look for power of two that is large enough for the screen @@ -3164,7 +3164,7 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 1.0f, -1.0f, 1.0f }; - if (gl_enable_screen_textures != 2) + if (gl_enable_screen_textures != 2) return; // look for power of two that is large enough for the screen @@ -3261,7 +3261,7 @@ void GL_MakeScreenTexture(int tex) { INT32 texsizew = 512, texsizey = 512; boolean firstTime = (screenTextures[tex] == 0); - + if (!gl_enable_screen_textures) return; @@ -3301,7 +3301,7 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh float off[12]; float fix[8]; - + if (gl_enable_screen_textures != 2) return; @@ -3392,7 +3392,7 @@ void GL_SetPaletteLookup(UINT8 *lut) { internalFormat = GL_R8; } - + if (!paletteLookupTex) pglGenTextures(1, &paletteLookupTex); pglActiveTexture(GL_TEXTURE1); @@ -3441,7 +3441,7 @@ void GL_ClearLightTables(void) } LightTablesTail = NULL; - + // we no longer have a bound light table (if we had one), we just deleted it! lt_downloaded = 0; } diff --git a/src/k_kart.c b/src/k_kart.c index fb14741cc..7fdd8351b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8982,7 +8982,7 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI if (emblem->collected) { - emblempic[curemb] = W_CachePatchName(M_GetEmblemPatch(emblem), PU_CACHE); + emblempic[curemb] = W_CachePatchName(M_GetEmblemPatch(emblem), PU_PATCH); emblemcol[curemb] = R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE); if (++curemb == 3) break; @@ -9018,7 +9018,7 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI V_DrawRightAlignedString(workx, worky, splitflags, targettext); workx -= 67; - V_DrawSmallScaledPatch(workx + 4, worky, splitflags, W_CachePatchName("NEEDIT", PU_CACHE)); + V_DrawSmallScaledPatch(workx + 4, worky, splitflags, W_CachePatchName("NEEDIT", PU_PATCH)); break; @@ -9546,11 +9546,11 @@ static void K_DrawDialSpeedometer(fixed_t speed, if (rot) { - dialpatch = W_CachePatchNameRotated("K_DSDIAL", rot, PU_STATIC); + dialpatch = W_CachePatchNameRotated("K_DSDIAL", rot, PU_PATCH); } else { - dialpatch = W_CachePatchName("K_DSDIAL", PU_STATIC); + dialpatch = W_CachePatchName("K_DSDIAL", PU_PATCH); } if (colorized) // Colourized hud @@ -10587,7 +10587,7 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) if (rot) { - minimaphead = W_CachePatchNameRotated(skin->facemmap, rot, PU_STATIC); + minimaphead = W_CachePatchNameRotated(skin->facemmap, rot, PU_PATCH); } } #endif @@ -11629,8 +11629,8 @@ void K_drawKartHUD(void) x += offs - frac; } - V_DrawSciencePatch(x - (54*FRACUNIT), y, logoflags, W_CachePatchName("TTKBANNR", PU_CACHE), FRACUNIT/4); - V_DrawSciencePatch(x - (54*FRACUNIT), y + (25*FRACUNIT), logoflags, W_CachePatchName("TTKART", PU_CACHE), FRACUNIT/4); + V_DrawSciencePatch(x - (54*FRACUNIT), y, logoflags, W_CachePatchName("TTKBANNR", PU_PATCH), FRACUNIT/4); + V_DrawSciencePatch(x - (54*FRACUNIT), y + (25*FRACUNIT), logoflags, W_CachePatchName("TTKART", PU_PATCH), FRACUNIT/4); } else if (G_RaceGametype()) // Race-only elements { diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 5bfb21e2e..b2425ec0a 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -396,7 +396,7 @@ static int libd_patchExists(lua_State *L) static int libd_cachePatch(lua_State *L) { HUDONLY - LUA_PushUserdata(L, W_CachePatchName(luaL_checkstring(L, 1), PU_STATIC), META_PATCH); + LUA_PushUserdata(L, W_CachePatchName(luaL_checkstring(L, 1), PU_PATCH), META_PATCH); return 1; } @@ -406,7 +406,7 @@ static int libd_cachePatchRotated(lua_State *L) HUDONLY angle_t rollangle = luaL_checkangle(L, 2); INT32 rot = R_GetRollAngle(rollangle); - LUA_PushUserdata(L, W_CachePatchNameRotated(luaL_checkstring(L, 1), rot, PU_STATIC), META_PATCH); + LUA_PushUserdata(L, W_CachePatchNameRotated(luaL_checkstring(L, 1), rot, PU_PATCH), META_PATCH); return 1; } @@ -526,7 +526,7 @@ static int libd_getSpritePatch(lua_State *L) #endif // push both the patch and its "flip" value - LUA_PushUserdata(L, W_CachePatchNum(sprframe->lumppat[angle], PU_STATIC), META_PATCH); + LUA_PushUserdata(L, W_CachePatchNum(sprframe->lumppat[angle], PU_SPRITE), META_PATCH); lua_pushboolean(L, (sprframe->flip & (1<width - p->leftoffset; for (i = 0; i < 16; i++) { - V_DrawScaledPatch(xx, y, V_WRAPX, W_CachePatchNum(centerlump[i & 1], PU_CACHE)); + V_DrawScaledPatch(xx, y, V_WRAPX, W_CachePatchNum(centerlump[i & 1], PU_PATCH)); xx += 8; } - V_DrawScaledPatch(xx, y, 0, W_CachePatchNum(rightlump, PU_CACHE)); + V_DrawScaledPatch(xx, y, 0, W_CachePatchNum(rightlump, PU_PATCH)); xx = (cv->value - cv->PossibleValue[0].value) * (15*8) / (cv->PossibleValue[1].value - cv->PossibleValue[0].value); - V_DrawScaledPatch((x + 8) + xx, y, 0, W_CachePatchNum(cursorlump, PU_CACHE)); + V_DrawScaledPatch((x + 8) + xx, y, 0, W_CachePatchNum(cursorlump, PU_PATCH)); } // A smaller 'Thermo', with range given as percents (0-100) @@ -5067,18 +5067,18 @@ static void M_DrawSlider(INT32 x, INT32 y, const consvar_t *cv, boolean ontop) x = BASEVIDWIDTH - x - SLIDER_WIDTH; - p = W_CachePatchName("M_SLIDEL", PU_CACHE); + p = W_CachePatchName("M_SLIDEL", PU_PATCH); V_DrawScaledPatch(x - 8, y, 0, p); - p = W_CachePatchName("M_SLIDEM", PU_CACHE); + p = W_CachePatchName("M_SLIDEM", PU_PATCH); for (i = 0; i < SLIDER_RANGE; i++) V_DrawScaledPatch (x+i*8, y, 0,p); - p = W_CachePatchName("M_SLIDER", PU_CACHE); + p = W_CachePatchName("M_SLIDER", PU_PATCH); V_DrawScaledPatch(x+i*8, y, 0, p); // draw the slider cursor - p = W_CachePatchName("M_SLIDEC", PU_CACHE); + p = W_CachePatchName("M_SLIDEC", PU_PATCH); for (i = 0; cv->PossibleValue[i+1].strvalue; i++); @@ -5174,10 +5174,10 @@ static void M_DrawMapEmblems(INT32 mapnum, INT32 x, INT32 y) lasttype = curtype; if (emblem->collected) - V_DrawSmallMappedPatch(x, y, 0, W_CachePatchName(M_GetEmblemPatch(emblem), PU_CACHE), + V_DrawSmallMappedPatch(x, y, 0, W_CachePatchName(M_GetEmblemPatch(emblem), PU_PATCH), R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_MENUCACHE)); else - V_DrawSmallScaledPatch(x, y, 0, W_CachePatchName("NEEDIT", PU_CACHE)); + V_DrawSmallScaledPatch(x, y, 0, W_CachePatchName("NEEDIT", PU_PATCH)); emblem = M_GetLevelEmblems(-1); x -= 8; @@ -5188,7 +5188,7 @@ static void M_DrawMenuTitle(void) { if (currentMenu->menutitlepic) { - patch_t *p = W_CachePatchName(currentMenu->menutitlepic, PU_CACHE); + patch_t *p = W_CachePatchName(currentMenu->menutitlepic, PU_PATCH); if (p->height > 24) // title is larger than normal { @@ -5292,13 +5292,13 @@ static void M_DrawGenericMenu(void) if (currentMenu->menuitems[i].status & IT_CENTER) { patch_t *p; - p = W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE); + p = W_CachePatchName(currentMenu->menuitems[i].patch, PU_PATCH); V_DrawScaledPatch((BASEVIDWIDTH - p->width)/2, y, 0, p); } else { V_DrawScaledPatch(x, y, 0, - W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE)); + W_CachePatchName(currentMenu->menuitems[i].patch, PU_PATCH)); } } /* FALLTHRU */ @@ -5370,7 +5370,7 @@ static void M_DrawGenericMenu(void) case IT_GRAYPATCH: if (currentMenu->menuitems[i].patch && currentMenu->menuitems[i].patch[0]) V_DrawMappedPatch(x, y, 0, - W_CachePatchName(currentMenu->menuitems[i].patch,PU_CACHE), graymap); + W_CachePatchName(currentMenu->menuitems[i].patch, PU_PATCH), graymap); y += LINEHEIGHT; break; case IT_TRANSTEXT: @@ -5403,12 +5403,12 @@ static void M_DrawGenericMenu(void) || ((currentMenu->menuitems[itemOn].status & IT_DISPLAY) == IT_NOTHING)) { V_DrawScaledPatch(currentMenu->x + SKULLXOFF, cursory - 5, 0, - W_CachePatchName("M_CURSOR", PU_CACHE)); + W_CachePatchName("M_CURSOR", PU_PATCH)); } else { V_DrawScaledPatch(currentMenu->x - 24, cursory, 0, - W_CachePatchName("M_CURSOR", PU_CACHE)); + W_CachePatchName("M_CURSOR", PU_PATCH)); V_DrawString(currentMenu->x, cursory, MENUCAPS|highlightflags, currentMenu->menuitems[itemOn].text); } @@ -5435,7 +5435,7 @@ static void M_DrawGenericMenu(void) static void M_DrawGenericBackgroundMenu(void) { - V_DrawPatchFill(W_CachePatchName("SRB2BACK", PU_CACHE)); + V_DrawPatchFill(W_CachePatchName("SRB2BACK", PU_PATCH)); M_DrawGenericMenu(); } @@ -5557,7 +5557,7 @@ static void M_DrawGenericScrollMenu(void) // DRAW THE SKULL CURSOR V_DrawScaledPatch(currentMenu->x - 24, cursory, 0, - W_CachePatchName("M_CURSOR", PU_CACHE)); + W_CachePatchName("M_CURSOR", PU_PATCH)); // dumb hack // tooltips @@ -5587,7 +5587,7 @@ static void M_DrawPauseMenu(void) (currentMenu->y + MPauseMenu[mpause_discordrequests].alphaKey - 1) * FRACUNIT, FRACUNIT, 0, - W_CachePatchName("K_REQUE2", PU_CACHE), + W_CachePatchName("K_REQUE2", PU_PATCH), NULL ); } @@ -5617,7 +5617,7 @@ static void M_DrawCenteredMenu(void) case IT_PATCH: if (currentMenu->menuitems[i].patch && currentMenu->menuitems[i].patch[0]) { - patch_t *p = W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE); + patch_t *p = W_CachePatchName(currentMenu->menuitems[i].patch, PU_PATCH); if (currentMenu->menuitems[i].status & IT_CENTER) { @@ -5695,7 +5695,7 @@ static void M_DrawCenteredMenu(void) case IT_GRAYPATCH: if (currentMenu->menuitems[i].patch && currentMenu->menuitems[i].patch[0]) V_DrawMappedPatch(x, y, 0, - W_CachePatchName(currentMenu->menuitems[i].patch,PU_CACHE), graymap); + W_CachePatchName(currentMenu->menuitems[i].patch, PU_PATCH), graymap); y += LINEHEIGHT; break; } @@ -5706,12 +5706,12 @@ static void M_DrawCenteredMenu(void) || ((currentMenu->menuitems[itemOn].status & IT_DISPLAY) == IT_NOTHING)) { V_DrawScaledPatch(x + SKULLXOFF, cursory - 5, 0, - W_CachePatchName("M_CURSOR", PU_CACHE)); + W_CachePatchName("M_CURSOR", PU_PATCH)); } else { V_DrawScaledPatch(x - V_StringWidth(currentMenu->menuitems[itemOn].text, 0)/2 - 24, cursory, 0, - W_CachePatchName("M_CURSOR", PU_CACHE)); + W_CachePatchName("M_CURSOR", PU_PATCH)); V_DrawCenteredString(x, cursory, highlightflags|MENUCAPS, currentMenu->menuitems[itemOn].text); } } @@ -6007,7 +6007,7 @@ static void M_DrawMessageMenu(void) // hack: draw RA background in RA menus if (gamestate == GS_TIMEATTACK) - V_DrawPatchFill(W_CachePatchName("SRB2BACK", PU_CACHE)); + V_DrawPatchFill(W_CachePatchName("SRB2BACK", PU_PATCH)); M_DrawTextBox(currentMenu->x, y - 8, (max+7)>>3, mlines); @@ -6073,7 +6073,7 @@ static void M_StopMessage(INT32 choice) // You can even put multiple images in one menu! static void M_DrawImageDef(void) { - patch_t *patch = W_CachePatchName(currentMenu->menuitems[itemOn].text,PU_CACHE); + patch_t *patch = W_CachePatchName(currentMenu->menuitems[itemOn].text, PU_PATCH); if (patch->width <= BASEVIDWIDTH) V_DrawScaledPatch(0,0,0,patch); else @@ -6189,23 +6189,23 @@ static void M_AddonsInternal(void) W_UnlockCachedPatch(addonsp[i]); } - addonsp[EXT_FOLDER] = W_CachePatchName("M_FFLDR", PU_STATIC); - addonsp[EXT_UP] = W_CachePatchName("M_FBACK", PU_STATIC); - addonsp[EXT_NORESULTS] = W_CachePatchName("M_FNOPE", PU_STATIC); - addonsp[EXT_TXT] = W_CachePatchName("M_FTXT", PU_STATIC); - addonsp[EXT_CFG] = W_CachePatchName("M_FCFG", PU_STATIC); - addonsp[EXT_WAD] = W_CachePatchName("M_FWAD", PU_STATIC); + addonsp[EXT_FOLDER] = W_CachePatchName("M_FFLDR", PU_PATCH); + addonsp[EXT_UP] = W_CachePatchName("M_FBACK", PU_PATCH); + addonsp[EXT_NORESULTS] = W_CachePatchName("M_FNOPE", PU_PATCH); + addonsp[EXT_TXT] = W_CachePatchName("M_FTXT", PU_PATCH); + addonsp[EXT_CFG] = W_CachePatchName("M_FCFG", PU_PATCH); + addonsp[EXT_WAD] = W_CachePatchName("M_FWAD", PU_PATCH); #ifdef USE_KART - addonsp[EXT_KART] = W_CachePatchName("M_FKART", PU_STATIC); + addonsp[EXT_KART] = W_CachePatchName("M_FKART", PU_PATCH); #endif - addonsp[EXT_PK3] = W_CachePatchName("M_FPK3", PU_STATIC); - addonsp[EXT_SOC] = W_CachePatchName("M_FSOC", PU_STATIC); - addonsp[EXT_LUA] = W_CachePatchName("M_FLUA", PU_STATIC); - addonsp[NUM_EXT] = W_CachePatchName("M_FUNKN", PU_STATIC); - addonsp[NUM_EXT+1] = W_CachePatchName("M_FSEL", PU_STATIC); - addonsp[NUM_EXT+2] = W_CachePatchName("M_FLOAD", PU_STATIC); - addonsp[NUM_EXT+3] = W_CachePatchName("M_FSRCH", PU_STATIC); - addonsp[NUM_EXT+4] = W_CachePatchName("M_FSAVE", PU_STATIC); + addonsp[EXT_PK3] = W_CachePatchName("M_FPK3", PU_PATCH); + addonsp[EXT_SOC] = W_CachePatchName("M_FSOC", PU_PATCH); + addonsp[EXT_LUA] = W_CachePatchName("M_FLUA", PU_PATCH); + addonsp[NUM_EXT] = W_CachePatchName("M_FUNKN", PU_PATCH); + addonsp[NUM_EXT+1] = W_CachePatchName("M_FSEL", PU_PATCH); + addonsp[NUM_EXT+2] = W_CachePatchName("M_FLOAD", PU_PATCH); + addonsp[NUM_EXT+3] = W_CachePatchName("M_FSRCH", PU_PATCH); + addonsp[NUM_EXT+4] = W_CachePatchName("M_FSAVE", PU_PATCH); MISC_AddonsDef.prevMenu = currentMenu; M_SetupNextMenu(&MISC_AddonsDef); @@ -7214,9 +7214,9 @@ static void DrawReplayHutReplayInfo(void) //CONS_Printf("%d %s\n", demolist[dir_on[menudepthleft]].map, G_BuildMapName(demolist[dir_on[menudepthleft]].map)); lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(demolist[dir_on[menudepthleft]].map))); if (lumpnum != LUMPERROR) - patch = W_CachePatchNum(lumpnum, PU_CACHE); + patch = W_CachePatchNum(lumpnum, PU_PATCH); else - patch = W_CachePatchName("M_NOLVL", PU_CACHE); + patch = W_CachePatchName("M_NOLVL", PU_PATCH); if (!(demolist[dir_on[menudepthleft]].kartspeed & DF_ENCORE)) V_DrawSmallScaledPatch(x, y, V_SNAPTOTOP, patch); @@ -7229,7 +7229,7 @@ static void DrawReplayHutReplayInfo(void) { static angle_t rubyfloattime = 0; const fixed_t rubyheight = FINESINE(rubyfloattime>>ANGLETOFINESHIFT); - V_DrawFixedPatch((x+(w>>2))<>2))<>2))<>2))<x - 24, cursory, V_SNAPTOTOP|V_SNAPTOLEFT, - W_CachePatchName("M_CURSOR", PU_CACHE)); + W_CachePatchName("M_CURSOR", PU_PATCH)); V_DrawString(currentMenu->x, cursory, V_SNAPTOTOP|V_SNAPTOLEFT|highlightflags, currentMenu->menuitems[itemOn].text); // Now draw some replay info! @@ -7526,7 +7526,7 @@ static void M_DrawReplayStartMenu(void) } else { - patch = W_CachePatchName("M_NORANK", PU_CACHE); + patch = W_CachePatchName("M_NORANK", PU_PATCH); colormap = R_GetTranslationColormap( TC_RAINBOW, demolist[dir_on[menudepthleft]].standings[i].color, @@ -7700,16 +7700,16 @@ static void M_DrawPlaybackMenu(void) inactivemap = R_GetTranslationColormap(players[ply].skin, players[ply].skincolor, GTC_MENUCACHE); } else if (currentMenu->menuitems[i].patch && W_CheckNumForName(currentMenu->menuitems[i].patch) != LUMPERROR) - icon = W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE); + icon = W_CachePatchName(currentMenu->menuitems[i].patch, PU_PATCH); else - icon = W_CachePatchName("PLAYRANK", PU_CACHE); // temp + icon = W_CachePatchName("PLAYRANK", PU_PATCH); // temp } else if (currentMenu->menuitems[i].status == IT_DISABLED) continue; else if (currentMenu->menuitems[i].patch && W_CheckNumForName(currentMenu->menuitems[i].patch) != LUMPERROR) - icon = W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE); + icon = W_CachePatchName(currentMenu->menuitems[i].patch, PU_PATCH); else - icon = W_CachePatchName("PLAYRANK", PU_CACHE); // temp + icon = W_CachePatchName("PLAYRANK", PU_PATCH); // temp if ((i == playback_fastforward && cv_playbackspeed.value > 1) || (i == playback_rewind && demo.rewinding)) V_DrawMappedPatch(currentMenu->x + currentMenu->menuitems[i].alphaKey, currentMenu->y, transmap|V_SNAPTOTOP, icon, R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_JAWZ, GTC_MENUCACHE)); @@ -8344,13 +8344,13 @@ static void M_DrawEmblemHints(void) if (emblem->collected) { collected = recommendedflags; - V_DrawMappedPatch(12, 12+(28*j), 0, W_CachePatchName(M_GetEmblemPatch(emblem), PU_CACHE), + V_DrawMappedPatch(12, 12+(28*j), 0, W_CachePatchName(M_GetEmblemPatch(emblem), PU_PATCH), R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_MENUCACHE)); } else { collected = 0; - V_DrawScaledPatch(12, 12+(28*j), 0, W_CachePatchName("NEEDIT", PU_CACHE)); + V_DrawScaledPatch(12, 12+(28*j), 0, W_CachePatchName("NEEDIT", PU_PATCH)); } if (emblem->hint[0]) @@ -8874,7 +8874,7 @@ static void M_DrawStatsMaps(void) V_DrawRightAlignedString(BASEVIDWIDTH-16, 50, recommendedflags|MENUCAPS, "(complete)"); V_DrawString(32, 50, MENUCAPS, va("x %d/%d", M_CountEmblems(), numemblems+numextraemblems)); - V_DrawSmallScaledPatch(20, 50, 0, W_CachePatchName("GOTITA", PU_STATIC)); + V_DrawSmallScaledPatch(20, 50, 0, W_CachePatchName("GOTITA", PU_PATCH)); if (location) V_DrawCharacter(10, y-(skullAnimCounter/5), @@ -8945,10 +8945,10 @@ static void M_DrawStatsMaps(void) exemblem = &extraemblems[i]; if (exemblem->collected) - V_DrawSmallMappedPatch(295, y, 0, W_CachePatchName(M_GetExtraEmblemPatch(exemblem), PU_CACHE), + V_DrawSmallMappedPatch(295, y, 0, W_CachePatchName(M_GetExtraEmblemPatch(exemblem), PU_PATCH), R_GetTranslationColormap(TC_DEFAULT, M_GetExtraEmblemColor(exemblem), GTC_MENUCACHE)); else - V_DrawSmallScaledPatch(295, y, 0, W_CachePatchName("NEEDIT", PU_CACHE)); + V_DrawSmallScaledPatch(295, y, 0, W_CachePatchName("NEEDIT", PU_PATCH)); V_DrawString(20, y, MENUCAPS, va("%s", exemblem->description)); } @@ -9115,7 +9115,7 @@ void M_DrawTimeAttackMenu(void) //S_ChangeMusicInternal("racent", true); // Eww, but needed for when user hits escape during demo playback - V_DrawPatchFill(W_CachePatchName("SRB2BACK", PU_CACHE)); + V_DrawPatchFill(W_CachePatchName("SRB2BACK", PU_PATCH)); M_DrawMenuTitle(); if (currentMenu == &SP_TimeAttackDef) @@ -9199,7 +9199,7 @@ void M_DrawTimeAttackMenu(void) y = currentMenu->y; // DRAW THE SKULL CURSOR - V_DrawScaledPatch(x - 24, cursory, 0, W_CachePatchName("M_CURSOR", PU_CACHE)); + V_DrawScaledPatch(x - 24, cursory, 0, W_CachePatchName("M_CURSOR", PU_PATCH)); V_DrawString(x, cursory, highlightflags|MENUCAPS, currentMenu->menuitems[itemOn].text); // Level record list @@ -10247,12 +10247,12 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) { lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(cv_nextmap.value))); if (lumpnum != LUMPERROR) - PictureOfLevel = W_CachePatchNum(lumpnum, PU_CACHE); + PictureOfLevel = W_CachePatchNum(lumpnum, PU_PATCH); else - PictureOfLevel = W_CachePatchName("BLANKLVL", PU_CACHE); + PictureOfLevel = W_CachePatchName("BLANKLVL", PU_PATCH); } else - PictureOfLevel = W_CachePatchName("RANDOMLV", PU_CACHE); + PictureOfLevel = W_CachePatchName("RANDOMLV", PU_PATCH); w = PictureOfLevel->width/2; i = PictureOfLevel->height/2; @@ -10287,14 +10287,14 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) { /*UINT8 *mappingforencore = NULL; if ((lumpnum = W_CheckNumForName(va("%sE", mapname))) != LUMPERROR) - mappingforencore = W_CachePatchNum(lumpnum, PU_CACHE);*/ + mappingforencore = W_CachePatchNum(lumpnum, PU_PATCH);*/ V_DrawFixedPatch((x+w)<>ANGLETOFINESHIFT); - V_DrawFixedPatch((x+w/2)< 7 * FRACUNIT; cursorframe -= 7 * FRACUNIT) {} - V_DrawFixedPatch(x<> FRACBITS) + 1), PU_CACHE), NULL); + V_DrawFixedPatch(x<> FRACBITS) + 1), PU_PATCH), NULL); } x += incrwidth; @@ -10776,10 +10776,10 @@ static void M_DrawSetupMultiPlayerMenu(void) INT32 tw = 0; spritedef_t *sprdef; spriteframe_t *sprframe; - patch_t *statbg = W_CachePatchName("K_STATBG", PU_CACHE); - patch_t *statlr = W_CachePatchName("K_STATLR", PU_CACHE); - patch_t *statud = W_CachePatchName("K_STATUD", PU_CACHE); - patch_t *statdot = W_CachePatchName("K_SDOT0", PU_CACHE); + patch_t *statbg = W_CachePatchName("K_STATBG", PU_PATCH); + patch_t *statlr = W_CachePatchName("K_STATLR", PU_PATCH); + patch_t *statud = W_CachePatchName("K_STATUD", PU_PATCH); + patch_t *statdot = W_CachePatchName("K_SDOT0", PU_PATCH); patch_t *patch; UINT8 frame; UINT8 speed; @@ -10957,17 +10957,17 @@ static void M_DrawSetupMultiPlayerMenu(void) if (statdp == true) { //Background - V_DrawScaledPatch(statx - 50, staty + 4, 0, W_CachePatchName("K_STATNB", PU_CACHE)); + V_DrawScaledPatch(statx - 50, staty + 4, 0, W_CachePatchName("K_STATNB", PU_PATCH)); //Speed for (i = 0; i < GETSELECTEDSPEED; i++) // draw the stat bars { if (i == 0) - V_DrawScaledPatch(statx - 45, staty + 63, 0, W_CachePatchName("K_STATN1", PU_CACHE)); + V_DrawScaledPatch(statx - 45, staty + 63, 0, W_CachePatchName("K_STATN1", PU_PATCH)); else if (i == GETSELECTEDSPEED -1 ) - V_DrawScaledPatch(statx - 45, staty + 63 -(5 *i), 0, W_CachePatchName("K_STATN3", PU_CACHE)); + V_DrawScaledPatch(statx - 45, staty + 63 -(5 *i), 0, W_CachePatchName("K_STATN3", PU_PATCH)); else - V_DrawScaledPatch(statx - 45, staty + 63 -(5 *i), 0, W_CachePatchName("K_STATN2", PU_CACHE)); + V_DrawScaledPatch(statx - 45, staty + 63 -(5 *i), 0, W_CachePatchName("K_STATN2", PU_PATCH)); } //Weight @@ -10975,11 +10975,11 @@ static void M_DrawSetupMultiPlayerMenu(void) { if (i == 0) - V_DrawScaledPatch(statx - 30, staty + 63, 0, W_CachePatchName("K_STATN4", PU_CACHE)); + V_DrawScaledPatch(statx - 30, staty + 63, 0, W_CachePatchName("K_STATN4", PU_PATCH)); else if (i == GETSELECTEDWEIGHT -1) - V_DrawScaledPatch(statx - 30, staty + 63 -(5 *i), 0, W_CachePatchName("K_STATN6", PU_CACHE)); + V_DrawScaledPatch(statx - 30, staty + 63 -(5 *i), 0, W_CachePatchName("K_STATN6", PU_PATCH)); else - V_DrawScaledPatch(statx - 30, staty + 63 -(5 *i), 0, W_CachePatchName("K_STATN5", PU_CACHE)); + V_DrawScaledPatch(statx - 30, staty + 63 -(5 *i), 0, W_CachePatchName("K_STATN5", PU_PATCH)); } } @@ -11109,7 +11109,7 @@ static void M_DrawSetupMultiPlayerMenu(void) UINT8 cursorframe = (I_GetTime() / 4) % 7; - cursor = W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_CACHE); + cursor = W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH); V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL); } @@ -11157,7 +11157,7 @@ static void M_DrawSetupMultiPlayerMenu(void) { UINT8 cursorframe = (I_GetTime() / 4) % 7; - cursor = W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_CACHE); + cursor = W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH); V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL); } } @@ -11166,13 +11166,13 @@ static void M_DrawSetupMultiPlayerMenu(void) INT32 selectedskin = (itemOn == 1 && setupm_skinselect < numskins ? skinsorted[setupm_skinselect] : setupm_fakeskin); speed = skins[selectedskin].kartspeed; weight = skins[selectedskin].kartweight; - statdot = W_CachePatchName("K_SDOT1", PU_CACHE); + statdot = W_CachePatchName("K_SDOT1", PU_PATCH); if (skullAnimCounter < 4) // SRB2Kart: we draw this dot later so that it's not covered if there's multiple skins with the same stats V_DrawFixedPatch((((statx+46+GRIDSTATOFFSET) + (speed*4))<>1), (((staty+71) + (weight*4))<>1, 0, statdot, flashcol); else V_DrawFixedPatch((((statx+46+GRIDSTATOFFSET) + (speed*4))<>1), (((staty+71) + (weight*4))<>1, 0, statdot, NULL); - statdot = W_CachePatchName("K_SDOT2", PU_CACHE); // coloured center + statdot = W_CachePatchName("K_SDOT2", PU_PATCH); // coloured center if (setupm_fakecolor) V_DrawFixedPatch((((statx+46+GRIDSTATOFFSET) + (speed*4))<>1), (((staty+71) + (weight*4))<>1, 0, statdot, R_GetTranslationColormap(0, setupm_fakecolor, GTC_MENUCACHE)); } @@ -11221,7 +11221,7 @@ static void M_DrawSetupMultiPlayerMenu(void) { UINT8 cursorframe = (I_GetTime() / 4) % 7; - cursor = W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_CACHE); + cursor = W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH); V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL); } } @@ -11232,13 +11232,13 @@ static void M_DrawSetupMultiPlayerMenu(void) speed = skins[setupm_fakeskin].kartspeed; weight = skins[setupm_fakeskin].kartweight; - statdot = W_CachePatchName("K_SDOT1", PU_CACHE); + statdot = W_CachePatchName("K_SDOT1", PU_PATCH); if (skullAnimCounter < 4) // SRB2Kart: we draw this dot later so that it's not covered if there's multiple skins with the same stats V_DrawFixedPatch(((BASEVIDWIDTH - mx - 80) + ((speed-1)*8))< 7 * FRACUNIT; cursorframe -= 7 * FRACUNIT) {} - cursor = W_CachePatchName(va("K_BHILI%d", (cursorframe >> FRACBITS) + 1), PU_CACHE); + cursor = W_CachePatchName(va("K_BHILI%d", (cursorframe >> FRACBITS) + 1), PU_PATCH); if (col < 0) col += numskins; @@ -11388,7 +11388,7 @@ static void M_DrawSetupMultiPlayerMenu(void) sprframe = &sprdef->spriteframes[frame]; //minenice's speen css, it's a piece of shit but hey - //patch = W_CachePatchNum(sprframe->lumppat[1], PU_CACHE); + //patch = W_CachePatchNum(sprframe->lumppat[1], PU_PATCH); speenframe = (I_GetTime()*cv_skinselectspin.value/TICRATE + 1)%8; //this is a very shitty solution for checking if a sprite needs flipping @@ -11396,7 +11396,7 @@ static void M_DrawSetupMultiPlayerMenu(void) if ((sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe]) && (speenframe > 4)) flags = V_FLIP; // This sprite is left/right flipped! - patch = W_CachePatchNum(sprframe->lumppat[speenframe], PU_CACHE); + patch = W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH); // draw box around guy V_DrawFill(mx + 36 - (charw/2), my+65, charw, 84, 239); @@ -12521,7 +12521,7 @@ static void M_DrawControl(void) } V_DrawScaledPatch(currentMenu->x - 20, cursory, 0, - W_CachePatchName("M_CURSOR", PU_CACHE)); + W_CachePatchName("M_CURSOR", PU_PATCH)); } #undef controlheight @@ -12916,7 +12916,7 @@ static void M_DrawLocalSkinMenu(void) sprframe = &sprdef->spriteframes[frame]; //minenice's speen css, it's a piece of shit but hey - //patch = W_CachePatchNum(sprframe->lumppat[1], PU_CACHE); + //patch = W_CachePatchNum(sprframe->lumppat[1], PU_PATCH); speenframe = (I_GetTime()*cv_skinselectspin.value/TICRATE + 1)%8; //this is a very shitty solution for checking if a sprite needs flipping @@ -12924,7 +12924,7 @@ static void M_DrawLocalSkinMenu(void) if ((sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe]) && (speenframe > 4)) { flags = V_FLIP; // This sprite is left/right flipped! } - patch = W_CachePatchNum(sprframe->lumppat[speenframe], PU_CACHE); + patch = W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH); // draw box around guy V_DrawFill(mx + 220 - (charw/2), my+54, charw, 84, 239); @@ -12933,8 +12933,8 @@ static void M_DrawLocalSkinMenu(void) UINT8 *colormap = R_GetTranslationColormap(skintodisplay, cv_playercolor.value, GTC_MENUCACHE); colormap = R_GetLocalTranslationColormap(&skins[allskins[skintodisplay].localnum], (allskins[skintodisplay].localskin ? &localskins[allskins[skintodisplay].localnum] : NULL), cv_playercolor.value, GTC_MENUCACHE, allskins[skintodisplay].localskin); - V_DrawMappedPatch(mx, my+50, 0, W_CachePatchName(allskins[skintodisplay].facewant, PU_CACHE), colormap); - V_DrawMappedPatch(mx+8, my+85, 0, W_CachePatchName(allskins[skintodisplay].facerank, PU_CACHE), colormap); + V_DrawMappedPatch(mx, my+50, 0, W_CachePatchName(allskins[skintodisplay].facewant, PU_PATCH), colormap); + V_DrawMappedPatch(mx+8, my+85, 0, W_CachePatchName(allskins[skintodisplay].facerank, PU_PATCH), colormap); V_DrawString(mx, my+108, V_ALLOWLOWERCASE, "Character"); if (strlen(allskins[skintodisplay].realname) > 10) V_DrawThinString(mx+20, my+118, V_ALLOWLOWERCASE|highlightflags, allskins[skintodisplay].realname); @@ -13022,7 +13022,7 @@ static void M_DrawVideoMode(void) j = OP_VideoModeDef.y + 14 + ((vidm_selected % vidm_column_size)*8); V_DrawScaledPatch(i - 8, j, 0, - W_CachePatchName("M_CURSOR", PU_CACHE)); + W_CachePatchName("M_CURSOR", PU_PATCH)); } // Just M_DrawGenericScrollMenu but showing a backing behind the headers. @@ -13135,7 +13135,7 @@ static void M_DrawColorMenu(void) // DRAW THE SKULL CURSOR V_DrawScaledPatch(currentMenu->x - 24, cursory, 0, - W_CachePatchName("M_CURSOR", PU_CACHE)); + W_CachePatchName("M_CURSOR", PU_PATCH)); } @@ -13296,14 +13296,14 @@ static void M_DrawMonitorToggles(void) #ifdef ITEMTOGGLEBOTTOMRIGHT if (currentMenu->menuitems[thisitem].alphaKey == 255) { - V_DrawScaledPatch(x, y, V_TRANSLUCENT, W_CachePatchName("K_ISBG", PU_CACHE)); + V_DrawScaledPatch(x, y, V_TRANSLUCENT, W_CachePatchName("K_ISBG", PU_PATCH)); continue; } #endif if (currentMenu->menuitems[thisitem].alphaKey == 0) { - V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISBG", PU_CACHE)); - V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISTOGL", PU_CACHE)); + V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISBG", PU_PATCH)); + V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISTOGL", PU_PATCH)); continue; } @@ -13332,18 +13332,18 @@ static void M_DrawMonitorToggles(void) } if (cv->value) - V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISBG", PU_CACHE)); + V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISBG", PU_PATCH)); else - V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISBGD", PU_CACHE)); + V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISBGD", PU_PATCH)); if (drawnum != 0) { - V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISMUL", PU_CACHE)); - V_DrawScaledPatch(x, y, translucent, W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[thisitem].alphaKey, true), PU_CACHE)); + V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISMUL", PU_PATCH)); + V_DrawScaledPatch(x, y, translucent, W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[thisitem].alphaKey, true), PU_PATCH)); V_DrawString(x+24, y+31, V_ALLOWLOWERCASE|translucent, va("x%d", drawnum)); } else - V_DrawScaledPatch(x, y, translucent, W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[thisitem].alphaKey, true), PU_CACHE)); + V_DrawScaledPatch(x, y, translucent, W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[thisitem].alphaKey, true), PU_PATCH)); y += spacing; } @@ -13356,7 +13356,7 @@ static void M_DrawMonitorToggles(void) #ifdef ITEMTOGGLEBOTTOMRIGHT if (currentMenu->menuitems[itemOn].alphaKey == 255) { - V_DrawScaledPatch(onx-1, ony-2, V_TRANSLUCENT, W_CachePatchName("K_ITBG", PU_CACHE)); + V_DrawScaledPatch(onx-1, ony-2, V_TRANSLUCENT, W_CachePatchName("K_ITBG", PU_PATCH)); if (shitsfree) { INT32 trans = V_TRANSLUCENT; @@ -13364,15 +13364,15 @@ static void M_DrawMonitorToggles(void) trans = ((10-TICRATE)+shitsfree-1)<menuitems[itemOn].alphaKey == 0) { - V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchName("K_ITBG", PU_CACHE)); - V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchName("K_ITTOGL", PU_CACHE)); + V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchName("K_ITBG", PU_PATCH)); + V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchName("K_ITTOGL", PU_PATCH)); } else { @@ -13397,19 +13397,19 @@ static void M_DrawMonitorToggles(void) } if (cv->value) - V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchName("K_ITBG", PU_CACHE)); + V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchName("K_ITBG", PU_PATCH)); else - V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchName("K_ITBGD", PU_CACHE)); + V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchName("K_ITBGD", PU_PATCH)); if (drawnum != 0) { - V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchName("K_ITMUL", PU_CACHE)); - V_DrawScaledPatch(onx-1, ony-2, translucent, W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[itemOn].alphaKey, false), PU_CACHE)); - V_DrawScaledPatch(onx+27, ony+39, translucent, W_CachePatchName("K_ITX", PU_CACHE)); + V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchName("K_ITMUL", PU_PATCH)); + V_DrawScaledPatch(onx-1, ony-2, translucent, W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[itemOn].alphaKey, false), PU_PATCH)); + V_DrawScaledPatch(onx+27, ony+39, translucent, W_CachePatchName("K_ITX", PU_PATCH)); V_DrawKartString(onx+37, ony+34, translucent, va("%d", drawnum)); } else - V_DrawScaledPatch(onx-1, ony-2, translucent, W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[itemOn].alphaKey, false), PU_CACHE)); + V_DrawScaledPatch(onx-1, ony-2, translucent, W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[itemOn].alphaKey, false), PU_PATCH)); } } @@ -13571,7 +13571,7 @@ void M_QuitResponse(INT32 ch) while (ptime > I_GetTime()) { V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); - V_DrawSmallScaledPatch(0, 0, 0, W_CachePatchName("GAMEQUIT", PU_CACHE)); // Demo 3 Quit Screen Tails 06-16-2001 + V_DrawSmallScaledPatch(0, 0, 0, W_CachePatchName("GAMEQUIT", PU_PATCH)); // Demo 3 Quit Screen Tails 06-16-2001 I_FinishUpdate(); // Update the screen with the image Tails 06-19-2001 I_Sleep(cv_sleep.value); I_UpdateTime(cv_timescale.value); @@ -13641,12 +13641,12 @@ static void M_DrawSticker(INT32 x, INT32 y, INT32 width, INT32 flags, boolean is if (isSmall == true) { - stickerEnd = W_CachePatchName("K_STIKE2", PU_CACHE); + stickerEnd = W_CachePatchName("K_STIKE2", PU_PATCH); height = 6; } else { - stickerEnd = W_CachePatchName("K_STIKEN", PU_CACHE); + stickerEnd = W_CachePatchName("K_STIKEN", PU_PATCH); height = 11; } @@ -13676,12 +13676,12 @@ static void M_DrawDiscordRequests(void) if (confirmAccept == true) { colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_GREEN, GTC_MENUCACHE); - hand = W_CachePatchName("K_LAPH02", PU_CACHE); + hand = W_CachePatchName("K_LAPH02", PU_PATCH); } else { colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_RED, GTC_MENUCACHE); - hand = W_CachePatchName("K_LAPH03", PU_CACHE); + hand = W_CachePatchName("K_LAPH03", PU_PATCH); } slide = confirmLength - confirmDelay; @@ -13696,7 +13696,7 @@ static void M_DrawDiscordRequests(void) colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_GREY, GTC_MENUCACHE); } - V_DrawFixedPatch(56*FRACUNIT, 150*FRACUNIT, FRACUNIT, 0, W_CachePatchName("K_LAPE01", PU_CACHE), colormap); + V_DrawFixedPatch(56*FRACUNIT, 150*FRACUNIT, FRACUNIT, 0, W_CachePatchName("K_LAPE01", PU_PATCH), colormap); if (hand != NULL) { diff --git a/src/p_setup.c b/src/p_setup.c index 5d944e5e2..8eddd2a72 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3056,6 +3056,8 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) HWR_ClearLightTables(); #endif + Patch_FreeTag(PU_PATCH_LOWPRIORITY); + //Patch_FreeTag(PU_PATCH_ROTATED); // we keep those ty! Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1); #if defined (WALLSPLATS) || defined (FLOORSPLATS) @@ -3347,6 +3349,8 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) // // search for sprite replacements // + Patch_FreeTag(PU_SPRITE); + Patch_FreeTag(PU_PATCH_ROTATED); R_AddSpriteDefs(wadnum); // Reload it all anyway, just in case they @@ -3461,7 +3465,7 @@ boolean P_MultiSetupWadFiles(boolean fullsetup) if (partadd_stage == 0) { // Flush and reload HUD graphics - ST_UnloadGraphics(); + //ST_UnloadGraphics(); HU_LoadGraphics(); ST_LoadGraphics(); ST_ReloadSkinFaceGraphics(); diff --git a/src/r_data.c b/src/r_data.c index de4d239fa..c35aea0d9 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -393,7 +393,12 @@ static UINT8 *R_GenerateTexture(size_t texnum) // Composite the columns together. for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { - realpatch = (softwarepatch_t *)W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + // If this patch has already been loaded, we just use it from the cache. + realpatch = (softwarepatch_t *)W_GetCachedPatchNumPwad(patch->wad, patch->lump); + + // Otherwise, we load it here. + if (realpatch == NULL) + realpatch = (softwarepatch_t *)W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); // Well, it's not valid... if (realpatch == NULL) @@ -1834,7 +1839,7 @@ static void R_PrecacheLevelSprites(void) lump = sf->lumppat[a];\ if (devparm)\ spritememory += W_LumpLength(lump);\ - W_CachePatchNum(lump, PU_CACHE);\ + W_CachePatchNum(lump, PU_SPRITE);\ } // see R_InitSprites for more about lumppat,lumpid switch (sf->rotate) diff --git a/src/r_patch.c b/src/r_patch.c index 665b50122..20444d9b4 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -375,7 +375,7 @@ patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest) // Frees a patch from memory. // -void Patch_Free(patch_t *patch) +static void Patch_FreeData(patch_t *patch) { #ifdef HWRENDER if (patch->hardware) @@ -403,10 +403,30 @@ void Patch_Free(patch_t *patch) Z_Free(patch->columnofs); if (patch->columns) Z_Free(patch->columns); +} +void Patch_Free(patch_t *patch) +{ + Patch_FreeData(patch); Z_Free(patch); } +// +// Frees patches with a tag range. +// + +static boolean Patch_FreeTagsCallback(void *mem) +{ + patch_t *patch = (patch_t *)mem; + Patch_FreeData(patch); + return true; +} + +void Patch_FreeTags(INT32 lowtag, INT32 hightag) +{ + Z_IterateTags(lowtag, hightag, Patch_FreeTagsCallback); +} + #ifdef HWRENDER // // Allocates a hardware patch. @@ -416,8 +436,8 @@ void *Patch_AllocateHardwarePatch(patch_t *patch) { if (!patch->hardware) { - GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, &patch->hardware); - grPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, &grPatch->mipmap); + GLPatch_t *glPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, &patch->hardware); + glPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, &glPatch->mipmap); } return (void *)(patch->hardware); } @@ -428,10 +448,10 @@ void *Patch_AllocateHardwarePatch(patch_t *patch) void *Patch_CreateGL(patch_t *patch) { - GLPatch_t *grPatch = (GLPatch_t *)Patch_AllocateHardwarePatch(patch); - if (!grPatch->mipmap->data) // Run HWR_MakePatch in all cases, to recalculate some things - HWR_MakePatch(patch, grPatch, grPatch->mipmap, false); - return grPatch; + GLPatch_t *glPatch = (GLPatch_t *)Patch_AllocateHardwarePatch(patch); + if (!glPatch->mipmap->data) // Run HWR_MakePatch in all cases, to recalculate some things + HWR_MakePatch(patch, glPatch, glPatch->mipmap, false); + return glPatch; } #endif // HWRENDER @@ -657,8 +677,7 @@ patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spri if (lump == LUMPERROR) return NULL; - patch = W_CachePatchNum(lump, PU_CACHE); // PU_SPRITE - //patch = W_CachePatchNum(lump, PU_SPRITE); + patch = W_CachePatchNum(lump, PU_SPRITE); if (sprinfo->available) { @@ -837,7 +856,7 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle // make patch rotated = (patch_t *)R_MaskedFlatToPatch(rawconv, width, height, 0, 0, &size); - //Z_ChangeTag(rotated, PU_LEVEL); + Z_ChangeTag(rotated, PU_PATCH_ROTATED); Z_SetUser(rotated, (void **)(&rotsprite->patches[idx])); Z_Free(rawconv); diff --git a/src/r_patch.h b/src/r_patch.h index 38df76b05..bde624ead 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -42,6 +42,9 @@ typedef struct patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest); void Patch_Free(patch_t *patch); +#define Patch_FreeTag(tagnum) Patch_FreeTags(tagnum, tagnum) +void Patch_FreeTags(INT32 lowtag, INT32 hightag); + #ifdef HWRENDER void *Patch_AllocateHardwarePatch(patch_t *patch); void *Patch_CreateGL(patch_t *patch); diff --git a/src/r_segs.c b/src/r_segs.c index d1f46b6e8..9a2af70ba 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -171,7 +171,7 @@ static void R_DrawWallSplats(void) mfloorclip = floorclip; mceilingclip = ceilingclip; - patch = W_CachePatchNum(splat->patch, PU_CACHE); + patch = W_CachePatchNum(splat->patch, PU_SPRITE); dc_texturemid = splat->top + (patch->height<<(FRACBITS-1)) - viewz; if (splat->yoffset) diff --git a/src/r_splats.c b/src/r_splats.c index f86f16860..13b092ad0 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -142,7 +142,7 @@ void R_AddWallSplat(line_t *wallline, INT16 sectorside, const char *patchname, f splat->flags = flags; // bad.. but will be needed for drawing anyway.. - patch = W_CachePatchNum(splat->patch, PU_CACHE); + patch = W_CachePatchNum(splat->patch, PU_SPRITE); // idk? // offset needed by draw code for texture mapping linelength = P_SegLength((seg_t *)wallline); diff --git a/src/r_things.c b/src/r_things.c index 57ec53e5e..caa9085b9 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1800,7 +1800,7 @@ static void R_ProjectSprite(mobj_t *thing) vis->patch = rotsprite; else #endif - vis->patch = W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); + vis->patch = W_CachePatchNum(sprframe->lumppat[rot], PU_SPRITE); vis->precip = false; @@ -1985,7 +1985,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) //Fab: lumppat is the lump number of the patch to use, this is different // than lumpid for sprites-in-pwad : the graphics are patched - vis->patch = W_CachePatchNum(sprframe->lumppat[0], PU_CACHE); + vis->patch = W_CachePatchNum(sprframe->lumppat[0], PU_SPRITE); // specific translucency if ((thing->blendmode != AST_COPY) && cv_translucency.value) diff --git a/src/st_stuff.c b/src/st_stuff.c index 6e39661e7..7660fbd3b 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -211,7 +211,7 @@ void ST_doPaletteStuff(void) void ST_UnloadGraphics(void) { - Z_FreeTags(PU_HUDGFX, PU_HUDGFX); + Patch_FreeTag(PU_HUDGFX); } void ST_LoadGraphics(void) @@ -249,7 +249,7 @@ void ST_LoadFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 skin facerankprefix[skinnum] = W_CachePatchName(rankstr, PU_HUDGFX); facewantprefix[skinnum] = W_CachePatchName(wantstr, PU_HUDGFX); facemmapprefix[skinnum] = W_CachePatchName(mmapstr, PU_HUDGFX); - + /*facerankprefix_name[skinnum] = rankstr; facewantprefix_name[skinnum] = wantstr; facemmapprefix_name[skinnum] = mmapstr;*/ @@ -260,7 +260,7 @@ void ST_LoadLocalFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 localfacerankprefix[skinnum] = W_CachePatchName(rankstr, PU_HUDGFX); localfacewantprefix[skinnum] = W_CachePatchName(wantstr, PU_HUDGFX); localfacemmapprefix[skinnum] = W_CachePatchName(mmapstr, PU_HUDGFX); - + /*localfacerankprefix_name[skinnum] = rankstr; localfacewantprefix_name[skinnum] = wantstr; localfacemmapprefix_name[skinnum] = mmapstr;*/ @@ -276,7 +276,7 @@ void ST_ReloadSkinFaceGraphics(void) for (i = 0; i < numskins; i++) ST_LoadFaceGraphics(skins[i].facerank, skins[i].facewant, skins[i].facemmap, i); - + for (i = 0; i < numlocalskins; i++) ST_LoadLocalFaceGraphics(localskins[i].facerank, localskins[i].facewant, localskins[i].facemmap, i); } @@ -432,7 +432,7 @@ static void ST_drawLevelTitle(void) ? BASEVIDHEIGHT/2 : 163; INT32 lvlw; - + if (!cv_stagetitle.value) return; diff --git a/src/v_video.c b/src/v_video.c index 413829a8b..93d12800a 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -999,11 +999,11 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ void V_DrawContinueIcon(INT32 x, INT32 y, INT32 flags, INT32 skinnum, UINT8 skincolor) { if (skinnum < 0 || skinnum >= numskins || (skins[skinnum].flags & SF_HIRES)) - V_DrawScaledPatch(x - 10, y - 14, flags, W_CachePatchName("CONTINS", PU_CACHE)); // Draw a star + V_DrawScaledPatch(x - 10, y - 14, flags, W_CachePatchName("CONTINS", PU_PATCH)); // Draw a star else { // Find front angle of the first waiting frame of the character's actual sprites spriteframe_t *sprframe = &skins[skinnum].spritedef.spriteframes[2 & FF_FRAMEMASK]; - patch_t *patch = W_CachePatchNum(sprframe->lumppat[0], PU_CACHE); + patch_t *patch = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH); const UINT8 *colormap = R_GetTranslationColormap(skinnum, skincolor, GTC_CACHE); // No variant for translucency diff --git a/src/w_wad.c b/src/w_wad.c index 0f298067d..4d8e24a93 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1799,6 +1799,14 @@ void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag) return W_CachePatchNumPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum),tag); } +void *W_GetCachedPatchNumPwad(UINT16 wad, UINT16 lump) +{ + if (!TestValidLump(wad, lump)) + return NULL; + + return wadfiles[wad]->patchcache[lump]; +} + #ifdef ROTSPRITE // Caches a rotsprite for patch rotation. void *W_GetCachedRotPatchPwad(UINT16 wadnum, UINT16 lumpnum) @@ -1828,7 +1836,7 @@ void W_UnlockCachedPatch(void *patch) HWR_UnlockCachedPatch((GLPatch_t *)((patch_t *)patch)->hardware); else #endif - Z_ChangeTag(patch, PU_LEVEL); + Z_ChangeTag(patch, PU_PATCH); } void *W_CachePatchName(const char *name, INT32 tag) @@ -1870,13 +1878,13 @@ void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag) { INT32 xpivot = 0, ypivot = 0; - ptr = W_CachePatchNum(num, PU_STATIC); // PU_PATCH + ptr = W_CachePatchNum(num, PU_PATCH); // >y pivot centered // >x pivot not centered // Why? - xpivot = SHORT(ptr->width) / 2; - ypivot = SHORT(ptr->height) / 2; + xpivot = ptr->width / 2; + ypivot = ptr->height / 2; RotatedPatch_DoRotation(rspr, ptr, rotationangle, xpivot, ypivot, false); } diff --git a/src/w_wad.h b/src/w_wad.h index 0de9057b6..79cad44e9 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -216,6 +216,8 @@ void *W_CachePatchName(const char *name, INT32 tag); void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag); void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag); +void *W_GetCachedPatchNumPwad(UINT16 wad, UINT16 lump); + // Returns a Software patch. void *W_CacheSoftwarePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag); void *W_CacheSoftwarePatchNum(lumpnum_t lumpnum, INT32 tag); diff --git a/src/y_inter.c b/src/y_inter.c index 68ad7365a..65871cc78 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -420,7 +420,7 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) if (pnum == whiteplayer) { UINT8 cursorframe = (intertic / 4) % 8; - V_DrawScaledPatch(x+16, y-4, 0, W_CachePatchName(va("K_CHILI%d", cursorframe+1), PU_CACHE)); + V_DrawScaledPatch(x+16, y-4, 0, W_CachePatchName(va("K_CHILI%d", cursorframe+1), PU_PATCH)); } STRBUFCPY(strtime, standings->name[i]); @@ -856,7 +856,7 @@ void Y_StartIntermission(void) break; } - bgtile = W_CachePatchName("SRB2BACK", PU_STATIC); + bgtile = W_CachePatchName("SRB2BACK", PU_PATCH); LUA_HUD_DestroyDrawList(luahuddrawlist_intermission); luahuddrawlist_intermission = LUA_HUD_CreateDrawList(); @@ -922,7 +922,7 @@ static void Y_DrawAnimatedVoteScreenPatch(boolean widePatch) if (currentAnimFrame > tempFoundAnimVoteFrames - 1) currentAnimFrame = 0; - patch_t *background = W_CachePatchName(va("%s%d", tempAnimPrefix, currentAnimFrame + 1), PU_CACHE); + patch_t *background = W_CachePatchName(va("%s%d", tempAnimPrefix, currentAnimFrame + 1), PU_PATCH); V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (background->width/2), // Keep the width/height adjustments, for screens that are less wide than 320(?) (vid.height / vid.dupy) - background->height, V_SNAPTOTOP|V_SNAPTOLEFT, background); @@ -1187,7 +1187,7 @@ void Y_VoteDrawer(void) if (!splitscreen && i == consoleplayer) { UINT8 cursorframe = (votetic / 4) % 8; - V_DrawScaledPatch(x+24, y+9, V_SNAPTOLEFT, W_CachePatchName(va("K_CHILI%d", cursorframe+1), PU_CACHE)); + V_DrawScaledPatch(x+24, y+9, V_SNAPTOLEFT, W_CachePatchName(va("K_CHILI%d", cursorframe+1), PU_PATCH)); } } @@ -1466,15 +1466,15 @@ void Y_StartVote(void) Y_AnimatedVoteScreenCheck(); - widebgpatch = W_CachePatchName(((prefgametype == GT_MATCH) ? "BATTLSCW" : "INTERSCW"), PU_STATIC); - bgpatch = W_CachePatchName(((prefgametype == GT_MATCH) ? "BATTLSCR" : "INTERSCR"), PU_STATIC); - cursor = W_CachePatchName("M_CURSOR", PU_STATIC); - cursor1 = W_CachePatchName("P1CURSOR", PU_STATIC); - cursor2 = W_CachePatchName("P2CURSOR", PU_STATIC); - cursor3 = W_CachePatchName("P3CURSOR", PU_STATIC); - cursor4 = W_CachePatchName("P4CURSOR", PU_STATIC); - randomlvl = W_CachePatchName("RANDOMLV", PU_STATIC); - rubyicon = W_CachePatchName("RUBYICON", PU_STATIC); + widebgpatch = W_CachePatchName(((prefgametype == GT_MATCH) ? "BATTLSCW" : "INTERSCW"), PU_PATCH); + bgpatch = W_CachePatchName(((prefgametype == GT_MATCH) ? "BATTLSCR" : "INTERSCR"), PU_PATCH); + cursor = W_CachePatchName("M_CURSOR", PU_PATCH); + cursor1 = W_CachePatchName("P1CURSOR", PU_PATCH); + cursor2 = W_CachePatchName("P2CURSOR", PU_PATCH); + cursor3 = W_CachePatchName("P3CURSOR", PU_PATCH); + cursor4 = W_CachePatchName("P4CURSOR", PU_PATCH); + randomlvl = W_CachePatchName("RANDOMLV", PU_PATCH); + rubyicon = W_CachePatchName("RUBYICON", PU_PATCH); timer = cv_votetime.value*TICRATE; pickedvote = -1; @@ -1542,9 +1542,9 @@ void Y_StartVote(void) // set up the pic lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(votelevels[i][0]+1))); if (lumpnum != LUMPERROR) - levelinfo[i].pic = W_CachePatchName(va("%sP", G_BuildMapName(votelevels[i][0]+1)), PU_STATIC); + levelinfo[i].pic = W_CachePatchName(va("%sP", G_BuildMapName(votelevels[i][0]+1)), PU_PATCH); else - levelinfo[i].pic = W_CachePatchName("BLANKLVL", PU_STATIC); + levelinfo[i].pic = W_CachePatchName("BLANKLVL", PU_PATCH); } voteclient.loaded = true; diff --git a/src/z_zone.c b/src/z_zone.c index dd10f36e3..f72afa29d 100644 --- a/src/z_zone.c +++ b/src/z_zone.c @@ -656,24 +656,29 @@ static void Command_Memfree_f(void) Z_CheckHeap(-1); CONS_Printf("\x82%s", M_GetText("Memory Info\n")); - CONS_Printf(M_GetText("Total heap used : %7s KB\n"), sizeu1(Z_TagsUsage(0, INT32_MAX)>>10)); - CONS_Printf(M_GetText("Static : %7s KB\n"), sizeu1(Z_TagUsage(PU_STATIC)>>10)); - CONS_Printf(M_GetText("Lua : %7s KB\n"), sizeu1(Z_TagUsage(PU_LUA)>>10)); - CONS_Printf(M_GetText("Static (sound) : %7s KB\n"), sizeu1(Z_TagUsage(PU_SOUND)>>10)); - CONS_Printf(M_GetText("Static (music) : %7s KB\n"), sizeu1(Z_TagUsage(PU_MUSIC)>>10)); - CONS_Printf(M_GetText("Locked cache : %7s KB\n"), sizeu1(Z_TagUsage(PU_CACHE)>>10)); - CONS_Printf(M_GetText("Level : %7s KB\n"), sizeu1(Z_TagUsage(PU_LEVEL)>>10)); - CONS_Printf(M_GetText("Special thinker : %7s KB\n"), sizeu1(Z_TagUsage(PU_LEVSPEC)>>10)); - CONS_Printf(M_GetText("All purgable : %7s KB\n"), + CONS_Printf(M_GetText("Total heap used : %7s KB\n"), sizeu1(Z_TagsUsage(0, INT32_MAX)>>10)); + CONS_Printf(M_GetText("Static : %7s KB\n"), sizeu1(Z_TagUsage(PU_STATIC)>>10)); + CONS_Printf(M_GetText("Lua : %7s KB\n"), sizeu1(Z_TagUsage(PU_LUA)>>10)); + CONS_Printf(M_GetText("Static (sound) : %7s KB\n"), sizeu1(Z_TagUsage(PU_SOUND)>>10)); + CONS_Printf(M_GetText("Static (music) : %7s KB\n"), sizeu1(Z_TagUsage(PU_MUSIC)>>10)); + CONS_Printf(M_GetText("Patches : %7s KB\n"), sizeu1(Z_TagUsage(PU_PATCH)>>10)); + CONS_Printf(M_GetText("Patches (low priority) : %7s KB\n"), sizeu1(Z_TagUsage(PU_PATCH_LOWPRIORITY)>>10)); + CONS_Printf(M_GetText("Patches (rotated) : %7s KB\n"), sizeu1(Z_TagUsage(PU_PATCH_ROTATED)>>10)); + CONS_Printf(M_GetText("Sprites : %7s KB\n"), sizeu1(Z_TagUsage(PU_SPRITE)>>10)); + CONS_Printf(M_GetText("HUD graphics : %7s KB\n"), sizeu1(Z_TagUsage(PU_HUDGFX)>>10)); + CONS_Printf(M_GetText("Locked cache : %7s KB\n"), sizeu1(Z_TagUsage(PU_CACHE)>>10)); + CONS_Printf(M_GetText("Level : %7s KB\n"), sizeu1(Z_TagUsage(PU_LEVEL)>>10)); + CONS_Printf(M_GetText("Special thinker : %7s KB\n"), sizeu1(Z_TagUsage(PU_LEVSPEC)>>10)); + CONS_Printf(M_GetText("All purgable : %7s KB\n"), sizeu1(Z_TagsUsage(PU_PURGELEVEL, INT32_MAX)>>10)); #ifdef HWRENDER if (rendermode != render_soft && rendermode != render_none) { - CONS_Printf(M_GetText("Patch info headers: %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHINFO)>>10)); - CONS_Printf(M_GetText("Mipmap patches : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHCOLMIPMAP)>>10)); - CONS_Printf(M_GetText("HW Texture cache : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRCACHE)>>10)); - CONS_Printf(M_GetText("Plane polygons : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPLANE)>>10)); + CONS_Printf(M_GetText("Patch info headers : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHINFO)>>10)); + CONS_Printf(M_GetText("Cached textures : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRCACHE)>>10)); + CONS_Printf(M_GetText("Texture colormaps : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHCOLMIPMAP)>>10)); + CONS_Printf(M_GetText("Plane polygons : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPLANE)>>10)); CONS_Printf(M_GetText("All GPU textures : %7d KB\n"), HWR_GetTextureUsed()>>10); } #endif diff --git a/src/z_zone.h b/src/z_zone.h index e4ee811f2..1c5bdffd5 100644 --- a/src/z_zone.h +++ b/src/z_zone.h @@ -44,7 +44,12 @@ enum PU_SOUND = 11, // static while playing PU_MUSIC = 12, // static while playing - PU_HUDGFX = 13, // static until WAD added + + PU_PATCH = 13, // static entire execution time + PU_PATCH_LOWPRIORITY = 14, // lower priority patch, static until level exited + PU_PATCH_ROTATED = 15, // rotated patch, static until level exited or WAD added + PU_SPRITE = 16, // sprite patch, static until WAD added + PU_HUDGFX = 17, // HUD patch, static until WAD added PU_HWRPATCHINFO = 21, // Hardware GLPatch_t struct for OpenGL texture cache PU_HWRPATCHCOLMIPMAP = 22, // Hardware GLMipmap_t struct colormap variation of patch From b0ba261e149a94e33fa3f29586f163d828dc008e Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 15 Apr 2025 14:32:42 +0200 Subject: [PATCH 211/350] change those tags also add PU_PATCH_DATA --- src/r_patch.c | 6 +++--- src/z_zone.h | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/r_patch.c b/src/r_patch.c index 20444d9b4..c10a8cd95 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -336,7 +336,7 @@ static unsigned char imgbuf[1<<26]; patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest) { - patch_t *patch = (dest == NULL) ? Z_Calloc(sizeof(patch_t), PU_CACHE, NULL) : (patch_t *)(dest); + patch_t *patch = (dest == NULL) ? Z_Calloc(sizeof(patch_t), PU_PATCH, NULL) : (patch_t *)(dest); if (source) { @@ -348,7 +348,7 @@ patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest) patch->height = SHORT(source->height); patch->leftoffset = SHORT(source->leftoffset); patch->topoffset = SHORT(source->topoffset); - patch->columnofs = Z_Calloc(size, PU_CACHE, NULL); + patch->columnofs = Z_Calloc(size, PU_PATCH_DATA, NULL); for (col = 0; col < source->width; col++) { @@ -364,7 +364,7 @@ patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest) if (colsize <= 0) I_Error("Patch_Create: no column data!"); - patch->columns = Z_Calloc(colsize, PU_CACHE, NULL); + patch->columns = Z_Calloc(colsize, PU_PATCH_DATA, NULL); M_Memcpy(patch->columns, ((UINT8 *)source + LONG(source->columnofs[0])), colsize); } diff --git a/src/z_zone.h b/src/z_zone.h index 1c5bdffd5..bb4597ac5 100644 --- a/src/z_zone.h +++ b/src/z_zone.h @@ -45,11 +45,12 @@ enum PU_SOUND = 11, // static while playing PU_MUSIC = 12, // static while playing - PU_PATCH = 13, // static entire execution time - PU_PATCH_LOWPRIORITY = 14, // lower priority patch, static until level exited - PU_PATCH_ROTATED = 15, // rotated patch, static until level exited or WAD added - PU_SPRITE = 16, // sprite patch, static until WAD added - PU_HUDGFX = 17, // HUD patch, static until WAD added + PU_PATCH = 14, // static entire execution time + PU_PATCH_LOWPRIORITY = 15, // lower priority patch, static until level exited + PU_PATCH_ROTATED = 16, // rotated patch, static until level exited or WAD added + PU_PATCH_DATA = 17, // patch data, lifetime depends on the patch that owns it + PU_SPRITE = 18, // sprite patch, static until WAD added + PU_HUDGFX = 19, // HUD patch, static until WAD added PU_HWRPATCHINFO = 21, // Hardware GLPatch_t struct for OpenGL texture cache PU_HWRPATCHCOLMIPMAP = 22, // Hardware GLMipmap_t struct colormap variation of patch From 1c95b2e464dd95c1848a9a9ebb412b0195044481 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 15:57:22 +0200 Subject: [PATCH 212/350] idk anymore lel --- src/hardware/hw_cache.c | 14 +++----------- src/r_data.c | 23 ++++++++++------------- src/st_stuff.c | 4 ++-- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 83a3a2d6b..7393caa47 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -314,6 +314,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe texture_t *texture; texpatch_t *patch; softwarepatch_t *realpatch; + UINT8 *pdata; INT32 blockwidth, blockheight, blocksize; UINT8 *colormap = colormaps; @@ -377,12 +378,8 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe // Composite the columns together. for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { - // If this patch has already been loaded, we just use it from the cache. - realpatch = (softwarepatch_t *)W_GetCachedPatchNumPwad(patch->wad, patch->lump); - - // Otherwise, we load it here. - if (realpatch == NULL) - realpatch = (softwarepatch_t *)W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + pdata = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + realpatch = (softwarepatch_t *)pdata; if (realpatch != NULL) { @@ -516,10 +513,6 @@ void HWR_FreeTextureColormaps(patch_t *patch) // Set the first colormap to the one that comes after it. next = pat->mipmap->nextcolormap; - - if (!next) - break; - pat->mipmap->nextcolormap = next->nextcolormap; // Free image data from memory. @@ -1233,7 +1226,6 @@ void HWR_GetFadeMask(lumpnum_t fademasklumpnum) patch = HWR_GetCachedGLPatch(fademasklumpnum); glMipmap = ((GLPatch_t *)Patch_AllocateHardwarePatch(patch))->mipmap; - if (!glMipmap->downloaded && !glMipmap->data) HWR_CacheFadeMask(glMipmap, fademasklumpnum); diff --git a/src/r_data.c b/src/r_data.c index c35aea0d9..bf11ce79d 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -303,6 +303,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) texture_t *texture; texpatch_t *patch; softwarepatch_t *realpatch; + UINT8 *pdata; int x, x1, x2, i, width, height; size_t blocksize; column_t *patchcol; @@ -322,8 +323,8 @@ static UINT8 *R_GenerateTexture(size_t texnum) { boolean holey = false; patch = texture->patches; - - realpatch = (softwarepatch_t *)W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + pdata = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + realpatch = (softwarepatch_t *)pdata; // Check the patch for holes. if (texture->width > SHORT(realpatch->width) || texture->height > SHORT(realpatch->height)) @@ -393,12 +394,8 @@ static UINT8 *R_GenerateTexture(size_t texnum) // Composite the columns together. for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { - // If this patch has already been loaded, we just use it from the cache. - realpatch = (softwarepatch_t *)W_GetCachedPatchNumPwad(patch->wad, patch->lump); - - // Otherwise, we load it here. - if (realpatch == NULL) - realpatch = (softwarepatch_t *)W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + pdata = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + realpatch = (softwarepatch_t *)pdata; // Well, it's not valid... if (realpatch == NULL) @@ -520,7 +517,7 @@ void R_LoadTextures(void) INT32 i, k, w; UINT16 j; UINT16 texstart, texend, texturesLumpPos; - patch_t *patchlump; + softwarepatch_t patchlump; texpatch_t *patch; texture_t *texture; @@ -642,13 +639,15 @@ void R_LoadTextures(void) } patchlump = W_CacheLumpNumPwad((UINT16)w, texstart + j, PU_CACHE); + W_ReadLumpHeaderPwad(wadnum, lumpnum, &patchlump, 8, 0); + //CONS_Printf("\n\"%s\" is a single patch, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),patchlump->width, patchlump->height); texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL); // Set texture properties. M_Memcpy(texture->name, W_CheckNameForNumPwad((UINT16)w, texstart + j), sizeof(texture->name)); - texture->width = patchlump->width; - texture->height = patchlump->height; + texture->width = SHORT(patchlump.width); + texture->height = SHORT(patchlump.height); texture->patchcount = 1; texture->holes = false; @@ -659,8 +658,6 @@ void R_LoadTextures(void) patch->wad = (UINT16)w; patch->lump = texstart + j; - Z_Free(patchlump); - k = 1; while (k << 1 <= texture->width) k <<= 1; diff --git a/src/st_stuff.c b/src/st_stuff.c index 7660fbd3b..5a09f61e8 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -217,8 +217,8 @@ void ST_UnloadGraphics(void) void ST_LoadGraphics(void) { // SRB2 border patch - st_borderpatchnum = W_GetNumForName("GFZFLR01"); - scr_borderpatch = W_CacheLumpNum(st_borderpatchnum, PU_HUDGFX); + //st_borderpatchnum = W_GetNumForName("GFZFLR01"); + //scr_borderpatch = W_CacheLumpNum(st_borderpatchnum, PU_HUDGFX); // the original Doom uses 'STF' as base name for all face graphics // Graue 04-08-2004: face/name graphics are now indexed by skins From 6b44ac922efdb371ece609c837d7a62a2103e71c Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 15:57:44 +0200 Subject: [PATCH 213/350] revert this part --- src/r_data.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index bf11ce79d..0c582054b 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -517,7 +517,7 @@ void R_LoadTextures(void) INT32 i, k, w; UINT16 j; UINT16 texstart, texend, texturesLumpPos; - softwarepatch_t patchlump; + softwarepatch_t *patchlump; texpatch_t *patch; texture_t *texture; @@ -639,15 +639,15 @@ void R_LoadTextures(void) } patchlump = W_CacheLumpNumPwad((UINT16)w, texstart + j, PU_CACHE); - W_ReadLumpHeaderPwad(wadnum, lumpnum, &patchlump, 8, 0); + patchlump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_STATIC); //CONS_Printf("\n\"%s\" is a single patch, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),patchlump->width, patchlump->height); texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL); // Set texture properties. M_Memcpy(texture->name, W_CheckNameForNumPwad((UINT16)w, texstart + j), sizeof(texture->name)); - texture->width = SHORT(patchlump.width); - texture->height = SHORT(patchlump.height); + texture->width = SHORT(patchlump->width); + texture->height = SHORT(patchlump->height); texture->patchcount = 1; texture->holes = false; From 2e7ae45fdbe89ed6baf7d4be96a6f9c0e4173120 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 15 Apr 2025 15:34:30 +0200 Subject: [PATCH 214/350] cast Zzz... --- src/r_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index 0c582054b..c91910a32 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -639,7 +639,7 @@ void R_LoadTextures(void) } patchlump = W_CacheLumpNumPwad((UINT16)w, texstart + j, PU_CACHE); - patchlump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_STATIC); + patchlump = (softwarepatch_t *)W_CacheLumpNumPwad(wadnum, lumpnum, PU_STATIC); //CONS_Printf("\n\"%s\" is a single patch, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),patchlump->width, patchlump->height); texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL); From 123fe48cad3e09e9fc129a95773492883604dfe8 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 15 Apr 2025 16:27:03 +0200 Subject: [PATCH 215/350] simplify this --- src/w_wad.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 4d8e24a93..2e7f2cee4 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1780,7 +1780,7 @@ void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) if (!TestValidLump(wad, lump)) return NULL; - patch = W_CacheSoftwarePatchNumPwad(wad, lump, tag); + patch = (patch_t *)W_CacheSoftwarePatchNumPwad(wad, lump, tag); #ifdef HWRENDER // Software-only compile cache the data without conversion @@ -1843,9 +1843,7 @@ void *W_CachePatchName(const char *name, INT32 tag) { lumpnum_t num; - const char *finalname = name; - - num = W_CheckNumForName(finalname); + num = W_CheckNumForName(name); if (num == LUMPERROR) return W_CachePatchNum(W_GetNumForName("MISSING"), tag); From 804d9e2e8eefc7dc3ef3f10181312dde34f1d5b5 Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 15 Apr 2025 17:49:52 +0300 Subject: [PATCH 216/350] If GLENCORE is enabled, free both encore and noencore textures --- src/hardware/hw_cache.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 7393caa47..aa995de85 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -585,7 +585,11 @@ void HWR_FreeMapTextures(void) { size_t i; +#ifdef GLENCORE + for (i = 0; i < gl_numtextures*2; i++) +#else for (i = 0; i < gl_numtextures; i++) +#endif { FreeMapTexture(&gl_textures[i]); } From 70f1a6bf48e8a01980d62dcde4ea9ecf9f95ff76 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 15 Apr 2025 16:55:04 +0200 Subject: [PATCH 217/350] readd hud gfx flushing now that stuff doesent completely die lmao --- src/hardware/hw_cache.c | 3 +-- src/p_setup.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index aa995de85..c4720450d 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -551,8 +551,7 @@ static void HWR_FreePatchCache(boolean freeall) callback = FreeColormapsCallback; Z_IterateTags(PU_PATCH, PU_PATCH_ROTATED, callback); - //Z_IterateTags(PU_SPRITE, PU_HUDGFX, callback); // why would we want to free our hudgfx? - Z_IterateTags(PU_SPRITE, PU_SPRITE, callback); + Z_IterateTags(PU_SPRITE, PU_HUDGFX, callback); } // free all textures after each level diff --git a/src/p_setup.c b/src/p_setup.c index 8eddd2a72..a984121aa 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3465,7 +3465,7 @@ boolean P_MultiSetupWadFiles(boolean fullsetup) if (partadd_stage == 0) { // Flush and reload HUD graphics - //ST_UnloadGraphics(); + ST_UnloadGraphics(); HU_LoadGraphics(); ST_LoadGraphics(); ST_ReloadSkinFaceGraphics(); From 41cb3e932a5d2a71927eeba81b8f22be7f09c11f Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 15:58:30 +0200 Subject: [PATCH 218/350] readd freeing those dont want kart to use like 4gbs of memory for no reason lel --- src/r_data.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index c91910a32..015cc626f 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -323,7 +323,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) { boolean holey = false; patch = texture->patches; - pdata = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + pdata = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_LEVEL); realpatch = (softwarepatch_t *)pdata; // Check the patch for holes. @@ -359,7 +359,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) { texture->holes = true; blocksize = W_LumpLengthPwad(patch->wad, patch->lump); - block = Z_Calloc(blocksize, PU_STATIC, // will change tag at end of this function + block = Z_Calloc(blocksize, PU_LEVEL, // will change tag at end of this function &texturecache[texnum]); M_Memcpy(block, realpatch, blocksize); texturememory += blocksize; @@ -380,7 +380,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) texture->holes = false; blocksize = (texture->width * 4) + (texture->width * texture->height); texturememory += blocksize; - block = Z_Malloc(blocksize+1, PU_STATIC, &texturecache[texnum]); + block = Z_Malloc(blocksize+1, PU_LEVEL, &texturecache[texnum]); memset(block, TRANSPARENTPIXEL, blocksize+1); // Transparency hack @@ -394,7 +394,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) // Composite the columns together. for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { - pdata = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + pdata = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_LEVEL); realpatch = (softwarepatch_t *)pdata; // Well, it's not valid... @@ -436,8 +436,6 @@ static UINT8 *R_GenerateTexture(size_t texnum) } done: - // Now that the texture has been built in column cache, it is purgable from zone memory. - Z_ChangeTag(block, PU_CACHE); return blocktex; } @@ -487,7 +485,7 @@ UINT8 *R_GetColumn(fixed_t tex, INT32 col) // UINT8 *R_GetFlat(lumpnum_t flatlumpnum) { - return W_CacheLumpNum(flatlumpnum, PU_CACHE); + return W_CacheLumpNum(flatlumpnum, PU_LEVEL); } // From 8ab097f166e6d963e19e3554b1b261aa0977da24 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 15 Apr 2025 18:37:33 +0200 Subject: [PATCH 219/350] dont free our rotsprites aa --- src/hardware/hw_cache.c | 3 ++- src/r_defs.h | 1 - src/r_patch.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index c4720450d..afba914a3 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -550,7 +550,8 @@ static void HWR_FreePatchCache(boolean freeall) if (!freeall) callback = FreeColormapsCallback; - Z_IterateTags(PU_PATCH, PU_PATCH_ROTATED, callback); + //Z_IterateTags(PU_PATCH, PU_PATCH_ROTATED, callback); + Z_IterateTags(PU_PATCH, PU_PATCH, callback); Z_IterateTags(PU_SPRITE, PU_HUDGFX, callback); } diff --git a/src/r_defs.h b/src/r_defs.h index a168b9c50..95f8a796d 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -656,7 +656,6 @@ typedef struct #ifdef ROTSPRITE rotsprite_t *rotated; // Rotated patches #endif - } patch_t; #if defined(_MSC_VER) diff --git a/src/r_patch.c b/src/r_patch.c index c10a8cd95..e35563fe6 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -383,7 +383,7 @@ static void Patch_FreeData(patch_t *patch) #endif #ifdef ROTSPRITE - if (patch->rotated) + /*if (patch->rotated) { rotsprite_t *rotsprite = patch->rotated; INT32 i = 0; @@ -396,7 +396,7 @@ static void Patch_FreeData(patch_t *patch) Z_Free(rotsprite->patches); Z_Free(rotsprite); - } + }*/ #endif if (patch->columnofs) From 14a1c391a68f1f4e1df62139ceba4fb3b33eeaac Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 15 Apr 2025 19:14:20 +0200 Subject: [PATCH 220/350] fix models lel --- src/hardware/hw_md2.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index d74486ac4..a3413f90f 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -368,7 +368,6 @@ static void md2_loadTexture(md2_t *model) { patch_t *patch; GLPatch_t *glPatch = NULL; - const char *filename = model->filename; if (model->glpatch) @@ -1324,10 +1323,15 @@ void HWR_DrawMD2(gl_vissprite_t *spr) || ((!hwrBlendPatch->mipmap->format || !hwrBlendPatch->mipmap->downloaded) && !hwrPatch->notfound))) md2_loadBlendTexture(md2); + // Load it again, because it isn't being loaded into blendgpatch after md2_loadblendtexture... + blendgpatch = md2->blendglpatch; + if (blendgpatch) + hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware); + if (gpatch && hwrPatch && hwrPatch->mipmap->format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture { if ((skincolors_t)spr->mobj->color != SKINCOLOR_NONE && - md2->blendglpatch && (hwrBlendPatch->mipmap->format + blendgpatch && (hwrBlendPatch->mipmap->format && gpatch->width == (blendgpatch->width && gpatch->height == (blendgpatch->height)))) { INT32 tcskinnum = TC_DEFAULT; @@ -1353,6 +1357,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) } else tcskinnum = TC_DEFAULT; } + HWR_GetBlendedTexture(gpatch, blendgpatch, tcskinnum, spr->colormap, (skincolors_t)spr->mobj->color); } else From 50caffd70f977f465964a12a1b19e4aeccdabcaa Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 15 Apr 2025 19:23:53 +0200 Subject: [PATCH 221/350] add tags for model textures --- src/hardware/hw_md2.c | 12 ++++++------ src/z_zone.c | 3 ++- src/z_zone.h | 2 ++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index a3413f90f..d50a30354 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -244,7 +244,7 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_ { png_uint_32 i, pitch = png_get_rowbytes(png_ptr, png_info_ptr); - png_bytep PNG_image = Z_Malloc(pitch*height, PU_HWRCACHE, &glpatch->mipmap->data); + png_bytep PNG_image = Z_Malloc(pitch*height, PU_HWRMODELTEXTURE, &glpatch->mipmap->data); png_bytepp row_pointers = png_malloc(png_ptr, height * sizeof (png_bytep)); for (i = 0; i < height; i++) row_pointers[i] = PNG_image + i*pitch; @@ -324,7 +324,7 @@ static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h, pw = *w = header.xmax - header.xmin + 1; ph = *h = header.ymax - header.ymin + 1; - image = Z_Malloc(pw*ph*4, PU_HWRCACHE, &glpatch->mipmap->data); + image = Z_Malloc(pw*ph*4, PU_HWRMODELTEXTURE, &glpatch->mipmap->data); if (fread(palette, sizeof (UINT8), PALSIZE, file) != PALSIZE) { @@ -729,7 +729,7 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi glMipmap->data = NULL; } - cur = Z_Malloc(size*4, PU_HWRCACHE, &glMipmap->data); + cur = Z_Malloc(size*4, PU_HWRMODELTEXTURE, &glMipmap->data); memset(cur, 0x00, size*4); image = hwrPatch->mipmap->data; @@ -1098,7 +1098,7 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendgpatch, INT32 sk else GL_SetTexture(glMipmap); // found the colormap, set it to the correct texture - Z_ChangeTag(glMipmap->data, PU_HWRCACHE_UNLOCKED); + Z_ChangeTag(glMipmap->data, PU_HWRMODELTEXTURE_UNLOCKED); return; } } @@ -1113,7 +1113,7 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendgpatch, INT32 sk // (...) unfortunately z_malloc fragment alot the memory :(so malloc is better newMipmap = calloc(1, sizeof (*newMipmap)); if (newMipmap == NULL) - I_Error("%s: Out of memory", "HWR_GetMappedPatch"); + I_Error("%s: Out of memory", "HWR_GetBlendedTexture"); glMipmap->nextcolormap = newMipmap; newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL); @@ -1123,7 +1123,7 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendgpatch, INT32 sk HWR_CreateBlendedTexture(patch, blendgpatch, newMipmap, skinnum, color); GL_SetTexture(newMipmap); - Z_ChangeTag(newMipmap->data, PU_HWRCACHE_UNLOCKED); + Z_ChangeTag(newMipmap->data, PU_HWRMODELTEXTURE_UNLOCKED); } // -----------------+ diff --git a/src/z_zone.c b/src/z_zone.c index f72afa29d..698861dfb 100644 --- a/src/z_zone.c +++ b/src/z_zone.c @@ -657,8 +657,8 @@ static void Command_Memfree_f(void) Z_CheckHeap(-1); CONS_Printf("\x82%s", M_GetText("Memory Info\n")); CONS_Printf(M_GetText("Total heap used : %7s KB\n"), sizeu1(Z_TagsUsage(0, INT32_MAX)>>10)); - CONS_Printf(M_GetText("Static : %7s KB\n"), sizeu1(Z_TagUsage(PU_STATIC)>>10)); CONS_Printf(M_GetText("Lua : %7s KB\n"), sizeu1(Z_TagUsage(PU_LUA)>>10)); + CONS_Printf(M_GetText("Static : %7s KB\n"), sizeu1(Z_TagUsage(PU_STATIC)>>10)); CONS_Printf(M_GetText("Static (sound) : %7s KB\n"), sizeu1(Z_TagUsage(PU_SOUND)>>10)); CONS_Printf(M_GetText("Static (music) : %7s KB\n"), sizeu1(Z_TagUsage(PU_MUSIC)>>10)); CONS_Printf(M_GetText("Patches : %7s KB\n"), sizeu1(Z_TagUsage(PU_PATCH)>>10)); @@ -678,6 +678,7 @@ static void Command_Memfree_f(void) CONS_Printf(M_GetText("Patch info headers : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHINFO)>>10)); CONS_Printf(M_GetText("Cached textures : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRCACHE)>>10)); CONS_Printf(M_GetText("Texture colormaps : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHCOLMIPMAP)>>10)); + CONS_Printf(M_GetText("Model textures : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRMODELTEXTURE)>>10)); CONS_Printf(M_GetText("Plane polygons : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPLANE)>>10)); CONS_Printf(M_GetText("All GPU textures : %7d KB\n"), HWR_GetTextureUsed()>>10); } diff --git a/src/z_zone.h b/src/z_zone.h index bb4597ac5..41ea1d669 100644 --- a/src/z_zone.h +++ b/src/z_zone.h @@ -54,6 +54,7 @@ enum PU_HWRPATCHINFO = 21, // Hardware GLPatch_t struct for OpenGL texture cache PU_HWRPATCHCOLMIPMAP = 22, // Hardware GLMipmap_t struct colormap variation of patch + PU_HWRMODELTEXTURE = 23, // Hardware model texture PU_HWRCACHE = 48, // static until unlocked PU_CACHE = 49, // static until unlocked @@ -69,6 +70,7 @@ enum PU_HWRCACHE_UNLOCKED = 102, // 'unlocked' PU_HWRCACHE memory: // 'second-level' cache for graphics // stored in hardware format and downloaded as needed + PU_HWRMODELTEXTURE_UNLOCKED = 103, // 'unlocked' PU_HWRMODELTEXTURE memory }; // From fccfcd12fd67610d4cdbe23c2c37ccf6bb5e0baa Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 15 Apr 2025 20:27:21 +0200 Subject: [PATCH 222/350] fix model blendpatches we already have a functional check in HWR_GetBlendedTexture anyways --- src/hardware/hw_md2.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index d50a30354..de78808e6 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1330,9 +1330,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) if (gpatch && hwrPatch && hwrPatch->mipmap->format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture { - if ((skincolors_t)spr->mobj->color != SKINCOLOR_NONE && - blendgpatch && (hwrBlendPatch->mipmap->format - && gpatch->width == (blendgpatch->width && gpatch->height == (blendgpatch->height)))) + if ((skincolors_t)spr->mobj->color != SKINCOLOR_NONE) { INT32 tcskinnum = TC_DEFAULT; if ((spr->mobj->flags & MF_BOSS) && (spr->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash" From 962b68c5c3e13d75f748717dd7d61912daea313b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 02:46:40 +0200 Subject: [PATCH 223/350] smol opitmizations and cleanup --- src/hardware/hw_cache.c | 13 +++++------ src/r_data.c | 51 +++++++++++++++++++++-------------------- src/r_plane.c | 6 ++--- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index afba914a3..545be088d 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -378,13 +378,10 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe // Composite the columns together. for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { - pdata = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + pdata = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_LEVEL); realpatch = (softwarepatch_t *)pdata; - if (realpatch != NULL) - { - HWR_DrawTexturePatchInCache(&gltex->mipmap, blockwidth, blockheight, texture, patch, realpatch); - } + HWR_DrawTexturePatchInCache(&gltex->mipmap, blockwidth, blockheight, texture, patch, realpatch); } //Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :( @@ -863,9 +860,9 @@ void HWR_LoadMapTextures(size_t pnumtextures) gl_numtextures = pnumtextures; #ifdef GLENCORE - gl_textures = calloc(pnumtextures, sizeof (*gl_textures)*2); // *2 - 1 for encore-remapped texture and another for noencore texture (unused when not in encore) + gl_textures = calloc(gl_numtextures, sizeof (*gl_textures)*2); // *2 - 1 for encore-remapped texture and another for noencore texture (unused when not in encore) #else - gl_textures = calloc(pnumtextures, sizeof (*gl_textures)); + gl_textures = calloc(gl_numtextures, sizeof (*gl_textures)); #endif if (gl_textures == NULL) I_Error("HWR_LoadMapTextures: ran out of memory for OpenGL textures. Sad!"); @@ -1121,6 +1118,7 @@ void HWR_UnlockCachedPatch(GLPatch_t *glPatch) patch_t *HWR_GetCachedGLPatchPwad(UINT16 wadnum, UINT16 lumpnum) { lumpcache_t *lumpcache = wadfiles[wadnum]->patchcache; + if (!lumpcache[lumpnum]) { void *ptr = Z_Calloc(sizeof(patch_t), PU_PATCH, &lumpcache[lumpnum]); @@ -1393,6 +1391,7 @@ UINT32 HWR_CreateLightTable(UINT8 *lighttable) UINT32 HWR_GetLightTableID(extracolormap_t *colormap) { boolean default_colormap = false; + if (!colormap) { colormap = &extra_colormaps[num_extra_colormaps]; // a place to store the hw lighttable id diff --git a/src/r_data.c b/src/r_data.c index 015cc626f..2a2a0bd1d 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -329,29 +329,31 @@ static UINT8 *R_GenerateTexture(size_t texnum) // Check the patch for holes. if (texture->width > SHORT(realpatch->width) || texture->height > SHORT(realpatch->height)) holey = true; - - colofs = (UINT8 *)realpatch->columnofs; - - for (x = 0; x < texture->width && !holey; x++) + else { - column_t *col = (column_t *)((UINT8 *)realpatch + LONG(*(UINT32 *)&colofs[x<<2])); + colofs = (UINT8 *)realpatch->columnofs; - INT32 topdelta, prevdelta = -1, y = 0; - - while (col->topdelta != 0xff) + for (x = 0; x < texture->width; x++) { - topdelta = col->topdelta; - if (topdelta <= prevdelta) - topdelta += prevdelta; - prevdelta = topdelta; - if (topdelta > y) - break; - y = topdelta + col->length + 1; - col = (column_t *)((UINT8 *)col + col->length + 4); - } + column_t *col = (column_t *)((UINT8 *)realpatch + LONG(*(UINT32 *)&colofs[x<<2])); - if (y < texture->height) - holey = true; // this texture is HOLEy! D: + INT32 topdelta, prevdelta = -1, y = 0; + + while (col->topdelta != 0xff) + { + topdelta = col->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + if (topdelta > y) + break; + y = topdelta + col->length + 1; + col = (column_t *)((UINT8 *)col + col->length + 4); + } + + if (y < texture->height) + holey = true; // this texture is HOLEy! D: + } } // If the patch uses transparency, we have to save it this way. @@ -359,8 +361,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) { texture->holes = true; blocksize = W_LumpLengthPwad(patch->wad, patch->lump); - block = Z_Calloc(blocksize, PU_LEVEL, // will change tag at end of this function - &texturecache[texnum]); + block = Z_Calloc(blocksize, PU_LEVEL, &texturecache[texnum]); M_Memcpy(block, realpatch, blocksize); texturememory += blocksize; @@ -368,8 +369,12 @@ static UINT8 *R_GenerateTexture(size_t texnum) colofs = (block + 8); texturecolumnofs[texnum] = (UINT32 *)colofs; blocktex = block; + for (x = 0; x < texture->width; x++) + { *(UINT32 *)&colofs[x<<2] = LONG(LONG(*(UINT32 *)&colofs[x<<2]) + 3); + } + goto done; } @@ -397,10 +402,6 @@ static UINT8 *R_GenerateTexture(size_t texnum) pdata = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_LEVEL); realpatch = (softwarepatch_t *)pdata; - // Well, it's not valid... - if (realpatch == NULL) - continue; - x1 = patch->originx; width = SHORT(realpatch->width); height = SHORT(realpatch->height); diff --git a/src/r_plane.c b/src/r_plane.c index 807baca5c..aaf8d519b 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -128,7 +128,7 @@ static void R_CalculatePlaneRipple(visplane_t *plane, INT32 y, fixed_t plheight, { fixed_t distance = FixedMul(plheight, yslope[y]); const INT32 yay = (planeripple.offset + (distance>>9)) & 8191; - + // ripples da water texture ds_bgofs = FixedDiv(FINESINE(yay), (1<<12) + (distance>>11))>>FRACBITS; @@ -630,7 +630,7 @@ void R_DrawPlanes(void) R_DrawSinglePlane(pl); } } - + #ifndef NOWATER R_UpdatePlaneRipple(); #endif @@ -1050,7 +1050,7 @@ void R_DrawSinglePlane(visplane_t *pl) xoffs = (fixed_t)(xoffs*fudgecanyon); yoffs = (fixed_t)(yoffs/fudgecanyon); - + #ifndef NOWATER if (planeripple.active) { From 46e10f67b2353c5043eb8680ac6583ad07be438d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 16:21:13 +0200 Subject: [PATCH 224/350] more smol fixes --- src/hardware/hw_cache.c | 8 ++++---- src/p_setup.c | 4 ++-- src/r_data.c | 20 ++++++++++++-------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 545be088d..ae9436ac0 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -991,7 +991,7 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap) if (!glMipmap->downloaded && !glMipmap->data) HWR_CacheFlat(glMipmap, flatlumpnum); - // If hardware does not have the texture, then call pfnSetTexture to upload it + // If hardware does not have the texture, then call GL_SetTexture to upload it if (!glMipmap->downloaded) GL_SetTexture(glMipmap); HWR_SetCurrentTexture(glMipmap); @@ -1010,7 +1010,7 @@ static void HWR_LoadPatchMipmap(patch_t *patch, GLMipmap_t *glMipmap) if (!glMipmap->downloaded && !glMipmap->data) HWR_MakePatch(patch, glPatch, glMipmap, true); - // If hardware does not have the texture, then call pfnSetTexture to upload it + // If hardware does not have the texture, then call GL_SetTexture to upload it if (!glMipmap->downloaded) GL_SetTexture(glMipmap); HWR_SetCurrentTexture(glMipmap); @@ -1027,8 +1027,8 @@ static void HWR_UpdatePatchMipmap(patch_t *patch, GLMipmap_t *glMipmap) GLPatch_t *grPatch = patch->hardware; HWR_MakePatch(patch, grPatch, glMipmap, true); - // If hardware does not have the texture, then call pfnSetTexture to upload it - // If it does have the texture, then call pfnUpdateTexture to update it + // If hardware does not have the texture, then call GL_SetTexture to upload it + // If it does have the texture, then call GL_UpdateTexture to update it if (!glMipmap->downloaded) GL_SetTexture(glMipmap); else diff --git a/src/p_setup.c b/src/p_setup.c index a984121aa..d1657a153 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3350,13 +3350,13 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) // search for sprite replacements // Patch_FreeTag(PU_SPRITE); - Patch_FreeTag(PU_PATCH_ROTATED); + //Patch_FreeTag(PU_PATCH_ROTATED); R_AddSpriteDefs(wadnum); // Reload it all anyway, just in case they // added some textures but didn't insert a // TEXTURES/etc. list. - R_LoadTexturesPwad(wadnum); + //R_LoadTexturesPwad(wadnum); // everything from MultiSetupWadFile until ST_Start was here originally diff --git a/src/r_data.c b/src/r_data.c index 2a2a0bd1d..b01b12ba5 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -541,7 +541,7 @@ void R_LoadTextures(void) // but the alternative is to spend a ton of time checking and re-checking all previous entries just to skip any potentially patched textures. for (w = 0, numtextures = 0; w < numwadfiles; w++) { - if (wadfiles[w]->type == RET_PK3) + if (W_FileHasFolders(wadfiles[w])) { texstart = W_CheckNumForFolderStartPK3("textures/", (UINT16)w, 0); texend = W_CheckNumForFolderEndPK3("textures/", (UINT16)w, texstart); @@ -605,7 +605,7 @@ void R_LoadTextures(void) for (i = 0, w = 0; w < numwadfiles; w++) { // Get the lump numbers for the markers in the WAD, if they exist. - if (wadfiles[w]->type == RET_PK3) + if (W_FileHasFolders(wadfiles[w])) { texstart = W_CheckNumForFolderStartPK3("textures/", (UINT16)w, 0); texend = W_CheckNumForFolderEndPK3("textures/", (UINT16)w, texstart); @@ -618,7 +618,7 @@ void R_LoadTextures(void) } else { - texstart = W_CheckNumForNamePwad(TX_START, (UINT16)w, 0) + 1; + texstart = W_CheckNumForMarkerStartPwad(TX_START, (UINT16)w, 0); texend = W_CheckNumForNamePwad(TX_END, (UINT16)w, 0); texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0); if (texturesLumpPos != INT16_MAX) @@ -631,20 +631,22 @@ void R_LoadTextures(void) // Work through each lump between the markers in the WAD. for (j = 0; j < (texend - texstart); j++) { + UINT16 wadnum = (UINT16)w; + lumpnum_t lumpnum = texstart + j; + if (W_FileHasFolders(wadfiles[w])) { - if (W_IsLumpFolder(w, texstart + j)) // Check if lump is a folder + if (W_IsLumpFolder(wadnum, lumpnum)) // Check if lump is a folder continue; // If it is then SKIP IT } - patchlump = W_CacheLumpNumPwad((UINT16)w, texstart + j, PU_CACHE); patchlump = (softwarepatch_t *)W_CacheLumpNumPwad(wadnum, lumpnum, PU_STATIC); - //CONS_Printf("\n\"%s\" is a single patch, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),patchlump->width, patchlump->height); + //CONS_Printf("\n\"%s\" is a single patch, dimensions %d x %d",W_CheckNameForNumPwad(wadnum, lumpnum), patchlump->width, patchlump->height); texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL); // Set texture properties. - M_Memcpy(texture->name, W_CheckNameForNumPwad((UINT16)w, texstart + j), sizeof(texture->name)); + M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name)); texture->width = SHORT(patchlump->width); texture->height = SHORT(patchlump->height); texture->patchcount = 1; @@ -654,9 +656,11 @@ void R_LoadTextures(void) patch = &texture->patches[0]; patch->originx = patch->originy = 0; - patch->wad = (UINT16)w; + patch->wad = wadnum; patch->lump = texstart + j; + Z_Free(patchlump); + k = 1; while (k << 1 <= texture->width) k <<= 1; From 2c8d5f2625970a6569285a33c6fdcc485002335f Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 16:25:58 +0200 Subject: [PATCH 225/350] dont clear all our textures if we dont intend to reload em the multipart addfile stuff is awkward asf --- src/p_setup.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index d1657a153..6e8ea237c 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3340,12 +3340,6 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) if (!devparm && digmreplaces) CONS_Printf(M_GetText("%s digital musics replaced\n"), sizeu1(digmreplaces)); -#ifdef HWRENDER - // Free GPU textures before freeing patches. - if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED)) - HWR_ClearAllTextures(); -#endif - // // search for sprite replacements // @@ -3482,6 +3476,11 @@ boolean P_MultiSetupWadFiles(boolean fullsetup) if (partadd_stage == 1) { +#ifdef HWRENDER + // Free GPU textures before freeing patches. + if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED)) + HWR_ClearAllTextures(); +#endif // Reload all textures, unconditionally for better or worse. R_LoadTextures(); From 8e6633d0bc7b1cf52d0121693798834bc9d678bf Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 16:36:41 +0200 Subject: [PATCH 226/350] fix the sprite shadows Zzz... --- src/hardware/hw_main.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 1ec415292..3e964db9e 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3324,6 +3324,9 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch) pslope_t *floorslope; fixed_t slopez; float offset = 0; + GLPatch_t *hwrpatch; + + hwrpatch = (GLPatch_t *)(gpatch->hardware); // technically this_scale gets multiplied and added to sprite y/x scale, but this thing needs it for some crap so ill just throw it in here again const boolean hires = (spr->mobj && spr->mobj->skin && K_GetMobjSkin(spr->mobj)->flags & SF_HIRES); @@ -3439,25 +3442,25 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch) if (spr->flip) { - swallVerts[0].s = swallVerts[3].s = gpatch->max_s; + swallVerts[0].s = swallVerts[3].s = hwrpatch->max_s; swallVerts[2].s = swallVerts[1].s = 0; } else { swallVerts[0].s = swallVerts[3].s = 0; - swallVerts[2].s = swallVerts[1].s = gpatch->max_s; + swallVerts[2].s = swallVerts[1].s = hwrpatch->max_s; } // flip the texture coords (look familiar?) if (spr->vflip) { - swallVerts[3].t = swallVerts[2].t = gpatch->max_t; + swallVerts[3].t = swallVerts[2].t = hwrpatch->max_t; swallVerts[0].t = swallVerts[1].t = 0; } else { swallVerts[3].t = swallVerts[2].t = 0; - swallVerts[0].t = swallVerts[1].t = gpatch->max_t; + swallVerts[0].t = swallVerts[1].t = hwrpatch->max_t; } sSurf.PolyColor.s.red = 0x01; From a0062060eb59ad82fd38e558e05e38d4e915b24f Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 16:50:09 +0200 Subject: [PATCH 227/350] oop --- src/r_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index b01b12ba5..53f58de27 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -618,7 +618,7 @@ void R_LoadTextures(void) } else { - texstart = W_CheckNumForMarkerStartPwad(TX_START, (UINT16)w, 0); + texstart = W_CheckNumForNamePwad(TX_START, (UINT16)w, 0) + 1; texend = W_CheckNumForNamePwad(TX_END, (UINT16)w, 0); texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0); if (texturesLumpPos != INT16_MAX) From 88dc5f25adb5e987eae169e0aa63add7be6d2899 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 18:46:55 +0200 Subject: [PATCH 228/350] smol cleanup W_CachePatchNumPwad --- src/w_wad.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 2e7f2cee4..98ab1488a 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1738,7 +1738,6 @@ void *W_CacheLumpName(const char *name, INT32 tag) // Cache a patch into heap memory, convert the patch format as necessary // -// Software-only compile cache the data without conversion void *W_CacheSoftwarePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) { lumpcache_t *lumpcache = NULL; @@ -1784,14 +1783,11 @@ void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) #ifdef HWRENDER // Software-only compile cache the data without conversion - if (rendermode == render_soft || rendermode == render_none) + if (rendermode == render_opengl) + Patch_CreateGL(patch); #endif - return (void *)patch; -#ifdef HWRENDER - Patch_CreateGL(patch); return (void *)patch; -#endif } void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag) From b28593dba7457ea34bba1958e57b042ed86ce40b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 19:22:28 +0200 Subject: [PATCH 229/350] turn rotcache into a lumpcache_t aswell no need for slow aatrees --- src/w_wad.c | 14 ++++++-------- src/w_wad.h | 4 +--- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 98ab1488a..5e2e2e94b 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -824,8 +824,7 @@ UINT16 W_InitFile(const char *filename, boolean local) Z_Calloc(numlumps * sizeof (*wadfile->patchcache), PU_STATIC, &wadfile->patchcache); #ifdef ROTSPRITE - // allocates rotsprite structures and store them in a tree - wadfile->rotcache = M_AATreeAlloc(AATREE_ZUSER); + Z_Calloc(numlumps * sizeof (*wadfile->rotcache), PU_STATIC, &wadfile->rotcache); #endif // @@ -1807,16 +1806,15 @@ void *W_GetCachedPatchNumPwad(UINT16 wad, UINT16 lump) // Caches a rotsprite for patch rotation. void *W_GetCachedRotPatchPwad(UINT16 wadnum, UINT16 lumpnum) { - aatree_t *rotcache = wadfiles[wadnum]->rotcache; - rotsprite_t *rspr; + lumpcache_t *rotcache = wadfiles[wadnum]->rotcache; - if (!(rspr = M_AATreeGet(rotcache, lumpnum))) + if (!rotcache[lumpnum]) { - rspr = RotatedPatch_Create(ROTANGLES); - M_AATreeSet(rotcache, lumpnum, rspr); + rotsprite_t *rspr = RotatedPatch_Create(ROTANGLES); + Z_SetUser(rspr, (void **)(&rotcache[lumpnum])); } - return (void *)rspr; + return (void *)(rotcache[lumpnum]); } #endif // ROTSPRITE diff --git a/src/w_wad.h b/src/w_wad.h index 79cad44e9..12ad8cea7 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -106,8 +106,6 @@ virtlump_t* vres_Find(const virtres_t*, const char*); #define lumpcache_t void * -#include "m_aatree.h" - // Resource type of the WAD. Yeah, I know this sounds dumb, but I'll leave it like this until I clean up the code further. typedef enum restype { @@ -127,7 +125,7 @@ typedef struct wadfile_s lumpcache_t *lumpcache; lumpcache_t *patchcache; #ifdef ROTSPRITE - aatree_t *rotcache; // Cache rotsprites for rotating patches. + lumpcache_t *rotcache; // Cache rotsprites for rotating patches. #endif UINT16 numlumps; // this wad's number of resources FILE *handle; From f4fc185f5b729951fdf9bd0cdcb7af8325528bec Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 20:25:56 +0200 Subject: [PATCH 230/350] move patch rotation stuff into their own files --- src/CMakeLists.txt | 4 +- src/Makefile | 1 + src/dehacked.c | 2 +- src/hardware/hw_cache.c | 2 +- src/hardware/hw_main.c | 7 +- src/k_kart.c | 4 + src/lua_hudlib.c | 4 + src/r_bsp.c | 5 +- src/r_patch.c | 254 +------------------------------------- src/r_patch.h | 16 +-- src/r_patchrotation.c | 262 ++++++++++++++++++++++++++++++++++++++++ src/r_patchrotation.h | 30 +++++ src/r_things.c | 34 +++--- src/sdl/Srb2SDL.dsp | 8 ++ src/w_wad.c | 3 +- 15 files changed, 347 insertions(+), 289 deletions(-) create mode 100644 src/r_patchrotation.c create mode 100644 src/r_patchrotation.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 121cb9925..729b5896a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -129,6 +129,7 @@ set(SRB2_CORE_RENDER_SOURCES r_fps.c r_main.c r_patch.c + r_patchrotation.c r_plane.c r_segs.c r_sky.c @@ -143,7 +144,8 @@ set(SRB2_CORE_RENDER_SOURCES r_fps.h r_local.h r_main.h - r_patch + r_patch.h + r_patchrotation.h r_plane.h r_segs.h r_sky.h diff --git a/src/Makefile b/src/Makefile index 9244c30fd..ebc2c683b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -552,6 +552,7 @@ OBJS:=$(i_main_o) \ $(OBJDIR)/r_sky.o \ $(OBJDIR)/r_splats.o \ $(OBJDIR)/r_patch.o \ + $(OBJDIR)/r_patchrotation.o \ $(OBJDIR)/r_things.o \ $(OBJDIR)/r_portal.o \ $(OBJDIR)/screen.o \ diff --git a/src/dehacked.c b/src/dehacked.c index fd90c380e..f0e2583d8 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -28,7 +28,7 @@ #include "p_local.h" // for var1 and var2, and some constants #include "p_setup.h" #include "r_data.h" -#include "r_patch.h" +#include "r_fps.h" #include "r_sky.h" #include "r_draw.h" // translation colormap consts (for lua) #include "fastcmp.h" diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index ae9436ac0..554c2297a 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -28,7 +28,7 @@ #include "../v_video.h" #include "../r_draw.h" #include "../r_main.h" -#include "../r_patch.h" // patch rotation +#include "../r_patch.h" #include "../p_setup.h" // levelflats #include "../p_spec.h" // anim_t #include "../r_sky.h" diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 3e964db9e..66809d19e 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -39,7 +39,6 @@ #include "../r_fps.h" #include "../r_local.h" #include "../r_main.h" // cv_fov -#include "../r_patch.h" // a mystery as to what this is for #include "../r_portal.h" #ifdef WALLSPLATS #include "../r_splats.h" @@ -56,7 +55,11 @@ #include "../w_wad.h" #include "../z_zone.h" -#include "../qs22j.h" // fast qsort +#ifdef ROTSPRITE +#include "../r_patchrotation.h" // a mystery as to what this is for +#endif + +#include "../qs22j.h" // fast qsort // ========================================================================== // Globals diff --git a/src/k_kart.c b/src/k_kart.c index 7fdd8351b..14677f18d 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -48,6 +48,10 @@ #include "hardware/hw_main.h" #endif +#ifdef ROTSPRITE +#include "r_patchrotation.h" +#endif + // Hud offset cvars #define IMPL_HUD_OFFSET_X(name)\ consvar_t cv_##name##_xoffset = {"hud_" #name "_xoffset", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index b2425ec0a..d6b6db5c3 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -30,6 +30,10 @@ #include "lua_hud.h" #include "lua_hook.h" +#ifdef ROTSPRITE +#include "r_patchrotation.h" +#endif + #define HUDONLY if (!hud_running) return luaL_error(L, "HUD rendering code should not be called outside of rendering hooks!"); boolean hud_running = false; diff --git a/src/r_bsp.c b/src/r_bsp.c index 278bafb82..6ef40b0e6 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -13,12 +13,13 @@ #include "doomdef.h" #include "g_game.h" + +#include "r_fps.h" #include "r_local.h" #include "r_state.h" #include "r_portal.h" // Add seg portals - - #include "r_splats.h" + #include "p_local.h" // camera #include "p_slopes.h" #include "z_zone.h" // Check R_Prep3DFloors diff --git a/src/r_patch.c b/src/r_patch.c index e35563fe6..209b7e017 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -13,12 +13,7 @@ /// \brief Patch generation. #include "byteptr.h" -#include "dehacked.h" #include "doomdef.h" -#include "i_video.h" -#include "r_data.h" -#include "r_draw.h" -#include "r_fps.h" #include "r_patch.h" #include "r_things.h" #include "z_zone.h" @@ -462,7 +457,7 @@ void *Patch_CreateGL(patch_t *patch) // Convert a masked flat to a patch. // Explanation of "masked" flats in R_PatchToMaskedFlat. // -static void *R_MaskedFlatToPatch(UINT16 *raw, INT16 width, INT16 height, INT16 leftoffset, INT16 topoffset, size_t *destsize) +void *R_MaskedFlatToPatch(UINT16 *raw, INT16 width, INT16 height, INT16 leftoffset, INT16 topoffset, size_t *destsize) { INT16 x, y; UINT8 *img; @@ -577,7 +572,7 @@ static void *R_MaskedFlatToPatch(UINT16 *raw, INT16 width, INT16 height, INT16 l return converted; } -static UINT16 GetPatchPixel(patch_t *patch, INT32 x, INT32 y, boolean flip) +UINT16 R_GetPatchPixel(patch_t *patch, INT32 x, INT32 y, boolean flip) { fixed_t ofs; column_t *column; @@ -619,248 +614,3 @@ static UINT16 GetPatchPixel(patch_t *patch, INT32 x, INT32 y, boolean flip) return 0xFF00; } - -#ifdef ROTSPRITE -// -// R_GetRollAngle -// -// Angles precalculated in R_InitSprites. -// -fixed_t rollcosang[ROTANGLES]; -fixed_t rollsinang[ROTANGLES]; - -INT32 R_GetRollAngle(angle_t rollangle) -{ - INT32 ra = AngleFixed(rollangle)>>FRACBITS; -#if (ROTANGDIFF > 1) - ra += (ROTANGDIFF/2); -#endif - ra /= ROTANGDIFF; - ra %= ROTANGLES; - return ra; -} - -angle_t R_RotationAngle(angle_t ang, angle_t camang, interpmobjstate_t *interp) -{ - return FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), interp->roll) + - FixedMul(FINESINE((ang) >> ANGLETOFINESHIFT), interp->pitch) + - FixedMul(FINECOSINE((camang) >> ANGLETOFINESHIFT), interp->sloperoll) + - FixedMul(FINESINE((camang) >> ANGLETOFINESHIFT), interp->slopepitch); -} - -patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, void *info, INT32 rotationangle) -{ - rotsprite_t *rotsprite; - spriteinfo_t *sprinfo = (spriteinfo_t *)info; - INT32 idx = rotationangle; - - if (rotationangle < 1 || rotationangle >= ROTANGLES) - return NULL; - - rotsprite = sprite->rotated[spriteangle]; - - if (rotsprite == NULL) - { - rotsprite = RotatedPatch_Create(ROTANGLES); - sprite->rotated[spriteangle] = rotsprite; - } - - if (flip) - idx += rotsprite->angles; - - if (rotsprite->patches[idx] == NULL) - { - patch_t *patch; - INT32 xpivot = 0, ypivot = 0; - lumpnum_t lump = sprite->lumppat[spriteangle]; - - if (lump == LUMPERROR) - return NULL; - - patch = W_CachePatchNum(lump, PU_SPRITE); - - if (sprinfo->available) - { - xpivot = sprinfo->pivot[frame].x; - ypivot = sprinfo->pivot[frame].y; - } - else - { - xpivot = patch->leftoffset; - ypivot = patch->height / 2; - } - - RotatedPatch_DoRotation(rotsprite, patch, rotationangle, xpivot, ypivot, flip); - } - - return rotsprite->patches[idx]; -} - -rotsprite_t *RotatedPatch_Create(INT32 numangles) -{ - rotsprite_t *rotsprite = Z_Calloc(sizeof(rotsprite_t), PU_STATIC, NULL); - rotsprite->angles = numangles; - rotsprite->patches = Z_Calloc(rotsprite->angles * 2 * sizeof(void *), PU_STATIC, NULL); - return rotsprite; -} - -static void RotatedPatch_CalculateDimensions( - INT32 width, INT32 height, - fixed_t ca, fixed_t sa, - INT32 *newwidth, INT32 *newheight) -{ - fixed_t fixedwidth = (width * FRACUNIT); - fixed_t fixedheight = (height * FRACUNIT); - - fixed_t w1 = abs(FixedMul(fixedwidth, ca) - FixedMul(fixedheight, sa)); - fixed_t w2 = abs(FixedMul(-fixedwidth, ca) - FixedMul(fixedheight, sa)); - fixed_t h1 = abs(FixedMul(fixedwidth, sa) + FixedMul(fixedheight, ca)); - fixed_t h2 = abs(FixedMul(-fixedwidth, sa) + FixedMul(fixedheight, ca)); - - w1 = FixedInt(FixedCeil(w1 + (FRACUNIT/2))); - w2 = FixedInt(FixedCeil(w2 + (FRACUNIT/2))); - h1 = FixedInt(FixedCeil(h1 + (FRACUNIT/2))); - h2 = FixedInt(FixedCeil(h2 + (FRACUNIT/2))); - - *newwidth = max(width, max(w1, w2)); - *newheight = max(height, max(h1, h2)); -} - -void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip) -{ - UINT32 i; - patch_t *rotated; - - UINT16 *rawdst, *rawconv; - size_t size; - INT32 bflip = (flip != 0x00); - - INT32 width = patch->width; - INT32 height = patch->height; - INT32 leftoffset = patch->leftoffset; - INT32 newwidth, newheight; - - fixed_t ca = rollcosang[angle]; - fixed_t sa = rollsinang[angle]; - fixed_t xcenter, ycenter; - INT32 idx = angle; - INT32 x, y; - INT32 sx, sy; - INT32 dx, dy; - INT32 ox, oy; - INT32 minx, miny, maxx, maxy; - - // Don't cache angle = 0 - if (angle < 1 || angle >= ROTANGLES) - return; - - if (flip) - { - idx += rotsprite->angles; - xpivot = width - xpivot; - leftoffset = width - leftoffset; - } - - if (rotsprite->patches[idx]) - return; - - // Find the dimensions of the rotated patch. - RotatedPatch_CalculateDimensions(width, height, ca, sa, &newwidth, &newheight); - - xcenter = (xpivot * FRACUNIT); - ycenter = (ypivot * FRACUNIT); - - if (xpivot != width / 2 || ypivot != height / 2) - { - newwidth *= 2; - newheight *= 2; - } - - minx = newwidth; - miny = newheight; - maxx = 0; - maxy = 0; - - // Draw the rotated sprite to a temporary buffer. - size = (newwidth * newheight); - if (!size) - size = (width * height); - rawdst = Z_Malloc(size * sizeof(UINT16), PU_STATIC, NULL); - - for (i = 0; i < size; i++) - rawdst[i] = 0xFF00; - - for (dy = 0; dy < newheight; dy++) - { - for (dx = 0; dx < newwidth; dx++) - { - x = (dx - (newwidth / 2)) * FRACUNIT; - y = (dy - (newheight / 2)) * FRACUNIT; - sx = FixedMul(x, ca) + FixedMul(y, sa) + xcenter; - sy = -FixedMul(x, sa) + FixedMul(y, ca) + ycenter; - - sx >>= FRACBITS; - sy >>= FRACBITS; - - if (sx >= 0 && sy >= 0 && sx < width && sy < height) - { - rawdst[(dy * newwidth) + dx] = GetPatchPixel(patch, sx, sy, bflip); - - if (dx < minx) - minx = dx; - if (dy < miny) - miny = dy; - if (dx > maxx) - maxx = dx; - if (dy > maxy) - maxy = dy; - } - } - } - - ox = (newwidth / 2) + (leftoffset - xpivot); - oy = (newheight / 2) + (patch->topoffset - ypivot); - width = (maxx - minx); - height = (maxy - miny); - - if ((unsigned)(width * height) > size) - { - UINT16 *src, *dest; - - size = (width * height); - rawconv = Z_Calloc(size * sizeof(UINT16), PU_STATIC, NULL); - - src = &rawdst[(miny * newwidth) + minx]; - dest = rawconv; - dy = height; - - while (dy--) - { - M_Memcpy(dest, src, width * sizeof(UINT16)); - dest += width; - src += newwidth; - } - - ox -= minx; - oy -= miny; - - Z_Free(rawdst); - } - else - { - rawconv = rawdst; - width = newwidth; - height = newheight; - } - - // make patch - rotated = (patch_t *)R_MaskedFlatToPatch(rawconv, width, height, 0, 0, &size); - - Z_ChangeTag(rotated, PU_PATCH_ROTATED); - Z_SetUser(rotated, (void **)(&rotsprite->patches[idx])); - Z_Free(rawconv); - - rotated->leftoffset = ox; - rotated->topoffset = oy; -} -#endif diff --git a/src/r_patch.h b/src/r_patch.h index bde624ead..2978ff10c 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -15,8 +15,6 @@ #define __R_PATCH__ #include "r_defs.h" -#include "r_fps.h" -#include "doomdef.h" // Structs typedef enum @@ -58,17 +56,7 @@ extern spriteinfo_t spriteinfo[NUMSPRITES]; void R_LoadSpriteInfoLumps(UINT16 wadnum, UINT16 numlumps); void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum); -// Sprite rotation -#ifdef ROTSPRITE -INT32 R_GetRollAngle(angle_t rollangle); -angle_t R_RotationAngle(angle_t ang, angle_t camang, interpmobjstate_t *interp); - -patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, void *info, INT32 rotationangle); -rotsprite_t *RotatedPatch_Create(INT32 numangles); -void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip); - -extern fixed_t rollcosang[ROTANGLES]; -extern fixed_t rollsinang[ROTANGLES]; -#endif +void *R_MaskedFlatToPatch(UINT16 *raw, INT16 width, INT16 height, INT16 leftoffset, INT16 topoffset, size_t *destsize); +UINT16 R_GetPatchPixel(patch_t *patch, INT32 x, INT32 y, boolean flip); #endif // __R_PATCH__ diff --git a/src/r_patchrotation.c b/src/r_patchrotation.c new file mode 100644 index 000000000..3f1836ad1 --- /dev/null +++ b/src/r_patchrotation.c @@ -0,0 +1,262 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 2020-2023 by Lactozilla. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file r_patchrotation.c +/// \brief Patch rotation. + +#include "doomdef.h" +#include "r_fps.h" +#include "r_patch.h" +#include "r_patchrotation.h" +#include "z_zone.h" +#include "w_wad.h" + +#ifdef ROTSPRITE +// +// R_GetRollAngle +// +// Angles precalculated in R_InitSprites. +// +fixed_t rollcosang[ROTANGLES]; +fixed_t rollsinang[ROTANGLES]; + +INT32 R_GetRollAngle(angle_t rollangle) +{ + INT32 ra = AngleFixed(rollangle)>>FRACBITS; +#if (ROTANGDIFF > 1) + ra += (ROTANGDIFF/2); +#endif + ra /= ROTANGDIFF; + ra %= ROTANGLES; + return ra; +} + +angle_t R_RotationAngle(angle_t ang, angle_t camang, interpmobjstate_t *interp) +{ + return FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), interp->roll) + + FixedMul(FINESINE((ang) >> ANGLETOFINESHIFT), interp->pitch) + + FixedMul(FINECOSINE((camang) >> ANGLETOFINESHIFT), interp->sloperoll) + + FixedMul(FINESINE((camang) >> ANGLETOFINESHIFT), interp->slopepitch); +} + +patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, void *info, INT32 rotationangle) +{ + rotsprite_t *rotsprite; + spriteinfo_t *sprinfo = (spriteinfo_t *)info; + INT32 idx = rotationangle; + + if (rotationangle < 1 || rotationangle >= ROTANGLES) + return NULL; + + rotsprite = sprite->rotated[spriteangle]; + + if (rotsprite == NULL) + { + rotsprite = RotatedPatch_Create(ROTANGLES); + sprite->rotated[spriteangle] = rotsprite; + } + + if (flip) + idx += rotsprite->angles; + + if (rotsprite->patches[idx] == NULL) + { + patch_t *patch; + INT32 xpivot = 0, ypivot = 0; + lumpnum_t lump = sprite->lumppat[spriteangle]; + + if (lump == LUMPERROR) + return NULL; + + patch = W_CachePatchNum(lump, PU_SPRITE); + + if (sprinfo->available) + { + xpivot = sprinfo->pivot[frame].x; + ypivot = sprinfo->pivot[frame].y; + } + else + { + xpivot = patch->leftoffset; + ypivot = patch->height / 2; + } + + RotatedPatch_DoRotation(rotsprite, patch, rotationangle, xpivot, ypivot, flip); + } + + return rotsprite->patches[idx]; +} + +rotsprite_t *RotatedPatch_Create(INT32 numangles) +{ + rotsprite_t *rotsprite = Z_Calloc(sizeof(rotsprite_t), PU_STATIC, NULL); + rotsprite->angles = numangles; + rotsprite->patches = Z_Calloc(rotsprite->angles * 2 * sizeof(void *), PU_STATIC, NULL); + return rotsprite; +} + +static void RotatedPatch_CalculateDimensions( + INT32 width, INT32 height, + fixed_t ca, fixed_t sa, + INT32 *newwidth, INT32 *newheight) +{ + fixed_t fixedwidth = (width * FRACUNIT); + fixed_t fixedheight = (height * FRACUNIT); + + fixed_t w1 = abs(FixedMul(fixedwidth, ca) - FixedMul(fixedheight, sa)); + fixed_t w2 = abs(FixedMul(-fixedwidth, ca) - FixedMul(fixedheight, sa)); + fixed_t h1 = abs(FixedMul(fixedwidth, sa) + FixedMul(fixedheight, ca)); + fixed_t h2 = abs(FixedMul(-fixedwidth, sa) + FixedMul(fixedheight, ca)); + + w1 = FixedInt(FixedCeil(w1 + (FRACUNIT/2))); + w2 = FixedInt(FixedCeil(w2 + (FRACUNIT/2))); + h1 = FixedInt(FixedCeil(h1 + (FRACUNIT/2))); + h2 = FixedInt(FixedCeil(h2 + (FRACUNIT/2))); + + *newwidth = max(width, max(w1, w2)); + *newheight = max(height, max(h1, h2)); +} + +void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip) +{ + UINT32 i; + patch_t *rotated; + + UINT16 *rawdst, *rawconv; + size_t size; + INT32 bflip = (flip != 0x00); + + INT32 width = patch->width; + INT32 height = patch->height; + INT32 leftoffset = patch->leftoffset; + INT32 newwidth, newheight; + + fixed_t ca = rollcosang[angle]; + fixed_t sa = rollsinang[angle]; + fixed_t xcenter, ycenter; + INT32 idx = angle; + INT32 x, y; + INT32 sx, sy; + INT32 dx, dy; + INT32 ox, oy; + INT32 minx, miny, maxx, maxy; + + // Don't cache angle = 0 + if (angle < 1 || angle >= ROTANGLES) + return; + + if (flip) + { + idx += rotsprite->angles; + xpivot = width - xpivot; + leftoffset = width - leftoffset; + } + + if (rotsprite->patches[idx]) + return; + + // Find the dimensions of the rotated patch. + RotatedPatch_CalculateDimensions(width, height, ca, sa, &newwidth, &newheight); + + xcenter = (xpivot * FRACUNIT); + ycenter = (ypivot * FRACUNIT); + + if (xpivot != width / 2 || ypivot != height / 2) + { + newwidth *= 2; + newheight *= 2; + } + + minx = newwidth; + miny = newheight; + maxx = 0; + maxy = 0; + + // Draw the rotated sprite to a temporary buffer. + size = (newwidth * newheight); + if (!size) + size = (width * height); + rawdst = Z_Malloc(size * sizeof(UINT16), PU_STATIC, NULL); + + for (i = 0; i < size; i++) + rawdst[i] = 0xFF00; + + for (dy = 0; dy < newheight; dy++) + { + for (dx = 0; dx < newwidth; dx++) + { + x = (dx - (newwidth / 2)) * FRACUNIT; + y = (dy - (newheight / 2)) * FRACUNIT; + sx = FixedMul(x, ca) + FixedMul(y, sa) + xcenter; + sy = -FixedMul(x, sa) + FixedMul(y, ca) + ycenter; + + sx >>= FRACBITS; + sy >>= FRACBITS; + + if (sx >= 0 && sy >= 0 && sx < width && sy < height) + { + rawdst[(dy * newwidth) + dx] = R_GetPatchPixel(patch, sx, sy, bflip); + + if (dx < minx) + minx = dx; + if (dy < miny) + miny = dy; + if (dx > maxx) + maxx = dx; + if (dy > maxy) + maxy = dy; + } + } + } + + ox = (newwidth / 2) + (leftoffset - xpivot); + oy = (newheight / 2) + (patch->topoffset - ypivot); + width = (maxx - minx); + height = (maxy - miny); + + if ((unsigned)(width * height) > size) + { + UINT16 *src, *dest; + + size = (width * height); + rawconv = Z_Calloc(size * sizeof(UINT16), PU_STATIC, NULL); + + src = &rawdst[(miny * newwidth) + minx]; + dest = rawconv; + dy = height; + + while (dy--) + { + M_Memcpy(dest, src, width * sizeof(UINT16)); + dest += width; + src += newwidth; + } + + ox -= minx; + oy -= miny; + + Z_Free(rawdst); + } + else + { + rawconv = rawdst; + width = newwidth; + height = newheight; + } + + // make patch + rotated = (patch_t *)R_MaskedFlatToPatch(rawconv, width, height, 0, 0, &size); + + Z_ChangeTag(rotated, PU_PATCH_ROTATED); + Z_SetUser(rotated, (void **)(&rotsprite->patches[idx])); + Z_Free(rawconv); + + rotated->leftoffset = ox; + rotated->topoffset = oy; +} +#endif diff --git a/src/r_patchrotation.h b/src/r_patchrotation.h new file mode 100644 index 000000000..d387ae20f --- /dev/null +++ b/src/r_patchrotation.h @@ -0,0 +1,30 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 2020-2023 by Lactozilla. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file r_patchrotation.h +/// \brief Patch rotation. + +#ifndef __R_PATCHROTATION__ +#define __R_PATCHROTATION__ + +#include "r_fps.h" + +// Sprite rotation +#ifdef ROTSPRITE +INT32 R_GetRollAngle(angle_t rollangle); +angle_t R_RotationAngle(angle_t ang, angle_t camang, interpmobjstate_t *interp); + +rotsprite_t *RotatedPatch_Create(INT32 numangles); +void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip); +patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, void *info, INT32 rotationangle); + +extern fixed_t rollcosang[ROTANGLES]; +extern fixed_t rollsinang[ROTANGLES]; +#endif + +#endif // __R_PATCHROTATION__ diff --git a/src/r_things.c b/src/r_things.c index caa9085b9..4a24e0158 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -11,34 +11,38 @@ /// \file r_things.c /// \brief Refresh of things, i.e. objects represented by sprites -#include "doomdef.h" -#include "console.h" -#include "g_game.h" -#include "r_local.h" -#include "st_stuff.h" -#include "w_wad.h" -#include "z_zone.h" -#include "m_misc.h" -#include "i_video.h" // rendermode #include "r_main.h" // stplyr #include "r_fps.h" #include "r_things.h" -#include "r_patch.h" #include "r_plane.h" +#include "r_portal.h" +#include "r_local.h" + +#include "dehacked.h" // get_number (for thok) +#include "doomdef.h" +#include "d_netfil.h" // blargh. for nameonly(). +#include "console.h" +#include "g_game.h" +#include "k_kart.h" // SRB2kart #include "p_tick.h" #include "p_local.h" #include "p_setup.h" #include "p_slopes.h" -#include "dehacked.h" // get_number (for thok) -#include "d_netfil.h" // blargh. for nameonly(). +#include "st_stuff.h" #include "m_cheat.h" // objectplace -#include "r_portal.h" -#include "k_kart.h" // SRB2kart -#include "p_local.h" // stplyr +#include "m_misc.h" +#include "i_video.h" // rendermode +#include "w_wad.h" +#include "z_zone.h" + #ifdef HWRENDER #include "hardware/hw_md2.h" #endif +#ifdef ROTSPRITE +#include "r_patchrotation.h" +#endif + #include "qs22j.h" CV_PossibleValue_t Forceskin_cons_t[MAXSKINS+2]; diff --git a/src/sdl/Srb2SDL.dsp b/src/sdl/Srb2SDL.dsp index 35e5ec32b..67400625a 100644 --- a/src/sdl/Srb2SDL.dsp +++ b/src/sdl/Srb2SDL.dsp @@ -897,6 +897,14 @@ SOURCE=..\r_patch.h # End Source File # Begin Source File +SOURCE=..\r_patchrotation.c +# End Source File +# Begin Source File + +SOURCE=..\r_patchrotation.h +# End Source File +# Begin Source File + SOURCE=..\r_plane.c # End Source File # Begin Source File diff --git a/src/w_wad.c b/src/w_wad.c index 5e2e2e94b..292101750 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -58,6 +58,7 @@ #include "dehacked.h" #include "d_clisrv.h" #include "r_defs.h" +#include "r_patch.h" #include "i_system.h" #include "md5.h" #include "lua_script.h" @@ -72,7 +73,7 @@ #endif #ifdef ROTSPRITE -#include "r_patch.h" // RotatedPatch_Create +#include "r_patchrotation.h" // RotatedPatch_Create #endif #ifndef O_BINARY From 8ec6b2e737ca4c98ea17619e677835eb2c0215ee Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 20:27:53 +0200 Subject: [PATCH 231/350] fix compile without ROTSPRITE --- src/k_kart.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/k_kart.c b/src/k_kart.c index 14677f18d..e1127f05c 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9643,7 +9643,9 @@ static void K_drawKartSpeedometer(void) // index 0 is the raw value, index 1 is the converted value fixed_t convSpeed[2] = {0,0}; +#ifdef ROTSPRITE fixed_t dial_divisor = DIALSPDDIV; +#endif INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); @@ -9659,12 +9661,16 @@ static void K_drawKartSpeedometer(void) case 2: convSpeed[0] = FixedDiv(FixedMul(stplyr->speed, 88465), mapobjectscale); // 1.349868774 convSpeed[1] = convSpeed[0] / FRACUNIT; +#ifdef ROTSPRITE dial_divisor = MPHDIV; +#endif break; case 3: convSpeed[0] = FixedDiv(stplyr->speed, mapobjectscale); convSpeed[1] = convSpeed[0] / FRACUNIT; +#ifdef ROTSPRITE dial_divisor = MPHDIV; +#endif break; case 4: if (stplyr->mo) From 7bd835f43e6622c6ef51a52b501c8ab3dec7fdd4 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 22:04:27 +0200 Subject: [PATCH 232/350] fix minimap disappearing when having minimap trans on 10 --- src/k_kart.c | 9 ++++++--- src/lua_hudlib.c | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 1d2bde533..44cee66a6 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8364,17 +8364,20 @@ INT32 K_getMinimapTrans(void) INT32 minimaptrans = cv_kartminimap.value; if (!minimaptrans) - return 0; + return -1; if (forceshowhud) return (10-minimaptrans)< Date: Wed, 16 Apr 2025 22:02:44 +0200 Subject: [PATCH 233/350] add support for drawing a dot on the minimap showing player angle mostly copy pasted from blankart so thx neppy c: --- src/d_main.c | 6 ++++ src/d_main.h | 1 + src/d_netcmd.h | 3 +- src/k_kart.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++-- src/r_fps.c | 4 +-- src/r_fps.h | 2 +- 6 files changed, 98 insertions(+), 7 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 39f354ba5..ad65138e8 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1221,6 +1221,7 @@ boolean nametaggfx = false; // Nametag stuffs boolean driftgaugegfx = false; // Driftgauge stuffs boolean multiitem_icon = false; // Extra icons for Sneakers, Banana and Jawz boolean joystickicon = false; // Extra icons for the joystick input display +boolean minidoticon = false; // Dot graphic for minimap player angle display // static void IdentifyVersion(void) @@ -1433,6 +1434,11 @@ static void D_CheckSaturnExtraFiles(void) joystickicon = true; PUSHCONS(inputdisplay_cons_temp, last_inputdisplay_i, 3, "StickGFX"); } + + if (W_LumpExists("MMAPDOT")) + { + minidoticon = true; + } } // now check for colour hud stuff diff --git a/src/d_main.h b/src/d_main.h index 41ccce20f..f8e5b0b41 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -52,6 +52,7 @@ extern boolean nametaggfx; // Nametag stuffs extern boolean driftgaugegfx; // Driftgauge stuffs extern boolean multiitem_icon; // Extra icons for Sneakers, Banana and Jawz extern boolean joystickicon; // Extra icons for the joystick input display +extern boolean minidoticon; // Dot icon for minimap player angle display // // autoload stuff diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 4ec6f43ba..b4ee22d93 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -149,8 +149,9 @@ extern consvar_t cv_pingstyle; //extern consvar_t cv_smallpos; extern consvar_t cv_showminimapnames; extern consvar_t cv_minihead; +extern consvar_t cv_showminimapangle; -extern consvar_t cv_showlapemblem; +extern consvar_t cv_showlapemblem; extern consvar_t cv_showviewpointtext; extern consvar_t cv_showdownloadprompt; diff --git a/src/k_kart.c b/src/k_kart.c index 44cee66a6..0949f0a15 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -102,6 +102,7 @@ consvar_t cv_fancyroulette = {"animatedroulette", "Off", CV_SAVE, CV_OnOff, NULL consvar_t cv_minihead = {"smallminimapplayers", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showminimapnames = {"showminimapnames", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showminimapangle = {"showminimapangle", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_highresportrait = {"highresportrait", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // make char potraits use their high-res version instead @@ -952,6 +953,8 @@ void K_RegisterClientKartStuff(void) CV_RegisterVar(&cv_minihead); CV_RegisterVar(&cv_showminimapnames); + CV_RegisterVar(&cv_showminimapangle); + CV_RegisterVar(&cv_showlapemblem); CV_RegisterVar(&cv_stagetitle); @@ -7614,6 +7617,8 @@ static patch_t *joybacking; static patch_t *joyknob; static patch_t *joyshadow; +static patch_t *kp_minimapdot; + void K_LoadKartHUDGraphics(void) { INT32 i, j; @@ -7887,6 +7892,9 @@ void K_LoadKartHUDGraphics(void) kp_wantedsplit = W_CachePatchName("4PWANTED", PU_HUDGFX); kp_wantedreticle = W_CachePatchName("MMAPWANT", PU_HUDGFX); + if (minidoticon) + kp_minimapdot = W_CachePatchName("MMAPDOT", PU_HUDGFX); + // Kart Item Windows kp_itembg[0] = W_CachePatchName("K_ITBG", PU_HUDGFX); kp_itembg[1] = W_CachePatchName("K_ITBGD", PU_HUDGFX); @@ -10530,6 +10538,46 @@ static void K_drawKartPlayerCheck(void) } } +static void K_drawKartMinimapIcon(fixed_t objx, fixed_t objy, INT32 hudx, INT32 hudy, INT32 flags, patch_t *icon, UINT8 *colormap) +{ + // amnum xpos & ypos are the icon's speed around the HUD. + // The number being divided by is for how fast it moves. + // The higher the number, the slower it moves. + + // am xpos & ypos are the icon's starting position. Withouht + // it, they wouldn't 'spawn' on the top-right side of the HUD. + + fixed_t amnumxpos, amnumypos; + INT32 amxpos, amypos; + fixed_t scale = FRACUNIT; + patch_t *AutomapPic; + + AutomapPic = minimapinfo.minimap_pic; + + if (AutomapPic == NULL) + { + return; // no pic, just get outta here + } + + amnumxpos = (FixedMul(objx, minimapinfo.zoom) - minimapinfo.offs_x); + amnumypos = -(FixedMul(objy, minimapinfo.zoom) - minimapinfo.offs_y); + + if (encoremode) + amnumxpos = -amnumxpos; + + amxpos = amnumxpos + ((hudx + (AutomapPic->width-icon->width)/2)<height-icon->height)/2)<width / 4)<height / 4)<health <= 0 && players[localplayers[i]].pflags & PF_TIMEOVER) + continue; + + UINT8 *colormap; + fixed_t interpx, interpy; + + angle_t ang = R_InterpolateAngle(mobj->old_angle, mobj->angle); + + if (mobj->colorized) + colormap = R_GetTranslationColormap(TC_RAINBOW, mobj->color, GTC_CACHE); + else + colormap = R_GetLocalTranslationColormap(mobj->skin, mobj->localskin, mobj->color, GTC_CACHE, mobj->skinlocal); + + interpx = lerp(mobj->old_x, mobj->x); + interpy = lerp(mobj->old_y, mobj->y); + + K_drawKartMinimapIcon( + interpx, + interpy, + x + FixedMul(FCOS(ang), icondotradius), + y - FixedMul(FSIN(ang), icondotradius), + splitflags, + kp_minimapdot, + colormap + ); } } +#undef lerp + static void K_drawKartStartCountdown(void) { INT32 pnum = 0, splitflags = K_calcSplitFlags(0); // 3 diff --git a/src/r_fps.c b/src/r_fps.c index 3d10449cc..9827a65f2 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -278,7 +278,7 @@ void R_SetViewContext(enum viewcontext_e _viewcontext) } return (R_LerpFixed(from, to, rendertimefrac)); -} +}*/ angle_t R_InterpolateAngle(angle_t from, angle_t to) { @@ -288,7 +288,7 @@ angle_t R_InterpolateAngle(angle_t from, angle_t to) } return (R_LerpAngle(from, to, rendertimefrac)); -}*/ +} void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) { diff --git a/src/r_fps.h b/src/r_fps.h index 563989fa6..006f80b67 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -134,7 +134,7 @@ void R_RelativeTeleportViewInterpolation(UINT8 p, fixed_t xdiff, fixed_t ydiff, // Set the current view context (the viewvars pointed to by newview) void R_SetViewContext(enum viewcontext_e _viewcontext); -fixed_t R_InterpolateFixed(fixed_t from, fixed_t to); +//fixed_t R_InterpolateFixed(fixed_t from, fixed_t to); angle_t R_InterpolateAngle(angle_t from, angle_t to); // Evaluate the interpolated mobj state for the given mobj From 1da62eb63d0d1510b33fac532c87e9e85964f443 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 22:31:08 +0200 Subject: [PATCH 234/350] add minimap icon dot to saturn hud menu --- src/m_menu.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 872d9a665..199b47d7b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2433,15 +2433,16 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 135}, {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 140}, {IT_STRING | IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 150}, + {IT_STRING | IT_CVAR, NULL, "Player Angle Dot", &cv_showminimapangle, 160}, - {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 160}, + {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 170}, - {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 170}, + {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 180}, - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 180}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 185}, + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 190}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 195}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 195}, + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 205}, }; static const char* OP_SaturnHudTooltips[] = @@ -2466,6 +2467,7 @@ static const char* OP_SaturnHudTooltips[] = "Show player names on the minimap.", "Minimize the player icons on the minimap.", "Erratically rotate player icons during spinouts.", + "Show a dot showing the player facing angle.", "Make the Intermission screen look like in beta versions of Kart!\nEither with background or just the rest.", "Show the Director Toggle prompt when spectating.", "Nametag Options.", @@ -2495,6 +2497,7 @@ enum sh_mapname, sh_smallmap, sh_iconspinout, + sh_minidot, sh_betainter, sh_directorhud, sh_nametagmen, @@ -4946,6 +4949,9 @@ void M_Init(void) if (!nametaggfx) OP_NametagMenu[nt_ntchar].status = IT_GRAYEDOUT; + if (!minidoticon) + OP_SaturnHudMenu[sh_minidot].status = IT_GRAYEDOUT; + #ifndef NONET CV_RegisterVar(&cv_serversort); #endif From b207a87f8bdfd0ff3526a5a39378a811b924bca9 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 22:31:24 +0200 Subject: [PATCH 235/350] fix camera vertical look tooltip for green res Zzz... --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 199b47d7b..7a35a61b5 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2033,7 +2033,7 @@ static const char* OP_PlayerCamOptionsTooltips[] = "Height of the Camera", "Speed of the Camera", "Should looking back inherit the Players Momentum?\nEither inherit Player Momentum or double of it\nmay make looking back while boosting or going in high speed less jarring", - "Allows looking up/down by holding aim forward/backward while standing still.", + "Allows looking up/down by holding\naim forward/backward while standing still.", "Speed of the Freecam/Spectator Camera", "Toggle between Third or First Person camera", }; From 5401cb58bdfbbeedc148eea0922aab1801099350 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 22:33:21 +0200 Subject: [PATCH 236/350] SHORT ma balls need this for now --- src/k_kart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 0949f0a15..a871f74bc 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -10565,13 +10565,13 @@ static void K_drawKartMinimapIcon(fixed_t objx, fixed_t objy, INT32 hudx, INT32 if (encoremode) amnumxpos = -amnumxpos; - amxpos = amnumxpos + ((hudx + (AutomapPic->width-icon->width)/2)<height-icon->height)/2)<width)-SHORT(icon->width))/2)<height)-SHORT(icon->height))/2)<width / 4)<height / 4)<width) / 4)<height) / 4)< Date: Wed, 16 Apr 2025 22:37:22 +0200 Subject: [PATCH 237/350] why are these even seperated like that lel --- src/m_menu.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 397a850c9..6d54e44d8 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2432,17 +2432,17 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 135}, {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 140}, - {IT_STRING | IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 150}, - {IT_STRING | IT_CVAR, NULL, "Player Angle Dot", &cv_showminimapangle, 160}, + {IT_STRING | IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 145}, + {IT_STRING | IT_CVAR, NULL, "Player Angle Dot", &cv_showminimapangle, 150}, - {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 170}, + {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 160}, - {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 180}, + {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 170}, - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 190}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 195}, + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 180}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 185}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 205}, + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 195}, }; static const char* OP_SaturnHudTooltips[] = From 3b4ffa20bc0f461d9f15e7d17702a5aac5d3a7f1 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 23:21:33 +0200 Subject: [PATCH 238/350] why? --- src/w_wad.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 292101750..241693324 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1854,9 +1854,7 @@ void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag) rotsprite_t *rspr; INT32 idx = rotationangle; - const char *finalname = name; - - num = W_CheckNumForName(finalname); + num = W_CheckNumForName(name); if (num == LUMPERROR) num = W_GetNumForName("MISSING"); From 285c8506288dfad199b262dab3897c413b973d37 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 17 Apr 2025 13:30:41 +0200 Subject: [PATCH 239/350] fix automap colours forgor those revert those when i ported RR code over, now they should match up with what they say --- src/am_map.c | 13 +++++++------ src/m_misc.c | 1 - 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/am_map.c b/src/am_map.c index 3c10f710d..08d5bd0db 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -28,14 +28,15 @@ #endif // For use if I do walls with outsides/insides -static const UINT8 REDS = (2*16); +static const UINT8 REDS = (8*16); static const UINT8 REDRANGE = 16; static const UINT8 GRAYS = (1*16); static const UINT8 GRAYSRANGE = 16; -static const UINT8 BROWNS = (15*16); -static const UINT8 YELLOWS = (5*16)+8; -static const UINT8 GREENS = (6*16); -static const UINT8 BLUES = (9*16); +static const UINT8 BROWNS = (3*16); +static const UINT8 YELLOWS = (7*16); +static const UINT8 GREENS = (10*16); +//static const UINT8 CYANS = (13*16); +static const UINT8 BLUES = (14*16); static const UINT8 DBLACK = 31; static const UINT8 DWHITE = 0; @@ -46,7 +47,7 @@ static const UINT8 DWHITE = 0; #define THOKWALLCOLORS REDS #define THOKWALLRANGE REDRANGE #define TSWALLCOLORS DWHITE -#define TSFINISHLINE GRAYS +#define TSFINISHLINE (GREENS + 2) #define TSFOFINFO (BLUES + 4) #define FDWALLCOLORS BROWNS #define CDWALLCOLORS YELLOWS diff --git a/src/m_misc.c b/src/m_misc.c index c6dd4175c..ca4b745ed 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1668,7 +1668,6 @@ failure: #endif //#ifdef USE_PNG } - // ========================================================================== // TRANSLATION FUNCTIONS // ========================================================================== From bcf82970a4b8fbeadb546e7625741065e59624b6 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 17 Apr 2025 13:32:37 +0200 Subject: [PATCH 240/350] fix oopsie in automap bounds calc --- src/am_map.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/am_map.c b/src/am_map.c index 08d5bd0db..69f7e4f65 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -265,9 +265,6 @@ static void AM_findMinMaxBoundaries(void) max_w = minimapinfo.map_w << MAPBITS; max_h = minimapinfo.map_h << MAPBITS; - max_w = (max_x >>= FRACTOMAPBITS) - (min_x >>= FRACTOMAPBITS); - max_h = (max_y >>= FRACTOMAPBITS) - (min_y >>= FRACTOMAPBITS); - a = FixedDiv(f_w<next) { fixed_t rovt1, rovt2; fixed_t rovb1, rovb2; + if (!(rover->flags & FF_EXISTS)) continue; if (!(rover->flags & FF_BLOCKPLAYER)) continue; + SLOPEPARAMS(*rover->t_slope, rovt1, rovt2, *rover->topheight) SLOPEPARAMS(*rover->b_slope, rovb1, rovb2, *rover->bottomheight) + for (secondaryrover = secondarystore; secondaryrover; secondaryrover = secondaryrover->next) { fixed_t sect1, sect2; fixed_t secb1, secb2; + if (!(secondaryrover->flags & FF_EXISTS)) continue; if (!(secondaryrover->flags & FF_BLOCKPLAYER)) continue; if (secondaryrover->secnum == rover->secnum) break; + SLOPEPARAMS(*secondaryrover->t_slope, sect1, sect2, *secondaryrover->topheight) SLOPEPARAMS(*secondaryrover->b_slope, secb1, secb2, *secondaryrover->bottomheight) + if (rovt1 != sect1) continue; if (rovt2 != sect2) @@ -984,8 +989,10 @@ static void AM_drawWalls(UINT8 pass) } continue; } + SLOPEPARAMS(lines[i].backsector->f_slope, backf1, backf2, lines[i].backsector->floorheight) SLOPEPARAMS(lines[i].backsector->c_slope, backc1, backc2, lines[i].backsector->ceilingheight) + if ((backf1 == backc1 && backf2 == backc2) // Back is thok barrier || (frontf1 == frontc1 && frontf2 == frontc2)) // Front is thok barrier { @@ -1221,16 +1228,19 @@ static inline void AM_drawCrosshair(UINT8 color) const fixed_t scale = 4<> FRACBITS; fl.a.y = FixedMul(cross_mark[i].a.y, scale) >> FRACBITS; fl.b.x = FixedMul(cross_mark[i].b.x, scale) >> FRACBITS; fl.b.y = FixedMul(cross_mark[i].b.y, scale) >> FRACBITS; + fl.a.x += f_x + (f_w / 2); fl.a.y += f_y + (f_h / 2); fl.b.x += f_x + (f_w / 2); fl.b.y += f_y + (f_h / 2); + AM_drawFline(&fl, color); } } From f7acf7c2d343681955d60d91728f9bbd8d8f8cc2 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 17 Apr 2025 13:48:24 +0200 Subject: [PATCH 241/350] fix up the automap again got the rest of stuff working in a horrible way automap aswell as minigen stuff looks good now --- src/am_map.c | 180 +++++++++++++++++++++++++++++++++++---------------- src/p_spec.c | 7 +- src/screen.c | 10 +-- 3 files changed, 135 insertions(+), 62 deletions(-) diff --git a/src/am_map.c b/src/am_map.c index 69f7e4f65..c8172837a 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -898,6 +898,38 @@ static void AM_drawGrid(INT32 color) } } +static INT32 GetDamage(INT32 special) +{ + switch (special) + { + case 1: // Damage (Generic) + return 1; + case 6: // Death Pit (Camera Tilt) + return 6; + case 7: // Death Pit (No Camera Tilt) + return 7; + case 8: // Instant Kill + return 8; + default: + return 0; + } +} + +static INT32 GetOffroad(INT32 special) +{ + switch (special) + { + case 2: // Offroad (Weak) + return 2; + case 3: // Offroad + return 3; + case 4: // Offroad (Strong) + return 4; + default: + return 0; + } +} + #define SLOPEPARAMS(slope, end1, end2, normalheight) \ if (slope) { \ end1 = (P_GetZAt(slope, lines[i].v1->x, lines[i].v1->y) + FRACUNIT/2) >> FRACBITS; \ @@ -945,8 +977,27 @@ static ffloor_t *AM_CompareFOFs(size_t i, ffloor_t *rover, ffloor_t *secondaryst continue; if (rovb2 != secb2) continue; + + // this is fucking horrible + INT32 damage1, damage2; + INT32 offroad1, offroad2; + INT32 special1, special2; + special1 = GETSECSPECIAL(sectors[rover->secnum].special, 1); + special2 = GETSECSPECIAL(sectors[secondaryrover->secnum].special, 1); + + damage1 = GetDamage(special1); + damage2 = GetDamage(special2); + offroad1 = GetOffroad(special1); + offroad2 = GetOffroad(special2); + + if (damage1 != damage2 + //|| sectors[rover->secnum].friction != sectors[secondaryrover->secnum].friction + || offroad1 != offroad2) + continue; + break; } + if (secondaryrover == NULL) break; } @@ -1011,29 +1062,28 @@ static void AM_drawWalls(UINT8 pass) } else { - //dont think kart even supports those idk? - /*if (lines[i].flags & (ML_IMPASSABLE|ML_BLOCKPLAYERS)) + if (lines[i].flags & ML_IMPASSIBLE) // (ML_IMPASSABLE|ML_BLOCKPLAYERS) { if (pass & PASS_SOLID) AM_drawMline(&l, TSWALLCOLORS); // Completely solid course boundary } - else if ((lines[i].flags & ML_MIDSOLID) + else if ((lines[i].flags & ML_EFFECT4) // ML_MIDSOLID && sides[lines->sidenum[0]].midtexture) { if (pass & PASS_SOLID) AM_drawMline(&l, TSWALLCOLORS); // solid midtexture, likely a course boundary - }*/ + } if ((backf1 != frontf1 && abs(backf1 - frontf1) > maxstep) || (backf2 != frontf2 && abs(backf2 - frontf2) > maxstep)) { if (pass & PASS_SOLID) AM_drawMline(&l, TSWALLCOLORS); // floor-wall, likely a course boundary } - /*else if (lines[i].special == 2001) // guh its a sector effect in kart idk how to make it work tbh lol + else if (GETSECSPECIAL(lines[i].frontsector->special, 4) == 10 || GETSECSPECIAL(lines[i].backsector->special, 4) == 10) { if (pass & PASS_SOLID) AM_drawMline(&l, TSFINISHLINE); // finish line - }*/ + } else if (backf1 != frontf1 || backf2 != frontf2) { if (pass & PASS_INTANGIBLE) @@ -1055,54 +1105,52 @@ static void AM_drawWalls(UINT8 pass) } else { - { - ffloor_t *rover = NULL; + ffloor_t *rover = NULL; - if (lines[i].frontsector->ffloors || lines[i].backsector->ffloors) + if (lines[i].frontsector->ffloors || lines[i].backsector->ffloors) + { + if (lines[i].backsector->ffloors == NULL) { - if (lines[i].backsector->ffloors == NULL) + // Check frontside for one solid + for (rover = lines[i].frontsector->ffloors; rover; rover = rover->next) { - // Check frontside for one solid - for (rover = lines[i].frontsector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS)) - continue; - if (!(rover->flags & FF_BLOCKPLAYER)) - continue; - break; - } - } - else if (lines[i].frontsector->ffloors == NULL) - { - // Check backside for one solid - for (rover = lines[i].backsector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS)) - continue; - if (!(rover->flags & FF_BLOCKPLAYER)) - continue; - break; - } - } - else - { - // Check to see if any secnums exist in one but not the other. - rover = AM_CompareFOFs(i, lines[i].frontsector->ffloors, lines[i].backsector->ffloors); - if (rover == NULL) - rover = AM_CompareFOFs(i, lines[i].backsector->ffloors, lines[i].frontsector->ffloors); + if (!(rover->flags & FF_EXISTS)) + continue; + if (!(rover->flags & FF_BLOCKPLAYER)) + continue; + break; } } - if (rover != NULL) + else if (lines[i].frontsector->ffloors == NULL) { - if (pass & PASS_FOF) - AM_drawMline(&l, TSFOFINFO); // a FOF is here but we don't know how to distinguish them yet + // Check backside for one solid + for (rover = lines[i].backsector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS)) + continue; + if (!(rover->flags & FF_BLOCKPLAYER)) + continue; + break; + } } - else if (!am_minigen) + else { - if (pass & PASS_INTANGIBLE) - AM_drawMline(&l, GRIDCOLORS); // likely low-relevance line + // Check to see if any secnums exist in one but not the other. + rover = AM_CompareFOFs(i, lines[i].frontsector->ffloors, lines[i].backsector->ffloors); + if (rover == NULL) + rover = AM_CompareFOFs(i, lines[i].backsector->ffloors, lines[i].frontsector->ffloors); } } + if (rover != NULL) + { + if (pass & PASS_FOF) + AM_drawMline(&l, TSFOFINFO); // a FOF is here but we don't know how to distinguish them yet + } + else if (!am_minigen) + { + if (pass & PASS_INTANGIBLE) + AM_drawMline(&l, GRIDCOLORS); // likely low-relevance line + } } } } @@ -1180,18 +1228,11 @@ static inline void AM_drawPlayers(void) player_t *p; INT32 color = GREENS; - if (!multiplayer) - { - AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 16<mo->angle, DWHITE, plr->mo->x, plr->mo->y); - return; - } - - // multiplayer (how??) for (i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i] || players[i].spectator) continue; - + if (!players[i].mo) continue; @@ -1213,7 +1254,37 @@ static inline void AM_drawThings(UINT8 colors) t = sectors[i].thinglist; while (t) { - AM_drawLineCharacter(thintriangle_guy, NUMTHINTRIANGLEGUYLINES, 16<angle, colors, t->x, t->y); + if (!t->player) + AM_drawLineCharacter(thintriangle_guy, NUMTHINTRIANGLEGUYLINES, 16<angle, colors, t->x, t->y); + t = t->snext; + } + } +} + +static inline void AM_drawSpecialThingsOnly(UINT8 colors) +{ + size_t i; + + for (i = 0; i < numsectors; i++) + { + mobj_t *t = NULL; + + // this is fucking horrible + const INT32 special = GETSECSPECIAL(sectors[i].special, 1); + + if (GetDamage(special) == 0 + //|| sectors[i].friction < ORIG_FRICTION + || GetOffroad(special) == 0) + continue; + + t = sectors[i].thinglist; + while (t) + { + if (t->type == MT_RANDOMITEM + || t->type == MT_RING + || t->type == MT_WAYPOINT + || (t->flags & MF_SPRING)) + AM_drawLineCharacter(thintriangle_guy, NUMTHINTRIANGLEGUYLINES, 16<angle, colors, t->x, t->y); t = t->snext; } } @@ -1261,8 +1332,8 @@ void AM_Drawer(void) AM_clearFB(BACKGROUND); if (draw_grid) AM_drawGrid(GRIDCOLORS); AM_drawWalls(PASS_FOF|PASS_INTANGIBLE|PASS_SOLID); - AM_drawPlayers(); AM_drawThings(THINGCOLORS); + AM_drawPlayers(); if (!followplayer) AM_drawCrosshair(XHAIRCOLORS); } @@ -1318,6 +1389,7 @@ minigen_t *AM_MinimapGenerate(INT32 mul) //AM_clearFB(BACKGROUND); memset(am_buf, 0xff, (f_w*f_h)); + AM_drawSpecialThingsOnly(BACKGROUND); AM_drawWalls(PASS_FOF); AM_drawWalls(PASS_INTANGIBLE); AM_drawWalls(PASS_SOLID); diff --git a/src/p_spec.c b/src/p_spec.c index 7dc7ce6bb..42345e6dd 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3287,9 +3287,10 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers if (roversector || P_MobjReadyToTrigger(player->mo, sector)) P_DamageMobj(player->mo, NULL, NULL, 1); break; - case 2: // Damage (Water) // SRB2kart - These three damage types are now offroad sectors - case 3: // Damage (Fire) - case 4: // Damage (Electrical) + // SRB2kart - These three damage types are now offroad sectors + case 2: // Offroad (Weak) + case 3: // Offroad + case 4: // Offroad (Strong) break; case 5: // Spikes // Don't do anything. In Soviet Russia, spikes find you. diff --git a/src/screen.c b/src/screen.c index 1d83a409d..0a9468d25 100644 --- a/src/screen.c +++ b/src/screen.c @@ -455,7 +455,7 @@ void SCR_DisplayTicRate(void) // draw "FPS" if (cv_ticrate.value == 1) V_DrawFixedPatch(306< (benchmark - 5)) ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_MINT, GTC_CACHE); else if (fps < 20) @@ -474,10 +474,10 @@ void SCR_DisplayTicRate(void) // draw total frame: V_DrawPingNum(x, 190, fpsflags, cap, ticcntcolor); - + x -= digits * 4; - // draw "/" + // draw "/" V_DrawFixedPatch(x< servermaxping)) // only show 2 (warning) if our ping is at a bad level { INT32 dispy = (cv_ticrate.value == 1) ? 165 : ((cv_ticrate.value == 2 || cv_ticrate.value == 4) ? 172 : ((cv_ticrate.value == 3) ? 163 : 181)); // absolute buttpain From 8702ddca6085a8bea0fe9a94f7c1f60b3bc10727 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 17 Apr 2025 13:48:38 +0200 Subject: [PATCH 242/350] those do not exist anymore lel --- src/Makefile | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/Makefile b/src/Makefile index 9244c30fd..4c3240dd1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -800,30 +800,10 @@ $(OBJDIR)/SRB2.res: win32/Srb2win.rc win32/afxres.h win32/resource.h $(WINDRES) -i $< -O rc $(WINDRESFLAGS) --include-dir=win32 -o $@ -O coff ifdef SDL - ifdef MINGW $(OBJDIR)/win_dbg.o: win32/win_dbg.c $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ endif - -ifdef FILTERS -$(OBJDIR)/%.o: $(INTERFACE)/filter/%.c - @echo $< needs deps - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ - -$(OBJDIR)/filters.o: $(INTERFACE)/filter/filters.c $(INTERFACE)/filter/filters.c \ - $(INTERFACE)/filter/filters.h - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ - -$(OBJDIR)/hq2x.o: $(INTERFACE)/filter/hq2x.c $(INTERFACE)/filter/hq2x.c \ - $(INTERFACE)/filter/filters.h - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ - -$(OBJDIR)/lq2x.o: $(INTERFACE)/filter/lq2x.c $(INTERFACE)/filter/lq2x.c \ - $(INTERFACE)/filter/filters.h $(INTERFACE)/filter/interp.h \ - $(INTERFACE)/filter/hq2x.h $(INTERFACE)/filter/lq2x.h - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ -endif endif ############################################################# From f2d1cb56061b94d89873afa951e096580f789b69 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 17 Apr 2025 13:50:26 +0200 Subject: [PATCH 243/350] aaaa != --- src/am_map.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/am_map.c b/src/am_map.c index c8172837a..62a3a3da6 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -1272,9 +1272,9 @@ static inline void AM_drawSpecialThingsOnly(UINT8 colors) // this is fucking horrible const INT32 special = GETSECSPECIAL(sectors[i].special, 1); - if (GetDamage(special) == 0 + if (GetDamage(special) != 0 //|| sectors[i].friction < ORIG_FRICTION - || GetOffroad(special) == 0) + || GetOffroad(special) != 0) continue; t = sectors[i].thinglist; From 541c70498d14e3e8f4f003f09ded825b5f93b0cd Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 17 Apr 2025 14:00:55 +0200 Subject: [PATCH 244/350] we dont use MT_WAYPOINT lel just use starposts also remove rings cause duh --- src/am_map.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/am_map.c b/src/am_map.c index 62a3a3da6..64fad1e0e 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -1281,8 +1281,7 @@ static inline void AM_drawSpecialThingsOnly(UINT8 colors) while (t) { if (t->type == MT_RANDOMITEM - || t->type == MT_RING - || t->type == MT_WAYPOINT + || t->type == MT_STARPOST || (t->flags & MF_SPRING)) AM_drawLineCharacter(thintriangle_guy, NUMTHINTRIANGLEGUYLINES, 16<angle, colors, t->x, t->y); t = t->snext; From da5aaa7ebfb1ab464276492aa59389513c5d24b2 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 17 Apr 2025 19:37:17 +0100 Subject: [PATCH 245/350] Revert "SHORT ma balls" This reverts commit 5401cb58bdfbbeedc148eea0922aab1801099350. --- src/k_kart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 36d3e90c2..da484841a 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -10575,13 +10575,13 @@ static void K_drawKartMinimapIcon(fixed_t objx, fixed_t objy, INT32 hudx, INT32 if (encoremode) amnumxpos = -amnumxpos; - amxpos = amnumxpos + ((hudx + (SHORT(AutomapPic->width)-SHORT(icon->width))/2)<height)-SHORT(icon->height))/2)<width-icon->width)/2)<height-icon->height)/2)<width) / 4)<height) / 4)<width / 4)<height / 4)< Date: Thu, 17 Apr 2025 20:49:35 +0200 Subject: [PATCH 246/350] Revert "convert fixed to float with multiplication instead of division" i did not intend to push this to testing lel --- src/m_fixed.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/m_fixed.h b/src/m_fixed.h index 8f537b328..3f1acd7ae 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -39,11 +39,9 @@ typedef UINT32 ufixed_t; \brief convert fixed_t into floating number */ -static const float FLOATUNIT = (1.0f / (float)FRACUNIT); - FUNCMATH FUNCINLINE static ATTRINLINE float FixedToFloat(fixed_t x) { - return x * FLOATUNIT; + return x / (float)FRACUNIT; } FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FloatToFixed(float f) From 6d15fc1ce4ed7bac48c49c629ee3590dd3c78011 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 18 Apr 2025 10:09:42 +0200 Subject: [PATCH 247/350] close menus when replay stops --- src/g_game.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 54e509be6..6de3b1c20 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -8044,6 +8044,8 @@ void G_StopDemo(void) if (gamestate == GS_VOTING) Y_EndVote(); + M_ClearMenus(true); + G_SetGamestate(GS_NULL); wipegamestate = GS_NULL; SV_StopServer(); From c4fd47657ee979d9f226264cef9569cf8c04b0ab Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 18 Apr 2025 11:11:36 +0200 Subject: [PATCH 248/350] fix crash when using connect command from within replays --- src/d_clisrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 07cb54ecd..7927f7b28 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3167,9 +3167,9 @@ static void Command_connect(void) M_ClearMenus(true); - if (Playing() || demo.title) + if (Playing() || demo.title || demo.playback) { - if (demo.title) + if (demo.title || demo.playback) G_CheckDemoStatus(); if (netgame) From 963eb427cf05d47a1d275f0faafea49848ee2ffc Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 18 Apr 2025 11:20:17 +0200 Subject: [PATCH 249/350] reset demo stuff for multiplayer demos when using connect command so if smth happens and we cannot connect the game wont be stuck in some weird replay limbo state --- src/d_clisrv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7927f7b28..c22400717 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3170,7 +3170,11 @@ static void Command_connect(void) if (Playing() || demo.title || demo.playback) { if (demo.title || demo.playback) + { G_CheckDemoStatus(); + if (multiplayer && !demo.title) // dumb hack: G_CheckDemoStatus doesent call G_StopDemo for multiplayer demos + G_StopDemo(); + } if (netgame) { From 08f208e4a01e57629c89da81ccc00fb1442cb064 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 18 Apr 2025 11:20:58 +0200 Subject: [PATCH 250/350] fix record attack condition in G_CheckDemoStatus --- src/g_game.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 6de3b1c20..89917b268 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -8017,7 +8017,7 @@ void G_StopDemo(void) demobuf.buffer = NULL; demo.playback = false; if (demo.title) - modeattacking = false; + modeattacking = ATTACKING_NONE; demo.title = false; demo.timing = false; singletics = false; @@ -8088,12 +8088,16 @@ boolean G_CheckDemoStatus(void) I_Quit(); if (multiplayer && !demo.title) + { G_ExitLevel(); + } else { + UINT8 wasmodeattacking = modeattacking; + G_StopDemo(); - if (modeattacking) + if (wasmodeattacking) M_EndModeAttackRun(); else D_StartTitle(); From 8943b6a3b7cbb798f44c5c17fada141bfaa8b96a Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 18 Apr 2025 11:29:42 +0200 Subject: [PATCH 251/350] reset record attack state in G_ResetDemoPlayback should fix some wonky issues in a few cases --- src/g_game.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 89917b268..5fdbbd231 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -8136,6 +8136,8 @@ static void G_ResetDemoPlayback(char *pdemoname) Z_Free(demobuf.buffer); demobuf.buffer = NULL; demo.playback = false; + if (demo.title) + modeattacking = ATTACKING_NONE; demo.title = false; } From 2b299039e68a98ef21691a8026743f590c35ffb3 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 18 Apr 2025 12:35:09 +0200 Subject: [PATCH 252/350] reword this lel --- src/g_game.c | 2 +- src/m_menu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index b644e2796..231e94ffe 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -647,7 +647,7 @@ void G_SetGameModified(boolean silent, boolean major) G_SetSaveGameModified(); if (!silent) - CONS_Alert(CONS_NOTICE, M_GetText("Record Attack data will be saved to seperate save.\n")); + CONS_Alert(CONS_NOTICE, M_GetText("Record Attack data will be saved to a seperate save file.\n")); // If in record attack recording, cancel it. if (modeattacking) diff --git a/src/m_menu.c b/src/m_menu.c index be0b3131f..09ed017c5 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6189,7 +6189,7 @@ static boolean M_AddonsRefresh(void) else if (majormods && !prevmajormods) { S_StartSound(NULL, sfx_s221); - message = va("%c%s\x80\nYou've loaded a gameplay-modifying addon.\n\nRecord Attack data will be saved to seperate save.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); + message = va("%c%s\x80\nYou've loaded a gameplay-modifying addon.\n\nRecord Attack data will be saved to a seperate save file.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); prevmajormods = majormods; } From c79f986a8f9c2db010f05df33c39b4af30f1ebb7 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 18 Apr 2025 12:52:24 +0200 Subject: [PATCH 253/350] make a backup of save data before writing to it --- src/g_game.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 231e94ffe..73ca41898 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3643,6 +3643,7 @@ void G_SaveGameData(boolean force) UINT8 btemp; savebuffer_t save; (void)force; + char backupfile[MAX_WADPATH+4]; if (!gamedataloaded) return; // If never loaded (-nodata), don't save @@ -3654,6 +3655,23 @@ void G_SaveGameData(boolean force) return; } + // Create backup of the save data + snprintf(backupfile, sizeof(backupfile), "%s.bak", gamedatafilename); + backupfile[sizeof(backupfile) - 1] = '\0'; + + FILE *gamedata = fopen(gamedatafilename, "r"); + + if (gamedata != NULL) + { + fclose(gamedata); + + if (!FIL_CopyFile(gamedatafilename, backupfile)) + { + CONS_Alert(CONS_WARNING,"Failed to create a backup of save data. Will not attempt to write to save data\n"); + return; + } + } + // Version test WRITEUINT32(save.p, 0xFCAFE211); From 3fe77da35fdf28eec55d6872ccd3cc5b5f754d32 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 18 Apr 2025 21:59:24 +0200 Subject: [PATCH 254/350] readd missing SHORT macro for patch_create --- src/r_patch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_patch.c b/src/r_patch.c index 209b7e017..21f59401c 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -336,7 +336,7 @@ patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest) if (source) { INT32 col, colsize; - size_t size = sizeof(INT32) * source->width; + size_t size = sizeof(INT32) * SHORT(source->width); size_t offs = (sizeof(INT16) * 4) + size; patch->width = SHORT(source->width); From f03a12241d6bdd2419faee320b2b4c348f11bf57 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 18 Apr 2025 22:03:55 +0200 Subject: [PATCH 255/350] fix hwrpatch grabbing the wrong patch getmapped patch needs to be called before this is referenced to avoid potential issues --- src/hardware/hw_main.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 66809d19e..5b1b3a48e 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3329,7 +3329,7 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch) float offset = 0; GLPatch_t *hwrpatch; - hwrpatch = (GLPatch_t *)(gpatch->hardware); + hwrpatch = ((GLPatch_t *)gpatch->hardware); // technically this_scale gets multiplied and added to sprite y/x scale, but this thing needs it for some crap so ill just throw it in here again const boolean hires = (spr->mobj && spr->mobj->skin && K_GetMobjSkin(spr->mobj)->flags & SF_HIRES); @@ -3604,13 +3604,14 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) INT32 shader = SHADER_NONE; gpatch = spr->gpatch; - hwrpatch = (GLPatch_t *)(gpatch->hardware); // cache the patch in the graphics card memory //12/12/99: Hurdler: same comment as above (for md2) //Hurdler: 25/04/2000: now support colormap in hardware mode HWR_GetMappedPatch(gpatch, spr->colormap); + hwrpatch = ((GLPatch_t *)gpatch->hardware); + // Draw shadow BEFORE sprite if (cv_shadow.value // Shadows enabled && (spr->mobj->flags & (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY)) != (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY) // Ceiling scenery have no shadow. @@ -3881,7 +3882,13 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) // in memory and we add the md2 model if it exists for that sprite gpatch = spr->gpatch; - hwrpatch = (GLPatch_t *)(gpatch->hardware); + + // cache the patch in the graphics card memory + //12/12/99: Hurdler: same comment as above (for md2) + //Hurdler: 25/04/2000: now support colormap in hardware mode + HWR_GetMappedPatch(gpatch, spr->colormap); + + hwrpatch = ((GLPatch_t *)gpatch->hardware); // create the sprite billboard // @@ -3924,11 +3931,6 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) wallVerts[0].t = wallVerts[1].t = hwrpatch->max_t; } - // cache the patch in the graphics card memory - //12/12/99: Hurdler: same comment as above (for md2) - //Hurdler: 25/04/2000: now support colormap in hardware mode - HWR_GetMappedPatch(gpatch, spr->colormap); - // Draw shadow BEFORE sprite if (cv_shadow.value // Shadows enabled && (spr->mobj->flags & (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY)) != (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY) // Ceiling scenery have no shadow. @@ -4018,7 +4020,13 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) // cache sprite graphics gpatch = spr->gpatch; - hwrpatch = (GLPatch_t *)(gpatch->hardware); + + // cache the patch in the graphics card memory + //12/12/99: Hurdler: same comment as above (for md2) + //Hurdler: 25/04/2000: now support colormap in hardware mode + HWR_GetMappedPatch(gpatch, spr->colormap); + + hwrpatch = ((GLPatch_t *)gpatch->hardware); // create the sprite billboard // @@ -4044,11 +4052,6 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) wallVerts[3].t = wallVerts[2].t = 0; wallVerts[0].t = wallVerts[1].t = hwrpatch->max_t; - // cache the patch in the graphics card memory - //12/12/99: Hurdler: same comment as above (for md2) - //Hurdler: 25/04/2000: now support colormap in hardware mode - HWR_GetMappedPatch(gpatch, spr->colormap); - // colormap test sector_t *sector = spr->mobj->subsector->sector; UINT8 lightlevel = 255; From dc4950288475f5ae13ada5d7a2e6ce88d8748346 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 18 Apr 2025 23:28:53 +0200 Subject: [PATCH 256/350] smol fix for R_AddSingleSpriteDef --- src/r_things.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 4a24e0158..d37107ca7 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -282,7 +282,7 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, for (l = startlump; l < endlump; l++) { - if (memcmp(lumpinfo[l].name,sprname,4)) + if (memcmp(lumpinfo[l].name, sprname, 4)) continue; frame = R_Char2Frame(lumpinfo[l].name[4]); @@ -295,12 +295,12 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, } // skip NULL sprites from very old dmadds pwads - if (W_LumpLengthPwad(wadnum,l)<=8) + if (W_LumpLengthPwad(wadnum, l) <= 8) continue; // store sprite info in lookup tables //FIXME : numspritelumps do not duplicate sprite replacements - W_ReadLumpHeaderPwad(wadnum, l, &patch, sizeof (patch_t), 0); + W_ReadLumpHeaderPwad(wadnum, l, &patch, (sizeof(INT16) *4), 0); spritecachedinfo[numspritelumps].width = (INT32)(SHORT(patch.width))< Date: Sat, 19 Apr 2025 01:06:39 +0200 Subject: [PATCH 257/350] smol software stuffs --- src/r_segs.c | 53 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 8a9f0dc29..2b0700e4d 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1181,6 +1181,18 @@ static boolean R_FFloorCanClip(visffloor_t *pfloor) return (cv_ffloorclip.value && !R_IsFFloorTranslucent(pfloor) && !pfloor->polyobj); } +// R_ExpandPlaneY +// +// A simple function to modify a vsplane's top and bottom for a particular column +// Sort of like R_ExpandPlane in r_plane.c, except this is vertical expansion +static inline void R_ExpandPlaneY(visplane_t *pl, INT32 x, INT16 top, INT16 bottom) +{ + // Expand the plane, don't shrink it! + // note: top and bottom default to 0xFFFF and 0x0000 respectively, which is totally compatible with this + if (pl->top[x] > top) pl->top[x] = top; + if (pl->bottom[x] < bottom) pl->bottom[x] = bottom; +} + // // R_RenderSegLoop // Draws zero, one, or two textures (and possibly a masked @@ -1220,15 +1232,11 @@ static void R_RenderSegLoop (void) if (markceiling) { - bottom = yl-1; + bottom = yl > floorclip[rw_x] ? floorclip[rw_x] : yl; - if (bottom >= floorclip[rw_x]) - bottom = floorclip[rw_x]-1; - - if (top <= bottom && ceilingplane) + if (top <= --bottom && ceilingplane) { - ceilingplane->top[rw_x] = (INT16)top; - ceilingplane->bottom[rw_x] = (INT16)bottom; + R_ExpandPlaneY(ceilingplane, rw_x, top, bottom); } } @@ -1245,8 +1253,7 @@ static void R_RenderSegLoop (void) if (++top <= bottom && floorplane) { - floorplane->top[rw_x] = (INT16)top; - floorplane->bottom[rw_x] = (INT16)bottom; + R_ExpandPlaneY(floorplane, rw_x, top, bottom); } } @@ -1266,14 +1273,6 @@ static void R_RenderSegLoop (void) if (ffloor[i].polyobj && (!curline->polyseg || ffloor[i].polyobj != curline->polyseg)) continue; - // FIXME hack to fix planes disappearing when a seg goes behind the camera. This NEEDS to be changed to be done properly. -Red - if (curline->polyseg) { - if (ffloor[i].plane->minx > rw_x) - ffloor[i].plane->minx = rw_x; - else if (ffloor[i].plane->maxx < rw_x) - ffloor[i].plane->maxx = rw_x; - } - if (ffloor[i].height < viewz) { INT32 top_w = (ffloor[i].f_frac >> HEIGHTBITS) + 1; @@ -1286,7 +1285,7 @@ static void R_RenderSegLoop (void) bottom_w = bottom; // Polyobject-specific hack to fix plane leaking -Red - if (curline->polyseg && ffloor[i].polyobj && ffloor[i].polyobj == curline->polyseg && top_w >= bottom_w) { + if (ffloor[i].polyobj && top_w >= bottom_w) { ffloor[i].plane->top[rw_x] = ffloor[i].plane->bottom[rw_x] = 0xFFFF; } else @@ -1330,7 +1329,7 @@ static void R_RenderSegLoop (void) bottom_w = bottom; // Polyobject-specific hack to fix plane leaking -Red - if (curline->polyseg && ffloor[i].polyobj && ffloor[i].polyobj == curline->polyseg && top_w >= bottom_w) { + if (ffloor[i].polyobj && top_w >= bottom_w) { ffloor[i].plane->top[rw_x] = ffloor[i].plane->bottom[rw_x] = 0xFFFF; } else @@ -2816,6 +2815,22 @@ void R_StoreWallRange(INT32 start, INT32 stop) for (i = 0; i < numffloors; i++) R_ExpandPlane(ffloor[i].plane, rw_x, rw_stopx - 1); } + + // FIXME hack to fix planes disappearing when a seg goes behind the camera. This NEEDS to be changed to be done properly. -Red + if (curline->polyseg) + { + for (i = 0; i < numffloors; i++) + { + if (!ffloor[i].polyobj || ffloor[i].polyobj != curline->polyseg) + continue; + if (ffloor[i].plane->minx > rw_x) + ffloor[i].plane->minx = rw_x; + + if (ffloor[i].plane->maxx < rw_stopx - 1) + ffloor[i].plane->maxx = rw_stopx - 1; + } + } + } rw_silhouette = &(ds_p->silhouette); From c9faccae64671a5658cb64b6aa501abe20239bb9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 19 Apr 2025 01:19:23 +0200 Subject: [PATCH 258/350] fix software sprite clipping --- src/r_things.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index c3a83880c..bf9b4e965 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1241,7 +1241,7 @@ static void R_ProjectSprite(mobj_t *thing) tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); // sideways distance // too far off the side? - if (!papersprite && abs(tx) > FixedMul(tz, fovtan)<<2) // papersprite clipping is handled later + if (!papersprite && abs(tx) > tz<<2) // papersprite clipping is handled later return; // aspect ratio stuff @@ -1518,10 +1518,7 @@ static void R_ProjectSprite(mobj_t *thing) } // Compatibility with MSVC - SSNTails - scalestep = ((yscale2 - yscale) / range); - if (!scalestep) - scalestep = 1; - + scalestep = ((yscale2 - yscale)/range) ?: 1; xscale = FixedDiv(range< FixedMul(tz, fovtan)<<2) + if (abs(tx) > tz<<2) return; // aspect ratio stuff : From 127e8b52d1ab9e78bde257a102bb7d9ecbd079c0 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 19 Apr 2025 01:25:37 +0200 Subject: [PATCH 259/350] a --- src/r_things.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index bf9b4e965..f0f960d63 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1518,7 +1518,11 @@ static void R_ProjectSprite(mobj_t *thing) } // Compatibility with MSVC - SSNTails - scalestep = ((yscale2 - yscale)/range) ?: 1; + scalestep = ((yscale2 - yscale)/range); + + if (scalestep == 0) + scalestep = 1; + xscale = FixedDiv(range< Date: Sat, 19 Apr 2025 01:25:37 +0200 Subject: [PATCH 260/350] a --- src/r_things.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index 44720585c..31fddc550 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1522,7 +1522,11 @@ static void R_ProjectSprite(mobj_t *thing) } // Compatibility with MSVC - SSNTails - scalestep = ((yscale2 - yscale)/range) ?: 1; + scalestep = ((yscale2 - yscale)/range); + + if (scalestep == 0) + scalestep = 1; + xscale = FixedDiv(range< Date: Sat, 19 Apr 2025 08:10:09 +0200 Subject: [PATCH 261/350] cleanup http download stuff a little unglobalise a bunch of stuffand put into a struct also hopefully made the progressbar less funky --- src/d_clisrv.c | 90 ++++++++++++++++++++++++-------------------------- src/d_clisrv.h | 1 + src/d_netfil.c | 85 +++++++++++++++++++++-------------------------- src/d_netfil.h | 28 +++++++++++----- 4 files changed, 102 insertions(+), 102 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c22400717..df35d8375 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1189,11 +1189,6 @@ typedef enum static void GetPackets(void); static cl_mode_t cl_mode = CL_SEARCHING; - -#ifdef HAVE_CURL -char http_source[MAX_MIRROR_LENGTH+1]; -#endif - static UINT16 cl_lastcheckedfilecount = 0; // used for full file list // Player name send/load @@ -1267,10 +1262,10 @@ static inline void CL_DrawConnectionStatus(void) { #ifdef JOININGAME case CL_DOWNLOADSAVEGAME: - if (lastfilenum != -1) + if (filedownload.current != -1) { - UINT32 currentsize = fileneeded[lastfilenum].currentsize; - UINT32 totalsize = fileneeded[lastfilenum].totalsize; + UINT32 currentsize = fileneeded[filedownload.current].currentsize; + UINT32 totalsize = fileneeded[filedownload.current].totalsize; INT32 dldlength; cltext = M_GetText("Downloading game state..."); @@ -1365,13 +1360,13 @@ static inline void CL_DrawConnectionStatus(void) V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, va(" %2u/%2u Files",loadcompletednum,fileneedednum)); } - else if (lastfilenum != -1) + else if (filedownload.current != -1) { INT32 dldlength; INT32 totalfileslength; UINT32 totaldldsize; static char tempname[28]; - fileneeded_t *file = &fileneeded[lastfilenum]; + fileneeded_t *file = &fileneeded[filedownload.current]; char *filename = file->filename; // Draw the bottom box. @@ -1410,32 +1405,32 @@ static inline void CL_DrawConnectionStatus(void) V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-22, V_YELLOWMAP|MENUCAPS, va(M_GetText("\"%s\""), tempname)); V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE|MENUCAPS, - va(" %4uK/%4uK",fileneeded[lastfilenum].currentsize>>10,file->totalsize>>10)); + va(" %4uK/%4uK",file->currentsize>>10,file->totalsize>>10)); V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE|MENUCAPS, va("%3.1fK/s ", ((double)getbps)/1024)); // Download progress - if (fileneeded[lastfilenum].currentsize != fileneeded[lastfilenum].totalsize) - totaldldsize = downloadcompletedsize+fileneeded[lastfilenum].currentsize; //Add in single file progress download if applicable + if (file->currentsize != file->totalsize) + totaldldsize = filedownload.completedsize+file->currentsize; //Add in single file progress download if applicable else - totaldldsize = downloadcompletedsize; + totaldldsize = filedownload.completedsize; V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-14, V_YELLOWMAP|MENUCAPS, "Overall Download Progress"); - totalfileslength = (INT32)((totaldldsize/(double)totalfilesrequestedsize) * 256); + totalfileslength = (INT32)((totaldldsize/(double)filedownload.totalsize) * 256); M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160); - if (totalfilesrequestedsize>>20 >= 10) //display in MB if over 10MB + if (filedownload.totalsize>>20 >= 10) //display in MB if over 10MB V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, - va(" %4uM/%4uM",totaldldsize>>20,totalfilesrequestedsize>>20)); + va(" %4uM/%4uM",totaldldsize>>20,filedownload.totalsize>>20)); else V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, - va(" %4uK/%4uK",totaldldsize>>10,totalfilesrequestedsize>>10)); + va(" %4uK/%4uK",totaldldsize>>10,filedownload.totalsize>>10)); V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, - va("%2u/%2u Files ",downloadcompletednum,totalfilesrequestednum)); + va("%2u/%2u Files ", filedownload.completednum, filedownload.totalnum)); } else { @@ -2241,10 +2236,10 @@ void CL_TimeoutServerList(void) static void CL_ConfirmConnect(void) { - if (totalfilesrequestednum > 0) + if (filedownload.totalnum > 0) { #ifdef HAVE_CURL - if (http_source[0] == '\0' || curl_failedwebdownload) + if (filedownload.http_source[0] == '\0' || filedownload.http_failed) #endif { if (CL_SendRequestFile()) @@ -2357,7 +2352,7 @@ static boolean CL_FinishedFileList(void) // must download something // can we, though? #ifdef HAVE_CURL - if (http_source[0] == '\0' || curl_failedwebdownload) + if (filedownload.http_source[0] == '\0' || filedownload.http_failed) #endif { if (!CL_CheckDownloadable()) // nope! @@ -2377,30 +2372,31 @@ static boolean CL_FinishedFileList(void) } #ifdef HAVE_CURL - if (!curl_failedwebdownload) + if (!filedownload.http_failed) #endif { #ifndef NONET - downloadcompletednum = 0; - downloadcompletedsize = 0; - totalfilesrequestednum = 0; - totalfilesrequestedsize = 0; + filedownload.completednum = 0; + filedownload.completedsize = 0; + + filedownload.totalnum = 0; + filedownload.totalsize = 0; #endif for (i = 0; i < fileneedednum; i++) if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD) { #ifndef NONET - totalfilesrequestednum++; - totalfilesrequestedsize += fileneeded[i].totalsize; + filedownload.totalnum++; + filedownload.totalsize += fileneeded[i].totalsize; #endif } #ifndef NONET - if (totalfilesrequestedsize>>20 >= 10) - downloadsize = Z_StrDup(va("%uM",totalfilesrequestedsize>>20)); + if (filedownload.totalsize>>20 >= 10) + downloadsize = Z_StrDup(va("%uM",filedownload.totalsize>>20)); else - downloadsize = Z_StrDup(va("%uK",totalfilesrequestedsize>>10)); + downloadsize = Z_StrDup(va("%uK",filedownload.totalsize>>10)); #endif if (cv_showdownloadprompt.value) @@ -2485,9 +2481,9 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent) { #ifdef HAVE_CURL if (serverlist[i].info.httpsource[0]) - strncpy(http_source, serverlist[i].info.httpsource, MAX_MIRROR_LENGTH); + strncpy(filedownload.http_source, serverlist[i].info.httpsource, MAX_MIRROR_LENGTH); else - http_source[0] = '\0'; + filedownload.http_source[0] = '\0'; #else if (serverlist[i].info.httpsource[0]) CONS_Printf("We received a http url from the server, however it will not be used as this build lacks curl support (%s)\n", serverlist[i].info.httpsource); @@ -2570,12 +2566,12 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic break; #ifdef HAVE_CURL case CL_PREPAREHTTPFILES: - if (http_source[0]) + if (filedownload.http_source[0]) { for (i = 0; i < fileneedednum; i++) if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD) { - curl_transfers++; + filedownload.remaining++; } cl_mode = CL_DOWNLOADHTTPFILES; @@ -2587,8 +2583,8 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic for (i = 0; i < fileneedednum; i++) if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD) { - if (!curl_running) - CURLPrepareFile(http_source, i); + if (!filedownload.http_running) + CURLPrepareFile(filedownload.http_source, i); waitmore = true; break; } @@ -2596,14 +2592,14 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic if (waitmore) break; // exit the case - if (curl_failedwebdownload && !curl_transfers) + if (filedownload.http_failed && !filedownload.remaining) { CONS_Printf("One or more files failed to download, falling back to internal downloader\n"); cl_mode = CL_CHECKFILES; break; } - if (!curl_transfers) + if (!filedownload.remaining) cl_mode = CL_LOADFILES; break; @@ -2780,7 +2776,7 @@ static void CL_ConnectToServer(void) #endif #ifdef CLIENT_LOADINGSCREEN - lastfilenum = -1; + filedownload.current = -1; #endif cl_mode = CL_SEARCHING; @@ -3421,18 +3417,18 @@ void CL_Reset(void) memset(packetstat, 0, sizeof(packetstat)); #ifndef NONET - totalfilesrequestednum = 0; - totalfilesrequestedsize = 0; + filedownload.totalnum = 0; + filedownload.totalsize = 0; #endif firstconnectattempttime = 0; serverisfull = false; connectiontimeout = (tic_t)cv_nettimeout.value; //reset this temporary hack #ifdef HAVE_CURL - curl_failedwebdownload = false; - curl_transfers = 0; - curl_running = false; - http_source[0] = '\0'; + filedownload.remaining = 0; + filedownload.http_failed = false; + filedownload.http_running = false; + filedownload.http_source[0] = '\0'; #endif G_ResetAllDeviceRumbles(); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index b0cce98e3..809cedd2e 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -393,6 +393,7 @@ typedef struct #define MAXSERVERNAME 32 #define MAXFILENEEDED 915 #define MAX_MIRROR_LENGTH 256 + // This packet is too large typedef struct { diff --git a/src/d_netfil.c b/src/d_netfil.c index b37fb6d95..2a4c321c3 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -64,11 +64,11 @@ static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid); #ifdef HAVE_CURL size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream); -#if defined(CURL_AT_LEAST_VERSION) && CURL_AT_LEAST_VERSION(7, 35, 0) +#if (LIBCURL_VERSION_MAJOR <= 7) && (LIBCURL_VERSION_MINOR < 35) +static int curlprogress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow); +#else static int curlprogress_callbackx(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow); #define XFERINFOFUNCTION -#else -static int curlprogress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow); #endif #endif @@ -114,24 +114,14 @@ fileneeded_t fileneeded[MAX_WADFILES]; // List of needed files static I_mutex downloadmutex; char downloaddir[512] = "DOWNLOAD"; -#ifdef CLIENT_LOADINGSCREEN -// for cl loading screen -INT32 lastfilenum = -1; -INT32 downloadcompletednum = 0; -UINT32 downloadcompletedsize = 0; -INT32 totalfilesrequestednum = 0; -UINT32 totalfilesrequestedsize = 0; -#endif +file_download_t filedownload; #ifdef HAVE_CURL static CURL *http_handle; static CURLM *multi_handle; -boolean curl_running = false; -boolean curl_failedwebdownload = false; -static double curl_dlnow; -static double curl_dltotal; +static UINT32 curl_dlnow; +static UINT32 curl_dltotal; static time_t curl_starttime; -INT32 curl_transfers = 0; static int curl_runninghandles = 0; static UINT32 curl_origfilesize; static UINT32 curl_origtotalfilesize; @@ -235,7 +225,7 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 fi void CL_PrepareDownloadSaveGame(const char *tmpsave) { #ifdef CLIENT_LOADINGSCREEN - lastfilenum = -1; + filedownload.current = -1; #endif fileneedednum = 1; fileneeded[0].status = FS_REQUESTED; @@ -1025,8 +1015,8 @@ void Got_Filetxpak(void) CONS_Printf(M_GetText("Downloading %s...(done)\n"), filename); #ifndef NONET - downloadcompletednum++; - downloadcompletedsize += file->totalsize; + filedownload.completednum++; + filedownload.completedsize += file->totalsize; #endif } } @@ -1062,7 +1052,7 @@ void Got_Filetxpak(void) } #ifdef CLIENT_LOADINGSCREEN - lastfilenum = filenum; + filedownload.current = filenum; #endif } @@ -1211,9 +1201,7 @@ filestatus_t findfile(char *filename, const UINT8 *wantedmd5sum, boolean complet #ifdef HAVE_CURL size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream) { - size_t written; - written = fwrite(ptr, size, nmemb, stream); - return written; + return fwrite(ptr, size, nmemb, stream); } #ifdef XFERINFOFUNCTION @@ -1227,12 +1215,12 @@ static int curlprogress_callbackx(void *clientp, curl_off_t dltotal, curl_off_t curtime = time(NULL); - curl_dlnow = dlnow; - curl_dltotal = dltotal; + curl_dlnow = (UINT32)dlnow; + curl_dltotal = (UINT32)dltotal; if (curtime > curl_starttime) { - getbytes = curl_dlnow / (curtime - curl_starttime); // To-do: Make this more accurate??? + getbytes = ((double)dlnow) / (curtime - curl_starttime); // To-do: Make this more accurate??? } else { @@ -1252,12 +1240,12 @@ static int curlprogress_callback(void *clientp, double dltotal, double dlnow, do curtime = time(NULL); - curl_dlnow = dlnow; - curl_dltotal = dltotal; + curl_dlnow = (UINT32)dlnow; + curl_dltotal = (UINT32)dltotal; if (curtime > curl_starttime) { - getbytes = curl_dlnow / (curtime - curl_starttime); // To-do: Make this more accurate??? + getbytes = ((double)dlnow) / (curtime - curl_starttime); // To-do: Make this more accurate??? } else { @@ -1299,10 +1287,10 @@ void CURLPrepareFile(const char* url, int dfilenum) curl_easy_setopt(http_handle, CURLOPT_URL, va("%s/%s", url, curl_realname)); // Only allow HTTP and HTTPS -#if defined(CURL_AT_LEAST_VERSION) && CURL_AT_LEAST_VERSION(7, 85, 0) - curl_easy_setopt(http_handle, CURLOPT_PROTOCOLS_STR, "http,https"); -#else +#if (LIBCURL_VERSION_MAJOR <= 7) && (LIBCURL_VERSION_MINOR < 85) curl_easy_setopt(http_handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP|CURLPROTO_HTTPS); +#else + curl_easy_setopt(http_handle, CURLOPT_PROTOCOLS_STR, "http,https"); #endif curl_easy_setopt(http_handle, CURLOPT_USERAGENT, va("SRB2Kart/v%d.%d", VERSION, SUBVERSION)); // Set user agent as some servers won't accept invalid user agents. @@ -1334,23 +1322,25 @@ void CURLPrepareFile(const char* url, int dfilenum) #endif curl_curfile->status = FS_DOWNLOADING; - lastfilenum = dfilenum; curl_multi_add_handle(multi_handle, http_handle); curl_multi_perform(multi_handle, &curl_runninghandles); curl_starttime = time(NULL); - curl_running = true; + filedownload.current = dfilenum; + filedownload.http_running = true; #ifdef HAVE_THREADS I_spawn_thread("http-download", (I_thread_fn)CURLGetFile, NULL); #endif } + else + filedownload.http_running = false; } void CURLAbortFile(void) { - curl_running = false; + filedownload.http_running = false; // lock and unlock to wait for the download thread to exit I_lock_mutex(&downloadmutex); @@ -1367,10 +1357,8 @@ void CURLGetFile(void) int msgs_left; /* how many messages are left */ const char *easy_handle_error; boolean running = true; - long response_code = 0; - static char *filename; - while (running && curl_running) + while (running && filedownload.http_running) { if (curl_runninghandles) { @@ -1397,11 +1385,13 @@ void CURLGetFile(void) e = m->easy_handle; easyres = m->data.result; - filename = Z_StrDup(curl_realname); + char *filename = Z_StrDup(curl_realname); nameonly(filename); if (easyres != CURLE_OK) { + long response_code = 0; + if (easyres == CURLE_HTTP_RETURNED_ERROR) curl_easy_getinfo(e, CURLINFO_RESPONSE_CODE, &response_code); @@ -1409,7 +1399,7 @@ void CURLGetFile(void) curl_curfile->status = FS_FALLBACK; curl_curfile->currentsize = curl_origfilesize; curl_curfile->totalsize = curl_origtotalfilesize; - curl_failedwebdownload = true; + filedownload.http_failed = true; fclose(curl_curfile->file); remove(curl_curfile->filename); CONS_Printf(M_GetText("Failed to download %s (%s)\n"), filename, easy_handle_error); @@ -1422,36 +1412,37 @@ void CURLGetFile(void) { CONS_Alert(CONS_ERROR, M_GetText("HTTP Download of %s finished but is corrupt or has been modified\n"), filename); curl_curfile->status = FS_FALLBACK; - curl_failedwebdownload = true; + filedownload.http_failed = true; } else { CONS_Printf(M_GetText("Finished HTTP download of %s\n"), filename); - downloadcompletednum++; - downloadcompletedsize += curl_curfile->totalsize; + filedownload.completednum++; + filedownload.completedsize += curl_curfile->totalsize; curl_curfile->status = FS_FOUND; } } Z_Free(filename); curl_curfile->file = NULL; - curl_transfers--; + filedownload.remaining--; curl_multi_remove_handle(multi_handle, e); curl_easy_cleanup(e); - if (!curl_transfers) + if (!filedownload.remaining) break; } } } - if (!curl_transfers || !curl_running) + if (!filedownload.remaining || !filedownload.http_running) { curl_multi_cleanup(multi_handle); curl_global_cleanup(); multi_handle = NULL; } - curl_running = false; + + filedownload.http_running = false; I_unlock_mutex(downloadmutex); } diff --git a/src/d_netfil.h b/src/d_netfil.h index a44c35139..9f36c2b32 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -13,6 +13,7 @@ #ifndef __D_NETFIL__ #define __D_NETFIL__ +#include "d_clisrv.h" #include "w_wad.h" typedef enum @@ -52,18 +53,29 @@ extern INT32 fileneedednum; extern fileneeded_t fileneeded[MAX_WADFILES]; extern char downloaddir[512]; +typedef struct +{ #ifdef CLIENT_LOADINGSCREEN -extern INT32 lastfilenum; -extern INT32 downloadcompletednum; -extern UINT32 downloadcompletedsize; -extern INT32 totalfilesrequestednum; -extern UINT32 totalfilesrequestedsize; + INT32 current; + INT32 remaining; + INT32 completednum; + UINT32 completedsize; + + INT32 totalnum; + UINT32 totalsize; #endif #ifdef HAVE_CURL -extern boolean curl_failedwebdownload; -extern boolean curl_running; -extern INT32 curl_transfers; + boolean http_failed; + boolean http_running; + + char http_source[MAX_MIRROR_LENGTH+1]; +#endif +} file_download_t; + +extern file_download_t filedownload; + +#ifdef HAVE_CURL typedef struct HTTP_login HTTP_login; From 56392d4e7845bc4a04cee442189da3400c2ebde5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 19 Apr 2025 08:13:07 +0200 Subject: [PATCH 262/350] whoop this is only used by curl --- src/d_netfil.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/d_netfil.h b/src/d_netfil.h index 9f36c2b32..464d885b3 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -57,15 +57,14 @@ typedef struct { #ifdef CLIENT_LOADINGSCREEN INT32 current; - INT32 remaining; INT32 completednum; UINT32 completedsize; - INT32 totalnum; UINT32 totalsize; #endif #ifdef HAVE_CURL + INT32 remaining; boolean http_failed; boolean http_running; From ce77a29892b79d9c5caa863e551b7c86907aae5e Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 19 Apr 2025 10:27:51 +0200 Subject: [PATCH 263/350] fix titlescreen demos crashing, again --- src/g_game.c | 13 ++++++------- src/m_menu.c | 8 +------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 00792bf96..2b6cb07cf 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -8109,16 +8109,15 @@ boolean G_CheckDemoStatus(void) { G_ExitLevel(); } + else if (modeattacking && !demo.title) // nooo dont crash our titledemos + { + G_StopDemo(); + M_EndModeAttackRun(); + } else { - UINT8 wasmodeattacking = modeattacking; - G_StopDemo(); - - if (wasmodeattacking) - M_EndModeAttackRun(); - else - D_StartTitle(); + D_StartTitle(); } return true; diff --git a/src/m_menu.c b/src/m_menu.c index d19fbcd81..b5a1bd8d2 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -9501,13 +9501,7 @@ static void M_ModeAttackEndGame(INT32 choice) Command_ExitGame_f(); M_StartControlPanel(); - switch(modeattacking) - { - default: - case ATTACKING_RECORD: - currentMenu = &SP_TimeAttackDef; - break; - } + currentMenu = &SP_TimeAttackDef; itemOn = currentMenu->lastOn; G_SetGamestate(GS_TIMEATTACK); modeattacking = ATTACKING_NONE; From 7bcf8df6fcb0818b17cc100a25d8c359d90f45a0 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 19 Apr 2025 10:28:04 +0200 Subject: [PATCH 264/350] unnest timedemo stop stuff --- src/g_game.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 2b6cb07cf..bc6c162a5 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -8070,6 +8070,29 @@ void G_StopDemo(void) SV_ResetServer(); } +// Stops timing a demo. +static void G_StopTimingDemo(void) +{ + INT32 demotime; + double f1, f2; + demotime = I_GetTime() - demostarttime; + if (!demotime) + return; + G_StopDemo(); + demo.timing = false; + f1 = (double)demotime; + f2 = (double)framecount*TICRATE; + + CONS_Printf(M_GetText("timed %u gametics in %d realtics - %u frames\n%f seconds, %f avg fps\n"), + leveltime, demotime, (UINT32)framecount, f1/TICRATE, f2/f1); + + if (restorecv_vidwait != cv_vidwait.value) + CV_SetValue(&cv_vidwait, restorecv_vidwait); + + D_StartTitle(); +} + + boolean G_CheckDemoStatus(void) { while (ghosts) @@ -8084,19 +8107,7 @@ boolean G_CheckDemoStatus(void) if (demo.timing) { - INT32 demotime; - double f1, f2; - demotime = I_GetTime() - demostarttime; - if (!demotime) - return true; - G_StopDemo(); - demo.timing = false; - f1 = (double)demotime; - f2 = (double)framecount*TICRATE; - CONS_Printf(M_GetText("timed %u gametics in %d realtics\n%f seconds, %f avg fps\n"), leveltime,demotime,f1/TICRATE,f2/f1); - if (restorecv_vidwait != cv_vidwait.value) - CV_SetValue(&cv_vidwait, restorecv_vidwait); - D_StartTitle(); + G_StopTimingDemo(); return true; } From 2e5e753d2ed913c9e7e12f13865e62b01c83a03b Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 20 Apr 2025 16:40:35 +0200 Subject: [PATCH 265/350] pass hardware patch to HWR_DrawSpriteShadow --- src/hardware/hw_main.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 5b1b3a48e..9001b4c5c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3317,7 +3317,7 @@ static fixed_t HWR_OpaqueFloorAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t hei return floorz; } -static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch) +static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t *hwrpatch) { float this_scale = 1.0f; FOutVector swallVerts[4]; @@ -3327,9 +3327,6 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch) pslope_t *floorslope; fixed_t slopez; float offset = 0; - GLPatch_t *hwrpatch; - - hwrpatch = ((GLPatch_t *)gpatch->hardware); // technically this_scale gets multiplied and added to sprite y/x scale, but this thing needs it for some crap so ill just throw it in here again const boolean hires = (spr->mobj && spr->mobj->skin && K_GetMobjSkin(spr->mobj)->flags & SF_HIRES); @@ -3538,6 +3535,7 @@ static void HWR_RotateSpritePolyToAim(gl_vissprite_t *spr, FOutVector *wallVerts { basey = FIXED_TO_FLOAT(interp.z); } + lowy = wallVerts[0].y; // Rotate sprites to fully billboard with the camera @@ -3621,7 +3619,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) //////////////////// // SHADOW SPRITE! // //////////////////// - HWR_DrawSpriteShadow(spr, gpatch); + HWR_DrawSpriteShadow(spr, gpatch, hwrpatch); } baseWallVerts[0].x = baseWallVerts[3].x = spr->x1; @@ -3940,7 +3938,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) //////////////////// // SHADOW SPRITE! // //////////////////// - HWR_DrawSpriteShadow(spr, gpatch); + HWR_DrawSpriteShadow(spr, gpatch, hwrpatch); } // push it toward the camera to mitigate floor-clipping sprites @@ -5879,6 +5877,7 @@ static void COM_HWR_glinfo(void) CONS_Printf("Vendor: %s\n", gl_vendor); CONS_Printf("%u GL extensions present.\n", gl_num_extensions); + if (list_extensions) { // We need this strtok loop because we cannot write the extensions list directly From 5ba6021010bfac6a8fb7c3dee4e79f35c004d189 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 20 Apr 2025 22:59:55 +0200 Subject: [PATCH 266/350] dont let postload free our waitingplayer spritepatches --- src/f_finale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/f_finale.c b/src/f_finale.c index b92291467..4bbf4d991 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1190,7 +1190,7 @@ void F_StartWaitingPlayers(void) for (i = 0; i < 2; i++) { sprframe = &skins[randskin].spritedef.spriteframes[(6+(i*3)) & FF_FRAMEMASK]; - driver[i] = W_CachePatchNum(sprframe->lumppat[1], PU_SPRITE); + driver[i] = W_CachePatchNum(sprframe->lumppat[1], PU_CACHE); } } From f838ff528e56edd7ee7b44b5d13e7cb7bf05a0e0 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 20 Apr 2025 06:22:58 +0200 Subject: [PATCH 267/350] dont need this anymore --- src/hardware/hw_clip.c | 2 -- src/hardware/hw_main.c | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index 7d0179dfc..0329ebc0e 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -314,8 +314,6 @@ void gld_clipper_Clear(void) cliphead = NULL; } -#define RMUL (1.6f/1.333333f) - angle_t gld_FrustumAngle(angle_t tiltangle) { double clipfov; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9001b4c5c..b6fc25b4f 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5557,11 +5557,11 @@ static void HWR_RenderFrame(player_t *player, boolean skybox) // V_DrawPatchFill, but for the fourth screen only patch_t *gpatch = W_CachePatchName("SRB2BACK", PU_PATCH); INT32 dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); - INT32 x, y, pw = (gpatch->width) * dupz, ph = (gpatch->height) * dupz; + INT32 x, y, pw = (gpatch->width * dupz), ph = (gpatch->height * dupz); - for (x = vid.width>>1; x < vid.width; x += pw) + for (x = vid.width >> 1; x < vid.width; x += pw) { - for (y = vid.height>>1; y < vid.height; y += ph) + for (y = vid.height >> 1; y < vid.height; y += ph) HWR_DrawStretchyFixedPatch(gpatch, (x)< Date: Sun, 20 Apr 2025 06:23:36 +0200 Subject: [PATCH 268/350] check for sloperoll first --- src/hardware/hw_main.c | 2 +- src/r_things.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 4e6f352ef..390192d16 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4673,7 +4673,7 @@ static void HWR_ProjectSprite(mobj_t *thing) #ifdef ROTSPRITE // determine here if sprite should rotate for optimization const boolean sliprollrotate = (cv_sliptideroll.value && (thing->player && thing->player->sliproll)); - const boolean shouldrotate = (interp.roll || interp.pitch || interp.sloperoll || interp.slopepitch || thing->rollangle || sliprollrotate); + const boolean shouldrotate = (interp.sloperoll || interp.slopepitch || interp.roll || interp.pitch || thing->rollangle || sliprollrotate); #endif //Fab : 02-08-98: 'skin' override spritedef currently used for skin diff --git a/src/r_things.c b/src/r_things.c index f0f960d63..f0538291c 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1259,7 +1259,7 @@ static void R_ProjectSprite(mobj_t *thing) #ifdef ROTSPRITE // determine here if sprite should rotate for optimization const boolean sliprollrotate = (cv_sliptideroll.value && (thing->player && thing->player->sliproll)); - const boolean shouldrotate = (interp.roll || interp.pitch || interp.sloperoll || interp.slopepitch || thing->rollangle || sliprollrotate); + const boolean shouldrotate = (interp.sloperoll || interp.slopepitch || interp.roll || interp.pitch || thing->rollangle || sliprollrotate); #endif //Fab : 02-08-98: 'skin' override spritedef currently used for skin From fe632340b436f2ccc28b5ede7d93a191ce2cfae6 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 20 Apr 2025 15:21:39 +0200 Subject: [PATCH 269/350] fix P_CameraLineOpening lel this was always botched --- src/p_maputl.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/src/p_maputl.c b/src/p_maputl.c index a88545135..7b748c22e 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -294,50 +294,34 @@ void P_CameraLineOpening(line_t *linedef) // If you can see through it, why not move the camera through it too? if (front->camsec >= 0) { - frontfloor = sectors[front->camsec].floorheight; - frontceiling = sectors[front->camsec].ceilingheight; - if (sectors[front->camsec].f_slope) - frontfloor = P_GetZAt(sectors[front->camsec].f_slope, camera[0].x, camera[0].y); - if (sectors[front->camsec].c_slope) - frontceiling = P_GetZAt(sectors[front->camsec].c_slope, camera[0].x, camera[0].y); + frontfloor = P_GetSectorFloorZAt (§ors[front->camsec], camera[0].x, camera[0].y); + frontceiling = P_GetSectorCeilingZAt(§ors[front->camsec], camera[0].x, camera[0].y); } else if (front->heightsec >= 0) { - frontfloor = sectors[front->heightsec].floorheight; - frontceiling = sectors[front->heightsec].ceilingheight; - if (sectors[front->heightsec].f_slope) - frontfloor = P_GetZAt(sectors[front->heightsec].f_slope, camera[0].x, camera[0].y); - if (sectors[front->heightsec].c_slope) - frontceiling = P_GetZAt(sectors[front->heightsec].c_slope, camera[0].x, camera[0].y); + frontfloor = P_GetSectorFloorZAt (§ors[front->heightsec], camera[0].x, camera[0].y); + frontceiling = P_GetSectorCeilingZAt(§ors[front->heightsec], camera[0].x, camera[0].y); } else { - frontfloor = P_CameraGetFloorZ(mapcampointer, front, tmx, tmy, linedef); + frontfloor = P_CameraGetFloorZ (mapcampointer, front, tmx, tmy, linedef); frontceiling = P_CameraGetCeilingZ(mapcampointer, front, tmx, tmy, linedef); } if (back->camsec >= 0) { - backfloor = sectors[back->camsec].floorheight; - backceiling = sectors[back->camsec].ceilingheight; - if (sectors[back->camsec].f_slope) - frontfloor = P_GetZAt(sectors[back->camsec].f_slope, camera[0].x, camera[0].y); - if (sectors[back->camsec].c_slope) - frontceiling = P_GetZAt(sectors[back->camsec].c_slope, camera[0].x, camera[0].y); + backfloor = P_GetSectorFloorZAt (§ors[back->camsec], camera[0].x, camera[0].y); + backceiling = P_GetSectorCeilingZAt(§ors[back->camsec], camera[0].x, camera[0].y); } else if (back->heightsec >= 0) { - backfloor = sectors[back->heightsec].floorheight; - backceiling = sectors[back->heightsec].ceilingheight; - if (sectors[back->heightsec].f_slope) - frontfloor = P_GetZAt(sectors[back->heightsec].f_slope, camera[0].x, camera[0].y); - if (sectors[back->heightsec].c_slope) - frontceiling = P_GetZAt(sectors[back->heightsec].c_slope, camera[0].x, camera[0].y); + backfloor = P_GetSectorFloorZAt (§ors[back->heightsec], camera[0].x, camera[0].y); + backceiling = P_GetSectorCeilingZAt(§ors[back->heightsec], camera[0].x, camera[0].y); } else { - backfloor = P_CameraGetFloorZ(mapcampointer, back, tmx, tmy, linedef); + backfloor = P_CameraGetFloorZ(mapcampointer, back, tmx, tmy, linedef); backceiling = P_CameraGetCeilingZ(mapcampointer, back, tmx, tmy, linedef); } From cd2f8577a00d53b853a646208b8368ac6750a6fd Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 20 Apr 2025 23:01:53 +0200 Subject: [PATCH 270/350] big cleanup "GetZAt" stuff GetZAt now takes 4 parameters (slope, x, y, normalheight) and everything now uses their designated getzatfunction --- src/am_map.c | 7 +- src/hardware/hw_main.c | 388 ++++++++++++++++++++--------------------- src/k_kart.c | 10 +- src/lua_baselib.c | 2 +- src/m_cheat.c | 16 +- src/p_map.c | 18 +- src/p_mobj.c | 130 +++++--------- src/p_setup.c | 7 +- src/p_slopes.c | 10 +- src/p_slopes.h | 17 +- src/p_spec.c | 12 +- src/p_user.c | 29 +-- src/r_bsp.c | 56 +++--- src/r_plane.c | 10 +- src/r_segs.c | 266 +++++++++++----------------- src/r_things.c | 47 ++--- 16 files changed, 440 insertions(+), 585 deletions(-) diff --git a/src/am_map.c b/src/am_map.c index 64fad1e0e..f91273e8b 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -931,11 +931,8 @@ static INT32 GetOffroad(INT32 special) } #define SLOPEPARAMS(slope, end1, end2, normalheight) \ - if (slope) { \ - end1 = (P_GetZAt(slope, lines[i].v1->x, lines[i].v1->y) + FRACUNIT/2) >> FRACBITS; \ - end2 = (P_GetZAt(slope, lines[i].v2->x, lines[i].v2->y) + FRACUNIT/2) >> FRACBITS; \ - } else \ - end1 = end2 = (normalheight + FRACUNIT/2) >> FRACBITS; + end1 = (P_GetZAt(slope, lines[i].v1->x, lines[i].v1->y, ((normalheight + FRACUNIT/2) >> FRACBITS)) + FRACUNIT/2) >> FRACBITS; \ + end2 = (P_GetZAt(slope, lines[i].v2->x, lines[i].v2->y, ((normalheight + FRACUNIT/2) >> FRACBITS)) + FRACUNIT/2) >> FRACBITS; static ffloor_t *AM_CompareFOFs(size_t i, ffloor_t *rover, ffloor_t *secondarystore) { diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 390192d16..65b6137bf 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -573,9 +573,9 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool // Set fixedheight to the slope's height from our viewpoint, if we have a slope if (slope) - fixedheight = P_GetZAt(slope, viewx, viewy); + fixedheight = P_GetSlopeZAt(slope, viewx, viewy); - height = FIXED_TO_FLOAT(fixedheight); + height = FixedToFloat(fixedheight); // Allocate plane-vertex buffer if we need to if (!planeVerts || nrPlaneVerts > numAllocedPlaneVerts) @@ -629,14 +629,14 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool { if (!isceiling) // it's a floor { - scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatsize; + scrollx = FixedToFloat(FOFsector->floor_xoffs)/fflatsize; + scrolly = FixedToFloat(FOFsector->floor_yoffs)/fflatsize; angle = FOFsector->floorpic_angle; } else // it's a ceiling { - scrollx = FIXED_TO_FLOAT(FOFsector->ceiling_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(FOFsector->ceiling_yoffs)/fflatsize; + scrollx = FixedToFloat(FOFsector->ceiling_xoffs)/fflatsize; + scrolly = FixedToFloat(FOFsector->ceiling_yoffs)/fflatsize; angle = FOFsector->ceilingpic_angle; } } @@ -644,14 +644,14 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool { if (!isceiling) // it's a floor { - scrollx = FIXED_TO_FLOAT(gl_frontsector->floor_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(gl_frontsector->floor_yoffs)/fflatsize; + scrollx = FixedToFloat(gl_frontsector->floor_xoffs)/fflatsize; + scrolly = FixedToFloat(gl_frontsector->floor_yoffs)/fflatsize; angle = gl_frontsector->floorpic_angle; } else // it's a ceiling { - scrollx = FIXED_TO_FLOAT(gl_frontsector->ceiling_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(gl_frontsector->ceiling_yoffs)/fflatsize; + scrollx = FixedToFloat(gl_frontsector->ceiling_xoffs)/fflatsize; + scrolly = FixedToFloat(gl_frontsector->ceiling_yoffs)/fflatsize; angle = gl_frontsector->ceilingpic_angle; } } @@ -662,10 +662,10 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool // This needs to be done so everything aligns after rotation // It would be done so that rotation is done, THEN the translation, but I couldn't get it to rotate AND scroll like software does - tempxsow = FLOAT_TO_FIXED(flatxref); - tempytow = FLOAT_TO_FIXED(flatyref); - flatxref = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); - flatyref = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); + tempxsow = FloatToFixed(flatxref); + tempytow = FloatToFixed(flatyref); + flatxref = (FixedToFloat(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); + flatyref = (FixedToFloat(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); } #define SETUP3DVERT(vert, vx, vy) {\ @@ -676,10 +676,10 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool /* Need to rotate before translate */\ if (angle) /* Only needs to be done if there's an altered angle */\ {\ - tempxsow = FLOAT_TO_FIXED(vert->s);\ - tempytow = FLOAT_TO_FIXED(vert->t);\ - vert->s = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle))));\ - vert->t = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle))));\ + tempxsow = FloatToFixed(vert->s);\ + tempytow = FloatToFixed(vert->t);\ + vert->s = (FixedToFloat(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle))));\ + vert->t = (FixedToFloat(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle))));\ }\ \ vert->x = (vx);\ @@ -688,8 +688,8 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool \ if (slope)\ {\ - fixedheight = P_GetZAt(slope, FLOAT_TO_FIXED((vx)), FLOAT_TO_FIXED((vy)));\ - vert->y = FIXED_TO_FLOAT(fixedheight);\ + fixedheight = P_GetSlopeZAt(slope, FloatToFixed((vx)), FloatToFixed((vy)));\ + vert->y = FixedToFloat(fixedheight);\ }\ } for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++,v3d++,pv++) @@ -745,7 +745,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool continue; P_ClosestPointOnLine(viewx, viewy, line->linedef, &v); - dist = FIXED_TO_FLOAT(R_PointToDist(v.x, v.y)); + dist = FixedToFloat(R_PointToDist(v.x, v.y)); if (line->pv1) { @@ -754,8 +754,8 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool } else { - x1 = FIXED_TO_FLOAT(line->v1->x); - y1 = FIXED_TO_FLOAT(line->v1->x); + x1 = FixedToFloat(line->v1->x); + y1 = FixedToFloat(line->v1->x); } if (line->pv2) @@ -765,8 +765,8 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool } else { - xd = FIXED_TO_FLOAT(line->v2->x) - x1; - yd = FIXED_TO_FLOAT(line->v2->y) - y1; + xd = FixedToFloat(line->v2->x) - x1; + yd = FixedToFloat(line->v2->y) - y1; } // Based on the seg length and the distance from the line, split horizon into multiple poly sets to reduce distortion @@ -830,11 +830,11 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) M_ClearBox(segbbox); M_AddToBox(segbbox, - FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x), - FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y)); + FloatToFixed(((polyvertex_t *)gl_curline->pv1)->x), + FloatToFixed(((polyvertex_t *)gl_curline->pv1)->y)); M_AddToBox(segbbox, - FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x), - FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y)); + FloatToFixed(((polyvertex_t *)gl_curline->pv2)->x), + FloatToFixed(((polyvertex_t *)gl_curline->pv2)->y)); splat = (wallsplat_t *)gl_curline->linedef->splats; for (; splat; splat = splat->next) @@ -847,17 +847,17 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) gpatch = W_CachePatchNum(splat->patch, PU_CACHE); HWR_GetPatch(gpatch); - wallVerts[0].x = wallVerts[3].x = FIXED_TO_FLOAT(splat->v1.x); - wallVerts[0].z = wallVerts[3].z = FIXED_TO_FLOAT(splat->v1.y); - wallVerts[2].x = wallVerts[1].x = FIXED_TO_FLOAT(splat->v2.x); - wallVerts[2].z = wallVerts[1].z = FIXED_TO_FLOAT(splat->v2.y); + wallVerts[0].x = wallVerts[3].x = FixedToFloat(splat->v1.x); + wallVerts[0].z = wallVerts[3].z = FixedToFloat(splat->v1.y); + wallVerts[2].x = wallVerts[1].x = FixedToFloat(splat->v2.x); + wallVerts[2].z = wallVerts[1].z = FixedToFloat(splat->v2.y); i = splat->top; if (splat->yoffset) i += *splat->yoffset; - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(i)+(gpatch->height>>1); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(i)-(gpatch->height>>1); + wallVerts[2].y = wallVerts[3].y = FixedToFloat(i)+(gpatch->height>>1); + wallVerts[0].y = wallVerts[1].y = FixedToFloat(i)-(gpatch->height>>1); wallVerts[3].s = wallVerts[3].t = wallVerts[2].s = wallVerts[0].t = 0.0f; wallVerts[1].s = wallVerts[1].t = wallVerts[2].t = wallVerts[0].s = 1.0f; @@ -1333,13 +1333,13 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { vs.x = ((polyvertex_t *)gl_curline->pv1)->x; vs.y = ((polyvertex_t *)gl_curline->pv1)->y; - v1x = FLOAT_TO_FIXED(vs.x); - v1y = FLOAT_TO_FIXED(vs.y); + v1x = FloatToFixed(vs.x); + v1y = FloatToFixed(vs.y); } else { - vs.x = FIXED_TO_FLOAT(gl_curline->v1->x); - vs.y = FIXED_TO_FLOAT(gl_curline->v1->y); + vs.x = FixedToFloat(gl_curline->v1->x); + vs.y = FixedToFloat(gl_curline->v1->y); v1x = gl_curline->v1->x; v1y = gl_curline->v1->y; } @@ -1348,23 +1348,20 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { ve.x = ((polyvertex_t *)gl_curline->pv2)->x; ve.y = ((polyvertex_t *)gl_curline->pv2)->y; - v2x = FLOAT_TO_FIXED(ve.x); - v2y = FLOAT_TO_FIXED(ve.y); + v2x = FloatToFixed(ve.x); + v2y = FloatToFixed(ve.y); } else { - ve.x = FIXED_TO_FLOAT(gl_curline->v2->x); - ve.y = FIXED_TO_FLOAT(gl_curline->v2->y); + ve.x = FixedToFloat(gl_curline->v2->x); + ve.y = FixedToFloat(gl_curline->v2->y); v2x = gl_curline->v2->x; v2y = gl_curline->v2->y; } #define SLOPEPARAMS(slope, end1, end2, normalheight) \ - if (slope) { \ - end1 = P_GetZAt(slope, v1x, v1y); \ - end2 = P_GetZAt(slope, v2x, v2y); \ - } else \ - end1 = end2 = normalheight; + end1 = P_GetZAt(slope, v1x, v1y, normalheight); \ + end2 = P_GetZAt(slope, v2x, v2y, normalheight); SLOPEPARAMS(gl_frontsector->c_slope, worldtop, worldtopslope, gl_frontsector->ceilingheight) SLOPEPARAMS(gl_frontsector->f_slope, worldbottom, worldbottomslope, gl_frontsector->floorheight) @@ -1412,7 +1409,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (!gl_curline->polyseg) // Don't do it for polyobjects { // Sky Ceilings - wallVerts[3].y = wallVerts[2].y = FIXED_TO_FLOAT(INT32_MAX); + wallVerts[3].y = wallVerts[2].y = FixedToFloat(INT32_MAX); if (gl_frontsector->ceilingpic == skyflatnum) { @@ -1424,29 +1421,29 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom && (worldhigh != worldtop || worldhighslope != worldtopslope)) // Removing the second line above will render more rarely visible skywalls. Example: Cave garden ceiling in Dark race { - wallVerts[0].y = FIXED_TO_FLOAT(worldhigh); - wallVerts[1].y = FIXED_TO_FLOAT(worldhighslope); + wallVerts[0].y = FixedToFloat(worldhigh); + wallVerts[1].y = FixedToFloat(worldhighslope); HWR_DrawSkyWall(wallVerts, &Surf); } } else { // Only the frontsector is sky, just draw a skywall from the front ceiling - wallVerts[0].y = FIXED_TO_FLOAT(worldtop); - wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope); + wallVerts[0].y = FixedToFloat(worldtop); + wallVerts[1].y = FixedToFloat(worldtopslope); HWR_DrawSkyWall(wallVerts, &Surf); } } else if (gl_backsector->ceilingpic == skyflatnum) { // Only the backsector is sky, just draw a skywall from the front ceiling - wallVerts[0].y = FIXED_TO_FLOAT(worldtop); - wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope); + wallVerts[0].y = FixedToFloat(worldtop); + wallVerts[1].y = FixedToFloat(worldtopslope); HWR_DrawSkyWall(wallVerts, &Surf); } // Sky Floors - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(INT32_MIN); + wallVerts[0].y = wallVerts[1].y = FixedToFloat(INT32_MIN); if (gl_frontsector->floorpic == skyflatnum) { @@ -1460,24 +1457,24 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // Removing the second line above will render more rarely visible skywalls. Example: Cave garden ceiling in Dark race && !(gl_sidedef->bottomtexture)) { - wallVerts[3].y = FIXED_TO_FLOAT(worldlow); - wallVerts[2].y = FIXED_TO_FLOAT(worldlowslope); + wallVerts[3].y = FixedToFloat(worldlow); + wallVerts[2].y = FixedToFloat(worldlowslope); HWR_DrawSkyWall(wallVerts, &Surf); } } else { // Only the backsector has sky, just draw a skywall from the back floor - wallVerts[3].y = FIXED_TO_FLOAT(worldbottom); - wallVerts[2].y = FIXED_TO_FLOAT(worldbottomslope); + wallVerts[3].y = FixedToFloat(worldbottom); + wallVerts[2].y = FixedToFloat(worldbottomslope); HWR_DrawSkyWall(wallVerts, &Surf); } } else if ((gl_backsector->floorpic == skyflatnum) && !(gl_sidedef->bottomtexture)) { // Only the backsector has sky, just draw a skywall from the back floor if there's no bottomtexture - wallVerts[3].y = FIXED_TO_FLOAT(worldlow); - wallVerts[2].y = FIXED_TO_FLOAT(worldlowslope); + wallVerts[3].y = FixedToFloat(worldlow); + wallVerts[2].y = FixedToFloat(worldlowslope); HWR_DrawSkyWall(wallVerts, &Surf); } } @@ -1540,10 +1537,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } // set top/bottom coords - wallVerts[3].y = FIXED_TO_FLOAT(worldtop); - wallVerts[0].y = FIXED_TO_FLOAT(worldhigh); - wallVerts[2].y = FIXED_TO_FLOAT(worldtopslope); - wallVerts[1].y = FIXED_TO_FLOAT(worldhighslope); + wallVerts[3].y = FixedToFloat(worldtop); + wallVerts[0].y = FixedToFloat(worldhigh); + wallVerts[2].y = FixedToFloat(worldtopslope); + wallVerts[1].y = FixedToFloat(worldhighslope); if (!gl_drawing_stencil && gl_frontsector->numlights) HWR_SplitWall(gl_frontsector, wallVerts, gl_toptexture, noencore, &Surf, FF_CUTLEVEL, NULL, 0); @@ -1601,10 +1598,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } // set top/bottom coords - wallVerts[3].y = FIXED_TO_FLOAT(worldlow); - wallVerts[0].y = FIXED_TO_FLOAT(worldbottom); - wallVerts[2].y = FIXED_TO_FLOAT(worldlowslope); - wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); + wallVerts[3].y = FixedToFloat(worldlow); + wallVerts[0].y = FixedToFloat(worldbottom); + wallVerts[2].y = FixedToFloat(worldlowslope); + wallVerts[1].y = FixedToFloat(worldbottomslope); if (!gl_drawing_stencil && gl_frontsector->numlights) HWR_SplitWall(gl_frontsector, wallVerts, gl_bottomtexture, noencore, &Surf, FF_CUTLEVEL, NULL, 0); @@ -1765,10 +1762,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // set top/bottom coords // Take the texture peg into account, rather than changing the offsets past // where the polygon might not be. - wallVerts[3].y = FIXED_TO_FLOAT(h); - wallVerts[0].y = FIXED_TO_FLOAT(l); - wallVerts[2].y = FIXED_TO_FLOAT(hS); - wallVerts[1].y = FIXED_TO_FLOAT(lS); + wallVerts[3].y = FixedToFloat(h); + wallVerts[0].y = FixedToFloat(l); + wallVerts[2].y = FixedToFloat(hS); + wallVerts[1].y = FixedToFloat(lS); // TODO: Actually use the surface's flags so that I don't have to do this FUINT blendmode = Surf.PolyFlags; @@ -1827,10 +1824,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } //Set textures properly on single sided walls that are sloped - wallVerts[3].y = FIXED_TO_FLOAT(worldtop); - wallVerts[0].y = FIXED_TO_FLOAT(worldbottom); - wallVerts[2].y = FIXED_TO_FLOAT(worldtopslope); - wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); + wallVerts[3].y = FixedToFloat(worldtop); + wallVerts[0].y = FixedToFloat(worldbottom); + wallVerts[2].y = FixedToFloat(worldtopslope); + wallVerts[1].y = FixedToFloat(worldbottomslope); if (gl_frontsector->numlights) { @@ -1847,10 +1844,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else { //Set textures properly on single sided walls that are sloped - wallVerts[3].y = FIXED_TO_FLOAT(worldtop); - wallVerts[0].y = FIXED_TO_FLOAT(worldbottom); - wallVerts[2].y = FIXED_TO_FLOAT(worldtopslope); - wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); + wallVerts[3].y = FixedToFloat(worldtop); + wallVerts[0].y = FixedToFloat(worldbottom); + wallVerts[2].y = FixedToFloat(worldtopslope); + wallVerts[1].y = FixedToFloat(worldbottomslope); // When there's no midtexture, draw a skywall to prevent rendering behind it HWR_DrawSkyWall(wallVerts, &Surf); @@ -1860,17 +1857,17 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { if (gl_frontsector->ceilingpic == skyflatnum) // It's a single-sided line with sky for its sector { - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(INT32_MAX); // draw to top of map space - wallVerts[0].y = FIXED_TO_FLOAT(worldtop); - wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope); + wallVerts[2].y = wallVerts[3].y = FixedToFloat(INT32_MAX); // draw to top of map space + wallVerts[0].y = FixedToFloat(worldtop); + wallVerts[1].y = FixedToFloat(worldtopslope); HWR_DrawSkyWall(wallVerts, &Surf); } if (gl_frontsector->floorpic == skyflatnum) { - wallVerts[3].y = FIXED_TO_FLOAT(worldbottom); - wallVerts[2].y = FIXED_TO_FLOAT(worldbottomslope); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(INT32_MIN); // draw to bottom of map space + wallVerts[3].y = FixedToFloat(worldbottom); + wallVerts[2].y = FixedToFloat(worldbottomslope); + wallVerts[0].y = wallVerts[1].y = FixedToFloat(INT32_MIN); // draw to bottom of map space HWR_DrawSkyWall(wallVerts, &Surf); } @@ -1940,10 +1937,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom //FIXME: check if peging is correct // set top/bottom coords - wallVerts[3].y = FIXED_TO_FLOAT(h); - wallVerts[2].y = FIXED_TO_FLOAT(hS); - wallVerts[0].y = FIXED_TO_FLOAT(l); - wallVerts[1].y = FIXED_TO_FLOAT(lS); + wallVerts[3].y = FixedToFloat(h); + wallVerts[2].y = FixedToFloat(hS); + wallVerts[0].y = FixedToFloat(l); + wallVerts[1].y = FixedToFloat(lS); if (roverflags & FF_FOG) { @@ -2090,10 +2087,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom //FIXME: check if peging is correct // set top/bottom coords - wallVerts[3].y = FIXED_TO_FLOAT(h); - wallVerts[2].y = FIXED_TO_FLOAT(hS); - wallVerts[0].y = FIXED_TO_FLOAT(l); - wallVerts[1].y = FIXED_TO_FLOAT(lS); + wallVerts[3].y = FixedToFloat(h); + wallVerts[2].y = FixedToFloat(hS); + wallVerts[0].y = FixedToFloat(l); + wallVerts[1].y = FixedToFloat(lS); if (roverflags & FF_FOG) { @@ -2187,8 +2184,8 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) if (LIKELY(gl_curline->pv1)) { - v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x); - v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y); + v1x = FloatToFixed(((polyvertex_t *)gl_curline->pv1)->x); + v1y = FloatToFixed(((polyvertex_t *)gl_curline->pv1)->y); } else { @@ -2198,8 +2195,8 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) if (LIKELY(gl_curline->pv2)) { - v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x); - v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y); + v2x = FloatToFixed(((polyvertex_t *)gl_curline->pv2)->x); + v2y = FloatToFixed(((polyvertex_t *)gl_curline->pv2)->y); } else { @@ -2208,11 +2205,8 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) } #define SLOPEPARAMS(slope, end1, end2, normalheight) \ - if (slope) { \ - end1 = P_GetZAt(slope, v1x, v1y); \ - end2 = P_GetZAt(slope, v2x, v2y); \ - } else \ - end1 = end2 = normalheight; + end1 = P_GetZAt(slope, v1x, v1y, normalheight); \ + end2 = P_GetZAt(slope, v2x, v2y, normalheight); SLOPEPARAMS(afrontsector->f_slope, frontf1, frontf2, afrontsector->floorheight) SLOPEPARAMS(afrontsector->c_slope, frontc1, frontc2, afrontsector->ceilingheight) @@ -2326,8 +2320,8 @@ static void HWR_AddLine(seg_t *line) if (LIKELY(gl_curline->pv1)) { - v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x); - v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y); + v1x = FloatToFixed(((polyvertex_t *)gl_curline->pv1)->x); + v1y = FloatToFixed(((polyvertex_t *)gl_curline->pv1)->y); } else { @@ -2337,8 +2331,8 @@ static void HWR_AddLine(seg_t *line) if (LIKELY(gl_curline->pv2)) { - v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x); - v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y); + v2x = FloatToFixed(((polyvertex_t *)gl_curline->pv2)->x); + v2y = FloatToFixed(((polyvertex_t *)gl_curline->pv2)->y); } else { @@ -2586,7 +2580,7 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, Z_Malloc(numAllocedPlaneVerts * sizeof (FOutVector), PU_LEVEL, &planeVerts); } - height = FIXED_TO_FLOAT(fixedheight); + height = FixedToFloat(fixedheight); len = W_LumpLength(lumpnum); @@ -2623,8 +2617,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, } // reference point for flat texture coord for each vertex around the polygon - flatxref = FIXED_TO_FLOAT(polysector->origVerts[0].x); - flatyref = FIXED_TO_FLOAT(polysector->origVerts[0].y); + flatxref = FixedToFloat(polysector->origVerts[0].x); + flatyref = FixedToFloat(polysector->origVerts[0].y); flatxref = (float)(((fixed_t)flatxref & (~flatflag)) / fflatsize); flatyref = (float)(((fixed_t)flatyref & (~flatflag)) / fflatsize); @@ -2636,14 +2630,14 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, { if (!isceiling) // it's a floor { - scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatsize; + scrollx = FixedToFloat(FOFsector->floor_xoffs)/fflatsize; + scrolly = FixedToFloat(FOFsector->floor_yoffs)/fflatsize; angle = FOFsector->floorpic_angle>>ANGLETOFINESHIFT; } else // it's a ceiling { - scrollx = FIXED_TO_FLOAT(FOFsector->ceiling_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(FOFsector->ceiling_yoffs)/fflatsize; + scrollx = FixedToFloat(FOFsector->ceiling_xoffs)/fflatsize; + scrolly = FixedToFloat(FOFsector->ceiling_yoffs)/fflatsize; angle = FOFsector->ceilingpic_angle>>ANGLETOFINESHIFT; } } @@ -2651,14 +2645,14 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, { if (!isceiling) // it's a floor { - scrollx = FIXED_TO_FLOAT(gl_frontsector->floor_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(gl_frontsector->floor_yoffs)/fflatsize; + scrollx = FixedToFloat(gl_frontsector->floor_xoffs)/fflatsize; + scrolly = FixedToFloat(gl_frontsector->floor_yoffs)/fflatsize; angle = gl_frontsector->floorpic_angle>>ANGLETOFINESHIFT; } else // it's a ceiling { - scrollx = FIXED_TO_FLOAT(gl_frontsector->ceiling_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(gl_frontsector->ceiling_yoffs)/fflatsize; + scrollx = FixedToFloat(gl_frontsector->ceiling_xoffs)/fflatsize; + scrolly = FixedToFloat(gl_frontsector->ceiling_yoffs)/fflatsize; angle = gl_frontsector->ceilingpic_angle>>ANGLETOFINESHIFT; } } @@ -2666,37 +2660,37 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, if (angle) // Only needs to be done if there's an altered angle { // This needs to be done so that it scrolls in a different direction after rotation like software - tempxsow = FLOAT_TO_FIXED(scrollx); - tempytow = FLOAT_TO_FIXED(scrolly); - scrollx = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); - scrolly = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); + tempxsow = FloatToFixed(scrollx); + tempytow = FloatToFixed(scrolly); + scrollx = (FixedToFloat(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); + scrolly = (FixedToFloat(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); // This needs to be done so everything aligns after rotation // It would be done so that rotation is done, THEN the translation, but I couldn't get it to rotate AND scroll like software does - tempxsow = FLOAT_TO_FIXED(flatxref); - tempytow = FLOAT_TO_FIXED(flatyref); - flatxref = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); - flatyref = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); + tempxsow = FloatToFixed(flatxref); + tempytow = FloatToFixed(flatyref); + flatxref = (FixedToFloat(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); + flatyref = (FixedToFloat(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); } for (i = 0; i < (INT32)nrPlaneVerts; i++,v3d++) { // Hurdler: add scrolling texture on floor/ceiling - v3d->s = (float)((FIXED_TO_FLOAT(polysector->origVerts[i].x) / fflatsize) - flatxref + scrollx); // Go from the polysector's original vertex locations - v3d->t = (float)(flatyref - (FIXED_TO_FLOAT(polysector->origVerts[i].y) / fflatsize) + scrolly); // Means the flat is offset based on the original vertex locations + v3d->s = (float)((FixedToFloat(polysector->origVerts[i].x) / fflatsize) - flatxref + scrollx); // Go from the polysector's original vertex locations + v3d->t = (float)(flatyref - (FixedToFloat(polysector->origVerts[i].y) / fflatsize) + scrolly); // Means the flat is offset based on the original vertex locations // Need to rotate before translate if (angle) // Only needs to be done if there's an altered angle { - tempxsow = FLOAT_TO_FIXED(v3d->s); - tempytow = FLOAT_TO_FIXED(v3d->t); - v3d->s = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); - v3d->t = (FIXED_TO_FLOAT(-FixedMul(tempxsow, FINESINE(angle)) - FixedMul(tempytow, FINECOSINE(angle)))); + tempxsow = FloatToFixed(v3d->s); + tempytow = FloatToFixed(v3d->t); + v3d->s = (FixedToFloat(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); + v3d->t = (FixedToFloat(-FixedMul(tempxsow, FINESINE(angle)) - FixedMul(tempytow, FINECOSINE(angle)))); } - v3d->x = FIXED_TO_FLOAT(polysector->vertices[i]->x); + v3d->x = FixedToFloat(polysector->vertices[i]->x); v3d->y = height; - v3d->z = FIXED_TO_FLOAT(polysector->vertices[i]->y); + v3d->z = FixedToFloat(polysector->vertices[i]->y); } HWR_Lighting(&Surf, lightlevel, planecolormap, P_SectorUsesDirectionalLighting((FOFsector != NULL) ? FOFsector : gl_frontsector)); @@ -2796,7 +2790,7 @@ static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float v if (!cullheight) return false; - cullplane = FIXED_TO_FLOAT(cullheight->frontsector->floorheight); + cullplane = FixedToFloat(cullheight->frontsector->floorheight); if (cullheight->flags & ML_NOCLIMB) // Group culling { @@ -2994,7 +2988,7 @@ static void HWR_Subsector(size_t num) if (gl_frontsector->cullheight) { - if (HWR_DoCulling(gl_frontsector->cullheight, viewsector->cullheight, gl_viewz, FIXED_TO_FLOAT(*rover->bottomheight), FIXED_TO_FLOAT(*rover->topheight))) + if (HWR_DoCulling(gl_frontsector->cullheight, viewsector->cullheight, gl_viewz, FixedToFloat(*rover->bottomheight), FixedToFloat(*rover->topheight))) continue; } @@ -3328,9 +3322,9 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, GLPatch_t *gpatch) // technically this_scale gets multiplied and added to sprite y/x scale, but this thing needs it for some crap so ill just throw it in here again const boolean hires = (spr->mobj && spr->mobj->skin && K_GetMobjSkin(spr->mobj)->flags & SF_HIRES); if (spr->mobj) - this_scale = FIXED_TO_FLOAT(spr->mobj->scale); + this_scale = FixedToFloat(spr->mobj->scale); if (hires) - this_scale = this_scale * FIXED_TO_FLOAT(K_GetMobjSkin(spr->mobj)->highresscale); + this_scale = this_scale * FixedToFloat(K_GetMobjSkin(spr->mobj)->highresscale); R_GetShadowZ(spr->mobj, &floorslope); @@ -3432,8 +3426,8 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, GLPatch_t *gpatch) { for (int i = 0; i < 4; i++) { - slopez = P_GetZAt(floorslope, FLOAT_TO_FIXED(swallVerts[i].x), FLOAT_TO_FIXED(swallVerts[i].z)); - swallVerts[i].y = FIXED_TO_FLOAT(slopez) + 0.05f; + slopez = P_GetSlopeZAt(floorslope, FloatToFixed(swallVerts[i].x), FloatToFixed(swallVerts[i].z)); + swallVerts[i].y = FixedToFloat(slopez) + 0.05f; } } @@ -3526,11 +3520,11 @@ static void HWR_RotateSpritePolyToAim(gl_vissprite_t *spr, FOutVector *wallVerts if (!precip && P_MobjFlip(spr->mobj) == -1) // precip doesn't have eflags so they can't flip { - basey = FIXED_TO_FLOAT(interp.z + spr->mobj->height); + basey = FixedToFloat(interp.z + spr->mobj->height); } else { - basey = FIXED_TO_FLOAT(interp.z); + basey = FixedToFloat(interp.z); } lowy = wallVerts[0].y; @@ -3623,10 +3617,10 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) baseWallVerts[2].y = baseWallVerts[3].y = spr->gzt; baseWallVerts[0].y = baseWallVerts[1].y = spr->gz; - v1x = FLOAT_TO_FIXED(spr->x1); - v1y = FLOAT_TO_FIXED(spr->z1); - v2x = FLOAT_TO_FIXED(spr->x2); - v2y = FLOAT_TO_FIXED(spr->z2); + v1x = FloatToFixed(spr->x1); + v1y = FloatToFixed(spr->z1); + v2x = FloatToFixed(spr->x2); + v2y = FloatToFixed(spr->z2); if (spr->flip) { @@ -3712,7 +3706,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) colormap = list[sector->numlights - 1].extra_colormap; i = 0; - temp = FLOAT_TO_FIXED(realtop); + temp = FloatToFixed(realtop); lightset = HWR_OverrideObjectLightLevel(spr->mobj, &lightlevel); @@ -3751,9 +3745,9 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) if (i + 1 < sector->numlights) { temp = P_GetLightZAt(&list[i+1], v1x, v1y); - bheight = FIXED_TO_FLOAT(temp); + bheight = FixedToFloat(temp); temp = P_GetLightZAt(&list[i+1], v2x, v2y); - endbheight = FIXED_TO_FLOAT(temp); + endbheight = FixedToFloat(temp); } else { @@ -4644,8 +4638,8 @@ static void HWR_ProjectSprite(mobj_t *thing) } // transform the origin point - tr_x = FIXED_TO_FLOAT(interp.x); - tr_y = FIXED_TO_FLOAT(interp.y); + tr_x = FixedToFloat(interp.x); + tr_y = FixedToFloat(interp.y); // rotation around vertical axis tz = ((tr_x - gl_viewx) * gl_viewcos) + ((tr_y - gl_viewy) * gl_viewsin); @@ -4658,9 +4652,9 @@ static void HWR_ProjectSprite(mobj_t *thing) const boolean vflip = (thing->eflags & MFE_VERTICALFLIP); const boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); - this_scale = FIXED_TO_FLOAT(interp.scale); - spritexscale = FIXED_TO_FLOAT(interp.spritexscale); - spriteyscale = FIXED_TO_FLOAT(interp.spriteyscale); + this_scale = FixedToFloat(interp.scale); + spritexscale = FixedToFloat(interp.spritexscale); + spriteyscale = FixedToFloat(interp.spriteyscale); // decide which patch to use for sprite relative to player #ifdef RANGECHECK @@ -4761,7 +4755,7 @@ static void HWR_ProjectSprite(mobj_t *thing) } if ((thing->skin || thing->localskin) && K_GetMobjSkin(thing)->flags & SF_HIRES) - this_scale *= FIXED_TO_FLOAT(K_GetMobjSkin(thing)->highresscale); + this_scale *= FixedToFloat(K_GetMobjSkin(thing)->highresscale); spr_width = spritecachedinfo[lumpoff].width; spr_height = spritecachedinfo[lumpoff].height; @@ -4809,13 +4803,13 @@ static void HWR_ProjectSprite(mobj_t *thing) if (papersprite) { - rightsin = FIXED_TO_FLOAT(FINESINE(interp.angle >> ANGLETOFINESHIFT)); - rightcos = FIXED_TO_FLOAT(FINECOSINE(interp.angle >> ANGLETOFINESHIFT)); + rightsin = FixedToFloat(FINESINE(interp.angle >> ANGLETOFINESHIFT)); + rightcos = FixedToFloat(FINECOSINE(interp.angle >> ANGLETOFINESHIFT)); } else { - rightsin = FIXED_TO_FLOAT(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); - rightcos = FIXED_TO_FLOAT(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); + rightsin = FixedToFloat(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); + rightcos = FixedToFloat(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); } spritexscale *= this_scale; @@ -4825,13 +4819,13 @@ static void HWR_ProjectSprite(mobj_t *thing) if (flip) { - x1 = (FIXED_TO_FLOAT(spr_width - spr_offset) * spritexscale); - x2 = (FIXED_TO_FLOAT(spr_offset) * spritexscale); + x1 = (FixedToFloat(spr_width - spr_offset) * spritexscale); + x2 = (FixedToFloat(spr_offset) * spritexscale); } else { - x1 = (FIXED_TO_FLOAT(spr_offset) * spritexscale); - x2 = (FIXED_TO_FLOAT(spr_width - spr_offset) * spritexscale); + x1 = (FixedToFloat(spr_offset) * spritexscale); + x2 = (FixedToFloat(spr_width - spr_offset) * spritexscale); } z1 = tr_y + x1 * rightsin; @@ -4841,13 +4835,13 @@ static void HWR_ProjectSprite(mobj_t *thing) if (vflip) { - gz = FIXED_TO_FLOAT(interp.z + thing->height) - (FIXED_TO_FLOAT(spr_topoffset) * spriteyscale); - gzt = gz + (FIXED_TO_FLOAT(spr_height) * spriteyscale); + gz = FixedToFloat(interp.z + thing->height) - (FixedToFloat(spr_topoffset) * spriteyscale); + gzt = gz + (FixedToFloat(spr_height) * spriteyscale); } else { - gzt = FIXED_TO_FLOAT(interp.z) + (FIXED_TO_FLOAT(spr_topoffset) * spriteyscale); - gz = gzt - (FIXED_TO_FLOAT(spr_height) * spriteyscale); + gzt = FixedToFloat(interp.z) + (FixedToFloat(spr_topoffset) * spriteyscale); + gz = gzt - (FixedToFloat(spr_height) * spriteyscale); } if (thing->subsector->sector->cullheight) @@ -4864,13 +4858,13 @@ static void HWR_ProjectSprite(mobj_t *thing) if (heightsec != -1 && phs != -1) // only clip things which are in special sectors { - if (gl_viewz < FIXED_TO_FLOAT(sectors[phs].floorheight) ? - FIXED_TO_FLOAT(interp.z) >= FIXED_TO_FLOAT(sectors[heightsec].floorheight) : - gzt < FIXED_TO_FLOAT(sectors[heightsec].floorheight)) + if (gl_viewz < FixedToFloat(sectors[phs].floorheight) ? + FixedToFloat(interp.z) >= FixedToFloat(sectors[heightsec].floorheight) : + gzt < FixedToFloat(sectors[heightsec].floorheight)) return; - if (gl_viewz > FIXED_TO_FLOAT(sectors[phs].ceilingheight) ? - gzt < FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) && gl_viewz >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) : - FIXED_TO_FLOAT(interp.z) >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight)) + if (gl_viewz > FixedToFloat(sectors[phs].ceilingheight) ? + gzt < FixedToFloat(sectors[heightsec].ceilingheight) && gl_viewz >= FixedToFloat(sectors[heightsec].ceilingheight) : + FixedToFloat(interp.z) >= FixedToFloat(sectors[heightsec].ceilingheight)) return; } @@ -4889,8 +4883,8 @@ static void HWR_ProjectSprite(mobj_t *thing) vis->scale = this_scale; vis->spritexscale = spritexscale; vis->spriteyscale = spriteyscale; - vis->spritexoffset = FIXED_TO_FLOAT(spr_offset); - vis->spriteyoffset = FIXED_TO_FLOAT(spr_topoffset); + vis->spritexoffset = FixedToFloat(spr_offset); + vis->spriteyoffset = FixedToFloat(spr_topoffset); #ifdef ROTSPRITE if (rotsprite != NULL) @@ -4992,8 +4986,8 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) } // transform the origin point - tr_x = FIXED_TO_FLOAT(interp.x); - tr_y = FIXED_TO_FLOAT(interp.y); + tr_x = FixedToFloat(interp.x); + tr_y = FixedToFloat(interp.y); // rotation around vertical axis tz = ((tr_x - gl_viewx) * gl_viewcos) + ((tr_y - gl_viewy) * gl_viewsin); @@ -5025,7 +5019,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) #endif } - this_scale = FIXED_TO_FLOAT(interp.scale); + this_scale = FixedToFloat(interp.scale); sprframe = &sprdef->spriteframes[thing->frame & FF_FRAMEMASK]; @@ -5033,18 +5027,18 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) lumpoff = sprframe->lumpid[0]; flip = sprframe->flip; // Will only be 0x00 or 0xFF - rightsin = FIXED_TO_FLOAT(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); - rightcos = FIXED_TO_FLOAT(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); + rightsin = FixedToFloat(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); + rightcos = FixedToFloat(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); if (flip) { - x1 = FIXED_TO_FLOAT(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset); - x2 = FIXED_TO_FLOAT(spritecachedinfo[lumpoff].offset); + x1 = FixedToFloat(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset); + x2 = FixedToFloat(spritecachedinfo[lumpoff].offset); } else { - x1 = FIXED_TO_FLOAT(spritecachedinfo[lumpoff].offset); - x2 = FIXED_TO_FLOAT(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset); + x1 = FixedToFloat(spritecachedinfo[lumpoff].offset); + x2 = FixedToFloat(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset); } x1 *= this_scale; @@ -5077,8 +5071,8 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) #endif // set top/bottom coords - vis->gzt = FIXED_TO_FLOAT(interp.z) + (FIXED_TO_FLOAT(spritecachedinfo[lumpoff].topoffset) * this_scale); - vis->gz = vis->gzt - (FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height) * this_scale); + vis->gzt = FixedToFloat(interp.z) + (FixedToFloat(spritecachedinfo[lumpoff].topoffset) * this_scale); + vis->gz = vis->gzt - (FixedToFloat(spritecachedinfo[lumpoff].height) * this_scale); vis->precip = true; } @@ -5313,7 +5307,7 @@ static void HWR_SetTransformAiming(FTransform *trans) if (cv_glshearing.value) { fixed_t fixedaiming = AIMINGTODY(aimingangle); - trans->viewaiming = FIXED_TO_FLOAT(fixedaiming); + trans->viewaiming = FixedToFloat(fixedaiming); trans->shearing = true; gl_aimingangle = 0; } @@ -5330,11 +5324,11 @@ void HWR_SetTransform(float fpov) UINT8 viewnum = R_GetViewNumber(); camera_t *thiscam = &camera[viewnum]; - gl_viewx = FIXED_TO_FLOAT(viewx); - gl_viewy = FIXED_TO_FLOAT(viewy); - gl_viewz = FIXED_TO_FLOAT(viewz); - gl_viewsin = FIXED_TO_FLOAT(viewsin); - gl_viewcos = FIXED_TO_FLOAT(viewcos); + gl_viewx = FixedToFloat(viewx); + gl_viewy = FixedToFloat(viewy); + gl_viewz = FixedToFloat(viewz); + gl_viewsin = FixedToFloat(viewsin); + gl_viewcos = FixedToFloat(viewcos); memset(&atransform, 0x00, sizeof(FTransform)); @@ -5350,8 +5344,8 @@ void HWR_SetTransform(float fpov) HWR_SetTransformAiming(&atransform); atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(FINEDEGREE); - gl_viewludsin = FIXED_TO_FLOAT(FINECOSINE(gl_aimingangle>>ANGLETOFINESHIFT)); - gl_viewludcos = FIXED_TO_FLOAT(-FINESINE(gl_aimingangle>>ANGLETOFINESHIFT)); + gl_viewludsin = FixedToFloat(FINECOSINE(gl_aimingangle>>ANGLETOFINESHIFT)); + gl_viewludcos = FixedToFloat(-FINESINE(gl_aimingangle>>ANGLETOFINESHIFT)); atransform.fovangle = fpov; // Tails HWR_RollTransform(&atransform, viewroll); @@ -6003,7 +5997,7 @@ static void HWR_DoPostProcessor(player_t *player) { // 10 by 10 grid. 2 coordinates (xy) float v[SCREENVERTS][SCREENVERTS][2]; - float disStart = (leveltime-1) + FIXED_TO_FLOAT(rendertimefrac); + float disStart = (leveltime-1) + FixedToFloat(rendertimefrac); UINT8 x, y; INT32 WAVELENGTH; diff --git a/src/k_kart.c b/src/k_kart.c index a871f74bc..344c1ace2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3720,7 +3720,8 @@ void K_SpawnBoostTrail(player_t *player) if (player->mo->standingslope) { - ground = P_GetZAt(player->mo->standingslope, newx, newy); + ground = P_GetSlopeZAt(player->mo->standingslope, newx, newy); + if (player->mo->eflags & MFE_VERTICALFLIP) ground -= FixedMul(mobjinfo[MT_SNEAKERTRAIL].height, player->mo->scale); } @@ -4830,12 +4831,7 @@ static fixed_t K_BananaSlopeZ(pslope_t *slope, fixed_t x, fixed_t y, fixed_t z, testy += y; } - if (slope) - { - slopez = P_GetZAt(slope, testx, testy); - } - else - slopez = z; + slopez = P_GetZAt(slope, testx, testy, z); return slopez; } diff --git a/src/lua_baselib.c b/src/lua_baselib.c index f125bbc11..df949149e 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1767,7 +1767,7 @@ static int lib_pGetZAt(lua_State *L) if (!slope) return LUA_ErrInvalid(L, "pslope_t"); - lua_pushfixed(L, P_GetZAt(slope, x, y)); + lua_pushfixed(L, P_GetSlopeZAt(slope, x, y)); return 1; } diff --git a/src/m_cheat.c b/src/m_cheat.c index 5f8648cbd..1cdb57419 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -864,7 +864,7 @@ static boolean OP_HeightOkay(player_t *player, UINT8 ceiling) { // Truncate position to match where mapthing would be when spawned // (this applies to every further P_GetZAt call as well) - fixed_t cheight = sec->c_slope ? P_GetZAt(sec->c_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->ceilingheight; + fixed_t cheight = P_GetSectorCeilingZAt(sec, (player->mo->x & 0xFFFF0000), (player->mo->y & 0xFFFF0000)); if (((cheight - player->mo->z - player->mo->height)>>FRACBITS) >= (1 << (16-ZSHIFT))) { @@ -875,7 +875,8 @@ static boolean OP_HeightOkay(player_t *player, UINT8 ceiling) } else { - fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->floorheight; + fixed_t fheight = P_GetSectorFloorZAt(sec, (player->mo->x & 0xFFFF0000), (player->mo->y & 0xFFFF0000)); + if (((player->mo->z - fheight)>>FRACBITS) >= (1 << (16-ZSHIFT))) { CONS_Printf(M_GetText("Sorry, you're too %s to place this object (max: %d %s).\n"), M_GetText("high"), @@ -922,12 +923,12 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c mt->y = (INT16)(player->mo->y>>FRACBITS); if (ceiling) { - fixed_t cheight = sec->c_slope ? P_GetZAt(sec->c_slope, mt->x << FRACBITS, mt->y << FRACBITS) : sec->ceilingheight; + fixed_t cheight = P_GetSectorCeilingZAt(sec, (mt->x << FRACBITS), (mt->y << FRACBITS)); mt->options = (UINT16)((cheight - player->mo->z - player->mo->height)>>FRACBITS); } else { - fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, mt->x << FRACBITS, mt->y << FRACBITS) : sec->floorheight; + fixed_t fheight = P_GetSectorFloorZAt(sec, (mt->x << FRACBITS), (mt->y << FRACBITS)); mt->options = (UINT16)((player->mo->z - fheight)>>FRACBITS); } mt->options <<= ZSHIFT; @@ -984,8 +985,7 @@ void OP_NightsObjectplace(player_t *player) UINT16 angle = (UINT16)(player->anotherflyangle % 360); INT16 temp = (INT16)FixedInt(AngleFixed(player->mo->angle)); // Traditional 2D Angle sector_t *sec = player->mo->subsector->sector; - fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->floorheight; - + fixed_t fheight = P_GetSectorFloorZAt(sec, (player->mo->x & 0xFFFF0000), (player->mo->y & 0xFFFF0000)); player->pflags |= PF_ATTACKDOWN; @@ -1141,12 +1141,12 @@ void OP_ObjectplaceMovement(player_t *player) if (!!(mobjinfo[op_currentthing].flags & MF_SPAWNCEILING) ^ !!(cv_opflags.value & MTF_OBJECTFLIP)) { - fixed_t cheight = sec->c_slope ? P_GetZAt(sec->c_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->ceilingheight; + fixed_t cheight = P_GetSectorCeilingZAt(sec, (player->mo->x & 0xFFFF0000), (player->mo->y & 0xFFFF0000)); op_displayflags = (UINT16)((cheight - player->mo->z - mobjinfo[op_currentthing].height)>>FRACBITS); } else { - fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->floorheight; + fixed_t fheight = P_GetSectorFloorZAt(sec, (player->mo->x & 0xFFFF0000), (player->mo->y & 0xFFFF0000)); op_displayflags = (UINT16)((player->mo->z - fheight)>>FRACBITS); } op_displayflags <<= ZSHIFT; diff --git a/src/p_map.c b/src/p_map.c index 91b15d8ab..aacbb2e6e 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1699,7 +1699,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) INT32 xl, xh, yl, yh, bx, by; subsector_t *newsubsec; boolean blockval = true; - + ps_checkposition_calls.value.i++; I_Assert(thing != NULL); @@ -4102,10 +4102,7 @@ void P_MapEnd(void) fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) { sector_t *sec = R_PointInSubsector(x, y)->sector; - fixed_t floorz = sec->floorheight; - - if (sec->f_slope) - floorz = P_GetZAt(sec->f_slope, x, y); + fixed_t floorz = P_GetSectorFloorZAt(sec, x, y); // Intercept the stupid 'fall through 3dfloors' bug Tails 03-17-2002 if (sec->ffloors) @@ -4116,19 +4113,15 @@ fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) for (rover = sec->ffloors; rover; rover = rover->next) { fixed_t topheight, bottomheight; + if (!(rover->flags & FF_EXISTS)) continue; if ((!(rover->flags & FF_SOLID || rover->flags & FF_QUICKSAND) || (rover->flags & FF_SWIMMABLE))) continue; - topheight = *rover->topheight; - bottomheight = *rover->bottomheight; - - if (*rover->t_slope) - topheight = P_GetZAt(*rover->t_slope, x, y); - if (*rover->b_slope) - bottomheight = P_GetZAt(*rover->b_slope, x, y); + topheight = P_GetFFloorTopZAt (rover, x, y); + bottomheight = P_GetFFloorBottomZAt(rover, x, y); if (rover->flags & FF_QUICKSAND) { @@ -4142,6 +4135,7 @@ fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) delta1 = z - (bottomheight + ((topheight - bottomheight)/2)); delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2)); + if (topheight > floorz && abs(delta1) < abs(delta2)) floorz = topheight; } diff --git a/src/p_mobj.c b/src/p_mobj.c index fa4d2c099..a743f05fc 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -502,12 +502,12 @@ static fixed_t HighestOnLine(fixed_t radius, fixed_t x, fixed_t y, line_t *line, /*CONS_Printf("BEFORE: v1 = %f %f %f\n", FIXED_TO_FLOAT(v1.x), FIXED_TO_FLOAT(v1.y), - FIXED_TO_FLOAT(P_GetZAt(slope, v1.x, v1.y)) + FIXED_TO_FLOAT(P_GetSlopeZAt(slope, v1.x, v1.y)) ); CONS_Printf(" v2 = %f %f %f\n", FIXED_TO_FLOAT(v2.x), FIXED_TO_FLOAT(v2.y), - FIXED_TO_FLOAT(P_GetZAt(slope, v2.x, v2.y)) + FIXED_TO_FLOAT(P_GetSlopeZAt(slope, v2.x, v2.y)) );*/ if (abs(v1.x-x) > radius) { @@ -565,24 +565,24 @@ static fixed_t HighestOnLine(fixed_t radius, fixed_t x, fixed_t y, line_t *line, /*CONS_Printf("AFTER: v1 = %f %f %f\n", FIXED_TO_FLOAT(v1.x), FIXED_TO_FLOAT(v1.y), - FIXED_TO_FLOAT(P_GetZAt(slope, v1.x, v1.y)) + FIXED_TO_FLOAT(P_GetSlopeZAt(slope, v1.x, v1.y)) ); CONS_Printf(" v2 = %f %f %f\n", FIXED_TO_FLOAT(v2.x), FIXED_TO_FLOAT(v2.y), - FIXED_TO_FLOAT(P_GetZAt(slope, v2.x, v2.y)) + FIXED_TO_FLOAT(P_GetSlopeZAt(slope, v2.x, v2.y)) );*/ // Return the higher of the two points if (actuallylowest) return min( - P_GetZAt(slope, v1.x, v1.y), - P_GetZAt(slope, v2.x, v2.y) + P_GetSlopeZAt(slope, v1.x, v1.y), + P_GetSlopeZAt(slope, v2.x, v2.y) ); else return max( - P_GetZAt(slope, v1.x, v1.y), - P_GetZAt(slope, v2.x, v2.y) + P_GetSlopeZAt(slope, v1.x, v1.y), + P_GetSlopeZAt(slope, v2.x, v2.y) ); } @@ -618,7 +618,7 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t // If the highest point is in the sector, then we have it easy! Just get the Z at that point if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) - return P_GetZAt(slope, testx, testy); + return P_GetSlopeZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point if (perfect) @@ -657,7 +657,7 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t // If we're just testing for base sector location (no collision line), just go for the center's spot... // It'll get fixed when we test for collision anyway, and the final result can't be lower than this if (line == NULL) - return P_GetZAt(slope, x, y); + return P_GetSlopeZAt(slope, x, y); return HighestOnLine(mobj->radius, x, y, line, slope, lowest); } @@ -697,7 +697,7 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed // If the highest point is in the sector, then we have it easy! Just get the Z at that point if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) - return P_GetZAt(slope, testx, testy); + return P_GetSlopeZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point if (perfect) @@ -736,7 +736,7 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed // If we're just testing for base sector location (no collision line), just go for the center's spot... // It'll get fixed when we test for collision anyway, and the final result can't be lower than this if (line == NULL) - return P_GetZAt(slope, x, y); + return P_GetSlopeZAt(slope, x, y); return HighestOnLine(mobj->radius, x, y, line, slope, lowest); } @@ -777,7 +777,7 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix // If the highest point is in the sector, then we have it easy! Just get the Z at that point if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) - return P_GetZAt(slope, testx, testy); + return P_GetSlopeZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point if (perfect) @@ -816,7 +816,7 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix // If we're just testing for base sector location (no collision line), just go for the center's spot... // It'll get fixed when we test for collision anyway, and the final result can't be lower than this if (line == NULL) - return P_GetZAt(slope, x, y); + return P_GetSlopeZAt(slope, x, y); return HighestOnLine(mobj->radius, x, y, line, slope, lowest); } @@ -856,7 +856,7 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f // If the highest point is in the sector, then we have it easy! Just get the Z at that point if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) - return P_GetZAt(slope, testx, testy); + return P_GetSlopeZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point if (perfect) @@ -895,7 +895,7 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f // If we're just testing for base sector location (no collision line), just go for the center's spot... // It'll get fixed when we test for collision anyway, and the final result can't be lower than this if (line == NULL) - return P_GetZAt(slope, x, y); + return P_GetSlopeZAt(slope, x, y); return HighestOnLine(mobj->radius, x, y, line, slope, lowest); } @@ -1918,9 +1918,7 @@ boolean P_CheckSolidLava(mobj_t *mo, ffloor_t *rover) I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); - fixed_t topheight = - *rover->t_slope ? P_GetZAt(*rover->t_slope, mo->x, mo->y) : - *rover->topheight; + fixed_t topheight = P_GetFFloorTopZAt(rover, mo->x, mo->y); if (rover->flags & FF_SWIMMABLE && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3 && !(rover->master->flags & ML_BLOCKMONSTERS) @@ -2887,14 +2885,8 @@ void P_MobjCheckWater(mobj_t *mobj) || ((rover->flags & FF_BLOCKOTHERS) && !mobj->player))) continue; - topheight = *rover->topheight; - bottomheight = *rover->bottomheight; - - if (*rover->t_slope) - topheight = P_GetZAt(*rover->t_slope, mobj->x, mobj->y); - - if (*rover->b_slope) - bottomheight = P_GetZAt(*rover->b_slope, mobj->x, mobj->y); + topheight = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); + bottomheight = P_GetFFloorBottomZAt(rover, mobj->x, mobj->y); if (mobj->eflags & MFE_VERTICALFLIP) { @@ -3112,14 +3104,8 @@ static void P_SceneryCheckWater(mobj_t *mobj) if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || rover->flags & FF_BLOCKOTHERS) continue; - topheight = *rover->topheight; - bottomheight = *rover->bottomheight; - - if (*rover->t_slope) - topheight = P_GetZAt(*rover->t_slope, mobj->x, mobj->y); - - if (*rover->b_slope) - bottomheight = P_GetZAt(*rover->b_slope, mobj->x, mobj->y); + topheight = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); + bottomheight = P_GetFFloorBottomZAt(rover, mobj->x, mobj->y); if (topheight <= mobj->z || bottomheight > (mobj->z + FixedMul(mobj->info->height >> 1, mobj->scale))) @@ -9471,12 +9457,8 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) // Make sure scale matches destscale immediately when spawned P_SetScale(mobj, mobj->destscale); - mobj->floorz = - mobj->subsector->sector->f_slope ? P_GetZAt(mobj->subsector->sector->f_slope, x, y) : - mobj->subsector->sector->floorheight; - mobj->ceilingz = - mobj->subsector->sector->c_slope ? P_GetZAt(mobj->subsector->sector->c_slope, x, y) : - mobj->subsector->sector->ceilingheight; + mobj->floorz = P_GetSectorFloorZAt(mobj->subsector->sector, x, y); + mobj->ceilingz = P_GetSectorCeilingZAt(mobj->subsector->sector, x, y); // Tells MobjCheckWater that the water height was not set. mobj->watertop = INT32_MAX; @@ -10542,9 +10524,8 @@ void P_RespawnSpecials(void) if (mthing->options & MTF_OBJECTFLIP) { - z = ( - ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) : - ss->sector->ceilingheight) - (mthing->options >> ZSHIFT) * FRACUNIT; + z = P_GetSectorCeilingZAt(ss->sector, x, y) - (mthing->options >> ZSHIFT) * FRACUNIT; + if (mthing->options & MTF_AMBUSH && (i == MT_RING || i == MT_REDTEAMRING || i == MT_BLUETEAMRING || i == MT_COIN || P_WeaponOrPanel(i))) z -= 24*FRACUNIT; @@ -10552,9 +10533,8 @@ void P_RespawnSpecials(void) } else { - z = ( - ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) : - ss->sector->floorheight) + (mthing->options >> ZSHIFT) * FRACUNIT; + z = P_GetSectorFloorZAt(ss->sector, x, y) + (mthing->options >> ZSHIFT) * FRACUNIT; + if (mthing->options & MTF_AMBUSH && (i == MT_RING || i == MT_REDTEAMRING || i == MT_BLUETEAMRING || i == MT_COIN || P_WeaponOrPanel(i))) z += 24*FRACUNIT; @@ -10853,14 +10833,9 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing) //spawn at the origin as a desperation move if there is no mapthing // set Z height - sector = R_PointInSubsector(x, y)->sector; - - floor = - sector->f_slope ? P_GetZAt(sector->f_slope, x, y) : - sector->floorheight; - ceiling = - sector->c_slope ? P_GetZAt(sector->c_slope, x, y) : - sector->ceilingheight; + sector = R_PointInSubsector(x, y)->sector; + floor = P_GetSectorFloorZAt(sector, x, y); + ceiling = P_GetSectorCeilingZAt(sector, x, y); if (mthing) { @@ -10928,14 +10903,11 @@ void P_MovePlayerToStarpost(INT32 playernum) mobj->x = p->starpostx << FRACBITS; mobj->y = p->starposty << FRACBITS; P_SetThingPosition(mobj); - sector = R_PointInSubsector(mobj->x, mobj->y)->sector; - floor = - sector->f_slope ? P_GetZAt(sector->f_slope, mobj->x, mobj->y) : - sector->floorheight; - ceiling = - sector->c_slope ? P_GetZAt(sector->c_slope, mobj->x, mobj->y) : - sector->ceilingheight; + // set Z height + sector = R_PointInSubsector(mobj->x, mobj->y)->sector; + floor = P_GetSectorFloorZAt(sector, mobj->x, mobj->y); + ceiling = P_GetSectorCeilingZAt(sector, mobj->x, mobj->y); if (mobj->player->kartstuff[k_starpostflip]) z = (p->starpostz<height; @@ -11107,10 +11079,8 @@ void P_SpawnMapThing(mapthing_t *mthing) if (gametype != GT_COOP) return; - ss = R_PointInSubsector(mthing->x << FRACBITS, mthing->y << FRACBITS); - mthing->z = (INT16)((( - ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, mthing->x << FRACBITS, mthing->y << FRACBITS) : - ss->sector->floorheight)>>FRACBITS) + (mthing->options >> ZSHIFT)); + ss = R_PointInSubsector((mthing->x << FRACBITS), (mthing->y << FRACBITS)); + mthing->z = (INT16)((P_GetSectorFloorZAt(ss->sector, (mthing->x << FRACBITS), (mthing->y << FRACBITS)) >> FRACBITS) + (mthing->options >> ZSHIFT)); if (numhuntemeralds < MAXHUNTEMERALDS) huntemeralds[numhuntemeralds++] = mthing; @@ -11224,18 +11194,14 @@ void P_SpawnMapThing(mapthing_t *mthing) ss = R_PointInSubsector(x, y); if (i == MT_NIGHTSBUMPER) - z = ( - ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) : - ss->sector->floorheight) + ((mthing->options >> ZSHIFT) << FRACBITS); + z = P_GetSectorFloorZAt(ss->sector, x, y) + ((mthing->options >> ZSHIFT) << FRACBITS); else if (i == MT_AXIS || i == MT_AXISTRANSFER || i == MT_AXISTRANSFERLINE) z = ONFLOORZ; else if (i == MT_SPECIALSPIKEBALL || P_WeaponOrPanel(i) || i == MT_EMERALDSPAWN || i == MT_EMMY) { if (mthing->options & MTF_OBJECTFLIP) { - z = ( - ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) : - ss->sector->ceilingheight); + z = P_GetSectorCeilingZAt(ss->sector, x, y); if (mthing->options & MTF_AMBUSH) // Special flag for rings z -= 24*FRACUNIT; @@ -11246,9 +11212,7 @@ void P_SpawnMapThing(mapthing_t *mthing) } else { - z = ( - ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) : - ss->sector->floorheight); + z = P_GetSectorFloorZAt(ss->sector, x, y); if (mthing->options & MTF_AMBUSH) // Special flag for rings z += 24*FRACUNIT; @@ -11268,13 +11232,9 @@ void P_SpawnMapThing(mapthing_t *mthing) // base positions if (flip) - z = ( - ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) : - ss->sector->ceilingheight) - mobjinfo[i].height; + z = P_GetSectorCeilingZAt(ss->sector, x, y) - mobjinfo[i].height; else - z = ( - ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) : - ss->sector->floorheight); + z = P_GetSectorFloorZAt(ss->sector, x, y); // offsetting if (mthing->options >> ZSHIFT) @@ -11847,9 +11807,7 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) hoopcenter = P_SpawnMobj(x, y, z, MT_HOOPCENTER); hoopcenter->spawnpoint = mthing; - z += - sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : - sec->floorheight; + z += P_GetSectorFloorZAt(sec, x, y); hoopcenter->z = z - hoopcenter->height/2; @@ -11980,9 +11938,7 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) hoopcenter = P_SpawnMobj(x, y, z, MT_HOOPCENTER); hoopcenter->spawnpoint = mthing; - z += - sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : - sec->floorheight; + z += P_GetSectorFloorZAt(sec, x, y); hoopcenter->z = z - hoopcenter->height/2; P_UnsetThingPosition(hoopcenter); diff --git a/src/p_setup.c b/src/p_setup.c index e6e46edd6..5d13df8b5 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1009,14 +1009,13 @@ static void P_LoadThings(void) mt = mapthings; numhuntemeralds = 0; + for (i = 0; i < nummapthings; i++, mt++) { - sector_t *mtsector = R_PointInSubsector(mt->x << FRACBITS, mt->y << FRACBITS)->sector; + sector_t *mtsector = R_PointInSubsector((mt->x << FRACBITS), (mt->y << FRACBITS))->sector; // Z for objects - mt->z = (INT16)( - mtsector->f_slope ? P_GetZAt(mtsector->f_slope, mt->x << FRACBITS, mt->y << FRACBITS) : - mtsector->floorheight)>>FRACBITS; + mt->z = (INT16)(P_GetSectorFloorZAt(mtsector, (mt->x << FRACBITS), (mt->y << FRACBITS))) >> FRACBITS; if (mt->type == 1700 // MT_AXIS || mt->type == 1701 // MT_AXISTRANSFER diff --git a/src/p_slopes.c b/src/p_slopes.c index 81d8c54e3..ed6c8019b 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -412,7 +412,7 @@ void P_SpawnSlope_Line(int linenum) fslope->sourceline = line; // To find the real highz/lowz of a slope, you need to check all the vertexes - // in the slope's sector with P_GetZAt to get the REAL lowz & highz + // in the slope's sector with P_GetSlopeZAt to get the REAL lowz & highz // Although these slopes are set by floorheights the ANGLE is what a slope is, // so technically any slope can extend on forever (they are just bound by sectors) // *You can use sourceline as a reference to see if two slopes really are the same @@ -426,7 +426,7 @@ void P_SpawnSlope_Line(int linenum) for (l = 0; l < line->frontsector->linecount; l++) { - fixed_t height = P_GetZAt(line->frontsector->f_slope, line->frontsector->lines[l]->v1->x, line->frontsector->lines[l]->v1->y); + fixed_t height = P_GetSlopeZAt(line->frontsector->f_slope, line->frontsector->lines[l]->v1->x, line->frontsector->lines[l]->v1->y); if (height > highest) highest = height; @@ -473,7 +473,7 @@ void P_SpawnSlope_Line(int linenum) for (l = 0; l < line->frontsector->linecount; l++) { - fixed_t height = P_GetZAt(line->frontsector->c_slope, line->frontsector->lines[l]->v1->x, line->frontsector->lines[l]->v1->y); + fixed_t height = P_GetSlopeZAt(line->frontsector->c_slope, line->frontsector->lines[l]->v1->x, line->frontsector->lines[l]->v1->y); if (height > highest) highest = height; @@ -542,7 +542,7 @@ void P_SpawnSlope_Line(int linenum) for (l = 0; l < line->backsector->linecount; l++) { - fixed_t height = P_GetZAt(line->backsector->f_slope, line->backsector->lines[l]->v1->x, line->backsector->lines[l]->v1->y); + fixed_t height = P_GetSlopeZAt(line->backsector->f_slope, line->backsector->lines[l]->v1->x, line->backsector->lines[l]->v1->y); if (height > highest) highest = height; @@ -589,7 +589,7 @@ void P_SpawnSlope_Line(int linenum) for (l = 0; l < line->backsector->linecount; l++) { - fixed_t height = P_GetZAt(line->backsector->c_slope, line->backsector->lines[l]->v1->x, line->backsector->lines[l]->v1->y); + fixed_t height = P_GetSlopeZAt(line->backsector->c_slope, line->backsector->lines[l]->v1->x, line->backsector->lines[l]->v1->y); if (height > highest) highest = height; diff --git a/src/p_slopes.h b/src/p_slopes.h index 89cfdc343..40502a5ea 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -40,39 +40,44 @@ extern pslope_t *slopelist; // // Returns the height of the sloped plane at (x, y) as a fixed_t -FUNCINLINE static ATTRINLINE fixed_t P_GetZAt(pslope_t *z_slope, fixed_t x, fixed_t y) +FUNCINLINE static ATTRINLINE fixed_t P_GetSlopeZAt(const pslope_t *z_slope, fixed_t x, fixed_t y) { return z_slope->o.z + FixedMul((FixedMul(x - z_slope->o.x, z_slope->d.x) + FixedMul(y - z_slope->o.y, z_slope->d.y)), z_slope->zdelta); } +// Like P_GetSlopeZAt but falls back to z if slope is NULL +FUNCINLINE static ATTRINLINE fixed_t P_GetZAt(const pslope_t *slope, fixed_t x, fixed_t y, fixed_t z) +{ + return slope ? P_GetSlopeZAt(slope, x, y) : z; +} // Returns the height of the sector floor at (x, y) FUNCINLINE static ATTRINLINE fixed_t P_GetSectorFloorZAt(const sector_t *z_sector, fixed_t x, fixed_t y) { - return z_sector->f_slope ? P_GetZAt(z_sector->f_slope, x, y) : z_sector->floorheight; + return z_sector->f_slope ? P_GetSlopeZAt(z_sector->f_slope, x, y) : z_sector->floorheight; } // Returns the height of the sector ceiling at (x, y) FUNCINLINE static ATTRINLINE fixed_t P_GetSectorCeilingZAt(const sector_t *z_sector, fixed_t x, fixed_t y) { - return z_sector->c_slope ? P_GetZAt(z_sector->c_slope, x, y) : z_sector->ceilingheight; + return z_sector->c_slope ? P_GetSlopeZAt(z_sector->c_slope, x, y) : z_sector->ceilingheight; } // Returns the height of the FOF top at (x, y) FUNCINLINE static ATTRINLINE fixed_t P_GetFFloorTopZAt(const ffloor_t *z_ffloor, fixed_t x, fixed_t y) { - return *z_ffloor->t_slope ? P_GetZAt(*z_ffloor->t_slope, x, y) : *z_ffloor->topheight; + return *z_ffloor->t_slope ? P_GetSlopeZAt(*z_ffloor->t_slope, x, y) : *z_ffloor->topheight; } // Returns the height of the FOF bottom at (x, y) FUNCINLINE static ATTRINLINE fixed_t P_GetFFloorBottomZAt(const ffloor_t *z_ffloor, fixed_t x, fixed_t y) { - return *z_ffloor->b_slope ? P_GetZAt(*z_ffloor->b_slope, x, y) : *z_ffloor->bottomheight; + return *z_ffloor->b_slope ? P_GetSlopeZAt(*z_ffloor->b_slope, x, y) : *z_ffloor->bottomheight; } // Returns the height of the light list at (x, y) FUNCINLINE static ATTRINLINE fixed_t P_GetLightZAt(const lightlist_t *z_light, fixed_t x, fixed_t y) { - return z_light->slope ? P_GetZAt(z_light->slope, x, y) : z_light->height; + return z_light->slope ? P_GetSlopeZAt(z_light->slope, x, y) : z_light->height; } // Lots of physics-based bullshit diff --git a/src/p_spec.c b/src/p_spec.c index 42345e6dd..670289fcf 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5125,11 +5125,10 @@ void T_LaserFlash(laserthink_t *flash) sourcesec = ffloor->master->frontsector; // Less to type! - top = (*ffloor->t_slope) ? P_GetZAt(*ffloor->t_slope, sector->soundorg.x, sector->soundorg.y) - : *ffloor->topheight; - bottom = (*ffloor->b_slope) ? P_GetZAt(*ffloor->b_slope, sector->soundorg.x, sector->soundorg.y) - : *ffloor->bottomheight; + top = P_GetFFloorTopZAt (ffloor, sector->soundorg.x, sector->soundorg.y); + bottom = P_GetFFloorBottomZAt(ffloor, sector->soundorg.x, sector->soundorg.y); sector->soundorg.z = (top + bottom)/2; + S_StartSound(§or->soundorg, sfx_laser); // Seek out objects to DESTROY! MUAHAHHAHAHAA!!!*cough* @@ -6765,10 +6764,7 @@ void T_Disappear(disappear_t *d) if (!(lines[d->sourceline].flags & ML_NOCLIMB)) { - if (*rover->t_slope) - sectors[s].soundorg.z = P_GetZAt(*rover->t_slope, sectors[s].soundorg.x, sectors[s].soundorg.y); - else - sectors[s].soundorg.z = *rover->topheight; + sectors[s].soundorg.z = P_GetFFloorTopZAt(rover, sectors[s].soundorg.x, sectors[s].soundorg.y); S_StartSound(§ors[s].soundorg, sfx_appear); } } diff --git a/src/p_user.c b/src/p_user.c index 1747a84a1..536ebc771 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1317,8 +1317,9 @@ boolean P_InSpaceSector(mobj_t *mo) // Returns true if you are in space if (GETSECSPECIAL(rover->master->frontsector->special, 1) != SPACESPECIAL) continue; - topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, mo->x, mo->y) : *rover->topheight; - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, mo->x, mo->y) : *rover->bottomheight; + + topheight = P_GetFFloorTopZAt(rover, mo->x, mo->y); + bottomheight = P_GetFFloorBottomZAt(rover, mo->x, mo->y); if (mo->z + (mo->height/2) > topheight) continue; @@ -1352,8 +1353,8 @@ boolean P_InQuicksand(mobj_t *mo) // Returns true if you are in quicksand if (!(rover->flags & FF_QUICKSAND)) continue; - topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, mo->x, mo->y) : *rover->topheight; - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, mo->x, mo->y) : *rover->bottomheight; + topheight = P_GetFFloorTopZAt(rover, mo->x, mo->y); + bottomheight = P_GetFFloorBottomZAt(rover, mo->x, mo->y); if (mo->z + flipoffset > topheight) continue; @@ -1644,8 +1645,8 @@ static void P_CheckQuicksand(player_t *player) if (!(rover->flags & FF_QUICKSAND)) continue; - topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; + topheight = P_GetFFloorTopZAt(rover, player->mo->x, player->mo->y); + bottomheight = P_GetFFloorBottomZAt(rover, player->mo->x, player->mo->y); if (topheight >= player->mo->z && bottomheight < player->mo->z + player->mo->height) { @@ -2133,12 +2134,16 @@ static void P_SpectatorMovement(player_t *player) void P_BlackOw(player_t *player) { INT32 i; - S_StartSound (player->mo, sfx_bkpoof); // Sound the BANG! + S_StartSound(player->mo, sfx_bkpoof); // Sound the BANG! for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && P_AproxDistance(player->mo->x - players[i].mo->x, - player->mo->y - players[i].mo->y) < 1536*FRACUNIT) + { + if (!playeringame[i]) + continue; + + if (P_AproxDistance(player->mo->x - players[i].mo->x, player->mo->y - players[i].mo->y) < 1536*FRACUNIT) P_FlashPal(&players[i], PAL_NUKE, 10); + } P_NukeEnemies(player->mo, player->mo, 1536*FRACUNIT); // Search for all nearby enemies and nuke their pants off! player->powers[pw_shield] = player->powers[pw_shield] & SH_STACK; @@ -2168,12 +2173,15 @@ void P_ElementalFireTrail(player_t *player) { newx = player->mo->x + P_ReturnThrustX(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale)); newy = player->mo->y + P_ReturnThrustY(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale)); + if (player->mo->standingslope) { - ground = P_GetZAt(player->mo->standingslope, newx, newy); + ground = P_GetSlopeZAt(player->mo->standingslope, newx, newy); + if (player->mo->eflags & MFE_VERTICALFLIP) ground -= FixedMul(mobjinfo[MT_SPINFIRE].height, player->mo->scale); } + flame = P_SpawnMobj(newx, newy, ground, MT_SPINFIRE); P_SetTarget(&flame->target, player->mo); flame->angle = travelangle; @@ -2184,6 +2192,7 @@ void P_ElementalFireTrail(player_t *player) flame->momx = 8; P_XYMovement(flame); + if (P_MobjWasRemoved(flame)) continue; diff --git a/src/r_bsp.c b/src/r_bsp.c index 278bafb82..e2e878078 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -482,11 +482,8 @@ static void R_AddLine(seg_t *line) if (frontsector->f_slope || frontsector->c_slope || backsector->f_slope || backsector->c_slope) { #define SLOPEPARAMS(slope, end1, end2, normalheight) \ - if (slope) { \ - end1 = P_GetZAt(slope, line->v1->x, line->v1->y); \ - end2 = P_GetZAt(slope, line->v2->x, line->v2->y); \ - } else \ - end1 = end2 = normalheight; + end1 = P_GetZAt(slope, line->v1->x, line->v1->y, normalheight); \ + end2 = P_GetZAt(slope, line->v2->x, line->v2->y, normalheight); SLOPEPARAMS(frontsector->f_slope, frontf1, frontf2, frontsector->floorheight) SLOPEPARAMS(frontsector->c_slope, frontc1, frontc2, frontsector->ceilingheight) @@ -849,13 +846,8 @@ static void R_Subsector(size_t num) floorcolormap = ceilingcolormap = frontsector->extra_colormap; - floorcenterz = - frontsector->f_slope ? P_GetZAt(frontsector->f_slope, frontsector->soundorg.x, frontsector->soundorg.y) : - frontsector->floorheight; - - ceilingcenterz = - frontsector->c_slope ? P_GetZAt(frontsector->c_slope, frontsector->soundorg.x, frontsector->soundorg.y) : - frontsector->ceilingheight; + floorcenterz = P_GetSectorFloorZAt(frontsector, frontsector->soundorg.x, frontsector->soundorg.y); + ceilingcenterz = P_GetSectorCeilingZAt(frontsector, frontsector->soundorg.x, frontsector->soundorg.y); // Check and prep all 3D floors. Set the sector floor/ceiling light levels and colormaps. if (frontsector->ffloors) @@ -900,9 +892,7 @@ static void R_Subsector(size_t num) sub->sector->extra_colormap = frontsector->extra_colormap; - if ((( - frontsector->f_slope ? P_GetZAt(frontsector->f_slope, viewx, viewy) : - frontsector->floorheight) < viewz || (frontsector->heightsec != -1 + if ((P_GetSectorFloorZAt(frontsector, viewx, viewy) < viewz || (frontsector->heightsec != -1 && sectors[frontsector->heightsec].ceilingpic == skyflatnum))) { floorplane = R_FindPlane(frontsector->floorheight, frontsector->floorpic, floorlightlevel, @@ -914,9 +904,7 @@ static void R_Subsector(size_t num) else floorplane = NULL; - if ((( - frontsector->c_slope ? P_GetZAt(frontsector->c_slope, viewx, viewy) : - frontsector->ceilingheight) > viewz || frontsector->ceilingpic == skyflatnum + if ((P_GetSectorCeilingZAt(frontsector, viewx, viewy) > viewz || frontsector->ceilingpic == skyflatnum || (frontsector->heightsec != -1 && sectors[frontsector->heightsec].floorpic == skyflatnum))) { @@ -934,6 +922,7 @@ static void R_Subsector(size_t num) ffloor[numffloors].slope = NULL; ffloor[numffloors].plane = NULL; ffloor[numffloors].polyobj = NULL; + if (frontsector->ffloors) { fixed_t heightcheck, planecenterz; @@ -955,13 +944,9 @@ static void R_Subsector(size_t num) ffloor[numffloors].plane = NULL; ffloor[numffloors].polyobj = NULL; - heightcheck = - *rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) : - *rover->bottomheight; + heightcheck = P_GetFFloorBottomZAt(rover, viewx, viewy); + planecenterz = P_GetFFloorBottomZAt(rover, frontsector->soundorg.x, frontsector->soundorg.y); - planecenterz = - *rover->b_slope ? P_GetZAt(*rover->b_slope, frontsector->soundorg.x, frontsector->soundorg.y) : - *rover->bottomheight; if (planecenterz <= ceilingcenterz && planecenterz >= floorcenterz && ((viewz < heightcheck && !(rover->flags & FF_INVERTPLANES)) @@ -987,18 +972,16 @@ static void R_Subsector(size_t num) ffloor[numffloors].ffloor = rover; numffloors++; } + if (numffloors >= MAXFFLOORS) break; + ffloor[numffloors].plane = NULL; ffloor[numffloors].polyobj = NULL; - heightcheck = - *rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) : - *rover->topheight; + heightcheck = P_GetFFloorTopZAt(rover, viewx, viewy); + planecenterz = P_GetFFloorTopZAt(rover, frontsector->soundorg.x, frontsector->soundorg.y); - planecenterz = - *rover->t_slope ? P_GetZAt(*rover->t_slope, frontsector->soundorg.x, frontsector->soundorg.y) : - *rover->topheight; if (planecenterz >= floorcenterz && planecenterz <= ceilingcenterz && ((viewz > heightcheck && !(rover->flags & FF_INVERTPLANES)) @@ -1166,7 +1149,7 @@ void R_Prep3DFloors(sector_t *sector) else memset(sector->lightlist, 0, sizeof (lightlist_t) * count); - heighttest = sector->c_slope ? P_GetZAt(sector->c_slope, sector->soundorg.x, sector->soundorg.y) : sector->ceilingheight; + heighttest = P_GetSectorCeilingZAt(sector, sector->soundorg.x, sector->soundorg.y); sector->lightlist[0].height = heighttest + 1; sector->lightlist[0].slope = sector->c_slope; @@ -1187,7 +1170,7 @@ void R_Prep3DFloors(sector_t *sector) && !(rover->flags & FF_CUTLEVEL) && !(rover->flags & FF_CUTSPRITES))) continue; - heighttest = *rover->t_slope ? P_GetZAt(*rover->t_slope, sector->soundorg.x, sector->soundorg.y) : *rover->topheight; + heighttest = P_GetFFloorTopZAt(rover, sector->soundorg.x, sector->soundorg.y); if (heighttest > bestheight && heighttest < maxheight) { @@ -1196,8 +1179,9 @@ void R_Prep3DFloors(sector_t *sector) bestslope = *rover->t_slope; continue; } - if (rover->flags & FF_DOUBLESHADOW) { - heighttest = *rover->b_slope ? P_GetZAt(*rover->b_slope, sector->soundorg.x, sector->soundorg.y) : *rover->bottomheight; + if (rover->flags & FF_DOUBLESHADOW) + { + heighttest = P_GetFFloorBottomZAt(rover, sector->soundorg.x, sector->soundorg.y); if (heighttest > bestheight && heighttest < maxheight) @@ -1221,6 +1205,7 @@ void R_Prep3DFloors(sector_t *sector) sector->lightlist[i].slope = bestslope; sec = §ors[best->secnum]; mapnum = sec->midmap; + if (mapnum >= 0 && (size_t)mapnum < num_extra_colormaps) sec->extra_colormap = &extra_colormaps[mapnum]; else @@ -1244,7 +1229,8 @@ void R_Prep3DFloors(sector_t *sector) if (best->flags & FF_DOUBLESHADOW) { - heighttest = *best->b_slope ? P_GetZAt(*best->b_slope, sector->soundorg.x, sector->soundorg.y) : *best->bottomheight; + heighttest = P_GetFFloorBottomZAt(best, sector->soundorg.x, sector->soundorg.y); + if (bestheight == heighttest) ///TODO: do this in a more efficient way -Red { sector->lightlist[i].lightlevel = sector->lightlist[best->lastlight].lightlevel; diff --git a/src/r_plane.c b/src/r_plane.c index 807baca5c..d4e9c92ff 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -697,7 +697,7 @@ void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planev vy = FIXED_TO_FLOAT(planeviewy-planeyoffset); vz = FIXED_TO_FLOAT(planeviewz); - temp = P_GetZAt(slope, planeviewx, planeviewy); + temp = P_GetSlopeZAt(slope, planeviewx, planeviewy); zeroheight = FIXED_TO_FLOAT(temp); // p is the texture origin in view space @@ -706,7 +706,7 @@ void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planev ang = ANG2RAD(ANGLE_270 - planeviewangle); p.x = vx * cos(ang) - vy * sin(ang); p.z = vx * sin(ang) + vy * cos(ang); - temp = P_GetZAt(slope, -planexoffset, planeyoffset); + temp = P_GetSlopeZAt(slope, -planexoffset, planeyoffset); p.y = FIXED_TO_FLOAT(temp) - vz; // m is the v direction vector in view space @@ -719,9 +719,9 @@ void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planev n.z = -xscale * cos(ang); ang = ANG2RAD(planeangle); - temp = P_GetZAt(slope, planeviewx + FLOAT_TO_FIXED(yscale * sin(ang)), planeviewy + FLOAT_TO_FIXED(yscale * cos(ang))); + temp = P_GetSlopeZAt(slope, planeviewx + FLOAT_TO_FIXED(yscale * sin(ang)), planeviewy + FLOAT_TO_FIXED(yscale * cos(ang))); m.y = FIXED_TO_FLOAT(temp) - zeroheight; - temp = P_GetZAt(slope, planeviewx + FLOAT_TO_FIXED(xscale * cos(ang)), planeviewy - FLOAT_TO_FIXED(xscale * sin(ang))); + temp = P_GetSlopeZAt(slope, planeviewx + FLOAT_TO_FIXED(xscale * cos(ang)), planeviewy - FLOAT_TO_FIXED(xscale * sin(ang))); n.y = FIXED_TO_FLOAT(temp) - zeroheight; m.x /= fudge; @@ -1054,7 +1054,7 @@ void R_DrawSinglePlane(visplane_t *pl) #ifndef NOWATER if (planeripple.active) { - fixed_t plheight = abs(P_GetZAt(pl->slope, pl->viewx, pl->viewy) - pl->viewz); + fixed_t plheight = abs(P_GetSlopeZAt(pl->slope, pl->viewx, pl->viewy) - pl->viewz); R_PlaneBounds(pl); diff --git a/src/r_segs.c b/src/r_segs.c index 2b0700e4d..a1d3b626e 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -389,11 +389,9 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) fixed_t leftheight, rightheight; light = &frontsector->lightlist[i]; rlight = &dc_lightlist[i]; - if (light->slope) { - leftheight = P_GetZAt(light->slope, ds->leftpos.x, ds->leftpos.y); - rightheight = P_GetZAt(light->slope, ds->rightpos.x, ds->rightpos.y); - } else - leftheight = rightheight = light->height; + + leftheight = P_GetLightZAt(light, ds-> leftpos.x, ds-> leftpos.y); + rightheight = P_GetLightZAt(light, ds->rightpos.x, ds->rightpos.y); leftheight -= viewz; rightheight -= viewz; @@ -401,8 +399,6 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) rlight->height = (centeryfrac) - FixedMul(leftheight, ds->scale1); rlight->heightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2); rlight->heightstep = (rlight->heightstep-rlight->height)/(range); - //if (x1 > ds->x1) - //rlight->height -= (x1 - ds->x1)*rlight->heightstep; rlight->startheight = rlight->height; // keep starting value here to reset for each repeat rlight->lightlevel = *light->lightlevel; rlight->extra_colormap = light->extra_colormap; @@ -762,11 +758,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) rlight = &dc_lightlist[p]; #define SLOPEPARAMS(slope, end1, end2, normalheight) \ - if (slope) { \ - end1 = P_GetZAt(slope, ds->leftpos.x, ds->leftpos.y); \ - end2 = P_GetZAt(slope, ds->rightpos.x, ds->rightpos.y); \ - } else \ - end1 = end2 = normalheight; + end1 = P_GetZAt(slope, ds->leftpos.x, ds->leftpos.y, normalheight); \ + end2 = P_GetZAt(slope, ds->rightpos.x, ds->rightpos.y, normalheight); SLOPEPARAMS(light->slope, leftheight, rightheight, light->height) SLOPEPARAMS(*pfloor->b_slope, pfloorleft, pfloorright, *pfloor->bottomheight) @@ -779,8 +772,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (leftheight > pfloorleft && rightheight > pfloorright && i+1 < dc_numlights) { lightlist_t *nextlight = &frontsector->lightlist[i+1]; - if ((nextlight->slope ? P_GetZAt(nextlight->slope, ds->leftpos.x, ds->leftpos.y) : nextlight->height) > pfloorleft - && (nextlight->slope ? P_GetZAt(nextlight->slope, ds->rightpos.x, ds->rightpos.y) : nextlight->height) > pfloorright) + if ((P_GetLightZAt(nextlight, ds->leftpos.x, ds->leftpos.y) > pfloorleft) + && (P_GetLightZAt(nextlight, ds->rightpos.x, ds->rightpos.y) > pfloorright)) continue; } @@ -873,16 +866,11 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) dc_texheight = textureheight[texnum]>>FRACBITS; // calculate both left ends - if (*pfloor->t_slope) - left_top = P_GetZAt(*pfloor->t_slope, ds->leftpos.x, ds->leftpos.y) - viewz; - else - left_top = *pfloor->topheight - viewz; + left_top = P_GetFFloorTopZAt (pfloor, ds->leftpos.x, ds->leftpos.y) - viewz; + left_bottom = P_GetFFloorBottomZAt(pfloor, ds->leftpos.x, ds->leftpos.y) - viewz; - if (*pfloor->b_slope) - left_bottom = P_GetZAt(*pfloor->b_slope, ds->leftpos.x, ds->leftpos.y) - viewz; - else - left_bottom = *pfloor->bottomheight - viewz; skewslope = *pfloor->t_slope; // skew using top slope by default + if (newline) { if (newline->flags & ML_DONTPEGTOP) @@ -949,15 +937,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) fixed_t right_top, right_bottom; // calculate right ends now - if (*pfloor->t_slope) - right_top = P_GetZAt(*pfloor->t_slope, ds->rightpos.x, ds->rightpos.y) - viewz; - else - right_top = *pfloor->topheight - viewz; - - if (*pfloor->b_slope) - right_bottom = P_GetZAt(*pfloor->b_slope, ds->rightpos.x, ds->rightpos.y) - viewz; - else - right_bottom = *pfloor->bottomheight - viewz; + right_top = P_GetFFloorTopZAt (pfloor, ds->rightpos.x, ds->rightpos.y) - viewz; + right_bottom = P_GetFFloorBottomZAt(pfloor, ds->rightpos.x, ds->rightpos.y) - viewz; // using INT64 to avoid 32bit overflow top_frac = (INT64)centeryfrac - (((INT64)left_top * ds->scale1) >> FRACBITS); @@ -1799,22 +1780,18 @@ void R_StoreWallRange(INT32 start, INT32 stop) } - if (frontsector->c_slope) { - worldtop = P_GetZAt(frontsector->c_slope, segleft.x, segleft.y) - viewz; - worldtopslope = P_GetZAt(frontsector->c_slope, segright.x, segright.y) - viewz; - } else { - worldtopslope = - worldtop = frontsector->ceilingheight - viewz; - } +#define SLOPEPARAMS(slope, end1, end2, normalheight) \ + end1 = P_GetZAt(slope, segleft.x, segleft.y, normalheight); \ + end2 = P_GetZAt(slope, segright.x, segright.y, normalheight); - - if (frontsector->f_slope) { - worldbottom = P_GetZAt(frontsector->f_slope, segleft.x, segleft.y) - viewz; - worldbottomslope = P_GetZAt(frontsector->f_slope, segright.x, segright.y) - viewz; - } else { - worldbottomslope = - worldbottom = frontsector->floorheight - viewz; - } + SLOPEPARAMS(frontsector->c_slope, worldtop, worldtopslope, frontsector->ceilingheight) + SLOPEPARAMS(frontsector->f_slope, worldbottom, worldbottomslope, frontsector->floorheight) + // subtract viewz from these to turn them into + // positions relative to the camera's z position + worldtop -= viewz; + worldtopslope -= viewz; + worldbottom -= viewz; + worldbottomslope -= viewz; midtexture = toptexture = bottomtexture = maskedtexture = 0; ds_p->maskedtexturecol = NULL; @@ -1834,12 +1811,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (ffloor[i].polyobj && (!ds_p->curline->polyseg || ffloor[i].polyobj != ds_p->curline->polyseg)) continue; - if (ffloor[i].slope) { - ffloor[i].f_pos = P_GetZAt(ffloor[i].slope, segleft.x, segleft.y) - viewz; - ffloor[i].f_pos_slope = P_GetZAt(ffloor[i].slope, segright.x, segright.y) - viewz; - } else - ffloor[i].f_pos_slope = - ffloor[i].f_pos = ffloor[i].height - viewz; + ffloor[i].f_pos = P_GetZAt(ffloor[i].slope, segleft .x, segleft .y, ffloor[i].height) - viewz; + ffloor[i].f_pos_slope = P_GetZAt(ffloor[i].slope, segright.x, segright.y, ffloor[i].height) - viewz; } } @@ -1898,26 +1871,15 @@ void R_StoreWallRange(INT32 start, INT32 stop) else { // two sided line - - if (backsector->c_slope) { - worldhigh = P_GetZAt(backsector->c_slope, segleft.x, segleft.y) - viewz; - worldhighslope = P_GetZAt(backsector->c_slope, segright.x, segright.y) - viewz; - } else { - worldhighslope = - worldhigh = backsector->ceilingheight - viewz; - } - - - if (backsector->f_slope) { - worldlow = P_GetZAt(backsector->f_slope, segleft.x, segleft.y) - viewz; - worldlowslope = P_GetZAt(backsector->f_slope, segright.x, segright.y) - viewz; - } else { - worldlowslope = - worldlow = backsector->floorheight - viewz; - } - + SLOPEPARAMS(backsector->c_slope, worldhigh, worldhighslope, backsector->ceilingheight) + SLOPEPARAMS(backsector->f_slope, worldlow, worldlowslope, backsector->floorheight) + worldhigh -= viewz; + worldhighslope -= viewz; + worldlow -= viewz; + worldlowslope -= viewz; // hack to allow height changes in outdoor areas + // This is what gets rid of the upper textures if there should be sky if (frontsector->ceilingpic == skyflatnum && backsector->ceilingpic == skyflatnum) { @@ -1931,12 +1893,12 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (worldbottomslope > worldlowslope || worldbottom > worldlow) { ds_p->silhouette = SIL_BOTTOM; - if ((backsector->f_slope ? P_GetZAt(backsector->f_slope, viewx, viewy) : backsector->floorheight) > viewz) + if (P_GetSectorFloorZAt(backsector, viewx, viewy) > viewz) ds_p->bsilheight = INT32_MAX; else ds_p->bsilheight = (frontsector->f_slope ? INT32_MAX : frontsector->floorheight); } - else if ((backsector->f_slope ? P_GetZAt(backsector->f_slope, viewx, viewy) : backsector->floorheight) > viewz) + else if (P_GetSectorFloorZAt(backsector, viewx, viewy) > viewz) { ds_p->silhouette = SIL_BOTTOM; ds_p->bsilheight = INT32_MAX; @@ -1946,16 +1908,15 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (worldtopslope < worldhighslope || worldtop < worldhigh) { ds_p->silhouette |= SIL_TOP; - if ((backsector->c_slope ? P_GetZAt(backsector->c_slope, viewx, viewy) : backsector->ceilingheight) < viewz) + if (P_GetSectorCeilingZAt(backsector, viewx, viewy) < viewz) ds_p->tsilheight = INT32_MIN; else ds_p->tsilheight = (frontsector->c_slope ? INT32_MIN : frontsector->ceilingheight); } - else if ((backsector->c_slope ? P_GetZAt(backsector->c_slope, viewx, viewy) : backsector->ceilingheight) < viewz) + else if (P_GetSectorCeilingZAt(backsector, viewx, viewy) < viewz) { ds_p->silhouette |= SIL_TOP; ds_p->tsilheight = INT32_MIN; - // ds_p->sprtopclip = screenheightarray; } if (viewsector != frontsector && viewsector != backsector) @@ -2053,13 +2014,15 @@ void R_StoreWallRange(INT32 start, INT32 stop) toptexture = R_GetTextureNum(sidedef->toptexture); texheight = textureheight[toptexture]; } - if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked + + if (!(linedef->flags & ML_EFFECT1)) // Ignore slopes for lower/upper textures unless flag is checked + { if (linedef->flags & ML_DONTPEGTOP) rw_toptexturemid = frontsector->ceilingheight - viewz; else rw_toptexturemid = backsector->ceilingheight - viewz; - } else - if (linedef->flags & ML_DONTPEGTOP) + } + else if (linedef->flags & ML_DONTPEGTOP) { // top of texture at top rw_toptexturemid = worldtop; @@ -2077,20 +2040,22 @@ void R_StoreWallRange(INT32 start, INT32 stop) // bottom texture bottomtexture = R_GetTextureNum(sidedef->bottomtexture); - if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked + if (!(linedef->flags & ML_EFFECT1)) // Ignore slopes for lower/upper textures unless flag is checked + { if (linedef->flags & ML_DONTPEGBOTTOM) rw_bottomtexturemid = frontsector->floorheight - viewz; else rw_bottomtexturemid = backsector->floorheight - viewz; - } else - if (linedef->flags & ML_DONTPEGBOTTOM) + } + else if (linedef->flags & ML_DONTPEGBOTTOM) { // bottom of texture at bottom // top of texture at top rw_bottomtexturemid = worldbottom; rw_bottomtextureslide = floorfrontslide; } - else { // top of texture at top + else // top of texture at top + { rw_bottomtexturemid = worldlow; rw_bottomtextureslide = floorbackslide; } @@ -2123,6 +2088,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (frontsector->ffloors && backsector->ffloors) { i = 0; + for (rover = backsector->ffloors; rover && i < MAXFFLOORS; rover = rover->next) { if (!(rover->flags & FF_RENDERSIDES) || !(rover->flags & FF_EXISTS)) @@ -2133,16 +2099,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (rover->norender == leveltime) continue; - if (*rover->t_slope) { - high1 = P_GetZAt(*rover->t_slope, segleft.x, segleft.y); - highslope1 = P_GetZAt(*rover->t_slope, segright.x, segright.y); - } else - high1 = highslope1 = *rover->topheight; - if (*rover->b_slope) { - low1 = P_GetZAt(*rover->b_slope, segleft.x, segleft.y); - lowslope1 = P_GetZAt(*rover->b_slope, segright.x, segright.y); - } else - low1 = lowslope1 = *rover->bottomheight; + SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) + SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight) if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) continue; @@ -2169,16 +2127,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) continue; } - if (*r2->t_slope) { - high2 = P_GetZAt(*r2->t_slope, segleft.x, segleft.y); - highslope2 = P_GetZAt(*r2->t_slope, segright.x, segright.y); - } else - high2 = highslope2 = *r2->topheight; - if (*r2->b_slope) { - low2 = P_GetZAt(*r2->b_slope, segleft.x, segleft.y); - lowslope2 = P_GetZAt(*r2->b_slope, segright.x, segright.y); - } else - low2 = lowslope2 = *r2->bottomheight; + SLOPEPARAMS(*r2->t_slope, high2, highslope2, *r2->topheight) + SLOPEPARAMS(*r2->b_slope, low2, lowslope2, *r2->bottomheight) if ((high2 < lowcut || highslope2 < lowcutslope) || (low2 > highcut || lowslope2 > highcutslope)) continue; @@ -2187,6 +2137,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) break; } + if (r2) continue; @@ -2204,16 +2155,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (rover->norender == leveltime) continue; - if (*rover->t_slope) { - high1 = P_GetZAt(*rover->t_slope, segleft.x, segleft.y); - highslope1 = P_GetZAt(*rover->t_slope, segright.x, segright.y); - } else - high1 = highslope1 = *rover->topheight; - if (*rover->b_slope) { - low1 = P_GetZAt(*rover->b_slope, segleft.x, segleft.y); - lowslope1 = P_GetZAt(*rover->b_slope, segright.x, segright.y); - } else - low1 = lowslope1 = *rover->bottomheight; + SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) + SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight) if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) continue; @@ -2240,16 +2183,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) continue; } - if (*r2->t_slope) { - high2 = P_GetZAt(*r2->t_slope, segleft.x, segleft.y); - highslope2 = P_GetZAt(*r2->t_slope, segright.x, segright.y); - } else - high2 = highslope2 = *r2->topheight; - if (*r2->b_slope) { - low2 = P_GetZAt(*r2->b_slope, segleft.x, segleft.y); - lowslope2 = P_GetZAt(*r2->b_slope, segright.x, segright.y); - } else - low2 = lowslope2 = *r2->bottomheight; + SLOPEPARAMS(*r2->t_slope, high2, highslope2, *r2->topheight) + SLOPEPARAMS(*r2->b_slope, low2, lowslope2, *r2->bottomheight) if ((high2 < lowcut || highslope2 < lowcutslope) || (low2 > highcut || lowslope2 > highcutslope)) continue; @@ -2275,10 +2210,10 @@ void R_StoreWallRange(INT32 start, INT32 stop) continue; // Oy vey. - if (( (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) <= worldbottom+viewz - && (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) <= worldbottomslope+viewz) - ||((*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) >= worldtop+viewz - && (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) >= worldtopslope+viewz)) + if ( ((P_GetFFloorTopZAt (rover, segleft .x, segleft .y)) <= worldbottom + viewz + && (P_GetFFloorTopZAt (rover, segright.x, segright.y)) <= worldbottomslope + viewz) + ||((P_GetFFloorBottomZAt(rover, segleft .x, segleft .y)) >= worldtop + viewz + && (P_GetFFloorBottomZAt(rover, segright.x, segright.y)) >= worldtopslope + viewz)) continue; ds_p->thicksides[i] = rover; @@ -2293,17 +2228,18 @@ void R_StoreWallRange(INT32 start, INT32 stop) continue; if (rover->norender == leveltime) continue; + // Oy vey. - if (( (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) <= worldbottom+viewz - && (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) <= worldbottomslope+viewz) - ||((*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) >= worldtop+viewz - && (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) >= worldtopslope+viewz)) + if ( (P_GetFFloorTopZAt (rover, segleft .x, segleft .y) <= worldbottom + viewz + && P_GetFFloorTopZAt (rover, segright.x, segright.y) <= worldbottomslope + viewz) + ||(P_GetFFloorBottomZAt(rover, segleft .x, segleft .y) >= worldtop + viewz + && P_GetFFloorBottomZAt(rover, segright.x, segright.y) >= worldtopslope + viewz)) continue; - if (( (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) <= worldlow+viewz - && (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) <= worldlowslope+viewz) - ||((*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) >= worldhigh+viewz - && (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) >= worldhighslope+viewz)) + if ( (P_GetFFloorTopZAt (rover, segleft .x, segleft .y) <= worldlow + viewz + && P_GetFFloorTopZAt (rover, segright.x, segright.y) <= worldlowslope + viewz) + ||(P_GetFFloorBottomZAt(rover, segleft .x, segleft .y) >= worldhigh + viewz + && P_GetFFloorBottomZAt(rover, segright.x, segright.y) >= worldhighslope + viewz)) continue; ds_p->thicksides[i] = rover; @@ -2313,6 +2249,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) ds_p->numthicksides = numthicksides = i; } + if (sidedef->midtexture > 0 && sidedef->midtexture < numtextures) { // masked midtexture @@ -2329,6 +2266,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (curline->polyseg) // use REAL front and back floors please, so midtexture rendering isn't mucked up { rw_midtextureslide = rw_midtexturebackslide = 0; + if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) rw_midtexturemid = rw_midtextureback = max(curline->frontsector->floorheight, curline->backsector->floorheight) - viewz; else @@ -2340,6 +2278,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (linedef->flags & ML_EFFECT2) // Ignore slopes when texturing { rw_midtextureslide = rw_midtexturebackslide = 0; + if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) rw_midtexturemid = rw_midtextureback = max(frontsector->floorheight, backsector->floorheight) - viewz; else @@ -2424,18 +2363,13 @@ void R_StoreWallRange(INT32 start, INT32 stop) // and doesn't need to be marked. if (frontsector->heightsec == -1) { - if (( - frontsector->f_slope ? P_GetZAt(frontsector->f_slope, viewx, viewy) : - frontsector->floorheight) >= viewz) + if (P_GetSectorFloorZAt(frontsector, viewx, viewy) >= viewz) { // above view plane markfloor = false; } - if (( - frontsector->c_slope ? P_GetZAt(frontsector->c_slope, viewx, viewy) : - frontsector->ceilingheight) <= viewz && - frontsector->ceilingpic != skyflatnum) + if (frontsector->ceilingpic != skyflatnum && P_GetSectorCeilingZAt(frontsector, viewx, viewy) <= viewz) { // below view plane markceiling = false; @@ -2492,14 +2426,12 @@ void R_StoreWallRange(INT32 start, INT32 stop) light = &frontsector->lightlist[i]; rlight = &dc_lightlist[p]; - if (light->slope) { - leftheight = P_GetZAt(light->slope, segleft.x, segleft.y); - rightheight = P_GetZAt(light->slope, segright.x, segright.y); + leftheight = P_GetLightZAt(light, segleft.x, segleft.y); + rightheight = P_GetLightZAt(light, segright.x, segright.y); - // Flag sector as having slopes + // Flag sector as having slopes + if (light->slope) frontsector->hasslope = true; - } else - leftheight = rightheight = light->height; leftheight -= viewz; rightheight -= viewz; @@ -2523,14 +2455,12 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (light->caster && light->caster->flags & FF_CUTSOLIDS) { - if (*light->caster->b_slope) { - leftheight = P_GetZAt(*light->caster->b_slope, segleft.x, segleft.y); - rightheight = P_GetZAt(*light->caster->b_slope, segright.x, segright.y); + leftheight = P_GetFFloorBottomZAt(light->caster, segleft.x, segleft.y); + rightheight = P_GetFFloorBottomZAt(light->caster, segright.x, segright.y); - // Flag sector as having slopes + // Flag sector as having slopes + if (*light->caster->b_slope) frontsector->hasslope = true; - } else - leftheight = rightheight = *light->caster->bottomheight; leftheight -= viewz; rightheight -= viewz; @@ -2623,9 +2553,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (*rover->b_slope || *rover->t_slope) backsector->hasslope = true; - roverleft = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) - viewz; - roverright = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) - viewz; - planevistest = (*rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) : *rover->bottomheight); + roverleft = P_GetFFloorBottomZAt(rover, segleft .x, segleft .y) - viewz; + roverright = P_GetFFloorBottomZAt(rover, segright.x, segright.y) - viewz; + planevistest = P_GetFFloorBottomZAt(rover, viewx, viewy); if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && @@ -2646,9 +2576,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (i >= MAXFFLOORS) break; - roverleft = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) - viewz; - roverright = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) - viewz; - planevistest = (*rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) : *rover->topheight); + roverleft = P_GetFFloorTopZAt(rover, segleft .x, segleft .y) - viewz; + roverright = P_GetFFloorTopZAt(rover, segright.x, segright.y) - viewz; + planevistest = P_GetFFloorTopZAt(rover, viewx, viewy); if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && @@ -2680,9 +2610,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (*rover->b_slope || *rover->t_slope) frontsector->hasslope = true; - roverleft = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) - viewz; - roverright = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) - viewz; - planevistest = (*rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) : *rover->bottomheight); + roverleft = P_GetFFloorBottomZAt(rover, segleft .x, segleft .y) - viewz; + roverright = P_GetFFloorBottomZAt(rover, segright.x, segright.y) - viewz; + planevistest = P_GetFFloorBottomZAt(rover, viewx, viewy); if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && @@ -2703,9 +2633,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (i >= MAXFFLOORS) break; - roverleft = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) - viewz; - roverright = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) - viewz; - planevistest = (*rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) : *rover->topheight); + roverleft = P_GetFFloorTopZAt(rover, segleft .x, segleft .y) - viewz; + roverright = P_GetFFloorTopZAt(rover, segright.x, segright.y) - viewz; + planevistest = P_GetFFloorTopZAt(rover, viewx, viewy); if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && @@ -2724,9 +2654,12 @@ void R_StoreWallRange(INT32 start, INT32 stop) } } } + if (curline->polyseg && frontsector && (curline->polyseg->flags & POF_RENDERPLANES)) { - while (i < numffloors && ffloor[i].polyobj != curline->polyseg) i++; + while (i < numffloors && ffloor[i].polyobj != curline->polyseg) + i++; + if (i < numffloors && backsector->floorheight <= frontsector->ceilingheight && backsector->floorheight >= frontsector->floorheight && (viewz < backsector->floorheight)) @@ -2744,6 +2677,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); i++; } + if (i < numffloors && backsector->ceilingheight >= frontsector->floorheight && backsector->ceilingheight <= frontsector->ceilingheight && (viewz > backsector->ceilingheight)) diff --git a/src/r_things.c b/src/r_things.c index f0538291c..ddae1d7ec 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -984,13 +984,12 @@ static void R_SplitSprite(vissprite_t *sprite) for (i = 1; i < sector->numlights; i++) { - fixed_t testheight = sector->lightlist[i].height; + fixed_t testheight; if (!(sector->lightlist[i].caster->flags & FF_CUTSPRITES)) continue; - if (sector->lightlist[i].slope) - testheight = P_GetZAt(sector->lightlist[i].slope, sprite->gx, sprite->gy); + testheight = P_GetLightZAt(§or->lightlist[i], sprite->gx, sprite->gy); if (testheight >= sprite->gzt) continue; @@ -1606,14 +1605,14 @@ static void R_ProjectSprite(mobj_t *thing) } else { - if (thing->subsector->sector->numlights) { light = thing->subsector->sector->numlights - 1; - for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) { - fixed_t h = thing->subsector->sector->lightlist[lightnum].slope ? P_GetZAt(thing->subsector->sector->lightlist[lightnum].slope, interp.x, interp.y) - : thing->subsector->sector->lightlist[lightnum].height; + for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) + { + fixed_t h = P_GetLightZAt(&thing->subsector->sector->lightlist[lightnum], interp.x, interp.y); + if (h <= gzt) { light = lightnum - 1; @@ -2283,6 +2282,7 @@ static void R_CreateDrawNodes(void) { if (!PolyObjects[i].visplane) continue; + plane = PolyObjects[i].visplane; R_PlaneBounds(plane); @@ -2291,6 +2291,7 @@ static void R_CreateDrawNodes(void) PolyObjects[i].visplane = NULL; continue; } + entry = R_CreateDrawNode(&nodehead); entry->plane = plane; // note: no seg is set, for what should be obvious reasons @@ -2301,6 +2302,7 @@ static void R_CreateDrawNodes(void) return; R_SortVisSprites(); + for (rover = vsprsortedhead.prev; rover != &vsprsortedhead; rover = rover->prev) { if (rover->szt > vid.height || rover->sz < 0) @@ -2319,13 +2321,8 @@ static void R_CreateDrawNodes(void) continue; // Effective height may be different for each comparison in the case of slopes - if (r2->plane->slope) - { - planeobjectz = P_GetZAt(r2->plane->slope, rover->gx, rover->gy); - planecameraz = P_GetZAt(r2->plane->slope, viewx, viewy); - } - else - planeobjectz = planecameraz = r2->plane->height; + planeobjectz = P_GetZAt(r2->plane->slope, rover->gx, rover->gy, r2->plane->height); + planecameraz = P_GetZAt(r2->plane->slope, viewx, viewy, r2->plane->height); if (rover->mobjflags & MF_NOCLIPHEIGHT) { @@ -2360,6 +2357,7 @@ static void R_CreateDrawNodes(void) if (r2->seg->frontscale[i] > rover->sortscale) break; } + if (i > x2) continue; } @@ -2373,31 +2371,22 @@ static void R_CreateDrawNodes(void) else if (r2->thickseg) { fixed_t topplaneobjectz, topplanecameraz, botplaneobjectz, botplanecameraz; + if (rover->x1 > r2->thickseg->x2 || rover->x2 < r2->thickseg->x1) continue; scale = r2->thickseg->scale1 > r2->thickseg->scale2 ? r2->thickseg->scale1 : r2->thickseg->scale2; if (scale <= rover->sortscale) continue; + scale = r2->thickseg->scale1 + (r2->thickseg->scalestep * (sintersect - r2->thickseg->x1)); if (scale <= rover->sortscale) continue; - if (*r2->ffloor->t_slope) - { - topplaneobjectz = P_GetZAt(*r2->ffloor->t_slope, rover->gx, rover->gy); - topplanecameraz = P_GetZAt(*r2->ffloor->t_slope, viewx, viewy); - } - else - topplaneobjectz = topplanecameraz = *r2->ffloor->topheight; - - if (*r2->ffloor->b_slope) - { - botplaneobjectz = P_GetZAt(*r2->ffloor->b_slope, rover->gx, rover->gy); - botplanecameraz = P_GetZAt(*r2->ffloor->b_slope, viewx, viewy); - } - else - botplaneobjectz = botplanecameraz = *r2->ffloor->bottomheight; + topplaneobjectz = P_GetFFloorTopZAt (r2->ffloor, rover->gx, rover->gy); + topplanecameraz = P_GetFFloorTopZAt (r2->ffloor, viewx, viewy); + botplaneobjectz = P_GetFFloorBottomZAt(r2->ffloor, rover->gx, rover->gy); + botplanecameraz = P_GetFFloorBottomZAt(r2->ffloor, viewx, viewy); if ((topplanecameraz > viewz && botplanecameraz < viewz) || (topplanecameraz < viewz && rover->gzt < topplaneobjectz) || From 00e59c480e545add3eeff6628f266a28a5e2b5bd Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 20 Apr 2025 23:19:15 +0200 Subject: [PATCH 271/350] remove lagless camera from the menu and change cvar name to reset it for everyone --- src/d_netcmd.c | 2 +- src/m_menu.c | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 9b68717db..8a6c17c1f 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -303,7 +303,7 @@ static void UseMouse_OnChange(void) consvar_t cv_mouseturn = {"mouseturn", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // Lagless camera! Yay! -consvar_t cv_laglesscam = {"laglesscamera", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_laglesscam = {"lagless_camera", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_verticallook[MAXSPLITSCREENPLAYERS] = { {"verticallook", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, diff --git a/src/m_menu.c b/src/m_menu.c index b5a1bd8d2..f84d2a85a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1934,19 +1934,16 @@ static menuitem_t OP_CamOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Field of View",&cv_fov, 30}, - {IT_STRING | IT_CVAR, NULL, "Lagless Camera", &cv_laglesscam, 50}, - - {IT_STRING | IT_SUBMENU, NULL, "Player 1 Camera options...", &OP_Player1CamOptionsDef, 70}, - {IT_STRING | IT_SUBMENU, NULL, "Player 2 Camera options...", &OP_Player2CamOptionsDef, 80}, - {IT_STRING | IT_SUBMENU, NULL, "Player 3 Camera options...", &OP_Player3CamOptionsDef, 90}, - {IT_STRING | IT_SUBMENU, NULL, "Player 4 Camera options...", &OP_Player4CamOptionsDef, 100}, + {IT_STRING | IT_SUBMENU, NULL, "Player 1 Camera options...", &OP_Player1CamOptionsDef, 50}, + {IT_STRING | IT_SUBMENU, NULL, "Player 2 Camera options...", &OP_Player2CamOptionsDef, 60}, + {IT_STRING | IT_SUBMENU, NULL, "Player 3 Camera options...", &OP_Player3CamOptionsDef, 70}, + {IT_STRING | IT_SUBMENU, NULL, "Player 4 Camera options...", &OP_Player4CamOptionsDef, 80}, }; static const char* OP_CamOptionsTooltips[] = { NULL, "Player field of view.", - "Removes Camera Lag in netgames\nMay cause Camera stutters in poor net conditions.", NULL, NULL, NULL, From b622fbb6533067e0191e20682e3a88a1a08597e9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 20 Apr 2025 23:34:59 +0200 Subject: [PATCH 272/350] add mindelay and gentlemens stuff to menu --- src/d_clisrv.c | 6 +++--- src/d_clisrv.h | 2 +- src/d_netcmd.c | 2 +- src/g_game.c | 2 +- src/m_menu.c | 51 ++++++++++++++++++++++++++++++++++++-------------- 5 files changed, 43 insertions(+), 20 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index df35d8375..66c71abfe 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -114,10 +114,10 @@ boolean server_lagless; static void Lagless_OnChange(void) { /* don't back out of dishonesty, or go lagless after playing honestly */ - if (cv_lagless.value && gamestate == GS_LEVEL) + if (!cv_gentlemens.value && gamestate == GS_LEVEL) server_lagless = true; - /*if (cv_lagless.value) + /*if (!cv_gentlemens.value) HU_AddChatText(M_GetText("\x82*Gentlemans Delay has been disabled for Serverplayer."), false); else HU_AddChatText(M_GetText("\x82*Gentlemans Delay will be enabled for Serverplayer."), false);*/ @@ -125,7 +125,7 @@ static void Lagless_OnChange(void) static CV_PossibleValue_t mindelay_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}}; consvar_t cv_mindelay = {"mindelay", "0", CV_SAVE, mindelay_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_lagless = {"serverlagless", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Lagless_OnChange, 0, NULL, NULL, 0, 0, NULL}; // this should be a netvar Zzz... +consvar_t cv_gentlemens = {"gentlemensdelay", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Lagless_OnChange, 0, NULL, NULL, 0, 0, NULL}; // this should be a netvar Zzz... SINT8 nodetoplayer[MAXNETNODES]; SINT8 nodetoplayer2[MAXNETNODES]; // say the numplayer for this node if any (splitscreen) diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 809cedd2e..8ad038a36 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -588,7 +588,7 @@ extern tic_t servermaxping; extern boolean server_lagless; extern tic_t simulated_lag; extern tic_t lowest_lag; -extern consvar_t cv_mindelay, cv_lagless; +extern consvar_t cv_mindelay, cv_gentlemens; extern consvar_t #ifdef VANILLAJOINNEXTROUND diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 8a6c17c1f..ebbf91736 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -928,7 +928,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_netstat); CV_RegisterVar(&cv_netticbuffer); CV_RegisterVar(&cv_mindelay); - CV_RegisterVar(&cv_lagless); + CV_RegisterVar(&cv_gentlemens); #ifdef NETGAME_DEVMODE CV_RegisterVar(&cv_fishcake); diff --git a/src/g_game.c b/src/g_game.c index bc6c162a5..7acda852e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1289,7 +1289,7 @@ static void G_DoLoadLevel(boolean resetplayer) // clear hud messages remains (usually from game startup) CON_ClearHUD(); - server_lagless = cv_lagless.value; + server_lagless = !cv_gentlemens.value; G_ResetAllDeviceRumbles(); } diff --git a/src/m_menu.c b/src/m_menu.c index f84d2a85a..72c28857c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2094,6 +2094,21 @@ static menuitem_t OP_GameOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Restrict Character Changes", &cv_restrictskinchange, 150}, }; +enum +{ + op_game_ittggl, + op_game_spd, + op_game_frantic, + op_game_encore, + op_game_numlaps, + op_game_countdown, + op_game_timelimit, + op_game_startbump, + op_game_karma, + op_game_forcechar, + op_game_restrictchar, +}; + static const char* OP_GameTooltips[] = { "Toggles for all in-game items.", @@ -2282,33 +2297,39 @@ static menuitem_t OP_SaturnMenu[] = {IT_STRING | IT_CVAR, NULL, "Serverqueue waittime", &cv_connectawaittime, 10}, - {IT_STRING | IT_CVAR, NULL, "Skin Select Spinning Speed", &cv_skinselectspin, 20}, + {IT_STRING | IT_CVAR, NULL, "Minimum Input Delay", &cv_mindelay, 20}, + {IT_STRING | IT_CVAR, NULL, "Gentlemens Ping", &cv_gentlemens, 25}, - {IT_STRING | IT_CVAR, NULL, "Colorized Speedlines", &cv_coloredspeedlines, 30}, - {IT_STRING | IT_CVAR, NULL, "Colorized Sneakertrails", &cv_coloredsneakertrail, 35}, + {IT_STRING | IT_CVAR, NULL, "Skin Select Spinning Speed", &cv_skinselectspin, 35}, - {IT_STRING | IT_CVAR, NULL, "Player Blendeffects", &cv_playerblendeffects, 45}, + {IT_STRING | IT_CVAR, NULL, "Colorized Speedlines", &cv_coloredspeedlines, 45}, + {IT_STRING | IT_CVAR, NULL, "Colorized Sneakertrails", &cv_coloredsneakertrail, 40}, - {IT_STRING | IT_CVAR, NULL, "Bananadrag Jitter", &cv_bananajitter, 55}, + {IT_STRING | IT_CVAR, NULL, "Player Blendeffects", &cv_playerblendeffects, 50}, - {IT_STRING | IT_CVAR, NULL, "Midair Driftsparks", &cv_airsparks, 65}, + {IT_STRING | IT_CVAR, NULL, "Bananadrag Jitter", &cv_bananajitter, 60}, - {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 75}, - {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 85}, + {IT_STRING | IT_CVAR, NULL, "Midair Driftsparks", &cv_airsparks, 70}, - {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 90}, + {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 80}, - {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 100}, + {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 90}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 110}, - {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 115}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 125}, // uwu + {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 100}, + + {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 110}, + + {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 120}, + {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 125}, + {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 130}, // uwu }; static const char* OP_SaturnTooltips[] = { NULL, "How long can the game wait before it kicks you out from the server\nconnecting screen.", + "Practice for online play! 0 = instant response.", + "Simulate online input delay when hosting a server.\nValue choosen by Player with the lowest ping", "How much speen do you want?", "Colourize the speedlines in your skincolor if you go fast enough!", "Colourize the sneaker flame trails in your skincolor!", @@ -2328,6 +2349,8 @@ enum { sm_header, sm_waittime, + sm_mindelay, + sm_gentlemens, sm_skinselspeed, sm_colorlines, sm_colorflames, @@ -8030,7 +8053,7 @@ static void M_Options(INT32 choice) OP_DataOptionsMenu[3].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU); // Erase data #endif - OP_GameOptionsMenu[3].status = (M_SecretUnlocked(SECRET_ENCORE)) ? (IT_CVAR|IT_STRING) : IT_SECRET; // cv_kartencore + OP_GameOptionsMenu[op_game_encore].status = (M_SecretUnlocked(SECRET_ENCORE)) ? (IT_CVAR|IT_STRING) : IT_SECRET; // cv_kartencore OP_MainDef.prevMenu = currentMenu; M_SetupNextMenu(&OP_MainDef); From af544e4e163e15c761b931bc54093dbf709a5316 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 21 Apr 2025 09:59:25 +0200 Subject: [PATCH 273/350] Fix server listing refusing to list servers on resolution failure --- 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 66c71abfe..f87f872bf 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2191,7 +2191,7 @@ void CL_QueryServerList (msg_server_t *server_list) { INT32 node = I_NetMakeNodewPort(server_list[i].ip, server_list[i].port); if (node == -1) - break; // no more node free + continue; // no more node free, or resolution failure SendAskInfo(node); resendserverlistnode[node] = true; // Leave this node open. It'll be closed if the From f398c0ceea8dc91d947face658f1e36b030fd464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Sun, 2 Mar 2025 12:15:52 +0100 Subject: [PATCH 274/350] Fix use-after-free when loading addons after searching addons --- src/filesrch.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/filesrch.c b/src/filesrch.c index 8af9118ba..d55c33ae8 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -661,6 +661,10 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut) return false; } + if (dirmenu != coredirmenu) + Z_Free(dirmenu); + dirmenu = NULL; + for (; sizecoredirmenu > 0; sizecoredirmenu--) // clear out existing items { Z_Free(coredirmenu[sizecoredirmenu-1]); From 9638ae56c52a788432cc42cc9cf53bd09ddfb44c Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 21 Apr 2025 12:12:39 +0200 Subject: [PATCH 275/350] add missing pglDisableClientState --- src/hardware/r_opengl/r_opengl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index b5bb031e0..40129b3b1 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2930,6 +2930,7 @@ void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2]) pglDisable(GL_DEPTH_TEST); pglDisable(GL_BLEND); + pglDisableClientState(GL_TEXTURE_COORD_ARRAY); // Draw a black square behind the screen texture, // so nothing shows through the edges @@ -2937,8 +2938,8 @@ void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2]) pglVertexPointer(3, GL_FLOAT, 0, blackBack); pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); - pglEnableClientState(GL_TEXTURE_COORD_ARRAY); + for(x = 0; x < SCREENVERTS-1;x ++) { for(y = 0; y < SCREENVERTS-1; y++) @@ -3129,8 +3130,6 @@ void GL_DoScreenWipe(int wipeStart, int wipeEnd) pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - // const float defaultST[8] - pglClientActiveTexture(GL_TEXTURE0); pglTexCoordPointer(2, GL_FLOAT, 0, fix); pglVertexPointer(3, GL_FLOAT, 0, screenVerts); From bc6ce84a2635bd03f5b5297d975d9eccb1df4d3e Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 21 Apr 2025 12:27:52 +0200 Subject: [PATCH 276/350] replace instances of malloc + memset with calloc --- src/d_clisrv.c | 2 + src/d_netfil.c | 10 +--- src/f_finale.c | 2 +- src/lua_hudlib_drawlist.c | 3 + src/lua_infolib.c | 8 +-- src/p_polyobj.c | 11 ++-- src/p_slopes.c | 116 +++++++++++++++++++++----------------- src/p_tick.c | 2 + src/r_draw.c | 1 - 9 files changed, 81 insertions(+), 74 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index f87f872bf..97b6c9358 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3268,6 +3268,7 @@ void CL_ClearPlayer(INT32 playernum) P_RemoveMobj(players[playernum].mo->tracer); P_RemoveMobj(players[playernum].mo); } + memset(&players[playernum], 0, sizeof (player_t)); } @@ -6491,6 +6492,7 @@ static inline void PingUpdate(void) INT32 i; UINT8 pingkick[MAXPLAYERS]; UINT8 nonlaggers = 0; + memset(pingkick, 0, sizeof(pingkick)); netbuffer->packettype = PT_PING; diff --git a/src/d_netfil.c b/src/d_netfil.c index 2a4c321c3..a71df9a71 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -654,13 +654,10 @@ static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid) q = &((*q)->next); // Allocate a file request and append it to the file list - p = *q = (filetx_t *)malloc(sizeof (filetx_t)); + p = *q = (filetx_t *)calloc(1, sizeof(filetx_t)); // Initialise with zeros if (!p) I_Error("SV_SendFile: No more memory\n"); - // Initialise with zeros - memset(p, 0, sizeof (filetx_t)); - // Allocate the file name p->id.filename = (char *)malloc(MAX_WADPATH); if (!p->id.filename) @@ -739,13 +736,10 @@ void SV_SendRam(INT32 node, void *data, size_t size, freemethod_t freemethod, UI q = &((*q)->next); // Allocate a file request and append it to the file list - p = *q = (filetx_t *)malloc(sizeof (filetx_t)); + p = *q = (filetx_t *)calloc(1, sizeof(filetx_t)); // Initialise with zeros if (!p) I_Error("SV_SendRam: No more memory\n"); - // Initialise with zeros - memset(p, 0, sizeof (filetx_t)); - p->ram = freemethod; // Remember how to free the memory block for when we're done sending it p->id.ram = data; p->size = (UINT32)size; diff --git a/src/f_finale.c b/src/f_finale.c index 1b8d236fe..167985c24 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -149,7 +149,7 @@ static UINT8 F_WriteText(void) static void F_NewCutscene(const char *basetext) { cutscene_basetext = basetext; - memset(cutscene_disptext,0,sizeof(cutscene_disptext)); + memset(cutscene_disptext, 0, sizeof(cutscene_disptext)); cutscene_writeptr = cutscene_baseptr = 0; cutscene_textspeed = 9; cutscene_textcount = TICRATE/2; diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index d64722f0c..98a4890b1 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -303,6 +303,7 @@ static void CalcFillCoords(drawitem_t *item) else if (!(c & V_SNAPTOLEFT)) x += (vid.width - (BASEVIDWIDTH * dupx)) / 2; } + if (vid.height != BASEVIDHEIGHT * dupy) { // same thing here @@ -311,6 +312,7 @@ static void CalcFillCoords(drawitem_t *item) else if (!(c & V_SNAPTOTOP)) y += (vid.height - (BASEVIDHEIGHT * dupy)) / 2; } + if (c & V_SPLITSCREEN) y += (BASEVIDHEIGHT * dupy)/2; if (c & V_HORZSCREEN) @@ -346,6 +348,7 @@ static UINT64 GetItemId(void) id |= INTERP_LATCH; hud_interplatch = false; } + if (hud_interpstring) id |= INTERP_STRING; diff --git a/src/lua_infolib.c b/src/lua_infolib.c index c220ad25b..a82fc947d 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -154,7 +154,7 @@ static int lib_setState(lua_State *L) return luaL_error(L, "Do not alter states in BuildCMD code!"); // clear the state to start with, in case of missing table elements - memset(state,0,sizeof(state_t)); + memset(state, 0, sizeof(state_t)); state->tics = -1; lua_pushnil(L); @@ -262,8 +262,8 @@ boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor) return false; // action not called. if (superstack && fasticmp(actionpointers[actionnum].name, superactions[superstack-1])) // the action is calling itself, - return false; // let it call the hardcoded function - + return false; // let it call the hardcoded function + lua_pushcfunction(gL, LUA_GetErrorMessage); // grab function by uppercase name. @@ -514,7 +514,7 @@ static int lib_setMobjInfo(lua_State *L) return luaL_error(L, "Do not alter mobjinfo in BuildCMD code!"); // clear the mobjinfo to start with, in case of missing table elements - memset(info,0,sizeof(mobjinfo_t)); + memset(info, 0, sizeof(mobjinfo_t)); info->doomednum = -1; // default to no editor value info->spawnhealth = 1; // avoid 'dead' noclip behaviors diff --git a/src/p_polyobj.c b/src/p_polyobj.c index ffc6651b8..61c08a05d 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -848,8 +848,7 @@ static polymaplink_t *Polyobj_getLink(void) } else { - l = Z_Malloc(sizeof(*l), PU_LEVEL, NULL); - memset(l, 0, sizeof(*l)); + l = Z_Calloc(sizeof(*l), PU_LEVEL, NULL); } return l; @@ -1565,8 +1564,7 @@ void Polyobj_InitLevel(void) { ++numPolyObjects; - qitem = malloc(sizeof(mobjqitem_t)); - memset(qitem, 0, sizeof(mobjqitem_t)); + qitem = calloc(1, sizeof(mobjqitem_t)); qitem->mo = mo; M_QueueInsert(&(qitem->mqitem), &spawnqueue); } @@ -1574,8 +1572,7 @@ void Polyobj_InitLevel(void) { ++numAnchors; - qitem = malloc(sizeof(mobjqitem_t)); - memset(qitem, 0, sizeof(mobjqitem_t)); + qitem = calloc(1, sizeof(mobjqitem_t)); qitem->mo = mo; M_QueueInsert(&(qitem->mqitem), &anchorqueue); } @@ -2466,7 +2463,7 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) R_CreateInterpolator_Polyobj(&th->thinker, po); // T_PolyObjWaypoint is the only polyobject movement // that can adjust z, so we add these ones too. - R_CreateInterpolator_SectorPlane(&th->thinker, po->lines[0]->backsector, false); + R_CreateInterpolator_SectorPlane(&th->thinker, po->lines[0]->backsector, false); R_CreateInterpolator_SectorPlane(&th->thinker, po->lines[0]->backsector, true); // Most other polyobject functions handle children by recursively diff --git a/src/p_slopes.c b/src/p_slopes.c index ed6c8019b..e64cd6f6b 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -181,54 +181,60 @@ void P_RunDynamicSlopes(void) { pslope_t *slope; - for (slope = slopelist; slope; slope = slope->next) { + for (slope = slopelist; slope; slope = slope->next) + { fixed_t zdelta; if (slope->flags & SL_NODYNAMIC) continue; - switch(slope->refpos) { - case 1: // front floor - zdelta = slope->sourceline->backsector->floorheight - slope->sourceline->frontsector->floorheight; - slope->o.z = slope->sourceline->frontsector->floorheight; - break; - case 2: // front ceiling - zdelta = slope->sourceline->backsector->ceilingheight - slope->sourceline->frontsector->ceilingheight; - slope->o.z = slope->sourceline->frontsector->ceilingheight; - break; - case 3: // back floor - zdelta = slope->sourceline->frontsector->floorheight - slope->sourceline->backsector->floorheight; - slope->o.z = slope->sourceline->backsector->floorheight; - break; - case 4: // back ceiling - zdelta = slope->sourceline->frontsector->ceilingheight - slope->sourceline->backsector->ceilingheight; - slope->o.z = slope->sourceline->backsector->ceilingheight; - break; - case 5: // vertices - { - mapthing_t *mt; - size_t i; - INT32 l; - line_t *line; + switch(slope->refpos) + { + case 1: // front floor + zdelta = slope->sourceline->backsector->floorheight - slope->sourceline->frontsector->floorheight; + slope->o.z = slope->sourceline->frontsector->floorheight; + break; + case 2: // front ceiling + zdelta = slope->sourceline->backsector->ceilingheight - slope->sourceline->frontsector->ceilingheight; + slope->o.z = slope->sourceline->frontsector->ceilingheight; + break; + case 3: // back floor + zdelta = slope->sourceline->frontsector->floorheight - slope->sourceline->backsector->floorheight; + slope->o.z = slope->sourceline->backsector->floorheight; + break; + case 4: // back ceiling + zdelta = slope->sourceline->frontsector->ceilingheight - slope->sourceline->backsector->ceilingheight; + slope->o.z = slope->sourceline->backsector->ceilingheight; + break; + case 5: // vertices + { + mapthing_t *mt; + size_t i; + INT32 l; + line_t *line; - for (i = 0; i < 3; i++) { - mt = slope->vertices[i]; - l = P_FindSpecialLineFromTag(799, mt->angle, -1); - if (l != -1) { - line = &lines[l]; - mt->z = line->frontsector->floorheight >> FRACBITS; + for (i = 0; i < 3; i++) + { + mt = slope->vertices[i]; + l = P_FindSpecialLineFromTag(799, mt->angle, -1); + + if (l != -1) + { + line = &lines[l]; + mt->z = line->frontsector->floorheight >> FRACBITS; + } } + + P_ReconfigureVertexSlope(slope); } + continue; // TODO - P_ReconfigureVertexSlope(slope); - } - continue; // TODO - - default: - I_Error("P_RunDynamicSlopes: slope has invalid type!"); + default: + I_Error("P_RunDynamicSlopes: slope has invalid type!"); } - if (slope->zdelta != FixedDiv(zdelta, slope->extent)) { + if (slope->zdelta != FixedDiv(zdelta, slope->extent)) + { slope->zdelta = FixedDiv(zdelta, slope->extent); slope->zangle = R_PointToAngle2(0, 0, slope->extent, -zdelta); slope->real_zangle = slope->zangle; @@ -245,8 +251,7 @@ void P_RunDynamicSlopes(void) static pslope_t *P_MakeSlope(const vector3_t *o, const vector2_t *d, const fixed_t zdelta, UINT8 flags) { - pslope_t *ret = Z_Malloc(sizeof(pslope_t), PU_LEVEL, NULL); - memset(ret, 0, sizeof(*ret)); + pslope_t *ret = Z_Calloc(sizeof(pslope_t), PU_LEVEL, NULL); ret->o.x = o->x; ret->o.y = o->y; @@ -340,13 +345,13 @@ void P_SpawnSlope_Line(int linenum) if (line->flags & ML_NOKNUX) flags |= SL_ANCHORVERTEX; - if(!frontfloor && !backfloor && !frontceil && !backceil) + if (!frontfloor && !backfloor && !frontceil && !backceil) { CONS_Printf("P_SpawnSlope_Line called with non-slope line special.\n"); return; } - if(!line->frontsector || !line->backsector) + if (!line->frontsector || !line->backsector) { CONS_Debug(DBG_SETUP, "P_SpawnSlope_Line used on a line without two sides. (line number %i)\n", linenum); return; @@ -626,15 +631,13 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag size_t i; mapthing_t *mt = mapthings; - pslope_t *ret = Z_Malloc(sizeof(pslope_t), PU_LEVEL, NULL); - memset(ret, 0, sizeof(*ret)); + pslope_t *ret = Z_Calloc(sizeof(pslope_t), PU_LEVEL, NULL); // Start by setting flags ret->flags = flags; // Now set up the vertex list - ret->vertices = Z_Malloc(3*sizeof(mapthing_t), PU_LEVEL, NULL); - memset(ret->vertices, 0, 3*sizeof(mapthing_t)); + ret->vertices = Z_Calloc(3*sizeof(mapthing_t), PU_LEVEL, NULL); // And... look for the vertices in question. for (i = 0; i < nummapthings; i++, mt++) @@ -688,7 +691,7 @@ void P_CopySectorSlope(line_t *line) int i, special = line->special; // Check for copy linedefs - for(i = -1; (i = P_FindSectorFromLineTag(line, i)) >= 0;) + for (i = -1; (i = P_FindSectorFromLineTag(line, i)) >= 0;) { sector_t *srcsec = sectors + i; @@ -899,11 +902,14 @@ void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) { vector3_t mom; // Ditto. - if (slope->flags & SL_NOPHYSICS) { // No physics, no need to make anything complicated. - if (P_MobjFlip(thing)*(thing->momz) < 0) { // falling, land on slope + if (slope->flags & SL_NOPHYSICS) // No physics, no need to make anything complicated. + { + if (P_MobjFlip(thing)*(thing->momz) < 0) // falling, land on slope + { thing->momz = -P_MobjFlip(thing); thing->standingslope = slope; } + return; } @@ -913,11 +919,11 @@ void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) P_ReverseQuantizeMomentumToSlope(&mom, slope); - if (P_MobjFlip(thing)*mom.z < 0) { // falling, land on slope + if (P_MobjFlip(thing)*mom.z < 0) // falling, land on slope + { thing->momx = mom.x; thing->momy = mom.y; thing->momz = -P_MobjFlip(thing); - thing->standingslope = slope; } } @@ -937,7 +943,8 @@ void P_ButteredSlope(mobj_t *mo) if (mo->flags & (MF_NOCLIPHEIGHT|MF_NOGRAVITY)) return; // don't slide down slopes if you can't touch them or you're not affected by gravity - if (mo->player) { + if (mo->player) + { if (abs(mo->standingslope->zdelta) < FRACUNIT/4 && !(mo->player->pflags & PF_SPINNING)) return; // Don't slide on non-steep slopes unless spinning @@ -947,9 +954,12 @@ void P_ButteredSlope(mobj_t *mo) thrust = FINESINE(mo->standingslope->zangle>>ANGLETOFINESHIFT) * 15 / 16 * (mo->eflags & MFE_VERTICALFLIP ? 1 : -1); - if (mo->player && (mo->player->pflags & PF_SPINNING)) { + if (mo->player && (mo->player->pflags & PF_SPINNING)) + { fixed_t mult = 0; - if (mo->momx || mo->momy) { + + if (mo->momx || mo->momy) + { angle_t angle = R_PointToAngle2(0, 0, mo->momx, mo->momy) - mo->standingslope->xydirection; if (P_MobjFlip(mo) * mo->standingslope->zdelta < 0) diff --git a/src/p_tick.c b/src/p_tick.c index 9406d1be5..8fbdf8b6a 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -835,6 +835,7 @@ void P_PreTicker(INT32 frames) LUA_HOOK(PreThinkFrame); for (i = 0; i < MAXPLAYERS; i++) + { if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) { // stupid fucking cmd hack @@ -849,6 +850,7 @@ void P_PreTicker(INT32 frames) memcpy(&players[i].cmd, &temptic, sizeof(ticcmd_t)); } + } // Dynamic slopeness if (midgamejoin) diff --git a/src/r_draw.c b/src/r_draw.c index e709c625b..f7d1fb413 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -452,7 +452,6 @@ static UINT8* RGetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 f if (flags & GTC_CACHE) { - // Allocate table for skin if necessary if (!tt[skintableindex]) tt[skintableindex] = Z_Calloc(MAXTRANSLATIONS * sizeof(UINT8**), PU_STATIC, NULL); From fc7405e5420ff2cbfb3b017a747c23dae43a5aa3 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 21 Apr 2025 14:12:42 +0200 Subject: [PATCH 277/350] dont free our hud patches when loading an addon lel appears to work fine in RR so we do it here fixes some weird issues and crashes with certain hud elements --- src/p_setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index 6749a87a9..bdab7022d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3458,7 +3458,7 @@ boolean P_MultiSetupWadFiles(boolean fullsetup) if (partadd_stage == 0) { // Flush and reload HUD graphics - ST_UnloadGraphics(); + //ST_UnloadGraphics(); HU_LoadGraphics(); ST_LoadGraphics(); ST_ReloadSkinFaceGraphics(); From 7c4b93fba89ce8dfbac85a7033ff4e1832435046 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 21 Apr 2025 14:15:35 +0200 Subject: [PATCH 278/350] add some savety to the hudlib just error instead of crashing so we can track down any issues more easily --- src/k_kart.c | 8 ++--- src/lua_hudlib.c | 79 ++++++++++++++++++++++++++++-------------------- 2 files changed, 51 insertions(+), 36 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index cb8978734..eb852f312 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7702,10 +7702,10 @@ void K_LoadKartHUDGraphics(void) kp_bumperstickerwideclr = W_CachePatchName("K_SCBALW", PU_HUDGFX); kp_karmastickerclr = W_CachePatchName("K_SCKARM", PU_HUDGFX); kp_timeoutstickerclr = W_CachePatchName("K_SCTOUT", PU_HUDGFX); - kp_itembgclr[0] = W_CachePatchName("K_ITBC", PU_HUDGFX); - kp_itembgclr[1] = W_CachePatchName("K_ITBCD", PU_HUDGFX); - kp_itembgclr[2] = W_CachePatchName("K_ISBC", PU_HUDGFX); - kp_itembgclr[3] = W_CachePatchName("K_ISBCD", PU_HUDGFX); + kp_itembgclr[0] = W_CachePatchName("K_ITBC" , PU_HUDGFX); + kp_itembgclr[1] = W_CachePatchName("K_ITBCD" , PU_HUDGFX); + kp_itembgclr[2] = W_CachePatchName("K_ISBC" , PU_HUDGFX); + kp_itembgclr[3] = W_CachePatchName("K_ISBCD" , PU_HUDGFX); kp_itemmulstickerclr[1] = W_CachePatchName("K_ISMULC", PU_HUDGFX); kp_itemmulstickerclr[0] = W_CachePatchName("K_ITMULC", PU_HUDGFX); } diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 8083807ad..d1dce0ae0 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -297,9 +297,13 @@ static int patch_get(lua_State *L) patch_t *patch = *((patch_t **)luaL_checkudata(L, 1, META_PATCH)); enum patch field = Lua_optoption(L, 2, -1, patch_fields_ref); - // patches are CURRENTLY always valid, expected to be cached with PU_STATIC - // this may change in the future, so patch.valid still exists - I_Assert(patch != NULL); + if (!patch) { + if (field == patch_valid) { + lua_pushboolean(L, 0); + return 1; + } + return LUA_ErrInvalid(L, "patch_t"); + } switch (field) { @@ -546,6 +550,8 @@ static int libd_draw(lua_State *L) x = luaL_checkinteger(L, 1); y = luaL_checkinteger(L, 2); patch = *((patch_t **)luaL_checkudata(L, 3, META_PATCH)); + if (!patch) + return LUA_ErrInvalid(L, "patch_t"); flags = luaL_optinteger(L, 4, 0); if (!lua_isnoneornil(L, 5)) colormap = *((UINT8 **)luaL_checkudata(L, 5, META_COLORMAP)); @@ -579,6 +585,8 @@ static int libd_drawScaled(lua_State *L) if (scale < 0) return luaL_error(L, "negative scale"); patch = *((patch_t **)luaL_checkudata(L, 4, META_PATCH)); + if (!patch) + return LUA_ErrInvalid(L, "patch_t"); flags = luaL_optinteger(L, 5, 0); if (!lua_isnoneornil(L, 6)) colormap = *((UINT8 **)luaL_checkudata(L, 6, META_COLORMAP)); @@ -642,6 +650,8 @@ static int libd_drawOnMinimap(lua_State *L) y = luaL_checkinteger(L, 2); scale = luaL_checkinteger(L, 3); patch = *((patch_t **)luaL_checkudata(L, 4, META_PATCH)); + if (!patch) + return LUA_ErrInvalid(L, "patch_t"); if (!lua_isnoneornil(L, 5)) colormap = *((UINT8 **)luaL_checkudata(L, 5, META_COLORMAP)); centered = lua_optboolean(L, 6); @@ -737,6 +747,8 @@ static int libd_drawStretched(lua_State *L) if (vscale < 0) return luaL_error(L, "negative vertical scale"); patch = *((patch_t **)luaL_checkudata(L, 5, META_PATCH)); + if (!patch) + return LUA_ErrInvalid(L, "patch_t"); flags = luaL_optinteger(L, 6, 0); if (!lua_isnoneornil(L, 7)) colormap = *((UINT8 **)luaL_checkudata(L, 7, META_COLORMAP)); @@ -910,35 +922,37 @@ static int libd_drawString(lua_State *L) if (LUA_HUD_IsDrawListValid(list)) LUA_HUD_AddDrawString(list, x, y, str, flags, align); else - switch(align) { - // hu_font - case align_left: - V_DrawString(x, y, flags, str); - break; - case align_center: - V_DrawCenteredString(x, y, flags, str); - break; - case align_right: - V_DrawRightAlignedString(x, y, flags, str); - break; - case align_fixed: - V_DrawStringAtFixed(x, y, flags, str); - break; - // hu_font, 0.5x scale - case align_small: - V_DrawSmallString(x, y, flags, str); - break; - case align_smallright: - V_DrawRightAlignedSmallString(x, y, flags, str); - break; - // tny_font - case align_thin: - V_DrawThinString(x, y, flags, str); - break; - case align_thinright: - V_DrawRightAlignedThinString(x, y, flags, str); - break; + switch(align) + { + // hu_font + case align_left: + V_DrawString(x, y, flags, str); + break; + case align_center: + V_DrawCenteredString(x, y, flags, str); + break; + case align_right: + V_DrawRightAlignedString(x, y, flags, str); + break; + case align_fixed: + V_DrawStringAtFixed(x, y, flags, str); + break; + // hu_font, 0.5x scale + case align_small: + V_DrawSmallString(x, y, flags, str); + break; + case align_smallright: + V_DrawRightAlignedSmallString(x, y, flags, str); + break; + // tny_font + case align_thin: + V_DrawThinString(x, y, flags, str); + break; + case align_thinright: + V_DrawRightAlignedThinString(x, y, flags, str); + break; + } } return 0; } @@ -1025,7 +1039,8 @@ static int libd_getColorHudPatch(lua_State *L) UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); boolean small, dark; - switch (option) { + switch (option) + { case hudpatch_item: small = lua_optboolean(L, 2); dark = lua_optboolean(L, 3); From 4ce111139f2c42ef47ed4ef9e2d3b60e7d626b42 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 22 Apr 2025 02:52:48 +0200 Subject: [PATCH 279/350] add cv_palette and cv_palettenum so palettes can be changed midgame note: subpalettes do not work properly in opengl with paletterendering disabled, so palettenum will NOT work there --- src/d_netcmd.c | 4 ++++ src/p_setup.c | 3 ++- src/v_video.c | 60 +++++++++++++++++++++++++++++++++++++------------- src/v_video.h | 12 +++++----- 4 files changed, 57 insertions(+), 22 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index ebbf91736..c0a7bfb93 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -39,6 +39,7 @@ #include "d_main.h" #include "m_random.h" #include "f_finale.h" +#include "v_video.h" #include "filesrch.h" #include "mserv.h" #include "md5.h" @@ -956,6 +957,9 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_audbuffersize); + CV_RegisterVar(&cv_palette); + CV_RegisterVar(&cv_palettenum); + // m_menu.c CV_RegisterVar(&cv_chatheight); CV_RegisterVar(&cv_chatwidth); diff --git a/src/p_setup.c b/src/p_setup.c index bdab7022d..e3b012d31 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3018,7 +3018,7 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) // Reset the palette now all fades have been done if (rendermode != render_none) - V_SetPaletteLump(GetPalette()); // Set the level palette + V_ReloadPalette(); // Set the level palette // Print "SPEEDING OFF TO [ZONE] [ACT 1]..." /*if (rendermode != render_none) @@ -3301,6 +3301,7 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) { name = lumpinfo->name; lumpnum_t lumpnum = i|(wadnum<<16); + if (name[0] == 'D') { if (name[1] == 'S') for (j = 1; j < NUMSFX; j++) diff --git a/src/v_video.c b/src/v_video.c index 93d12800a..217bb0ae5 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -48,6 +48,9 @@ consvar_t cv_ticrate = {"showfps", "No", CV_SAVE, fps_cons_t, NULL, 0, NULL, NUL static void CV_palette_OnChange(void); +consvar_t cv_palette = {"palette", "", CV_CALL|CV_NOINIT, NULL, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_palettenum = {"palettenum", "0", CV_CALL|CV_NOINIT, CV_Unsigned, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; + static CV_PossibleValue_t gamma_cons_t[] = {{-15, "MIN"}, {4, "MAX"}, {0, NULL}}; consvar_t cv_globalgamma = {"gamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -91,6 +94,8 @@ consvar_t cv_menucaps = {"menucaps", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NUL // local copy of the palette for V_GetColor() RGBA_t *pLocalPalette = NULL; +static size_t currentPaletteSize; + /* The following was an extremely helpful resource when developing my Colour Cube LUT. http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter24.html @@ -411,13 +416,19 @@ const UINT8 gammatable[5][256] = // keep a copy of the palette so that we can get the RGB value for a color index at any time. static void LoadPalette(const char *lumpname) { + UINT8 *pal; + size_t i, palsize; + lumpnum_t lumpnum; + #ifdef BACKWARDSCOMPATCORRECTION const UINT8 *usegamma = gammatable[min(max(cv_globalgamma.value, 0), 4)]; #endif Cubeapply = InitCube(); - lumpnum_t lumpnum = W_GetNumForName(lumpname); - size_t i, palsize = W_LumpLength(lumpnum)/3; - UINT8 *pal; + + lumpnum = W_GetNumForName(lumpname); + + currentPaletteSize = W_LumpLength(lumpnum); + palsize = currentPaletteSize / 3; Z_Free(pLocalPalette); @@ -505,8 +516,23 @@ const char *R_GetPalname(UINT16 num) const char *GetPalette(void) { + const char *user = cv_palette.string; + + if (user && user[0]) + { + if (W_CheckNumForName(user) == LUMPERROR) + { + CONS_Alert(CONS_WARNING, "cv_palette %s lump does not exist\n", user); + } + else + { + return cv_palette.string; + } + } + if (gamestate == GS_LEVEL) return R_GetPalname((encoremode ? mapheaderinfo[gamemap-1]->encorepal : mapheaderinfo[gamemap-1]->palette)); + return "PLAYPAL"; } @@ -524,6 +550,20 @@ void V_SetPalette(INT32 palettenum) if (!pLocalPalette) V_ReloadPalette(); + if (rendermode == render_soft || (rendermode == render_opengl && HWR_ShouldUsePaletteRendering())) // opengl without paletterendering hates subpalettes + { + if (palettenum == 0) + { + palettenum = cv_palettenum.value; + + if (palettenum * 256U > currentPaletteSize - 256) + { + CONS_Alert(CONS_WARNING, "cv_palettenum %d out of range\n", palettenum); + palettenum = 0; + } + } + } + #ifdef HWRENDER if (rendermode == render_opengl) HWR_SetPalette(&pLocalPalette[palettenum*256]); @@ -538,18 +578,7 @@ void V_SetPalette(INT32 palettenum) void V_SetPaletteLump(const char *pal) { LoadPalette(pal); -#ifdef HWRENDER - if (rendermode == render_opengl) - HWR_SetPalette(pLocalPalette); -#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) - else -#endif -#endif - if (rendermode != render_none) - I_SetPalette(pLocalPalette); -#ifdef HASINVERT - R_MakeInvertmap(); -#endif + V_SetPalette(0); } static void CV_palette_OnChange(void) @@ -557,6 +586,7 @@ static void CV_palette_OnChange(void) if (loaded_config == false) return; // reload palette + // recalculate Color Cube V_ReloadPalette(); V_SetPalette(0); } diff --git a/src/v_video.h b/src/v_video.h index 85338751c..c8eca1069 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -28,12 +28,12 @@ extern UINT8 *screens[5]; -extern consvar_t cv_ticrate, cv_accuratefps, cv_allcaps, cv_constextsize, cv_menucaps,\ -cv_globalgamma, cv_globalsaturation,\ -cv_rhue, cv_yhue, cv_ghue, cv_chue, cv_bhue, cv_mhue,\ -cv_rgamma, cv_ygamma, cv_ggamma, cv_cgamma, cv_bgamma, cv_mgamma, \ -cv_rsaturation, cv_ysaturation, cv_gsaturation, cv_csaturation, cv_bsaturation, cv_msaturation; - +extern consvar_t cv_ticrate, cv_accuratefps, cv_allcaps, cv_constextsize, cv_menucaps, +cv_globalgamma, cv_globalsaturation, +cv_rhue, cv_yhue, cv_ghue, cv_chue, cv_bhue, cv_mhue, +cv_rgamma, cv_ygamma, cv_ggamma, cv_cgamma, cv_bgamma, cv_mgamma, +cv_rsaturation, cv_ysaturation, cv_gsaturation, cv_csaturation, cv_bsaturation, cv_msaturation, +cv_palette, cv_palettenum; // Allocates buffer screens, call before R_Init. void V_Init(void); From 1ffb655131e9cf488b5100bcc672e51e2b86c5f5 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 22 Apr 2025 05:04:04 +0200 Subject: [PATCH 280/350] speed up ogl palette stuff doesent wipe all our gpu textures if palette hasnt changed too lol --- src/hardware/r_opengl/r_opengl.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 4621658ce..457f7fcf9 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -683,7 +683,7 @@ typedef enum gluniform_leveltime, gluniform_scr_resolution, - + gluniform_max, } gluniform_t; @@ -1328,14 +1328,13 @@ void GL_ReadScreenTexture(int tex, UINT16 *dst_data) // -----------------+ void GL_SetPalette(RGBA_t *palette) { - INT32 i; - - for (i = 0; i < 256; i++) + size_t palsize = (sizeof(RGBA_t) * 256); + // on a palette change, you have to reload all of the textures + if (memcmp(&myPaletteData, palette, palsize)) { - myPaletteData[i].s = palette[i].s; + memcpy(&myPaletteData, palette, palsize); + GL_Flush(); } - - GL_Flush(); } // -----------------+ @@ -2641,7 +2640,7 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics poly.green = byte2float[Surface->PolyColor.s.green]; poly.blue = byte2float[Surface->PolyColor.s.blue]; poly.alpha = byte2float[Surface->PolyColor.s.alpha]; - + pglColor4ubv((GLubyte*)&Surface->PolyColor.s); GL_SetBlend((poly.alpha < 1 ? Surface->PolyFlags : (PF_Masked|PF_Occlude))|PF_Modulated); @@ -2655,7 +2654,7 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics fade.green = byte2float[Surface->FadeColor.s.green]; fade.blue = byte2float[Surface->FadeColor.s.blue]; fade.alpha = byte2float[Surface->FadeColor.s.alpha]; - + if (Surface->LightTableId && Surface->LightTableId != lt_downloaded) { pglActiveTexture(GL_TEXTURE2); From e5e63a56a13f5ec337c01527c3ba055a40a2b686 Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 22 Apr 2025 18:24:59 +0300 Subject: [PATCH 281/350] Don't resume music when game is paused (happens when you pause -> lose window focus -> regain window focus) --- src/s_sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s_sound.c b/src/s_sound.c index 9db004a44..6aa3f74ae 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1839,7 +1839,7 @@ void S_ResumeAudio(void) if (S_MusicNotInFocus()) return; - if (I_SongPlaying() && I_SongPaused()) + if (!paused && I_SongPlaying() && I_SongPaused()) I_ResumeSong(); } From 2a3e4c4c6d64e46f52acd595bd84a5f798a2a7cb Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 22 Apr 2025 20:13:28 +0200 Subject: [PATCH 282/350] smol cleanup z_zone --- src/z_zone.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/z_zone.c b/src/z_zone.c index 698861dfb..548c1e025 100644 --- a/src/z_zone.c +++ b/src/z_zone.c @@ -656,7 +656,7 @@ static void Command_Memfree_f(void) Z_CheckHeap(-1); CONS_Printf("\x82%s", M_GetText("Memory Info\n")); - CONS_Printf(M_GetText("Total heap used : %7s KB\n"), sizeu1(Z_TagsUsage(0, INT32_MAX)>>10)); + CONS_Printf(M_GetText("Total heap used : %7s KB\n"), sizeu1(Z_TotalUsage()>>10)); CONS_Printf(M_GetText("Lua : %7s KB\n"), sizeu1(Z_TagUsage(PU_LUA)>>10)); CONS_Printf(M_GetText("Static : %7s KB\n"), sizeu1(Z_TagUsage(PU_STATIC)>>10)); CONS_Printf(M_GetText("Static (sound) : %7s KB\n"), sizeu1(Z_TagUsage(PU_SOUND)>>10)); @@ -673,7 +673,7 @@ static void Command_Memfree_f(void) sizeu1(Z_TagsUsage(PU_PURGELEVEL, INT32_MAX)>>10)); #ifdef HWRENDER - if (rendermode != render_soft && rendermode != render_none) + if (rendermode == render_opengl) { CONS_Printf(M_GetText("Patch info headers : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHINFO)>>10)); CONS_Printf(M_GetText("Cached textures : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRCACHE)>>10)); @@ -690,8 +690,6 @@ static void Command_Memfree_f(void) CONS_Printf(M_GetText("Available physical memory: %s KB\n"), sizeu1(freebytes>>10)); } - - #ifdef ZDEBUG /** The function called by the "memdump" console command. * Prints zone memory debugging information (i.e. tag, size, location in code allocated). From 89906cf384344420ed947d2c7fefd5553270101c Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 22 Apr 2025 18:43:19 +0100 Subject: [PATCH 283/350] Revert "speed up ogl palette stuff" why is windows like this? This reverts commit 1ffb655131e9cf488b5100bcc672e51e2b86c5f5. --- src/hardware/r_opengl/r_opengl.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 457f7fcf9..4621658ce 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -683,7 +683,7 @@ typedef enum gluniform_leveltime, gluniform_scr_resolution, - + gluniform_max, } gluniform_t; @@ -1328,13 +1328,14 @@ void GL_ReadScreenTexture(int tex, UINT16 *dst_data) // -----------------+ void GL_SetPalette(RGBA_t *palette) { - size_t palsize = (sizeof(RGBA_t) * 256); - // on a palette change, you have to reload all of the textures - if (memcmp(&myPaletteData, palette, palsize)) + INT32 i; + + for (i = 0; i < 256; i++) { - memcpy(&myPaletteData, palette, palsize); - GL_Flush(); + myPaletteData[i].s = palette[i].s; } + + GL_Flush(); } // -----------------+ @@ -2640,7 +2641,7 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics poly.green = byte2float[Surface->PolyColor.s.green]; poly.blue = byte2float[Surface->PolyColor.s.blue]; poly.alpha = byte2float[Surface->PolyColor.s.alpha]; - + pglColor4ubv((GLubyte*)&Surface->PolyColor.s); GL_SetBlend((poly.alpha < 1 ? Surface->PolyFlags : (PF_Masked|PF_Occlude))|PF_Modulated); @@ -2654,7 +2655,7 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics fade.green = byte2float[Surface->FadeColor.s.green]; fade.blue = byte2float[Surface->FadeColor.s.blue]; fade.alpha = byte2float[Surface->FadeColor.s.alpha]; - + if (Surface->LightTableId && Surface->LightTableId != lt_downloaded) { pglActiveTexture(GL_TEXTURE2); From b43ca1f3c7e1e1ee1990dccaf1c570056a63496d Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 22 Apr 2025 09:27:40 +0200 Subject: [PATCH 284/350] let saltyhop work without gravstretch --- src/k_kart.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 344c1ace2..291b79409 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3462,9 +3462,6 @@ static void K_SpawnAIZDust(player_t *player) static void K_StretchPlayerGravity(player_t *player) { - if (!cv_gravstretch.value) - return; - I_Assert(player != NULL); I_Assert(!P_MobjWasRemoved(player->mo)); @@ -3515,6 +3512,30 @@ static void K_StretchPlayerGravity(player_t *player) pmo->stretchslam = 0; } +// copy pasted from above +// but here to allow salty squish to work when gravstretch is disabled +static void K_SaltySquish(player_t *player) +{ + I_Assert(player != NULL); + I_Assert(!P_MobjWasRemoved(player->mo)); + + mobj_t *pmo = player->mo; + + fixed_t tempxscale = pmo->realxscale; + fixed_t tempyscale = pmo->realyscale; + + if (pmo->stretchslam > 0) + { + const fixed_t slamDiv = FixedDiv(pmo->stretchslam, 3932160); // stretchScaleFactor = FixedDiv(FRACUNIT*60, FRACUNIT) + + pmo->spritexscale = (tempxscale + (((slamDiv*2)/3)*2)); + pmo->spriteyscale = (tempyscale - slamDiv); + pmo->stretchslam -= (4*FRACUNIT); + } + else + pmo->stretchslam = 0; +} + static void K_QuiteSaltyHop(player_t *player) { if (!cv_saltyhop.value) @@ -7028,7 +7049,11 @@ void K_MoveKartPlayer(player_t *player, boolean onground) } // funneh Saturn sprite stuff - K_StretchPlayerGravity(player); + if (cv_gravstretch.value) + K_StretchPlayerGravity(player); + else if (cv_saltyhop.value && cv_saltysquish.value) + K_SaltySquish(player); + K_RollMobjBySlopes(player->mo, player->mo->standingslope); // Quick Turning From 8edec89a36da4184d6720d9a555fa5037f5a0f08 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 22 Apr 2025 21:52:46 +0200 Subject: [PATCH 285/350] fix cloud tops palette not applying --- src/p_setup.c | 2 +- src/v_video.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index e3b012d31..32f77658d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3018,7 +3018,7 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) // Reset the palette now all fades have been done if (rendermode != render_none) - V_ReloadPalette(); // Set the level palette + V_SetPaletteLump(GetPalette()); // Set the level palette // Print "SPEEDING OFF TO [ZONE] [ACT 1]..." /*if (rendermode != render_none) diff --git a/src/v_video.c b/src/v_video.c index 217bb0ae5..2552244c4 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -579,6 +579,9 @@ void V_SetPaletteLump(const char *pal) { LoadPalette(pal); V_SetPalette(0); +#ifdef HASINVERT + R_MakeInvertmap(); +#endif } static void CV_palette_OnChange(void) From db9435f81021d063ef4713f6d0ef34f33b5ed07c Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 22 Apr 2025 22:10:49 +0200 Subject: [PATCH 286/350] reset palette cvars when toggling paletterendering everything gets wiped anyways, so this would be just confusing --- src/hardware/hw_main.c | 2 ++ src/p_setup.c | 3 +++ src/sdl/ogl_sdl.c | 8 ++++---- src/v_video.c | 17 +++++++++++++++-- src/v_video.h | 2 ++ 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index b7ece1f81..75a62f596 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5721,6 +5721,8 @@ void HWR_LoadLevel(void) // shader recompilation is done in the cvar callback static void HWR_TogglePaletteRendering(void) { + V_ResetPaletteCVars(); // dont carry over changed palettes + // which state should we go to? if (HWR_ShouldUsePaletteRendering()) { diff --git a/src/p_setup.c b/src/p_setup.c index 32f77658d..2582261e9 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3018,7 +3018,10 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) // Reset the palette now all fades have been done if (rendermode != render_none) + { + //V_ResetPaletteCVars(); // dont carry over changed palettes V_SetPaletteLump(GetPalette()); // Set the level palette + } // Print "SPEEDING OFF TO [ZONE] [ACT 1]..." /*if (rendermode != render_none) diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 73f6635e3..d6805cf21 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -134,7 +134,7 @@ boolean OglSdlSurface(INT32 w, INT32 h) if (!first_init) { - if (!gllogstream) + if (!gllogstream) { gllogdir = D_Home(); @@ -147,7 +147,7 @@ boolean OglSdlSurface(INT32 w, INT32 h) gllogstream = fopen("./ogllog.txt", "wt"); #endif } - + gl_version = pglGetString(GL_VERSION); gl_renderer = pglGetString(GL_RENDERER); gl_extensions = pglGetString(GL_EXTENSIONS); @@ -220,7 +220,7 @@ boolean OglSdlSurface(INT32 w, INT32 h) } SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0); - + // The screen textures need to be flushed if the width or height change so that they be remade for the correct size if (screen_width != w || screen_height != h) { @@ -310,7 +310,7 @@ void OglSdlFinishUpdate(boolean waitvbl) #if defined (__unix__) #ifdef USE_FBO_OGL - if (loaded_config == true) + if (loaded_config) xwaylandcrap = false; #endif #endif diff --git a/src/v_video.c b/src/v_video.c index 2552244c4..34bc9f296 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -139,7 +139,7 @@ static boolean InitCube(void) float globalgammamul, globalgammaoffs; boolean doinggamma; - if (loaded_config == false) + if (!loaded_config) return false; #define diffcons(cv) (strcmp(cv.string, cv.defaultvalue)) @@ -586,7 +586,7 @@ void V_SetPaletteLump(const char *pal) static void CV_palette_OnChange(void) { - if (loaded_config == false) + if (!loaded_config) return; // reload palette // recalculate Color Cube @@ -594,6 +594,19 @@ static void CV_palette_OnChange(void) V_SetPalette(0); } +void V_ResetPaletteCVars(void) +{ + if (!loaded_config) + return; + +#define diffcons(cv) (strcmp(cv.string, cv.defaultvalue)) + if diffcons(cv_palette) + CV_StealthSetValue(&cv_palette, atoi(cv_palette.defaultvalue)); + if diffcons(cv_palettenum) + CV_StealthSetValue(&cv_palettenum, atoi(cv_palettenum.defaultvalue)); +#undef diffcons +} + static void CV_constextsize_OnChange(void) { con_recalc = true; diff --git a/src/v_video.h b/src/v_video.h index c8eca1069..c8f614afc 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -60,6 +60,8 @@ void V_SetPalette(INT32 palettenum); void V_SetPaletteLump(const char *pal); +void V_ResetPaletteCVars(void); + const char *R_GetPalname(UINT16 num); const char *GetPalette(void); From 60e0e501415ea3915dd28503fa40c09633b441de Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 00:17:31 +0200 Subject: [PATCH 287/350] try to fix skywalls zfighting just apply a small polygonoffset to them lets hope this is small enough so they dont end up rendering infront of actual textures and such --- src/hardware/hw_defs.h | 3 ++- src/hardware/hw_main.c | 4 ++-- src/hardware/r_opengl/r_opengl.c | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index 43e320fc0..822389758 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -255,7 +255,8 @@ enum EPolyFlags PF_RemoveYWrap = 0x00010000, // Force clamp texture on Y PF_ForceWrapX = 0x00020000, // Force repeat texture on X PF_ForceWrapY = 0x00040000, // Forces repeat texture on Y - PF_Ripple = 0x00100000 // Water ripple effect. The current backend doesn't use it for anything. + PF_Ripple = 0x00100000, // Water ripple effect. The current backend doesn't use it for anything. + PF_Skydecal = 0x20000000 // Enables smaller polygon offset, to be used for skywalls only // 0x20000000 // 0x40000000 // 0x80000000 diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 65b6137bf..37d0e25cd 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1211,7 +1211,7 @@ static void HWR_DrawSkyWallList(void) GL_UnSetShader(); for (i = 0; i < skyWallVertexArraySize; i++) { - GL_DrawPolygon(&surf, skyWallVertexArray + i * 4, 4, PF_Occlude|PF_Invisible|PF_NoTexture); + GL_DrawPolygon(&surf, skyWallVertexArray + i * 4, 4, PF_Occlude|PF_Invisible|PF_NoTexture|PF_Skydecal); } } @@ -1233,7 +1233,7 @@ static void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf) else { HWR_SetCurrentTexture(NULL); - HWR_ProjectWall(wallVerts, Surf, PF_Invisible|PF_NoTexture, 255, NULL); + HWR_ProjectWall(wallVerts, Surf, PF_Invisible|PF_NoTexture|PF_Skydecal, 255, NULL); } // PF_Invisible so it's not drawn into the colour buffer // PF_NoTexture for no texture diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 40129b3b1..0fcb58a3d 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1529,7 +1529,7 @@ void GL_SetBlend(FBITFIELD PolyFlags) { const FBITFIELD Xor = CurrentPolyFlags^PolyFlags;; - if (Xor & (PF_Blending|PF_RemoveYWrap|PF_ForceWrapX|PF_ForceWrapY|PF_Occlude|PF_NoTexture|PF_Modulated|PF_NoDepthTest|PF_Decal|PF_Invisible)) + if (Xor & (PF_Blending|PF_RemoveYWrap|PF_ForceWrapX|PF_ForceWrapY|PF_Occlude|PF_NoTexture|PF_Modulated|PF_NoDepthTest|PF_Decal|PF_Skydecal|PF_Invisible)) { if (Xor & PF_Blending) // if blending mode must be changed GL_SetBlendMode(PolyFlags & PF_Blending); @@ -1545,7 +1545,21 @@ void GL_SetBlend(FBITFIELD PolyFlags) if (Xor & PF_Decal) { if (PolyFlags & PF_Decal) + { + pglPolygonOffset(-1.0f, -1.0f); pglEnable(GL_POLYGON_OFFSET_FILL); + } + else + pglDisable(GL_POLYGON_OFFSET_FILL); + } + + if (Xor & PF_Skydecal) + { + if (PolyFlags & PF_Skydecal) + { + pglPolygonOffset(-0.45f, -0.45f); // dont let skywalls draw over actual walls tho + pglEnable(GL_POLYGON_OFFSET_FILL); + } else pglDisable(GL_POLYGON_OFFSET_FILL); } From 5aca7e12c79a92839b05dfdd55ff4a049822e4d1 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 28 Mar 2025 04:52:50 +0100 Subject: [PATCH 288/350] :3 --- src/d_player.h | 2 ++ src/p_user.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/src/d_player.h b/src/d_player.h index 7ecef63de..a1e4a0b20 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -555,6 +555,8 @@ typedef struct player_s fixed_t spinoutrot; // When a player spins out, this value increments modulus 360. + tic_t dancetime; + fixed_t fovadd; // adjust FOV for hw rendering } player_t; diff --git a/src/p_user.c b/src/p_user.c index 536ebc771..4b3de290c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4439,6 +4439,37 @@ DoABarrelRoll (player_t *player) #define SPINOUTROTSPEED (24 * FRACUNIT) #define MAXSPINROT (360 * FRACUNIT) +static void P_DoFunnyDance (player_t *player) +{ + static tic_t time = 0; + fixed_t bounce; + fixed_t work, bpm; + angle_t ang; + + if (player->spectator || !player->mo || player->kartstuff[k_respawn] || player->mo->salty_jump) // this looks jank as hell during hop + return; + + bounce = 0; + + // bpm = FLOAT_TO_FIXED(mapmusic.bpm) << maybe can get the tempo and beat detection lib to work for bpm autodetection + bpm = FixedDiv((60*TICRATE)<= (FRACUNIT>>1)) // prevent overflow jump - takes about 15 minutes + time = (work>>FRACBITS); + + work = FixedDiv(work*180, bpm); + + ang = (FixedAngle(work)>>ANGLETOFINESHIFT) & FINEMASK; + bounce = (FINESINE(ang) - FRACUNIT/2); + + player->mo->spritexscale -= bounce/2; + player->mo->spriteyscale += bounce/2; + + time++; // bruh +} + // // P_PlayerThink // @@ -4976,6 +5007,16 @@ void P_PlayerThink(player_t *player) if (player->losstime && !player->powers[pw_flashing]) player->losstime--; + if (cmd->buttons & BT_CUSTOM3) + { + player->dancetime++; + + if (player->dancetime > TICRATE*2) + P_DoFunnyDance(player); + } + else + player->dancetime = 0; + // Flash player after being hit. if (!(player->kartstuff[k_hyudorotimer] // SRB2kart - fixes Hyudoro not flashing when it should. || player->kartstuff[k_growshrinktimer] > 0 // Grow doesn't flash either. From c4aba91e79ba1c96a0c9cea2702f42bf4305f8e1 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 09:04:54 +0200 Subject: [PATCH 289/350] shh --- src/g_game.h | 2 ++ src/k_kart.c | 4 ++++ src/p_user.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/g_game.h b/src/g_game.h index e50557a9d..8027d86f2 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -187,6 +187,8 @@ extern consvar_t cv_sloperolldist; extern consvar_t cv_sparkroll; extern consvar_t cv_spinoutroll; +extern consvar_t cv_squishdance; + extern consvar_t cv_playerblendeffects; extern consvar_t cv_cechotoggle; diff --git a/src/k_kart.c b/src/k_kart.c index 291b79409..1e2190c2f 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -149,6 +149,8 @@ static CV_PossibleValue_t saltyheight_t[] = {{FRACUNIT/4, "MIN"}, {2*FRACUNIT, " consvar_t cv_saltyheight = {"hardcodehopheight", "1", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, saltyheight_t, saltyhop_onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_saltyroll = {"hardcodehoproll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_squishdance = {"squishdance", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + static void saltyhop_onchange(void) { // reset everything when toggling saltyhop @@ -1001,6 +1003,8 @@ void K_RegisterClientKartStuff(void) CV_RegisterVar(&cv_slamsound); + CV_RegisterVar(&cv_squishdance); + CV_RegisterVar(&cv_lessflicker); CV_RegisterVar(&cv_mouseturn); diff --git a/src/p_user.c b/src/p_user.c index 4b3de290c..c9712048e 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5007,7 +5007,7 @@ void P_PlayerThink(player_t *player) if (player->losstime && !player->powers[pw_flashing]) player->losstime--; - if (cmd->buttons & BT_CUSTOM3) + if (cv_squishdance.value && (cmd->buttons & BT_CUSTOM3)) { player->dancetime++; From ef93209d409816f2104d40bc12a942073e1072cf Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 11:23:09 +0200 Subject: [PATCH 290/350] delet bunch of stuff --- src/d_clisrv.c | 5 ----- src/d_clisrv.h | 1 - src/doomstat.h | 2 -- src/info.c | 2 +- src/p_setup.c | 15 ++++----------- src/sdl/i_system.c | 6 ------ 6 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 97b6c9358..4a2a0cc0f 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -539,11 +539,6 @@ void D_ResetTiccmds(void) D_Clearticcmd(textcmds[i]->tic); } -ticcmd_t *D_LocalTiccmd(UINT8 ss) -{ - return &localcmds[ss][0]; -} - void SendKick(UINT8 playernum, UINT8 msg) { UINT8 buf[2]; diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 8ad038a36..65884362b 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -662,7 +662,6 @@ extern UINT8 playernode[MAXPLAYERS]; INT32 D_NumPlayers(void); void D_ResetTiccmds(void); -ticcmd_t *D_LocalTiccmd(UINT8 ss); tic_t GetLag(INT32 node); //UINT8 GetFreeXCmdSize(UINT8 playerid); diff --git a/src/doomstat.h b/src/doomstat.h index 6e1aa2485..f6e708be6 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -299,8 +299,6 @@ typedef struct #define LF_NORELOAD 8 ///< Don't reload level on death #define LF_NOZONE 16 ///< Don't include "ZONE" on level title #define LF_SECTIONRACE 32 ///< Section race level -#define LF_SUBTRACTNUM 64 ///< Use subtractive position number (for bright levels) - #define LF2_HIDEINMENU 1 ///< Hide in the multiplayer menu #define LF2_HIDEINSTATS 2 ///< Hide in the statistics screen diff --git a/src/info.c b/src/info.c index fcf0029e9..7afc76bf6 100644 --- a/src/info.c +++ b/src/info.c @@ -2614,7 +2614,7 @@ state_t states[NUMSTATES] = {SPR_KINV, FF_FULLBRIGHT|1, 1, {NULL}, 0, 0, S_KARTINVULN_SMALL3}, // S_KARTINVULN_SMALL2 {SPR_KINV, FF_FULLBRIGHT|2, 1, {NULL}, 0, 0, S_KARTINVULN_SMALL4}, // S_KARTINVULN_SMALL3 {SPR_KINV, FF_FULLBRIGHT|3, 1, {NULL}, 0, 0, S_KARTINVULN_SMALL5}, // S_KARTINVULN_SMALL4 - {SPR_KINV, FF_FULLBRIGHT|4, 1, {NULL}, 0, 0, S_NULL}, // S_KARTINVULN_SMALL5 + {SPR_KINV, FF_FULLBRIGHT|4, 1, {NULL}, 0, 0, S_NULL}, // S_KARTINVULN_SMALL5 {SPR_KINV, FF_FULLBRIGHT|1, 1, {NULL}, 0, 0, S_KARTINVULN_LARGE2}, // S_KARTINVULN_LARGE1 {SPR_KINV, FF_FULLBRIGHT|2, 1, {NULL}, 0, 0, S_KARTINVULN_LARGE3}, // S_KARTINVULN_LARGE2 diff --git a/src/p_setup.c b/src/p_setup.c index 5d13df8b5..e4c22f253 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -615,10 +615,10 @@ static void P_SetupDirectionalLight(void) if (gamemap != oldmap || encoremode != oldencore || reinitmaplight) { - maplighting.contrast = M_RandomRange(0, 58); - maplighting.backlight = 0; - maplighting.directional = M_RandomRange(0, 1); // either on or off - maplighting.angle = M_RandomRange(-382, 382); + lighting->light_contrast = M_RandomRange(0, 58); + lighting->sprite_backlight = 0; + lighting->use_light_angle = M_RandomRange(0, 1); // either on or off + lighting->light_angle = M_RandomRange(-382, 382); reinitmaplight = false; } @@ -627,13 +627,6 @@ static void P_SetupDirectionalLight(void) oldencore = encoremode; return; } - else if (lighting->use_custom_light == false) - { - maplighting.contrast = 8; - maplighting.backlight = 0; - maplighting.directional = false; - maplighting.angle = 0; - } maplighting.contrast = lighting->light_contrast; maplighting.backlight = lighting->sprite_backlight; diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 1262707a8..b622c4c45 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -501,9 +501,6 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) write_backtrace(BT_CRASH_REASON_SIGNAL(num)); #endif - if (demo.recording) - G_SaveDemo(); - I_ReportSignal(num, 0); I_ShutdownSystem(); signal(num, SIG_DFL); //default signal action @@ -884,9 +881,6 @@ static void signal_handler_child(INT32 num) write_backtrace(BT_CRASH_REASON_SIGNAL(num)); #endif - if (demo.recording) - G_SaveDemo(); - signal(num, SIG_DFL); //default signal action raise(num); } From e87ca3fe1b36edfa6347b664dccda4425cbd7c1d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 13:09:03 +0200 Subject: [PATCH 291/350] fix cv_set being called for allowsaturnjoin before its registered --- src/d_netcmd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 37fec1869..b380b8d76 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -752,6 +752,11 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_killingdead); // d_clisrv +#ifndef NONET +#ifdef SATURNJOIN + CV_RegisterVar(&cv_allownewsaturnplayer); // need to register it before cv_maxplayers && cv_allownewplayer +#endif +#endif CV_RegisterVar(&cv_maxplayers); CV_RegisterVar(&cv_resynchattempts); #ifdef SATURNPAK @@ -765,9 +770,7 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_httpsource); #ifndef NONET CV_RegisterVar(&cv_allownewplayer); -#ifdef SATURNJOIN - CV_RegisterVar(&cv_allownewsaturnplayer); -#endif + CV_RegisterVar(&cv_joinrefusemessage); CV_RegisterVar(&cv_chatlogsize); #ifdef VANILLAJOINNEXTROUND From 72ea257a063f10ada40a6a63ed401b56684f8eba Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 13:10:07 +0200 Subject: [PATCH 292/350] we have a global to check if config was loaded --- src/d_main.c | 6 ++++-- src/m_misc.c | 7 +------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index ad65138e8..44511b87d 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -147,7 +147,7 @@ INT32 eventhead, eventtail; boolean dedicated = false; -boolean loaded_config = false; +boolean loaded_config = false; // true once config.cfg loaded AND executed // // D_PostEvent @@ -1881,7 +1881,9 @@ void D_SRB2Main(void) savedata.lives = 0; // flag this as not-used - loaded_config = true; // so pallettechange doesent get called 500 times at startup lol + // make sure I_Quit() will write back the correct config + // (do not write back the config if it crash before) + loaded_config = true; // so palettechange doesent get called 500 times at startup lol //------------------------------------------------ COMMAND LINE PARAMS diff --git a/src/m_misc.c b/src/m_misc.c index ca4b745ed..ff9892464 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -443,7 +443,6 @@ char configfile[MAX_WADPATH]; // ========================================================================== // CONFIGURATION // ========================================================================== -static boolean gameconfig_loaded = false; // true once config.cfg loaded AND executed /** Saves a player's config, possibly to a particular file. * @@ -548,10 +547,6 @@ void M_FirstLoadConfig(void) // don't filter anymore vars and don't let this convsvar be changed COM_BufInsertText(va("%s \"%d\"\n", cv_execversion.name, EXECVERSION)); CV_ToggleExecVersion(false); - - // make sure I_Quit() will write back the correct config - // (do not write back the config if it crash before) - gameconfig_loaded = true; } /** Saves the game configuration. @@ -565,7 +560,7 @@ void M_SaveConfig(const char *filename) char backupfile[MAX_WADPATH+4]; // make sure not to write back the config until it's been correctly loaded - if (!gameconfig_loaded) + if (!loaded_config) return; // Create backup of the config file From abba2a9eac194fb0a49aa593d246c465d5ff586c Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 13:09:03 +0200 Subject: [PATCH 293/350] fix cv_set being called for allowsaturnjoin before its registered --- src/d_netcmd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index ebbf91736..3b53dd8c4 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -752,6 +752,11 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_killingdead); // d_clisrv +#ifndef NONET +#ifdef SATURNJOIN + CV_RegisterVar(&cv_allownewsaturnplayer); // need to register it before cv_maxplayers && cv_allownewplayer +#endif +#endif CV_RegisterVar(&cv_maxplayers); CV_RegisterVar(&cv_resynchattempts); #ifdef SATURNPAK @@ -765,9 +770,7 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_httpsource); #ifndef NONET CV_RegisterVar(&cv_allownewplayer); -#ifdef SATURNJOIN - CV_RegisterVar(&cv_allownewsaturnplayer); -#endif + CV_RegisterVar(&cv_joinrefusemessage); CV_RegisterVar(&cv_chatlogsize); #ifdef VANILLAJOINNEXTROUND From 0b515939ad4719d3f55cbfc42ecb181cc35c8695 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 13:10:07 +0200 Subject: [PATCH 294/350] we have a global to check if config was loaded --- src/d_main.c | 6 ++++-- src/m_misc.c | 7 +------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index ad65138e8..44511b87d 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -147,7 +147,7 @@ INT32 eventhead, eventtail; boolean dedicated = false; -boolean loaded_config = false; +boolean loaded_config = false; // true once config.cfg loaded AND executed // // D_PostEvent @@ -1881,7 +1881,9 @@ void D_SRB2Main(void) savedata.lives = 0; // flag this as not-used - loaded_config = true; // so pallettechange doesent get called 500 times at startup lol + // make sure I_Quit() will write back the correct config + // (do not write back the config if it crash before) + loaded_config = true; // so palettechange doesent get called 500 times at startup lol //------------------------------------------------ COMMAND LINE PARAMS diff --git a/src/m_misc.c b/src/m_misc.c index ca4b745ed..ff9892464 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -443,7 +443,6 @@ char configfile[MAX_WADPATH]; // ========================================================================== // CONFIGURATION // ========================================================================== -static boolean gameconfig_loaded = false; // true once config.cfg loaded AND executed /** Saves a player's config, possibly to a particular file. * @@ -548,10 +547,6 @@ void M_FirstLoadConfig(void) // don't filter anymore vars and don't let this convsvar be changed COM_BufInsertText(va("%s \"%d\"\n", cv_execversion.name, EXECVERSION)); CV_ToggleExecVersion(false); - - // make sure I_Quit() will write back the correct config - // (do not write back the config if it crash before) - gameconfig_loaded = true; } /** Saves the game configuration. @@ -565,7 +560,7 @@ void M_SaveConfig(const char *filename) char backupfile[MAX_WADPATH+4]; // make sure not to write back the config until it's been correctly loaded - if (!gameconfig_loaded) + if (!loaded_config) return; // Create backup of the config file From 0ceeac4726cf799ea7f4f645adb7527bd8b63ab8 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 13:23:11 +0200 Subject: [PATCH 295/350] nooo PARANOIA dont set our thinker next to NULL --- src/p_tick.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 8fbdf8b6a..91f40c623 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -243,13 +243,19 @@ static thinker_t *currentthinker; void P_RemoveThinkerDelayed(thinker_t *thinker) { #ifdef PARANOIA - if (thinker->next) - thinker->next = NULL; - else if (thinker->references) // Usually gets cleared up in one frame; what's going on here, then? - CONS_Printf("Number of potentially faulty references: %d\n", thinker->references); -#endif - if (thinker->references) +#define BEENAROUNDBIT (0x40000000) // has to be sufficiently high that it's unlikely to happen in regular gameplay. If you change this, pay attention to the bit pattern of INT32_MIN. + if (thinker->references & ~BEENAROUNDBIT) + { + if (thinker->references & BEENAROUNDBIT) // Usually gets cleared up in one frame; what's going on here, then? + CONS_Printf("Number of potentially faulty references: %d\n", (thinker->references & ~BEENAROUNDBIT)); + thinker->references |= BEENAROUNDBIT; return; + } +#undef BEENAROUNDBIT +#else + if (thinker->references != 0) + return; +#endif /* Remove from main thinker list */ thinker_t *next = thinker->next; From cd7177682ab8696e6c4fdf72d0c8175f0e1c4b2d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 13:43:55 +0200 Subject: [PATCH 296/350] fix P_RemoveSavegameMobj triggering assert in P_UnlinkThinker --- src/p_mobj.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index a743f05fc..66d4493ca 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10163,8 +10163,10 @@ void P_FreePrecipMobj(precipmobj_t *mobj) // Clearing out stuff for savegames void P_RemoveSavegameMobj(mobj_t *mobj) { + thinker_t *th = (thinker_t*)mobj; + // unlink from sector and block lists - if (((thinker_t *)mobj)->function.acp1 == (actionf_p1)P_NullPrecipThinker) + if (th->function.acp1 == (actionf_p1)P_NullPrecipThinker) { P_UnsetPrecipThingPosition((precipmobj_t *)mobj); } @@ -10185,9 +10187,13 @@ void P_RemoveSavegameMobj(mobj_t *mobj) S_StopSound(mobj); R_RemoveMobjInterpolator(mobj); + // just set its reference count to 0 to not trigger the assert in P_UnlinkThinker + if (th->references != 0) + th->references = 0; + // free block // Here we use the same code as R_RemoveThinkerDelayed, but without reference counting (we're removing everything so it shouldn't matter) and without touching currentthinker since we aren't in P_RunThinkers - P_UnlinkThinker((thinker_t*)mobj); + P_UnlinkThinker(th); } static CV_PossibleValue_t respawnitemtime_cons_t[] = {{1, "MIN"}, {300, "MAX"}, {0, NULL}}; From 6509e7fdf95996d32fc6dd743fc55d80932db635 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 13:23:11 +0200 Subject: [PATCH 297/350] nooo PARANOIA dont set our thinker next to NULL --- src/p_tick.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 8fbdf8b6a..91f40c623 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -243,13 +243,19 @@ static thinker_t *currentthinker; void P_RemoveThinkerDelayed(thinker_t *thinker) { #ifdef PARANOIA - if (thinker->next) - thinker->next = NULL; - else if (thinker->references) // Usually gets cleared up in one frame; what's going on here, then? - CONS_Printf("Number of potentially faulty references: %d\n", thinker->references); -#endif - if (thinker->references) +#define BEENAROUNDBIT (0x40000000) // has to be sufficiently high that it's unlikely to happen in regular gameplay. If you change this, pay attention to the bit pattern of INT32_MIN. + if (thinker->references & ~BEENAROUNDBIT) + { + if (thinker->references & BEENAROUNDBIT) // Usually gets cleared up in one frame; what's going on here, then? + CONS_Printf("Number of potentially faulty references: %d\n", (thinker->references & ~BEENAROUNDBIT)); + thinker->references |= BEENAROUNDBIT; return; + } +#undef BEENAROUNDBIT +#else + if (thinker->references != 0) + return; +#endif /* Remove from main thinker list */ thinker_t *next = thinker->next; From 87fd33793d3c61c64bc2ac2cbf55cc0cab13e426 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 13:43:55 +0200 Subject: [PATCH 298/350] fix P_RemoveSavegameMobj triggering assert in P_UnlinkThinker --- src/p_mobj.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index a743f05fc..66d4493ca 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10163,8 +10163,10 @@ void P_FreePrecipMobj(precipmobj_t *mobj) // Clearing out stuff for savegames void P_RemoveSavegameMobj(mobj_t *mobj) { + thinker_t *th = (thinker_t*)mobj; + // unlink from sector and block lists - if (((thinker_t *)mobj)->function.acp1 == (actionf_p1)P_NullPrecipThinker) + if (th->function.acp1 == (actionf_p1)P_NullPrecipThinker) { P_UnsetPrecipThingPosition((precipmobj_t *)mobj); } @@ -10185,9 +10187,13 @@ void P_RemoveSavegameMobj(mobj_t *mobj) S_StopSound(mobj); R_RemoveMobjInterpolator(mobj); + // just set its reference count to 0 to not trigger the assert in P_UnlinkThinker + if (th->references != 0) + th->references = 0; + // free block // Here we use the same code as R_RemoveThinkerDelayed, but without reference counting (we're removing everything so it shouldn't matter) and without touching currentthinker since we aren't in P_RunThinkers - P_UnlinkThinker((thinker_t*)mobj); + P_UnlinkThinker(th); } static CV_PossibleValue_t respawnitemtime_cons_t[] = {{1, "MIN"}, {300, "MAX"}, {0, NULL}}; From 55704f2ba2a9ff6ca31b911a5154c0a72dabe1ff Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 16:02:41 +0200 Subject: [PATCH 299/350] port RRs improved paranoia thinker/mobj prints https://git.srb2.org/KartKrew/RingRacers/-/commit/509a023329ea1cd583c500a3287c488e5ee3e3a6 https://git.srb2.org/KartKrew/RingRacers/-/commit/17aaf178d587970a3a845aa6c2f3807077996a77 --- src/d_think.h | 6 +++ src/p_mobj.c | 8 ++++ src/p_polyobj.c | 3 ++ src/p_tick.c | 123 ++++++++++++++++++++++++++++++++++++++++++------ src/p_tick.h | 14 +++++- 5 files changed, 139 insertions(+), 15 deletions(-) diff --git a/src/d_think.h b/src/d_think.h index 6b8ee113a..8177f464d 100644 --- a/src/d_think.h +++ b/src/d_think.h @@ -17,6 +17,8 @@ #ifndef __D_THINK__ #define __D_THINK__ +#include "doomdef.h" + #ifdef __GNUG__ #pragma interface #endif @@ -50,6 +52,10 @@ typedef struct thinker_s // this one using pointers. Used for garbage collection. INT32 references; boolean cachable; +#ifdef PARANOIA + INT32 debug_mobjtype; + tic_t debug_time; +#endif } thinker_t; #endif diff --git a/src/p_mobj.c b/src/p_mobj.c index 66d4493ca..fb34b335d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10132,6 +10132,10 @@ void P_RemoveMobj(mobj_t *mobj) { // Add thinker just to delay removing it until refrences are gone. mobj->flags &= ~MF_NOTHINK; P_AddThinker((thinker_t *)mobj); +#ifdef PARANOIA + // Saved to avoid being scrambled like below... + mobj->thinker.debug_mobjtype = mobj->type; +#endif #ifdef SCRAMBLE_REMOVED // Invalidate mobj_t data to cause crashes if accessed! memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); @@ -10141,6 +10145,10 @@ void P_RemoveMobj(mobj_t *mobj) } else { +#ifdef PARANOIA + // Saved to avoid being scrambled like below... + mobj->thinker.debug_mobjtype = mobj->type; +#endif #ifdef SCRAMBLE_REMOVED // Invalidate mobj_t data to cause crashes if accessed! memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 61c08a05d..629595068 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -156,6 +156,9 @@ FUNCINLINE static ATTRINLINE void PolyObj_AddThinker(thinker_t *th) th->references = 0; th->cachable = false; // not initialising this made the mobjcache die thx! +#ifdef PARANOIA + th->debug_mobjtype = MT_NULL; +#endif } static void FreeSideLists(void) diff --git a/src/p_tick.c b/src/p_tick.c index 91f40c623..986708767 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -11,6 +11,10 @@ /// \file p_tick.c /// \brief Archiving: SaveGame I/O, Thinker, Ticker +#ifdef PARANOIA +#include "dehacked.h" // MOBJTYPE_LIST +#endif + #include "doomstat.h" #include "g_game.h" #include "g_input.h" @@ -204,6 +208,9 @@ void P_AddThinker(thinker_t *thinker) thinker->references = 0; // killough 11/98: init reference counter to 0 thinker->cachable = (thinker->function.acp1 == (actionf_p1)P_MobjThinker); +#ifdef PARANOIA + thinker->debug_mobjtype = MT_NULL; +#endif } // @@ -220,8 +227,48 @@ void P_AddPrecipThinker(thinker_t *thinker) thinker->references = 0; // killough 11/98: init reference counter to 0 thinker->cachable = false; +#ifdef PARANOIA + thinker->debug_mobjtype = MT_NULL; +#endif } +#ifdef PARANOIA +static const char *MobjTypeName(const mobj_t *mobj) +{ + actionf_p1 p1 = mobj->thinker.function.acp1; + + if (p1 == (actionf_p1)P_MobjThinker) + { + return MOBJTYPE_LIST[mobj->type]; + } + else if (p1 == (actionf_p1)P_RemoveThinkerDelayed) + { + if (mobj->thinker.debug_mobjtype != MT_NULL) + { + return MOBJTYPE_LIST[mobj->thinker.debug_mobjtype]; + } + } + + return ""; +} + +static const char *MobjThinkerName(const mobj_t *mobj) +{ + actionf_p1 p1 = mobj->thinker.function.acp1; + + if (p1 == (actionf_p1)P_MobjThinker) + { + return "P_MobjThinker"; + } + else if (p1 == (actionf_p1)P_RemoveThinkerDelayed) + { + return "P_RemoveThinkerDelayed"; + } + + return ""; +} +#endif + // // killough 11/98: // @@ -242,20 +289,35 @@ static thinker_t *currentthinker; // void P_RemoveThinkerDelayed(thinker_t *thinker) { -#ifdef PARANOIA -#define BEENAROUNDBIT (0x40000000) // has to be sufficiently high that it's unlikely to happen in regular gameplay. If you change this, pay attention to the bit pattern of INT32_MIN. - if (thinker->references & ~BEENAROUNDBIT) + if (thinker->references != 0) { - if (thinker->references & BEENAROUNDBIT) // Usually gets cleared up in one frame; what's going on here, then? - CONS_Printf("Number of potentially faulty references: %d\n", (thinker->references & ~BEENAROUNDBIT)); - thinker->references |= BEENAROUNDBIT; +#ifdef PARANOIA + // Removed mobjs can be the target of another mobj. In + // that case, the other mobj will manage its reference + // to the removed mobj in P_MobjThinker. However, if + // the removed mobj is removed after the other object + // thinks, the reference management is delayed by one + // tic (or two?) + const UINT8 delay = 2; + + if (thinker->debug_time > leveltime) + { + thinker->debug_time = leveltime + delay + 1; // do not print errors again + } + else if ((thinker->debug_time + delay) <= leveltime) + { + CONS_Printf( + "PARANOIA/P_RemoveThinkerDelayed: %p %s references=%d\n", + (void*)thinker, + MobjTypeName((mobj_t*)thinker), + thinker->references + ); + + thinker->debug_time = leveltime + delay + 1; // do not print this error again + } +#endif return; } -#undef BEENAROUNDBIT -#else - if (thinker->references != 0) - return; -#endif /* Remove from main thinker list */ thinker_t *next = thinker->next; @@ -333,12 +395,45 @@ void P_RemoveThinker(thinker_t *thinker) * references, and delay removal until the count is 0. */ -mobj_t *P_SetTarget(mobj_t **mop, mobj_t *targ) +mobj_t *P_SetTarget2(mobj_t **mop, mobj_t *targ +#ifdef PARANOIA + , const char *source_file, int source_line +#endif +) { - if (*mop) // If there was a target already, decrease its refcount + if (*mop) // If there was a target already, decrease its refcount + { (*mop)->thinker.references--; - if ((*mop = targ) != NULL) // Set new target and if non-NULL, increase its counter + +#ifdef PARANOIA + if ((*mop)->thinker.references < 0) + { + CONS_Printf( + "PARANOIA/P_SetTarget: %p %s %s references=%d, references go negative! (%s:%d)\n", + (void*)*mop, + MobjTypeName(*mop), + MobjThinkerName(*mop), + (*mop)->thinker.references, + source_file, + source_line + ); + } + + (*mop)->thinker.debug_time = leveltime; +#endif + } + + if (targ != NULL) // Set new target and if non-NULL, increase its counter + { targ->thinker.references++; + +#ifdef PARANOIA + targ->thinker.debug_time = leveltime; +#endif + } + + *mop = targ; + return targ; } diff --git a/src/p_tick.h b/src/p_tick.h index 11b5889ed..a903be0fd 100644 --- a/src/p_tick.h +++ b/src/p_tick.h @@ -14,6 +14,8 @@ #ifndef __P_TICK__ #define __P_TICK__ +#include "doomdef.h" + #ifdef __GNUG__ #pragma interface #endif @@ -29,6 +31,16 @@ void P_Ticker(boolean run); void P_PreTicker(INT32 frames); void P_DoTeamscrambling(void); void P_RemoveThinkerDelayed(thinker_t *thinker); -mobj_t *P_SetTarget(mobj_t **mo, mobj_t *target); // killough 11/98 +mobj_t *P_SetTarget2(mobj_t **mo, mobj_t *target +#ifdef PARANOIA +, const char *source_file, int source_line +#endif +); + +#ifdef PARANOIA +#define P_SetTarget(...) P_SetTarget2(__VA_ARGS__, __FILE__, __LINE__) +#else +#define P_SetTarget P_SetTarget2 +#endif #endif From ede95c8ec40cfd7c0dcb75a44d3f5c954088cee7 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 16:04:53 +0200 Subject: [PATCH 300/350] use P_UnlinkThinker idk why it still was like this in here lel --- src/p_tick.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 986708767..212c2f1e6 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -319,25 +319,16 @@ void P_RemoveThinkerDelayed(thinker_t *thinker) return; } - /* Remove from main thinker list */ - thinker_t *next = thinker->next; + R_DestroyLevelInterpolators(thinker); + /* Note that currentthinker is guaranteed to point to us, * and since we're freeing our memory, we had better change that. So * point it to thinker->prev, so the iterator will correctly move on to * thinker->prev->next = thinker->next */ - (next->prev = currentthinker = thinker->prev)->next = next; - R_DestroyLevelInterpolators(thinker); + currentthinker = thinker->prev; - if (thinker->cachable == true) - { - // put cachable thinkers in the mobj cache, so we can avoid allocations - ((mobj_t *)thinker)->hnext = mobjcache; - mobjcache = (mobj_t *)thinker; - } - else - { - Z_Free(thinker); - } + /* Remove from main thinker list */ + P_UnlinkThinker(thinker); } // From f75eb0d766de787aa1d933a6f997ac7d07255e4b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 16:02:41 +0200 Subject: [PATCH 301/350] port RRs improved paranoia thinker/mobj prints https://git.srb2.org/KartKrew/RingRacers/-/commit/509a023329ea1cd583c500a3287c488e5ee3e3a6 https://git.srb2.org/KartKrew/RingRacers/-/commit/17aaf178d587970a3a845aa6c2f3807077996a77 --- src/d_think.h | 6 +++ src/p_mobj.c | 8 ++++ src/p_polyobj.c | 3 ++ src/p_tick.c | 123 ++++++++++++++++++++++++++++++++++++++++++------ src/p_tick.h | 14 +++++- 5 files changed, 139 insertions(+), 15 deletions(-) diff --git a/src/d_think.h b/src/d_think.h index 6b8ee113a..8177f464d 100644 --- a/src/d_think.h +++ b/src/d_think.h @@ -17,6 +17,8 @@ #ifndef __D_THINK__ #define __D_THINK__ +#include "doomdef.h" + #ifdef __GNUG__ #pragma interface #endif @@ -50,6 +52,10 @@ typedef struct thinker_s // this one using pointers. Used for garbage collection. INT32 references; boolean cachable; +#ifdef PARANOIA + INT32 debug_mobjtype; + tic_t debug_time; +#endif } thinker_t; #endif diff --git a/src/p_mobj.c b/src/p_mobj.c index 66d4493ca..fb34b335d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10132,6 +10132,10 @@ void P_RemoveMobj(mobj_t *mobj) { // Add thinker just to delay removing it until refrences are gone. mobj->flags &= ~MF_NOTHINK; P_AddThinker((thinker_t *)mobj); +#ifdef PARANOIA + // Saved to avoid being scrambled like below... + mobj->thinker.debug_mobjtype = mobj->type; +#endif #ifdef SCRAMBLE_REMOVED // Invalidate mobj_t data to cause crashes if accessed! memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); @@ -10141,6 +10145,10 @@ void P_RemoveMobj(mobj_t *mobj) } else { +#ifdef PARANOIA + // Saved to avoid being scrambled like below... + mobj->thinker.debug_mobjtype = mobj->type; +#endif #ifdef SCRAMBLE_REMOVED // Invalidate mobj_t data to cause crashes if accessed! memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 61c08a05d..629595068 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -156,6 +156,9 @@ FUNCINLINE static ATTRINLINE void PolyObj_AddThinker(thinker_t *th) th->references = 0; th->cachable = false; // not initialising this made the mobjcache die thx! +#ifdef PARANOIA + th->debug_mobjtype = MT_NULL; +#endif } static void FreeSideLists(void) diff --git a/src/p_tick.c b/src/p_tick.c index 91f40c623..986708767 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -11,6 +11,10 @@ /// \file p_tick.c /// \brief Archiving: SaveGame I/O, Thinker, Ticker +#ifdef PARANOIA +#include "dehacked.h" // MOBJTYPE_LIST +#endif + #include "doomstat.h" #include "g_game.h" #include "g_input.h" @@ -204,6 +208,9 @@ void P_AddThinker(thinker_t *thinker) thinker->references = 0; // killough 11/98: init reference counter to 0 thinker->cachable = (thinker->function.acp1 == (actionf_p1)P_MobjThinker); +#ifdef PARANOIA + thinker->debug_mobjtype = MT_NULL; +#endif } // @@ -220,8 +227,48 @@ void P_AddPrecipThinker(thinker_t *thinker) thinker->references = 0; // killough 11/98: init reference counter to 0 thinker->cachable = false; +#ifdef PARANOIA + thinker->debug_mobjtype = MT_NULL; +#endif } +#ifdef PARANOIA +static const char *MobjTypeName(const mobj_t *mobj) +{ + actionf_p1 p1 = mobj->thinker.function.acp1; + + if (p1 == (actionf_p1)P_MobjThinker) + { + return MOBJTYPE_LIST[mobj->type]; + } + else if (p1 == (actionf_p1)P_RemoveThinkerDelayed) + { + if (mobj->thinker.debug_mobjtype != MT_NULL) + { + return MOBJTYPE_LIST[mobj->thinker.debug_mobjtype]; + } + } + + return ""; +} + +static const char *MobjThinkerName(const mobj_t *mobj) +{ + actionf_p1 p1 = mobj->thinker.function.acp1; + + if (p1 == (actionf_p1)P_MobjThinker) + { + return "P_MobjThinker"; + } + else if (p1 == (actionf_p1)P_RemoveThinkerDelayed) + { + return "P_RemoveThinkerDelayed"; + } + + return ""; +} +#endif + // // killough 11/98: // @@ -242,20 +289,35 @@ static thinker_t *currentthinker; // void P_RemoveThinkerDelayed(thinker_t *thinker) { -#ifdef PARANOIA -#define BEENAROUNDBIT (0x40000000) // has to be sufficiently high that it's unlikely to happen in regular gameplay. If you change this, pay attention to the bit pattern of INT32_MIN. - if (thinker->references & ~BEENAROUNDBIT) + if (thinker->references != 0) { - if (thinker->references & BEENAROUNDBIT) // Usually gets cleared up in one frame; what's going on here, then? - CONS_Printf("Number of potentially faulty references: %d\n", (thinker->references & ~BEENAROUNDBIT)); - thinker->references |= BEENAROUNDBIT; +#ifdef PARANOIA + // Removed mobjs can be the target of another mobj. In + // that case, the other mobj will manage its reference + // to the removed mobj in P_MobjThinker. However, if + // the removed mobj is removed after the other object + // thinks, the reference management is delayed by one + // tic (or two?) + const UINT8 delay = 2; + + if (thinker->debug_time > leveltime) + { + thinker->debug_time = leveltime + delay + 1; // do not print errors again + } + else if ((thinker->debug_time + delay) <= leveltime) + { + CONS_Printf( + "PARANOIA/P_RemoveThinkerDelayed: %p %s references=%d\n", + (void*)thinker, + MobjTypeName((mobj_t*)thinker), + thinker->references + ); + + thinker->debug_time = leveltime + delay + 1; // do not print this error again + } +#endif return; } -#undef BEENAROUNDBIT -#else - if (thinker->references != 0) - return; -#endif /* Remove from main thinker list */ thinker_t *next = thinker->next; @@ -333,12 +395,45 @@ void P_RemoveThinker(thinker_t *thinker) * references, and delay removal until the count is 0. */ -mobj_t *P_SetTarget(mobj_t **mop, mobj_t *targ) +mobj_t *P_SetTarget2(mobj_t **mop, mobj_t *targ +#ifdef PARANOIA + , const char *source_file, int source_line +#endif +) { - if (*mop) // If there was a target already, decrease its refcount + if (*mop) // If there was a target already, decrease its refcount + { (*mop)->thinker.references--; - if ((*mop = targ) != NULL) // Set new target and if non-NULL, increase its counter + +#ifdef PARANOIA + if ((*mop)->thinker.references < 0) + { + CONS_Printf( + "PARANOIA/P_SetTarget: %p %s %s references=%d, references go negative! (%s:%d)\n", + (void*)*mop, + MobjTypeName(*mop), + MobjThinkerName(*mop), + (*mop)->thinker.references, + source_file, + source_line + ); + } + + (*mop)->thinker.debug_time = leveltime; +#endif + } + + if (targ != NULL) // Set new target and if non-NULL, increase its counter + { targ->thinker.references++; + +#ifdef PARANOIA + targ->thinker.debug_time = leveltime; +#endif + } + + *mop = targ; + return targ; } diff --git a/src/p_tick.h b/src/p_tick.h index 11b5889ed..a903be0fd 100644 --- a/src/p_tick.h +++ b/src/p_tick.h @@ -14,6 +14,8 @@ #ifndef __P_TICK__ #define __P_TICK__ +#include "doomdef.h" + #ifdef __GNUG__ #pragma interface #endif @@ -29,6 +31,16 @@ void P_Ticker(boolean run); void P_PreTicker(INT32 frames); void P_DoTeamscrambling(void); void P_RemoveThinkerDelayed(thinker_t *thinker); -mobj_t *P_SetTarget(mobj_t **mo, mobj_t *target); // killough 11/98 +mobj_t *P_SetTarget2(mobj_t **mo, mobj_t *target +#ifdef PARANOIA +, const char *source_file, int source_line +#endif +); + +#ifdef PARANOIA +#define P_SetTarget(...) P_SetTarget2(__VA_ARGS__, __FILE__, __LINE__) +#else +#define P_SetTarget P_SetTarget2 +#endif #endif From 61a4cb554a450001f08d5b7c799dc4fb115154f0 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 16:04:53 +0200 Subject: [PATCH 302/350] use P_UnlinkThinker idk why it still was like this in here lel --- src/p_tick.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 986708767..212c2f1e6 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -319,25 +319,16 @@ void P_RemoveThinkerDelayed(thinker_t *thinker) return; } - /* Remove from main thinker list */ - thinker_t *next = thinker->next; + R_DestroyLevelInterpolators(thinker); + /* Note that currentthinker is guaranteed to point to us, * and since we're freeing our memory, we had better change that. So * point it to thinker->prev, so the iterator will correctly move on to * thinker->prev->next = thinker->next */ - (next->prev = currentthinker = thinker->prev)->next = next; - R_DestroyLevelInterpolators(thinker); + currentthinker = thinker->prev; - if (thinker->cachable == true) - { - // put cachable thinkers in the mobj cache, so we can avoid allocations - ((mobj_t *)thinker)->hnext = mobjcache; - mobjcache = (mobj_t *)thinker; - } - else - { - Z_Free(thinker); - } + /* Remove from main thinker list */ + P_UnlinkThinker(thinker); } // From def40280285d8b2ff3fdbd94b9b36010be9f3458 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 11:39:54 +0200 Subject: [PATCH 303/350] add P_DivlineCrossedFast to take more advantage of P_DivlineSideFast --- src/p_sight.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/p_sight.c b/src/p_sight.c index 5dfc796b8..b02ffd786 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -34,6 +34,7 @@ typedef struct { static INT32 sightcounts[2]; typedef INT32 (*divlinefunc)(fixed_t x, fixed_t y, const divline_t *node); +typedef INT32 (*divlinecrossfunc)(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, const divline_t *node); // // P_DivlineSide @@ -67,6 +68,11 @@ static inline INT32 P_DivlineCrossed(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t return (P_DivlineSide(x1, y1, node) == P_DivlineSide(x2, y2, node)); } +static inline INT32 P_DivlineCrossedFast(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, const divline_t *node) +{ + return (P_DivlineSideFast(x1, y1, node) == P_DivlineSideFast(x2, y2, node)); +} + static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los) { size_t i; @@ -130,7 +136,7 @@ static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los) // // Returns true if strace crosses the given subsector successfully. // -static boolean P_CrossSubsector(size_t num, register los_t *los) +static boolean P_CrossSubsector(size_t num, register los_t *los, boolean fast) { seg_t *seg; INT32 count; @@ -159,6 +165,8 @@ static boolean P_CrossSubsector(size_t num, register los_t *los) } } + const divlinecrossfunc divlinecrossFunc = fast ? P_DivlineCrossedFast : P_DivlineCrossed; + for (count = subsectors[num].numlines; --count >= 0; seg++) // check lines { line_t *line = seg->linedef; @@ -187,14 +195,14 @@ static boolean P_CrossSubsector(size_t num, register los_t *los) v2 = line->v2; // line isn't crossed? - if (P_DivlineCrossed(v1->x, v1->y, v2->x, v2->y, &los->strace)) + if (divlinecrossFunc(v1->x, v1->y, v2->x, v2->y, &los->strace)) continue; divl.dx = v2->x - (divl.x = v1->x); divl.dy = v2->y - (divl.y = v1->y); // line isn't crossed? - if (P_DivlineCrossed(los->strace.x, los->strace.y, los->t2x, los->t2y, &divl)) + if (divlinecrossFunc(los->strace.x, los->strace.y, los->t2x, los->t2y, &divl)) continue; // stop because it is not two sided anyway @@ -326,7 +334,7 @@ static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los, boolean fast) } } - return P_CrossSubsector((bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR), los); + return P_CrossSubsector((bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR), los, fast); } // From d2844e7087826d10ff9e8b270eac91d19c3c6184 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 11:39:54 +0200 Subject: [PATCH 304/350] add P_DivlineCrossedFast to take more advantage of P_DivlineSideFast --- src/p_sight.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/p_sight.c b/src/p_sight.c index 5dfc796b8..b02ffd786 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -34,6 +34,7 @@ typedef struct { static INT32 sightcounts[2]; typedef INT32 (*divlinefunc)(fixed_t x, fixed_t y, const divline_t *node); +typedef INT32 (*divlinecrossfunc)(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, const divline_t *node); // // P_DivlineSide @@ -67,6 +68,11 @@ static inline INT32 P_DivlineCrossed(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t return (P_DivlineSide(x1, y1, node) == P_DivlineSide(x2, y2, node)); } +static inline INT32 P_DivlineCrossedFast(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, const divline_t *node) +{ + return (P_DivlineSideFast(x1, y1, node) == P_DivlineSideFast(x2, y2, node)); +} + static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los) { size_t i; @@ -130,7 +136,7 @@ static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los) // // Returns true if strace crosses the given subsector successfully. // -static boolean P_CrossSubsector(size_t num, register los_t *los) +static boolean P_CrossSubsector(size_t num, register los_t *los, boolean fast) { seg_t *seg; INT32 count; @@ -159,6 +165,8 @@ static boolean P_CrossSubsector(size_t num, register los_t *los) } } + const divlinecrossfunc divlinecrossFunc = fast ? P_DivlineCrossedFast : P_DivlineCrossed; + for (count = subsectors[num].numlines; --count >= 0; seg++) // check lines { line_t *line = seg->linedef; @@ -187,14 +195,14 @@ static boolean P_CrossSubsector(size_t num, register los_t *los) v2 = line->v2; // line isn't crossed? - if (P_DivlineCrossed(v1->x, v1->y, v2->x, v2->y, &los->strace)) + if (divlinecrossFunc(v1->x, v1->y, v2->x, v2->y, &los->strace)) continue; divl.dx = v2->x - (divl.x = v1->x); divl.dy = v2->y - (divl.y = v1->y); // line isn't crossed? - if (P_DivlineCrossed(los->strace.x, los->strace.y, los->t2x, los->t2y, &divl)) + if (divlinecrossFunc(los->strace.x, los->strace.y, los->t2x, los->t2y, &divl)) continue; // stop because it is not two sided anyway @@ -326,7 +334,7 @@ static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los, boolean fast) } } - return P_CrossSubsector((bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR), los); + return P_CrossSubsector((bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR), los, fast); } // From 9d1b8ba736922f69f6df16c3b549e3b5f8dba428 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 16:14:33 +0200 Subject: [PATCH 305/350] move saturn menu stuff around --- src/m_menu.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 72c28857c..bcd406e4c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2452,17 +2452,17 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 135}, {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 140}, - {IT_STRING | IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 150}, - {IT_STRING | IT_CVAR, NULL, "Player Angle Dot", &cv_showminimapangle, 160}, + {IT_STRING | IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 145}, + {IT_STRING | IT_CVAR, NULL, "Player Angle Dot", &cv_showminimapangle, 150}, - {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 170}, + {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 160}, - {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 180}, + {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 170}, - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 190}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 195}, + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 180}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 185}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 205}, + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 195}, }; static const char* OP_SaturnHudTooltips[] = From 117db36ed3468fbb38b8b95dae32d47030025d24 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 16:14:33 +0200 Subject: [PATCH 306/350] move saturn menu stuff around --- src/m_menu.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 72c28857c..bcd406e4c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2452,17 +2452,17 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 135}, {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 140}, - {IT_STRING | IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 150}, - {IT_STRING | IT_CVAR, NULL, "Player Angle Dot", &cv_showminimapangle, 160}, + {IT_STRING | IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 145}, + {IT_STRING | IT_CVAR, NULL, "Player Angle Dot", &cv_showminimapangle, 150}, - {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 170}, + {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 160}, - {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 180}, + {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 170}, - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 190}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 195}, + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 180}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 185}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 205}, + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 195}, }; static const char* OP_SaturnHudTooltips[] = From 1d15f89433c4cb485b7894373bb97fb7d8db9da8 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 23 Apr 2025 19:09:02 +0300 Subject: [PATCH 307/350] Remove I_Assert in GetItemId in lua_hudlib_drawlist.c It is legal for lua_getpc to be null (thanks GenericHeroGuy for investigating!) --- src/lua_hudlib_drawlist.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index 98a4890b1..a9c9d93b7 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -337,7 +337,6 @@ static UINT64 GetItemId(void) #else // he who controls the JIT controls the API const void *p = lua_getpc(gL, 1); - I_Assert(p != NULL); UINT64 id = (uintptr_t)p; #endif // leave bits 0 and 1 free for the string mode From 1bb52b9c2d270f243bda280915406645ca59b207 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 19:54:17 +0200 Subject: [PATCH 308/350] check ceiling first in encore flat precaching no clue why but this fixes the sides of the road on ORR not being encore remapped --- src/hardware/hw_cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 5ba8655b8..f3b4ae84f 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -553,7 +553,7 @@ static void HWR_PrecacheLevelFlats(void) // gotta check sector floor and ceiling for (j = 0; j < 2; j++) { - const boolean ceiling = (j == 1); + const boolean ceiling = (j == 0); INT32 pic = ceiling ? sec->ceilingpic : sec->floorpic; levelflat = levelflats[pic]; From a099f825a77c64ee61adb546d14b7e5b6eca62bd Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 06:42:50 +0200 Subject: [PATCH 309/350] missed removing this --- src/d_netcmd.c | 18 +++++++++--------- src/r_things.c | 1 - src/w_wad.c | 5 +++++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 3b53dd8c4..d3b9ca5b4 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4591,7 +4591,7 @@ static void Command_GLocalSkin (void) char* fuck; // local skin name - if (!( first_option = COM_FirstOption() )) + if (!(first_option = COM_FirstOption())) first_option = COM_Argc(); if (first_option < 2) @@ -4599,14 +4599,14 @@ static void Command_GLocalSkin (void) /* holy fucking shit */ CONS_Printf("localskin [-player ] [-display ] [-all]:\n"); CONS_Printf(M_GetText("Set a localskin via its internal name (usually printed on the console).\n\n\ -* Using \"-player\" will set a localskin to a specified player.\n\ - Defaults to yourself.\n\ -* Using \"-display\" will set a localskin to the displayed player.\n\ - Defaults to 0, which is the first player displayed.\n\ - Can go up to 3 for splitscreen.\n\ -* Using \"-all\" will set a localskin to ALL players.\n\ -* \"localskin none\" removes the localskin, just like how\n\ - \"forceskin none\" does.\n")); + * Using \"-player\" will set a localskin to a specified player.\n\ + Defaults to yourself.\n\ + * Using \"-display\" will set a localskin to the displayed player.\n\ + Defaults to 0, which is the first player displayed.\n\ + Can go up to 3 for splitscreen.\n\ + * Using \"-all\" will set a localskin to ALL players.\n\ + * \"localskin none\" removes the localskin, just like how\n\ + \"forceskin none\" does.\n")); return; } diff --git a/src/r_things.c b/src/r_things.c index ddae1d7ec..44a2bfe84 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -3700,7 +3700,6 @@ next_token: numallskins++; } -#undef lskin #undef lnumskins //sortSkinGrid(); diff --git a/src/w_wad.c b/src/w_wad.c index 6432c3223..3a9ab6c6c 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -898,8 +898,10 @@ INT32 W_InitMultipleFiles(char **filenames, boolean addons) //CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames); rc = W_InitFile(*filenames, false); + if (rc == INT16_MAX) CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), *filenames); + overallrc &= (rc != INT16_MAX) ? 1 : 0; } @@ -918,8 +920,10 @@ INT32 W_AddAutoloadedLocalFiles(char **filenames) for (; *filenames; filenames++) { rc = P_PartialAddWadFile(*filenames, true); + if (rc == UINT16_MAX) CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), *filenames); + overallrc &= (rc != UINT16_MAX) ? 1 : 0; } @@ -928,6 +932,7 @@ INT32 W_AddAutoloadedLocalFiles(char **filenames) if (P_PartialAddGetStage() >= 0) P_MultiSetupWadFiles(true); + return overallrc; } From f81488500c6f10d3416711f86d6deee3eda6acee Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 06:46:41 +0200 Subject: [PATCH 310/350] just mark it like this --- src/r_things.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index 44a2bfe84..aad15de15 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2856,7 +2856,7 @@ void R_ClipSprites(void) /* Check if thing may be drawn from our current view. */ boolean R_ThingVisible (mobj_t *thing) { - if (UNLIKELY(thing->sprite == SPR_NULL) || UNLIKELY((thing->flags2 & MF2_DONTDRAW))) + if (UNLIKELY((thing->sprite == SPR_NULL) || (thing->flags2 & MF2_DONTDRAW))) return false; if (splitscreen) From cf92df5faafaf1f267444c7d726a1fda3317d4a3 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 06:54:22 +0200 Subject: [PATCH 311/350] skip checking skin array if localskin was found in localskin array --- src/lua_mobjlib.c | 5 ++--- src/r_things.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 9498974d5..44c43297f 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -452,7 +452,7 @@ int mobj_localskin_setter(lua_State *L) strlcpy(skin, luaL_optstring(L, 2, "none"), sizeof skin); strlwr(skin); // all skin names are lowercase - if (strcasecmp(skin, "none")) + if (stricmp(skin, "none")) { // Try localskins for (i = 0; i < numlocalskins; i++) @@ -468,7 +468,7 @@ int mobj_localskin_setter(lua_State *L) // Try other skins for (i = 0; i < numskins; i++) { - if (fastcmp(skins[i].name, skin)) + if (stricmp(skins[i].name, skin) == 0) { mo->localskin = &skins[i]; mo->skinlocal = false; @@ -483,7 +483,6 @@ int mobj_localskin_setter(lua_State *L) } } - return 0; } diff --git a/src/r_things.c b/src/r_things.c index aad15de15..e2c3c2c76 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -3163,11 +3163,11 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) INT32 i; player_t *player = &players[playernum]; - if (strcasecmp(skinname, "none")) + if (stricmp(skinname, "none")) { for (i = 0; i < numlocalskins; i++) { - // search in the skin list + // search in the localskin list if (stricmp(localskins[i].name, skinname) == 0) { player->localskin = 1 + i; @@ -3177,9 +3177,11 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) player->mo->localskin = &localskins[i]; player->mo->skinlocal = true; } - break; + + goto setcvar; } } + for (i = 0; i < numskins; i++) { // search in the skin list @@ -3192,7 +3194,8 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) player->mo->localskin = &skins[i]; player->mo->skinlocal = false; } - break; + + goto setcvar; } } } @@ -3207,6 +3210,7 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) } } +setcvar: if (cvar != NULL) { if (player->localskin > 0) From 7bb4b74c65e7db92d55417f0b0221b67579e6e45 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 06:56:57 +0200 Subject: [PATCH 312/350] fix potential crash on startup thx hanicef --- src/g_input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_input.c b/src/g_input.c index f0121f37d..7adb4462a 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1022,7 +1022,7 @@ INT32 G_KeyStringtoNum(const char *keystr) if (!keystr[0]) return 0; - if (!keystr[1] && keystr[0] > ' ' && keystr[0] <= 'z') + if (!keystr[0] || (!keystr[1] && keystr[0] > ' ' && keystr[0] <= 'z')) return keystr[0]; if (!strncmp(keystr, "KEY", 3) && keystr[3] >= '0' && keystr[3] <= '9') From 987d18fe992418007891a837d15a9f00d0fa3a67 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 09:24:37 +0200 Subject: [PATCH 313/350] memset those --- src/doomstat.h | 4 ++-- src/p_setup.c | 26 ++++++++++++++++++++------ src/r_things.c | 7 ++++--- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index f6e708be6..54c6ae320 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -244,7 +244,7 @@ typedef struct INT16 nextlevel; ///< Map number of next level, or 1100-1102 to end. char musname[7]; ///< Music track to play. "" for no music. UINT16 mustrack; ///< Subsong to play. Only really relevant for music modules and specific formats supported by GME. 0 to ignore. - UINT32 muspos; ///< Music position to jump to. + UINT32 muspos; ///< Music position to jump to. char forcecharacter[17]; ///< (SKINNAMESIZE+1) Skin to switch to or "" to disable. UINT8 weather; ///< 0 = sunny day, 1 = storm, 2 = snow, 3 = rain, 4 = blank, 5 = thunder w/o rain, 6 = rain w/o lightning, 7 = heat wave. INT16 skynum; ///< Sky number to use. @@ -276,7 +276,7 @@ typedef struct // SRB2kart //boolean automap; ///< Displays a level's white map outline in modified games - fixed_t mobj_scale; ///< Replacement for TOL_ERZ3 + fixed_t mobj_scale; ///< Replacement for TOL_ERZ3 mapheader_lighting_t lighting; ///< Wall and sprite lighting mapheader_lighting_t lighting_encore; ///< Alternative lighting for Encore mode diff --git a/src/p_setup.c b/src/p_setup.c index e4c22f253..b51a8abce 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -296,6 +296,7 @@ static void P_ClearMapHeaderLighting(mapheader_lighting_t *lighting) static void P_ClearSingleMapHeaderInfo(INT16 i) { const INT16 num = (INT16)(i-1); + mapheaderinfo[num]->lvlttl[0] = '\0'; mapheaderinfo[num]->subttl[0] = '\0'; mapheaderinfo[num]->zonttl[0] = '\0'; @@ -329,8 +330,10 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->saveoverride = SAVE_DEFAULT; mapheaderinfo[num]->levelflags = 0; mapheaderinfo[num]->menuflags = (mainwads ? 0 : LF2_EXISTSHACK); // see p_setup.c - prevents replacing maps in addons with easier versions + // TODO grades support for delfile (pfft yeah right) P_DeleteGrades(num); + // SRB2Kart //mapheaderinfo[num]->automap = false; mapheaderinfo[num]->mobj_scale = FRACUNIT; @@ -752,7 +755,7 @@ INT32 P_AddLevelFlat(const char *flatname, levelflat_t *levelflat) // first scan through the already found flats // for (i = 0; i < numlevelflats; i++, levelflat++) - if (strnicmp(levelflat->name,flatname,8)==0) + if (strnicmp(levelflat->name,flatname,8) == 0) break; // that flat was already found in the level, return the id @@ -947,6 +950,7 @@ static void P_LoadRawNodes(UINT8 *data) no->y = SHORT(mn->y)<dx = SHORT(mn->dx)<dy = SHORT(mn->dy)<children[j] = SHORT(mn->children[j]); @@ -2376,10 +2380,14 @@ static INT32 P_MakeBufferMD5(const char *buffer, size_t len, void *resblock) return 1; #else tic_t t = I_GetTime(); + CONS_Debug(DBG_SETUP, "Making MD5\n"); + if (md5_buffer(buffer, len, resblock) == NULL) return 1; + CONS_Debug(DBG_SETUP, "MD5 calc took %f seconds\n", (float)(I_GetTime() - t)/NEWTICRATE); + return 0; #endif } @@ -2460,6 +2468,7 @@ static void P_RunLevelScript(const char *scriptname) { COM_BufAddText(va("exec %s\n", scriptname)); } + COM_BufExecute(); // Run it! } @@ -2760,7 +2769,7 @@ static boolean P_RunSpecialWipe(boolean reloadinggamestate) F_WipeEndScreen(); F_RunWipe(wipedefs[wipe_level_final], false); } - else //dedicated servers can call this now, to wait the appropriate amount of time for clients to wipe + else // dedicated servers can call this now, to wait the appropriate amount of time for clients to wipe { F_RunWipe(wipedefs[wipe_speclevel_towhite], false); F_RunWipe(wipedefs[wipe_level_final], false); @@ -2778,7 +2787,9 @@ static boolean P_RunSpecialWipe(boolean reloadinggamestate) I_Sleep(cv_sleep.value); I_UpdateTime(cv_timescale.value); } + lastwipetic = nowtime; + if (moviemode) // make sure we save frames for the white hold too M_SaveFrame(); @@ -2797,6 +2808,7 @@ static void P_SetupPlayer(void) INT32 i; for (i = 0; i < MAXPLAYERS; i++) + { if (playeringame[i]) { players[i].pflags &= ~PF_NIGHTSMODE; @@ -2821,6 +2833,7 @@ static void P_SetupPlayer(void) G_SpawnPlayer(i, false); } } + } if (modeattacking == ATTACKING_RECORD && !demo.playback) P_LoadRecordGhosts(); @@ -3077,10 +3090,8 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) numdmstarts = numredctfstarts = numbluectfstarts = 0; // reset the player starts - for (i = 0; i < MAXPLAYERS; i++) - playerstarts[i] = NULL; - for (i = 0; i < 2; i++) - skyboxmo[i] = NULL; + memset(playerstarts, 0, sizeof(playerstarts)); + memset(skyboxmo, 0, sizeof(skyboxmo)); P_ResetWaypoints(); @@ -3180,12 +3191,15 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) if (!fromnetsave) // uglier hack { // to make a newly loaded level start on the second frame. INT32 buf = gametic % TICQUEUE; + for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i]) G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1); } + P_PreTicker(2); + if (!reloadinggamestate) LUA_HookInt(gamemap, HOOK(MapLoad)); } diff --git a/src/r_things.c b/src/r_things.c index e2c3c2c76..45afd824d 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -3096,7 +3096,7 @@ INT32 R_SkinAvailable(const char *name) for (i = 0; i < numskins; i++) { - if (stricmp(skins[i].name,name)==0) + if (stricmp(skins[i].name,name) == 0) return i; } return -1; @@ -3110,7 +3110,7 @@ INT32 R_AnySkinAvailable(const char *name) for (i = 0; i < numallskins; i++) { - if (stricmp(allskins[i].name,name)==0) + if (stricmp(allskins[i].name,name) == 0) return i; } return -1; @@ -3124,7 +3124,7 @@ INT32 R_LocalSkinAvailable(const char *name, boolean local) { for (i = 0; i < numlocalskins; i++) { - if (stricmp(localskins[i].name,name)==0) + if (stricmp(localskins[i].name,name) == 0) return i; } return -1; @@ -3258,6 +3258,7 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) CONS_Alert(CONS_WARNING, M_GetText("Skin %d not found\n"), skinnum); else if(server || IsPlayerAdmin(consoleplayer)) CONS_Alert(CONS_WARNING, "Player %d (%s) skin %d not found\n", playernum, player_names[playernum], skinnum); + SetPlayerSkinByNum(playernum, 0); // not found put the sonic skin } From 5df33e070549ef0964f9aab5d3b39abca4aab242 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 08:58:05 +0200 Subject: [PATCH 314/350] cleanup G_Responder man --- src/g_game.c | 328 ++++++++++++++++++++------------------------------ src/g_input.c | 8 ++ src/g_input.h | 2 + 3 files changed, 141 insertions(+), 197 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 7acda852e..de290949b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1277,7 +1277,8 @@ static void G_DoLoadLevel(boolean resetplayer) // clear cmd building stuff memset(gamekeydown, 0, sizeof (gamekeydown)); - for (i = 0;i < JOYAXISSET; i++) + + for (i = 0; i < JOYAXISSET; i++) { joyxmove[i] = joyymove[i] = 0; joy2xmove[i] = joy2ymove[i] = 0; @@ -1298,91 +1299,10 @@ static INT32 pausedelay = 0; static INT32 camtoggledelay[MAXSPLITSCREENPLAYERS] = {0,0,0,0}; static INT32 spectatedelay[MAXSPLITSCREENPLAYERS] = {0,0,0,0}; -// -// G_Responder -// Get info needed to make ticcmd_ts for the players. -// -boolean G_Responder(event_t *ev) +static boolean G_LevelResponder(event_t *ev) { - // any other key pops up menu if in demos - if (gameaction == ga_nothing && !demo.quitafterplaying && - ((demo.playback && !modeattacking && !demo.title && !multiplayer) || gamestate == GS_TITLESCREEN)) - { - if (ev->type == ev_keydown && ev->data1 != 301) - { - M_StartControlPanel(); - return true; - } - return false; - } - else if (demo.playback && demo.title) - { - // Title demo uses intro responder - if (F_IntroResponder(ev)) - { - // stop the title demo - G_CheckDemoStatus(); - return true; - } - return false; - } - - if (gamestate == GS_LEVEL) - { - if (HU_Responder(ev)) - return true; // chat ate the event - if (AM_Responder(ev)) - return true; // automap ate it - // map the event (key/mouse/joy) to a gamecontrol - } - // Intro - else if (gamestate == GS_INTRO) - { - if (F_IntroResponder(ev)) - { - D_StartTitle(); - return true; - } - } - else if (gamestate == GS_CUTSCENE) - { - if (HU_Responder(ev)) - return true; // chat ate the event - - if (F_CutsceneResponder(ev)) - { - D_StartTitle(); - return true; - } - } - - else if (gamestate == GS_CREDITS) - { - if (HU_Responder(ev)) - return true; // chat ate the event - - if (F_CreditResponder(ev)) - { - F_StartGameEvaluation(); - return true; - } - } - - else if (gamestate == GS_CONTINUING) - { - if (F_ContinueResponder(ev)) - return true; - } - // Demo End - else if (gamestate == GS_GAMEEND || gamestate == GS_EVALUATION || gamestate == GS_CREDITS) - return true; - - else if (gamestate == GS_INTERMISSION || gamestate == GS_VOTING || gamestate == GS_WAITINGPLAYERS) - if (HU_Responder(ev)) - return true; // chat ate the event - // allow spy mode changes even during the demo - if (gamestate == GS_LEVEL && ev->type == ev_keydown + if (ev->type == ev_keydown && (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[gc_viewpoint][0] || ev->data1 == gamecontrol[gc_viewpoint][1])) { if (!demo.playback && (splitscreen || !netgame)) @@ -1399,30 +1319,20 @@ boolean G_Responder(event_t *ev) } } - if (gamestate == GS_LEVEL && ev->type == ev_keydown && multiplayer && demo.playback) + if (ev->type == ev_keydown && multiplayer && demo.playback) { - if (ev->data1 == gamecontrolbis[gc_viewpoint][0] || ev->data1 == gamecontrolbis[gc_viewpoint][1]) + for (INT32 i = 1; i <= splitscreen; i++) { - G_AdjustView(2, 1, true); - - return true; - } - else if (ev->data1 == gamecontrol3[gc_viewpoint][0] || ev->data1 == gamecontrol3[gc_viewpoint][1]) - { - G_AdjustView(3, 1, true); - - return true; - } - else if (ev->data1 == gamecontrol4[gc_viewpoint][0] || ev->data1 == gamecontrol4[gc_viewpoint][1]) - { - G_AdjustView(4, 1, true); - - return true; + if (ev->data1 == gamecontrols[i][gc_viewpoint][0] + || ev->data1 == gamecontrols[i][gc_viewpoint][1]) + { + G_AdjustView(i+1, 1, true); + return true; + } } // Allow pausing - if ( - ev->data1 == gamecontrol[gc_pause][0] + if (ev->data1 == gamecontrol[gc_pause][0] || ev->data1 == gamecontrol[gc_pause][1] || ev->data1 == KEY_PAUSE ) @@ -1447,11 +1357,98 @@ boolean G_Responder(event_t *ev) if (ev->data1 == 32) { M_StartControlPanel(); - return true; } } + return false; +} + +// +// G_Responder +// Get info needed to make ticcmd_ts for the players. +// +boolean G_Responder(event_t *ev) +{ + if (demo.playback && demo.title) + { + // Title demo uses intro responder + if (F_IntroResponder(ev)) + { + // stop the title demo + G_CheckDemoStatus(); + return true; + } + + return false; + } + else if (gameaction == ga_nothing + && !demo.quitafterplaying + && ((demo.playback && !modeattacking && !multiplayer) || gamestate == GS_TITLESCREEN)) + { + // any other key pops up menu if in demos + if (ev->type == ev_keydown && ev->data1 != 301) + { + M_StartControlPanel(); + return true; + } + + return false; + } + + if (Playing()) + { + // If you're playing, chat is real. + // Neatly sidesteps a class of bugs where whenever we add a + // new gamestate accessible in netplay, chat was console-only. + if (HU_Responder(ev)) + { + return true; // chat ate the event + } + } + + switch (gamestate) + { + case GS_LEVEL: + if (AM_Responder(ev)) + return true; // automap ate it + // map the event (key/mouse/joy) to a gamecontrol + if (G_LevelResponder(ev)) + return true; + break; + case GS_INTRO: + if (F_IntroResponder(ev)) + { + D_StartTitle(); + return true; + } + break; + case GS_CUTSCENE: + if (F_CutsceneResponder(ev)) + { + D_StartTitle(); + return true; + } + break; + case GS_CREDITS: + if (F_CreditResponder(ev)) + { + F_StartGameEvaluation(); + return true; + } + break; + case GS_CONTINUING: + if (F_ContinueResponder(ev)) + return true; + break; + case GS_GAMEEND: + case GS_EVALUATION: + return true; // Demo End + break; + default: + break; + } + // update keys current state G_MapEventsToControls(ev); @@ -1474,121 +1471,58 @@ boolean G_Responder(event_t *ev) else pausedelay = NEWTICRATE/7; } - if (ev->data1 == gamecontrol[gc_camtoggle][0] - || ev->data1 == gamecontrol[gc_camtoggle][1]) - { - if (!camtoggledelay[0]) - { - camtoggledelay[0] = NEWTICRATE / 7; - CV_SetValue(&cv_chasecam[0], cv_chasecam[0].value ? 0 : 1); - } - } - if (ev->data1 == gamecontrolbis[gc_camtoggle][0] - || ev->data1 == gamecontrolbis[gc_camtoggle][1]) - { - if (!camtoggledelay[1]) - { - camtoggledelay[1] = NEWTICRATE / 7; - CV_SetValue(&cv_chasecam[1], cv_chasecam[1].value ? 0 : 1); - } - } - if (ev->data1 == gamecontrol3[gc_camtoggle][0] - || ev->data1 == gamecontrol3[gc_camtoggle][1]) - { - if (!camtoggledelay[2]) - { - camtoggledelay[2] = NEWTICRATE / 7; - CV_SetValue(&cv_chasecam[2], cv_chasecam[2].value ? 0 : 1); - } - } - if (ev->data1 == gamecontrol4[gc_camtoggle][0] - || ev->data1 == gamecontrol4[gc_camtoggle][1]) - { - if (!camtoggledelay[3]) - { - camtoggledelay[3] = NEWTICRATE / 7; - CV_SetValue(&cv_chasecam[3], cv_chasecam[3].value ? 0 : 1); - } - } - if (ev->data1 == gamecontrol[gc_spectate][0] - || ev->data1 == gamecontrol[gc_spectate][1]) - { - if (!spectatedelay[0]) - { - spectatedelay[0] = NEWTICRATE / 7; - COM_ImmedExecute("changeteam spectator"); - } - } - if (ev->data1 == gamecontrolbis[gc_spectate][0] - || ev->data1 == gamecontrolbis[gc_spectate][1]) - { - if (!spectatedelay[1]) - { - spectatedelay[1] = NEWTICRATE / 7; - COM_ImmedExecute("changeteam2 spectator"); - } - } - if (ev->data1 == gamecontrol3[gc_spectate][0] - || ev->data1 == gamecontrol3[gc_spectate][1]) - { - if (!spectatedelay[2]) - { - spectatedelay[2] = NEWTICRATE / 7; - COM_ImmedExecute("changeteam3 spectator"); - } - } - if (ev->data1 == gamecontrol4[gc_spectate][0] - || ev->data1 == gamecontrol4[gc_spectate][1]) - { - if (!spectatedelay[3]) - { - spectatedelay[3] = NEWTICRATE / 7; - COM_ImmedExecute("changeteam4 spectator"); - } - } - if (ev->data1 == gamecontrol[gc_director][0] || ev->data1 == gamecontrol[gc_director][1]) + // no splitscreen support for director here + if (ev->data1 == gamecontrol[gc_director][0] + || ev->data1 == gamecontrol[gc_director][1]) { K_ToggleDirector(); } - if (ev->data1 == gamecontrol[gc_freecam][0] || ev->data1 == gamecontrol[gc_freecam][1]) + // absolutely horrid + for (INT32 i = 0; i <= splitscreen; i++) { - P_ToggleDemoCamera(0); - } - else if (ev->data1 == gamecontrolbis[gc_freecam][0] || ev->data1 == gamecontrolbis[gc_freecam][1]) - { - P_ToggleDemoCamera(1); - } - else if (ev->data1 == gamecontrol3[gc_freecam][0] || ev->data1 == gamecontrol3[gc_freecam][1]) - { - P_ToggleDemoCamera(2); - } - else if (ev->data1 == gamecontrol4[gc_freecam][0] || ev->data1 == gamecontrol4[gc_freecam][1]) - { - P_ToggleDemoCamera(3); + if (ev->data1 == gamecontrols[i][gc_camtoggle][0] + || ev->data1 == gamecontrols[i][gc_camtoggle][1]) + { + if (!camtoggledelay[i]) + { + camtoggledelay[i] = NEWTICRATE / 7; + CV_SetValue(&cv_chasecam[i], (cv_chasecam[i].value ^ 1)); + } + } + + if (ev->data1 == gamecontrols[i][gc_spectate][0] + || ev->data1 == gamecontrols[i][gc_spectate][1]) + { + if (!spectatedelay[i]) + { + spectatedelay[i] = NEWTICRATE / 7; + COM_ImmedExecute("changeteam spectator"); + } + } + + if (ev->data1 == gamecontrols[i][gc_freecam][0] + || ev->data1 == gamecontrols[i][gc_freecam][1]) + { + P_ToggleDemoCamera(i); + } } return true; case ev_keyup: return false; // always let key up events filter down - case ev_mouse: return true; // eat events - case ev_joystick: return true; // eat events - case ev_joystick2: return true; // eat events - case ev_joystick3: return true; // eat events - case ev_joystick4: return true; // eat events - default: break; } diff --git a/src/g_input.c b/src/g_input.c index 7adb4462a..3c38cf192 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -136,6 +136,14 @@ INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player INT32 gamecontrol3[num_gamecontrols][2]; // tertiary splitscreen player INT32 gamecontrol4[num_gamecontrols][2]; // quarternary splitscreen player +// TODO: this is dumb as hell +INT32 (*gamecontrols[MAXSPLITSCREENPLAYERS])[2] = { + gamecontrol, + gamecontrolbis, + gamecontrol3, + gamecontrol4 +}; + typedef struct { UINT8 time; diff --git a/src/g_input.h b/src/g_input.h index 505d210f8..820e2cdbc 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -125,6 +125,8 @@ extern INT32 gamecontrol[num_gamecontrols][2]; extern INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player extern INT32 gamecontrol3[num_gamecontrols][2]; extern INT32 gamecontrol4[num_gamecontrols][2]; +extern INT32 (*gamecontrols[MAXSPLITSCREENPLAYERS])[2]; + #define PLAYER1INPUTDOWN(gc) (gamekeydown[gamecontrol[gc][0]] || gamekeydown[gamecontrol[gc][1]]) #define PLAYER2INPUTDOWN(gc) (gamekeydown[gamecontrolbis[gc][0]] || gamekeydown[gamecontrolbis[gc][1]]) #define PLAYER3INPUTDOWN(gc) (gamekeydown[gamecontrol3[gc][0]] || gamekeydown[gamecontrol3[gc][1]]) From c14c28ac1e35aac55da3b96589eae2fd91b270a4 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 09:13:14 +0200 Subject: [PATCH 315/350] attempt at cleaning up gamecontrol splitscreen shit --- src/console.c | 6 +- src/d_clisrv.c | 4 +- src/g_game.c | 32 +++---- src/g_input.c | 233 +++++++++++++++++++++---------------------------- src/g_input.h | 14 ++- src/hu_stuff.c | 14 +-- src/m_menu.c | 38 ++++---- src/m_misc.c | 4 +- src/st_stuff.c | 4 +- 9 files changed, 155 insertions(+), 194 deletions(-) diff --git a/src/console.c b/src/console.c index 3212521b0..f1c8efcc2 100644 --- a/src/console.c +++ b/src/console.c @@ -827,7 +827,7 @@ boolean CON_Responder(event_t *ev) // let go keyup events, don't eat them if (ev->type != ev_keydown && ev->type != ev_console) { - if (ev->data1 == gamecontrol[gc_console][0] || ev->data1 == gamecontrol[gc_console][1]) + if (ev->data1 == gamecontrol[0][gc_console][0] || ev->data1 == gamecontrol[0][gc_console][1]) consdown = false; return false; } @@ -845,7 +845,7 @@ boolean CON_Responder(event_t *ev) INT32 i; for (i = 0; i < num_gamecontrols; i++) { - if (gamecontrol[i][0] == ev->data1 || gamecontrol[i][1] == ev->data1) + if (gamecontrol[0][i][0] == ev->data1 || gamecontrol[0][i][1] == ev->data1) break; } @@ -853,7 +853,7 @@ boolean CON_Responder(event_t *ev) return false; } - if (key == gamecontrol[gc_console][0] || key == gamecontrol[gc_console][1]) + if (key == gamecontrol[0][gc_console][0] || key == gamecontrol[0][gc_console][1]) { if (consdown) // ignore repeat return true; diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 4a2a0cc0f..d76e67e88 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2261,13 +2261,13 @@ static void M_ConfirmConnect(event_t *ev) #ifndef NONET if (ev->type == ev_keydown) { - if (ev->data1 == ' ' || ev->data1 == 'y' || ev->data1 == KEY_ENTER || ev->data1 == gamecontrol[gc_accelerate][0] || ev->data1 == gamecontrol[gc_accelerate][1]) + if (ev->data1 == ' ' || ev->data1 == 'y' || ev->data1 == KEY_ENTER || ev->data1 == gamecontrol[0][gc_accelerate][0] || ev->data1 == gamecontrol[0][gc_accelerate][1]) { CL_ConfirmConnect(); M_ClearMenus(true); } - else if (ev->data1 == 'n' || ev->data1 == KEY_ESCAPE|| ev->data1 == gamecontrol[gc_brake][0] || ev->data1 == gamecontrol[gc_brake][1]) + else if (ev->data1 == 'n' || ev->data1 == KEY_ESCAPE|| ev->data1 == gamecontrol[0][gc_brake][0] || ev->data1 == gamecontrol[0][gc_brake][1]) { cl_mode = CL_ABORTED; M_ClearMenus(true); diff --git a/src/g_game.c b/src/g_game.c index de290949b..eaec9e212 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1303,7 +1303,9 @@ static boolean G_LevelResponder(event_t *ev) { // allow spy mode changes even during the demo if (ev->type == ev_keydown - && (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[gc_viewpoint][0] || ev->data1 == gamecontrol[gc_viewpoint][1])) + && (ev->data1 == KEY_F12 + || ev->data1 == gamecontrol[0][gc_viewpoint][0] + || ev->data1 == gamecontrol[0][gc_viewpoint][1])) { if (!demo.playback && (splitscreen || !netgame)) displayplayers[0] = consoleplayer; @@ -1323,8 +1325,8 @@ static boolean G_LevelResponder(event_t *ev) { for (INT32 i = 1; i <= splitscreen; i++) { - if (ev->data1 == gamecontrols[i][gc_viewpoint][0] - || ev->data1 == gamecontrols[i][gc_viewpoint][1]) + if (ev->data1 == gamecontrol[i][gc_viewpoint][0] + || ev->data1 == gamecontrol[i][gc_viewpoint][1]) { G_AdjustView(i+1, 1, true); return true; @@ -1332,8 +1334,8 @@ static boolean G_LevelResponder(event_t *ev) } // Allow pausing - if (ev->data1 == gamecontrol[gc_pause][0] - || ev->data1 == gamecontrol[gc_pause][1] + if (ev->data1 == gamecontrol[0][gc_pause][0] + || ev->data1 == gamecontrol[0][gc_pause][1] || ev->data1 == KEY_PAUSE ) { @@ -1455,8 +1457,8 @@ boolean G_Responder(event_t *ev) switch (ev->type) { case ev_keydown: - if (ev->data1 == gamecontrol[gc_pause][0] - || ev->data1 == gamecontrol[gc_pause][1] + if (ev->data1 == gamecontrol[0][gc_pause][0] + || ev->data1 == gamecontrol[0][gc_pause][1] || ev->data1 == KEY_PAUSE) { if (!pausedelay) @@ -1473,8 +1475,8 @@ boolean G_Responder(event_t *ev) } // no splitscreen support for director here - if (ev->data1 == gamecontrol[gc_director][0] - || ev->data1 == gamecontrol[gc_director][1]) + if (ev->data1 == gamecontrol[0][gc_director][0] + || ev->data1 == gamecontrol[0][gc_director][1]) { K_ToggleDirector(); } @@ -1482,8 +1484,8 @@ boolean G_Responder(event_t *ev) // absolutely horrid for (INT32 i = 0; i <= splitscreen; i++) { - if (ev->data1 == gamecontrols[i][gc_camtoggle][0] - || ev->data1 == gamecontrols[i][gc_camtoggle][1]) + if (ev->data1 == gamecontrol[i][gc_camtoggle][0] + || ev->data1 == gamecontrol[i][gc_camtoggle][1]) { if (!camtoggledelay[i]) { @@ -1492,8 +1494,8 @@ boolean G_Responder(event_t *ev) } } - if (ev->data1 == gamecontrols[i][gc_spectate][0] - || ev->data1 == gamecontrols[i][gc_spectate][1]) + if (ev->data1 == gamecontrol[i][gc_spectate][0] + || ev->data1 == gamecontrol[i][gc_spectate][1]) { if (!spectatedelay[i]) { @@ -1502,8 +1504,8 @@ boolean G_Responder(event_t *ev) } } - if (ev->data1 == gamecontrols[i][gc_freecam][0] - || ev->data1 == gamecontrols[i][gc_freecam][1]) + if (ev->data1 == gamecontrol[i][gc_freecam][0] + || ev->data1 == gamecontrol[i][gc_freecam][1]) { P_ToggleDemoCamera(i); } diff --git a/src/g_input.c b/src/g_input.c index 3c38cf192..f7ea83a75 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -131,18 +131,7 @@ joy3xmove[JOYAXISSET], joy3ymove[JOYAXISSET], joy4xmove[JOYAXISSET], joy4ymove[J UINT8 gamekeydown[NUMINPUTS]; // two key codes (or virtual key) per game control -INT32 gamecontrol[num_gamecontrols][2]; -INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player -INT32 gamecontrol3[num_gamecontrols][2]; // tertiary splitscreen player -INT32 gamecontrol4[num_gamecontrols][2]; // quarternary splitscreen player - -// TODO: this is dumb as hell -INT32 (*gamecontrols[MAXSPLITSCREENPLAYERS])[2] = { - gamecontrol, - gamecontrolbis, - gamecontrol3, - gamecontrol4 -}; +INT32 gamecontrol[MAXSPLITSCREENPLAYERS][num_gamecontrols][2]; typedef struct { @@ -985,13 +974,14 @@ void G_ClearControlKeys(INT32 (*setupcontrols)[2], INT32 control) void G_ClearAllControlKeys(void) { - INT32 i; - for (i = 0; i < num_gamecontrols; i++) + INT32 i, k; + + for (k = 0; k < MAXSPLITSCREENPLAYERS; k++) { - G_ClearControlKeys(gamecontrol, i); - G_ClearControlKeys(gamecontrolbis, i); - G_ClearControlKeys(gamecontrol3, i); - G_ClearControlKeys(gamecontrol4, i); + for (i = 0; i < num_gamecontrols; i++) + { + G_ClearControlKeys(gamecontrol[k], i); + } } } @@ -1049,158 +1039,131 @@ void G_Controldefault(UINT8 player) if (player == 0 || player == 1) { // Main controls - gamecontrol[gc_aimforward ][0] = KEY_UPARROW; - gamecontrol[gc_aimbackward][0] = KEY_DOWNARROW; - gamecontrol[gc_turnleft ][0] = KEY_LEFTARROW; - gamecontrol[gc_turnright ][0] = KEY_RIGHTARROW; - gamecontrol[gc_accelerate ][0] = 'a'; - gamecontrol[gc_drift ][0] = 's'; - gamecontrol[gc_brake ][0] = 'd'; - gamecontrol[gc_fire ][0] = KEY_SPACE; - gamecontrol[gc_lookback ][0] = KEY_LSHIFT; + gamecontrol[0][gc_aimforward ][0] = KEY_UPARROW; + gamecontrol[0][gc_aimbackward][0] = KEY_DOWNARROW; + gamecontrol[0][gc_turnleft ][0] = KEY_LEFTARROW; + gamecontrol[0][gc_turnright ][0] = KEY_RIGHTARROW; + gamecontrol[0][gc_accelerate ][0] = 'a'; + gamecontrol[0][gc_drift ][0] = 's'; + gamecontrol[0][gc_brake ][0] = 'd'; + gamecontrol[0][gc_fire ][0] = KEY_SPACE; + gamecontrol[0][gc_lookback ][0] = KEY_LSHIFT; - gamecontrol[gc_accelerate ][1] = KEY_JOY1+0; // A - gamecontrol[gc_lookback ][1] = KEY_JOY1+2; // X - gamecontrol[gc_brake ][1] = KEY_JOY1+1; // B - gamecontrol[gc_fire ][1] = KEY_JOY1+9; // LB - gamecontrol[gc_drift ][1] = KEY_JOY1+10; // RB + gamecontrol[0][gc_accelerate ][1] = KEY_JOY1+0; // A + gamecontrol[0][gc_lookback ][1] = KEY_JOY1+2; // X + gamecontrol[0][gc_brake ][1] = KEY_JOY1+1; // B + gamecontrol[0][gc_fire ][1] = KEY_JOY1+9; // LB + gamecontrol[0][gc_drift ][1] = KEY_JOY1+10; // RB // Extra controls - gamecontrol[gc_pause ][0] = KEY_PAUSE; - gamecontrol[gc_console ][0] = KEY_CONSOLE; - gamecontrol[gc_screenshot ][0] = KEY_F8; - gamecontrol[gc_recordgif ][0] = KEY_F9; - gamecontrol[gc_viewpoint ][0] = KEY_F12; - gamecontrol[gc_talkkey ][0] = 't'; + gamecontrol[0][gc_pause ][0] = KEY_PAUSE; + gamecontrol[0][gc_console ][0] = KEY_CONSOLE; + gamecontrol[0][gc_screenshot ][0] = KEY_F8; + gamecontrol[0][gc_recordgif ][0] = KEY_F9; + gamecontrol[0][gc_viewpoint ][0] = KEY_F12; + gamecontrol[0][gc_talkkey ][0] = 't'; //gamecontrol[gc_teamkey ][0] = 'y'; - gamecontrol[gc_scores ][0] = KEY_TAB; - gamecontrol[gc_spectate ][0] = '\''; - gamecontrol[gc_lookup ][0] = KEY_PGUP; - gamecontrol[gc_lookdown ][0] = KEY_PGDN; - gamecontrol[gc_centerview ][0] = KEY_END; - gamecontrol[gc_camreset ][0] = KEY_HOME; - gamecontrol[gc_camtoggle ][0] = KEY_BACKSPACE; + gamecontrol[0][gc_scores ][0] = KEY_TAB; + gamecontrol[0][gc_spectate ][0] = '\''; + gamecontrol[0][gc_lookup ][0] = KEY_PGUP; + gamecontrol[0][gc_lookdown ][0] = KEY_PGDN; + gamecontrol[0][gc_centerview ][0] = KEY_END; + gamecontrol[0][gc_camreset ][0] = KEY_HOME; + gamecontrol[0][gc_camtoggle ][0] = KEY_BACKSPACE; - gamecontrol[gc_viewpoint ][1] = KEY_JOY1+3; // Y - gamecontrol[gc_pause ][1] = KEY_JOY1+4; // Back - gamecontrol[gc_systemmenu ][0] = KEY_JOY1+6; // Start - //gamecontrol[gc_camtoggle ][1] = KEY_HAT1+0; // D-Pad Up - //gamecontrol[gc_screenshot ][1] = KEY_HAT1+1; // D-Pad Down // absolutely fucking NOT - gamecontrol[gc_talkkey ][1] = KEY_HAT1+1; // D-Pad Down - gamecontrol[gc_scores ][1] = KEY_HAT1+0; // D-Pad Up + gamecontrol[0][gc_viewpoint ][1] = KEY_JOY1+3; // Y + gamecontrol[0][gc_pause ][1] = KEY_JOY1+4; // Back + gamecontrol[0][gc_systemmenu ][0] = KEY_JOY1+6; // Start + //gamecontrol[0][gc_camtoggle ][1] = KEY_HAT1+0; // D-Pad Up + //gamecontrol[0][gc_screenshot ][1] = KEY_HAT1+1; // D-Pad Down // absolutely fucking NOT + gamecontrol[0][gc_talkkey ][1] = KEY_HAT1+1; // D-Pad Down + gamecontrol[0][gc_scores ][1] = KEY_HAT1+0; // D-Pad Up } if (player == 0 || player == 2) { // Player 2 controls - gamecontrolbis[gc_accelerate ][0] = KEY_2JOY1+0; // A - gamecontrolbis[gc_lookback ][0] = KEY_2JOY1+2; // X - gamecontrolbis[gc_brake ][0] = KEY_2JOY1+1; // B - gamecontrolbis[gc_fire ][0] = KEY_2JOY1+9; // LB - gamecontrolbis[gc_drift ][0] = KEY_2JOY1+10; // RB + gamecontrol[1][gc_accelerate ][0] = KEY_2JOY1+0; // A + gamecontrol[1][gc_lookback ][0] = KEY_2JOY1+2; // X + gamecontrol[1][gc_brake ][0] = KEY_2JOY1+1; // B + gamecontrol[1][gc_fire ][0] = KEY_2JOY1+9; // LB + gamecontrol[1][gc_drift ][0] = KEY_2JOY1+10; // RB } if (player == 0 || player == 3) { // Player 3 controls - gamecontrol3[gc_accelerate ][0] = KEY_3JOY1+0; // A - gamecontrol3[gc_lookback ][0] = KEY_3JOY1+2; // X - gamecontrol3[gc_brake ][0] = KEY_3JOY1+1; // B - gamecontrol3[gc_fire ][0] = KEY_3JOY1+9; // LB - gamecontrol3[gc_drift ][0] = KEY_3JOY1+10; // RB + gamecontrol[2][gc_accelerate ][0] = KEY_3JOY1+0; // A + gamecontrol[2][gc_lookback ][0] = KEY_3JOY1+2; // X + gamecontrol[2][gc_brake ][0] = KEY_3JOY1+1; // B + gamecontrol[2][gc_fire ][0] = KEY_3JOY1+9; // LB + gamecontrol[2][gc_drift ][0] = KEY_3JOY1+10; // RB } if (player == 0 || player == 4) { // Player 4 controls - gamecontrol4[gc_accelerate ][0] = KEY_4JOY1+0; // A - gamecontrol4[gc_lookback ][0] = KEY_4JOY1+2; // X - gamecontrol4[gc_brake ][0] = KEY_4JOY1+1; // B - gamecontrol4[gc_fire ][0] = KEY_4JOY1+9; // LB - gamecontrol4[gc_drift ][0] = KEY_4JOY1+10; // RB + gamecontrol[3][gc_accelerate ][0] = KEY_4JOY1+0; // A + gamecontrol[3][gc_lookback ][0] = KEY_4JOY1+2; // X + gamecontrol[3][gc_brake ][0] = KEY_4JOY1+1; // B + gamecontrol[3][gc_fire ][0] = KEY_4JOY1+9; // LB + gamecontrol[3][gc_drift ][0] = KEY_4JOY1+10; // RB } } void G_SaveKeySetting(FILE *f) { - INT32 i; + INT32 i, k; - for (i = 1; i < num_gamecontrols; i++) + static const char *controltext[MAXSPLITSCREENPLAYERS] = { + "setcontrol", + "setcontrol2", + "setcontrol3", + "setcontrol4" + }; + + for (k = 0; k < MAXSPLITSCREENPLAYERS; k++) { - fprintf(f, "setcontrol \"%s\" \"%s\"", gamecontrolname[i], - G_KeynumToString(gamecontrol[i][0])); + for (i = 1; i < num_gamecontrols; i++) + { + fprintf(f, "%s \"%s\" \"%s\"", controltext[k], gamecontrolname[i], + G_KeynumToString(gamecontrol[k][i][0])); - if (gamecontrol[i][1]) - fprintf(f, " \"%s\"\n", G_KeynumToString(gamecontrol[i][1])); - else - fprintf(f, "\n"); - } - - for (i = 1; i < num_gamecontrols; i++) - { - fprintf(f, "setcontrol2 \"%s\" \"%s\"", gamecontrolname[i], - G_KeynumToString(gamecontrolbis[i][0])); - - if (gamecontrolbis[i][1]) - fprintf(f, " \"%s\"\n", G_KeynumToString(gamecontrolbis[i][1])); - else - fprintf(f, "\n"); - } - - for (i = 1; i < num_gamecontrols; i++) - { - fprintf(f, "setcontrol3 \"%s\" \"%s\"", gamecontrolname[i], - G_KeynumToString(gamecontrol3[i][0])); - - if (gamecontrol3[i][1]) - fprintf(f, " \"%s\"\n", G_KeynumToString(gamecontrol3[i][1])); - else - fprintf(f, "\n"); - } - - for (i = 1; i < num_gamecontrols; i++) - { - fprintf(f, "setcontrol4 \"%s\" \"%s\"", gamecontrolname[i], - G_KeynumToString(gamecontrol4[i][0])); - - if (gamecontrol4[i][1]) - fprintf(f, " \"%s\"\n", G_KeynumToString(gamecontrol4[i][1])); - else - fprintf(f, "\n"); + if (gamecontrol[k][i][1]) + fprintf(f, " \"%s\"\n", G_KeynumToString(gamecontrol[k][i][1])); + else + fprintf(f, "\n"); + } } } INT32 G_CheckDoubleUsage(INT32 keynum, boolean modify) { INT32 result = gc_null; + if (cv_controlperkey.value == 1) { - INT32 i, j; - for (i = 0; i < num_gamecontrols; i++) + INT32 i, j, k; + + for (k = 0; k < MAXSPLITSCREENPLAYERS; k++) { - for (j = 0; j < 2; j++) + for (i = 0; i < num_gamecontrols; i++) { - if (gamecontrol[i][j] == keynum) { - result = i; - if (modify) gamecontrol[i][j] = KEY_NULL; + for (j = 0; j < 2; j++) + { + if (gamecontrol[k][i][j] == keynum) + { + result = i; + if (modify) gamecontrol[k][i][j] = KEY_NULL; + } + + if (result && !modify) + return result; } - if (gamecontrolbis[i][j] == keynum) { - result = i; - if (modify) gamecontrolbis[i][j] = KEY_NULL; - } - if (gamecontrol3[i][j] == keynum) { - result = i; - if (modify) gamecontrol3[i][j] = KEY_NULL; - } - if (gamecontrol4[i][j] == keynum) { - result = i; - if (modify) gamecontrol4[i][j] = KEY_NULL; - } - if (result && !modify) - return result; } } } + return result; } @@ -1354,11 +1317,11 @@ static void setcontrol(INT32 (*gc)[2]) INT32 player; boolean nestedoverride = false; - if ((void*)gc == (void*)&gamecontrol4) + if ((void*)gc == (void*)&gamecontrol[3]) player = 3; - else if ((void*)gc == (void*)&gamecontrol3) + else if ((void*)gc == (void*)&gamecontrol[2]) player = 2; - else if ((void*)gc == (void*)&gamecontrolbis) + else if ((void*)gc == (void*)&gamecontrol[1]) player = 1; else player = 0; @@ -1421,7 +1384,7 @@ void Command_Setcontrol_f(void) return; } - setcontrol(gamecontrol); + setcontrol(gamecontrol[0]); } void Command_Setcontrol2_f(void) @@ -1436,7 +1399,7 @@ void Command_Setcontrol2_f(void) return; } - setcontrol(gamecontrolbis); + setcontrol(gamecontrol[1]); } void Command_Setcontrol3_f(void) @@ -1451,7 +1414,7 @@ void Command_Setcontrol3_f(void) return; } - setcontrol(gamecontrol3); + setcontrol(gamecontrol[2]); } void Command_Setcontrol4_f(void) @@ -1466,5 +1429,5 @@ void Command_Setcontrol4_f(void) return; } - setcontrol(gamecontrol4); + setcontrol(gamecontrol[3]); } diff --git a/src/g_input.h b/src/g_input.h index 820e2cdbc..b8e4cd8d8 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -121,16 +121,12 @@ extern INT32 joyxmove[JOYAXISSET], joyymove[JOYAXISSET], joy2xmove[JOYAXISSET], extern UINT8 gamekeydown[NUMINPUTS]; // two key codes (or virtual key) per game control -extern INT32 gamecontrol[num_gamecontrols][2]; -extern INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player -extern INT32 gamecontrol3[num_gamecontrols][2]; -extern INT32 gamecontrol4[num_gamecontrols][2]; -extern INT32 (*gamecontrols[MAXSPLITSCREENPLAYERS])[2]; +extern INT32 gamecontrol[MAXSPLITSCREENPLAYERS][num_gamecontrols][2]; -#define PLAYER1INPUTDOWN(gc) (gamekeydown[gamecontrol[gc][0]] || gamekeydown[gamecontrol[gc][1]]) -#define PLAYER2INPUTDOWN(gc) (gamekeydown[gamecontrolbis[gc][0]] || gamekeydown[gamecontrolbis[gc][1]]) -#define PLAYER3INPUTDOWN(gc) (gamekeydown[gamecontrol3[gc][0]] || gamekeydown[gamecontrol3[gc][1]]) -#define PLAYER4INPUTDOWN(gc) (gamekeydown[gamecontrol4[gc][0]] || gamekeydown[gamecontrol4[gc][1]]) +#define PLAYER1INPUTDOWN(gc) (gamekeydown[gamecontrol[0][gc][0]] || gamekeydown[gamecontrol[0][gc][1]]) +#define PLAYER2INPUTDOWN(gc) (gamekeydown[gamecontrol[1][gc][0]] || gamekeydown[gamecontrol[1][gc][1]]) +#define PLAYER3INPUTDOWN(gc) (gamekeydown[gamecontrol[2][gc][0]] || gamekeydown[gamecontrol[2][gc][1]]) +#define PLAYER4INPUTDOWN(gc) (gamekeydown[gamecontrol[3][gc][0]] || gamekeydown[gamecontrol[3][gc][1]]) // peace to my little coder fingers! // check a gamecontrol being active or not diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 268059d06..feedf4039 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1315,7 +1315,7 @@ boolean HU_Responder(event_t *ev) INT32 i; for (i = 0; i < num_gamecontrols; i++) { - if (gamecontrol[i][0] == ev->data1 || gamecontrol[i][1] == ev->data1) + if (gamecontrol[0][i][0] == ev->data1 || gamecontrol[0][i][1] == ev->data1) break; } @@ -1327,7 +1327,7 @@ boolean HU_Responder(event_t *ev) if (!chat_on) { // enter chat mode - if ((ev->data1 == gamecontrol[gc_talkkey][0] || ev->data1 == gamecontrol[gc_talkkey][1]) + if ((ev->data1 == gamecontrol[0][gc_talkkey][0] || ev->data1 == gamecontrol[0][gc_talkkey][1]) && netgame && !OLD_MUTE) // check for old chat mute, still let the players open the chat incase they want to scroll otherwise. { chat_on = true; @@ -1338,7 +1338,7 @@ boolean HU_Responder(event_t *ev) typelines = 1; return true; } - if ((ev->data1 == gamecontrol[gc_teamkey][0] || ev->data1 == gamecontrol[gc_teamkey][1]) + if ((ev->data1 == gamecontrol[0][gc_teamkey][0] || ev->data1 == gamecontrol[0][gc_teamkey][1]) && netgame && !OLD_MUTE) { chat_on = true; @@ -1364,8 +1364,8 @@ boolean HU_Responder(event_t *ev) // Ignore non-keyboard keys, except when the talk key is bound if (ev->data1 >= KEY_MOUSE1 - && (ev->data1 != gamecontrol[gc_talkkey][0] - && ev->data1 != gamecontrol[gc_talkkey][1])) + && (ev->data1 != gamecontrol[0][gc_talkkey][0] + && ev->data1 != gamecontrol[0][gc_talkkey][1])) return false; M_TextInputHandle(&w_chat, c); @@ -1377,8 +1377,8 @@ boolean HU_Responder(event_t *ev) HU_SendChatMessage(); } else if (c == KEY_ESCAPE - || ((c == gamecontrol[gc_talkkey][0] || c == gamecontrol[gc_talkkey][1] - || c == gamecontrol[gc_teamkey][0] || c == gamecontrol[gc_teamkey][1]) + || ((c == gamecontrol[0][gc_talkkey][0] || c == gamecontrol[0][gc_talkkey][1] + || c == gamecontrol[0][gc_teamkey][0] || c == gamecontrol[0][gc_teamkey][1]) && c >= KEY_MOUSE1)) // If it's not a keyboard key, then the chat button is used as a toggle. { chat_on = false; diff --git a/src/m_menu.c b/src/m_menu.c index bcd406e4c..27902ce9c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3887,8 +3887,8 @@ boolean M_Responder(event_t *ev) { if (currentMenu == &MISC_ChangeLevelDef || currentMenu == &MP_OfflineServerDef || currentMenu == &MP_ServerDef) { - if (ch == gamecontrol[gc_fire][0] - || ch == gamecontrol[gc_fire][1]) + if (ch == gamecontrol[0][gc_fire][0] + || ch == gamecontrol[0][gc_fire][1]) { COM_ImmedExecute("add kartencore 1"); } @@ -4021,9 +4021,9 @@ boolean M_Responder(event_t *ev) if (ch == -1) return false; - else if (ch == gamecontrol[gc_systemmenu][0] || ch == gamecontrol[gc_systemmenu][1]) // allow remappable ESC key + else if (ch == gamecontrol[0][gc_systemmenu][0] || ch == gamecontrol[0][gc_systemmenu][1]) // allow remappable ESC key ch = KEY_ESCAPE; - else if ((ch == gamecontrol[gc_accelerate][0] || ch == gamecontrol[gc_accelerate][1]) && ch >= KEY_MOUSE1) + else if ((ch == gamecontrol[0][gc_accelerate][0] || ch == gamecontrol[0][gc_accelerate][1]) && ch >= KEY_MOUSE1) ch = KEY_ENTER; // F-Keys @@ -4099,7 +4099,7 @@ boolean M_Responder(event_t *ev) return false; } - if ((ch == gamecontrol[gc_brake][0] || ch == gamecontrol[gc_brake][1]) && ch >= KEY_MOUSE1) // do this here, otherwise brake opens the menu mid-game + if ((ch == gamecontrol[0][gc_brake][0] || ch == gamecontrol[0][gc_brake][1]) && ch >= KEY_MOUSE1) // do this here, otherwise brake opens the menu mid-game ch = KEY_ESCAPE; routine = currentMenu->menuitems[itemOn].itemaction; @@ -10097,7 +10097,7 @@ static void M_HandleMasterServerResetChoice(event_t *ev) if (ev->type == ev_keydown) { - if (choice == ' ' || choice == 'y' || choice == KEY_ENTER || choice == gamecontrol[gc_accelerate][0] || choice == gamecontrol[gc_accelerate][1]) + if (choice == ' ' || choice == 'y' || choice == KEY_ENTER || choice == gamecontrol[0][gc_accelerate][0] || choice == gamecontrol[0][gc_accelerate][1]) { CV_Set(&cv_masterserver, cv_masterserver.defaultvalue); CV_Set(&cv_masterserver_nagattempts, cv_masterserver_nagattempts.defaultvalue); @@ -10251,8 +10251,8 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) if (levellistmode != LLM_RECORDATTACK) // so it doesent show in record attack menu { char encoretoggle[32] = {0}; - const char *item1 = gamecontrol[gc_fire][0] != 0 ? G_KeynumToString(gamecontrol[gc_fire][0]) : NULL; - const char *item2 = gamecontrol[gc_fire][1] != 0 ? G_KeynumToString(gamecontrol[gc_fire][1]) : NULL; + const char *item1 = gamecontrol[0][gc_fire][0] != 0 ? G_KeynumToString(gamecontrol[0][gc_fire][0]) : NULL; + const char *item2 = gamecontrol[0][gc_fire][1] != 0 ? G_KeynumToString(gamecontrol[0][gc_fire][1]) : NULL; if (item1 != NULL && item2 != NULL) snprintf(encoretoggle, 32, "%s/%s - Toggle Encore", item1, item2); @@ -11445,7 +11445,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) boolean exitmenu = false; // exit to previous menu and send name change const boolean gridselect = (cv_skinselectmenu.value == SKINMENUTYPE_GRID || cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED); // menus with "grids" - if ((choice == gamecontrol[gc_fire][0] || choice == gamecontrol[gc_fire][1]) && (itemOn == 2 || (gridselect && itemOn == 1))) + if ((choice == gamecontrol[0][gc_fire][0] || choice == gamecontrol[0][gc_fire][1]) && (itemOn == 2 || (gridselect && itemOn == 1))) choice = KEY_BACKSPACE; // Hack to allow resetting prefcolor on controllers #define BREAKWHENLOCKED {\ @@ -11741,8 +11741,8 @@ static void M_HandleSetupMultiPlayer(INT32 choice) break; //c why????? - //case gamecontrol[gc_accelerate][0]: - //case gamecontrol[gc_accelerate][1]: + //case gamecontrol[0][gc_accelerate][0]: + //case gamecontrol[0][gc_accelerate][1]: case KEY_ENTER: if (cv_skinselectmenu.value == SKINMENUTYPE_2D) { @@ -12356,7 +12356,7 @@ static void M_Setup1PControlsMenu(INT32 choice) { (void)choice; setupcontrolplayer = 1; - setupcontrols = gamecontrol; // was called from main Options (for console player, then) + setupcontrols = gamecontrol[0]; // was called from main Options (for console player, then) currentMenu->lastOn = itemOn; // Set proper gamepad options @@ -12379,7 +12379,7 @@ static void M_Setup2PControlsMenu(INT32 choice) { (void)choice; setupcontrolplayer = 2; - setupcontrols = gamecontrolbis; + setupcontrols = gamecontrol[1]; currentMenu->lastOn = itemOn; // Set proper gamepad options @@ -12402,7 +12402,7 @@ static void M_Setup3PControlsMenu(INT32 choice) { (void)choice; setupcontrolplayer = 3; - setupcontrols = gamecontrol3; + setupcontrols = gamecontrol[2]; currentMenu->lastOn = itemOn; // Set proper gamepad options @@ -12425,7 +12425,7 @@ static void M_Setup4PControlsMenu(INT32 choice) { (void)choice; setupcontrolplayer = 4; - setupcontrols = gamecontrol4; + setupcontrols = gamecontrol[3]; currentMenu->lastOn = itemOn; // Set proper gamepad options @@ -12673,17 +12673,17 @@ static void M_ResetControlsResponse(INT32 ch) switch (setupcontrolplayer) { case 4: - G_ClearControlKeys(gamecontrol4, i); + G_ClearControlKeys(gamecontrol[3], i); break; case 3: - G_ClearControlKeys(gamecontrol3, i); + G_ClearControlKeys(gamecontrol[2], i); break; case 2: - G_ClearControlKeys(gamecontrolbis, i); + G_ClearControlKeys(gamecontrol[1], i); break; case 1: default: - G_ClearControlKeys(gamecontrol, i); + G_ClearControlKeys(gamecontrol[0], i); break; } } diff --git a/src/m_misc.c b/src/m_misc.c index ff9892464..6b9699243 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1577,9 +1577,9 @@ boolean M_ScreenshotResponder(event_t *ev) if (ch >= KEY_MOUSE1 && menuactive) // If it's not a keyboard key, then don't allow it in the menus! return false; - if (ch == KEY_F8 || ch == gamecontrol[gc_screenshot][0] || ch == gamecontrol[gc_screenshot][1]) // remappable F8 + if (ch == KEY_F8 || ch == gamecontrol[0][gc_screenshot][0] || ch == gamecontrol[0][gc_screenshot][1]) // remappable F8 M_ScreenShot(); - else if (ch == KEY_F9 || ch == gamecontrol[gc_recordgif][0] || ch == gamecontrol[gc_recordgif][1]) // remappable F9 + else if (ch == KEY_F9 || ch == gamecontrol[0][gc_recordgif][0] || ch == gamecontrol[0][gc_recordgif][1]) // remappable F9 ((moviemode) ? M_StopMovie : M_StartMovie)(); else return false; diff --git a/src/st_stuff.c b/src/st_stuff.c index 6e39661e7..aac9b7fa7 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -506,8 +506,8 @@ static void ST_drawLevelTitle(void) static const char *ST_GetButtonName(INT32 control, const char *inputtext, boolean unbound, boolean gamectrl) { static char buttname[32] = ""; - const char *butt1 = (gamecontrol[control][0] != 0 ? G_KeynumToString(gamecontrol[control][0]) : NULL); - const char *butt2 = (gamecontrol[control][1] != 0 ? G_KeynumToString(gamecontrol[control][1]) : NULL); // alternative bind + const char *butt1 = (gamecontrol[0][control][0] != 0 ? G_KeynumToString(gamecontrol[0][control][0]) : NULL); + const char *butt2 = (gamecontrol[0][control][1] != 0 ? G_KeynumToString(gamecontrol[0][control][1]) : NULL); // alternative bind if (butt1 == NULL && butt2 == NULL) // not bound to a button snprintf(buttname, 32, (unbound ? "%s - %s" : (gamectrl ? "-%s - %s" : "%s - %s")), (unbound ? "Unbound" : ""), inputtext); From 58a9e17500296996f402e93da3ce26dc863d5d19 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 09:42:01 +0200 Subject: [PATCH 316/350] fix spectator key lel oopsie --- src/g_game.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index eaec9e212..18b7f94c0 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1299,6 +1299,25 @@ static INT32 pausedelay = 0; static INT32 camtoggledelay[MAXSPLITSCREENPLAYERS] = {0,0,0,0}; static INT32 spectatedelay[MAXSPLITSCREENPLAYERS] = {0,0,0,0}; +static void G_ToggleSpectate(INT32 player) +{ + switch (player) + { + case 0: + COM_ImmedExecute("changeteam spectator"); + break; + case 1: + COM_ImmedExecute("changeteam2 spectator"); + break; + case 2: + COM_ImmedExecute("changeteam3 spectator"); + break; + case 3: + COM_ImmedExecute("changeteam4 spectator"); + break; + } +} + static boolean G_LevelResponder(event_t *ev) { // allow spy mode changes even during the demo @@ -1500,7 +1519,7 @@ boolean G_Responder(event_t *ev) if (!spectatedelay[i]) { spectatedelay[i] = NEWTICRATE / 7; - COM_ImmedExecute("changeteam spectator"); + G_ToggleSpectate(i); } } From b6fd7a1e9675f6fa6513f3aea765a334e56672c8 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 13:02:26 +0200 Subject: [PATCH 317/350] put precip purge into a function to reduce code dupe and branching --- src/p_mobj.c | 20 ++++++-------------- src/p_saveg.c | 19 +------------------ src/p_spec.c | 44 +++++++++++++++----------------------------- src/p_spec.h | 1 + src/r_main.c | 22 +++------------------- 5 files changed, 26 insertions(+), 80 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index fb34b335d..364396ce8 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10174,21 +10174,13 @@ void P_RemoveSavegameMobj(mobj_t *mobj) thinker_t *th = (thinker_t*)mobj; // unlink from sector and block lists - if (th->function.acp1 == (actionf_p1)P_NullPrecipThinker) - { - P_UnsetPrecipThingPosition((precipmobj_t *)mobj); - } - else - { - // unlink from sector and block lists - P_UnsetThingPosition(mobj); + P_UnsetThingPosition(mobj); - // Remove touching_sectorlist from mobj. - if (sector_list) - { - P_DelSeclist(sector_list); - sector_list = NULL; - } + // Remove touching_sectorlist from mobj. + if (sector_list) + { + P_DelSeclist(sector_list); + sector_list = NULL; } // stop any playing sound diff --git a/src/p_saveg.c b/src/p_saveg.c index b5f11cedb..c63887b69 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2669,8 +2669,6 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save) { thinker_t *currentthinker; thinker_t *next; - thinker_t *currentprecipthinker; - thinker_t *nextprecip; UINT8 tclass; UINT8 restoreNum = false; UINT32 i; @@ -2696,22 +2694,7 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save) } // remove all the current precip thinkers - currentprecipthinker = precipcap.next; - for (currentprecipthinker = precipcap.next; currentprecipthinker != &precipcap; currentprecipthinker = nextprecip) - { - nextprecip = currentprecipthinker->next; - -#ifdef PARANOIA - if (currentprecipthinker->function.acp1 != (actionf_p1)P_NullPrecipThinker) - { - (next->prev = currentprecipthinker->prev)->next = nextprecip; - R_DestroyLevelInterpolators(currentprecipthinker); - Z_Free(currentprecipthinker); - } - else -#endif - P_RemoveSavegameMobj((mobj_t *)currentprecipthinker); // item isn't saved, don't remove it - } + P_PurgePrecipitation(); // we don't want the removed mobjs to come back iquetail = iquehead = 0; diff --git a/src/p_spec.c b/src/p_spec.c index 670289fcf..e14d09333 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1721,6 +1721,19 @@ static boolean is_rain_type (INT32 weathernum) } } +void P_PurgePrecipitation(void) +{ + thinker_t *think; + thinker_t *next; + + for (think = precipcap.next; think != NULL && think != &precipcap;) + { + next = think->next; + P_FreePrecipMobj((precipmobj_t *)think); + think = next; + } +} + // // P_SwitchWeather // @@ -1729,6 +1742,7 @@ static boolean is_rain_type (INT32 weathernum) void P_SwitchWeather(INT32 weathernum) { boolean purge = true; + boolean spawnprecip = false; if (weathernum == curWeather) return; @@ -1739,22 +1753,7 @@ void P_SwitchWeather(INT32 weathernum) if (purge) { - thinker_t *think; - thinker_t *next; - precipmobj_t *precipmobj; - - for (think = precipcap.next; think != &precipcap; think = next) - { - next = think->next; - -#ifdef PARANOIA - if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) - continue; // not a precipmobj thinker -#endif - - precipmobj = (precipmobj_t *)think; - P_FreePrecipMobj(precipmobj); - } + P_PurgePrecipitation(); } else // Rather than respawn all that crap, reuse it! { @@ -1764,11 +1763,6 @@ void P_SwitchWeather(INT32 weathernum) for (think = precipcap.next; think != &precipcap; think = think->next) { -#ifdef PARANOIA - if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) - continue; // not a precipmobj thinker -#endif - precipmobj = (precipmobj_t *)think; INT32 z = 0; @@ -1813,8 +1807,6 @@ void P_SwitchWeather(INT32 weathernum) } } - boolean spawnprecip = false; - switch (weathernum) { case PRECIP_SNOW: // snow @@ -1822,23 +1814,17 @@ void P_SwitchWeather(INT32 weathernum) spawnprecip = true; break; case PRECIP_RAIN: // rain - { curWeather = PRECIP_RAIN; spawnprecip = true; break; - } case PRECIP_STORM: // storm - { curWeather = PRECIP_STORM; spawnprecip = true; break; - } case PRECIP_STORM_NOSTRIKES: // storm w/o lightning - { curWeather = PRECIP_STORM_NOSTRIKES; spawnprecip = true; break; - } case PRECIP_STORM_NORAIN: // storm w/o rain curWeather = PRECIP_STORM_NORAIN; break; diff --git a/src/p_spec.h b/src/p_spec.h index c89d024d2..60b10a8f4 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -74,6 +74,7 @@ INT32 P_FindMinSurroundingLight(sector_t *sector, INT32 max); void P_SetupSignExit(player_t *player); boolean P_IsFlagAtBase(mobjtype_t flag); +void P_PurgePrecipitation(void); void P_SwitchWeather(INT32 weathernum); boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller); diff --git a/src/r_main.c b/src/r_main.c index 4ff9a96ff..b1b707d1d 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -295,27 +295,11 @@ static void FlipCam4_OnChange(void) static void Precipstuff_OnChange(void) { - if (gamestate != GS_LEVEL) - return; - - thinker_t *think; - thinker_t *next; - precipmobj_t *precipmobj; - - for (think = precipcap.next; think != &precipcap; think = next) + if (gamestate == GS_LEVEL) { - next = think->next; - -#ifdef PARANOIA - if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) - continue; // not a precipmobj thinker -#endif - - precipmobj = (precipmobj_t *)think; - P_FreePrecipMobj(precipmobj); + P_PurgePrecipitation(); + P_SpawnPrecipitation(); } - - P_SpawnPrecipitation(); } // From 45506b381e7c167c4c232622304e849917dc11f0 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 13:11:09 +0200 Subject: [PATCH 318/350] take mobjscale into account when skipping small sectors for precip spawn --- src/p_mobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 364396ce8..3fd74f4a7 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10244,7 +10244,7 @@ void P_SpawnPrecipitation(void) continue; // Exists, but is too small for reasonable precipitation. - if (!(precipsector->sector->floorheight <= precipsector->sector->ceilingheight - (32<sector->ceilingheight - precipsector->sector->floorheight, mapobjectscale) < 64< Date: Thu, 24 Apr 2025 06:56:35 +0200 Subject: [PATCH 319/350] deprecate "addskins" command "addskins" is an incredibly ambigous name since its main purpose was to add skins LOCALLY just prints a notice for now since there may be ppl that still use it --- src/d_netcmd.c | 35 +++-------------------------------- src/p_setup.c | 11 ----------- src/p_setup.h | 2 +- 3 files changed, 4 insertions(+), 44 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index d3b9ca5b4..cd9c354fe 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4449,7 +4449,7 @@ static void Command_Addfilelocal(void) // Add any wad file, ignoring checks for if it contains complex things like // lua. Great for complex but client-side customizations, like different // level cards or anything like that. - P_AddWadFileLocal(fn); + P_AddWadFile(fn, true); } @@ -4544,38 +4544,9 @@ static void Command_Addfile(void) /** Adds something at runtime. */ -static void -Command_Addskins (void) +static void Command_Addskins(void) { - if (COM_Argc() > 3) - { - CONS_Printf( - "addskins : Load a skin file.\n"); - return; - } - // no forcing? - /* - if (fasticmp(COM_Argv(2), "-force") || fasticmp(COM_Argv(2), "-f")) { - CONS_Alert(CONS_NOTICE, M_GetText("Adding file %s. May or may not be a skin.\n"), COM_Argv(1)); - P_AddWadFile(COM_Argv(1), 0, true); - } else { - if (DumbStartsWith("KC_", COM_Argv(1))) { - P_AddWadFile(COM_Argv(1), 0, true); - } else if (DumbStartsWith("KCL_", COM_Argv(1))) { - if (!demo.playback) { - CONS_Alert(CONS_ERROR, M_GetText("Cannot add file %s as it is a skin with lua. Include -force or -f to force it to load.\n"), COM_Argv(1)); - return; - } else { - */ - P_AddWadFile(COM_Argv(1), true); - /* - } - } else { - CONS_Alert(CONS_ERROR, M_GetText("Cannot add file %s as it is not a skin.\n"), COM_Argv(1)); - return; - } - } - */ + CONS_Printf("addskins has been deprecated\nuse addfilelocal instead!\n"); } static void Command_GLocalSkin (void) diff --git a/src/p_setup.c b/src/p_setup.c index b51a8abce..1ef81c3cb 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3252,17 +3252,6 @@ boolean P_AddWadFile(const char *wadfilename, boolean local) return true; } -boolean P_AddWadFileLocal(const char *wadfilename) -{ - UINT16 wadnum; - - if ((wadnum = P_PartialAddWadFile(wadfilename, true)) == UINT16_MAX) - return false; - - P_MultiSetupWadFiles(true); - return true; -} - // check for replacement votescreen backgrounds boolean wideracereplaced = false; boolean racereplaced = false; diff --git a/src/p_setup.h b/src/p_setup.h index 723b48d18..f0ae13e6c 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -65,8 +65,8 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate); #ifdef HWRENDER void HWR_LoadLevel(void); #endif + boolean P_AddWadFile(const char *wadfilename, boolean local); -boolean P_AddWadFileLocal(const char *wadfilename); extern boolean wideracereplaced; extern boolean racereplaced; From cd15c5d3803651b756a831ef39aae77a1acc6a07 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 09:21:11 +0200 Subject: [PATCH 320/350] oops didnt think addskins would be used here lel --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 27902ce9c..b78e72ee5 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6719,7 +6719,7 @@ static void M_HandleAddons(INT32 choice) { if (DumbStartsWith("KC_", dirmenu[dir_on[menudepthleft]]+DIR_STRING) || DumbStartsWith("kc_", dirmenu[dir_on[menudepthleft]]+DIR_STRING)) { M_StartMessage(va("%c%s\x80\nYou are loading a local skin.\nLocal skins will not be usable\nafter going back from\nthe title screen.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING),NULL,MM_NOTHING); - COM_BufAddText(va("addskins \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING)); + COM_BufAddText(va("addfilelocal \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING)); } else S_StartSound(NULL, sfx_s26d); From 97093dbeb9b85890143d3373fd07cd14c8d41ceb Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 25 Apr 2025 12:15:57 +0300 Subject: [PATCH 321/350] Don't free PU_SPRITE memory, since it invalidates some lua patches if they are using sprite frames --- src/p_setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index 4c6a76ef1..b229cabdc 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3342,7 +3342,7 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) // // search for sprite replacements // - Patch_FreeTag(PU_SPRITE); + //Patch_FreeTag(PU_SPRITE); //Patch_FreeTag(PU_PATCH_ROTATED); R_AddSpriteDefs(wadnum); From 4f83d3b36bc9c72a7c24da90c53ea0d95656faa8 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 25 Apr 2025 15:02:36 +0200 Subject: [PATCH 322/350] whitespace crap --- src/d_clisrv.c | 3 ++- src/d_netcmd.c | 6 +++--- src/g_game.c | 7 ++++--- src/m_menu.c | 2 +- src/tables.c | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index d76e67e88..51abad01d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6305,7 +6305,8 @@ static void Local_Maketic(INT32 realtics) D_ProcessEvents(); // menu responder, cons responder, // game responder calls HU_Responder, AM_Responder, F_Responder, // and G_MapEventsToControls - if (!dedicated) rendergametic = gametic; + if (!dedicated) + rendergametic = gametic; // translate inputs (keyboard/mouse/joystick) into game controls for (i = 0; i <= splitscreen; i++) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index cd9c354fe..4d41ada94 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2691,7 +2691,8 @@ static tic_t last_map_cmd = 0; // static void Command_Map_f(void) { - if (I_GetTime() - last_map_cmd < 20) { + if (I_GetTime() - last_map_cmd < 20) + { CONS_Alert(CONS_WARNING, "Map command is used too frequently!\n"); return; } @@ -2749,8 +2750,7 @@ static void Command_Map_f(void) { if (!multiplayer) { - CONS_Printf(M_GetText( - "You can't switch gametypes in single player!\n")); + CONS_Printf(M_GetText("You can't switch gametypes in single player!\n")); return; } else if (COM_Argc() < option_gametype + 2)/* no argument after? */ diff --git a/src/g_game.c b/src/g_game.c index 18b7f94c0..77257a6fb 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4010,7 +4010,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool unlocktriggers = 0; // clear itemfinder, just in case - if (!dedicated) // except in dedicated servers, where it is not registered and can actually I_Error debug builds + if (!dedicated) // except in dedicated servers, where it is not registered and can actually I_Error debug builds CV_StealthSetValue(&cv_itemfinder, 0); } @@ -4028,7 +4028,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool // gamemap changed; we assume that its map header is always valid, // so make it so - if(!mapheaderinfo[gamemap-1]) + if (!mapheaderinfo[gamemap-1]) P_AllocMapHeader(gamemap-1); maptol = mapheaderinfo[gamemap-1]->typeoflevel; @@ -5345,7 +5345,8 @@ void G_ConsGhostTic(INT32 playernum) void G_GhostTicker(void) { demoghost *g,*p; - for(g = ghosts, p = NULL; g; g = g->next) + + for (g = ghosts, p = NULL; g; g = g->next) { // Skip normal demo data. UINT8 ziptic = READUINT8(g->p); diff --git a/src/m_menu.c b/src/m_menu.c index b78e72ee5..283870f7c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -9290,7 +9290,7 @@ static void M_TimeAttack(INT32 choice) if (M_CountLevelsToShowInList() == 0) { - M_StartMessage(M_GetText("No record-attackable levels found.\n"),NULL,MM_NOTHING); + M_StartMessage(M_GetText("No record-attackable levels found.\n"), NULL, MM_NOTHING); return; } diff --git a/src/tables.c b/src/tables.c index e293842bc..98a2c8a17 100644 --- a/src/tables.c +++ b/src/tables.c @@ -274,7 +274,7 @@ boolean FV2_InsidePolygon(const vector2_t *vIntersection, const vector2_t *Poly, // with floating point numbers. It usually won't always be perfectly 2 * PI, so we need // to use a little twiddling. I use .9999, but you can change this to fit your own desired accuracy. - if(Angle >= ANGLE_MAX) // If the angle is greater than 2 PI, (360 degrees) + if (Angle >= ANGLE_MAX) // If the angle is greater than 2 PI, (360 degrees) return 1; // The point is inside of the polygon return 0; // If you get here, it obviously wasn't inside the polygon. From a18e81ee186119efbd9418bb226cb358cdb5d1d9 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 25 Apr 2025 21:33:08 +0200 Subject: [PATCH 323/350] invert skywall offset also fixes the issue, but doesent draw skywalls over actual walls in rare cases lets hope this doesent draw walls over actual skywalls now (: --- src/hardware/r_opengl/r_opengl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 0fcb58a3d..d2e363079 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1557,7 +1557,7 @@ void GL_SetBlend(FBITFIELD PolyFlags) { if (PolyFlags & PF_Skydecal) { - pglPolygonOffset(-0.45f, -0.45f); // dont let skywalls draw over actual walls tho + pglPolygonOffset(0.45f, 0.45f); pglEnable(GL_POLYGON_OFFSET_FILL); } else From 8ad161f061af7c885e7fcd02f1fc17b3e1810aed Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 25 Apr 2025 21:34:02 +0200 Subject: [PATCH 324/350] add a few more branching hints also fix some indentation --- src/hardware/hw_main.c | 69 +++++++++++++++++++++--------------------- src/p_slopes.c | 5 ++- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 37d0e25cd..096e738c6 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2437,8 +2437,8 @@ static boolean HWR_CheckBBox(const fixed_t *bspcoord) // Find the corners of the box // that define the edges from current viewpoint. - const INT32 boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT ] ? 1 : 2) + - (viewy >= bspcoord[BOXTOP ] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8); + const INT32 boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT] ? 1 : 2) + + (viewy >= bspcoord[BOXTOP] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8); if (boxpos == 5) return true; @@ -2877,7 +2877,7 @@ static void HWR_Subsector(size_t num) gl_frontsector = R_FakeFlat(gl_frontsector, &tempsec, &floorlightlevel, &ceilinglightlevel, false); - if (gl_portal_state == GLPORTAL_SEARCH) + if (UNLIKELY(gl_portal_state == GLPORTAL_SEARCH)) { goto doaddline; } @@ -3003,37 +3003,37 @@ static void HWR_Subsector(size_t num) { UINT8 alpha; - light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < bottomCullHeight)); alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); HWR_AddTransparentFloor(0, - &extrasubsectors[num], - false, - *rover->bottomheight, - *gl_frontsector->lightlist[light].lightlevel, - alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, - true, rover->master->frontsector->extra_colormap); + &extrasubsectors[num], + false, + *rover->bottomheight, + *gl_frontsector->lightlist[light].lightlevel, + alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, + true, rover->master->frontsector->extra_colormap); } else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) // SoM: Flags are more efficient { - light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < bottomCullHeight)); HWR_AddTransparentFloor(levelflats[*rover->bottompic].lumpnum, - &extrasubsectors[num], - false, - *rover->bottomheight, - *gl_frontsector->lightlist[light].lightlevel, - CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent), - false, gl_frontsector->lightlist[light].extra_colormap); + &extrasubsectors[num], + false, + *rover->bottomheight, + *gl_frontsector->lightlist[light].lightlevel, + CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent), + false, gl_frontsector->lightlist[light].extra_colormap); } else { HWR_GetFlat(levelflats[*rover->bottompic].lumpnum, R_NoEncore(gl_frontsector, false)); - light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < bottomCullHeight)); HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum, - rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); + rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); } } @@ -3049,21 +3049,21 @@ static void HWR_Subsector(size_t num) { UINT8 alpha; - light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < topCullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < topCullHeight)); alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); HWR_AddTransparentFloor(0, - &extrasubsectors[num], - true, - *rover->topheight, - *gl_frontsector->lightlist[light].lightlevel, - alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, - true, rover->master->frontsector->extra_colormap); + &extrasubsectors[num], + true, + *rover->topheight, + *gl_frontsector->lightlist[light].lightlevel, + alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, + true, rover->master->frontsector->extra_colormap); } else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { - light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < topCullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < topCullHeight)); HWR_AddTransparentFloor(levelflats[*rover->toppic].lumpnum, &extrasubsectors[num], @@ -3076,10 +3076,10 @@ static void HWR_Subsector(size_t num) else { HWR_GetFlat(levelflats[*rover->toppic].lumpnum, R_NoEncore(gl_frontsector, true)); - light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < topCullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < topCullHeight)); HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, - rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); + rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); } } } @@ -3459,7 +3459,7 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, GLPatch_t *gpatch) sSurf.PolyColor.s.green = 0x01; // shadow is always half as translucent as the sprite itself - if (!cv_translucency.value) // use default translucency (main sprite won't have any translucency) + if (UNLIKELY(!cv_translucency.value)) // use default translucency (main sprite won't have any translucency) sSurf.PolyColor.s.alpha = 0x80; // default else if (spr->mobj->flags2 & MF2_SHADOW) sSurf.PolyColor.s.alpha = 0x20; @@ -3668,7 +3668,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) else blendmode = spr->mobj->blendmode; - if (!cv_translucency.value) // translucency disabled + if (UNLIKELY(!cv_translucency.value)) // translucency disabled { Surf.PolyColor.s.alpha = 0xFF; blend = PF_Translucent|PF_Occlude; @@ -3952,7 +3952,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) else blendmode = spr->mobj->blendmode; - if (!cv_translucency.value) // translucency disabled + if (UNLIKELY(!cv_translucency.value)) // translucency disabled { Surf.PolyColor.s.alpha = 0xFF; blend = PF_Translucent|PF_Occlude; @@ -5316,6 +5316,7 @@ static void HWR_SetTransformAiming(FTransform *trans) trans->shearing = false; gl_aimingangle = aimingangle; } + trans->anglex = (float)(gl_aimingangle>>ANGLETOFINESHIFT)*(FINEDEGREE); } @@ -5451,7 +5452,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl validcount++; - if (cv_glbatching.value) + if (LIKELY(cv_glbatching.value)) HWR_StartBatching(); if (useportals && !rootportal && portallist.base && !skybox) // if portals have been drawn in the main view, then render skywalls differently @@ -5475,7 +5476,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl PS_STOP_TIMING(ps_bsptime); - if (cv_glbatching.value) + if (LIKELY(cv_glbatching.value)) HWR_RenderBatches(); if (skyWallVertexArraySize) // if there are skywalls to draw using the alternate method diff --git a/src/p_slopes.c b/src/p_slopes.c index e64cd6f6b..b4ebf0284 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -500,6 +500,7 @@ void P_SpawnSlope_Line(int linenum) P_CalculateSlopeNormal(cslope); } } + if (backfloor || backceil) { line->backsector->hasslope = true; // Tell the software renderer that we're sloped @@ -511,7 +512,7 @@ void P_SpawnSlope_Line(int linenum) extent = P_GetExtent(line->backsector, line); - if(extent < 0) + if (extent < 0) { CONS_Printf("P_SpawnSlope_Line failed to get backsector extent on line number %i\n", linenum); return; @@ -678,8 +679,6 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag return ret; } - - // // P_CopySectorSlope // From cf453bad5f292cffc5a11b9491b963f8e30ee6a8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 27 Apr 2025 00:24:52 +0200 Subject: [PATCH 325/350] make a struct for squishy this is horrid but should fix this speeding up when multiple players squish --- src/d_player.h | 12 +++++++++++- src/p_user.c | 44 +++++++++++++++++++++++--------------------- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index a1e4a0b20..af24630c2 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -356,6 +356,16 @@ typedef enum LAP__MAX } laptime_e; +// yes i made a whole struct for this :chonkbuncle: +typedef struct squishdance_s +{ + tic_t countdown; // hold "custom 3" for 2 seconds to engange le dance + tic_t time; + fixed_t work; + fixed_t ang; + fixed_t bounce; // hehe squishy +} squishdance_t; + // ======================================================================== // PLAYER STRUCTURE // ======================================================================== @@ -555,7 +565,7 @@ typedef struct player_s fixed_t spinoutrot; // When a player spins out, this value increments modulus 360. - tic_t dancetime; + squishdance_t squishdance; fixed_t fovadd; // adjust FOV for hw rendering } player_t; diff --git a/src/p_user.c b/src/p_user.c index c9712048e..669ab0ef4 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4436,40 +4436,39 @@ DoABarrelRoll (player_t *player) player->tilt = slope; } -#define SPINOUTROTSPEED (24 * FRACUNIT) -#define MAXSPINROT (360 * FRACUNIT) - -static void P_DoFunnyDance (player_t *player) +// mhhm this is definitely not mostly copy pasted code from SRB2s music test (: +// TODO: make this sane lmao +static void P_DoFunnyDance(player_t *player) { - static tic_t time = 0; - fixed_t bounce; - fixed_t work, bpm; - angle_t ang; + fixed_t bpm; if (player->spectator || !player->mo || player->kartstuff[k_respawn] || player->mo->salty_jump) // this looks jank as hell during hop return; - bounce = 0; + player->squishdance.bounce = 0; // bpm = FLOAT_TO_FIXED(mapmusic.bpm) << maybe can get the tempo and beat detection lib to work for bpm autodetection bpm = FixedDiv((60*TICRATE)<squishdance.work = (player->squishdance.time << FRACBITS) % bpm; - if (time >= (FRACUNIT>>1)) // prevent overflow jump - takes about 15 minutes - time = (work>>FRACBITS); + if (player->squishdance.time >= (FRACUNIT>>1)) // prevent overflow jump - takes about 15 minutes + player->squishdance.time = (player->squishdance.work>>FRACBITS); - work = FixedDiv(work*180, bpm); + player->squishdance.work = FixedDiv(player->squishdance.work*180, bpm); - ang = (FixedAngle(work)>>ANGLETOFINESHIFT) & FINEMASK; - bounce = (FINESINE(ang) - FRACUNIT/2); + player->squishdance.ang = ((FixedAngle(player->squishdance.work)>>ANGLETOFINESHIFT) & FINEMASK); + player->squishdance.bounce = (FINESINE(player->squishdance.ang) - FRACUNIT/2); - player->mo->spritexscale -= bounce/2; - player->mo->spriteyscale += bounce/2; + player->mo->spritexscale -= player->squishdance.bounce/2; + player->mo->spriteyscale += player->squishdance.bounce/2; - time++; // bruh + player->squishdance.time++; } +#define SPINOUTROTSPEED (24 * FRACUNIT) +#define MAXSPINROT (360 * FRACUNIT) + // // P_PlayerThink // @@ -5009,13 +5008,16 @@ void P_PlayerThink(player_t *player) if (cv_squishdance.value && (cmd->buttons & BT_CUSTOM3)) { - player->dancetime++; + player->squishdance.countdown++; - if (player->dancetime > TICRATE*2) + if (player->squishdance.countdown > TICRATE*2) P_DoFunnyDance(player); } else - player->dancetime = 0; + { + player->squishdance.countdown = 0; + player->squishdance.time = 0; + } // Flash player after being hit. if (!(player->kartstuff[k_hyudorotimer] // SRB2kart - fixes Hyudoro not flashing when it should. From 9c8aee1befb6e3ba5b396134160558776885b3cf Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 27 Apr 2025 00:57:43 +0200 Subject: [PATCH 326/350] tiny optimization we dont need to recalc the bpm stuff we can also divide the bounce in half just once --- src/p_user.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 669ab0ef4..31e6a52ef 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4440,28 +4440,27 @@ DoABarrelRoll (player_t *player) // TODO: make this sane lmao static void P_DoFunnyDance(player_t *player) { - fixed_t bpm; + static const fixed_t bpm = 983040; // 140bpm ish if (player->spectator || !player->mo || player->kartstuff[k_respawn] || player->mo->salty_jump) // this looks jank as hell during hop return; player->squishdance.bounce = 0; - // bpm = FLOAT_TO_FIXED(mapmusic.bpm) << maybe can get the tempo and beat detection lib to work for bpm autodetection - bpm = FixedDiv((60*TICRATE)<squishdance.work = (player->squishdance.time << FRACBITS) % bpm; - if (player->squishdance.time >= (FRACUNIT>>1)) // prevent overflow jump - takes about 15 minutes - player->squishdance.time = (player->squishdance.work>>FRACBITS); + if (player->squishdance.time >= (FRACUNIT >> 1)) // prevent overflow jump - takes about 15 minutes + player->squishdance.time = (player->squishdance.work >> FRACBITS); player->squishdance.work = FixedDiv(player->squishdance.work*180, bpm); - player->squishdance.ang = ((FixedAngle(player->squishdance.work)>>ANGLETOFINESHIFT) & FINEMASK); - player->squishdance.bounce = (FINESINE(player->squishdance.ang) - FRACUNIT/2); + player->squishdance.ang = ((FixedAngle(player->squishdance.work) >> ANGLETOFINESHIFT) & FINEMASK); + player->squishdance.bounce = ((FINESINE(player->squishdance.ang) - FRACUNIT/2) / 2); - player->mo->spritexscale -= player->squishdance.bounce/2; - player->mo->spriteyscale += player->squishdance.bounce/2; + player->mo->spritexscale -= player->squishdance.bounce; + player->mo->spriteyscale += player->squishdance.bounce; player->squishdance.time++; } From b960e3d84879714526ca0200688cbb7829cdfe9a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 27 Apr 2025 13:14:52 +0200 Subject: [PATCH 327/350] fix replay ghost double free kinda rare, but may happen when you resynch on the exact same time you got hit by something --- src/g_game.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 77257a6fb..0712a49e5 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4833,6 +4833,7 @@ void G_GhostAddThok(INT32 playernum) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + ghostext[playernum].flags = (ghostext[playernum].flags & ~EZT_THOKMASK) | EZT_THOK; } @@ -4840,6 +4841,7 @@ void G_GhostAddSpin(INT32 playernum) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + ghostext[playernum].flags = (ghostext[playernum].flags & ~EZT_THOKMASK) | EZT_SPIN; } @@ -4847,6 +4849,7 @@ void G_GhostAddRev(INT32 playernum) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + ghostext[playernum].flags = (ghostext[playernum].flags & ~EZT_THOKMASK) | EZT_REV; } @@ -4854,6 +4857,7 @@ void G_GhostAddFlip(INT32 playernum) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + ghostext[playernum].flags |= EZT_FLIP; } @@ -4861,11 +4865,13 @@ void G_GhostAddColor(INT32 playernum, ghostcolor_t color) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + if (ghostext[playernum].lastcolor == (UINT8)color) { ghostext[playernum].flags &= ~EZT_COLOR; return; } + ghostext[playernum].flags |= EZT_COLOR; ghostext[playernum].color = (UINT8)color; } @@ -4874,11 +4880,13 @@ void G_GhostAddScale(INT32 playernum, fixed_t scale) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + if (ghostext[playernum].lastscale == scale) { ghostext[playernum].flags &= ~EZT_SCALE; return; } + ghostext[playernum].flags |= EZT_SCALE; ghostext[playernum].scale = scale; } @@ -4887,9 +4895,10 @@ void G_GhostAddHit(INT32 playernum, mobj_t *victim) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + ghostext[playernum].flags |= EZT_HIT; ghostext[playernum].hits++; - ghostext[playernum].hitlist = Z_Realloc(ghostext[playernum].hitlist, ghostext[playernum].hits * sizeof(mobj_t *), PU_LEVEL, NULL); + ghostext[playernum].hitlist = Z_Realloc(ghostext[playernum].hitlist, ghostext[playernum].hits * sizeof(mobj_t *), PU_LEVEL, &ghostext[playernum].hitlist); P_SetTarget(ghostext[playernum].hitlist + (ghostext[playernum].hits-1), victim); } @@ -4909,7 +4918,7 @@ void G_WriteAllGhostTics(void) if (!playeringame[i] || players[i].spectator) continue; - if (!players[i].mo) + if (P_MobjWasRemoved(players[i].mo)) continue; counter++; @@ -4993,6 +5002,7 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) // Store one full byte of movement, plus one byte of fractional movement. INT16 momx = (INT16)((ghost->x-oldghost[playernum].x + (1<<4))>>8); INT16 momy = (INT16)((ghost->y-oldghost[playernum].y + (1<<4))>>8); + if (momx != oldghost[playernum].momx || momy != oldghost[playernum].momy) { @@ -5005,7 +5015,9 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) WRITEINT16(demobuf.p,momx); WRITEINT16(demobuf.p,momy); } + momx = (INT16)((ghost->z-oldghost[playernum].z + (1<<4))>>8); + if (momx != oldghost[playernum].momz) { oldghost[playernum].momz = momx; @@ -5077,6 +5089,7 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) if (ghostext[playernum].color == ghostext[playernum].lastcolor) ghostext[playernum].flags &= ~EZT_COLOR; + if (ghostext[playernum].scale == ghostext[playernum].lastscale) ghostext[playernum].flags &= ~EZT_SCALE; @@ -5091,16 +5104,19 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) WRITEUINT8(demobuf.p,ghostext[playernum].color); ghostext[playernum].lastcolor = ghostext[playernum].color; } + if (ghostext[playernum].flags & EZT_SCALE) { CHECKSPACE(sizeof(fixed_t)); WRITEFIXED(demobuf.p,ghostext[playernum].scale); ghostext[playernum].lastscale = ghostext[playernum].scale; } + if (ghostext[playernum].flags & EZT_HIT) { CHECKSPACE(2); WRITEUINT16(demobuf.p,ghostext[playernum].hits); + for (i = 0; i < ghostext[playernum].hits; i++) { mobj_t *mo = ghostext[playernum].hitlist[i]; @@ -5116,23 +5132,24 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) WRITEANGLE(demobuf.p,mo->angle); P_SetTarget(ghostext[playernum].hitlist+i, NULL); } - Z_Free(ghostext[playernum].hitlist); + ghostext[playernum].hits = 0; - ghostext[playernum].hitlist = NULL; } + if (ghostext[playernum].flags & EZT_SPRITE) { CHECKSPACE(1); WRITEUINT8(demobuf.p,sprite); } + if (ghostext[playernum].flags & EZT_KART) { CHECKSPACE(12); - WRITEINT32(demobuf.p, ghostext[playernum].kartitem); WRITEINT32(demobuf.p, ghostext[playernum].kartamount); WRITEINT32(demobuf.p, ghostext[playernum].kartbumpers); } + ghostext[playernum].flags = 0; } @@ -5180,6 +5197,7 @@ void G_ConsGhostTic(INT32 playernum) // Grab ghost data. ziptic = READUINT8(demobuf.p); + if (ziptic & GZT_XYZ) { oldghost[playernum].x = READFIXED(demobuf.p); @@ -5194,17 +5212,22 @@ void G_ConsGhostTic(INT32 playernum) oldghost[playernum].momx = READINT16(demobuf.p)<<8; oldghost[playernum].momy = READINT16(demobuf.p)<<8; } + if (ziptic & GZT_MOMZ) oldghost[playernum].momz = READINT16(demobuf.p)<<8; + oldghost[playernum].x += oldghost[playernum].momx; oldghost[playernum].y += oldghost[playernum].momy; oldghost[playernum].z += oldghost[playernum].momz; syncleeway = FRACUNIT; } + if (ziptic & GZT_ANGLE) demobuf.p++; + if (ziptic & GZT_SPRITE) demobuf.p++; + if (ziptic & GZT_NIGHTS) { if (!testmo || !testmo->player || !(testmo->player->pflags & PF_NIGHTSMODE) || !testmo->tracer) @@ -5218,8 +5241,10 @@ void G_ConsGhostTic(INT32 playernum) ziptic = READUINT8(demobuf.p); if (ziptic & EZT_COLOR) demobuf.p++; + if (ziptic & EZT_SCALE) demobuf.p += sizeof(fixed_t); + if (ziptic & EZT_HIT) { // Resync mob damage. UINT16 i, count = READUINT16(demobuf.p); @@ -5252,6 +5277,7 @@ void G_ConsGhostTic(INT32 playernum) break; mobj = NULL; // wasn't this one, keep searching. } + if (mobj && mobj->health != health) // Wasn't damaged?! This is desync! Fix it! { if (demosynced) @@ -5259,13 +5285,16 @@ void G_ConsGhostTic(INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (health)!\n")); CONS_Printf("expected health %d got %d\n", health, mobj->health); } + demosynced = false; P_DamageMobj(mobj, players[0].mo, players[0].mo, 1); } } } + if (ziptic & EZT_SPRITE) demobuf.p++; + if (ziptic & EZT_KART) { ghostext[playernum].kartitem = READINT32(demobuf.p); From 4f81349ea38d6eec35f038f64655674d079e80a7 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 28 Apr 2025 09:55:10 +0200 Subject: [PATCH 328/350] another tiny cleanup p_setup and p_saveg --- src/p_saveg.c | 18 +-- src/p_setup.c | 429 ++++++++++++++++++++++---------------------------- src/p_setup.h | 2 +- 3 files changed, 196 insertions(+), 253 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index c63887b69..c875272bd 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1009,13 +1009,13 @@ static inline UINT32 SaveMobjnum(const mobj_t *mobj) return 0; } -static UINT32 SaveSector(const sector_t *sector) +static inline UINT32 SaveSector(const sector_t *sector) { if (sector) return (UINT32)(sector - sectors); return 0xFFFFFFFF; } -static UINT32 SaveLine(const line_t *line) +static inline UINT32 SaveLine(const line_t *line) { if (line) return (UINT32)(line - lines); return 0xFFFFFFFF; @@ -1040,11 +1040,7 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8 UINT16 diff2; // Ignore stationary hoops - these will be respawned from mapthings. - if (mobj->type == MT_HOOP) - return; - - // These are NEVER saved. - if (mobj->type == MT_HOOPCOLLIDE) + if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE) // These are NEVER saved. return; // This hoop has already been collected. @@ -1905,13 +1901,13 @@ static inline mobj_t *LoadMobj(UINT32 mobjnum) return (mobj_t *)(size_t)mobjnum; } -static sector_t *LoadSector(UINT32 sector) +static inline sector_t *LoadSector(UINT32 sector) { if (sector >= numsectors) return NULL; return §ors[sector]; } -static line_t *LoadLine(UINT32 line) +static inline line_t *LoadLine(UINT32 line) { if (line >= numlines) return NULL; return &lines[line]; @@ -3022,7 +3018,7 @@ static void P_RelinkPointers(void) mobj = (mobj_t *)currentthinker; - if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) + if (UNLIKELY(mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER)) continue; #define RELINK(obj, name) if ((obj) && !RelinkMobj(&(obj))) \ @@ -3439,7 +3435,7 @@ void P_SaveNetGame(savebuffer_t *save, boolean resending) mobj = (mobj_t *)th; - if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) + if (UNLIKELY(mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER)) continue; mobj->mobjnum = i++; diff --git a/src/p_setup.c b/src/p_setup.c index 1ef81c3cb..973d37f82 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -357,6 +357,7 @@ void P_AllocMapHeader(INT16 i) mapheaderinfo[i] = Z_Malloc(sizeof(mapheader_t), PU_STATIC, NULL); mapheaderinfo[i]->grades = NULL; } + P_ClearSingleMapHeaderInfo(i + 1); } @@ -434,8 +435,10 @@ UINT8 P_GetGrade(UINT32 pscore, INT16 map, UINT8 mare) if (pscore >= mapheaderinfo[map-1]->grades[mare].grade[i]) ++pgrade; } + return (UINT8)pgrade; } + return 0; } @@ -443,10 +446,8 @@ UINT8 P_HasGrades(INT16 map, UINT8 mare) { // Determining the grade // Mare 0 is treated as overall and is true if ANY grades exist - if (mapheaderinfo[map-1] && mapheaderinfo[map-1]->grades - && (mare == 0 || mapheaderinfo[map-1]->numGradedMares >= mare)) - return true; - return false; + return (mapheaderinfo[map-1] && mapheaderinfo[map-1]->grades + && (mare == 0 || mapheaderinfo[map-1]->numGradedMares >= mare)); } UINT32 P_GetScoreForGrade(INT16 map, UINT8 mare, UINT8 grade) @@ -796,7 +797,7 @@ INT32 P_AddLevelFlatRuntime(const char *flatname) // first scan through the already found flats // for (i = 0; i < numlevelflats; i++, levelflat++) - if (strnicmp(levelflat->name,flatname,8)==0) + if (strnicmp(levelflat->name, flatname, 8) == 0) break; // that flat was already found in the level, return the id @@ -837,7 +838,7 @@ INT32 P_CheckLevelFlat(const char *flatname) // scan through the already found flats // for (i = 0; i < numlevelflats; i++, levelflat++) - if (strnicmp(levelflat->name,flatname,8)==0) + if (strnicmp(levelflat->name, flatname, 8) == 0) break; if (i == numlevelflats) @@ -1351,10 +1352,180 @@ static void P_LoadLineDefs2(void) } } +static void P_LoadSideColormaps(mapsidedef_t *msd, side_t *sd, sector_t *sec) +{ + INT32 num; + +#ifdef HWRENDER + if (rendermode == render_opengl) + { + // for now, full support of toptexture only + if ((msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) + || (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6])) + { + char *col; + RGBA_t color; + size_t j; + + sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, + msd->bottomtexture); + sd->toptexture = sd->bottomtexture = 0; +#define HEX2INT(x) (x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) +#define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) + sec->extra_colormap = &extra_colormaps[sec->midmap]; + + if (msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) + { + col = msd->toptexture; + + // encore mode colormaps! + // do it like software by aproximating a color to a palette index, and then convert it to its encore variant and then back to a color code. + // do this for both the start and fade colormaps. + + color.s.red = (HEX2INT(col[1]) << 4) + HEX2INT(col[2]); + color.s.green = (HEX2INT(col[3]) << 4) + HEX2INT(col[4]); + color.s.blue = (HEX2INT(col[5]) << 4) + HEX2INT(col[6]); + +#ifdef GLENCORE + if (encoremap) + { + j = encoremap[NearestColor(color.s.red, color.s.green, color.s.blue)]; + color = pLocalPalette[j]; // note: this sets alpha to 255, we will reset it below + } +#endif + color.s.alpha = 0; // reset/init the alpha, so the addition below will work correctly + sec->extra_colormap->rgba = color.rgba; + + // alpha + if (msd->toptexture[7]) + sec->extra_colormap->rgba += (ALPHA2INT(col[7]) << 24); + else + sec->extra_colormap->rgba += (25 << 24); + } + else + sec->extra_colormap->rgba = 0; + + if (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]) + { + col = msd->bottomtexture; + + // do the exact same thing as above here. + + color.s.red = (HEX2INT(col[1]) << 4) + HEX2INT(col[2]); + color.s.green = (HEX2INT(col[3]) << 4) + HEX2INT(col[4]); + color.s.blue = (HEX2INT(col[5]) << 4) + HEX2INT(col[6]); + +#ifdef GLENCORE + if (encoremap) + { + j = encoremap[NearestColor(color.s.red, color.s.green, color.s.blue)]; + color = pLocalPalette[j]; // note: this sets alpha to 255, we will reset it below + } +#endif + color.s.alpha = 0; // reset/init the alpha, so the addition below will work correctly + sec->extra_colormap->fadergba = color.rgba; + + // alpha + if (msd->bottomtexture[7]) + sec->extra_colormap->fadergba += (ALPHA2INT(col[7]) << 24); + else + sec->extra_colormap->fadergba += (25 << 24); + } + else + sec->extra_colormap->fadergba = 0x19000000; // default alpha, (25 << 24) +#undef ALPHA2INT +#undef HEX2INT + } + else + { + if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) + sd->toptexture = 0; + else + sd->toptexture = num; + + if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) + sd->midtexture = 0; + else + sd->midtexture = num; + + if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) + sd->bottomtexture = 0; + else + sd->bottomtexture = num; + } + } +#endif +#ifdef HWRENDER + else +#endif + { + if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#') + { + sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, + msd->bottomtexture); + sd->toptexture = sd->bottomtexture = 0; + } + else + { + if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) + sd->toptexture = 0; + else + sd->toptexture = num; + if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) + sd->midtexture = 0; + else + sd->midtexture = num; + if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) + sd->bottomtexture = 0; + else + sd->bottomtexture = num; + } + } +} + +static void P_LoadSideChangeMusic(boolean firstside, mapsidedef_t *msd, side_t *sd) +{ + char process[8+1]; + + sd->toptexture = sd->midtexture = sd->bottomtexture = 0; + + if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') + { + M_Memcpy(process,msd->bottomtexture,8); + process[8] = '\0'; + sd->bottomtexture = get_number(process); + } + + if (!(msd->midtexture[0] == '-' && msd->midtexture[1] == '\0') || msd->midtexture[1] != '\0') + { + M_Memcpy(process,msd->midtexture,8); + process[8] = '\0'; + sd->midtexture = get_number(process); + } + + // always process if back sidedef, because we need that - symbol + sd->text = Z_Malloc(7, PU_LEVEL, NULL); + + if (firstside || msd->toptexture[0] != '-' || msd->toptexture[1] != '\0') + { + M_Memcpy(process,msd->toptexture,8); + process[8] = '\0'; + + // If they type in O_ or D_ and their music name, just shrug, + // then copy the rest instead. + if ((process[0] == 'O' || process[0] == 'D') && process[7]) + M_Memcpy(sd->text, process+2, 6); + else // Assume it's a proper music name. + M_Memcpy(sd->text, process, 6); + sd->text[6] = 0; + } + else + sd->text[0] = 0; +} + static void P_LoadRawSideDefs2(void *data) { UINT16 i; - INT32 num; for (i = 0; i < numsides; i++) { @@ -1388,186 +1559,11 @@ static void P_LoadRawSideDefs2(void *data) case 606: //SoM: 4/4/2000: Just colormap transfer // SoM: R_CreateColormap will only create a colormap in software mode... // Perhaps we should just call it instead of doing the calculations here. -#ifdef HWRENDER - if (rendermode != render_opengl) -#endif - { - if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#') - { - sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, - msd->bottomtexture); - sd->toptexture = sd->bottomtexture = 0; - } - else - { - if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) - sd->toptexture = 0; - else - sd->toptexture = num; - if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) - sd->midtexture = 0; - else - sd->midtexture = num; - if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) - sd->bottomtexture = 0; - else - sd->bottomtexture = num; - } - break; - } -#ifdef HWRENDER - else - { - // for now, full support of toptexture only - if ((msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) - || (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6])) - { - char *col; - RGBA_t color; - size_t j; - - sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, - msd->bottomtexture); - sd->toptexture = sd->bottomtexture = 0; -#define HEX2INT(x) (x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) -#define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) - sec->extra_colormap = &extra_colormaps[sec->midmap]; - - if (msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) - { - col = msd->toptexture; - - // encore mode colormaps! - // do it like software by aproximating a color to a palette index, and then convert it to its encore variant and then back to a color code. - // do this for both the start and fade colormaps. - - color.s.red = (HEX2INT(col[1]) << 4) + HEX2INT(col[2]); - color.s.green = (HEX2INT(col[3]) << 4) + HEX2INT(col[4]); - color.s.blue = (HEX2INT(col[5]) << 4) + HEX2INT(col[6]); - -#ifdef GLENCORE - if (encoremap) - { - j = encoremap[NearestColor(color.s.red, color.s.green, color.s.blue)]; - //CONS_Printf("R_CreateColormap: encoremap[%d] = %d\n", j, encoremap[j]); -- moved encoremap upwards for optimisation - color = pLocalPalette[j]; // note: this sets alpha to 255, we will reset it below - } -#endif - color.s.alpha = 0; // reset/init the alpha, so the addition below will work correctly - sec->extra_colormap->rgba = color.rgba; - - // alpha - if (msd->toptexture[7]) - sec->extra_colormap->rgba += (ALPHA2INT(col[7]) << 24); - else - sec->extra_colormap->rgba += (25 << 24); - - /*nearest = NearestColor( - (HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0), - (HEX2INT(col[3]) << 4) + (HEX2INT(col[4]) << 0), - (HEX2INT(col[5]) << 4) + (HEX2INT(col[6]) << 0) - ); - - sec->extra_colormap->rgba = - pLocalPalette[nearest].s.red + - (pLocalPalette[nearest].s.green << 8) + - (pLocalPalette[nearest].s.blue << 16);*/ - } - else - sec->extra_colormap->rgba = 0; - - if (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]) - { - col = msd->bottomtexture; - - // do the exact same thing as above here. - - color.s.red = (HEX2INT(col[1]) << 4) + HEX2INT(col[2]); - color.s.green = (HEX2INT(col[3]) << 4) + HEX2INT(col[4]); - color.s.blue = (HEX2INT(col[5]) << 4) + HEX2INT(col[6]); - -#ifdef GLENCORE - if (encoremap) - { - j = encoremap[NearestColor(color.s.red, color.s.green, color.s.blue)]; - //CONS_Printf("R_CreateColormap: encoremap[%d] = %d\n", j, encoremap[j]); -- moved encoremap upwards for optimisation - color = pLocalPalette[j]; // note: this sets alpha to 255, we will reset it below - } -#endif - color.s.alpha = 0; // reset/init the alpha, so the addition below will work correctly - sec->extra_colormap->fadergba = color.rgba; - - // alpha - if (msd->bottomtexture[7]) - sec->extra_colormap->fadergba += (ALPHA2INT(col[7]) << 24); - else - sec->extra_colormap->fadergba += (25 << 24); - } - else - sec->extra_colormap->fadergba = 0x19000000; // default alpha, (25 << 24) -#undef ALPHA2INT -#undef HEX2INT - } - else - { - if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) - sd->toptexture = 0; - else - sd->toptexture = num; - - if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) - sd->midtexture = 0; - else - sd->midtexture = num; - - if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) - sd->bottomtexture = 0; - else - sd->bottomtexture = num; - } - break; - } -#endif - + P_LoadSideColormaps(msd, sd, sec); + break; case 413: // Change music - { - char process[8+1]; - - sd->toptexture = sd->midtexture = sd->bottomtexture = 0; - if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') - { - M_Memcpy(process,msd->bottomtexture,8); - process[8] = '\0'; - sd->bottomtexture = get_number(process); - } - - if (!(msd->midtexture[0] == '-' && msd->midtexture[1] == '\0') || msd->midtexture[1] != '\0') - { - M_Memcpy(process,msd->midtexture,8); - process[8] = '\0'; - sd->midtexture = get_number(process); - } - - // always process if back sidedef, because we need that - symbol - sd->text = Z_Malloc(7, PU_LEVEL, NULL); - if (i == 1 || msd->toptexture[0] != '-' || msd->toptexture[1] != '\0') - { - M_Memcpy(process,msd->toptexture,8); - process[8] = '\0'; - - // If they type in O_ or D_ and their music name, just shrug, - // then copy the rest instead. - if ((process[0] == 'O' || process[0] == 'D') && process[7]) - M_Memcpy(sd->text, process+2, 6); - else // Assume it's a proper music name. - M_Memcpy(sd->text, process, 6); - sd->text[6] = 0; - } - else - sd->text[0] = 0; + P_LoadSideChangeMusic((i == 1), msd, sd); break; - } - case 4: // Speed pad parameters case 414: // Play SFX { @@ -1581,7 +1577,6 @@ static void P_LoadRawSideDefs2(void *data) } break; } - case 9: // Mace parameters case 14: // Bustable block parameters case 15: // Fan particle spawner parameters @@ -1601,9 +1596,9 @@ static void P_LoadRawSideDefs2(void *data) if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') M_Memcpy(process+strlen(process), msd->bottomtexture, 8); sd->toptexture = get_number(process); + break; } - case 443: // Calls a named Lua function { char process[8*3+1]; @@ -1619,9 +1614,9 @@ static void P_LoadRawSideDefs2(void *data) M_Memcpy(process+strlen(process), msd->bottomtexture, 8); sd->text = Z_Malloc(strlen(process)+1, PU_LEVEL, NULL); M_Memcpy(sd->text, process, strlen(process)+1); + break; } - default: // normal cases if (msd->toptexture[0] == '#') { @@ -1641,6 +1636,7 @@ static void P_LoadRawSideDefs2(void *data) break; } } + R_ClearTextureNumCache(true); } @@ -2317,6 +2313,7 @@ static void P_LevelInitStuff(boolean reloadinggamestate) gamespeed = 0; else gamespeed = (UINT8)cv_kartspeed.value; + franticitems = (boolean)cv_kartfrantic.value; comeback = (boolean)cv_kartcomeback.value; } @@ -2325,43 +2322,6 @@ static void P_LevelInitStuff(boolean reloadinggamestate) battlewanted[i] = -1; } -// -// P_LoadThingsOnly -// -// "Reloads" a level, but only reloads all of the mobjs. -// -void P_LoadThingsOnly(void) -{ - // Search through all the thinkers. - mobj_t *mo; - thinker_t *think; - - virtres_t* virt = vres_GetMap(lastloadedmaplumpnum); - virtlump_t* vth = vres_Find(virt, "THINGS"); - - for (think = thinkercap.next; think != &thinkercap; think = think->next) - { - if (think->function.acp1 != (actionf_p1)P_MobjThinker) - continue; // not a mobj thinker - - mo = (mobj_t *)think; - - if (mo) - P_RemoveMobj(mo); - } - - P_LevelInitStuff(false); - - memset(localaiming, 0, sizeof(localaiming)); - - P_PrepareRawThings(vth->data); - P_LoadThings(); - - vres_Free(virt); - - P_SpawnSecretItems(true); -} - /** Compute MD5 message digest for bytes read from memory source * * The resulting message digest number will be written into the 16 bytes @@ -2672,11 +2632,6 @@ static void P_InitCamera(void) displayplayers[0] = consoleplayer; // Start with your OWN view, please! } -static boolean P_CanSave(void) -{ - return false; // SRB2Kart: no SP, no saving. -} - struct minimapinfo minimapinfo; static void P_InitMinimapInfo(void) { @@ -2824,13 +2779,7 @@ static void P_SetupPlayer(void) else // gametype is GT_COOP or GT_RACE { players[i].mo = NULL; - - if (players[i].starposttime) - { - G_SpawnPlayer(i, true); - } - else - G_SpawnPlayer(i, false); + G_SpawnPlayer(i, (players[i].starposttime)); } } } @@ -3169,9 +3118,6 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) P_RunCachedActions(); - if (P_CanSave()) - G_SaveGame((UINT32)cursaveslot); - if (savedata.lives > 0) { players[consoleplayer].continues = savedata.continues; @@ -3276,7 +3222,8 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), wadfilename); return UINT16_MAX; } - else wadnum = (UINT16)(numwadfiles-1); + + wadnum = (UINT16)(numwadfiles-1); if (wadfiles[wadnum]->important) partadd_important = true; diff --git a/src/p_setup.h b/src/p_setup.h index f0ae13e6c..47a9ea85b 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -60,8 +60,8 @@ extern size_t nummapthings; extern mapthing_t *mapthings; void P_SetupLevelSky(INT32 skynum, boolean global); -void P_LoadThingsOnly(void); boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate); + #ifdef HWRENDER void HWR_LoadLevel(void); #endif From e138d540c84efe7b562d2d800c6d7489dcda8760 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 28 Apr 2025 11:21:24 +0200 Subject: [PATCH 329/350] skip rechecking for horizonlines when reloading gamestate map remains the same during desynch, so safe some time --- src/hardware/hw_main.c | 5 +++-- src/p_setup.c | 5 ++--- src/p_setup.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 096e738c6..76313eb6d 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5690,7 +5690,7 @@ static void HWR_CheckForHorizonLines(void) } } -void HWR_LoadLevel(void) +void HWR_LoadLevel(boolean reloadinggamestate) { // Lactozilla (December 8, 2019) // Level setup used to free EVERY mipmap from memory. @@ -5709,7 +5709,8 @@ void HWR_LoadLevel(void) HWR_ClearSkyDome(); HWR_BuildSkyDome(); - HWR_CheckForHorizonLines(); + if (!reloadinggamestate) + HWR_CheckForHorizonLines(); if (HWR_ShouldUsePaletteRendering()) HWR_SetMapPalette(); diff --git a/src/p_setup.c b/src/p_setup.c index 973d37f82..399276474 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3073,9 +3073,8 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) if (rendermode == render_opengl) { HWR_FreeExtraSubsectors(); - - // stuff like HWR_CreatePlanePolygons is called there - HWR_LoadLevel(); + // Create plane polygons. + HWR_LoadLevel(reloadinggamestate); } #endif diff --git a/src/p_setup.h b/src/p_setup.h index 47a9ea85b..97209e154 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -63,7 +63,7 @@ void P_SetupLevelSky(INT32 skynum, boolean global); boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate); #ifdef HWRENDER -void HWR_LoadLevel(void); +void HWR_LoadLevel(boolean reloadinggamestate); #endif boolean P_AddWadFile(const char *wadfilename, boolean local); From 984d501ee1ab5429ea288b0b96671fb9fad90461 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 28 Apr 2025 11:29:35 +0200 Subject: [PATCH 330/350] move doaddline block slightly better branching since maps with portals are very uncommon in kart --- src/hardware/hw_main.c | 59 +++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 76313eb6d..c485b5a77 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2357,7 +2357,35 @@ static void HWR_AddLine(seg_t *line) gl_backsector = line->backsector; if (!cv_glportals.value || LIKELY(!gl_maphasportals)) - goto doaddline; + { +doaddline: + if (!line->backsector) + { + gld_clipper_SafeAddClipRange(angle2, angle1); + } + else + { + gl_backsector = R_FakeFlat(gl_backsector, &tempsec, NULL, NULL, true); + + if (CheckClip(gl_frontsector, gl_backsector)) + { + gld_clipper_SafeAddClipRange(angle2, angle1); + checkforemptylines = false; + } + + // Reject empty lines used for triggers and special events. + // Identical floor and ceiling on both sides, + // identical light levels on both sides, + // and no middle texture. + if (checkforemptylines && R_IsEmptyLine(line, gl_frontsector, gl_backsector)) + return; + } + + if (LIKELY(gl_portal_state != GLPORTAL_SEARCH && !dont_draw))// no need to do this during the portal check + HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D + + return; + } // do extra checks on the seg when rendering portals: // don't render segs that are behind the portal destination line @@ -2393,34 +2421,7 @@ static void HWR_AddLine(seg_t *line) return;// dont do anything with the other side i guess? } -doaddline: - - if (!line->backsector) - { - gld_clipper_SafeAddClipRange(angle2, angle1); - } - else - { - gl_backsector = R_FakeFlat(gl_backsector, &tempsec, NULL, NULL, true); - - if (CheckClip(gl_frontsector, gl_backsector)) - { - gld_clipper_SafeAddClipRange(angle2, angle1); - checkforemptylines = false; - } - - // Reject empty lines used for triggers and special events. - // Identical floor and ceiling on both sides, - // identical light levels on both sides, - // and no middle texture. - if (checkforemptylines && R_IsEmptyLine(line, gl_frontsector, gl_backsector)) - return; - } - - if (LIKELY(gl_portal_state != GLPORTAL_SEARCH && !dont_draw))// no need to do this during the portal check - HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D - - return; + goto doaddline; } // HWR_CheckBBox From 79d440d398156bf4118a9ad6066b833cf262f6cc Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 28 Apr 2025 13:25:30 +0100 Subject: [PATCH 331/350] quick and dirty gcc 15 compile fix need to fix this properly --- src/dehacked.c | 4 ++++ src/info.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index f0e2583d8..a453715a7 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1414,6 +1414,9 @@ static void readhuditem(MYFILE *f, INT32 num) // IMPORTANT! // DO NOT FORGET TO SYNC THIS LIST WITH THE ACTIONNUM ENUM IN INFO.H + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wincompatible-pointer-types" actionpointer_t actionpointers[] = { {{A_Explode}, "A_EXPLODE"}, @@ -1622,6 +1625,7 @@ actionpointer_t actionpointers[] = // This NULL entry must be the last in the list {{NULL}, NULL}, }; +#pragma GCC diagnostic pop static void readframe(MYFILE *f, INT32 num) { diff --git a/src/info.c b/src/info.c index 7afc76bf6..19183de52 100644 --- a/src/info.c +++ b/src/info.c @@ -69,6 +69,8 @@ char sprnames[NUMSPRITES + 1][5] = }; // Doesn't work with g++, needs actionf_p1 (don't modify this comment) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wincompatible-pointer-types" state_t states[NUMSTATES] = { // frame is masked through FF_FRAMEMASK @@ -3410,6 +3412,7 @@ state_t states[NUMSTATES] = {SPR_NULL, 0, 1, {NULL}, 0, 0, S_NULL}, // S_NAMECHECK #endif }; +#pragma GCC diagnostic pop mobjinfo_t mobjinfo[NUMMOBJTYPES] = { From 4c1cfc91daeafccd2d8200dc261a3f5cb86eae96 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 28 Apr 2025 13:25:30 +0100 Subject: [PATCH 332/350] quick and dirty gcc 15 compile fix need to fix this properly --- src/dehacked.c | 4 ++++ src/info.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index fd90c380e..1a84108fd 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1414,6 +1414,9 @@ static void readhuditem(MYFILE *f, INT32 num) // IMPORTANT! // DO NOT FORGET TO SYNC THIS LIST WITH THE ACTIONNUM ENUM IN INFO.H + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wincompatible-pointer-types" actionpointer_t actionpointers[] = { {{A_Explode}, "A_EXPLODE"}, @@ -1622,6 +1625,7 @@ actionpointer_t actionpointers[] = // This NULL entry must be the last in the list {{NULL}, NULL}, }; +#pragma GCC diagnostic pop static void readframe(MYFILE *f, INT32 num) { diff --git a/src/info.c b/src/info.c index 7afc76bf6..19183de52 100644 --- a/src/info.c +++ b/src/info.c @@ -69,6 +69,8 @@ char sprnames[NUMSPRITES + 1][5] = }; // Doesn't work with g++, needs actionf_p1 (don't modify this comment) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wincompatible-pointer-types" state_t states[NUMSTATES] = { // frame is masked through FF_FRAMEMASK @@ -3410,6 +3412,7 @@ state_t states[NUMSTATES] = {SPR_NULL, 0, 1, {NULL}, 0, 0, S_NULL}, // S_NAMECHECK #endif }; +#pragma GCC diagnostic pop mobjinfo_t mobjinfo[NUMMOBJTYPES] = { From 7ba21abacd37bb86a7abac7cbf54016b323af3a9 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 28 Apr 2025 17:47:22 +0200 Subject: [PATCH 333/350] tiny more cleanup speedometer stuffs put check for color speedo into a function and precalc the xtra 3 scale --- src/k_kart.c | 59 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 1e2190c2f..222890332 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -230,6 +230,8 @@ static boolean K_SpeedLinesShouldBlend(player_t *player); // mapreset is set when enough players fill an empty server // nospectategrief is the players in-game needed to eliminate the person in last +#define XTRA3PSCALE 50135 //0.765 +#define XTRA3VSCALE 35344 //0.55 //{ SRB2kart Color Code @@ -774,6 +776,26 @@ static UINT8 K_GetSpeedometerStyle(void) return SPEEDO_VANILLA; } +static boolean K_UseColorSpeedo(int speedostyle) +{ + if (!K_UseColorHud()) + return false; + + switch (speedostyle) + { + case SPEEDO_EXTRA: + return xtra_speedo_clr; + case SPEEDO_ACHII: + return achi_speedo_clr; + case SPEEDO_DIAL: + return dial_speedo_clr; + case SPEEDO_EXTRA3: + return xtra_speedo_clr3; + default: + return false; + } +} + static boolean K_IsHighResolution(void) { return (vid.width >= 640 && vid.height >= 400); @@ -9739,33 +9761,33 @@ static void K_drawKartSpeedometer(void) } else if (speedostyle == SPEEDO_EXTRA) // why bother if we dont? { - if (K_UseColorHud() && xtra_speedo_clr) //Colourized hud + if (K_UseColorSpeedo(SPEEDO_EXTRA)) //Colourized hud { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawMappedPatch(SPDM_X + 1, SPDM_Y + 4, (V_HUDTRANS|splitflags), (skp_smallstickerclr), colormap); + V_DrawMappedPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallstickerclr, colormap); } else - V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, (V_HUDTRANS|splitflags), (skp_smallsticker)); + V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallsticker); V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatches[cv_kartspeedometer.value]); } else if (speedostyle == SPEEDO_ACHII) // why bother if we dont? { - if (K_UseColorHud() && achi_speedo_clr) //Colourized hud + if (K_UseColorSpeedo(SPEEDO_ACHII)) //Colourized hud { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawMappedPatch(SPDM_X + 1, SPDM_Y + 4, (V_HUDTRANS|splitflags), (skp_smallstickerachiclr), colormap); + V_DrawMappedPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallstickerachiclr, colormap); V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); V_DrawMappedPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatchesachiclr[cv_kartspeedometer.value], colormap); } else { - V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, (V_HUDTRANS|splitflags), (skp_smallstickerachi)); + V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallstickerachi); V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatchesachi[cv_kartspeedometer.value]); } - } + } #ifdef ROTSPRITE else if (speedostyle == SPEEDO_DIAL) // why bother if we dont? { @@ -9774,18 +9796,18 @@ static void K_drawKartSpeedometer(void) splitflags, (boolean)(G_BattleGametype()), (LUA_HudEnabled(hud_gametypeinfo)), - (boolean)(K_UseColorHud() && dial_speedo_clr)); + (K_UseColorSpeedo(SPEEDO_DIAL))); } #endif else if (speedostyle == SPEEDO_EXTRA3) // why bother if we dont? { - if (K_UseColorHud() && xtra_speedo_clr3) //Colourized hud + if (K_UseColorSpeedo(SPEEDO_EXTRA3)) //Colourized hud { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawStretchyFixedPatch((SPDM_X-1)< 54) || (fuspeed < 60 && fuspeed > 56) || (fuspeed > 59)) && !(leveltime & 4)) spdpatch = 23; - patch_t *patch = NULL; - - if (speedostyle == SPEEDO_PMETER) - patch = kp_kartzspeedo[spdpatch]; - else if (speedostyle == SPEEDO_PMETERSMOL) - patch = kp_kartzspeedo_smol[spdpatch]; - - V_DrawScaledPatch(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, patch); + V_DrawScaledPatch(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, (speedostyle == SPEEDO_PMETER) ? kp_kartzspeedo[spdpatch] : kp_kartzspeedo_smol[spdpatch]); } } @@ -10346,13 +10361,13 @@ skipcrap: if (usescaledpatch) // i hate hud code i hate hud code i hate hud code i hate hud code i hate hud code..... { - if (K_UseColorHud() && xtra_speedo_clr3) // Colourized hud + if (K_UseColorSpeedo(SPEEDO_EXTRA3)) // Colourized hud { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawStretchyFixedPatch((basex - dup*30)< Date: Mon, 28 Apr 2025 22:19:59 +0200 Subject: [PATCH 334/350] Reapply "disable jit compilation for now" This reverts commit a662a0a68f52ddbf8851356353570ac93fdb2f9e. --- src/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Makefile b/src/Makefile index 4c3240dd1..5754a3724 100644 --- a/src/Makefile +++ b/src/Makefile @@ -93,7 +93,10 @@ ifeq ($(OS),Windows_NT) # all windows are Windows_NT... WINDOWSHELL=1 NOOBJDUMP=1 + NOBLUAJIT=1 + else # if you on the *nix + NOBLUAJIT=1 system:=$(shell uname -s) ifeq ($(system),Linux) From 68c913a5e16dadf72fc18165f31d6bdd9c0a5b76 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 29 Apr 2025 18:22:33 +0200 Subject: [PATCH 335/350] raise cmake minimum requiered to 3.5 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ceaf65f04..b7d280190 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.5) # DO NOT CHANGE THIS SRB2 STRING! Some variable names depend on this string. # Version change is fine. project(SRB2 From 838379d970433fa25b6d981ceaec6090d11276b1 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 29 Apr 2025 18:30:23 +0200 Subject: [PATCH 336/350] we dont have this on this branch --- src/Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Makefile b/src/Makefile index 9dddfe7da..46b7993ac 100644 --- a/src/Makefile +++ b/src/Makefile @@ -93,10 +93,7 @@ ifeq ($(OS),Windows_NT) # all windows are Windows_NT... WINDOWSHELL=1 NOOBJDUMP=1 - NOBLUAJIT=1 - else # if you on the *nix - NOBLUAJIT=1 system:=$(shell uname -s) ifeq ($(system),Linux) From 431c0f41d19142ce16c2132c7576450b21fbd800 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 29 Apr 2025 21:02:56 +0200 Subject: [PATCH 337/350] raise version number so i dont forger about it later lol --- src/doomdef.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 382713b69..4c4a2a3aa 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -113,8 +113,8 @@ extern char logfilename[1024]; #else #define VERSION 1 // Game version #define SUBVERSION 6 // more precise version number -#define VERSIONSTRING "Saturn v7.2" -#define VERSIONSTRINGW L"Saturn v7.2" +#define VERSIONSTRING "Saturn v8" +#define VERSIONSTRINGW L"Saturn v8" // Hey! If you change this, add 1 to the MODVERSION below! Otherwise we can't force updates! // And change CMakeLists.txt (not src/, but in root), for CMake users! // AND appveyor.yml, for the build bots! From ebcdb23d345153ddedbb2b75a1dbcb67fc0f2dbc Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 29 Apr 2025 21:13:18 +0200 Subject: [PATCH 338/350] delet old high color software stuff --- SRB2.cbp | 5 - Srb2.dev | 10 - src/r_draw.c | 8 - src/r_draw.h | 12 - src/r_draw16.c | 214 ------------------ src/sdl/Srb2SDL.dsp | 5 - src/sdl/macosx/Srb2mac.pbproj/project.pbxproj | 7 - .../macosx/Srb2mac.xcodeproj/project.pbxproj | 2 - 8 files changed, 263 deletions(-) delete mode 100644 src/r_draw16.c diff --git a/SRB2.cbp b/SRB2.cbp index b4cf543db..e5be4f5e0 100644 --- a/SRB2.cbp +++ b/SRB2.cbp @@ -1726,11 +1726,6 @@ HW3SOUND for 3D hardware sound support