From 37969a34159d54df63a1fa00f9acd98813c3b7f9 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Wed, 19 Feb 2025 21:58:12 +0100 Subject: [PATCH] Add mapcompat global (AKA fix remapping on palette texture skyboxes) Rather than setting udmf earlier in P_SetupLevel and continuing to awkwardly check udmf everywhere, I'm adding a new global solely for compat purposes. For now, have it mirror udmf to avoid supporting two binary formats. (still keeping the 2.2 conversion code tho?) --- src/doomstat.h | 1 + src/g_game.c | 1 + src/lua_script.c | 3 +++ src/p_floor.c | 2 +- src/p_mobj.c | 4 ++-- src/p_setup.c | 16 +++++++++++++--- src/p_slopes.c | 2 +- src/p_spec.c | 8 ++++---- src/r_textures.c | 2 +- 9 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index 7c1ce5491..7c3c7afed 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -46,6 +46,7 @@ extern UINT8 mapmusrng; // Use other bits if necessary. extern UINT32 maptol; +extern boolean mapcompat; extern INT32 cursaveslot; //extern INT16 lastmapsaved; diff --git a/src/g_game.c b/src/g_game.c index 0a203217c..d84bd426d 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -92,6 +92,7 @@ UINT8 mapmusrng; // Random selection result INT16 gamemap = 1; UINT32 maptol; +boolean mapcompat = false; preciptype_t globalweather = PRECIP_NONE; preciptype_t curWeather = PRECIP_NONE; diff --git a/src/lua_script.c b/src/lua_script.c index 67c8b9b7e..60b3bf447 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -401,6 +401,9 @@ int LUA_PushGlobals(lua_State *L, const char *word) } else if (fastcmp(word, "compatmode")) { lua_pushboolean(L, lua_compatmode); return 1; + } else if (fastcmp(word, "mapcompat")) { + lua_pushboolean(L, mapcompat); + return 1; } return 0; diff --git a/src/p_floor.c b/src/p_floor.c index ef31d5d1d..8661cc25e 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1805,7 +1805,7 @@ static floormove_t *CreateFloorThinker(sector_t *sec) } dofloor = Z_Calloc(sizeof (*dofloor), PU_LEVSPEC, NULL); - P_AddThinker(udmf ? THINK_MAIN : THINK_FLOORS, &dofloor->thinker); + P_AddThinker(mapcompat ? THINK_FLOORS : THINK_MAIN, &dofloor->thinker); // make sure another floor thinker won't get started over this one sec->floordata = dofloor; diff --git a/src/p_mobj.c b/src/p_mobj.c index 15333e037..500f6aa97 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11094,7 +11094,7 @@ static boolean P_SetupMace(mapthing_t *mthing, mobj_t *mobj, boolean *doangle) mnumspokes = mthing->args[1] + 1; mspokeangle = FixedAngle((360*FRACUNIT)/mnumspokes) >> ANGLETOFINESHIFT; mwidth = max(0, mthing->args[2]); - mspeed = abs(mthing->args[3] << (udmf ? 4 : 0)); + mspeed = abs(mthing->args[3] << (mapcompat ? 0 : 4)); mphase = mthing->args[4] % 360; mpinch = mthing->args[5] % 360; mnumnospokes = mthing->args[6]; @@ -12007,7 +12007,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean case MT_YELLOWSPRING: case MT_INVISSPRING: { - if (!udmf) + if (mapcompat) mobj->flags ^= MF_NOGRAVITY; } default: diff --git a/src/p_setup.c b/src/p_setup.c index b51786f24..0ceb123e4 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -5235,7 +5235,7 @@ static void P_ConvertBinaryLinedefTypes(void) //Alpha if (lines[i].special == 141 || lines[i].special == 142 || lines[i].special == 144 || lines[i].special == 145) { - if (udmf && lines[i].flags & ML_NOCLIMB) + if (!mapcompat && lines[i].flags & ML_NOCLIMB) lines[i].args[3] |= TMFA_INSIDES; P_SetBinaryFOFAlpha(&lines[i]); @@ -7220,7 +7220,7 @@ static void P_ConvertBinaryThingTypes(void) break; } - if (udmf) + if (!mapcompat) { mapthings[i].angle = lines[j].frontsector->ceilingheight >> FRACBITS; mapthings[i].pitch = lines[j].frontsector->floorheight >> FRACBITS; @@ -7341,7 +7341,7 @@ static void P_ConvertBinaryThingTypes(void) mapthings[i].args[0] = mapthings[i].angle >> 13; mapthings[i].args[1] = (mapthings[i].angle >> 10) & 7; mapthings[i].args[3] = !!(mapthings[i].options & MTF_AMBUSH); - if (udmf) + if (!mapcompat) { mapthings[i].args[0] = mapthings[i].args[0]*TICRATE/2; mapthings[i].args[1] = mapthings[i].args[1]*TICRATE/2; @@ -7638,6 +7638,13 @@ static void P_MakeMapMD5(virtres_t *virt, void *dest) M_Memcpy(dest, &resmd5, 16); } +static void P_SetMapCompat(void) +{ + // choose wisely... + mapcompat = vres_Find(curmapvirt, "TEXTMAP") == NULL; + //mapcompat = wadfiles[WADFILENUM(mapheaderinfo[gamemap-1]->lumpnum)]->compatmode; +} + static boolean P_LoadMapFromFile(void) { virtlump_t *textmap = vres_Find(curmapvirt, "TEXTMAP"); @@ -8464,6 +8471,9 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) curmapvirt = vres_GetMap(lastloadedmaplumpnum); + // set this as early as possible, to fix palette texture skyboxes + P_SetMapCompat(); + if (mapheaderinfo[gamemap-1]) { encoreLump = vres_Find(curmapvirt, encoremode ? "ENCORE" : "TWEAKMAP"); diff --git a/src/p_slopes.c b/src/p_slopes.c index 851b048be..21937a7a1 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -862,7 +862,7 @@ void P_SpawnSlopes(const boolean fromsave) { // end of jart // in kart, copied slopes are created AFTER spawning mapthings - if (!udmf) + if (mapcompat) return; /// Copies slopes from tagged sectors via line specials. diff --git a/src/p_spec.c b/src/p_spec.c index d1e707cfe..c2d78875b 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1412,15 +1412,15 @@ static boolean P_CheckRaceLapSpecial(line_t *triggerline, player_t *player) { lap = P_FindLowestLap(); - if (udmf && lap <= lastLowestLap) + if (!mapcompat && lap <= lastLowestLap) { - // Need to be able to search for E4 linedefs + // Need to be able to search for MIDSOLID linedefs return false; } } // kart laps are zero-based - if (lap && !udmf) + if (lap && mapcompat) lap--; UINT16 threshold = sides[triggerline->sidenum[0]].textureoffset >> FRACBITS; @@ -7853,7 +7853,7 @@ void P_SpawnSpecialsThatRequireObjects(boolean fromnetsave) for (i = 0; i < numlines; i++) { - if (!udmf && lines[i].special == 720) + if (mapcompat && lines[i].special == 720) P_CopySectorSlope(&lines[i]); if (P_IsLineDisabled(&lines[i])) diff --git a/src/r_textures.c b/src/r_textures.c index 5a56e80f5..66d346f29 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -2033,7 +2033,7 @@ void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *texindex) static void PaletteTextureHack(const char **name) { static char uberhack[5]; - if (!udmf) + if (mapcompat) { unsigned num; if (sscanf(*name, "~%03u", &num) && num < 256)