From 5fa8b225f9c0c0a2c175881964b7c97ae068d6c1 Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Wed, 21 Aug 2024 23:48:34 -0400 Subject: [PATCH 01/26] Add missing deh table entry for invis spring --- src/deh_tables.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/deh_tables.c b/src/deh_tables.c index 74b60680c..8ffe266b0 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -4551,6 +4551,7 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t "MT_REDSPRING", "MT_BLUESPRING", "MT_GREYSPRING", + "MT_INVISSPRING", "MT_POGOSPRING", "MT_YELLOWDIAG", // Yellow Diagonal Spring "MT_REDDIAG", // Red Diagonal Spring From b239a6fe07ee8910a9bbee260780770cda0d4bc0 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sun, 31 Jul 2022 15:12:59 +0200 Subject: [PATCH 02/26] Fix equation slopes overflow --- src/p_slopes.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index 6b4589261..7af264169 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -200,10 +200,14 @@ void P_ReconfigureViaVertexes (pslope_t *slope, const vector3_t v1, const vector static void ReconfigureViaConstants (pslope_t *slope, const fixed_t a, const fixed_t b, const fixed_t c, const fixed_t d) { fixed_t m; + fixed_t o = 0; vector3_t *normal = &slope->normal; + if (c) + o = abs(c) <= FRACUNIT ? -FixedMul(d, FixedDiv(FRACUNIT, c)) : -FixedDiv(d, c); + // Set origin. - FV3_Load(&slope->o, 0, 0, c ? -FixedDiv(d, c) : 0); + FV3_Load(&slope->o, 0, 0, o); // Get slope's normal. FV3_Load(normal, a, b, c); From 18047b6f2386ba45e5d8f6784b6cfe38d478ead1 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 23 Apr 2023 14:47:47 -0400 Subject: [PATCH 03/26] Move camera Z slightly faster RR has more & taller slopes than SRB2K, so the old values were a bit jarring (you go off-screen a LOT more often) --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index a776771ec..bdf382a55 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3570,7 +3570,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { thiscam->momx = x - thiscam->x; thiscam->momy = y - thiscam->y; - thiscam->momz = FixedMul(z - thiscam->z, camspeed/2); + thiscam->momz = FixedMul(z - thiscam->z, camspeed*3/5); } thiscam->pan = pan; From 0ea698d662a388fdb254523e359b380408788fb5 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 23 Oct 2022 22:24:46 +0000 Subject: [PATCH 04/26] Merge branch 'fix-terrain-saveg' into 'master' Save terrainOverlay in gamestate See merge request KartKrew/Kart!735 --- src/p_saveg.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index 758d917ad..b8d5bb9fc 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2022,6 +2022,7 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) if (diff2 & MD2_TERRAIN) { WRITEUINT32(save_p, K_GetTerrainHeapIndex(mobj->terrain)); + WRITEUINT32(save_p, SaveMobjnum(mobj->terrainOverlay)); } WRITEUINT32(save_p, mobj->mobjnum); From 73db1e0fa0be8fadcd3d94db56e25bc12da4a4ab Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 5 Jan 2023 18:10:42 +0000 Subject: [PATCH 05/26] K_InitTerrain: Do what ANIMDEFs parsing does and create a copy of the TERRAIN lump with a guaranteed null terminator --- src/k_terrain.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/k_terrain.c b/src/k_terrain.c index c6558a22f..8a023ef5a 100644 --- a/src/k_terrain.c +++ b/src/k_terrain.c @@ -1625,9 +1625,9 @@ static boolean K_DoTERRAINLumpParse(size_t num, void (*parser)(size_t, char *, c Return:- false if any errors occured, otherwise true. --------------------------------------------------*/ -static boolean K_TERRAINLumpParser(UINT8 *data, size_t size) +static boolean K_TERRAINLumpParser(char *data, size_t size) { - char *tkn = M_GetToken((char *)data); + char *tkn = M_GetToken(data); UINT32 tknHash = 0; size_t pos = 0; size_t i; @@ -2022,6 +2022,7 @@ void K_InitTerrain(UINT16 wadNum) else { size_t size = W_LumpLengthPwad(wadNum, lumpNum); + char *datacopy; size_t nameLength = strlen(wadfiles[wadNum]->filename) + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name char *name = malloc(nameLength + 1); @@ -2032,7 +2033,16 @@ void K_InitTerrain(UINT16 wadNum) size = W_LumpLengthPwad(wadNum, lumpNum); CONS_Printf(M_GetText("Loading TERRAIN from %s\n"), name); - K_TERRAINLumpParser(data, size); + + datacopy = (char *)Z_Malloc((size+1)*sizeof(char),PU_STATIC,NULL); + memmove(datacopy,data,size); + datacopy[size] = '\0'; + + Z_Free(data); + + K_TERRAINLumpParser(datacopy, size); + + Z_Free(datacopy); free(name); } From 000949727424c9ef0bd055ae9f091f0aae2042bf Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 5 Jan 2023 20:50:13 +0000 Subject: [PATCH 06/26] K_InitBrightmapsPwad: Also use guaranteed null-terminated data copy ala K_InitTerrain --- src/k_brightmap.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/k_brightmap.c b/src/k_brightmap.c index a70d7a955..5b9963426 100644 --- a/src/k_brightmap.c +++ b/src/k_brightmap.c @@ -86,7 +86,7 @@ static brightmapStorage_t *K_GetBrightmapStorageByTextureName(const char *checkN } /*-------------------------------------------------- - static boolean K_BRIGHTLumpParser(UINT8 *data, size_t size) + static boolean K_BRIGHTLumpParser(char *data, size_t size) Parses inputted lump data as a BRIGHT lump. @@ -97,7 +97,7 @@ static brightmapStorage_t *K_GetBrightmapStorageByTextureName(const char *checkN Return:- false if any errors occured, otherwise true. --------------------------------------------------*/ -static boolean K_BRIGHTLumpParser(UINT8 *data, size_t size) +static boolean K_BRIGHTLumpParser(char *data, size_t size) { char *tkn = M_GetToken((char *)data); size_t pos = 0; @@ -188,6 +188,7 @@ void K_InitBrightmapsPwad(INT32 wadNum) { lumpinfo_t *lump_p = &wadfiles[wadNum]->lumpinfo[lumpNum]; size_t size = W_LumpLengthPwad(wadNum, lumpNum); + char *datacopy; size_t nameLength = strlen(wadfiles[wadNum]->filename) + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name char *name = malloc(nameLength + 1); @@ -198,10 +199,18 @@ void K_InitBrightmapsPwad(INT32 wadNum) size = W_LumpLengthPwad(wadNum, lumpNum); CONS_Printf(M_GetText("Loading BRIGHT from %s\n"), name); - K_BRIGHTLumpParser(data, size); + + datacopy = (char *)Z_Malloc((size+1)*sizeof(char),PU_STATIC,NULL); + memmove(datacopy,data,size); + datacopy[size] = '\0'; + + Z_Free(data); + + K_BRIGHTLumpParser(datacopy, size); + + Z_Free(datacopy); free(name); - Z_Free(data); } lumpNum = W_CheckNumForNamePwad("BRIGHT", (UINT16)wadNum, lumpNum + 1); From c234c6d093ac661e3eca835b8108fed5590f6f87 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 5 Jan 2023 19:19:39 -0800 Subject: [PATCH 07/26] Remove non TERRAIN offroad particles Fixes spectators generating offroad particles when touching the ground. --- src/k_terrain.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/k_terrain.c b/src/k_terrain.c index 8a023ef5a..0e986469f 100644 --- a/src/k_terrain.c +++ b/src/k_terrain.c @@ -879,26 +879,13 @@ void K_HandleFootstepParticles(mobj_t *mo) return; } - if (!(mo->flags & MF_APPLYTERRAIN)) + if (!(mo->flags & MF_APPLYTERRAIN) || mo->terrain == NULL) { // No TERRAIN effects for this object. return; } - if (mo->terrain == NULL || mo->terrain->footstepID == SIZE_MAX) - { - // If no terrain, check for offroad. - // If we're in offroad, use the default particle. - - if (mo->player != NULL && mo->player->boostpower < FRACUNIT) - { - fs = K_GetFootstepByIndex(defaultOffroadFootstep); - } - } - else - { - fs = K_GetFootstepByIndex(mo->terrain->footstepID); - } + fs = K_GetFootstepByIndex(mo->terrain->footstepID); if (fs == NULL || fs->mobjType == MT_NULL || fs->frequency <= 0) { From 6b087c30781c6cc875ab84852c96e886f06d78f8 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 19 Mar 2023 22:40:43 -0700 Subject: [PATCH 08/26] Reset TERRAIN when respawning Fixes damage floor TERRAIN applying for the entire duration of lightsnake. --- src/p_mobj.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index d32674a0a..1fced3907 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3726,6 +3726,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) P_CheckPosition(mobj, mobj->x, mobj->y); mobj->floorz = tmfloorz; mobj->ceilingz = tmceilingz; + mobj->terrain = NULL; goto animonly; } From a3f643bfd79c307de1c5b6d3417ced5446c9310a Mon Sep 17 00:00:00 2001 From: Oni Date: Mon, 1 May 2023 19:33:02 +0000 Subject: [PATCH 09/26] Merge branch 'boostpower-terrain-particles' into 'master' Slowdown Terrain Particle repair See merge request KartKrew/Kart!1166 --- src/k_terrain.c | 50 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/src/k_terrain.c b/src/k_terrain.c index 0e986469f..7c182ab8a 100644 --- a/src/k_terrain.c +++ b/src/k_terrain.c @@ -868,6 +868,9 @@ static void K_SpawnFootstepParticle(mobj_t *mo, t_footstep_t *fs, tic_t timer) See header file for description. --------------------------------------------------*/ + +#define INVALIDFOOTSTEP (fs == NULL || fs->mobjType == MT_NULL || fs->frequency <= 0) + void K_HandleFootstepParticles(mobj_t *mo) { tic_t timer = leveltime; @@ -879,31 +882,60 @@ void K_HandleFootstepParticles(mobj_t *mo) return; } + if (mo->player) + { + // Offset the timer. + timer += mo->player - players; + } + if (!(mo->flags & MF_APPLYTERRAIN) || mo->terrain == NULL) { // No TERRAIN effects for this object. - return; + goto offroadhandle; } fs = K_GetFootstepByIndex(mo->terrain->footstepID); - if (fs == NULL || fs->mobjType == MT_NULL || fs->frequency <= 0) + if (INVALIDFOOTSTEP) { // No particles to spawn. - return; - } - - if (mo->player != NULL) - { - // Offset timer by player ID. - timer += mo->player - players; + goto offroadhandle; } // Idea for later: if different spawning styles are desired, // we can put a switch case here! K_SpawnFootstepParticle(mo, fs, timer); + + return; + +offroadhandle: + // ...unless you're + // - A player and + if (mo->player == NULL) + { + return; + } + + // - Being affected by offroad + if (mo->player->boostpower >= FRACUNIT) + { + return; + } + + // in which case make default offroad footstep! + fs = K_GetFootstepByIndex(defaultOffroadFootstep); + + if (INVALIDFOOTSTEP) + { + // No particles to spawn. + return; + } + + K_SpawnFootstepParticle(mo, fs, timer); } +#undef INVALIDFOOTSTEP + /*-------------------------------------------------- static void K_CleanupTerrainOverlay(mobj_t *mo) From 4d5ba6affb21e2ecf3caf72ad2e17f7bbf160662 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 22 Dec 2023 04:22:04 -0800 Subject: [PATCH 10/26] Cache TERRAIN on texture_t - K_GetTerrainForTextureNum no longer performs a string lookup --- src/k_terrain.c | 2 ++ src/r_textures.c | 1 + 2 files changed, 3 insertions(+) diff --git a/src/k_terrain.c b/src/k_terrain.c index 7c182ab8a..688513f2b 100644 --- a/src/k_terrain.c +++ b/src/k_terrain.c @@ -2066,4 +2066,6 @@ void K_InitTerrain(UINT16 wadNum) free(name); } } + + R_ClearTextureNumCache(false); } diff --git a/src/r_textures.c b/src/r_textures.c index 40dbf291c..e65d5d907 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -27,6 +27,7 @@ #include "p_setup.h" // levelflats #include "byteptr.h" #include "dehacked.h" +#include "k_terrain.h" #ifdef HWRENDER #include "hardware/hw_glob.h" // HWR_LoadMapTextures From 72354be22dcd8cd901f4a8007effe95161f3ae90 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 31 May 2024 17:03:51 +0200 Subject: [PATCH 11/26] Fix off-by-one error in BRIGHT and TERRAIN lump parsing --- src/k_brightmap.c | 4 ++-- src/k_terrain.c | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/k_brightmap.c b/src/k_brightmap.c index 5b9963426..371d4a70d 100644 --- a/src/k_brightmap.c +++ b/src/k_brightmap.c @@ -112,7 +112,7 @@ static boolean K_BRIGHTLumpParser(char *data, size_t size) tkn = M_GetToken(NULL); pos = M_GetTokenPos(); - if (tkn && pos < size) + if (tkn && pos <= size) { brightmapStorage_t *bms = K_GetBrightmapStorageByTextureName(tkn); @@ -127,7 +127,7 @@ static boolean K_BRIGHTLumpParser(char *data, size_t size) tkn = M_GetToken(NULL); pos = M_GetTokenPos(); - if (tkn && pos < size) + if (tkn && pos <= size) { strncpy(bms->brightmapName, tkn, 8); bms->brightmapHash = quickncasehash(tkn, 8); diff --git a/src/k_terrain.c b/src/k_terrain.c index 688513f2b..ce0baab36 100644 --- a/src/k_terrain.c +++ b/src/k_terrain.c @@ -1668,7 +1668,7 @@ static boolean K_TERRAINLumpParser(char *data, size_t size) tkn = M_GetToken(NULL); pos = M_GetTokenPos(); - if (tkn && pos < size) + if (tkn && pos <= size) { t_splash_t *s = NULL; @@ -1709,7 +1709,7 @@ static boolean K_TERRAINLumpParser(char *data, size_t size) tkn = M_GetToken(NULL); pos = M_GetTokenPos(); - if (tkn && pos < size) + if (tkn && pos <= size) { t_footstep_t *fs = NULL; @@ -1750,7 +1750,7 @@ static boolean K_TERRAINLumpParser(char *data, size_t size) tkn = M_GetToken(NULL); pos = M_GetTokenPos(); - if (tkn && pos < size) + if (tkn && pos <= size) { t_overlay_t *o = NULL; @@ -1791,7 +1791,7 @@ static boolean K_TERRAINLumpParser(char *data, size_t size) tkn = M_GetToken(NULL); pos = M_GetTokenPos(); - if (tkn && pos < size) + if (tkn && pos <= size) { terrain_t *t = NULL; @@ -1831,8 +1831,8 @@ static boolean K_TERRAINLumpParser(char *data, size_t size) Z_Free(tkn); tkn = M_GetToken(NULL); pos = M_GetTokenPos(); - - if (tkn && pos < size) + + if (tkn && pos <= size) { if (stricmp(tkn, "optional") == 0) { @@ -1843,7 +1843,7 @@ static boolean K_TERRAINLumpParser(char *data, size_t size) pos = M_GetTokenPos(); } - if (tkn && pos < size) + if (tkn && pos <= size) { t_floor_t *f = NULL; @@ -1872,7 +1872,7 @@ static boolean K_TERRAINLumpParser(char *data, size_t size) tkn = M_GetToken(NULL); pos = M_GetTokenPos(); - if (tkn && pos < size) + if (tkn && pos <= size) { terrain_t *t = K_GetTerrainByName(tkn); @@ -1917,7 +1917,7 @@ static boolean K_TERRAINLumpParser(char *data, size_t size) tkn = M_GetToken(NULL); pos = M_GetTokenPos(); - if (tkn && pos < size) + if (tkn && pos <= size) { terrain_t *t = NULL; @@ -1956,7 +1956,7 @@ static boolean K_TERRAINLumpParser(char *data, size_t size) tkn = M_GetToken(NULL); pos = M_GetTokenPos(); - if (tkn && pos < size) + if (tkn && pos <= size) { t_footstep_t *fs = NULL; From ce47997a1000689bd153d095a8c262ef5dd6b672 Mon Sep 17 00:00:00 2001 From: Oni Date: Thu, 2 Feb 2023 05:49:31 +0000 Subject: [PATCH 12/26] Merge branch 'sprite-brightmaps' into 'master' Rudimentary sprite brightmap support See merge request KartKrew/Kart!801 --- src/lua_infolib.c | 64 +++++++++++++++++++++++++++++++++++++--------- src/lua_libs.h | 1 + src/r_picformats.c | 17 +++++++++--- src/r_picformats.h | 2 ++ src/r_things.c | 64 +++++++++++++++++++++++++++++++++------------- src/r_things.h | 1 + 6 files changed, 116 insertions(+), 33 deletions(-) diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 555bf3196..25241f66f 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -268,6 +268,20 @@ static UINT8 GetPivotFrame(lua_State *L, int idx) return frame; } +static int PushCast(lua_State *L, const char *meta) +{ + // bypass LUA_PushUserdata + void **userdata = lua_newuserdata(L, sizeof(void *)); + + *userdata = lua_touserdata(L, 1); + + luaL_getmetatable(L, meta); + lua_setmetatable(L, -2); + + // stack is left with the userdata on top, as if getting it had originally succeeded. + return 1; +} + // spriteinfo[] static int lib_getSpriteInfo(lua_State *L) { @@ -456,23 +470,15 @@ static int lib_spriteinfolen(lua_State *L) // spriteinfo_t static int spriteinfo_get(lua_State *L) { - spriteinfo_t *sprinfo = *((spriteinfo_t **)luaL_checkudata(L, 1, META_SPRITEINFO)); const char *field = luaL_checkstring(L, 2); - I_Assert(sprinfo != NULL); + luaL_checkudata(L, 1, META_SPRITEINFO); // push spriteframepivot_t userdata if (fastcmp(field, "pivot")) - { - // bypass LUA_PushUserdata - void **userdata = lua_newuserdata(L, sizeof(void *)); - *userdata = sprinfo; - luaL_getmetatable(L, META_PIVOTLIST); - lua_setmetatable(L, -2); - - // stack is left with the userdata on top, as if getting it had originally succeeded. - return 1; - } + return PushCast(L, META_PIVOTLIST); + else if (fastcmp(field, "brightmap")) + return PushCast(L, META_SPRITEBRIGHTLIST); else return luaL_error(L, LUA_QL("spriteinfo_t") " has no field named " LUA_QS, field); @@ -642,6 +648,29 @@ static int framepivot_num(lua_State *L) return 1; } +static int brightlist_get(lua_State *L) +{ + const spriteinfo_t *sprinfo = *((spriteinfo_t **)luaL_checkudata(L, 1, META_SPRITEBRIGHTLIST)); + const UINT8 frame = GetPivotFrame(L, 2); + + lua_pushstring(L, sprinfo->bright[frame]); + + return 1; +} + +static int brightlist_set(lua_State *L) +{ + spriteinfo_t *sprinfo = *((spriteinfo_t **)luaL_checkudata(L, 1, META_SPRITEBRIGHTLIST)); + + const UINT8 frame = GetPivotFrame(L, 2); + const char *val = luaL_checkstring(L, 3); + + Z_Free(sprinfo->bright[frame]); + sprinfo->bright[frame] = Z_StrDup(val); + + return 0; +} + //////////////// // STATE INFO // //////////////// @@ -2096,6 +2125,17 @@ int LUA_InfoLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_pop(L, 1); + luaL_newmetatable(L, META_SPRITEBRIGHTLIST); + lua_pushcfunction(L, brightlist_get); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, brightlist_set); + lua_setfield(L, -2, "__newindex"); + + lua_pushcfunction(L, pivotlist_num); + lua_setfield(L, -2, "__len"); + lua_pop(L, 1); + luaL_newmetatable(L, META_PRECIPPROPS); lua_pushcfunction(L, precipprops_get); lua_setfield(L, -2, "__index"); diff --git a/src/lua_libs.h b/src/lua_libs.h index 0cc818739..6a28e85fa 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -28,6 +28,7 @@ extern lua_State *gL; #define META_SPRITEINFO "SPRITEINFO_T*" #define META_PIVOTLIST "SPRITEFRAMEPIVOT_T[]" #define META_FRAMEPIVOT "SPRITEFRAMEPIVOT_T*" +#define META_SPRITEBRIGHTLIST "SPRITEBRIGHTMAP_T[]" #define META_PRECIPPROPS "PRECIPPROPS_T*" #define META_TAGLIST "TAGLIST" diff --git a/src/r_picformats.c b/src/r_picformats.c index 1f39ae42c..f8e3d3ca5 100644 --- a/src/r_picformats.c +++ b/src/r_picformats.c @@ -1474,9 +1474,10 @@ static void R_ParseSpriteInfoFrame(struct ParseSpriteInfoState *parser, boolean size_t sprinfoTokenLength; char *frameChar = NULL; UINT8 frameFrame = 0xFF; - INT16 frameXPivot = 0; - INT16 frameYPivot = 0; + INT16 frameXPivot = INT16_MIN; + INT16 frameYPivot = INT16_MIN; rotaxis_t frameRotAxis = 0; + char *bright = NULL; if (all) { @@ -1541,6 +1542,11 @@ static void R_ParseSpriteInfoFrame(struct ParseSpriteInfoState *parser, boolean else if ((stricmp(sprinfoToken, "Z")==0) || (stricmp(sprinfoToken, "ZAXIS")==0) || (stricmp(sprinfoToken, "YAW")==0)) frameRotAxis = ROTAXIS_Z; } + else if (stricmp(sprinfoToken, "BRIGHTMAP")==0) + { + Z_Free(bright); + bright = M_GetToken(NULL); + } Z_Free(sprinfoToken); sprinfoToken = M_GetToken(NULL); @@ -1557,8 +1563,13 @@ static void R_ParseSpriteInfoFrame(struct ParseSpriteInfoState *parser, boolean parser->info->pivot[frameFrame].x = frameXPivot; parser->info->pivot[frameFrame].y = frameYPivot; parser->info->pivot[frameFrame].rotaxis = frameRotAxis; + Z_Free(parser->info->bright[frameFrame]); + parser->info->bright[frameFrame] = bright; - set_bit_array(parser->info->available, frameFrame); + if (frameXPivot != INT16_MIN || frameYPivot != INT16_MIN) + { + set_bit_array(parser->info->available, frameFrame); + } if (parser->spr2) { diff --git a/src/r_picformats.h b/src/r_picformats.h index 700424814..9e6913b7b 100644 --- a/src/r_picformats.h +++ b/src/r_picformats.h @@ -103,6 +103,8 @@ typedef struct spriteframepivot_t pivot[64 + 1]; #define SPRINFO_DEFAULT_PIVOT (64) UINT8 available[BIT_ARRAY_SIZE(64 + 1)]; // 1 extra for default_pivot + + char *bright[64 + 1]; // brightmap lump name } spriteinfo_t; // Portable Network Graphics diff --git a/src/r_things.c b/src/r_things.c index 039a80c97..ca1e3dafd 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -849,12 +849,13 @@ UINT8 *R_GetSpriteTranslation(vissprite_t *vis) // static void R_DrawVisSprite(vissprite_t *vis) { - column_t *column; + column_t *column, *bmcol = NULL; void (*localcolfunc)(column_t *, column_t *, INT32); INT32 texturecolumn; INT32 pwidth; fixed_t frac; patch_t *patch = vis->patch; + patch_t *bmpatch = vis->bright; fixed_t this_scale = vis->thingscale; INT32 x1, x2; INT64 overflow_test; @@ -875,6 +876,13 @@ static void R_DrawVisSprite(vissprite_t *vis) if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) return; // ditto } + // Prevent an out of bounds error + if (bmpatch && (bmpatch->width != patch->width || + bmpatch->height != patch->height)) + { + return; + } + R_SetColumnFunc(BASEDRAWFUNC, false); // hack: this isn't resetting properly somewhere. dc_colormap = vis->colormap; dc_fullbright = colormaps; @@ -1009,7 +1017,10 @@ static void R_DrawVisSprite(vissprite_t *vis) column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); - localcolfunc (column, NULL, baseclip); + if (bmpatch) + bmcol = (column_t *)((UINT8 *)bmpatch->columns + (bmpatch->columnofs[texturecolumn])); + + localcolfunc (column, bmcol, baseclip); } } else if (vis->cut & SC_SHEAR) @@ -1021,17 +1032,18 @@ static void R_DrawVisSprite(vissprite_t *vis) // Vertically sheared sprite for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale, dc_texturemid -= vis->shear.tan) { -#ifdef RANGECHECK texturecolumn = frac>>FRACBITS; + +#ifdef RANGECHECK if (texturecolumn < 0 || texturecolumn >= pwidth) I_Error("R_DrawSpriteRange: bad texturecolumn at %d from end", vis->x2 - dc_x); - column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); -#else - column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[frac>>FRACBITS])); #endif + column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); + if (bmpatch) + bmcol = (column_t *)((UINT8 *)bmpatch->columns + (bmpatch->columnofs[texturecolumn])); sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale)); - localcolfunc (column, NULL, baseclip); + localcolfunc (column, bmcol, baseclip); } } else @@ -1043,15 +1055,18 @@ static void R_DrawVisSprite(vissprite_t *vis) // Non-paper drawing loop for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale, sprtopscreen += vis->shear.tan) { -#ifdef RANGECHECK texturecolumn = frac>>FRACBITS; + +#ifdef RANGECHECK if (texturecolumn < 0 || texturecolumn >= pwidth) I_Error("R_DrawSpriteRange: bad texturecolumn at %d from end", vis->x2 - dc_x); - column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); -#else - column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[frac>>FRACBITS])); #endif - localcolfunc (column, NULL, baseclip); + column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); + + if (bmpatch) + bmcol = (column_t *)((UINT8 *)bmpatch->columns + (bmpatch->columnofs[texturecolumn])); + + localcolfunc (column, bmcol, baseclip); } } @@ -1066,9 +1081,7 @@ static void R_DrawVisSprite(vissprite_t *vis) static void R_DrawPrecipitationVisSprite(vissprite_t *vis) { column_t *column; -#ifdef RANGECHECK INT32 texturecolumn; -#endif fixed_t frac; patch_t *patch; fixed_t this_scale = vis->thingscale; @@ -1115,16 +1128,15 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) { -#ifdef RANGECHECK texturecolumn = frac>>FRACBITS; +#ifdef RANGECHECK if (texturecolumn < 0 || texturecolumn >= patch->width) I_Error("R_DrawPrecipitationSpriteRange: bad texturecolumn"); +#endif column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); -#else - column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[frac>>FRACBITS])); -#endif + R_DrawMaskedColumn(column, NULL, -1); } @@ -1211,6 +1223,18 @@ static void R_SplitSprite(vissprite_t *sprite) } } +static patch_t *R_CacheSpriteBrightMap(const spriteinfo_t *sprinfo, UINT8 frame) +{ + const char *name = sprinfo->bright[frame]; + + if (name == NULL) + { + name = sprinfo->bright[SPRINFO_DEFAULT_PIVOT]; + } + + return W_CachePatchNum(W_CheckNumForLongName(name), PU_SPRITE); +} + // // R_GetShadowZ(thing, shadowslope) // Get the first visible floor below the object for shadows @@ -1387,6 +1411,7 @@ static void R_ProjectDropShadow( shadow = R_NewVisSprite(); shadow->patch = patch; + shadow->bright = NULL; shadow->heightsec = vis->heightsec; shadow->mobjflags = 0; @@ -2291,6 +2316,7 @@ static void R_ProjectSprite(mobj_t *thing) vis->cut |= SC_SPLAT; // I like ya cut g vis->patch = patch; + vis->bright = R_CacheSpriteBrightMap(sprinfo, frame); if (thing->subsector->sector->numlights && !(shadowdraw || splat)) R_SplitSprite(vis); @@ -2480,6 +2506,8 @@ 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_SPRITE); + vis->bright = R_CacheSpriteBrightMap(&spriteinfo[thing->sprite], + thing->frame & FF_FRAMEMASK); vis->transmap = R_GetBlendTable(blendmode, trans); diff --git a/src/r_things.h b/src/r_things.h index 789e7aab8..7b77c0901 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -188,6 +188,7 @@ typedef struct vissprite_s fixed_t texturemid; patch_t *patch; + patch_t *bright; lighttable_t *colormap; // for color translation and shadow draw // maxbright frames as well From a13913bebd12d71266c2e4fb317b6cffce8a76c2 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 14 Feb 2023 01:05:48 -0800 Subject: [PATCH 13/26] Fix R_CacheSpriteBrightMap trying to cache out of range lump --- src/r_things.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index ca1e3dafd..171ed6746 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1232,7 +1232,14 @@ static patch_t *R_CacheSpriteBrightMap(const spriteinfo_t *sprinfo, UINT8 frame) name = sprinfo->bright[SPRINFO_DEFAULT_PIVOT]; } - return W_CachePatchNum(W_CheckNumForLongName(name), PU_SPRITE); + const lumpnum_t num = W_CheckNumForLongName(name); + + if (num == LUMPERROR) + { + return NULL; + } + + return W_CachePatchNum(num, PU_SPRITE); } // From d439ce2966729bd02bd991af37fa9aa1f20cb7c8 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 4 Apr 2023 22:15:44 -0700 Subject: [PATCH 14/26] R_RasterizeFloorSplat: set ds_brightmap to NULL Previously did not set ds_brightmap, so it could sneak in from a previous span renderer. --- src/r_splats.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/r_splats.c b/src/r_splats.c index 27cc5566a..46dcfce12 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -425,6 +425,8 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr ds_colormap = vis->colormap; ds_fullbright = colormaps; + ds_brightmap = NULL; + ds_translation = R_GetSpriteTranslation(vis); if (ds_translation == NULL) ds_translation = colormaps; From 84ede3188e6255ee7581486b8faefec03799a24d Mon Sep 17 00:00:00 2001 From: Eidolon Date: Sat, 14 Oct 2023 15:24:18 -0500 Subject: [PATCH 15/26] Only render HWR player view if literally in opengl --- 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 88e98f134..907ccd317 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -473,7 +473,7 @@ static void D_Display(void) viewssnum = i; #ifdef HWRENDER - if (rendermode != render_soft) + if (rendermode == render_opengl) HWR_RenderPlayerView(); else #endif From f1d7d5f763ab3199d65d2da199587d4bc64183ec Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Sat, 24 Aug 2024 15:25:46 -0400 Subject: [PATCH 16/26] Revert Merge branch sprite-brightmaps into master This reverts commit ce47997a1000689bd153d095a8c262ef5dd6b672. --- src/lua_infolib.c | 64 ++++++++--------------------------------- src/lua_libs.h | 1 - src/r_picformats.c | 17 ++--------- src/r_picformats.h | 2 -- src/r_things.c | 71 ++++++++++++---------------------------------- src/r_things.h | 1 - 6 files changed, 33 insertions(+), 123 deletions(-) diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 25241f66f..555bf3196 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -268,20 +268,6 @@ static UINT8 GetPivotFrame(lua_State *L, int idx) return frame; } -static int PushCast(lua_State *L, const char *meta) -{ - // bypass LUA_PushUserdata - void **userdata = lua_newuserdata(L, sizeof(void *)); - - *userdata = lua_touserdata(L, 1); - - luaL_getmetatable(L, meta); - lua_setmetatable(L, -2); - - // stack is left with the userdata on top, as if getting it had originally succeeded. - return 1; -} - // spriteinfo[] static int lib_getSpriteInfo(lua_State *L) { @@ -470,15 +456,23 @@ static int lib_spriteinfolen(lua_State *L) // spriteinfo_t static int spriteinfo_get(lua_State *L) { + spriteinfo_t *sprinfo = *((spriteinfo_t **)luaL_checkudata(L, 1, META_SPRITEINFO)); const char *field = luaL_checkstring(L, 2); - luaL_checkudata(L, 1, META_SPRITEINFO); + I_Assert(sprinfo != NULL); // push spriteframepivot_t userdata if (fastcmp(field, "pivot")) - return PushCast(L, META_PIVOTLIST); - else if (fastcmp(field, "brightmap")) - return PushCast(L, META_SPRITEBRIGHTLIST); + { + // bypass LUA_PushUserdata + void **userdata = lua_newuserdata(L, sizeof(void *)); + *userdata = sprinfo; + luaL_getmetatable(L, META_PIVOTLIST); + lua_setmetatable(L, -2); + + // stack is left with the userdata on top, as if getting it had originally succeeded. + return 1; + } else return luaL_error(L, LUA_QL("spriteinfo_t") " has no field named " LUA_QS, field); @@ -648,29 +642,6 @@ static int framepivot_num(lua_State *L) return 1; } -static int brightlist_get(lua_State *L) -{ - const spriteinfo_t *sprinfo = *((spriteinfo_t **)luaL_checkudata(L, 1, META_SPRITEBRIGHTLIST)); - const UINT8 frame = GetPivotFrame(L, 2); - - lua_pushstring(L, sprinfo->bright[frame]); - - return 1; -} - -static int brightlist_set(lua_State *L) -{ - spriteinfo_t *sprinfo = *((spriteinfo_t **)luaL_checkudata(L, 1, META_SPRITEBRIGHTLIST)); - - const UINT8 frame = GetPivotFrame(L, 2); - const char *val = luaL_checkstring(L, 3); - - Z_Free(sprinfo->bright[frame]); - sprinfo->bright[frame] = Z_StrDup(val); - - return 0; -} - //////////////// // STATE INFO // //////////////// @@ -2125,17 +2096,6 @@ int LUA_InfoLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_pop(L, 1); - luaL_newmetatable(L, META_SPRITEBRIGHTLIST); - lua_pushcfunction(L, brightlist_get); - lua_setfield(L, -2, "__index"); - - lua_pushcfunction(L, brightlist_set); - lua_setfield(L, -2, "__newindex"); - - lua_pushcfunction(L, pivotlist_num); - lua_setfield(L, -2, "__len"); - lua_pop(L, 1); - luaL_newmetatable(L, META_PRECIPPROPS); lua_pushcfunction(L, precipprops_get); lua_setfield(L, -2, "__index"); diff --git a/src/lua_libs.h b/src/lua_libs.h index 6a28e85fa..0cc818739 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -28,7 +28,6 @@ extern lua_State *gL; #define META_SPRITEINFO "SPRITEINFO_T*" #define META_PIVOTLIST "SPRITEFRAMEPIVOT_T[]" #define META_FRAMEPIVOT "SPRITEFRAMEPIVOT_T*" -#define META_SPRITEBRIGHTLIST "SPRITEBRIGHTMAP_T[]" #define META_PRECIPPROPS "PRECIPPROPS_T*" #define META_TAGLIST "TAGLIST" diff --git a/src/r_picformats.c b/src/r_picformats.c index f8e3d3ca5..1f39ae42c 100644 --- a/src/r_picformats.c +++ b/src/r_picformats.c @@ -1474,10 +1474,9 @@ static void R_ParseSpriteInfoFrame(struct ParseSpriteInfoState *parser, boolean size_t sprinfoTokenLength; char *frameChar = NULL; UINT8 frameFrame = 0xFF; - INT16 frameXPivot = INT16_MIN; - INT16 frameYPivot = INT16_MIN; + INT16 frameXPivot = 0; + INT16 frameYPivot = 0; rotaxis_t frameRotAxis = 0; - char *bright = NULL; if (all) { @@ -1542,11 +1541,6 @@ static void R_ParseSpriteInfoFrame(struct ParseSpriteInfoState *parser, boolean else if ((stricmp(sprinfoToken, "Z")==0) || (stricmp(sprinfoToken, "ZAXIS")==0) || (stricmp(sprinfoToken, "YAW")==0)) frameRotAxis = ROTAXIS_Z; } - else if (stricmp(sprinfoToken, "BRIGHTMAP")==0) - { - Z_Free(bright); - bright = M_GetToken(NULL); - } Z_Free(sprinfoToken); sprinfoToken = M_GetToken(NULL); @@ -1563,13 +1557,8 @@ static void R_ParseSpriteInfoFrame(struct ParseSpriteInfoState *parser, boolean parser->info->pivot[frameFrame].x = frameXPivot; parser->info->pivot[frameFrame].y = frameYPivot; parser->info->pivot[frameFrame].rotaxis = frameRotAxis; - Z_Free(parser->info->bright[frameFrame]); - parser->info->bright[frameFrame] = bright; - if (frameXPivot != INT16_MIN || frameYPivot != INT16_MIN) - { - set_bit_array(parser->info->available, frameFrame); - } + set_bit_array(parser->info->available, frameFrame); if (parser->spr2) { diff --git a/src/r_picformats.h b/src/r_picformats.h index 9e6913b7b..700424814 100644 --- a/src/r_picformats.h +++ b/src/r_picformats.h @@ -103,8 +103,6 @@ typedef struct spriteframepivot_t pivot[64 + 1]; #define SPRINFO_DEFAULT_PIVOT (64) UINT8 available[BIT_ARRAY_SIZE(64 + 1)]; // 1 extra for default_pivot - - char *bright[64 + 1]; // brightmap lump name } spriteinfo_t; // Portable Network Graphics diff --git a/src/r_things.c b/src/r_things.c index 171ed6746..039a80c97 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -849,13 +849,12 @@ UINT8 *R_GetSpriteTranslation(vissprite_t *vis) // static void R_DrawVisSprite(vissprite_t *vis) { - column_t *column, *bmcol = NULL; + column_t *column; void (*localcolfunc)(column_t *, column_t *, INT32); INT32 texturecolumn; INT32 pwidth; fixed_t frac; patch_t *patch = vis->patch; - patch_t *bmpatch = vis->bright; fixed_t this_scale = vis->thingscale; INT32 x1, x2; INT64 overflow_test; @@ -876,13 +875,6 @@ static void R_DrawVisSprite(vissprite_t *vis) if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) return; // ditto } - // Prevent an out of bounds error - if (bmpatch && (bmpatch->width != patch->width || - bmpatch->height != patch->height)) - { - return; - } - R_SetColumnFunc(BASEDRAWFUNC, false); // hack: this isn't resetting properly somewhere. dc_colormap = vis->colormap; dc_fullbright = colormaps; @@ -1017,10 +1009,7 @@ static void R_DrawVisSprite(vissprite_t *vis) column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); - if (bmpatch) - bmcol = (column_t *)((UINT8 *)bmpatch->columns + (bmpatch->columnofs[texturecolumn])); - - localcolfunc (column, bmcol, baseclip); + localcolfunc (column, NULL, baseclip); } } else if (vis->cut & SC_SHEAR) @@ -1032,18 +1021,17 @@ static void R_DrawVisSprite(vissprite_t *vis) // Vertically sheared sprite for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale, dc_texturemid -= vis->shear.tan) { - texturecolumn = frac>>FRACBITS; - #ifdef RANGECHECK + texturecolumn = frac>>FRACBITS; if (texturecolumn < 0 || texturecolumn >= pwidth) I_Error("R_DrawSpriteRange: bad texturecolumn at %d from end", vis->x2 - dc_x); -#endif column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); - if (bmpatch) - bmcol = (column_t *)((UINT8 *)bmpatch->columns + (bmpatch->columnofs[texturecolumn])); +#else + column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[frac>>FRACBITS])); +#endif sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale)); - localcolfunc (column, bmcol, baseclip); + localcolfunc (column, NULL, baseclip); } } else @@ -1055,18 +1043,15 @@ static void R_DrawVisSprite(vissprite_t *vis) // Non-paper drawing loop for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale, sprtopscreen += vis->shear.tan) { - texturecolumn = frac>>FRACBITS; - #ifdef RANGECHECK + texturecolumn = frac>>FRACBITS; if (texturecolumn < 0 || texturecolumn >= pwidth) I_Error("R_DrawSpriteRange: bad texturecolumn at %d from end", vis->x2 - dc_x); -#endif column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); - - if (bmpatch) - bmcol = (column_t *)((UINT8 *)bmpatch->columns + (bmpatch->columnofs[texturecolumn])); - - localcolfunc (column, bmcol, baseclip); +#else + column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[frac>>FRACBITS])); +#endif + localcolfunc (column, NULL, baseclip); } } @@ -1081,7 +1066,9 @@ static void R_DrawVisSprite(vissprite_t *vis) static void R_DrawPrecipitationVisSprite(vissprite_t *vis) { column_t *column; +#ifdef RANGECHECK INT32 texturecolumn; +#endif fixed_t frac; patch_t *patch; fixed_t this_scale = vis->thingscale; @@ -1128,15 +1115,16 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) { +#ifdef RANGECHECK texturecolumn = frac>>FRACBITS; -#ifdef RANGECHECK if (texturecolumn < 0 || texturecolumn >= patch->width) I_Error("R_DrawPrecipitationSpriteRange: bad texturecolumn"); -#endif column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); - +#else + column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[frac>>FRACBITS])); +#endif R_DrawMaskedColumn(column, NULL, -1); } @@ -1223,25 +1211,6 @@ static void R_SplitSprite(vissprite_t *sprite) } } -static patch_t *R_CacheSpriteBrightMap(const spriteinfo_t *sprinfo, UINT8 frame) -{ - const char *name = sprinfo->bright[frame]; - - if (name == NULL) - { - name = sprinfo->bright[SPRINFO_DEFAULT_PIVOT]; - } - - const lumpnum_t num = W_CheckNumForLongName(name); - - if (num == LUMPERROR) - { - return NULL; - } - - return W_CachePatchNum(num, PU_SPRITE); -} - // // R_GetShadowZ(thing, shadowslope) // Get the first visible floor below the object for shadows @@ -1418,7 +1387,6 @@ static void R_ProjectDropShadow( shadow = R_NewVisSprite(); shadow->patch = patch; - shadow->bright = NULL; shadow->heightsec = vis->heightsec; shadow->mobjflags = 0; @@ -2323,7 +2291,6 @@ static void R_ProjectSprite(mobj_t *thing) vis->cut |= SC_SPLAT; // I like ya cut g vis->patch = patch; - vis->bright = R_CacheSpriteBrightMap(sprinfo, frame); if (thing->subsector->sector->numlights && !(shadowdraw || splat)) R_SplitSprite(vis); @@ -2513,8 +2480,6 @@ 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_SPRITE); - vis->bright = R_CacheSpriteBrightMap(&spriteinfo[thing->sprite], - thing->frame & FF_FRAMEMASK); vis->transmap = R_GetBlendTable(blendmode, trans); diff --git a/src/r_things.h b/src/r_things.h index 7b77c0901..789e7aab8 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -188,7 +188,6 @@ typedef struct vissprite_s fixed_t texturemid; patch_t *patch; - patch_t *bright; lighttable_t *colormap; // for color translation and shadow draw // maxbright frames as well From 46c015d317aef5710a0f1fb1496c33c99e4e4ef7 Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Sat, 24 Aug 2024 15:36:23 -0400 Subject: [PATCH 17/26] Revert Revert the-big-step-up since it has regressions This revert causes issues on some slope types for whatever reason so back it comes for now This reverts commit 515c531d51df7729fa484951bedfcd149a7c4d3d. --- src/p_map.c | 180 +++++++----------------------------- src/p_maputl.c | 245 +++++++++++++++++++++++++++++++------------------ src/p_maputl.h | 4 + 3 files changed, 191 insertions(+), 238 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 8de4cd171..b36bb53e2 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1567,6 +1567,11 @@ static BlockItReturn_t PIT_CheckLine(line_t *ld) tmceilingrover = openceilingrover; tmceilingslope = opentopslope; tmceilingpic = opentoppic; + tmceilingstep = openceilingstep; + if (thingtop == tmthing->ceilingz) + { + tmthing->ceilingdrop = openceilingdrop; + } } if (openbottom > tmfloorz) @@ -1575,6 +1580,11 @@ static BlockItReturn_t PIT_CheckLine(line_t *ld) tmfloorrover = openfloorrover; tmfloorslope = openbottomslope; tmfloorpic = openbottompic; + tmfloorstep = openfloorstep; + if (tmthing->z == tmthing->floorz) + { + tmthing->floordrop = openfloordrop; + } } if (highceiling > tmdrpoffceilz) @@ -2532,149 +2542,15 @@ boolean P_CheckMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) // boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) { - fixed_t tryx = thing->x; - fixed_t tryy = thing->y; - fixed_t oldx = tryx; - fixed_t oldy = tryy; - fixed_t radius = thing->radius; - fixed_t thingtop = thing->z + thing->height; + fixed_t oldx = thing->x; + fixed_t oldy = thing->y; fixed_t startingonground = P_IsObjectOnGround(thing); - floatok = false; - - // reset this to 0 at the start of each trymove call as it's only used here - numspechitint = 0U; - - // This makes sure that there are no freezes from computing extremely small movements. - // Originally was MAXRADIUS/2, but that causes some inconsistencies for small players. - if (radius < mapobjectscale) - radius = mapobjectscale; - - do { - if (thing->flags & MF_NOCLIP) { - tryx = x; - tryy = y; - } else { - if (x-tryx > radius) - tryx += radius; - else if (x-tryx < -radius) - tryx -= radius; - else - tryx = x; - if (y-tryy > radius) - tryy += radius; - else if (y-tryy < -radius) - tryy -= radius; - else - tryy = y; - } - - if (!P_CheckPosition(thing, tryx, tryy)) - return false; // solid wall or thing - - // copy into the spechitint buffer from spechit - spechitint_copyinto(); - - if (!(thing->flags & MF_NOCLIP)) - { - //All things are affected by their scale. - const fixed_t maxstepmove = FixedMul(MAXSTEPMOVE, mapobjectscale); - fixed_t maxstep = maxstepmove; - - if (thing->player && thing->player->waterskip) - maxstep += maxstepmove; // Add some extra stepmove when waterskipping - - // If using type Section1:13, double the maxstep. - if (P_MobjTouchingSectorSpecial(thing, 1, 13, false)) - maxstep <<= 1; - // If using type Section1:12, no maxstep. For short walls, like Egg Zeppelin - else if (P_MobjTouchingSectorSpecial(thing, 1, 12, false)) - maxstep = 0; - - if (thing->type == MT_SKIM) - maxstep = 0; - - if (tmceilingz - tmfloorz < thing->height) - { - if (tmfloorthing) - tmhitthing = tmfloorthing; - return false; // doesn't fit - } - - floatok = true; - - if (thing->eflags & MFE_VERTICALFLIP) - { - if (thing->z < tmfloorz) - return false; // mobj must raise itself to fit - } - else if (tmceilingz < thingtop) - return false; // mobj must lower itself to fit - - // Ramp test - if ((maxstep > 0) && !(P_MobjTouchingSectorSpecial(thing, 1, 14, false))) - { - // If the floor difference is MAXSTEPMOVE or less, and the sector isn't Section1:14, ALWAYS - // step down! Formerly required a Section1:13 sector for the full MAXSTEPMOVE, but no more. - - if (thing->eflags & MFE_VERTICALFLIP) - { - if (thingtop == thing->ceilingz && tmceilingz > thingtop && tmceilingz - thingtop <= maxstep) - { - thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height; - thing->ceilingrover = tmceilingrover; - thing->eflags |= MFE_JUSTSTEPPEDDOWN; - } - else if (tmceilingz < thingtop && thingtop - tmceilingz <= maxstep) - { - thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height; - thing->ceilingrover = tmceilingrover; - thing->eflags |= MFE_JUSTSTEPPEDDOWN; - } - } - else if (thing->z == thing->floorz && tmfloorz < thing->z && thing->z - tmfloorz <= maxstep) - { - thing->z = thing->floorz = tmfloorz; - thing->floorrover = tmfloorrover; - thing->eflags |= MFE_JUSTSTEPPEDDOWN; - } - else if (tmfloorz > thing->z && tmfloorz - thing->z <= maxstep) - { - thing->z = thing->floorz = tmfloorz; - thing->floorrover = tmfloorrover; - thing->eflags |= MFE_JUSTSTEPPEDDOWN; - } - } - - if (thing->eflags & MFE_VERTICALFLIP) - { - if (thingtop - tmceilingz > maxstep) - { - if (tmfloorthing) - tmhitthing = tmfloorthing; - return false; // too big a step up - } - } - else if (tmfloorz - thing->z > maxstep) - { - if (tmfloorthing) - tmhitthing = tmfloorthing; - return false; // too big a step up - } - - if (!allowdropoff && !(thing->flags & MF_FLOAT) && thing->type != MT_SKIM && !tmfloorthing) - { - if (thing->eflags & MFE_VERTICALFLIP) - { - if (tmdrpoffceilz - tmceilingz > maxstep) - return false; - } - else if (tmfloorz - tmdropoffz > maxstep) - return false; // don't stand over a dropoff - } - } - } while (tryx != x || tryy != y); + fixed_t stairjank = 0; + pslope_t *oldslope = thing->standingslope; // The move is ok! + if (!increment_move(thing, x, y, allowdropoff)) + return false; // If it's a pushable object, check if anything is // standing on top and move it, too. @@ -2709,12 +2585,14 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (!(thing->flags & MF_NOCLIPHEIGHT)) { // Assign thing's standingslope if needed - if (thing->z <= tmfloorz && !(thing->eflags & MFE_VERTICALFLIP)) { - + if (thing->z <= tmfloorz && !(thing->eflags & MFE_VERTICALFLIP)) + { K_UpdateMobjTerrain(thing, tmfloorpic); - + if (!startingonground && tmfloorslope) + { P_HandleSlopeLanding(thing, tmfloorslope); + } if (thing->momz <= 0) { @@ -2722,15 +2600,19 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) P_SetPitchRollFromSlope(thing, thing->standingslope); if (thing->momz == 0 && thing->player && !startingonground) + { P_PlayerHitFloor(thing->player, true); + } } } - else if (thing->z+thing->height >= tmceilingz && (thing->eflags & MFE_VERTICALFLIP)) { - + else if (thing->z+thing->height >= tmceilingz && (thing->eflags & MFE_VERTICALFLIP)) + { K_UpdateMobjTerrain(thing, tmceilingpic); - + if (!startingonground && tmceilingslope) + { P_HandleSlopeLanding(thing, tmceilingslope); + } if (thing->momz >= 0) { @@ -2738,15 +2620,19 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) P_SetPitchRollFromSlope(thing, thing->standingslope); if (thing->momz == 0 && thing->player && !startingonground) + { P_PlayerHitFloor(thing->player, true); + } } } } - else // don't set standingslope if you're not going to clip against it + else { + // don't set standingslope if you're not going to clip against it thing->standingslope = NULL; thing->terrain = NULL; } + thing->x = x; thing->y = y; diff --git a/src/p_maputl.c b/src/p_maputl.c index fe99e6f81..b4ae2f3ed 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -338,6 +338,10 @@ line_t * P_FindNearestLine fixed_t opentop, openbottom, openrange, lowfloor, highceiling; pslope_t *opentopslope, *openbottomslope; ffloor_t *openfloorrover, *openceilingrover; +fixed_t openceilingstep; +fixed_t openceilingdrop; +fixed_t openfloorstep; +fixed_t openfloordrop; INT32 opentoppic, openbottompic; // P_CameraLineOpening @@ -560,7 +564,18 @@ P_GetMidtextureTopBottom void P_LineOpening(line_t *linedef, mobj_t *mobj) { + enum { FRONT, BACK }; + sector_t *front, *back; + fixed_t thingtop = 0; + vertex_t cross; + + /* these init to shut compiler up */ + fixed_t topedge[2] = {0}; + fixed_t botedge[2] = {0}; + + int hi = 0; + int lo = 0; if (linedef->sidenum[1] == 0xffff) { @@ -569,6 +584,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) return; } + P_ClosestPointOnLine(tmx, tmy, linedef, &cross); + // Treat polyobjects kind of like 3D Floors if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT)) { @@ -584,6 +601,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) I_Assert(front != NULL); I_Assert(back != NULL); + if (mobj) + { + thingtop = mobj->z + mobj->height; + } + openfloorrover = openceilingrover = NULL; if (linedef->polyobj) { @@ -594,110 +616,90 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) lowfloor = INT32_MAX; opentopslope = openbottomslope = NULL; opentoppic = openbottompic = -1; + openceilingstep = 0; + openceilingdrop = 0; + openfloorstep = 0; + openfloordrop = 0; } else { // Set open and high/low values here - fixed_t frontheight, backheight; + fixed_t height[2]; const sector_t * sector[2] = { front, back }; - frontheight = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); - backheight = P_GetCeilingZ(mobj, back, tmx, tmy, linedef); + height[FRONT] = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); + height[BACK] = P_GetCeilingZ(mobj, back, tmx, tmy, linedef); - if (frontheight < backheight) + hi = ( height[0] < height[1] ); + lo = ! hi; + + opentop = height[lo]; + highceiling = height[hi]; + opentopslope = sector[lo]->c_slope; + opentoppic = sector[lo]->ceilingpic; + + if (mobj) { - opentop = frontheight; - highceiling = backheight; - opentopslope = front->c_slope; - } - else - { - opentop = backheight; - highceiling = frontheight; - opentopslope = back->c_slope; + topedge[FRONT] = P_GetSectorCeilingZAt(front, cross.x, cross.y); + topedge[BACK] = P_GetSectorCeilingZAt(back, cross.x, cross.y); + + openceilingstep = ( thingtop - topedge[lo] ); + openceilingdrop = ( topedge[hi] - topedge[lo] ); } - frontheight = P_GetFloorZ(mobj, front, tmx, tmy, linedef); - backheight = P_GetFloorZ(mobj, back, tmx, tmy, linedef); + height[FRONT] = P_GetFloorZ(mobj, front, tmx, tmy, linedef); + height[BACK] = P_GetFloorZ(mobj, back, tmx, tmy, linedef); - if (frontheight > backheight) + hi = ( height[0] < height[1] ); + lo = ! hi; + + openbottom = height[hi]; + lowfloor = height[lo]; + openbottomslope = sector[hi]->f_slope; + openbottompic = sector[hi]->floorpic; + + if (mobj) { - openbottom = frontheight; - lowfloor = backheight; - openbottomslope = front->f_slope; + botedge[FRONT] = P_GetSectorFloorZAt(front, cross.x, cross.y); + botedge[BACK] = P_GetSectorFloorZAt(back, cross.x, cross.y); + + openfloorstep = ( botedge[hi] - mobj->z ); + openfloordrop = ( botedge[hi] - botedge[lo] ); } - else - { - openbottom = backheight; - lowfloor = frontheight; - openbottomslope = back->f_slope; - } - - opentoppic = sector[!(frontheight < backheight)]->ceilingpic; - openbottompic = sector[frontheight < backheight]->floorpic; } if (mobj) { - fixed_t thingtop = mobj->z + mobj->height; - // Check for collision with front side's midtexture if Effect 4 is set if ((linedef->flags & ML_EFFECT4 || (mobj->player && P_IsLineTripWire(linedef) && !K_TripwirePass(mobj->player))) && !linedef->polyobj // don't do anything for polyobjects! ...for now ) { - side_t *side = &sides[linedef->sidenum[0]]; - fixed_t textop, texbottom, texheight; + fixed_t textop, texbottom; fixed_t texmid, delta1, delta2; - INT32 texnum = R_GetTextureNum(side->midtexture); // make sure the texture is actually valid - vertex_t cross; - if (texnum) { - // Get the midtexture's height - texheight = textures[texnum]->height << FRACBITS; + if (P_GetMidtextureTopBottom(linedef, cross.x, cross.y, &textop, &texbottom)) + { + texmid = texbottom+(textop-texbottom)/2; - // Set texbottom and textop to the Z coordinates of the texture's boundaries -#if 0 - // don't remove this code unless solid midtextures - // on non-solid polyobjects should NEVER happen in the future - if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT)) { - if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat - texbottom = back->floorheight + side->rowoffset; - textop = back->ceilingheight + side->rowoffset; - } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { - texbottom = back->floorheight + side->rowoffset; - textop = texbottom + texheight*(side->repeatcnt+1); - } else { - textop = back->ceilingheight + side->rowoffset; - texbottom = textop - texheight*(side->repeatcnt+1); + delta1 = abs(mobj->z - texmid); + delta2 = abs(thingtop - texmid); + + if (delta1 > delta2) { // Below + if (opentop > texbottom) + { + topedge[lo] -= ( opentop - texbottom ); + + opentop = texbottom; + openceilingstep = ( thingtop - topedge[lo] ); + openceilingdrop = ( topedge[hi] - topedge[lo] ); } - } else -#endif - { - if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat - texbottom = openbottom + side->rowoffset; - textop = opentop + side->rowoffset; - } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { - texbottom = openbottom + side->rowoffset; - textop = texbottom + texheight*(side->repeatcnt+1); - } else { - textop = opentop + side->rowoffset; - texbottom = textop - texheight*(side->repeatcnt+1); - } - } - P_ClosestPointOnLine(tmx, tmy, linedef, &cross); - - if (P_GetMidtextureTopBottom(linedef, cross.x, cross.y, &textop, &texbottom)) - { - texmid = texbottom+(textop-texbottom)/2; + } else { // Above + if (openbottom < textop) + { + botedge[hi] += ( textop - openbottom ); - delta1 = abs(mobj->z - texmid); - delta2 = abs(thingtop - texmid); - - if (delta1 > delta2) { // Below - if (opentop > texbottom) - opentop = texbottom; - } else { // Above - if (openbottom < textop) - openbottom = textop; + openbottom = textop; + openfloorstep = ( botedge[hi] - mobj->z ); + openfloordrop = ( botedge[hi] - botedge[lo] ); } } } @@ -726,14 +728,22 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) delta2 = abs(thingtop - (polybottom + ((polytop - polybottom)/2))); if (polybottom < opentop && delta1 >= delta2) + { opentop = polybottom; + } else if (polybottom < highceiling && delta1 >= delta2) + { highceiling = polybottom; + } if (polytop > openbottom && delta1 < delta2) + { openbottom = polytop; + } else if (polytop > lowfloor && delta1 < delta2) + { lowfloor = polytop; + } } // otherwise don't do anything special, pretend there's nothing else there } @@ -745,6 +755,21 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) ffloor_t *rover; fixed_t delta1, delta2; + /* yuck */ + struct + { + fixed_t top; + fixed_t bottom; + ffloor_t * ceilingrover; + ffloor_t * floorrover; + } open[2] = { + { INT32_MAX, INT32_MIN, NULL, NULL }, + { INT32_MAX, INT32_MIN, NULL, NULL }, + }; + + const fixed_t oldopentop = opentop; + const fixed_t oldopenbottom = openbottom; + // Check for frontsector's fake floors for (rover = front->ffloors; rover; rover = rover->next) { @@ -766,11 +791,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) // thing is below FOF { - if (bottomheight < opentop) { - opentop = bottomheight; + if (bottomheight < open[FRONT].top) { + open[FRONT].top = bottomheight; opentopslope = *rover->b_slope; opentoppic = *rover->bottompic; - openceilingrover = rover; + open[FRONT].ceilingrover = rover; } else if (bottomheight < highceiling) highceiling = bottomheight; @@ -778,11 +803,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 < delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_REVERSEPLATFORM) // thing is above FOF { - if (topheight > openbottom) { - openbottom = topheight; + if (topheight > open[FRONT].bottom) { + open[FRONT].bottom = topheight; openbottomslope = *rover->t_slope; openbottompic = *rover->toppic; - openfloorrover = rover; + open[FRONT].floorrover = rover; } else if (topheight > lowfloor) lowfloor = topheight; @@ -810,11 +835,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) // thing is below FOF { - if (bottomheight < opentop) { - opentop = bottomheight; + if (bottomheight < open[BACK].top) { + open[BACK].top = bottomheight; opentopslope = *rover->b_slope; opentoppic = *rover->bottompic; - openceilingrover = rover; + open[BACK].ceilingrover = rover; } else if (bottomheight < highceiling) highceiling = bottomheight; @@ -822,16 +847,54 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 < delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_REVERSEPLATFORM) // thing is above FOF { - if (topheight > openbottom) { - openbottom = topheight; + if (topheight > open[BACK].bottom) { + open[BACK].bottom = topheight; openbottomslope = *rover->t_slope; openbottompic = *rover->toppic; - openfloorrover = rover; + open[BACK].floorrover = rover; } else if (topheight > lowfloor) lowfloor = topheight; } } + + lo = ( open[0].top > open[1].top ); + + if (open[lo].top <= oldopentop) + { + hi = ! lo; + + topedge[lo] = P_GetFFloorBottomZAt(open[lo].ceilingrover, cross.x, cross.y); + + if (open[hi].top < oldopentop) + { + topedge[hi] = P_GetFFloorBottomZAt(open[hi].ceilingrover, cross.x, cross.y); + } + + opentop = open[lo].top; + openceilingrover = open[lo].ceilingrover; + openceilingstep = ( thingtop - topedge[lo] ); + openceilingdrop = ( topedge[hi] - topedge[lo] ); + } + + hi = ( open[0].bottom < open[1].bottom ); + + if (open[hi].bottom >= oldopenbottom) + { + lo = ! hi; + + botedge[hi] = P_GetFFloorTopZAt(open[hi].floorrover, cross.x, cross.y); + + if (open[lo].bottom > oldopenbottom) + { + botedge[lo] = P_GetFFloorTopZAt(open[lo].floorrover, cross.x, cross.y); + } + + openbottom = open[hi].bottom; + openfloorrover = open[hi].floorrover; + openfloorstep = ( botedge[hi] - mobj->z ); + openfloordrop = ( botedge[hi] - botedge[lo] ); + } } } } diff --git a/src/p_maputl.h b/src/p_maputl.h index 936094498..29e7d4de9 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -61,6 +61,10 @@ boolean P_GetMidtextureTopBottom(line_t *linedef, fixed_t x, fixed_t y, fixed_t extern fixed_t opentop, openbottom, openrange, lowfloor, highceiling; extern pslope_t *opentopslope, *openbottomslope; extern ffloor_t *openfloorrover, *openceilingrover; +extern fixed_t openceilingstep; +extern fixed_t openceilingdrop; +extern fixed_t openfloorstep; +extern fixed_t openfloordrop; extern INT32 opentoppic, openbottompic; void P_LineOpening(line_t *plinedef, mobj_t *mobj); From 8e61036c9ea305a6b8b3b8090e704b010e73963a Mon Sep 17 00:00:00 2001 From: Wumbo <58399748+WumboSpasm@users.noreply.github.com> Date: Sat, 24 Aug 2024 17:07:48 -0400 Subject: [PATCH 18/26] Mostly revert "Revert Revert the-big-step-up since it has regressions" This reverts everything except P_TryMove, which fixes the Hill Top ramp without breaking the Opulence shortcut. --- src/p_map.c | 10 -- src/p_maputl.c | 245 ++++++++++++++++++------------------------------- src/p_maputl.h | 4 - 3 files changed, 91 insertions(+), 168 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index b36bb53e2..68980653e 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1567,11 +1567,6 @@ static BlockItReturn_t PIT_CheckLine(line_t *ld) tmceilingrover = openceilingrover; tmceilingslope = opentopslope; tmceilingpic = opentoppic; - tmceilingstep = openceilingstep; - if (thingtop == tmthing->ceilingz) - { - tmthing->ceilingdrop = openceilingdrop; - } } if (openbottom > tmfloorz) @@ -1580,11 +1575,6 @@ static BlockItReturn_t PIT_CheckLine(line_t *ld) tmfloorrover = openfloorrover; tmfloorslope = openbottomslope; tmfloorpic = openbottompic; - tmfloorstep = openfloorstep; - if (tmthing->z == tmthing->floorz) - { - tmthing->floordrop = openfloordrop; - } } if (highceiling > tmdrpoffceilz) diff --git a/src/p_maputl.c b/src/p_maputl.c index b4ae2f3ed..fe99e6f81 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -338,10 +338,6 @@ line_t * P_FindNearestLine fixed_t opentop, openbottom, openrange, lowfloor, highceiling; pslope_t *opentopslope, *openbottomslope; ffloor_t *openfloorrover, *openceilingrover; -fixed_t openceilingstep; -fixed_t openceilingdrop; -fixed_t openfloorstep; -fixed_t openfloordrop; INT32 opentoppic, openbottompic; // P_CameraLineOpening @@ -564,18 +560,7 @@ P_GetMidtextureTopBottom void P_LineOpening(line_t *linedef, mobj_t *mobj) { - enum { FRONT, BACK }; - sector_t *front, *back; - fixed_t thingtop = 0; - vertex_t cross; - - /* these init to shut compiler up */ - fixed_t topedge[2] = {0}; - fixed_t botedge[2] = {0}; - - int hi = 0; - int lo = 0; if (linedef->sidenum[1] == 0xffff) { @@ -584,8 +569,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) return; } - P_ClosestPointOnLine(tmx, tmy, linedef, &cross); - // Treat polyobjects kind of like 3D Floors if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT)) { @@ -601,11 +584,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) I_Assert(front != NULL); I_Assert(back != NULL); - if (mobj) - { - thingtop = mobj->z + mobj->height; - } - openfloorrover = openceilingrover = NULL; if (linedef->polyobj) { @@ -616,90 +594,110 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) lowfloor = INT32_MAX; opentopslope = openbottomslope = NULL; opentoppic = openbottompic = -1; - openceilingstep = 0; - openceilingdrop = 0; - openfloorstep = 0; - openfloordrop = 0; } else { // Set open and high/low values here - fixed_t height[2]; + fixed_t frontheight, backheight; const sector_t * sector[2] = { front, back }; - height[FRONT] = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); - height[BACK] = P_GetCeilingZ(mobj, back, tmx, tmy, linedef); + frontheight = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); + backheight = P_GetCeilingZ(mobj, back, tmx, tmy, linedef); - hi = ( height[0] < height[1] ); - lo = ! hi; - - opentop = height[lo]; - highceiling = height[hi]; - opentopslope = sector[lo]->c_slope; - opentoppic = sector[lo]->ceilingpic; - - if (mobj) + if (frontheight < backheight) { - topedge[FRONT] = P_GetSectorCeilingZAt(front, cross.x, cross.y); - topedge[BACK] = P_GetSectorCeilingZAt(back, cross.x, cross.y); - - openceilingstep = ( thingtop - topedge[lo] ); - openceilingdrop = ( topedge[hi] - topedge[lo] ); + opentop = frontheight; + highceiling = backheight; + opentopslope = front->c_slope; + } + else + { + opentop = backheight; + highceiling = frontheight; + opentopslope = back->c_slope; } - height[FRONT] = P_GetFloorZ(mobj, front, tmx, tmy, linedef); - height[BACK] = P_GetFloorZ(mobj, back, tmx, tmy, linedef); + frontheight = P_GetFloorZ(mobj, front, tmx, tmy, linedef); + backheight = P_GetFloorZ(mobj, back, tmx, tmy, linedef); - hi = ( height[0] < height[1] ); - lo = ! hi; - - openbottom = height[hi]; - lowfloor = height[lo]; - openbottomslope = sector[hi]->f_slope; - openbottompic = sector[hi]->floorpic; - - if (mobj) + if (frontheight > backheight) { - botedge[FRONT] = P_GetSectorFloorZAt(front, cross.x, cross.y); - botedge[BACK] = P_GetSectorFloorZAt(back, cross.x, cross.y); - - openfloorstep = ( botedge[hi] - mobj->z ); - openfloordrop = ( botedge[hi] - botedge[lo] ); + openbottom = frontheight; + lowfloor = backheight; + openbottomslope = front->f_slope; } + else + { + openbottom = backheight; + lowfloor = frontheight; + openbottomslope = back->f_slope; + } + + opentoppic = sector[!(frontheight < backheight)]->ceilingpic; + openbottompic = sector[frontheight < backheight]->floorpic; } if (mobj) { + fixed_t thingtop = mobj->z + mobj->height; + // Check for collision with front side's midtexture if Effect 4 is set if ((linedef->flags & ML_EFFECT4 || (mobj->player && P_IsLineTripWire(linedef) && !K_TripwirePass(mobj->player))) && !linedef->polyobj // don't do anything for polyobjects! ...for now ) { - fixed_t textop, texbottom; + side_t *side = &sides[linedef->sidenum[0]]; + fixed_t textop, texbottom, texheight; fixed_t texmid, delta1, delta2; + INT32 texnum = R_GetTextureNum(side->midtexture); // make sure the texture is actually valid + vertex_t cross; - if (P_GetMidtextureTopBottom(linedef, cross.x, cross.y, &textop, &texbottom)) - { - texmid = texbottom+(textop-texbottom)/2; + if (texnum) { + // Get the midtexture's height + texheight = textures[texnum]->height << FRACBITS; - delta1 = abs(mobj->z - texmid); - delta2 = abs(thingtop - texmid); - - if (delta1 > delta2) { // Below - if (opentop > texbottom) - { - topedge[lo] -= ( opentop - texbottom ); - - opentop = texbottom; - openceilingstep = ( thingtop - topedge[lo] ); - openceilingdrop = ( topedge[hi] - topedge[lo] ); + // Set texbottom and textop to the Z coordinates of the texture's boundaries +#if 0 + // don't remove this code unless solid midtextures + // on non-solid polyobjects should NEVER happen in the future + if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT)) { + if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat + texbottom = back->floorheight + side->rowoffset; + textop = back->ceilingheight + side->rowoffset; + } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { + texbottom = back->floorheight + side->rowoffset; + textop = texbottom + texheight*(side->repeatcnt+1); + } else { + textop = back->ceilingheight + side->rowoffset; + texbottom = textop - texheight*(side->repeatcnt+1); } - } else { // Above - if (openbottom < textop) - { - botedge[hi] += ( textop - openbottom ); + } else +#endif + { + if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat + texbottom = openbottom + side->rowoffset; + textop = opentop + side->rowoffset; + } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { + texbottom = openbottom + side->rowoffset; + textop = texbottom + texheight*(side->repeatcnt+1); + } else { + textop = opentop + side->rowoffset; + texbottom = textop - texheight*(side->repeatcnt+1); + } + } + P_ClosestPointOnLine(tmx, tmy, linedef, &cross); + + if (P_GetMidtextureTopBottom(linedef, cross.x, cross.y, &textop, &texbottom)) + { + texmid = texbottom+(textop-texbottom)/2; - openbottom = textop; - openfloorstep = ( botedge[hi] - mobj->z ); - openfloordrop = ( botedge[hi] - botedge[lo] ); + delta1 = abs(mobj->z - texmid); + delta2 = abs(thingtop - texmid); + + if (delta1 > delta2) { // Below + if (opentop > texbottom) + opentop = texbottom; + } else { // Above + if (openbottom < textop) + openbottom = textop; } } } @@ -728,22 +726,14 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) delta2 = abs(thingtop - (polybottom + ((polytop - polybottom)/2))); if (polybottom < opentop && delta1 >= delta2) - { opentop = polybottom; - } else if (polybottom < highceiling && delta1 >= delta2) - { highceiling = polybottom; - } if (polytop > openbottom && delta1 < delta2) - { openbottom = polytop; - } else if (polytop > lowfloor && delta1 < delta2) - { lowfloor = polytop; - } } // otherwise don't do anything special, pretend there's nothing else there } @@ -755,21 +745,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) ffloor_t *rover; fixed_t delta1, delta2; - /* yuck */ - struct - { - fixed_t top; - fixed_t bottom; - ffloor_t * ceilingrover; - ffloor_t * floorrover; - } open[2] = { - { INT32_MAX, INT32_MIN, NULL, NULL }, - { INT32_MAX, INT32_MIN, NULL, NULL }, - }; - - const fixed_t oldopentop = opentop; - const fixed_t oldopenbottom = openbottom; - // Check for frontsector's fake floors for (rover = front->ffloors; rover; rover = rover->next) { @@ -791,11 +766,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) // thing is below FOF { - if (bottomheight < open[FRONT].top) { - open[FRONT].top = bottomheight; + if (bottomheight < opentop) { + opentop = bottomheight; opentopslope = *rover->b_slope; opentoppic = *rover->bottompic; - open[FRONT].ceilingrover = rover; + openceilingrover = rover; } else if (bottomheight < highceiling) highceiling = bottomheight; @@ -803,11 +778,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 < delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_REVERSEPLATFORM) // thing is above FOF { - if (topheight > open[FRONT].bottom) { - open[FRONT].bottom = topheight; + if (topheight > openbottom) { + openbottom = topheight; openbottomslope = *rover->t_slope; openbottompic = *rover->toppic; - open[FRONT].floorrover = rover; + openfloorrover = rover; } else if (topheight > lowfloor) lowfloor = topheight; @@ -835,11 +810,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) // thing is below FOF { - if (bottomheight < open[BACK].top) { - open[BACK].top = bottomheight; + if (bottomheight < opentop) { + opentop = bottomheight; opentopslope = *rover->b_slope; opentoppic = *rover->bottompic; - open[BACK].ceilingrover = rover; + openceilingrover = rover; } else if (bottomheight < highceiling) highceiling = bottomheight; @@ -847,54 +822,16 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 < delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_REVERSEPLATFORM) // thing is above FOF { - if (topheight > open[BACK].bottom) { - open[BACK].bottom = topheight; + if (topheight > openbottom) { + openbottom = topheight; openbottomslope = *rover->t_slope; openbottompic = *rover->toppic; - open[BACK].floorrover = rover; + openfloorrover = rover; } else if (topheight > lowfloor) lowfloor = topheight; } } - - lo = ( open[0].top > open[1].top ); - - if (open[lo].top <= oldopentop) - { - hi = ! lo; - - topedge[lo] = P_GetFFloorBottomZAt(open[lo].ceilingrover, cross.x, cross.y); - - if (open[hi].top < oldopentop) - { - topedge[hi] = P_GetFFloorBottomZAt(open[hi].ceilingrover, cross.x, cross.y); - } - - opentop = open[lo].top; - openceilingrover = open[lo].ceilingrover; - openceilingstep = ( thingtop - topedge[lo] ); - openceilingdrop = ( topedge[hi] - topedge[lo] ); - } - - hi = ( open[0].bottom < open[1].bottom ); - - if (open[hi].bottom >= oldopenbottom) - { - lo = ! hi; - - botedge[hi] = P_GetFFloorTopZAt(open[hi].floorrover, cross.x, cross.y); - - if (open[lo].bottom > oldopenbottom) - { - botedge[lo] = P_GetFFloorTopZAt(open[lo].floorrover, cross.x, cross.y); - } - - openbottom = open[hi].bottom; - openfloorrover = open[hi].floorrover; - openfloorstep = ( botedge[hi] - mobj->z ); - openfloordrop = ( botedge[hi] - botedge[lo] ); - } } } } diff --git a/src/p_maputl.h b/src/p_maputl.h index 29e7d4de9..936094498 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -61,10 +61,6 @@ boolean P_GetMidtextureTopBottom(line_t *linedef, fixed_t x, fixed_t y, fixed_t extern fixed_t opentop, openbottom, openrange, lowfloor, highceiling; extern pslope_t *opentopslope, *openbottomslope; extern ffloor_t *openfloorrover, *openceilingrover; -extern fixed_t openceilingstep; -extern fixed_t openceilingdrop; -extern fixed_t openfloorstep; -extern fixed_t openfloordrop; extern INT32 opentoppic, openbottompic; void P_LineOpening(line_t *plinedef, mobj_t *mobj); From 8e83dfb934ee7fccc90ce3b33db137d30100f33d Mon Sep 17 00:00:00 2001 From: Wumbo <58399748+WumboSpasm@users.noreply.github.com> Date: Sun, 25 Aug 2024 00:53:28 -0400 Subject: [PATCH 19/26] Fix the Hill Top ramps without breaking everything else this time --- src/p_maputl.c | 143 ++++++++++++++++--------------------------------- 1 file changed, 45 insertions(+), 98 deletions(-) diff --git a/src/p_maputl.c b/src/p_maputl.c index b4ae2f3ed..6e010d84c 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -670,36 +670,44 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (mobj) { // Check for collision with front side's midtexture if Effect 4 is set - if ((linedef->flags & ML_EFFECT4 || (mobj->player && P_IsLineTripWire(linedef) && !K_TripwirePass(mobj->player))) - && !linedef->polyobj // don't do anything for polyobjects! ...for now - ) { - fixed_t textop, texbottom; + if (linedef->flags & ML_EFFECT4 && !linedef->polyobj) // don't do anything for polyobjects! ...for now + { + side_t *side = &sides[linedef->sidenum[0]]; + fixed_t textop, texbottom, texheight; fixed_t texmid, delta1, delta2; + INT32 texnum = R_GetTextureNum(side->midtexture); // make sure the texture is actually valid - if (P_GetMidtextureTopBottom(linedef, cross.x, cross.y, &textop, &texbottom)) - { - texmid = texbottom+(textop-texbottom)/2; + if (texnum) { + // Get the midtexture's height + texheight = textures[texnum]->height << FRACBITS; - delta1 = abs(mobj->z - texmid); - delta2 = abs(thingtop - texmid); - - if (delta1 > delta2) { // Below - if (opentop > texbottom) - { - topedge[lo] -= ( opentop - texbottom ); - - opentop = texbottom; - openceilingstep = ( thingtop - topedge[lo] ); - openceilingdrop = ( topedge[hi] - topedge[lo] ); + // Set texbottom and textop to the Z coordinates of the texture's boundaries + { + if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat + texbottom = openbottom + side->rowoffset; + textop = opentop + side->rowoffset; + } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { + texbottom = openbottom + side->rowoffset; + textop = texbottom + texheight*(side->repeatcnt+1); + } else { + textop = opentop + side->rowoffset; + texbottom = textop - texheight*(side->repeatcnt+1); } - } else { // Above - if (openbottom < textop) - { - botedge[hi] += ( textop - openbottom ); + } + + if (P_GetMidtextureTopBottom(linedef, cross.x, cross.y, &textop, &texbottom)) + { + texmid = texbottom+(textop-texbottom)/2; - openbottom = textop; - openfloorstep = ( botedge[hi] - mobj->z ); - openfloordrop = ( botedge[hi] - botedge[lo] ); + delta1 = abs(mobj->z - texmid); + delta2 = abs(thingtop - texmid); + + if (delta1 > delta2) { // Below + if (opentop > texbottom) + opentop = texbottom; + } else { // Above + if (openbottom < textop) + openbottom = textop; } } } @@ -728,22 +736,14 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) delta2 = abs(thingtop - (polybottom + ((polytop - polybottom)/2))); if (polybottom < opentop && delta1 >= delta2) - { opentop = polybottom; - } else if (polybottom < highceiling && delta1 >= delta2) - { highceiling = polybottom; - } if (polytop > openbottom && delta1 < delta2) - { openbottom = polytop; - } else if (polytop > lowfloor && delta1 < delta2) - { lowfloor = polytop; - } } // otherwise don't do anything special, pretend there's nothing else there } @@ -755,21 +755,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) ffloor_t *rover; fixed_t delta1, delta2; - /* yuck */ - struct - { - fixed_t top; - fixed_t bottom; - ffloor_t * ceilingrover; - ffloor_t * floorrover; - } open[2] = { - { INT32_MAX, INT32_MIN, NULL, NULL }, - { INT32_MAX, INT32_MIN, NULL, NULL }, - }; - - const fixed_t oldopentop = opentop; - const fixed_t oldopenbottom = openbottom; - // Check for frontsector's fake floors for (rover = front->ffloors; rover; rover = rover->next) { @@ -791,11 +776,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) // thing is below FOF { - if (bottomheight < open[FRONT].top) { - open[FRONT].top = bottomheight; + if (bottomheight < opentop) { + opentop = bottomheight; opentopslope = *rover->b_slope; opentoppic = *rover->bottompic; - open[FRONT].ceilingrover = rover; + openceilingrover = rover; } else if (bottomheight < highceiling) highceiling = bottomheight; @@ -803,11 +788,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 < delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_REVERSEPLATFORM) // thing is above FOF { - if (topheight > open[FRONT].bottom) { - open[FRONT].bottom = topheight; + if (topheight > openbottom) { + openbottom = topheight; openbottomslope = *rover->t_slope; openbottompic = *rover->toppic; - open[FRONT].floorrover = rover; + openfloorrover = rover; } else if (topheight > lowfloor) lowfloor = topheight; @@ -835,11 +820,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) // thing is below FOF { - if (bottomheight < open[BACK].top) { - open[BACK].top = bottomheight; + if (bottomheight < opentop) { + opentop = bottomheight; opentopslope = *rover->b_slope; opentoppic = *rover->bottompic; - open[BACK].ceilingrover = rover; + openceilingrover = rover; } else if (bottomheight < highceiling) highceiling = bottomheight; @@ -847,54 +832,16 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 < delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_REVERSEPLATFORM) // thing is above FOF { - if (topheight > open[BACK].bottom) { - open[BACK].bottom = topheight; + if (topheight > openbottom) { + openbottom = topheight; openbottomslope = *rover->t_slope; openbottompic = *rover->toppic; - open[BACK].floorrover = rover; + openfloorrover = rover; } else if (topheight > lowfloor) lowfloor = topheight; } } - - lo = ( open[0].top > open[1].top ); - - if (open[lo].top <= oldopentop) - { - hi = ! lo; - - topedge[lo] = P_GetFFloorBottomZAt(open[lo].ceilingrover, cross.x, cross.y); - - if (open[hi].top < oldopentop) - { - topedge[hi] = P_GetFFloorBottomZAt(open[hi].ceilingrover, cross.x, cross.y); - } - - opentop = open[lo].top; - openceilingrover = open[lo].ceilingrover; - openceilingstep = ( thingtop - topedge[lo] ); - openceilingdrop = ( topedge[hi] - topedge[lo] ); - } - - hi = ( open[0].bottom < open[1].bottom ); - - if (open[hi].bottom >= oldopenbottom) - { - lo = ! hi; - - botedge[hi] = P_GetFFloorTopZAt(open[hi].floorrover, cross.x, cross.y); - - if (open[lo].bottom > oldopenbottom) - { - botedge[lo] = P_GetFFloorTopZAt(open[lo].floorrover, cross.x, cross.y); - } - - openbottom = open[hi].bottom; - openfloorrover = open[hi].floorrover; - openfloorstep = ( botedge[hi] - mobj->z ); - openfloordrop = ( botedge[hi] - botedge[lo] ); - } } } } From 6491960430a2ebaf4fb9848d1c73552a9f1fbbee Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Sun, 25 Aug 2024 01:03:24 -0400 Subject: [PATCH 20/26] Revert "Mostly revert "Revert Revert the-big-step-up since it has regressions"" This reverts commit 8e61036c9ea305a6b8b3b8090e704b010e73963a. --- src/p_map.c | 10 ++ src/p_maputl.c | 245 +++++++++++++++++++++++++++++++------------------ src/p_maputl.h | 4 + 3 files changed, 168 insertions(+), 91 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 68980653e..b36bb53e2 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1567,6 +1567,11 @@ static BlockItReturn_t PIT_CheckLine(line_t *ld) tmceilingrover = openceilingrover; tmceilingslope = opentopslope; tmceilingpic = opentoppic; + tmceilingstep = openceilingstep; + if (thingtop == tmthing->ceilingz) + { + tmthing->ceilingdrop = openceilingdrop; + } } if (openbottom > tmfloorz) @@ -1575,6 +1580,11 @@ static BlockItReturn_t PIT_CheckLine(line_t *ld) tmfloorrover = openfloorrover; tmfloorslope = openbottomslope; tmfloorpic = openbottompic; + tmfloorstep = openfloorstep; + if (tmthing->z == tmthing->floorz) + { + tmthing->floordrop = openfloordrop; + } } if (highceiling > tmdrpoffceilz) diff --git a/src/p_maputl.c b/src/p_maputl.c index fe99e6f81..b4ae2f3ed 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -338,6 +338,10 @@ line_t * P_FindNearestLine fixed_t opentop, openbottom, openrange, lowfloor, highceiling; pslope_t *opentopslope, *openbottomslope; ffloor_t *openfloorrover, *openceilingrover; +fixed_t openceilingstep; +fixed_t openceilingdrop; +fixed_t openfloorstep; +fixed_t openfloordrop; INT32 opentoppic, openbottompic; // P_CameraLineOpening @@ -560,7 +564,18 @@ P_GetMidtextureTopBottom void P_LineOpening(line_t *linedef, mobj_t *mobj) { + enum { FRONT, BACK }; + sector_t *front, *back; + fixed_t thingtop = 0; + vertex_t cross; + + /* these init to shut compiler up */ + fixed_t topedge[2] = {0}; + fixed_t botedge[2] = {0}; + + int hi = 0; + int lo = 0; if (linedef->sidenum[1] == 0xffff) { @@ -569,6 +584,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) return; } + P_ClosestPointOnLine(tmx, tmy, linedef, &cross); + // Treat polyobjects kind of like 3D Floors if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT)) { @@ -584,6 +601,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) I_Assert(front != NULL); I_Assert(back != NULL); + if (mobj) + { + thingtop = mobj->z + mobj->height; + } + openfloorrover = openceilingrover = NULL; if (linedef->polyobj) { @@ -594,110 +616,90 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) lowfloor = INT32_MAX; opentopslope = openbottomslope = NULL; opentoppic = openbottompic = -1; + openceilingstep = 0; + openceilingdrop = 0; + openfloorstep = 0; + openfloordrop = 0; } else { // Set open and high/low values here - fixed_t frontheight, backheight; + fixed_t height[2]; const sector_t * sector[2] = { front, back }; - frontheight = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); - backheight = P_GetCeilingZ(mobj, back, tmx, tmy, linedef); + height[FRONT] = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); + height[BACK] = P_GetCeilingZ(mobj, back, tmx, tmy, linedef); - if (frontheight < backheight) + hi = ( height[0] < height[1] ); + lo = ! hi; + + opentop = height[lo]; + highceiling = height[hi]; + opentopslope = sector[lo]->c_slope; + opentoppic = sector[lo]->ceilingpic; + + if (mobj) { - opentop = frontheight; - highceiling = backheight; - opentopslope = front->c_slope; - } - else - { - opentop = backheight; - highceiling = frontheight; - opentopslope = back->c_slope; + topedge[FRONT] = P_GetSectorCeilingZAt(front, cross.x, cross.y); + topedge[BACK] = P_GetSectorCeilingZAt(back, cross.x, cross.y); + + openceilingstep = ( thingtop - topedge[lo] ); + openceilingdrop = ( topedge[hi] - topedge[lo] ); } - frontheight = P_GetFloorZ(mobj, front, tmx, tmy, linedef); - backheight = P_GetFloorZ(mobj, back, tmx, tmy, linedef); + height[FRONT] = P_GetFloorZ(mobj, front, tmx, tmy, linedef); + height[BACK] = P_GetFloorZ(mobj, back, tmx, tmy, linedef); - if (frontheight > backheight) + hi = ( height[0] < height[1] ); + lo = ! hi; + + openbottom = height[hi]; + lowfloor = height[lo]; + openbottomslope = sector[hi]->f_slope; + openbottompic = sector[hi]->floorpic; + + if (mobj) { - openbottom = frontheight; - lowfloor = backheight; - openbottomslope = front->f_slope; + botedge[FRONT] = P_GetSectorFloorZAt(front, cross.x, cross.y); + botedge[BACK] = P_GetSectorFloorZAt(back, cross.x, cross.y); + + openfloorstep = ( botedge[hi] - mobj->z ); + openfloordrop = ( botedge[hi] - botedge[lo] ); } - else - { - openbottom = backheight; - lowfloor = frontheight; - openbottomslope = back->f_slope; - } - - opentoppic = sector[!(frontheight < backheight)]->ceilingpic; - openbottompic = sector[frontheight < backheight]->floorpic; } if (mobj) { - fixed_t thingtop = mobj->z + mobj->height; - // Check for collision with front side's midtexture if Effect 4 is set if ((linedef->flags & ML_EFFECT4 || (mobj->player && P_IsLineTripWire(linedef) && !K_TripwirePass(mobj->player))) && !linedef->polyobj // don't do anything for polyobjects! ...for now ) { - side_t *side = &sides[linedef->sidenum[0]]; - fixed_t textop, texbottom, texheight; + fixed_t textop, texbottom; fixed_t texmid, delta1, delta2; - INT32 texnum = R_GetTextureNum(side->midtexture); // make sure the texture is actually valid - vertex_t cross; - if (texnum) { - // Get the midtexture's height - texheight = textures[texnum]->height << FRACBITS; + if (P_GetMidtextureTopBottom(linedef, cross.x, cross.y, &textop, &texbottom)) + { + texmid = texbottom+(textop-texbottom)/2; - // Set texbottom and textop to the Z coordinates of the texture's boundaries -#if 0 - // don't remove this code unless solid midtextures - // on non-solid polyobjects should NEVER happen in the future - if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT)) { - if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat - texbottom = back->floorheight + side->rowoffset; - textop = back->ceilingheight + side->rowoffset; - } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { - texbottom = back->floorheight + side->rowoffset; - textop = texbottom + texheight*(side->repeatcnt+1); - } else { - textop = back->ceilingheight + side->rowoffset; - texbottom = textop - texheight*(side->repeatcnt+1); + delta1 = abs(mobj->z - texmid); + delta2 = abs(thingtop - texmid); + + if (delta1 > delta2) { // Below + if (opentop > texbottom) + { + topedge[lo] -= ( opentop - texbottom ); + + opentop = texbottom; + openceilingstep = ( thingtop - topedge[lo] ); + openceilingdrop = ( topedge[hi] - topedge[lo] ); } - } else -#endif - { - if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat - texbottom = openbottom + side->rowoffset; - textop = opentop + side->rowoffset; - } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { - texbottom = openbottom + side->rowoffset; - textop = texbottom + texheight*(side->repeatcnt+1); - } else { - textop = opentop + side->rowoffset; - texbottom = textop - texheight*(side->repeatcnt+1); - } - } - P_ClosestPointOnLine(tmx, tmy, linedef, &cross); - - if (P_GetMidtextureTopBottom(linedef, cross.x, cross.y, &textop, &texbottom)) - { - texmid = texbottom+(textop-texbottom)/2; + } else { // Above + if (openbottom < textop) + { + botedge[hi] += ( textop - openbottom ); - delta1 = abs(mobj->z - texmid); - delta2 = abs(thingtop - texmid); - - if (delta1 > delta2) { // Below - if (opentop > texbottom) - opentop = texbottom; - } else { // Above - if (openbottom < textop) - openbottom = textop; + openbottom = textop; + openfloorstep = ( botedge[hi] - mobj->z ); + openfloordrop = ( botedge[hi] - botedge[lo] ); } } } @@ -726,14 +728,22 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) delta2 = abs(thingtop - (polybottom + ((polytop - polybottom)/2))); if (polybottom < opentop && delta1 >= delta2) + { opentop = polybottom; + } else if (polybottom < highceiling && delta1 >= delta2) + { highceiling = polybottom; + } if (polytop > openbottom && delta1 < delta2) + { openbottom = polytop; + } else if (polytop > lowfloor && delta1 < delta2) + { lowfloor = polytop; + } } // otherwise don't do anything special, pretend there's nothing else there } @@ -745,6 +755,21 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) ffloor_t *rover; fixed_t delta1, delta2; + /* yuck */ + struct + { + fixed_t top; + fixed_t bottom; + ffloor_t * ceilingrover; + ffloor_t * floorrover; + } open[2] = { + { INT32_MAX, INT32_MIN, NULL, NULL }, + { INT32_MAX, INT32_MIN, NULL, NULL }, + }; + + const fixed_t oldopentop = opentop; + const fixed_t oldopenbottom = openbottom; + // Check for frontsector's fake floors for (rover = front->ffloors; rover; rover = rover->next) { @@ -766,11 +791,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) // thing is below FOF { - if (bottomheight < opentop) { - opentop = bottomheight; + if (bottomheight < open[FRONT].top) { + open[FRONT].top = bottomheight; opentopslope = *rover->b_slope; opentoppic = *rover->bottompic; - openceilingrover = rover; + open[FRONT].ceilingrover = rover; } else if (bottomheight < highceiling) highceiling = bottomheight; @@ -778,11 +803,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 < delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_REVERSEPLATFORM) // thing is above FOF { - if (topheight > openbottom) { - openbottom = topheight; + if (topheight > open[FRONT].bottom) { + open[FRONT].bottom = topheight; openbottomslope = *rover->t_slope; openbottompic = *rover->toppic; - openfloorrover = rover; + open[FRONT].floorrover = rover; } else if (topheight > lowfloor) lowfloor = topheight; @@ -810,11 +835,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) // thing is below FOF { - if (bottomheight < opentop) { - opentop = bottomheight; + if (bottomheight < open[BACK].top) { + open[BACK].top = bottomheight; opentopslope = *rover->b_slope; opentoppic = *rover->bottompic; - openceilingrover = rover; + open[BACK].ceilingrover = rover; } else if (bottomheight < highceiling) highceiling = bottomheight; @@ -822,16 +847,54 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 < delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_REVERSEPLATFORM) // thing is above FOF { - if (topheight > openbottom) { - openbottom = topheight; + if (topheight > open[BACK].bottom) { + open[BACK].bottom = topheight; openbottomslope = *rover->t_slope; openbottompic = *rover->toppic; - openfloorrover = rover; + open[BACK].floorrover = rover; } else if (topheight > lowfloor) lowfloor = topheight; } } + + lo = ( open[0].top > open[1].top ); + + if (open[lo].top <= oldopentop) + { + hi = ! lo; + + topedge[lo] = P_GetFFloorBottomZAt(open[lo].ceilingrover, cross.x, cross.y); + + if (open[hi].top < oldopentop) + { + topedge[hi] = P_GetFFloorBottomZAt(open[hi].ceilingrover, cross.x, cross.y); + } + + opentop = open[lo].top; + openceilingrover = open[lo].ceilingrover; + openceilingstep = ( thingtop - topedge[lo] ); + openceilingdrop = ( topedge[hi] - topedge[lo] ); + } + + hi = ( open[0].bottom < open[1].bottom ); + + if (open[hi].bottom >= oldopenbottom) + { + lo = ! hi; + + botedge[hi] = P_GetFFloorTopZAt(open[hi].floorrover, cross.x, cross.y); + + if (open[lo].bottom > oldopenbottom) + { + botedge[lo] = P_GetFFloorTopZAt(open[lo].floorrover, cross.x, cross.y); + } + + openbottom = open[hi].bottom; + openfloorrover = open[hi].floorrover; + openfloorstep = ( botedge[hi] - mobj->z ); + openfloordrop = ( botedge[hi] - botedge[lo] ); + } } } } diff --git a/src/p_maputl.h b/src/p_maputl.h index 936094498..29e7d4de9 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -61,6 +61,10 @@ boolean P_GetMidtextureTopBottom(line_t *linedef, fixed_t x, fixed_t y, fixed_t extern fixed_t opentop, openbottom, openrange, lowfloor, highceiling; extern pslope_t *opentopslope, *openbottomslope; extern ffloor_t *openfloorrover, *openceilingrover; +extern fixed_t openceilingstep; +extern fixed_t openceilingdrop; +extern fixed_t openfloorstep; +extern fixed_t openfloordrop; extern INT32 opentoppic, openbottompic; void P_LineOpening(line_t *plinedef, mobj_t *mobj); From 84a9a6fbcc8b749aab13b3d5c65e9a273d87248f Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Thu, 29 Aug 2024 19:53:06 -0400 Subject: [PATCH 21/26] Fix code here and make tripwires work again --- src/p_maputl.c | 52 ++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/src/p_maputl.c b/src/p_maputl.c index 6e010d84c..ae681323c 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -670,44 +670,42 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (mobj) { // Check for collision with front side's midtexture if Effect 4 is set - if (linedef->flags & ML_EFFECT4 && !linedef->polyobj) // don't do anything for polyobjects! ...for now + if ((linedef->flags & ML_EFFECT4 || (mobj->player && P_IsLineTripWire(linedef) && !K_TripwirePass(mobj->player))) + && !linedef->polyobj) // don't do anything for polyobjects! ...for now { side_t *side = &sides[linedef->sidenum[0]]; fixed_t textop, texbottom, texheight; fixed_t texmid, delta1, delta2; - INT32 texnum = R_GetTextureNum(side->midtexture); // make sure the texture is actually valid - if (texnum) { - // Get the midtexture's height - texheight = textures[texnum]->height << FRACBITS; + if (P_GetMidtextureTopBottom(linedef, cross.x, cross.y, &textop, &texbottom)) + { + texmid = texbottom+(textop-texbottom)/2; - // Set texbottom and textop to the Z coordinates of the texture's boundaries + delta1 = abs(mobj->z - texmid); + delta2 = abs(thingtop - texmid); + + if (delta1 > delta2) { - if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat - texbottom = openbottom + side->rowoffset; - textop = opentop + side->rowoffset; - } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { - texbottom = openbottom + side->rowoffset; - textop = texbottom + texheight*(side->repeatcnt+1); - } else { - textop = opentop + side->rowoffset; - texbottom = textop - texheight*(side->repeatcnt+1); + // Below + if (opentop > texbottom) + { + topedge[lo] -= ( opentop - texbottom ); + + opentop = texbottom; + openceilingstep = ( thingtop - topedge[lo] ); + openceilingdrop = ( topedge[hi] - topedge[lo] ); } } - - if (P_GetMidtextureTopBottom(linedef, cross.x, cross.y, &textop, &texbottom)) + else { - texmid = texbottom+(textop-texbottom)/2; + // Above + if (openbottom < textop) + { + botedge[hi] += ( textop - openbottom ); - delta1 = abs(mobj->z - texmid); - delta2 = abs(thingtop - texmid); - - if (delta1 > delta2) { // Below - if (opentop > texbottom) - opentop = texbottom; - } else { // Above - if (openbottom < textop) - openbottom = textop; + openbottom = textop; + openfloorstep = ( botedge[hi] - mobj->z ); + openfloordrop = ( botedge[hi] - botedge[lo] ); } } } From f6dd00f3f1e2686dc198c36ccf11284447d293a9 Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Sun, 1 Sep 2024 19:16:16 -0400 Subject: [PATCH 22/26] Revert "Fix code here and make tripwires work again" This reverts commit 84a9a6fbcc8b749aab13b3d5c65e9a273d87248f. --- src/p_maputl.c | 52 ++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/src/p_maputl.c b/src/p_maputl.c index ae681323c..6e010d84c 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -670,42 +670,44 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (mobj) { // Check for collision with front side's midtexture if Effect 4 is set - if ((linedef->flags & ML_EFFECT4 || (mobj->player && P_IsLineTripWire(linedef) && !K_TripwirePass(mobj->player))) - && !linedef->polyobj) // don't do anything for polyobjects! ...for now + if (linedef->flags & ML_EFFECT4 && !linedef->polyobj) // don't do anything for polyobjects! ...for now { side_t *side = &sides[linedef->sidenum[0]]; fixed_t textop, texbottom, texheight; fixed_t texmid, delta1, delta2; + INT32 texnum = R_GetTextureNum(side->midtexture); // make sure the texture is actually valid - if (P_GetMidtextureTopBottom(linedef, cross.x, cross.y, &textop, &texbottom)) - { - texmid = texbottom+(textop-texbottom)/2; + if (texnum) { + // Get the midtexture's height + texheight = textures[texnum]->height << FRACBITS; - delta1 = abs(mobj->z - texmid); - delta2 = abs(thingtop - texmid); - - if (delta1 > delta2) + // Set texbottom and textop to the Z coordinates of the texture's boundaries { - // Below - if (opentop > texbottom) - { - topedge[lo] -= ( opentop - texbottom ); - - opentop = texbottom; - openceilingstep = ( thingtop - topedge[lo] ); - openceilingdrop = ( topedge[hi] - topedge[lo] ); + if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat + texbottom = openbottom + side->rowoffset; + textop = opentop + side->rowoffset; + } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { + texbottom = openbottom + side->rowoffset; + textop = texbottom + texheight*(side->repeatcnt+1); + } else { + textop = opentop + side->rowoffset; + texbottom = textop - texheight*(side->repeatcnt+1); } } - else + + if (P_GetMidtextureTopBottom(linedef, cross.x, cross.y, &textop, &texbottom)) { - // Above - if (openbottom < textop) - { - botedge[hi] += ( textop - openbottom ); + texmid = texbottom+(textop-texbottom)/2; - openbottom = textop; - openfloorstep = ( botedge[hi] - mobj->z ); - openfloordrop = ( botedge[hi] - botedge[lo] ); + delta1 = abs(mobj->z - texmid); + delta2 = abs(thingtop - texmid); + + if (delta1 > delta2) { // Below + if (opentop > texbottom) + opentop = texbottom; + } else { // Above + if (openbottom < textop) + openbottom = textop; } } } From 87bf09c82ff94dff708da9aaf61f736d23113e2d Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Sun, 1 Sep 2024 19:16:31 -0400 Subject: [PATCH 23/26] Revert Merge pull request #8 from WumboSpasm/slopeslop This reverts commit d516801bb5e424cb3ca4208ef358d00161a163f2, reversing changes made to 6491960430a2ebaf4fb9848d1c73552a9f1fbbee. --- src/p_maputl.c | 143 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 98 insertions(+), 45 deletions(-) diff --git a/src/p_maputl.c b/src/p_maputl.c index 6e010d84c..b4ae2f3ed 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -670,44 +670,36 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (mobj) { // Check for collision with front side's midtexture if Effect 4 is set - if (linedef->flags & ML_EFFECT4 && !linedef->polyobj) // don't do anything for polyobjects! ...for now - { - side_t *side = &sides[linedef->sidenum[0]]; - fixed_t textop, texbottom, texheight; + if ((linedef->flags & ML_EFFECT4 || (mobj->player && P_IsLineTripWire(linedef) && !K_TripwirePass(mobj->player))) + && !linedef->polyobj // don't do anything for polyobjects! ...for now + ) { + fixed_t textop, texbottom; fixed_t texmid, delta1, delta2; - INT32 texnum = R_GetTextureNum(side->midtexture); // make sure the texture is actually valid - if (texnum) { - // Get the midtexture's height - texheight = textures[texnum]->height << FRACBITS; + if (P_GetMidtextureTopBottom(linedef, cross.x, cross.y, &textop, &texbottom)) + { + texmid = texbottom+(textop-texbottom)/2; - // Set texbottom and textop to the Z coordinates of the texture's boundaries - { - if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat - texbottom = openbottom + side->rowoffset; - textop = opentop + side->rowoffset; - } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { - texbottom = openbottom + side->rowoffset; - textop = texbottom + texheight*(side->repeatcnt+1); - } else { - textop = opentop + side->rowoffset; - texbottom = textop - texheight*(side->repeatcnt+1); + delta1 = abs(mobj->z - texmid); + delta2 = abs(thingtop - texmid); + + if (delta1 > delta2) { // Below + if (opentop > texbottom) + { + topedge[lo] -= ( opentop - texbottom ); + + opentop = texbottom; + openceilingstep = ( thingtop - topedge[lo] ); + openceilingdrop = ( topedge[hi] - topedge[lo] ); } - } - - if (P_GetMidtextureTopBottom(linedef, cross.x, cross.y, &textop, &texbottom)) - { - texmid = texbottom+(textop-texbottom)/2; + } else { // Above + if (openbottom < textop) + { + botedge[hi] += ( textop - openbottom ); - delta1 = abs(mobj->z - texmid); - delta2 = abs(thingtop - texmid); - - if (delta1 > delta2) { // Below - if (opentop > texbottom) - opentop = texbottom; - } else { // Above - if (openbottom < textop) - openbottom = textop; + openbottom = textop; + openfloorstep = ( botedge[hi] - mobj->z ); + openfloordrop = ( botedge[hi] - botedge[lo] ); } } } @@ -736,14 +728,22 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) delta2 = abs(thingtop - (polybottom + ((polytop - polybottom)/2))); if (polybottom < opentop && delta1 >= delta2) + { opentop = polybottom; + } else if (polybottom < highceiling && delta1 >= delta2) + { highceiling = polybottom; + } if (polytop > openbottom && delta1 < delta2) + { openbottom = polytop; + } else if (polytop > lowfloor && delta1 < delta2) + { lowfloor = polytop; + } } // otherwise don't do anything special, pretend there's nothing else there } @@ -755,6 +755,21 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) ffloor_t *rover; fixed_t delta1, delta2; + /* yuck */ + struct + { + fixed_t top; + fixed_t bottom; + ffloor_t * ceilingrover; + ffloor_t * floorrover; + } open[2] = { + { INT32_MAX, INT32_MIN, NULL, NULL }, + { INT32_MAX, INT32_MIN, NULL, NULL }, + }; + + const fixed_t oldopentop = opentop; + const fixed_t oldopenbottom = openbottom; + // Check for frontsector's fake floors for (rover = front->ffloors; rover; rover = rover->next) { @@ -776,11 +791,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) // thing is below FOF { - if (bottomheight < opentop) { - opentop = bottomheight; + if (bottomheight < open[FRONT].top) { + open[FRONT].top = bottomheight; opentopslope = *rover->b_slope; opentoppic = *rover->bottompic; - openceilingrover = rover; + open[FRONT].ceilingrover = rover; } else if (bottomheight < highceiling) highceiling = bottomheight; @@ -788,11 +803,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 < delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_REVERSEPLATFORM) // thing is above FOF { - if (topheight > openbottom) { - openbottom = topheight; + if (topheight > open[FRONT].bottom) { + open[FRONT].bottom = topheight; openbottomslope = *rover->t_slope; openbottompic = *rover->toppic; - openfloorrover = rover; + open[FRONT].floorrover = rover; } else if (topheight > lowfloor) lowfloor = topheight; @@ -820,11 +835,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) // thing is below FOF { - if (bottomheight < opentop) { - opentop = bottomheight; + if (bottomheight < open[BACK].top) { + open[BACK].top = bottomheight; opentopslope = *rover->b_slope; opentoppic = *rover->bottompic; - openceilingrover = rover; + open[BACK].ceilingrover = rover; } else if (bottomheight < highceiling) highceiling = bottomheight; @@ -832,16 +847,54 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 < delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_REVERSEPLATFORM) // thing is above FOF { - if (topheight > openbottom) { - openbottom = topheight; + if (topheight > open[BACK].bottom) { + open[BACK].bottom = topheight; openbottomslope = *rover->t_slope; openbottompic = *rover->toppic; - openfloorrover = rover; + open[BACK].floorrover = rover; } else if (topheight > lowfloor) lowfloor = topheight; } } + + lo = ( open[0].top > open[1].top ); + + if (open[lo].top <= oldopentop) + { + hi = ! lo; + + topedge[lo] = P_GetFFloorBottomZAt(open[lo].ceilingrover, cross.x, cross.y); + + if (open[hi].top < oldopentop) + { + topedge[hi] = P_GetFFloorBottomZAt(open[hi].ceilingrover, cross.x, cross.y); + } + + opentop = open[lo].top; + openceilingrover = open[lo].ceilingrover; + openceilingstep = ( thingtop - topedge[lo] ); + openceilingdrop = ( topedge[hi] - topedge[lo] ); + } + + hi = ( open[0].bottom < open[1].bottom ); + + if (open[hi].bottom >= oldopenbottom) + { + lo = ! hi; + + botedge[hi] = P_GetFFloorTopZAt(open[hi].floorrover, cross.x, cross.y); + + if (open[lo].bottom > oldopenbottom) + { + botedge[lo] = P_GetFFloorTopZAt(open[lo].floorrover, cross.x, cross.y); + } + + openbottom = open[hi].bottom; + openfloorrover = open[hi].floorrover; + openfloorstep = ( botedge[hi] - mobj->z ); + openfloordrop = ( botedge[hi] - botedge[lo] ); + } } } } From f3d563898e0a41144ba9745c436774da68a5dddc Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Sun, 1 Sep 2024 19:46:56 -0400 Subject: [PATCH 24/26] Port this --- src/p_maputl.c | 52 ++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/src/p_maputl.c b/src/p_maputl.c index b4ae2f3ed..357831b74 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -577,10 +577,20 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) int hi = 0; int lo = 0; + // set these defaults so that polyobjects don't interfere with collision above or below them + opentop = highceiling = INT32_MAX; + openbottom = lowfloor = INT32_MIN; + openrange = 0; + opentopslope = openbottomslope = NULL; + opentoppic = openbottompic = -1; + openceilingstep = 0; + openceilingdrop = 0; + openfloorstep = 0; + openfloordrop = 0; + if (linedef->sidenum[1] == 0xffff) { // single sided line - openrange = 0; return; } @@ -607,22 +617,9 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) } openfloorrover = openceilingrover = NULL; - if (linedef->polyobj) + if (!linedef->polyobj) { - // set these defaults so that polyobjects don't interfere with collision above or below them - opentop = INT32_MAX; - openbottom = INT32_MIN; - highceiling = INT32_MIN; - lowfloor = INT32_MAX; - opentopslope = openbottomslope = NULL; - opentoppic = openbottompic = -1; - openceilingstep = 0; - openceilingdrop = 0; - openfloorstep = 0; - openfloordrop = 0; - } - else - { // Set open and high/low values here + // Set open and high/low values here fixed_t height[2]; const sector_t * sector[2] = { front, back }; @@ -735,15 +732,10 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) { highceiling = polybottom; } - - if (polytop > openbottom && delta1 < delta2) + else { openbottom = polytop; } - else if (polytop > lowfloor && delta1 < delta2) - { - lowfloor = polytop; - } } // otherwise don't do anything special, pretend there's nothing else there } @@ -800,8 +792,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) else if (bottomheight < highceiling) highceiling = bottomheight; } - - if (delta1 < delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_REVERSEPLATFORM) // thing is above FOF + else { if (topheight > open[FRONT].bottom) { open[FRONT].bottom = topheight; @@ -844,8 +835,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) else if (bottomheight < highceiling) highceiling = bottomheight; } - - if (delta1 < delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_REVERSEPLATFORM) // thing is above FOF + else { if (topheight > open[BACK].bottom) { open[BACK].bottom = topheight; @@ -893,7 +883,15 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) openbottom = open[hi].bottom; openfloorrover = open[hi].floorrover; openfloorstep = ( botedge[hi] - mobj->z ); - openfloordrop = ( botedge[hi] - botedge[lo] ); + + if (open[lo].bottom > lowfloor) + { + lowfloor = open[lo].bottom; + } + } + else if (open[hi].bottom > lowfloor) + { + lowfloor = open[hi].bottom; } } } From 6bcca94805a49649954e12622c13d02925bf552d Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 13 May 2023 00:39:36 -0400 Subject: [PATCH 25/26] Local P_LineOpening result P_LineOpening results are stored in a locally made struct instead of being a bunch of disorganized globals. --- src/p_map.c | 78 +++++---- src/p_maputl.c | 438 ++++++++++++++++++++++++++----------------------- src/p_maputl.h | 25 +-- src/p_sight.c | 20 ++- 4 files changed, 300 insertions(+), 261 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index b36bb53e2..1ada250f5 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1400,6 +1400,8 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) // Adjusts tmfloorz and tmceilingz as lines are contacted - FOR CAMERA ONLY static BlockItReturn_t PIT_CheckCameraLine(line_t *ld) { + opening_t open = {0}; + if (ld->polyobj && !(ld->polyobj->flags & POF_SOLID)) return BMIT_CONTINUE; @@ -1433,25 +1435,25 @@ static BlockItReturn_t PIT_CheckCameraLine(line_t *ld) } // set openrange, opentop, openbottom - P_CameraLineOpening(ld); + P_CameraLineOpening(ld, &open); // adjust floor / ceiling heights - if (opentop < tmceilingz) + if (open.ceiling < tmceilingz) { - tmceilingz = opentop; + tmceilingz = open.ceiling; ceilingline = ld; } - if (openbottom > tmfloorz) + if (open.floor > tmfloorz) { - tmfloorz = openbottom; + tmfloorz = open.floor; } - if (highceiling > tmdrpoffceilz) - tmdrpoffceilz = highceiling; + if (open.highceiling > tmdrpoffceilz) + tmdrpoffceilz = open.highceiling; - if (lowfloor < tmdropoffz) - tmdropoffz = lowfloor; + if (open.lowfloor < tmdropoffz) + tmdropoffz = open.lowfloor; return BMIT_CONTINUE; } @@ -1485,6 +1487,7 @@ boolean P_IsLineTripWire(const line_t *ld) static BlockItReturn_t PIT_CheckLine(line_t *ld) { const fixed_t thingtop = tmthing->z + tmthing->height; + opening_t open = {0}; if (ld->polyobj && !(ld->polyobj->flags & POF_SOLID)) return BMIT_CONTINUE; @@ -1557,41 +1560,41 @@ static BlockItReturn_t PIT_CheckLine(line_t *ld) return BMIT_ABORT; // set openrange, opentop, openbottom - P_LineOpening(ld, tmthing); + P_LineOpening(ld, tmthing, &open); // adjust floor / ceiling heights - if (opentop < tmceilingz) + if (open.ceiling < tmceilingz) { - tmceilingz = opentop; + tmceilingz = open.ceiling; ceilingline = ld; - tmceilingrover = openceilingrover; - tmceilingslope = opentopslope; - tmceilingpic = opentoppic; - tmceilingstep = openceilingstep; + tmceilingrover = open.ceilingrover; + tmceilingslope = open.ceilingslope; + tmceilingpic = open.ceilingpic; + tmceilingstep = open.ceilingstep; if (thingtop == tmthing->ceilingz) { - tmthing->ceilingdrop = openceilingdrop; + tmthing->ceilingdrop = open.ceilingdrop; } } - if (openbottom > tmfloorz) + if (open.floor > tmfloorz) { - tmfloorz = openbottom; - tmfloorrover = openfloorrover; - tmfloorslope = openbottomslope; - tmfloorpic = openbottompic; - tmfloorstep = openfloorstep; + tmfloorz = open.floor; + tmfloorrover = open.floorrover; + tmfloorslope = open.floorslope; + tmfloorpic = open.floorpic; + tmfloorstep = open.floorstep; if (tmthing->z == tmthing->floorz) { - tmthing->floordrop = openfloordrop; + tmthing->floordrop = open.floordrop; } } - if (highceiling > tmdrpoffceilz) - tmdrpoffceilz = highceiling; + if (open.highceiling > tmdrpoffceilz) + tmdrpoffceilz = open.highceiling; - if (lowfloor < tmdropoffz) - tmdropoffz = lowfloor; + if (open.lowfloor < tmdropoffz) + tmdropoffz = open.lowfloor; // we've crossed the line if (P_SpecialIsLinedefCrossType(ld)) @@ -3091,6 +3094,7 @@ static void P_HitBounceLine(line_t *ld) static boolean PTR_SlideCameraTraverse(intercept_t *in) { line_t *li; + opening_t open = {0}; I_Assert(in->isaline); @@ -3105,15 +3109,15 @@ static boolean PTR_SlideCameraTraverse(intercept_t *in) } // set openrange, opentop, openbottom - P_CameraLineOpening(li); + P_CameraLineOpening(li, &open); - if (openrange < mapcampointer->height) + if (open.range < mapcampointer->height) goto isblocking; // doesn't fit - if (opentop - mapcampointer->z < mapcampointer->height) + if (open.ceiling - mapcampointer->z < mapcampointer->height) goto isblocking; // mobj is too high - if (openbottom - mapcampointer->z > 0) // We don't want to make the camera step up. + if (open.floor - mapcampointer->z > 0) // We don't want to make the camera step up. goto isblocking; // too big a step up // this line doesn't block movement @@ -3137,6 +3141,8 @@ isblocking: static boolean PTR_LineIsBlocking(line_t *li) { + opening_t open = {0}; + // one-sided linedefs are always solid to sliding movement. if (!li->backsector) return !P_PointOnLineSide(slidemo->x, slidemo->y, li); @@ -3145,15 +3151,15 @@ static boolean PTR_LineIsBlocking(line_t *li) return true; // set openrange, opentop, openbottom - P_LineOpening(li, slidemo); + P_LineOpening(li, slidemo, &open); - if (openrange < slidemo->height) + if (open.range < slidemo->height) return true; // doesn't fit - if (opentop - slidemo->z < slidemo->height) + if (open.ceiling - slidemo->z < slidemo->height) return true; // mobj is too high - if (openbottom - slidemo->z > P_GetThingStepUp(slidemo)) + if (open.floor - slidemo->z > P_GetThingStepUp(slidemo)) return true; // too big a step up return false; diff --git a/src/p_maputl.c b/src/p_maputl.c index 357831b74..7e08a29af 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -335,28 +335,24 @@ line_t * P_FindNearestLine // Sets opentop and openbottom to the window through a two sided line. // OPTIMIZE: keep this precalculated // -fixed_t opentop, openbottom, openrange, lowfloor, highceiling; -pslope_t *opentopslope, *openbottomslope; -ffloor_t *openfloorrover, *openceilingrover; -fixed_t openceilingstep; -fixed_t openceilingdrop; -fixed_t openfloorstep; -fixed_t openfloordrop; -INT32 opentoppic, openbottompic; // P_CameraLineOpening // P_LineOpening, but for camera // Tails 09-29-2002 -void P_CameraLineOpening(line_t *linedef) +void P_CameraLineOpening(line_t *linedef, opening_t *open) { sector_t *front; sector_t *back; fixed_t frontfloor, frontceiling, backfloor, backceiling; + fixed_t thingtop; + + open->ceiling = open->highceiling = INT32_MAX; + open->floor = open->lowfloor = INT32_MIN; + open->range = 0; if (linedef->sidenum[1] == 0xffff) { // single sided line - openrange = 0; return; } @@ -368,14 +364,14 @@ void P_CameraLineOpening(line_t *linedef) if (front->camsec >= 0) { // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) - frontfloor = P_GetSectorFloorZAt (§ors[front->camsec], camera[0].x, camera[0].y); - frontceiling = P_GetSectorCeilingZAt(§ors[front->camsec], camera[0].x, camera[0].y); + frontfloor = P_GetSectorFloorZAt (§ors[front->camsec], mapcampointer->x, mapcampointer->y); + frontceiling = P_GetSectorCeilingZAt(§ors[front->camsec], mapcampointer->x, mapcampointer->y); } else if (front->heightsec >= 0) { // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) - frontfloor = P_GetSectorFloorZAt (§ors[front->heightsec], camera[0].x, camera[0].y); - frontceiling = P_GetSectorCeilingZAt(§ors[front->heightsec], camera[0].x, camera[0].y); + frontfloor = P_GetSectorFloorZAt (§ors[front->heightsec], mapcampointer->x, mapcampointer->x); + frontceiling = P_GetSectorCeilingZAt(§ors[front->heightsec], mapcampointer->x, mapcampointer->y); } else { @@ -386,103 +382,101 @@ void P_CameraLineOpening(line_t *linedef) if (back->camsec >= 0) { // SRB2CBTODO: ESLOPE (sectors[back->heightsec].f_slope) - backfloor = P_GetSectorFloorZAt (§ors[back->camsec], camera[0].x, camera[0].y); - backceiling = P_GetSectorCeilingZAt(§ors[back->camsec], camera[0].x, camera[0].y); + backfloor = P_GetSectorFloorZAt (§ors[back->camsec], mapcampointer->x, mapcampointer->y); + backceiling = P_GetSectorCeilingZAt(§ors[back->camsec], mapcampointer->x, mapcampointer->y); } else if (back->heightsec >= 0) { // SRB2CBTODO: ESLOPE (sectors[back->heightsec].f_slope) - backfloor = P_GetSectorFloorZAt (§ors[back->heightsec], camera[0].x, camera[0].y); - backceiling = P_GetSectorCeilingZAt(§ors[back->heightsec], camera[0].x, camera[0].y); + backfloor = P_GetSectorFloorZAt (§ors[back->heightsec], mapcampointer->x, mapcampointer->y); + backceiling = P_GetSectorCeilingZAt(§ors[back->heightsec], mapcampointer->x, mapcampointer->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); } + thingtop = mapcampointer->z + mapcampointer->height; + + if (frontceiling < backceiling) { - fixed_t thingtop = mapcampointer->z + mapcampointer->height; - - if (frontceiling < backceiling) - { - opentop = frontceiling; - highceiling = backceiling; - } - else - { - opentop = backceiling; - highceiling = frontceiling; - } - - if (frontfloor > backfloor) - { - openbottom = frontfloor; - lowfloor = backfloor; - } - else - { - openbottom = backfloor; - lowfloor = frontfloor; - } - - // Check for fake floors in the sector. - if (front->ffloors || back->ffloors) - { - ffloor_t *rover; - fixed_t delta1, delta2; - - // Check for frontsector's fake floors - if (front->ffloors) - for (rover = front->ffloors; rover; rover = rover->next) - { - fixed_t topheight, bottomheight; - if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) - continue; - - topheight = P_CameraGetFOFTopZ(mapcampointer, front, rover, tmx, tmy, linedef); - bottomheight = P_CameraGetFOFBottomZ(mapcampointer, front, rover, tmx, tmy, linedef); - - delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); - delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); - if (bottomheight < opentop && delta1 >= delta2) - opentop = bottomheight; - else if (bottomheight < highceiling && delta1 >= delta2) - highceiling = bottomheight; - - if (topheight > openbottom && delta1 < delta2) - openbottom = topheight; - else if (topheight > lowfloor && delta1 < delta2) - lowfloor = topheight; - } - - // Check for backsectors fake floors - if (back->ffloors) - for (rover = back->ffloors; rover; rover = rover->next) - { - fixed_t topheight, bottomheight; - if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) - continue; - - topheight = P_CameraGetFOFTopZ(mapcampointer, back, rover, tmx, tmy, linedef); - bottomheight = P_CameraGetFOFBottomZ(mapcampointer, back, rover, tmx, tmy, linedef); - - delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); - delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); - if (bottomheight < opentop && delta1 >= delta2) - opentop = bottomheight; - else if (bottomheight < highceiling && delta1 >= delta2) - highceiling = bottomheight; - - if (topheight > openbottom && delta1 < delta2) - openbottom = topheight; - else if (topheight > lowfloor && delta1 < delta2) - lowfloor = topheight; - } - } - openrange = opentop - openbottom; - return; + open->ceiling = frontceiling; + open->highceiling = backceiling; } + else + { + open->ceiling = backceiling; + open->highceiling = frontceiling; + } + + if (frontfloor > backfloor) + { + open->floor = frontfloor; + open->lowfloor = backfloor; + } + else + { + open->floor = backfloor; + open->lowfloor = frontfloor; + } + + // Check for fake floors in the sector. + if (front->ffloors || back->ffloors) + { + ffloor_t *rover; + fixed_t delta1, delta2; + + // Check for frontsector's fake floors + if (front->ffloors) + for (rover = front->ffloors; rover; rover = rover->next) + { + fixed_t topheight, bottomheight; + if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) ) + continue; + + topheight = P_CameraGetFOFTopZ(mapcampointer, front, rover, tmx, tmy, linedef); + bottomheight = P_CameraGetFOFBottomZ(mapcampointer, front, rover, tmx, tmy, linedef); + + delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); + delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); + if (bottomheight < open->ceiling && delta1 >= delta2) + open->ceiling = bottomheight; + else if (bottomheight < open->highceiling && delta1 >= delta2) + open->highceiling = bottomheight; + + if (topheight > open->floor && delta1 < delta2) + open->floor = topheight; + else if (topheight > open->lowfloor && delta1 < delta2) + open->lowfloor = topheight; + } + + // Check for backsectors fake floors + if (back->ffloors) + for (rover = back->ffloors; rover; rover = rover->next) + { + fixed_t topheight, bottomheight; + if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) ) + continue; + + topheight = P_CameraGetFOFTopZ(mapcampointer, back, rover, tmx, tmy, linedef); + bottomheight = P_CameraGetFOFBottomZ(mapcampointer, back, rover, tmx, tmy, linedef); + + delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); + delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); + if (bottomheight < open->ceiling && delta1 >= delta2) + open->ceiling = bottomheight; + else if (bottomheight < open->highceiling && delta1 >= delta2) + open->highceiling = bottomheight; + + if (topheight > open->floor && delta1 < delta2) + open->floor = topheight; + else if (topheight > open->lowfloor && delta1 < delta2) + open->lowfloor = topheight; + } + } + + open->range = (open->ceiling - open->floor); } boolean @@ -562,7 +556,7 @@ P_GetMidtextureTopBottom return true; } -void P_LineOpening(line_t *linedef, mobj_t *mobj) +void P_LineOpening(line_t *linedef, mobj_t *mobj, opening_t *open) { enum { FRONT, BACK }; @@ -578,15 +572,14 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) int lo = 0; // set these defaults so that polyobjects don't interfere with collision above or below them - opentop = highceiling = INT32_MAX; - openbottom = lowfloor = INT32_MIN; - openrange = 0; - opentopslope = openbottomslope = NULL; - opentoppic = openbottompic = -1; - openceilingstep = 0; - openceilingdrop = 0; - openfloorstep = 0; - openfloordrop = 0; + open->ceiling = open->highceiling = INT32_MAX; + open->floor = open->lowfloor = INT32_MIN; + open->range = 0; + open->ceilingslope = open->floorslope = NULL; + open->ceilingrover = open->floorrover = NULL; + open->ceilingpic = open->floorpic = -1; + open->ceilingstep = open->floorstep = 0; + open->ceilingdrop = open->floordrop = 0; if (linedef->sidenum[1] == 0xffff) { @@ -616,7 +609,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) thingtop = mobj->z + mobj->height; } - openfloorrover = openceilingrover = NULL; if (!linedef->polyobj) { // Set open and high/low values here @@ -629,18 +621,18 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) hi = ( height[0] < height[1] ); lo = ! hi; - opentop = height[lo]; - highceiling = height[hi]; - opentopslope = sector[lo]->c_slope; - opentoppic = sector[lo]->ceilingpic; + open->ceiling = height[lo]; + open->highceiling = height[hi]; + open->ceilingslope = sector[lo]->c_slope; + open->ceilingpic = sector[lo]->ceilingpic; if (mobj) { topedge[FRONT] = P_GetSectorCeilingZAt(front, cross.x, cross.y); topedge[BACK] = P_GetSectorCeilingZAt(back, cross.x, cross.y); - openceilingstep = ( thingtop - topedge[lo] ); - openceilingdrop = ( topedge[hi] - topedge[lo] ); + open->ceilingstep = ( thingtop - topedge[lo] ); + open->ceilingdrop = ( topedge[hi] - topedge[lo] ); } height[FRONT] = P_GetFloorZ(mobj, front, tmx, tmy, linedef); @@ -649,18 +641,18 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) hi = ( height[0] < height[1] ); lo = ! hi; - openbottom = height[hi]; - lowfloor = height[lo]; - openbottomslope = sector[hi]->f_slope; - openbottompic = sector[hi]->floorpic; + open->floor = height[hi]; + open->lowfloor = height[lo]; + open->floorslope = sector[hi]->f_slope; + open->floorpic = sector[hi]->floorpic; if (mobj) { botedge[FRONT] = P_GetSectorFloorZAt(front, cross.x, cross.y); botedge[BACK] = P_GetSectorFloorZAt(back, cross.x, cross.y); - openfloorstep = ( botedge[hi] - mobj->z ); - openfloordrop = ( botedge[hi] - botedge[lo] ); + open->floorstep = ( botedge[hi] - mobj->z ); + open->floordrop = ( botedge[hi] - botedge[lo] ); } } @@ -680,23 +672,28 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) delta1 = abs(mobj->z - texmid); delta2 = abs(thingtop - texmid); - if (delta1 > delta2) { // Below - if (opentop > texbottom) + if (delta1 > delta2) + { + // Below + if (open->ceiling > texbottom) { - topedge[lo] -= ( opentop - texbottom ); + topedge[lo] -= ( open->ceiling - texbottom ); - opentop = texbottom; - openceilingstep = ( thingtop - topedge[lo] ); - openceilingdrop = ( topedge[hi] - topedge[lo] ); + open->ceiling = texbottom; + open->ceilingstep = ( thingtop - topedge[lo] ); + open->ceilingdrop = ( topedge[hi] - topedge[lo] ); } - } else { // Above - if (openbottom < textop) + } + else + { + // Above + if (open->floor < textop) { - botedge[hi] += ( textop - openbottom ); + botedge[hi] += ( textop - open->floor ); - openbottom = textop; - openfloorstep = ( botedge[hi] - mobj->z ); - openfloordrop = ( botedge[hi] - botedge[lo] ); + open->floor = textop; + open->floorstep = ( botedge[hi] - mobj->z ); + open->floordrop = ( botedge[hi] - botedge[lo] ); } } } @@ -724,17 +721,27 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) delta1 = abs(mobj->z - (polybottom + ((polytop - polybottom)/2))); delta2 = abs(thingtop - (polybottom + ((polytop - polybottom)/2))); - if (polybottom < opentop && delta1 >= delta2) + if (delta1 > delta2) { - opentop = polybottom; - } - else if (polybottom < highceiling && delta1 >= delta2) - { - highceiling = polybottom; + if (polybottom < open->ceiling) + { + open->ceiling = polybottom; + } + else if (polybottom < open->highceiling) + { + open->highceiling = polybottom; + } } else { - openbottom = polytop; + if (polytop > open->floor) + { + open->floor = polytop; + } + else if (polytop > open->lowfloor) + { + open->lowfloor = polytop; + } } } // otherwise don't do anything special, pretend there's nothing else there @@ -750,18 +757,15 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) /* yuck */ struct { - fixed_t top; - fixed_t bottom; + fixed_t ceiling; + fixed_t floor; ffloor_t * ceilingrover; ffloor_t * floorrover; - } open[2] = { + } fofopen[2] = { { INT32_MAX, INT32_MIN, NULL, NULL }, { INT32_MAX, INT32_MIN, NULL, NULL }, }; - const fixed_t oldopentop = opentop; - const fixed_t oldopenbottom = openbottom; - // Check for frontsector's fake floors for (rover = front->ffloors; rover; rover = rover->next) { @@ -783,25 +787,27 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) // thing is below FOF { - if (bottomheight < open[FRONT].top) { - open[FRONT].top = bottomheight; - opentopslope = *rover->b_slope; - opentoppic = *rover->bottompic; - open[FRONT].ceilingrover = rover; + // thing is below FOF + if ((rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) + { + if (bottomheight < fofopen[FRONT].ceiling) + { + fofopen[FRONT].ceiling = bottomheight; + fofopen[FRONT].ceilingrover = rover; + } } - else if (bottomheight < highceiling) - highceiling = bottomheight; } else { - if (topheight > open[FRONT].bottom) { - open[FRONT].bottom = topheight; - openbottomslope = *rover->t_slope; - openbottompic = *rover->toppic; - open[FRONT].floorrover = rover; + // thing is above FOF + if ((rover->flags & FF_INTANGIBLEFLATS) != FF_REVERSEPLATFORM) + { + if (topheight > fofopen[FRONT].floor) + { + fofopen[FRONT].floor = topheight; + fofopen[FRONT].floorrover = rover; + } } - else if (topheight > lowfloor) - lowfloor = topheight; } } @@ -826,78 +832,92 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) // thing is below FOF { - if (bottomheight < open[BACK].top) { - open[BACK].top = bottomheight; - opentopslope = *rover->b_slope; - opentoppic = *rover->bottompic; - open[BACK].ceilingrover = rover; + // thing is below FOF + if ((rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) + { + if (bottomheight < fofopen[BACK].ceiling) + { + fofopen[BACK].ceiling = bottomheight; + fofopen[BACK].ceilingrover = rover; + } } - else if (bottomheight < highceiling) - highceiling = bottomheight; } else { - if (topheight > open[BACK].bottom) { - open[BACK].bottom = topheight; - openbottomslope = *rover->t_slope; - openbottompic = *rover->toppic; - open[BACK].floorrover = rover; + // thing is above FOF + if ((rover->flags & FF_INTANGIBLEFLATS) != FF_REVERSEPLATFORM) + { + if (topheight > fofopen[BACK].floor) + { + fofopen[BACK].floor = topheight; + fofopen[BACK].floorrover = rover; + } } - else if (topheight > lowfloor) - lowfloor = topheight; } } - lo = ( open[0].top > open[1].top ); + hi = ( fofopen[0].ceiling < fofopen[1].ceiling ); + lo = ! hi; - if (open[lo].top <= oldopentop) + if (fofopen[lo].ceiling <= open->ceiling) { - hi = ! lo; + topedge[lo] = P_GetFFloorBottomZAt(fofopen[lo].ceilingrover, cross.x, cross.y); - topedge[lo] = P_GetFFloorBottomZAt(open[lo].ceilingrover, cross.x, cross.y); - - if (open[hi].top < oldopentop) + if (fofopen[hi].ceiling < open->ceiling) { - topedge[hi] = P_GetFFloorBottomZAt(open[hi].ceilingrover, cross.x, cross.y); + topedge[hi] = P_GetFFloorBottomZAt(fofopen[hi].ceilingrover, cross.x, cross.y); } - opentop = open[lo].top; - openceilingrover = open[lo].ceilingrover; - openceilingstep = ( thingtop - topedge[lo] ); - openceilingdrop = ( topedge[hi] - topedge[lo] ); - } + open->ceiling = fofopen[lo].ceiling; + open->ceilingrover = fofopen[lo].ceilingrover; + open->ceilingslope = *fofopen[lo].ceilingrover->b_slope; + open->ceilingpic = *fofopen[lo].ceilingrover->bottompic; + open->ceilingstep = ( thingtop - topedge[lo] ); + open->ceilingdrop = ( topedge[hi] - topedge[lo] ); - hi = ( open[0].bottom < open[1].bottom ); - - if (open[hi].bottom >= oldopenbottom) - { - lo = ! hi; - - botedge[hi] = P_GetFFloorTopZAt(open[hi].floorrover, cross.x, cross.y); - - if (open[lo].bottom > oldopenbottom) + if (fofopen[hi].ceiling < open->highceiling) { - botedge[lo] = P_GetFFloorTopZAt(open[lo].floorrover, cross.x, cross.y); - } - - openbottom = open[hi].bottom; - openfloorrover = open[hi].floorrover; - openfloorstep = ( botedge[hi] - mobj->z ); - - if (open[lo].bottom > lowfloor) - { - lowfloor = open[lo].bottom; + open->highceiling = fofopen[hi].ceiling; } } - else if (open[hi].bottom > lowfloor) + else if (fofopen[lo].ceiling < open->highceiling) { - lowfloor = open[hi].bottom; + open->highceiling = fofopen[lo].ceiling; + } + + hi = ( fofopen[0].floor < fofopen[1].floor ); + lo = ! hi; + + if (fofopen[hi].floor >= open->floor) + { + botedge[hi] = P_GetFFloorTopZAt(fofopen[hi].floorrover, cross.x, cross.y); + + if (fofopen[lo].floor > open->floor) + { + botedge[lo] = P_GetFFloorTopZAt(fofopen[lo].floorrover, cross.x, cross.y); + } + + open->floor = fofopen[hi].floor; + open->floorrover = fofopen[hi].floorrover; + open->floorslope = *fofopen[hi].floorrover->t_slope; + open->floorpic = *fofopen[hi].floorrover->toppic; + open->floorstep = ( botedge[hi] - mobj->z ); + open->floordrop = ( botedge[hi] - botedge[lo] ); + + if (fofopen[lo].floor > open->lowfloor) + { + open->lowfloor = fofopen[lo].floor; + } + } + else if (fofopen[hi].floor > open->lowfloor) + { + open->lowfloor = fofopen[hi].floor; } } } } - openrange = opentop - openbottom; + open->range = (open->ceiling - open->floor); } diff --git a/src/p_maputl.h b/src/p_maputl.h index 29e7d4de9..1b9528ac5 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -46,7 +46,19 @@ void P_ClosestPointOnLine(fixed_t x, fixed_t y, line_t *line, vertex_t *result); void P_ClosestPointOnLine3D(const vector3_t *p, const vector3_t *line, vector3_t *result); INT32 P_PointOnLineSide(fixed_t x, fixed_t y, line_t *line); void P_MakeDivline(line_t *li, divline_t *dl); -void P_CameraLineOpening(line_t *plinedef); +typedef struct +{ + fixed_t ceiling, floor, range; + fixed_t lowfloor, highceiling; + pslope_t *floorslope, *ceilingslope; + ffloor_t *floorrover, *ceilingrover; + fixed_t ceilingstep, ceilingdrop; + fixed_t floorstep, floordrop; + INT32 ceilingpic, floorpic; +} opening_t; + +void P_LineOpening(line_t *plinedef, mobj_t *mobj, opening_t *open); +void P_CameraLineOpening(line_t *plinedef, opening_t *open); fixed_t P_InterceptVector(divline_t *v2, divline_t *v1); INT32 P_BoxOnLineSide(fixed_t *tmbox, line_t *ld); line_t * P_FindNearestLine(const fixed_t x, const fixed_t y, const sector_t *, const INT32 special); @@ -58,17 +70,6 @@ void P_HitSpecialLines(mobj_t *thing, fixed_t x, fixed_t y, fixed_t momx, fixed_ boolean P_GetMidtextureTopBottom(line_t *linedef, fixed_t x, fixed_t y, fixed_t *return_top, fixed_t *return_bottom); -extern fixed_t opentop, openbottom, openrange, lowfloor, highceiling; -extern pslope_t *opentopslope, *openbottomslope; -extern ffloor_t *openfloorrover, *openceilingrover; -extern fixed_t openceilingstep; -extern fixed_t openceilingdrop; -extern fixed_t openfloorstep; -extern fixed_t openfloordrop; -extern INT32 opentoppic, openbottompic; - -void P_LineOpening(line_t *plinedef, mobj_t *mobj); - typedef enum { BMIT_CONTINUE, // Continue blockmap search diff --git a/src/p_sight.c b/src/p_sight.c index 10d670ede..cc02a17b8 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -32,10 +32,16 @@ typedef struct { divline_t strace; // from t1 to t2 fixed_t topslope, bottomslope; // slopes to top and bottom of target fixed_t bbox[4]; + + mobj_t *t1, *t2; + boolean alreadyHates; // For bot traversal, for if the bot is already in a sector it doesn't want to be + UINT8 traversed; } los_t; static INT32 sightcounts[2]; +#define TRAVERSE_MAX (2) + // // P_DivlineSide // @@ -423,6 +429,11 @@ boolean P_CheckSight(mobj_t *t1, mobj_t *t2) validcount++; + los.t1 = t1; + los.t2 = t2; + los.alreadyHates = false; + los.traversed = 0; + los.topslope = (los.bottomslope = t2->z - (los.sightzstart = t1->z + t1->height - @@ -681,6 +692,7 @@ static boolean P_CrossBotTraversalSubsector(size_t num, register traceblocking_t { seg_t *seg; INT32 count; + opening_t open = {0}; #ifdef RANGECHECK if (num >= numsubsectors) @@ -751,12 +763,12 @@ static boolean P_CrossBotTraversalSubsector(size_t num, register traceblocking_t // set openrange, opentop, openbottom tmx = tb->compareThing->x; tmy = tb->compareThing->y; - P_LineOpening(line, tb->compareThing); + P_LineOpening(line, tb->compareThing, &open); maxstep = P_GetThingStepUp(tb->compareThing); - if ((openrange < tb->compareThing->height) // doesn't fit - || (opentop - tb->compareThing->z < tb->compareThing->height) // mobj is too high - || (openbottom - tb->compareThing->z > maxstep)) // too big a step up + if ((open.range < tb->compareThing->height) // doesn't fit + || (open.ceiling - tb->compareThing->z < tb->compareThing->height) // mobj is too high + || (open.floor - tb->compareThing->z > maxstep)) // too big a step up { // This line situationally blocks us return false; From 5c6e894ee3d6c0b4229485cf6ef969007ce0437c Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 13 May 2023 01:14:40 -0400 Subject: [PATCH 26/26] Add FOF behavior switch to P_LineOpening Finally fixes the very specific issue on Endless Mine ( https://cdn.discordapp.com/attachments/1006454720686202951/1106749881663631420/image.png ) --- src/p_maputl.c | 78 ++++++++++++++++++++++++++++++++++++++------------ src/p_maputl.h | 5 ++++ 2 files changed, 65 insertions(+), 18 deletions(-) diff --git a/src/p_maputl.c b/src/p_maputl.c index 7e08a29af..c4a5e2787 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -723,24 +723,30 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj, opening_t *open) if (delta1 > delta2) { - if (polybottom < open->ceiling) + if (open->fofType != LO_FOF_FLOORS) { - open->ceiling = polybottom; - } - else if (polybottom < open->highceiling) - { - open->highceiling = polybottom; + if (polybottom < open->ceiling) + { + open->ceiling = polybottom; + } + else if (polybottom < open->highceiling) + { + open->highceiling = polybottom; + } } } else { - if (polytop > open->floor) + if (open->fofType != LO_FOF_CEILINGS) { - open->floor = polytop; - } - else if (polytop > open->lowfloor) - { - open->lowfloor = polytop; + if (polytop > open->floor) + { + open->floor = polytop; + } + else if (polytop > open->lowfloor) + { + open->lowfloor = polytop; + } } } } @@ -779,14 +785,27 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj, opening_t *open) || (rover->flags & FF_BLOCKOTHERS && !mobj->player))) continue; - topheight = P_GetFOFTopZ(mobj, front, rover, tmx, tmy, linedef); - bottomheight = P_GetFOFBottomZ(mobj, front, rover, tmx, tmy, linedef); + if (open->fofType != LO_FOF_ANY) + { + topheight = P_VeryTopOfFOF(rover); + bottomheight = P_VeryBottomOfFOF(rover); + } + else + { + topheight = P_GetFOFTopZ(mobj, front, rover, tmx, tmy, linedef); + bottomheight = P_GetFOFBottomZ(mobj, front, rover, tmx, tmy, linedef); + } delta1 = abs(mobj->z - (bottomheight + ((topheight - bottomheight)/2))); delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); - if (delta1 >= delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) // thing is below FOF + if (delta1 > delta2) { + if (open->fofType == LO_FOF_FLOORS) + { + continue; + } + // thing is below FOF if ((rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) { @@ -799,6 +818,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj, opening_t *open) } else { + if (open->fofType == LO_FOF_CEILINGS) + { + continue; + } + // thing is above FOF if ((rover->flags & FF_INTANGIBLEFLATS) != FF_REVERSEPLATFORM) { @@ -824,14 +848,27 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj, opening_t *open) || (rover->flags & FF_BLOCKOTHERS && !mobj->player))) continue; - topheight = P_GetFOFTopZ(mobj, back, rover, tmx, tmy, linedef); - bottomheight = P_GetFOFBottomZ(mobj, back, rover, tmx, tmy, linedef); + if (open->fofType != LO_FOF_ANY) + { + topheight = P_VeryTopOfFOF(rover); + bottomheight = P_VeryBottomOfFOF(rover); + } + else + { + topheight = P_GetFOFTopZ(mobj, back, rover, tmx, tmy, linedef); + bottomheight = P_GetFOFBottomZ(mobj, back, rover, tmx, tmy, linedef); + } delta1 = abs(mobj->z - (bottomheight + ((topheight - bottomheight)/2))); delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); - if (delta1 >= delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) // thing is below FOF + if (delta1 > delta2) { + if (open->fofType == LO_FOF_FLOORS) + { + continue; + } + // thing is below FOF if ((rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) { @@ -844,6 +881,11 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj, opening_t *open) } else { + if (open->fofType == LO_FOF_CEILINGS) + { + continue; + } + // thing is above FOF if ((rover->flags & FF_INTANGIBLEFLATS) != FF_REVERSEPLATFORM) { diff --git a/src/p_maputl.h b/src/p_maputl.h index 1b9528ac5..3e1d464ac 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -55,8 +55,13 @@ typedef struct fixed_t ceilingstep, ceilingdrop; fixed_t floorstep, floordrop; INT32 ceilingpic, floorpic; + UINT8 fofType; // LO_FOF_ types for forcing FOF collide } opening_t; +#define LO_FOF_ANY (0) +#define LO_FOF_FLOORS (1) +#define LO_FOF_CEILINGS (2) + void P_LineOpening(line_t *plinedef, mobj_t *mobj, opening_t *open); void P_CameraLineOpening(line_t *plinedef, opening_t *open); fixed_t P_InterceptVector(divline_t *v2, divline_t *v1);