From 44ce0fd4482f62ed50781f413f1cc0454d1efed0 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Wed, 21 May 2025 16:09:56 -0400 Subject: [PATCH 01/33] Only do particles on real landing and make exiting pit hits not instashield --- src/p_inter.c | 3 ++- src/p_user.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 5a816d52f..83eb50777 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2158,7 +2158,8 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (player->exiting) { - K_DoInstashield(player); + if (inflictor) + K_DoInstashield(player); return false; } diff --git a/src/p_user.c b/src/p_user.c index 886692000..f10090f11 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1364,7 +1364,7 @@ boolean P_PlayerHitFloor(player_t *player, boolean fromAir) clipmomz = !(P_CheckDeathPitCollide(player->mo)); - if (player->prevonground == false && fromAir == true && clipmomz == true) + if (player->airtime > 10 && player->prevonground == false && fromAir == true && clipmomz == true) { K_SpawnSplashForMobj(player->mo, abs(player->mo->momz)); } From c8d5ef46be22956b724278b1b0dfc0085fcde55f Mon Sep 17 00:00:00 2001 From: NepDisk Date: Wed, 21 May 2025 20:25:56 -0400 Subject: [PATCH 02/33] Disable Floor ring drain sector special --- src/p_spec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 564bd5d61..247dc3dd4 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5545,12 +5545,12 @@ static void P_EvaluateLinedefExecutorTrigger(player_t *player, sector_t *sector, static void P_EvaluateOldSectorSpecial(player_t *player, sector_t *sector, sector_t *roversector, boolean isTouching) { - switch (GETSECSPECIAL(sector->special, 1)) + /*switch (GETSECSPECIAL(sector->special, 1)) { case 9: // Ring Drainer (Floor Touch) if (!isTouching) break; - /* FALLTHRU */ + // FALLTHRU case 10: // Ring Drainer (No Floor Touch) if (leveltime % (TICRATE/2) == 0 && player->rings > 0) { @@ -5558,7 +5558,7 @@ static void P_EvaluateOldSectorSpecial(player_t *player, sector_t *sector, secto S_StartSound(player->mo, sfx_antiri); } break; - } + }*/ switch (GETSECSPECIAL(sector->special, 2)) { From 04d3cea9e6a14887dcda241852f7f895d9fc6643 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Thu, 22 May 2025 08:17:36 -0400 Subject: [PATCH 03/33] Fix flipcam playerflag sticking --- src/d_netcmd.c | 2 +- src/g_game.c | 3 --- src/p_mobj.c | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index ead568b36..b36c5a2a9 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1895,7 +1895,7 @@ void WeaponPref_Parse(UINT8 **cp, INT32 playernum) UINT8 prefs = READUINT8(*cp); - player->pflags &= ~(PF_KICKSTARTACCEL|PF_SHRINKME); + player->pflags &= ~(PF_KICKSTARTACCEL|PF_SHRINKME|PF_FLIPCAM); if (prefs & WP_KICKSTARTACCEL) player->pflags |= PF_KICKSTARTACCEL; diff --git a/src/g_game.c b/src/g_game.c index dbdfdd6a1..b83622852 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2545,9 +2545,6 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) starposttime = players[player].starposttime; prevcheck = players[player].prevcheck; prevcheck = players[player].nextcheck; - - pflags |= (players[player].pflags & (PF_STASIS|PF_ELIMINATED|PF_NOCONTEST|PF_LOSTLIFE|PF_FLIPCAM)); - lastsafelap = players[player].lastsafelap; lastsafestarpost = players[player].lastsafestarpost; bigwaypointgap = players[player].bigwaypointgap; diff --git a/src/p_mobj.c b/src/p_mobj.c index cba5d3d58..0e1d1273c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3558,7 +3558,7 @@ void P_DestroyRobots(void) // the below is chasecam only, if you're curious. check out P_CalcPostImg in p_user.c for first person void P_CalcChasePostImg(player_t *player, camera_t *thiscam) { - const boolean flipcam = (player->pflags & PF_FLIPCAM && player->mo->eflags & MFE_VERTICALFLIP); + const boolean flipcam = ((player->pflags & PF_FLIPCAM) && (player->mo->eflags & MFE_VERTICALFLIP)); UINT8 postimgtype = 0; // This can happen when joining From 7d7e107fc2da2e9af98c7a7399fb39344b9412fb Mon Sep 17 00:00:00 2001 From: NepDisk Date: Thu, 22 May 2025 08:30:51 -0400 Subject: [PATCH 04/33] Lower starting Rings back to 5 --- src/d_main.cpp | 2 +- src/g_game.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 4c0194331..e4323ebca 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -87,7 +87,7 @@ #define ASSET_HASH_CHARS_KART 0x1e68a3e01aa5c68b #define ASSET_HASH_MAPS_KART 0x38558ed00da41ce9 #define ASSET_HASH_MAIN_PK3 0x90bc93435f9aa4c4 -#define ASSET_HASH_MAPPATCH_PK3 0xc789aadf69a0bcf9 +#define ASSET_HASH_MAPPATCH_PK3 0x7b0709aedd6b48b3 #ifdef USE_PATCH_FILE #define ASSET_HASH_PATCH_PK3 0x0000000000000000 #endif diff --git a/src/g_game.c b/src/g_game.c index b83622852..5a15b332d 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2474,7 +2474,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) bumper = ((gametyperules & GTR_BUMPERS) ? K_StartingBumperCount() : 0); karmapoints = 0; wanted = 0; - rings = 10; + rings = 5; kickstartaccel = 0; lastsafelap = 0; lastsafestarpost = 0; From 43ad4b045b5bfb9f7ac751e7f19d22bca65312aa Mon Sep 17 00:00:00 2001 From: NepDisk Date: Thu, 22 May 2025 08:48:49 -0400 Subject: [PATCH 05/33] Play sound when getting low on rings --- src/p_enemy.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_enemy.c b/src/p_enemy.c index d45b3fbb6..53669e87f 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3174,6 +3174,12 @@ void A_AttractChase(mobj_t *actor) actor->target->player->ringboost += K_GetKartRingPower(actor->target->player, true) + 3; S_StartSoundAtVolume(actor->target, sfx_s1b5, actor->target->player->ringvolume); + if (actor->target->player->rings <= 10) + { + S_StartSoundAtVolume(actor->target, sfx_s251, 255 - actor->target->player->rings*8); + S_StartSoundAtVolume(actor->target, sfx_s251, 255 - actor->target->player->rings*8); + } + if (actor->target->player->ringboost > (4*TICRATE + TICRATE/2)) actor->target->player->ringboost = (4*TICRATE + TICRATE/2); From 171eafee1fbff69793ac0dc9fb134a20830a2b59 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Thu, 22 May 2025 09:08:24 -0400 Subject: [PATCH 06/33] Use a Custom sound for Low Rings Yes its the same one from Gunstar heroes like RR --- src/d_main.cpp | 2 +- src/info/sounds.h | 3 +++ src/p_enemy.c | 3 +-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index e4323ebca..b91a0ad80 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -86,7 +86,7 @@ #define ASSET_HASH_TEXTURES_KART 0xb4211b2f32b6a291 #define ASSET_HASH_CHARS_KART 0x1e68a3e01aa5c68b #define ASSET_HASH_MAPS_KART 0x38558ed00da41ce9 -#define ASSET_HASH_MAIN_PK3 0x90bc93435f9aa4c4 +#define ASSET_HASH_MAIN_PK3 0x3bbd056a4ce5e993 #define ASSET_HASH_MAPPATCH_PK3 0x7b0709aedd6b48b3 #ifdef USE_PATCH_FILE #define ASSET_HASH_PATCH_PK3 0x0000000000000000 diff --git a/src/info/sounds.h b/src/info/sounds.h index f3e786126..25d8694aa 100644 --- a/src/info/sounds.h +++ b/src/info/sounds.h @@ -850,6 +850,9 @@ _(eggspr) // Chaining Sound _(bstchn) +// Low Ring Sound +_(ringlw) + // Shout message sound effect _(sysmsg) diff --git a/src/p_enemy.c b/src/p_enemy.c index 53669e87f..8dd71470d 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3176,8 +3176,7 @@ void A_AttractChase(mobj_t *actor) if (actor->target->player->rings <= 10) { - S_StartSoundAtVolume(actor->target, sfx_s251, 255 - actor->target->player->rings*8); - S_StartSoundAtVolume(actor->target, sfx_s251, 255 - actor->target->player->rings*8); + S_StartSoundAtVolume(actor->target, sfx_ringlw, 255 - actor->target->player->rings*10); } if (actor->target->player->ringboost > (4*TICRATE + TICRATE/2)) From 153838b7c2870a2baf0e216b8d87ea4d31799ccc Mon Sep 17 00:00:00 2001 From: NepDisk Date: Thu, 22 May 2025 09:27:17 -0400 Subject: [PATCH 07/33] Fix firstperson POSTIMG for heat and water --- src/p_user.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index f10090f11..a54d0c092 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3372,9 +3372,7 @@ boolean P_SpectatorJoinGame(player_t *player) static boolean P_CameraCheckHeatFirstperson(player_t *player, sector_t *sector, fixed_t pviewheight) { - mtag_t sectag = Tag_FGet(§or->tags); - - if (Tag_FindLineSpecial(13, sectag)) + if (sector->flags & MSF_HEATWAVE) return true; if (sector->ffloors) @@ -3388,13 +3386,10 @@ static boolean P_CameraCheckHeatFirstperson(player_t *player, sector_t *sector, if (pviewheight >= P_GetFFloorTopZAt(rover, player->mo->x, player->mo->y)) continue; - if (pviewheight <= P_GetFFloorBottomZAt(rover, player->mo->x, player->mo->y)) continue; - sectag = Tag_FGet(&rover->master->frontsector->tags); - - if (Tag_FindLineSpecial(13, sectag)) + if (rover->master->frontsector->flags & MSF_HEATWAVE) return true; } } @@ -3410,12 +3405,11 @@ static boolean P_CameraCheckWaterFirstperson(player_t *player, sector_t *sector, for (rover = sector->ffloors; rover; rover = rover->next) { - if (!(rover->fofflags & FOF_EXISTS) || !(rover->fofflags & FOF_SWIMMABLE) || rover->fofflags & FOF_BLOCKPLAYER) + if (!(rover->fofflags & FOF_EXISTS) || !(rover->fofflags & FOF_SWIMMABLE) || rover->fofflags & FOF_BLOCKOTHERS) continue; if (pviewheight >= P_GetFFloorTopZAt(rover, player->mo->x, player->mo->y)) continue; - if (pviewheight <= P_GetFFloorBottomZAt(rover, player->mo->x, player->mo->y)) continue; From 199dd2c85d684b6ade738ac624a87d4b66bdac83 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Thu, 22 May 2025 09:31:33 -0400 Subject: [PATCH 08/33] This is supposed to be blockplayer --- 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 a54d0c092..4bbf23945 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3405,7 +3405,7 @@ static boolean P_CameraCheckWaterFirstperson(player_t *player, sector_t *sector, for (rover = sector->ffloors; rover; rover = rover->next) { - if (!(rover->fofflags & FOF_EXISTS) || !(rover->fofflags & FOF_SWIMMABLE) || rover->fofflags & FOF_BLOCKOTHERS) + if (!(rover->fofflags & FOF_EXISTS) || !(rover->fofflags & FOF_SWIMMABLE) || rover->fofflags & FOF_BLOCKPLAYER) continue; if (pviewheight >= P_GetFFloorTopZAt(rover, player->mo->x, player->mo->y)) From 25a8e3dd4d6e7531f63376c7964651769fdd056e Mon Sep 17 00:00:00 2001 From: NepDisk Date: Fri, 23 May 2025 13:31:33 -0400 Subject: [PATCH 09/33] Don't fallback for change viewpoint --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 5a15b332d..a8f46b4f7 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1625,7 +1625,7 @@ boolean G_Responder(event_t *ev) // allow spy mode changes even during the demo if (gamestate == GS_LEVEL && ev->type == ev_keydown - && G_ControlBoundToKey(0, gc_viewpoint, ev->data1, true)) + && G_ControlBoundToKey(0, gc_viewpoint, ev->data1, false)) { if (!demo.playback && (r_splitscreen)) g_localplayers[0] = consoleplayer; From 479af14832ad6a7498cb167f9b2750bef5d9177f Mon Sep 17 00:00:00 2001 From: NepDisk Date: Fri, 23 May 2025 13:51:57 -0400 Subject: [PATCH 10/33] Add sliptide tilt toggle Thanks Jon for the idea! --- src/p_user.c | 2 +- src/r_main.cpp | 3 +++ src/r_main.h | 1 + src/r_patchrotation.c | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 4bbf23945..60c756648 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3639,7 +3639,7 @@ Quaketilt (player_t *player) delta = (INT32)(( moma + ANGLE_180 ) - player->mo->angle ); if (P_IsObjectOnGround(player->mo)) { - if (sliptiding) + if (sliptiding && cv_sliptidetilt.value) { tilt = ANGLE_45; lowb = 20*FRACUNIT; diff --git a/src/r_main.cpp b/src/r_main.cpp index 77191978b..7cc6c7d83 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -196,6 +196,8 @@ consvar_t cv_renderstats = CVAR_INIT ("renderstats", "Off", 0, CV_OnOff, NULL); consvar_t cv_sloperoll = CVAR_INIT ("spritesloperoll", "On", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_sliptidetilt = CVAR_INIT ("sliptidetilt", "On", CV_SAVE, CV_OnOff, NULL); + void SplitScreen_OnChange(void) { UINT8 i; @@ -1836,6 +1838,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_tilting); CV_RegisterVar(&cv_actionmovie); CV_RegisterVar(&cv_sloperoll); + CV_RegisterVar(&cv_sliptidetilt); CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud); diff --git a/src/r_main.h b/src/r_main.h index b5c4e0968..aea3e6550 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -159,6 +159,7 @@ extern consvar_t cv_tailspickup; extern consvar_t cv_debugfinishline; extern consvar_t cv_sloperoll; +extern consvar_t cv_sliptidetilt; // debugging diff --git a/src/r_patchrotation.c b/src/r_patchrotation.c index 2bb1c1a58..7b88d792b 100644 --- a/src/r_patchrotation.c +++ b/src/r_patchrotation.c @@ -62,7 +62,7 @@ static angle_t R_PlayerSpriteRotation(player_t *player, player_t *viewPlayer) angle_t rollAngle = 0; - if (sliptideLift) + if (sliptideLift && cv_sliptidetilt.value) { /* (from side) tilt downward if turning toward camera, upward if away. */ From 4d4a6a29f1b6e238d1824f596e5ab50b797f04b4 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Sat, 24 May 2025 10:18:36 -0400 Subject: [PATCH 11/33] Prevent sigsevs --- src/k_kart.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 8a4126db7..cd3e7f2a5 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8776,7 +8776,7 @@ void K_SetRespawnAtNextWaypoint(player_t * player) oopisepoint = K_GetClosestWaypointToMobj(player->mo); } - if (oopisepoint->numnextwaypoints > 0) + if (oopisepoint && oopisepoint->numnextwaypoints > 0) { for (i = 0; i < oopisepoint->numnextwaypoints; i++) { @@ -8820,10 +8820,14 @@ void K_SetRespawnAtNextWaypoint(player_t * player) safewaypoint = oopisepoint->nextwaypoints[i]; break; } - oopisepoint = safewaypoint; + + if (safewaypoint) + { + oopisepoint = safewaypoint; + } } - if (oopisepoint->numprevwaypoints > 0) + if (oopisepoint && oopisepoint->numprevwaypoints > 0) { for (i = 0; i < oopisepoint->numprevwaypoints; i++) { @@ -8856,7 +8860,6 @@ void K_SetRespawnAtNextWaypoint(player_t * player) } } - CONS_Debug(DBG_GAMELOGIC, M_GetText("Tried to respawn at invalid waypoint! Setting respawn to closest waypoint\n")); } else From 9a21eaee0b4c8f49fb16ef910f00622fb48dfa29 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Sat, 24 May 2025 17:47:07 -0400 Subject: [PATCH 12/33] Basic Startboost timing code --- src/k_bot.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/k_bot.cpp b/src/k_bot.cpp index 8f568205f..9155bffb1 100644 --- a/src/k_bot.cpp +++ b/src/k_bot.cpp @@ -1566,12 +1566,17 @@ static void K_BuildBotTiccmdNormal(player_t *player, ticcmd_t *cmd) destangle = R_PointToAngle2(player->mo->x, player->mo->y, predict->x, predict->y); turnamt = K_HandleBotTrack(player, cmd, predict, destangle); } - else if (leveltime <= starttime ) + else if (leveltime <= starttime) { - if (leveltime >= starttime-TICRATE-TICRATE/7) + UINT8 timing = P_RandomRange(0, 5); + UINT8 finaltiming = (MAXBOTDIFFICULTY/2)-(player->botvars.difficulty/2)+timing; + if (player->botvars.difficulty > 4) { - cmd->buttons |= BT_ACCELERATE; - cmd->forwardmove = MAXPLMOVE; + if (leveltime >= starttime-TICRATE-TICRATE/7+finaltiming) + { + cmd->buttons |= BT_ACCELERATE; + cmd->forwardmove = MAXPLMOVE; + } } } else From d95b9210e9b7a8043a35b8ddf2fd161d483a2848 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Sat, 24 May 2025 18:34:07 -0400 Subject: [PATCH 13/33] Invert binary conversion code for spikes This has been the cause of the most annoying long standing bug to date. Who knew this got inverted in 2.2 --- src/p_setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 7585be750..fdf2284ca 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -7272,7 +7272,7 @@ static void P_ConvertBinaryThingTypes(void) if (mapthings[i].options & MTF_EXTRA) mapthings[i].args[2] |= TMSF_RETRACTED; } - if (mapthings[i].options & MTF_AMBUSH) + if (!(mapthings[i].options & MTF_AMBUSH)) mapthings[i].args[2] |= TMSF_INTANGIBLE; break; case 523: //Spike @@ -7283,7 +7283,7 @@ static void P_ConvertBinaryThingTypes(void) if (mapthings[i].options & MTF_EXTRA) mapthings[i].args[2] |= TMSF_RETRACTED; } - if (mapthings[i].options & MTF_AMBUSH) + if (!(mapthings[i].options & MTF_AMBUSH)) mapthings[i].args[2] |= TMSF_INTANGIBLE; break; case 540: //Fan From b1550d05084dd18529c704a1f8cd69c4590d7de6 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Sat, 24 May 2025 20:14:40 -0400 Subject: [PATCH 14/33] Use built in backwards compat instead of Dofloor/Doceiling old on special 403 --- src/p_spec.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 247dc3dd4..7a9efc6b6 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2725,15 +2725,6 @@ boolean P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, cha return false; } - if (mapnamespace == MNS_SRB2KART) - { - if (line->args[2] != TMP_CEILING) - EV_DoFloor(line->args[1], line, moveFloorByFrontSector); - if (line->args[2] != TMP_FLOOR) - EV_DoCeiling(line->args[1], line, moveCeilingByFrontSector); - break; - } - copySector = line->frontsector; } else From 0a453db80d3f7cef4ecc9d96b728222a809c5257 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Sat, 24 May 2025 20:37:09 -0400 Subject: [PATCH 15/33] Readd extra bouncyfloor feature for binary backwards compat --- src/p_user.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 60c756648..117e01a81 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1616,6 +1616,17 @@ static void P_CheckBouncySectors(player_t *player) if (abs(momentum.z) < (rover->bouncestrength*2)) goto bouncydone; + if ((mapnamespace == MNS_SRB2KART) && !(rover->master->flags & ML_NOTBOUNCY)) + { + if (momentum.z > 0) + { + if (momentum.z < 8*FRACUNIT) + momentum.z = 8*FRACUNIT; + } + else if (momentum.z > -8*FRACUNIT && momentum.z != 0) + momentum.z = -8*FRACUNIT; + } + if (momentum.z > FixedMul(24*FRACUNIT, player->mo->scale)) //half of the default player height momentum.z = FixedMul(24*FRACUNIT, player->mo->scale); else if (momentum.z < -FixedMul(24*FRACUNIT, player->mo->scale)) From c7cbc27efb0f07d1ac7a089fe7ac0ed1ce6fa16e Mon Sep 17 00:00:00 2001 From: NepDisk Date: Sat, 24 May 2025 23:36:32 -0400 Subject: [PATCH 16/33] completly borked remove flats port Completey fucked color and brightmap handling for floors. --- src/doomdef.h | 3 - src/hardware/hw_cache.c | 205 ++++++++++-------------------- src/hardware/hw_main.c | 122 +++--------------- src/p_setup.c | 99 ++++----------- src/p_setup.h | 41 +----- src/p_spec.c | 110 ++-------------- src/p_spec.h | 3 - src/r_picformats.c | 2 +- src/r_plane.cpp | 55 ++++---- src/r_textures.c | 270 +++++++++++++--------------------------- src/r_textures.h | 11 +- 11 files changed, 238 insertions(+), 683 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index da551b5b2..489302e48 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -515,9 +515,6 @@ extern int compuncommitted; #define NO_PNG_LUMPS #endif -/// Render flats on walls -#define WALLFLATS - /// Divide volume of music and sounds by this much (loudest sounds on earth) #define VOLUME_DIVIDER 4 #define USER_VOLUME_SCALE 2 diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 4b9da2616..7da9716c8 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -521,7 +521,6 @@ static void HWR_GenerateTexture(GLMapTexture_t *grtex, INT32 texnum, boolean noe realpatch = (softwarepatch_t *)Picture_PNGConvert(pdata, PICFMT_DOOMPATCH, NULL, NULL, NULL, NULL, lumplength, NULL, 0); else #endif -#ifdef WALLFLATS if (texture->type == TEXTURETYPE_FLAT) { if (doremap) @@ -529,7 +528,6 @@ static void HWR_GenerateTexture(GLMapTexture_t *grtex, INT32 texnum, boolean noe realpatch = (softwarepatch_t *)Picture_Convert(PICFMT_FLAT, pdata, PICFMT_DOOMPATCH, 0, NULL, texture->width, texture->height, 0, 0, 0); } else -#endif { dealloc = false; if (doremap) @@ -767,7 +765,7 @@ void HWR_LoadMapTextures(size_t pnumtextures) gl_textures = calloc(gl_numtextures, sizeof(*gl_textures)); gl_flats = calloc(gl_numtextures, sizeof(*gl_flats)); - if ((gl_textures == NULL) || (gl_flats == NULL)) + if (gl_textures == NULL || gl_flats == NULL) I_Error("HWR_LoadMapTextures: ran out of memory for OpenGL textures"); gl_maptexturesloaded = true; @@ -896,36 +894,6 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) flat[steppy] = grMipmap->colormap->source[flat[steppy]]; } -static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum, boolean noencoremap) -{ - UINT8 *flat; - UINT8 *converted; - size_t size; - size_t i; - UINT8 *colormap = colormaps; - - if (!noencoremap && encoremap) - { - colormap += COLORMAP_REMAPOFFSET; - } - - // setup the texture info - grMipmap->format = GL_TEXFMT_P_8; - grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; - - grMipmap->width = (UINT16)textures[texturenum]->width; - grMipmap->height = (UINT16)textures[texturenum]->height; - size = (grMipmap->width * grMipmap->height); - - flat = Z_Malloc(size, PU_HWRCACHE, &grMipmap->data); - converted = (UINT8 *)Picture_TextureToFlat(texturenum); - for (i = 0; i < size; i++) - { - flat[i] = colormap[converted[i]]; - } - Z_Free(converted); -} - // Download a Doom 'flat' to the hardware cache and make it ready for use void HWR_GetRawFlat(lumpnum_t flatlumpnum, boolean noencoremap) { @@ -966,125 +934,80 @@ void HWR_GetRawFlat(lumpnum_t flatlumpnum, boolean noencoremap) void HWR_GetLevelFlat(levelflat_t *levelflat, boolean noencoremap) { - // Who knows? - if (levelflat == NULL) - return; - - if (levelflat->type == LEVELFLAT_FLAT) - HWR_GetRawFlat(levelflat->u.flat.lumpnum, noencoremap); - else if (levelflat->type == LEVELFLAT_TEXTURE) + if (levelflat->type == LEVELFLAT_NONE) { - GLMapTexture_t *grtex; - INT32 texturenum = levelflat->u.texture.num; -#ifdef PARANOIA - if ((unsigned)texturenum >= gl_numtextures) - I_Error("HWR_GetLevelFlat: texturenum >= numtextures"); -#endif + HWR_SetCurrentTexture(NULL); + return; + } - // Who knows? - if (texturenum == 0 || texturenum == -1) - return; + INT32 texturenum = texturetranslation[levelflat->texture_id]; + INT32 brightmapnum = R_GetTextureBrightmap(texturenum); + if (texturenum <= 0) + { + HWR_SetCurrentTexture(NULL); + return; + } - // Every texture in memory, stored as a 8-bit flat. Wow! - grtex = &gl_flats[texturenum]; + GLMapTexture_t *grtex = &gl_flats[texturenum]; + GLMipmap_t *grMipmap = &grtex->mipmap; - // Generate flat if missing from the cache - if (!grtex->mipmap.data && !grtex->mipmap.downloaded) + if (!grMipmap->data && !grMipmap->downloaded) + { + UINT8 *colormap = colormaps; + + if (!noencoremap && encoremap) { - HWR_CacheTextureAsFlat(&grtex->mipmap, texturenum, noencoremap); - - if (!noencoremap && encoremap) - { - grtex->mipmap.colormap = Z_Calloc(sizeof(*grtex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL); - grtex->mipmap.colormap->source = colormaps + COLORMAP_REMAPOFFSET; - M_Memcpy(grtex->mipmap.colormap->data, colormaps + COLORMAP_REMAPOFFSET, 256); - } + colormap += COLORMAP_REMAPOFFSET; } - // If hardware does not have the texture, then call pfnSetTexture to upload it - if (!grtex->mipmap.downloaded) + grMipmap->format = GL_TEXFMT_P_8; + grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; + + grMipmap->width = (UINT16)textures[texturenum]->width; + grMipmap->height = (UINT16)textures[texturenum]->height; + + size_t size = grMipmap->width * grMipmap->height; + memcpy(Z_Malloc(size, PU_HWRCACHE, &grMipmap->data), R_GetFlatForTexture(texturenum), size); + + if (!noencoremap && encoremap) + { + grtex->mipmap.colormap = Z_Calloc(sizeof(*grtex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL); + grtex->mipmap.colormap->source = colormaps + COLORMAP_REMAPOFFSET; + M_Memcpy(grtex->mipmap.colormap->data, colormaps + COLORMAP_REMAPOFFSET, 256); + } + } + + if (!grMipmap->downloaded) + HWD.pfnSetTexture(&grtex->mipmap); + + HWR_SetCurrentTexture(&grtex->mipmap); + + Z_ChangeTag(grMipmap->data, PU_HWRCACHE_UNLOCKED); + + if (brightmapnum) + { + grtex = &gl_flats[brightmapnum]; + grMipmap = &grtex->mipmap; + + if (!grMipmap->data && !grMipmap->downloaded) + { + grMipmap->format = GL_TEXFMT_P_8; + grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; + + grMipmap->width = (UINT16)textures[brightmapnum]->width; + grMipmap->height = (UINT16)textures[brightmapnum]->height; + + size_t size = grMipmap->width * grMipmap->height; + memcpy(Z_Malloc(size, PU_HWRCACHE, &grMipmap->data), R_GetFlatForTexture(brightmapnum), size); + } + + if (!grMipmap->downloaded) HWD.pfnSetTexture(&grtex->mipmap); + HWR_SetCurrentTexture(&grtex->mipmap); - // The system-memory data can be purged now. - Z_ChangeTag(grtex->mipmap.data, PU_HWRCACHE_UNLOCKED); - - if ((texturenum = R_GetTextureBrightmap(texturenum))) - { - // Every texture in memory, stored as a 8-bit flat. Wow! - grtex = &gl_flats[texturenum]; - - // Generate flat if missing from the cache - if (!grtex->mipmap.data && !grtex->mipmap.downloaded) - HWR_CacheTextureAsFlat(&grtex->mipmap, texturenum, true); - - grtex->mipmap.flags |= TF_BRIGHTMAP; - - // If hardware does not have the texture, then call pfnSetTexture to upload it - if (!grtex->mipmap.downloaded) - HWD.pfnSetTexture(&grtex->mipmap); - HWR_SetCurrentTexture(&grtex->mipmap); - - // The system-memory data can be purged now. - Z_ChangeTag(grtex->mipmap.data, PU_HWRCACHE_UNLOCKED); - } + Z_ChangeTag(grMipmap->data, PU_HWRCACHE_UNLOCKED); } - else if (levelflat->type == LEVELFLAT_PATCH) - { - patch_t *patch = W_CachePatchNum(levelflat->u.flat.lumpnum, PU_CACHE); - levelflat->width = (UINT16)(patch->width); - levelflat->height = (UINT16)(patch->height); - HWR_GetPatch(patch); - } -#ifndef NO_PNG_LUMPS - else if (levelflat->type == LEVELFLAT_PNG) - { - GLMipmap_t *mipmap = levelflat->mipmap; - - // Cache the picture. - if (!levelflat->mippic) - { - INT32 pngwidth = 0, pngheight = 0; - void *pic = Picture_PNGConvert(W_CacheLumpNum(levelflat->u.flat.lumpnum, PU_CACHE), PICFMT_FLAT, &pngwidth, &pngheight, NULL, NULL, W_LumpLength(levelflat->u.flat.lumpnum), NULL, 0); - - Z_ChangeTag(pic, PU_LEVEL); - Z_SetUser(pic, &levelflat->mippic); - - levelflat->width = (UINT16)pngwidth; - levelflat->height = (UINT16)pngheight; - } - - // Make the mipmap. - if (mipmap == NULL) - { - mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_STATIC, NULL); - mipmap->format = GL_TEXFMT_P_8; - mipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; - levelflat->mipmap = mipmap; - } - - if (!mipmap->data && !mipmap->downloaded) - { - UINT8 *flat; - size_t size; - - if (levelflat->mippic == NULL) - I_Error("HWR_GetLevelFlat: levelflat->mippic == NULL"); - - mipmap->width = levelflat->width; - mipmap->height = levelflat->height; - - size = (mipmap->width * mipmap->height); - flat = Z_Malloc(size, PU_LEVEL, &mipmap->data); - M_Memcpy(flat, levelflat->mippic, size); - } - - // Tell the hardware driver to bind the current texture to the flat's mipmap - HWR_SetCurrentTexture(mipmap); - } -#endif - else // set no texture - HWR_SetCurrentTexture(NULL); } // --------------------+ diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 24e5897fd..6a06bc4e8 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -396,8 +396,6 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool INT32 i; float flatxref,flatyref; float fflatwidth = 64.0f, fflatheight = 64.0f; - INT32 flatflag = 63; - boolean texflat = false; float scrollx = 0.0f, scrolly = 0.0f, anglef = 0.0f; angle_t angle = 0; FSurfaceInfo Surf; @@ -452,34 +450,16 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool // set texture for polygon if (levelflat != NULL) { - if (levelflat->type == LEVELFLAT_FLAT) - { - size_t len = W_LumpLength(levelflat->u.flat.lumpnum); - size_t sflatsize = R_FlatDimensionsFromLumpSize(len); - fflatwidth = fflatheight = (double)sflatsize; - flatflag = sflatsize-1; - } - else - { - if (levelflat->type == LEVELFLAT_TEXTURE) - { - fflatwidth = textures[levelflat->u.texture.num]->width; - fflatheight = textures[levelflat->u.texture.num]->height; - } - else if (levelflat->type == LEVELFLAT_PATCH || levelflat->type == LEVELFLAT_PNG) - { - fflatwidth = levelflat->width; - fflatheight = levelflat->height; - } - texflat = true; - } + texture_t *texture = textures[R_GetTextureNumForFlat(levelflat)]; + fflatwidth = texture->width; + fflatheight = texture->height; } else // set no texture HWR_SetCurrentTexture(NULL); // reference point for flat texture coord for each vertex around the polygon - flatxref = (float)(((fixed_t)pv->x & (~flatflag)) / fflatwidth); - flatyref = (float)(((fixed_t)pv->y & (~flatflag)) / fflatheight); + flatxref = 0.0; + flatyref = 0.0; // transform if (FOFsector != NULL) @@ -514,30 +494,13 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool } - if (angle) // Only needs to be done if there's an altered angle - { - tempxsow = flatxref; - tempytow = flatyref; - - anglef = ANG2RAD(InvAngle(angle)); - - flatxref = (tempxsow * cos(anglef)) - (tempytow * sin(anglef)); - flatyref = (tempxsow * sin(anglef)) + (tempytow * cos(anglef)); - } + anglef = ANG2RAD(InvAngle(angle)); #define SETUP3DVERT(vert, vx, vy) {\ - /* Hurdler: add scrolling texture on floor/ceiling */\ - if (texflat)\ - {\ - vert->s = (float)((vx) / fflatwidth) + scrollx;\ - vert->t = -(float)((vy) / fflatheight) + scrolly;\ - }\ - else\ - {\ - vert->s = (float)(((vx) / fflatwidth) - flatxref + scrollx);\ - vert->t = (float)(flatyref - ((vy) / fflatheight) + scrolly);\ - }\ -\ + /* Hurdler: add scrolling texture on floor/ceiling */ \ + vert->s = (float)(((vx) / fflatwidth) - flatxref + scrollx);\ + vert->t = (float)(flatyref - ((vy) / fflatheight) + scrolly);\ + \ /* Need to rotate before translate */\ if (angle) /* Only needs to be done if there's an altered angle */\ {\ @@ -2479,9 +2442,6 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, float height = FIXED_TO_FLOAT(fixedheight); // constant y for all points on the convex flat polygon float flatxref, flatyref; float fflatwidth = 64.0f, fflatheight = 64.0f; - INT32 flatflag = 63; - - boolean texflat = false; float scrollx = 0.0f, scrolly = 0.0f; angle_t angle = 0; @@ -2509,37 +2469,16 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, // set texture for polygon if (levelflat != NULL) { - if (levelflat->type == LEVELFLAT_FLAT) - { - size_t len = W_LumpLength(levelflat->u.flat.lumpnum); - size_t sflatsize = R_FlatDimensionsFromLumpSize(len); - fflatwidth = fflatheight = (double)sflatsize; - flatflag = sflatsize-1; - } - else - { - if (levelflat->type == LEVELFLAT_TEXTURE) - { - fflatwidth = textures[levelflat->u.texture.num]->width; - fflatheight = textures[levelflat->u.texture.num]->height; - } - else if (levelflat->type == LEVELFLAT_PATCH || levelflat->type == LEVELFLAT_PNG) - { - fflatwidth = levelflat->width; - fflatheight = levelflat->height; - } - texflat = true; - } + texture_t *texture = textures[R_GetTextureNumForFlat(levelflat)]; + fflatwidth = texture->width; + fflatheight = texture->height; } else // set no texture HWR_SetCurrentTexture(NULL); // reference point for flat texture coord for each vertex around the polygon - flatxref = FIXED_TO_FLOAT(polysector->origVerts[0].x); - flatyref = FIXED_TO_FLOAT(polysector->origVerts[0].y); - - flatxref = (float)(((fixed_t)flatxref & (~flatflag)) / fflatwidth); - flatyref = (float)(((fixed_t)flatyref & (~flatflag)) / fflatheight); + flatxref = 0.0; + flatyref = 0.0; // transform v3d = planeVerts; @@ -2575,44 +2514,19 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, } } - if (angle) // Only needs to be done if there's an altered angle - { - angle = (InvAngle(angle))>>ANGLETOFINESHIFT; - - // This needs to be done so that it scrolls in a different direction after rotation like software - /*tempxs = FLOAT_TO_FIXED(scrollx); - tempyt = FLOAT_TO_FIXED(scrolly); - scrollx = (FIXED_TO_FLOAT(FixedMul(tempxs, FINECOSINE(angle)) - FixedMul(tempyt, FINESINE(angle)))); - scrolly = (FIXED_TO_FLOAT(FixedMul(tempxs, FINESINE(angle)) + FixedMul(tempyt, FINECOSINE(angle))));*/ - - // This needs to be done so everything aligns after rotation - // It would be done so that rotation is done, THEN the translation, but I couldn't get it to rotate AND scroll like software does - tempxs = FLOAT_TO_FIXED(flatxref); - tempyt = FLOAT_TO_FIXED(flatyref); - flatxref = (FIXED_TO_FLOAT(FixedMul(tempxs, FINECOSINE(angle)) - FixedMul(tempyt, FINESINE(angle)))); - flatyref = (FIXED_TO_FLOAT(FixedMul(tempxs, FINESINE(angle)) + FixedMul(tempyt, FINECOSINE(angle)))); - } - for (i = 0; i < (INT32)nrPlaneVerts; i++,v3d++) { // Go from the polysector's original vertex locations // Means the flat is offset based on the original vertex locations - if (texflat) - { - v3d->s = (float)(FIXED_TO_FLOAT(polysector->origVerts[i].x) / fflatwidth) + scrollx; - v3d->t = -(float)(FIXED_TO_FLOAT(polysector->origVerts[i].y) / fflatheight) + scrolly; - } - else - { - v3d->s = (float)((FIXED_TO_FLOAT(polysector->origVerts[i].x) / fflatwidth) - flatxref + scrollx); - v3d->t = (float)(flatyref - (FIXED_TO_FLOAT(polysector->origVerts[i].y) / fflatheight) + scrolly); - } + v3d->s = (float)((FIXED_TO_FLOAT(polysector->origVerts[i].x) / fflatwidth) - flatxref + scrollx); + v3d->t = (float)(flatyref - (FIXED_TO_FLOAT(polysector->origVerts[i].y) / fflatheight) + scrolly); // Need to rotate before translate if (angle) // Only needs to be done if there's an altered angle { tempxs = FLOAT_TO_FIXED(v3d->s); tempyt = FLOAT_TO_FIXED(v3d->t); + angle = ANG2RAD(InvAngle(angle)); v3d->s = (FIXED_TO_FLOAT(FixedMul(tempxs, FINECOSINE(angle)) - FixedMul(tempyt, FINESINE(angle)))); v3d->t = (FIXED_TO_FLOAT(FixedMul(tempxs, FINESINE(angle)) + FixedMul(tempyt, FINECOSINE(angle)))); } diff --git a/src/p_setup.c b/src/p_setup.c index fdf2284ca..43c239f08 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -539,13 +539,8 @@ size_t P_PrecacheLevelFlats(void) flatmemory = 0; for (i = 0; i < numlevelflats; i++) { - if (levelflats[i].type == LEVELFLAT_FLAT) - { - lump = levelflats[i].u.flat.lumpnum; - if (devparm) - flatmemory += W_LumpLength(lump); - R_GetFlat(lump); - } + if (levelflats[i].type != LEVELFLAT_NONE) + R_GetFlat(&levelflats[i]); } return flatmemory; } @@ -557,18 +552,8 @@ or NULL if we want to allocate it now. static INT32 Ploadflat (levelflat_t *levelflat, const char *flatname, boolean resize) { -#ifndef NO_PNG_LUMPS - UINT8 buffer[8]; -#endif - - lumpnum_t flatnum; - int texturenum; - UINT8 *flatpatch; - size_t lumplength; - size_t i; - // Scan through the already found flats, return if it matches. - for (i = 0; i < numlevelflats; i++) + for (size_t i = 0; i < numlevelflats; i++) { if (strnicmp(levelflat[i].name, flatname, 8) == 0) return i; @@ -592,65 +577,38 @@ Ploadflat (levelflat_t *levelflat, const char *flatname, boolean resize) strlcpy(levelflat->name, flatname, sizeof (levelflat->name)); strupr(levelflat->name); - /* If we can't find a flat, try looking for a texture! */ - if (( flatnum = R_GetFlatNumForName(levelflat->name) ) == LUMPERROR) - { - if (( texturenum = R_CheckTextureNumForName(levelflat->name) ) == -1) - { - // check for REDWALL - if (( texturenum = R_CheckTextureNumForName(MISSING_TEXTURE) ) != -1) - goto texturefound; - // check for REDFLR - else if (( flatnum = R_GetFlatNumForName(MISSING_TEXTURE) ) != LUMPERROR) - goto flatfound; - // nevermind - levelflat->type = LEVELFLAT_NONE; - } - else - { -texturefound: - levelflat->type = LEVELFLAT_TEXTURE; - levelflat->u.texture. num = texturenum; - levelflat->u.texture.lastnum = texturenum; - /* start out unanimated */ - levelflat->u.texture.basenum = -1; - } - } - else - { -flatfound: - /* This could be a flat, patch, or PNG. */ - flatpatch = W_CacheLumpNum(flatnum, PU_CACHE); - lumplength = W_LumpLength(flatnum); - if (Picture_CheckIfDoomPatch((softwarepatch_t *)flatpatch, lumplength)) - levelflat->type = LEVELFLAT_PATCH; - else - { -#ifndef NO_PNG_LUMPS - /* - Only need eight bytes for PNG headers. - FIXME: Put this elsewhere. - */ - W_ReadLumpHeader(flatnum, buffer, 8, 0); - if (Picture_IsLumpPNG(buffer, lumplength)) - levelflat->type = LEVELFLAT_PNG; - else -#endif/*NO_PNG_LUMPS*/ - levelflat->type = LEVELFLAT_FLAT;/* phew */ - } - if (flatpatch) - Z_Free(flatpatch); + levelflat->type = LEVELFLAT_TEXTURE; - levelflat->u.flat. lumpnum = flatnum; - levelflat->u.flat.baselumpnum = LUMPERROR; + // Look for a flat + int texturenum = R_CheckFlatNumForName(levelflat->name); + if (texturenum <= 0) + { + // If we can't find a flat, try looking for a texture! + texturenum = R_CheckTextureNumForName(levelflat->name); + if (texturenum <= 0) + { + // Use "not found" texture + texturenum = R_CheckTextureNumForName("REDWALL"); + + // Give up? + if (texturenum <= 0) + { + levelflat->type = LEVELFLAT_NONE; + texturenum = -1; + } + } } + levelflat->texture_id = texturenum; + levelflat->terrain = K_GetTerrainForTextureName(levelflat->name); +#ifndef ZDEBUG CONS_Debug(DBG_SETUP, "flat #%03d: %s\n", atoi(sizeu1(numlevelflats)), levelflat->name); +#endif - return ( numlevelflats++ ); + return numlevelflats++; } // Auxiliary function. Find a flat in the active wad files, @@ -3784,9 +3742,6 @@ static boolean P_LoadMapData(const virtres_t *virt) levelflats = M_Memcpy(Z_Calloc(numlevelflats * sizeof (*levelflats), PU_LEVEL, NULL), foundflats, numlevelflats * sizeof (levelflat_t)); free(foundflats); - // search for animated flats and set up - P_SetupLevelFlatAnims(); - TracyCZoneEnd(__zone); return true; } diff --git a/src/p_setup.h b/src/p_setup.h index 3b1f5ae29..c7c438d3d 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -54,9 +54,6 @@ extern mapnamespace_t mapnamespace; enum { LEVELFLAT_NONE,/* HOM time my friend */ - LEVELFLAT_FLAT, - LEVELFLAT_PATCH, - LEVELFLAT_PNG, LEVELFLAT_TEXTURE, }; @@ -66,43 +63,9 @@ enum struct levelflat_t { char name[9]; // resource name from wad - - UINT8 type; - union - { - struct - { - lumpnum_t lumpnum; // lump number of the flat - // for flat animation - lumpnum_t baselumpnum; - } - flat; - struct - { - INT32 num; - INT32 lastnum; // texture number of the flat - // for flat animation - INT32 basenum; - } - texture; - } - u; - - UINT16 width, height; - terrain_t *terrain; - - // for flat animation - INT32 animseq; // start pos. in the anim sequence - INT32 numpics; - INT32 speed; - - // for textures - UINT8 *picture; -#ifdef HWRENDER - void *mipmap; - void *mippic; -#endif + UINT8 type; + INT32 texture_id; }; extern size_t numlevelflats; diff --git a/src/p_spec.c b/src/p_spec.c index 7a9efc6b6..bce69e446 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -217,11 +217,11 @@ void P_InitPicAnims(void) } else { - if ((W_CheckNumForName(animdefs[i].startname)) == LUMPERROR) + if (R_CheckFlatNumForName(animdefs[i].startname) == -1) continue; - lastanim->picnum = R_GetFlatNumForName(animdefs[i].endname); - lastanim->basepic = R_GetFlatNumForName(animdefs[i].startname); + lastanim->picnum = R_CheckFlatNumForName(animdefs[i].endname); + lastanim->basepic = R_CheckFlatNumForName(animdefs[i].startname); } lastanim->istexture = animdefs[i].istexture; @@ -449,82 +449,13 @@ void P_ParseAnimationDefintion(SINT8 istexture) animdefs[i].speed = animSpeed; Z_Free(animdefsToken); -#ifdef WALLFLATS - // hehe... uhh..... + // Add it as a texture too if (!istexture) { GrowAnimDefs(); M_Memcpy(&animdefs[maxanims-1], &animdefs[i], sizeof(animdef_t)); animdefs[maxanims-1].istexture = 1; } -#endif -} - -/** Checks for flats in levelflats that are part of a flat animation sequence - * and sets them up for animation. - * - * \param animnum Index into ::anims to find flats for. - * \sa P_SetupLevelFlatAnims - */ -static inline void P_FindAnimatedFlat(INT32 animnum) -{ - size_t i; - lumpnum_t startflatnum, endflatnum; - levelflat_t *foundflats; - - foundflats = levelflats; - startflatnum = anims[animnum].basepic; - endflatnum = anims[animnum].picnum; - - // note: high word of lumpnum is the wad number - if ((startflatnum>>16) != (endflatnum>>16)) - I_Error("AnimatedFlat start %s not in same wad as end %s\n", - animdefs[animnum].startname, animdefs[animnum].endname); - - // - // now search through the levelflats if this anim flat sequence is used - // - for (i = 0; i < numlevelflats; i++, foundflats++) - { - // is that levelflat from the flat anim sequence ? - if ((anims[animnum].istexture) && (foundflats->type == LEVELFLAT_TEXTURE) - && ((UINT16)foundflats->u.texture.num >= startflatnum && (UINT16)foundflats->u.texture.num <= endflatnum)) - { - foundflats->u.texture.basenum = startflatnum; - foundflats->animseq = foundflats->u.texture.num - startflatnum; - foundflats->numpics = endflatnum - startflatnum + 1; - foundflats->speed = anims[animnum].speed; - - CONS_Debug(DBG_SETUP, "animflat: #%03d name:%.8s animseq:%d numpics:%d speed:%d\n", - atoi(sizeu1(i)), foundflats->name, foundflats->animseq, - foundflats->numpics,foundflats->speed); - } - else if ((!anims[animnum].istexture) && (foundflats->type == LEVELFLAT_FLAT) - && (foundflats->u.flat.lumpnum >= startflatnum && foundflats->u.flat.lumpnum <= endflatnum)) - { - foundflats->u.flat.baselumpnum = startflatnum; - foundflats->animseq = foundflats->u.flat.lumpnum - startflatnum; - foundflats->numpics = endflatnum - startflatnum + 1; - foundflats->speed = anims[animnum].speed; - - CONS_Debug(DBG_SETUP, "animflat: #%03d name:%.8s animseq:%d numpics:%d speed:%d\n", - atoi(sizeu1(i)), foundflats->name, foundflats->animseq, - foundflats->numpics,foundflats->speed); - } - } -} - -/** Sets up all flats used in a level. - * - * \sa P_InitPicAnims, P_FindAnimatedFlat - */ -void P_SetupLevelFlatAnims(void) -{ - INT32 i; - - // the original game flat anim sequences - for (i = 0; anims[i].istexture != -1; i++) - P_FindAnimatedFlat(i); } // @@ -6155,13 +6086,6 @@ void P_CheckMobjTouchingSectorActions(mobj_t *mobj, boolean continuous, boolean */ void P_UpdateSpecials(void) { - anim_t *anim; - INT32 i; - INT32 pic; - size_t j; - - levelflat_t *foundflats; // for flat animation - // LEVEL TIMER P_CheckTimeLimit(); @@ -6169,37 +6093,19 @@ void P_UpdateSpecials(void) P_CheckPointLimit(); // ANIMATE TEXTURES - for (anim = anims; anim < lastanim; anim++) + for (anim_t *anim = anims; anim < lastanim; anim++) { - for (i = 0; i < anim->numpics; i++) + for (INT32 i = 0; i < anim->numpics; i++) { - pic = anim->basepic + ((leveltime/anim->speed + i) % anim->numpics); + INT32 pic = anim->basepic + ((leveltime/anim->speed + i) % anim->numpics); if (anim->istexture) texturetranslation[anim->basepic+i] = pic; } } - - // ANIMATE FLATS - /// \todo do not check the non-animate flat.. link the animated ones? - /// \note its faster than the original anywaysince it animates only - /// flats used in the level, and there's usually very few of them - foundflats = levelflats; - for (j = 0; j < numlevelflats; j++, foundflats++) - { - if (foundflats->speed) // it is an animated flat - { - // update the levelflat texture number - if ((foundflats->type == LEVELFLAT_TEXTURE) && (foundflats->u.texture.basenum != -1)) - foundflats->u.texture.num = foundflats->u.texture.basenum + ((leveltime/foundflats->speed + foundflats->animseq) % foundflats->numpics); - // update the levelflat lump number - else if ((foundflats->type == LEVELFLAT_FLAT) && (foundflats->u.flat.baselumpnum != LUMPERROR)) - foundflats->u.flat.lumpnum = foundflats->u.flat.baselumpnum + ((leveltime/foundflats->speed + foundflats->animseq) % foundflats->numpics); - } - } } // -// Floor over floors (FOFs), 3Dfloors, 3Dblocks, fake floors (ffloors), rovers, or whatever you want to call them +// 3D floors // /** Gets the ID number for a 3Dfloor in its target sector. diff --git a/src/p_spec.h b/src/p_spec.h index 9b247ab7f..a3fba69ab 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -526,9 +526,6 @@ void P_StartQuake(fixed_t intensity, tic_t time); // at game start void P_InitPicAnims(void); -// at map load (sectors) -void P_SetupLevelFlatAnims(void); - // at map load void P_InitSpecials(void); void P_ApplyFlatAlignment(sector_t* sector, angle_t flatangle, fixed_t xoffs, fixed_t yoffs, boolean floor, boolean ceiling); diff --git a/src/r_picformats.c b/src/r_picformats.c index c382bcbc0..db33c33d6 100644 --- a/src/r_picformats.c +++ b/src/r_picformats.c @@ -764,7 +764,7 @@ void *Picture_TextureToFlat(size_t trickytex) R_CheckTextureCache(tex); // Allocate the flat - flatsize = (texture->width * texture->height); + flatsize = texture->width * texture->height; converted = Z_Malloc(flatsize, PU_STATIC, NULL); memset(converted, TRANSPARENTPIXEL, flatsize); diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 87a4fd308..61be014f9 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1118,39 +1118,32 @@ void R_DrawSinglePlane(drawspandata_t *ds, visplane_t *pl, boolean allow_paralle ds->currentplane = pl; levelflat = &levelflats[pl->picnum]; - /* :james: */ - type = levelflat->type; - switch (type) - { - case LEVELFLAT_NONE: - return; - case LEVELFLAT_FLAT: - ds->source = (UINT8 *)R_GetFlat(levelflat->u.flat.lumpnum); - R_CheckFlatLength(ds, W_LumpLength(levelflat->u.flat.lumpnum)); - // Raw flats always have dimensions that are powers-of-two numbers. - ds->powersoftwo = true; - break; - default: - ds->source = (UINT8 *)R_GetLevelFlat(ds, levelflat); - if (!ds->source) - return; - // Check if this texture or patch has power-of-two dimensions. - if (R_CheckPowersOfTwo(ds)) - R_CheckFlatLength(ds, ds->flatwidth * ds->flatheight); - } + // Get the texture + ds->source = (UINT8 *)R_GetFlat(levelflat); + if (ds->source == NULL) + return; - if (type == LEVELFLAT_TEXTURE) + texture_t *texture = textures[R_GetTextureNumForFlat(levelflat)]; + ds->flatwidth = texture->width; + ds->flatheight = texture->height; + + /*(if (R_CheckSolidColorFlat()) + ds->solidcolor = true; + else if (R_CheckPowersOfTwo()) { - // Get the span's brightmap. - // FLATS not supported, SORRY!! - INT32 bmNum = R_GetTextureBrightmap(levelflat->u.texture.num); - if (bmNum != 0) - { - // FIXME: This has the potential to read out of - // bounds if the brightmap texture is not as - // large as the flat. - ds->brightmap = (UINT8 *)R_GenerateTextureAsFlat(bmNum); - } + R_SetFlatVars(ds_flatwidth * ds_flatheight); + ds->powersoftwo = true; + }*/ + + // Get the span's brightmap. + // FLATS not supported, SORRY!! + INT32 bmNum = R_GetTextureBrightmap(levelflat->texture_id); + if (bmNum != 0) + { + // FIXME: This has the potential to read out of + // bounds if the brightmap texture is not as + // large as the flat. + ds->brightmap = (UINT8 *)R_GetFlatForTexture(bmNum); } if (!pl->slope // Don't mess with angle on slopes! We'll handle this ourselves later diff --git a/src/r_textures.c b/src/r_textures.c index 7232216d9..29f7747da 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -66,6 +66,7 @@ static struct { char name[9]; UINT32 hash; INT32 id; + UINT8 type; } *tidcache = NULL; static INT32 tidcachelen = 0; @@ -361,7 +362,8 @@ UINT8 *R_GenerateTexture(size_t texnum) texture = textures[texnum]; I_Assert(texture != NULL); - // allocate texture column offset lookup + if (texture->type == TEXTURETYPE_FLAT) + goto multipatch; // single-patch textures can have holes in them and may be used on // 2sided lines so they need to be kept in 'packed' format @@ -390,11 +392,8 @@ UINT8 *R_GenerateTexture(size_t texnum) realpatch = (softwarepatch_t *)pdata; #ifndef NO_PNG_LUMPS - if (Picture_IsLumpPNG((UINT8 *)realpatch, lumplength)) - goto multipatch; -#endif -#ifdef WALLFLATS - if (texture->type == TEXTURETYPE_FLAT) + // TODO: Is it worth converting those? + if (Picture_IsLumpPNG(pdata, lumplength)) goto multipatch; #endif @@ -495,7 +494,6 @@ UINT8 *R_GenerateTexture(size_t texnum) realpatch = (softwarepatch_t *)Picture_PNGConvert((UINT8 *)realpatch, PICFMT_DOOMPATCH, NULL, NULL, NULL, NULL, lumplength, NULL, 0); else #endif -#ifdef WALLFLATS if (texture->type == TEXTURETYPE_FLAT) { if (doremap) @@ -503,7 +501,6 @@ UINT8 *R_GenerateTexture(size_t texnum) realpatch = (softwarepatch_t *)Picture_Convert(PICFMT_FLAT, pdata, PICFMT_DOOMPATCH, 0, NULL, texture->width, texture->height, 0, 0, 0); } else -#endif { dealloc = false; if (doremap) @@ -562,29 +559,38 @@ done: return blocktex; } -// -// R_GenerateTextureAsFlat -// -// Generates a flat picture for a texture. -// -UINT8 *R_GenerateTextureAsFlat(size_t texnum) +UINT8 *R_GetFlatForTexture(size_t texnum) { texture_t *texture = textures[texnum]; - UINT8 *converted = NULL; - size_t size = (texture->width * texture->height); - // The flat picture for this texture was not generated yet. - if (!texture->flat) + if (texture->flat != NULL) + return texture->flat; + + if (texture->type == TEXTURETYPE_FLAT) { - // Well, let's do it now, then. - Z_Malloc(size, PU_LEVEL, &texture->flat); + texpatch_t *patch = &texture->patches[0]; + UINT16 wadnum = patch->wad; + lumpnum_t lumpnum = patch->lump; + UINT8 *pdata = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); - // Picture_TextureToFlat handles everything for us. - converted = (UINT8 *)Picture_TextureToFlat(texnum); - M_Memcpy(texture->flat, converted, size); - Z_Free(converted); +#ifndef NO_PNG_LUMPS + size_t lumplength = W_LumpLengthPwad(wadnum, lumpnum); + if (Picture_IsLumpPNG(pdata, lumplength)) + { + texture->flat = Picture_PNGConvert(pdata, PICFMT_FLAT, NULL, NULL, NULL, NULL, lumplength, NULL, 0); + Z_Free(pdata); + } + else +#endif + texture->flat = pdata; + + return texture->flat; } + texture->flat = (UINT8 *)Picture_TextureToFlat(texnum); + + flatmemory += texture->width + texture->height; + return texture->flat; } @@ -935,96 +941,26 @@ UINT8 *R_GetBrightmapColumn(fixed_t tex, INT32 col) return texturebrightmapcache[tex] + LONG(texturecolumnofs[tex][wrap_column(tex, col)]); } -void *R_GetFlat(lumpnum_t flatlumpnum) +INT32 R_GetTextureNumForFlat(levelflat_t *levelflat) { - // FIXME: checking this every time a flat is fetched for drawing is stupid... - // sadly they are not cached anywhere else so i have no choice - boolean doremap = W_NeedPaletteRemap(flatlumpnum, false); - void *flat = W_CacheLumpNum(flatlumpnum, PU_LEVEL); - if (doremap) - R_DoPaletteRemapFlat(flat, W_LumpLength(flatlumpnum)); - return flat; + return texturetranslation[levelflat->texture_id]; } -// -// R_GetLevelFlat -// -// If needed, convert a texture or patch to a flat. -// -void *R_GetLevelFlat(drawspandata_t* ds, levelflat_t *levelflat) +void *R_GetFlat(levelflat_t *levelflat) { - boolean isleveltexture = (levelflat->type == LEVELFLAT_TEXTURE); - texture_t *texture = (isleveltexture ? textures[levelflat->u.texture.num] : NULL); - boolean texturechanged = (isleveltexture ? (levelflat->u.texture.num != levelflat->u.texture.lastnum) : false); - UINT8 *flatdata = NULL; + if (levelflat->type == LEVELFLAT_NONE) + return NULL; - // Check if the texture changed. - if (isleveltexture && (!texturechanged)) - { - if (texture->flat) - { - flatdata = texture->flat; - ds->flatwidth = texture->width; - ds->flatheight = texture->height; - texturechanged = false; - } - else - texturechanged = true; - } + // FIXME: checking this every time a flat is fetched for drawing is stupid... + // sadly they are not cached anywhere else so i have no choice + /*boolean doremap = W_NeedPaletteRemap(flatlumpnum, false); + void *flat = W_CacheLumpNum(flatlumpnum, PU_LEVEL); + if (doremap) + R_DoPaletteRemapFlat(flat, W_LumpLength(levelflat->texture_id)); + return flat;*/ - // If the texture changed, or the flat wasn't generated, convert. - if (levelflat->picture == NULL || texturechanged) - { - // Level texture - if (isleveltexture) - { - levelflat->picture = R_GenerateTextureAsFlat(levelflat->u.texture.num); - ds->flatwidth = levelflat->width = texture->width; - ds->flatheight = levelflat->height = texture->height; - } - else - { -#ifndef NO_PNG_LUMPS - if (levelflat->type == LEVELFLAT_PNG) - { - INT32 pngwidth, pngheight; - - levelflat->picture = Picture_PNGConvert(W_CacheLumpNum(levelflat->u.flat.lumpnum, PU_LEVEL), PICFMT_FLAT, &pngwidth, &pngheight, NULL, NULL, W_LumpLength(levelflat->u.flat.lumpnum), NULL, 0); - levelflat->width = (UINT16)pngwidth; - levelflat->height = (UINT16)pngheight; - - ds->flatwidth = levelflat->width; - ds->flatheight = levelflat->height; - } - else -#endif - if (levelflat->type == LEVELFLAT_PATCH) - { - UINT8 *converted; - size_t size; - softwarepatch_t *patch = W_CacheLumpNum(levelflat->u.flat.lumpnum, PU_LEVEL); - - levelflat->width = ds->flatwidth = SHORT(patch->width); - levelflat->height = ds->flatheight = SHORT(patch->height); - - levelflat->picture = Z_Malloc(levelflat->width * levelflat->height, PU_LEVEL, NULL); - converted = Picture_FlatConvert(PICFMT_DOOMPATCH, patch, PICFMT_FLAT, 0, &size, levelflat->width, levelflat->height, SHORT(patch->topoffset), SHORT(patch->leftoffset), 0); - M_Memcpy(levelflat->picture, converted, size); - Z_Free(converted); - } - } - } - else - { - ds->flatwidth = levelflat->width; - ds->flatheight = levelflat->height; - } - - levelflat->u.texture.lastnum = levelflat->u.texture.num; - - if (flatdata == NULL) - flatdata = levelflat->picture; - return flatdata; + // FIXME: How do I convert above for new format. + return R_GetFlatForTexture(R_GetTextureNumForFlat(levelflat)); } // @@ -1178,7 +1114,6 @@ void R_FlushTextureCache(void) int R_CountTexturesInTEXTURESLump(UINT16 wadNum, UINT16 lumpNum); void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *index); -#ifdef WALLFLATS static INT32 Rloadflats (INT32 i, INT32 w) { @@ -1188,7 +1123,6 @@ Rloadflats (INT32 i, INT32 w) texpatch_t *patch; UINT8 header[PNG_HEADER_SIZE]; - // Yes if (wadfiles[w]->type == RET_PK3) { texstart = W_CheckNumForFolderStartPK3("flats/", (UINT16)w, 0); @@ -1207,8 +1141,6 @@ Rloadflats (INT32 i, INT32 w) { UINT16 wadnum = (UINT16)w; lumpnum_t lumpnum = texstart + j; - size_t lumplength; - size_t flatsize = 0; if (wadfiles[w]->type == RET_PK3) { @@ -1216,10 +1148,8 @@ Rloadflats (INT32 i, INT32 w) continue; // If it is then SKIP IT } - W_ReadLumpHeaderPwad(wadnum, lumpnum, header, sizeof header, 0); - lumplength = W_LumpLengthPwad(wadnum, lumpnum); - - flatsize = R_FlatDimensionsFromLumpSize(lumplength); + size_t lumplength = W_LumpLengthPwad(wadnum, lumpnum); + size_t flatsize = R_FlatDimensionsFromLumpSize(lumplength); //CONS_Printf("\n\"%s\" is a flat, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),flatsize,flatsize); texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL); @@ -1229,6 +1159,8 @@ Rloadflats (INT32 i, INT32 w) texture->hash = quickncasehash(texture->name, 8); #ifndef NO_PNG_LUMPS + W_ReadLumpHeaderPwad(wadnum, lumpnum, header, sizeof header, 0); + if (Picture_IsLumpPNG(header, lumplength)) { UINT8 *flatlump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); @@ -1264,7 +1196,6 @@ Rloadflats (INT32 i, INT32 w) return i; } -#endif/*WALLFLATS*/ #define TX_START "TX_START" #define TX_END "TX_END" @@ -1424,9 +1355,7 @@ static INT32 R_CountTextures(UINT16 wadnum) // This system will allocate memory for all duplicate/patched textures even if it never uses them, // but the alternative is to spend a ton of time checking and re-checking all previous entries just to skip any potentially patched textures. -#ifdef WALLFLATS count += count_range("F_START", "F_END", "flats/", wadnum); -#endif // Count the textures from TEXTURES lumps texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", wadnum, 0); @@ -1508,9 +1437,7 @@ void R_UpdateTextureBrightmap(INT32 tx, INT32 bm) static INT32 R_DefineTextures(INT32 i, UINT16 w) { -#ifdef WALLFLATS i = Rloadflats(i, w); -#endif return Rloadtextures(i, w); } @@ -2044,56 +1971,6 @@ static void PaletteTextureHack(const char **name) } } -// Search for flat name. -lumpnum_t R_GetFlatNumForName(const char *name) -{ - INT32 i; - lumpnum_t lump; - lumpnum_t start; - lumpnum_t end; - - PaletteTextureHack(&name); - - // Scan wad files backwards so patched flats take preference. - for (i = numwadfiles - 1; i >= 0; i--) - { - switch (wadfiles[i]->type) - { - case RET_WAD: - if ((start = W_CheckNumForMarkerStartPwad("F_START", (UINT16)i, 0)) == INT16_MAX) - { - if ((start = W_CheckNumForMarkerStartPwad("FF_START", (UINT16)i, 0)) == INT16_MAX) - continue; - else if ((end = W_CheckNumForNamePwad("FF_END", (UINT16)i, start)) == INT16_MAX) - continue; - } - else - if ((end = W_CheckNumForNamePwad("F_END", (UINT16)i, start)) == INT16_MAX) - continue; - break; - case RET_PK3: - if ((start = W_CheckNumForFolderStartPK3("Flats/", i, 0)) == INT16_MAX) - continue; - if ((end = W_CheckNumForFolderEndPK3("Flats/", i, start)) == INT16_MAX) - continue; - break; - default: - continue; - } - - // Now find lump with specified name in that range. - lump = W_CheckNumForNamePwad(name, (UINT16)i, start); - if (lump < end) - { - lump += (i<<16); // found it, in our constraints - break; - } - lump = LUMPERROR; - } - - return lump; -} - void R_ClearTextureNumCache(boolean btell) { if (tidcache) @@ -2104,6 +1981,20 @@ void R_ClearTextureNumCache(boolean btell) tidcachelen = 0; } +static void AddTextureToCache(const char *name, UINT32 hash, INT32 id, UINT8 type) +{ + tidcachelen++; + Z_Realloc(tidcache, tidcachelen * sizeof(*tidcache), PU_STATIC, &tidcache); + strncpy(tidcache[tidcachelen-1].name, name, 8); + tidcache[tidcachelen-1].name[8] = '\0'; +#ifndef ZDEBUG + CONS_Debug(DBG_SETUP, "texture #%s: %s\n", sizeu1(tidcachelen), tidcache[tidcachelen-1].name); +#endif + tidcache[tidcachelen-1].hash = hash; + tidcache[tidcachelen-1].id = id; + tidcache[tidcachelen-1].type = type; +} + // // R_CheckTextureNumForName // @@ -2126,18 +2017,10 @@ INT32 R_CheckTextureNumForName(const char *name) if (tidcache[i].hash == hash && !strncasecmp(tidcache[i].name, name, 8)) return tidcache[i].id; - // Need to parse the list backwards, so textures loaded more recently are used in lieu of ones loaded earlier - //for (i = 0; i < numtextures; i++) <- old - for (i = (numtextures - 1); i >= 0; i--) // <- new + for (i = numtextures - 1; i >= 0; i--) if (textures[i]->hash == hash && !strncasecmp(textures[i]->name, name, 8)) { - tidcachelen++; - Z_Realloc(tidcache, tidcachelen * sizeof(*tidcache), PU_STATIC, &tidcache); - strncpy(tidcache[tidcachelen-1].name, name, 8); - tidcache[tidcachelen-1].name[8] = '\0'; - CONS_Debug(DBG_SETUP, "texture #%s: %s\n", sizeu1(tidcachelen), tidcache[tidcachelen-1].name); - tidcache[tidcachelen-1].hash = hash; - tidcache[tidcachelen-1].id = i; + AddTextureToCache(name, hash, i, textures[i]->type); return i; } @@ -2170,3 +2053,28 @@ INT32 R_TextureNumForName(const char *name) } return i; } + +INT32 R_CheckFlatNumForName(const char *name) +{ + INT32 i; + UINT32 hash; + + // "NoTexture" marker. + if (name[0] == '-') + return 0; + + hash = quickncasehash(name, 8); + + for (i = 0; i < tidcachelen; i++) + if (tidcache[i].type == TEXTURETYPE_FLAT && tidcache[i].hash == hash && !strncasecmp(tidcache[i].name, name, 8)) + return tidcache[i].id; + + for (i = numtextures - 1; i >= 0; i--) + if (textures[i]->hash == hash && !strncasecmp(textures[i]->name, name, 8) && textures[i]->type == TEXTURETYPE_FLAT) + { + AddTextureToCache(name, hash, i, TEXTURETYPE_FLAT); + return i; + } + + return -1; +} diff --git a/src/r_textures.h b/src/r_textures.h index 44f1b3d61..650cb523c 100644 --- a/src/r_textures.h +++ b/src/r_textures.h @@ -44,9 +44,7 @@ enum TEXTURETYPE_UNKNOWN, TEXTURETYPE_SINGLEPATCH, TEXTURETYPE_COMPOSITE, -#ifdef WALLFLATS TEXTURETYPE_FLAT, -#endif }; // A texture_t describes a rectangular texture, @@ -86,7 +84,7 @@ void R_FlushTextureCache(void); // Texture generation UINT8 *R_GenerateTexture(size_t texnum); -UINT8 *R_GenerateTextureAsFlat(size_t texnum); +UINT8 *R_GetFlatForTexture(size_t texnum); UINT8 *R_GenerateTextureBrightmap(size_t texnum); INT32 R_GetTextureNum(INT32 texnum); INT32 R_GetTextureBrightmap(INT32 texnum); @@ -98,10 +96,11 @@ void R_DoPaletteRemapPatch(softwarepatch_t *patch, size_t size); void R_DoPaletteRemapFlat(UINT8 *data, size_t size); // Retrieve texture data. -void *R_GetLevelFlat(drawspandata_t* ds, levelflat_t *levelflat); UINT8 *R_GetColumn(fixed_t tex, INT32 col); UINT8 *R_GetBrightmapColumn(fixed_t tex, INT32 col); -void *R_GetFlat(lumpnum_t flatnum); +void *R_GetFlat(levelflat_t *levelflat); + +INT32 R_GetTextureNumForFlat(levelflat_t *levelflat); boolean R_CheckPowersOfTwo(drawspandata_t* ds); void R_CheckFlatLength(drawspandata_t* ds, size_t size); @@ -111,7 +110,7 @@ void R_UpdateTextureBrightmap(INT32 tx, INT32 bm); // Returns the texture number for the texture name. INT32 R_TextureNumForName(const char *name); INT32 R_CheckTextureNumForName(const char *name); -lumpnum_t R_GetFlatNumForName(const char *name); +INT32 R_CheckFlatNumForName(const char *name); extern INT32 numtextures; From 6874f7ca70f6e351403f0a4d33e22232f9f452e5 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Sun, 25 May 2025 00:48:25 -0400 Subject: [PATCH 17/33] Fix brightmap overlays being drawn instead of regular texture: --- src/hardware/hw_cache.c | 2 ++ src/r_plane.cpp | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 7da9716c8..15c726a7c 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -1001,6 +1001,8 @@ void HWR_GetLevelFlat(levelflat_t *levelflat, boolean noencoremap) memcpy(Z_Malloc(size, PU_HWRCACHE, &grMipmap->data), R_GetFlatForTexture(brightmapnum), size); } + grtex->mipmap.flags |= TF_BRIGHTMAP; + if (!grMipmap->downloaded) HWD.pfnSetTexture(&grtex->mipmap); diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 61be014f9..cc9088256 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1136,7 +1136,6 @@ void R_DrawSinglePlane(drawspandata_t *ds, visplane_t *pl, boolean allow_paralle }*/ // Get the span's brightmap. - // FLATS not supported, SORRY!! INT32 bmNum = R_GetTextureBrightmap(levelflat->texture_id); if (bmNum != 0) { From c83d5cebd4ff4672f7f4f5d8883b9c1982764bd6 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Sun, 25 May 2025 02:01:33 -0400 Subject: [PATCH 18/33] AAAAAA I'll be honest what am I doing??? --- src/hardware/hw_cache.c | 7 +++++++ src/p_setup.c | 6 ++++-- src/p_setup.h | 1 + src/r_textures.c | 9 +++++---- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 15c726a7c..2d65d6511 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -991,6 +991,13 @@ void HWR_GetLevelFlat(levelflat_t *levelflat, boolean noencoremap) if (!grMipmap->data && !grMipmap->downloaded) { + UINT8 *colormap = colormaps; + + if (!noencoremap && encoremap) + { + colormap += COLORMAP_REMAPOFFSET; + } + grMipmap->format = GL_TEXFMT_P_8; grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; diff --git a/src/p_setup.c b/src/p_setup.c index 43c239f08..4777a78d5 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -532,7 +532,6 @@ levelflat_t *foundflats; //SoM: Other files want this info. size_t P_PrecacheLevelFlats(void) { - lumpnum_t lump; size_t i; //SoM: 4/18/2000: New flat code to make use of levelflats. @@ -581,6 +580,7 @@ Ploadflat (levelflat_t *levelflat, const char *flatname, boolean resize) // Look for a flat int texturenum = R_CheckFlatNumForName(levelflat->name); + lumpnum_t texturelump = W_CheckNumForName(levelflat->name); if (texturenum <= 0) { // If we can't find a flat, try looking for a texture! @@ -588,7 +588,8 @@ Ploadflat (levelflat_t *levelflat, const char *flatname, boolean resize) if (texturenum <= 0) { // Use "not found" texture - texturenum = R_CheckTextureNumForName("REDWALL"); + texturenum = R_CheckTextureNumForName(MISSING_TEXTURE); + texturelump = W_CheckNumForName(MISSING_TEXTURE); // Give up? if (texturenum <= 0) @@ -600,6 +601,7 @@ Ploadflat (levelflat_t *levelflat, const char *flatname, boolean resize) } levelflat->texture_id = texturenum; + levelflat->lump = texturelump; levelflat->terrain = K_GetTerrainForTextureName(levelflat->name); diff --git a/src/p_setup.h b/src/p_setup.h index c7c438d3d..b1cea67db 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -66,6 +66,7 @@ struct levelflat_t terrain_t *terrain; UINT8 type; INT32 texture_id; + lumpnum_t lump; }; extern size_t numlevelflats; diff --git a/src/r_textures.c b/src/r_textures.c index 29f7747da..3e99f4026 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -953,14 +953,15 @@ void *R_GetFlat(levelflat_t *levelflat) // FIXME: checking this every time a flat is fetched for drawing is stupid... // sadly they are not cached anywhere else so i have no choice - /*boolean doremap = W_NeedPaletteRemap(flatlumpnum, false); + lumpnum_t flatlumpnum = levelflat->lump; + boolean doremap = W_NeedPaletteRemap(flatlumpnum, false); void *flat = W_CacheLumpNum(flatlumpnum, PU_LEVEL); if (doremap) - R_DoPaletteRemapFlat(flat, W_LumpLength(levelflat->texture_id)); - return flat;*/ + R_DoPaletteRemapFlat(flat, W_LumpLength(flatlumpnum)); + return flat; // FIXME: How do I convert above for new format. - return R_GetFlatForTexture(R_GetTextureNumForFlat(levelflat)); + //return R_GetFlatForTexture(R_GetTextureNumForFlat(levelflat)); } // From b429a3e74cdf02f792f51cfe8f4a2249253a1264 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Sun, 25 May 2025 10:57:20 -0400 Subject: [PATCH 19/33] Repair removeflats commit to make it function correctly with colormapping --- src/hardware/hw_cache.c | 17 +++++++++-------- src/r_textures.c | 17 ++++++----------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 2d65d6511..25a950908 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -953,7 +953,9 @@ void HWR_GetLevelFlat(levelflat_t *levelflat, boolean noencoremap) if (!grMipmap->data && !grMipmap->downloaded) { + UINT8 *flat; UINT8 *colormap = colormaps; + UINT8 *converted; if (!noencoremap && encoremap) { @@ -967,7 +969,13 @@ void HWR_GetLevelFlat(levelflat_t *levelflat, boolean noencoremap) grMipmap->height = (UINT16)textures[texturenum]->height; size_t size = grMipmap->width * grMipmap->height; - memcpy(Z_Malloc(size, PU_HWRCACHE, &grMipmap->data), R_GetFlatForTexture(texturenum), size); + flat = Z_Malloc(size, PU_HWRCACHE, &grMipmap->data); + converted = (UINT8 *)Picture_TextureToFlat(texturenum); + for (size_t i = 0; i < size; i++) + { + flat[i] = colormap[converted[i]]; + } + Z_Free(converted); if (!noencoremap && encoremap) { @@ -991,13 +999,6 @@ void HWR_GetLevelFlat(levelflat_t *levelflat, boolean noencoremap) if (!grMipmap->data && !grMipmap->downloaded) { - UINT8 *colormap = colormaps; - - if (!noencoremap && encoremap) - { - colormap += COLORMAP_REMAPOFFSET; - } - grMipmap->format = GL_TEXFMT_P_8; grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; diff --git a/src/r_textures.c b/src/r_textures.c index 3e99f4026..28e60090e 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -571,7 +571,12 @@ UINT8 *R_GetFlatForTexture(size_t texnum) texpatch_t *patch = &texture->patches[0]; UINT16 wadnum = patch->wad; lumpnum_t lumpnum = patch->lump; + boolean doremap = W_NeedPaletteRemapPwad(wadnum, lumpnum, false); UINT8 *pdata = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); + if (doremap) + { + R_DoPaletteRemapFlat(pdata, W_LumpLengthPwad(wadnum, lumpnum)); + } #ifndef NO_PNG_LUMPS size_t lumplength = W_LumpLengthPwad(wadnum, lumpnum); @@ -951,17 +956,7 @@ void *R_GetFlat(levelflat_t *levelflat) if (levelflat->type == LEVELFLAT_NONE) return NULL; - // FIXME: checking this every time a flat is fetched for drawing is stupid... - // sadly they are not cached anywhere else so i have no choice - lumpnum_t flatlumpnum = levelflat->lump; - boolean doremap = W_NeedPaletteRemap(flatlumpnum, false); - void *flat = W_CacheLumpNum(flatlumpnum, PU_LEVEL); - if (doremap) - R_DoPaletteRemapFlat(flat, W_LumpLength(flatlumpnum)); - return flat; - - // FIXME: How do I convert above for new format. - //return R_GetFlatForTexture(R_GetTextureNumForFlat(levelflat)); + return R_GetFlatForTexture(R_GetTextureNumForFlat(levelflat)); } // From 41a62d7823a80318a20083674b60ea4ed06c6e70 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Sun, 25 May 2025 11:30:07 -0400 Subject: [PATCH 20/33] Do palette hack for flats as well --- src/r_textures.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/r_textures.c b/src/r_textures.c index 28e60090e..c9366688e 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -2059,6 +2059,8 @@ INT32 R_CheckFlatNumForName(const char *name) if (name[0] == '-') return 0; + PaletteTextureHack(&name); + hash = quickncasehash(name, 8); for (i = 0; i < tidcachelen; i++) From fbea771486e928dea2056ce9eef929cf0783981a Mon Sep 17 00:00:00 2001 From: Lactozilla Date: Mon, 15 Jan 2024 02:47:03 -0300 Subject: [PATCH 21/33] Cleanup R_GetFlatForTexture --- src/r_textures.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/r_textures.c b/src/r_textures.c index c9366688e..c1f1f7b9d 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -561,11 +561,14 @@ done: UINT8 *R_GetFlatForTexture(size_t texnum) { - texture_t *texture = textures[texnum]; + if (texnum >= (unsigned)numtextures) + return NULL; + texture_t *texture = textures[texnum]; if (texture->flat != NULL) return texture->flat; + // Special case: Textures that are flats don't need to be converted FROM a texture INTO a flat. if (texture->type == TEXTURETYPE_FLAT) { texpatch_t *patch = &texture->patches[0]; @@ -588,13 +591,11 @@ UINT8 *R_GetFlatForTexture(size_t texnum) else #endif texture->flat = pdata; - - return texture->flat; } + else + texture->flat = (UINT8 *)Picture_TextureToFlat(texnum); - texture->flat = (UINT8 *)Picture_TextureToFlat(texnum); - - flatmemory += texture->width + texture->height; + flatmemory += texture->width * texture->height; return texture->flat; } From fc03c880fbaf285e6243188dcf5679f656d3e083 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Sun, 25 May 2025 18:07:25 +0200 Subject: [PATCH 22/33] Fix flat corruption (from lacto's feffdb37) --- src/r_textures.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/r_textures.c b/src/r_textures.c index c1f1f7b9d..eb7abc5d9 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -576,21 +576,25 @@ UINT8 *R_GetFlatForTexture(size_t texnum) lumpnum_t lumpnum = patch->lump; boolean doremap = W_NeedPaletteRemapPwad(wadnum, lumpnum, false); UINT8 *pdata = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); + size_t lumplength = W_LumpLengthPwad(wadnum, lumpnum); if (doremap) { R_DoPaletteRemapFlat(pdata, W_LumpLengthPwad(wadnum, lumpnum)); } #ifndef NO_PNG_LUMPS - size_t lumplength = W_LumpLengthPwad(wadnum, lumpnum); if (Picture_IsLumpPNG(pdata, lumplength)) - { texture->flat = Picture_PNGConvert(pdata, PICFMT_FLAT, NULL, NULL, NULL, NULL, lumplength, NULL, 0); - Z_Free(pdata); - } else #endif - texture->flat = pdata; + { + texture->flat = Z_Malloc(lumplength, PU_STATIC, NULL); + memcpy(texture->flat, pdata, lumplength); + } + + Z_SetUser(texture->flat, &texture->flat); + + Z_Free(pdata); } else texture->flat = (UINT8 *)Picture_TextureToFlat(texnum); @@ -1104,7 +1108,10 @@ void R_FlushTextureCache(void) if (numtextures) for (i = 0; i < numtextures; i++) + { + Z_Free(textures[i]->flat); Z_Free(texturecache[i]); + } } // Need these prototypes for later; defining them here instead of r_textures.h so they're "private" From 2642e8d9727637633139e6346dafc2bb4c640fbf Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Sun, 25 May 2025 18:18:21 +0200 Subject: [PATCH 23/33] Get flat palremap working again --- src/p_setup.c | 3 --- src/p_setup.h | 1 - src/r_textures.c | 8 +++----- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 4777a78d5..234f8460d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -580,7 +580,6 @@ Ploadflat (levelflat_t *levelflat, const char *flatname, boolean resize) // Look for a flat int texturenum = R_CheckFlatNumForName(levelflat->name); - lumpnum_t texturelump = W_CheckNumForName(levelflat->name); if (texturenum <= 0) { // If we can't find a flat, try looking for a texture! @@ -589,7 +588,6 @@ Ploadflat (levelflat_t *levelflat, const char *flatname, boolean resize) { // Use "not found" texture texturenum = R_CheckTextureNumForName(MISSING_TEXTURE); - texturelump = W_CheckNumForName(MISSING_TEXTURE); // Give up? if (texturenum <= 0) @@ -601,7 +599,6 @@ Ploadflat (levelflat_t *levelflat, const char *flatname, boolean resize) } levelflat->texture_id = texturenum; - levelflat->lump = texturelump; levelflat->terrain = K_GetTerrainForTextureName(levelflat->name); diff --git a/src/p_setup.h b/src/p_setup.h index b1cea67db..c7c438d3d 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -66,7 +66,6 @@ struct levelflat_t terrain_t *terrain; UINT8 type; INT32 texture_id; - lumpnum_t lump; }; extern size_t numlevelflats; diff --git a/src/r_textures.c b/src/r_textures.c index eb7abc5d9..26ae8650d 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -574,13 +574,8 @@ UINT8 *R_GetFlatForTexture(size_t texnum) texpatch_t *patch = &texture->patches[0]; UINT16 wadnum = patch->wad; lumpnum_t lumpnum = patch->lump; - boolean doremap = W_NeedPaletteRemapPwad(wadnum, lumpnum, false); UINT8 *pdata = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); size_t lumplength = W_LumpLengthPwad(wadnum, lumpnum); - if (doremap) - { - R_DoPaletteRemapFlat(pdata, W_LumpLengthPwad(wadnum, lumpnum)); - } #ifndef NO_PNG_LUMPS if (Picture_IsLumpPNG(pdata, lumplength)) @@ -592,6 +587,9 @@ UINT8 *R_GetFlatForTexture(size_t texnum) memcpy(texture->flat, pdata, lumplength); } + if (W_NeedPaletteRemapPwad(wadnum, lumpnum, true)) + R_DoPaletteRemapFlat(texture->flat, lumplength); + Z_SetUser(texture->flat, &texture->flat); Z_Free(pdata); From 647bc08b3f832ee4c873b33bda8eb79ad06df7fe Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Sun, 25 May 2025 19:36:37 +0200 Subject: [PATCH 24/33] Fix chromakey in encore mode (+ cleanup) --- src/hardware/hw_cache.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 25a950908..54676f2f4 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -955,12 +955,6 @@ void HWR_GetLevelFlat(levelflat_t *levelflat, boolean noencoremap) { UINT8 *flat; UINT8 *colormap = colormaps; - UINT8 *converted; - - if (!noencoremap && encoremap) - { - colormap += COLORMAP_REMAPOFFSET; - } grMipmap->format = GL_TEXFMT_P_8; grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; @@ -969,20 +963,20 @@ void HWR_GetLevelFlat(levelflat_t *levelflat, boolean noencoremap) grMipmap->height = (UINT16)textures[texturenum]->height; size_t size = grMipmap->width * grMipmap->height; - flat = Z_Malloc(size, PU_HWRCACHE, &grMipmap->data); - converted = (UINT8 *)Picture_TextureToFlat(texturenum); - for (size_t i = 0; i < size; i++) - { - flat[i] = colormap[converted[i]]; - } - Z_Free(converted); + flat = Picture_TextureToFlat(texturenum); + Z_ChangeTag(flat, PU_HWRCACHE); + Z_SetUser(flat, &grMipmap->data); if (!noencoremap && encoremap) - { - grtex->mipmap.colormap = Z_Calloc(sizeof(*grtex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL); - grtex->mipmap.colormap->source = colormaps + COLORMAP_REMAPOFFSET; - M_Memcpy(grtex->mipmap.colormap->data, colormaps + COLORMAP_REMAPOFFSET, 256); - } + colormap += COLORMAP_REMAPOFFSET; + + grtex->mipmap.colormap = Z_Calloc(sizeof(*grtex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL); + grtex->mipmap.colormap->source = colormap; + M_Memcpy(grtex->mipmap.colormap->data, colormap, 256); + + for (size_t steppy = 0; steppy < size; steppy++) + if (flat[steppy] != HWR_PATCHES_CHROMAKEY_COLORINDEX) + flat[steppy] = grtex->mipmap.colormap->source[flat[steppy]]; } if (!grMipmap->downloaded) From f96c9e90952da97da8994f076d8ea755d480f1d0 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Sun, 25 May 2025 19:51:06 +0200 Subject: [PATCH 25/33] Forgot why this is necessary --- src/r_textures.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/r_textures.c b/src/r_textures.c index 26ae8650d..1a191828f 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -574,6 +574,7 @@ UINT8 *R_GetFlatForTexture(size_t texnum) texpatch_t *patch = &texture->patches[0]; UINT16 wadnum = patch->wad; lumpnum_t lumpnum = patch->lump; + boolean doremap = W_NeedPaletteRemapPwad(wadnum, lumpnum, false); UINT8 *pdata = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); size_t lumplength = W_LumpLengthPwad(wadnum, lumpnum); @@ -587,7 +588,7 @@ UINT8 *R_GetFlatForTexture(size_t texnum) memcpy(texture->flat, pdata, lumplength); } - if (W_NeedPaletteRemapPwad(wadnum, lumpnum, true)) + if (doremap) R_DoPaletteRemapFlat(texture->flat, lumplength); Z_SetUser(texture->flat, &texture->flat); From 8cfa0fa74ff3891c2c495f20007fe869d05cfb47 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Sun, 25 May 2025 14:00:41 -0400 Subject: [PATCH 26/33] Remove leftover flat animdef code --- src/p_spec.c | 85 ++++++++++++++++++++++++------------------------ src/r_textures.c | 1 + 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index bce69e446..06cda1111 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -66,17 +66,12 @@ mobj_t *skyboxcenterpnts[16]; // array of MT_SKYBOX centerpoint mobjs */ typedef struct { - SINT8 istexture; ///< ::true for a texture, ::false for a flat INT32 picnum; ///< The end flat number INT32 basepic; ///< The start flat number INT32 numpics; ///< Number of frames in the animation tic_t speed; ///< Number of tics for which each frame is shown } anim_t; -#if defined(_MSC_VER) -#pragma pack(1) -#endif - /** Animated texture definition. * Used for loading an ANIMDEFS lump from a wad. * @@ -91,13 +86,9 @@ typedef struct SINT8 istexture; ///< True for a texture, false for a flat. char endname[9]; ///< Name of the last frame, null-terminated. char startname[9]; ///< Name of the first frame, null-terminated. - INT32 speed ; ///< Number of tics for which each frame is shown. + INT32 speed; ///< Number of tics for which each frame is shown. } ATTRPACK animdef_t; -#if defined(_MSC_VER) -#pragma pack() -#endif - typedef struct { UINT32 count; @@ -142,17 +133,32 @@ static size_t maxanims; static animdef_t *animdefs = NULL; -// Increase the size of animdefs to make room for a new animation definition -static void GrowAnimDefs(void) -{ - maxanims++; - animdefs = (animdef_t *)Z_Realloc(animdefs, sizeof(animdef_t)*(maxanims + 1), PU_STATIC, NULL); -} - // A prototype; here instead of p_spec.h, so they're "private" void P_ParseANIMDEFSLump(INT32 wadNum, UINT16 lumpnum); void P_ParseAnimationDefintion(SINT8 istexture); +static boolean P_FindTextureForAnimation(anim_t *anim, animdef_t *animdef) +{ + if (R_CheckTextureNumForName(animdef->startname) == -1) + return false; + + anim->picnum = R_TextureNumForName(animdef->endname); + anim->basepic = R_TextureNumForName(animdef->startname); + + return true; +} + +static boolean P_FindFlatForAnimation(anim_t *anim, animdef_t *animdef) +{ + if (R_CheckFlatNumForName(animdef->startname) == -1) + return false; + + anim->picnum = R_CheckFlatNumForName(animdef->endname); + anim->basepic = R_CheckFlatNumForName(animdef->startname); + + return true; +} + /** Sets up texture and flat animations. * * Converts an ::animdef_t array loaded from a lump into @@ -207,37 +213,38 @@ void P_InitPicAnims(void) lastanim = anims; for (i = 0; animdefs[i].istexture != -1; i++) { - if (animdefs[i].istexture == 1) - { - if (R_CheckTextureNumForName(animdefs[i].startname) == -1) - continue; + animdef_t *animdef = &animdefs[i]; - lastanim->picnum = R_TextureNumForName(animdefs[i].endname); - lastanim->basepic = R_TextureNumForName(animdefs[i].startname); + // If this animation is for a texture, look for one first, THEN look for a flat + if (animdefs[i].istexture) + { + if (!P_FindTextureForAnimation(lastanim, animdef)) + { + if (!P_FindFlatForAnimation(lastanim, animdef)) + continue; + } } else { - if (R_CheckFlatNumForName(animdefs[i].startname) == -1) - continue; - - lastanim->picnum = R_CheckFlatNumForName(animdefs[i].endname); - lastanim->basepic = R_CheckFlatNumForName(animdefs[i].startname); + if (!P_FindFlatForAnimation(lastanim, animdef)) + { + if (!P_FindTextureForAnimation(lastanim, animdef)) + continue; + } } - lastanim->istexture = animdefs[i].istexture; lastanim->numpics = lastanim->picnum - lastanim->basepic + 1; if (lastanim->numpics < 2) { free(anims); I_Error("P_InitPicAnims: bad cycle from %s to %s", - animdefs[i].startname, animdefs[i].endname); + animdefs->startname, animdefs->endname); } - lastanim->speed = LONG(animdefs[i].speed); + lastanim->speed = animdef->speed; lastanim++; } - lastanim->istexture = -1; R_ClearTextureNumCache(false); // Clear animdefs now that we're done with it. @@ -362,7 +369,8 @@ void P_ParseAnimationDefintion(SINT8 istexture) if (i == maxanims) { // Increase the size to make room for the new animation definition - GrowAnimDefs(); + maxanims++; + animdefs = (animdef_t *)Z_Realloc(animdefs, sizeof(animdef_t)*(maxanims + 1), PU_STATIC, NULL); strncpy(animdefs[i].startname, animdefsToken, 9); } @@ -448,14 +456,6 @@ void P_ParseAnimationDefintion(SINT8 istexture) } animdefs[i].speed = animSpeed; Z_Free(animdefsToken); - - // Add it as a texture too - if (!istexture) - { - GrowAnimDefs(); - M_Memcpy(&animdefs[maxanims-1], &animdefs[i], sizeof(animdef_t)); - animdefs[maxanims-1].istexture = 1; - } } // @@ -6098,8 +6098,7 @@ void P_UpdateSpecials(void) for (INT32 i = 0; i < anim->numpics; i++) { INT32 pic = anim->basepic + ((leveltime/anim->speed + i) % anim->numpics); - if (anim->istexture) - texturetranslation[anim->basepic+i] = pic; + texturetranslation[anim->basepic+i] = pic; } } } diff --git a/src/r_textures.c b/src/r_textures.c index 1a191828f..d8c57b49d 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -2057,6 +2057,7 @@ INT32 R_TextureNumForName(const char *name) return i; } +// Like R_CheckTextureNumForName, but only looks in the flat namespace specifically. INT32 R_CheckFlatNumForName(const char *name) { INT32 i; From eab0f9410623d9937e53ffc6cfe8ec9943381979 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Sun, 25 May 2025 14:54:37 -0400 Subject: [PATCH 27/33] Make accel stacking more accurate to neptune --- src/k_kart.c | 7 ++++++- src/k_kart.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index cd3e7f2a5..840044bac 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3600,7 +3600,12 @@ static void K_GetKartBoostPower(player_t *player) for (i = 0; i < numsneakers; i++) { - K_DoBoost(player, sneakerspeedboost, SNEAKERACCELBOOST, SNEAKERSTACKABLE, SNEAKERSTACKABLE); // + ???% top speed, + 800% acceleration + K_DoBoost(player, sneakerspeedboost, ACCELSTACK ? 0 : SNEAKERACCELBOOST, SNEAKERSTACKABLE, SNEAKERSTACKABLE); // + ???% top speed, + 800% acceleration + } + + if (ACCELSTACK) + { + K_DoBoost(player, 0, SNEAKERACCELBOOST, true, false); // + 800% acceleration } } diff --git a/src/k_kart.h b/src/k_kart.h index 59e001bdd..f1a839a03 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -43,6 +43,7 @@ Make sure this matches the actual number of states #define MAXVANILLABOOST K_RAGuard(cv_kartstacking_maxvanillaboost) #define SPEEDBOOSTDROPOFF K_RAGuard(cv_kartstacking_speedboostdropoff) #define SPEEDBOOSTDROPOFF_BRAKE K_RAGuard(cv_kartstacking_speedboostdropoff_brake) +#define ACCELSTACK K_RAGuard(cv_kartstacking_accelstack) // Vanilla Boosts #define EASYSNEAKERSPEEDBOOST K_RAGuard(cv_kartstacking_sneaker_easyspeedboost) From c89333a92433bfaaee690ce0a6ef251206994d5e Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Sun, 25 May 2025 22:28:52 +0200 Subject: [PATCH 28/33] Get rid of the ancient Android backend Doesn't seem to have been properly maintained since 2009 --- Android.mk | 6 - android/.classpath | 7 - android/.project | 33 --- android/.settings/org.eclipse.jdt.core.prefs | 5 - android/Android.mk | 17 -- android/AndroidManifest.xml | 18 -- android/default.properties | 13 - android/gen/org/srb2/R.java | 26 -- android/res/drawable-hdpi/icon.png | Bin 4147 -> 0 bytes android/res/drawable-ldpi/icon.png | Bin 1723 -> 0 bytes android/res/drawable-mdpi/icon.png | Bin 2574 -> 0 bytes android/res/layout/main.xml | 9 - android/res/values/strings.xml | 5 - android/src/org/srb2/GameThread.java | 25 -- android/src/org/srb2/SRB2Game.java | 39 --- android/src/org/srb2/nativecode/Main.java | 13 - android/src/org/srb2/nativecode/SRB2.java | 35 --- android/src/org/srb2/nativecode/Video.java | 39 --- src/Android.mk | 90 ------ src/android/README | 43 --- src/android/i_cdmus.c | 37 --- src/android/i_main.c | 53 ---- src/android/i_net.c | 6 - src/android/i_sound.c | 214 -------------- src/android/i_system.c | 276 ------------------- src/android/i_video.c | 92 ------- src/android/i_video.h | 20 -- src/android/jni_main.h | 21 -- src/d_main.cpp | 4 - 29 files changed, 1146 deletions(-) delete mode 100644 Android.mk delete mode 100644 android/.classpath delete mode 100644 android/.project delete mode 100644 android/.settings/org.eclipse.jdt.core.prefs delete mode 100644 android/Android.mk delete mode 100644 android/AndroidManifest.xml delete mode 100644 android/default.properties delete mode 100644 android/gen/org/srb2/R.java delete mode 100644 android/res/drawable-hdpi/icon.png delete mode 100644 android/res/drawable-ldpi/icon.png delete mode 100644 android/res/drawable-mdpi/icon.png delete mode 100644 android/res/layout/main.xml delete mode 100644 android/res/values/strings.xml delete mode 100644 android/src/org/srb2/GameThread.java delete mode 100644 android/src/org/srb2/SRB2Game.java delete mode 100644 android/src/org/srb2/nativecode/Main.java delete mode 100644 android/src/org/srb2/nativecode/SRB2.java delete mode 100644 android/src/org/srb2/nativecode/Video.java delete mode 100644 src/Android.mk delete mode 100644 src/android/README delete mode 100644 src/android/i_cdmus.c delete mode 100644 src/android/i_main.c delete mode 100644 src/android/i_net.c delete mode 100644 src/android/i_sound.c delete mode 100644 src/android/i_system.c delete mode 100644 src/android/i_video.c delete mode 100644 src/android/i_video.h delete mode 100644 src/android/jni_main.h diff --git a/Android.mk b/Android.mk deleted file mode 100644 index 240dfa843..000000000 --- a/Android.mk +++ /dev/null @@ -1,6 +0,0 @@ -# Build both the native piece of SRB2 for Android, and the Java frontend. -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/android/.classpath b/android/.classpath deleted file mode 100644 index 609aa00eb..000000000 --- a/android/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/android/.project b/android/.project deleted file mode 100644 index 2654493b0..000000000 --- a/android/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - SRB2 - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/android/.settings/org.eclipse.jdt.core.prefs b/android/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index eda3d91ae..000000000 --- a/android/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -#Mon Nov 09 14:38:16 EST 2009 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.source=1.5 diff --git a/android/Android.mk b/android/Android.mk deleted file mode 100644 index 650337e5c..000000000 --- a/android/Android.mk +++ /dev/null @@ -1,17 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := user - -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_PACKAGE_NAME := SRB2 -LOCAL_CERTIFICATE := media - -LOCAL_REQUIRED_MODULES := libsrb2 -LOCAL_JNI_SHARED_LIBRARIES := libsrb2 - -include $(BUILD_PACKAGE) - -# Use the following include to make our test apk. -include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml deleted file mode 100644 index cc6a1db1c..000000000 --- a/android/AndroidManifest.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - diff --git a/android/default.properties b/android/default.properties deleted file mode 100644 index 5dad0b51a..000000000 --- a/android/default.properties +++ /dev/null @@ -1,13 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "build.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-4 -# Indicates whether an apk should be generated for each density. -split.density=false diff --git a/android/gen/org/srb2/R.java b/android/gen/org/srb2/R.java deleted file mode 100644 index 8db10bde5..000000000 --- a/android/gen/org/srb2/R.java +++ /dev/null @@ -1,26 +0,0 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ - -package org.srb2; - -public final class R { - public static final class attr { - } - public static final class drawable { - public static final int icon=0x7f020000; - } - public static final class id { - public static final int SoftwareRendererDisplay=0x7f050000; - } - public static final class layout { - public static final int main=0x7f030000; - } - public static final class string { - public static final int app_name=0x7f040001; - public static final int hello=0x7f040000; - } -} diff --git a/android/res/drawable-hdpi/icon.png b/android/res/drawable-hdpi/icon.png deleted file mode 100644 index 8074c4c571b8cd19e27f4ee5545df367420686d7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4147 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 diff --git a/android/res/drawable-ldpi/icon.png b/android/res/drawable-ldpi/icon.png deleted file mode 100644 index 1095584ec21f71cd0afc9e0993aa2209671b590c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1723 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 - - - - diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml deleted file mode 100644 index 20f67d16f..000000000 --- a/android/res/values/strings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Hello World, SRB2Game! - SRB2 - diff --git a/android/src/org/srb2/GameThread.java b/android/src/org/srb2/GameThread.java deleted file mode 100644 index 6aecdac74..000000000 --- a/android/src/org/srb2/GameThread.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.srb2; - -import org.srb2.nativecode.SRB2; - -import android.graphics.Canvas; -import android.util.Log; -import android.view.SurfaceHolder; - -public class GameThread extends Thread { - public static String TAG = "SRB2-GameThread"; - private SurfaceHolder sh; - private SRB2 srb2; - - public GameThread(SurfaceHolder h) { - super(); - this.srb2 = new SRB2(h); - this.sh = h; - } - - @Override - public void run() { - Log.d(TAG, "Starting thread!"); - this.srb2.run(); - } -} diff --git a/android/src/org/srb2/SRB2Game.java b/android/src/org/srb2/SRB2Game.java deleted file mode 100644 index ae9f43b2a..000000000 --- a/android/src/org/srb2/SRB2Game.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.srb2; - -import android.util.Log; -import android.view.SurfaceHolder; -import android.view.SurfaceView; -import android.view.SurfaceHolder.Callback; -import android.app.Activity; -import android.os.Bundle; - -public class SRB2Game extends Activity implements Callback { - public static String TAG = "SRB2-Activity"; - private SurfaceView sv; - private GameThread thread; - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setContentView(R.layout.main); - - sv = (SurfaceView) findViewById(R.id.SoftwareRendererDisplay); - sv.getHolder().addCallback(this); - } - - public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) { - Log.e(TAG, "Output surface changed? OHSHI-"); - } - - public void surfaceCreated(SurfaceHolder arg0) { - Log.d(TAG, "Output surface ready! Instantiating and starting game..."); - thread = new GameThread(sv.getHolder()); - thread.start(); - } - - public void surfaceDestroyed(SurfaceHolder arg0) { - // TODO shutdown SRB2 as cleanly as possible. - } -} diff --git a/android/src/org/srb2/nativecode/Main.java b/android/src/org/srb2/nativecode/Main.java deleted file mode 100644 index 1a2dc200a..000000000 --- a/android/src/org/srb2/nativecode/Main.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.srb2.nativecode; - -import java.nio.ByteBuffer; - -public class Main { - private SRB2 srb2; - - public Main(SRB2 srb2) { - this.srb2 = srb2; - } - - public native int main(Video v); -} diff --git a/android/src/org/srb2/nativecode/SRB2.java b/android/src/org/srb2/nativecode/SRB2.java deleted file mode 100644 index 0f18f1eaf..000000000 --- a/android/src/org/srb2/nativecode/SRB2.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.srb2.nativecode; - -import android.util.Log; -import android.view.SurfaceHolder; - -/// Wraps the entire native game. This object should be wholly owned -/// by the thread it's going to run in. -public class SRB2 { - public static String TAG = "SRB2-Wrapper"; - private Main main; - public Video video; - - public SRB2(SurfaceHolder videoOut) { - try { - Log.i(TAG, "Loading native SRB2 shared object from package..."); - System.load("/data/data/org.srb2/lib/libsrb2.so"); - - } catch (UnsatisfiedLinkError ule) { - Log.i(TAG, "... it doesn't appear to be installed in the package. Looking for native library in the global search path."); - try { - System.load("libsrb2.so"); - - } catch (UnsatisfiedLinkError ule2) { - Log.e("JNI", "... no luck. Could not load libsrb2.so!"); - return; - } - } - this.video = new Video(this, videoOut); - this.main = new Main(this); - } - - public void run() { - this.main.main(this.video); - } -} diff --git a/android/src/org/srb2/nativecode/Video.java b/android/src/org/srb2/nativecode/Video.java deleted file mode 100644 index d7256ee1e..000000000 --- a/android/src/org/srb2/nativecode/Video.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.srb2.nativecode; - -import java.nio.ByteBuffer; - -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.view.SurfaceHolder; - -public class Video { - public static int width = 340; - public static int height = 240; - private SurfaceHolder sh; - public ByteBuffer fb; - public Bitmap bmp; - - public Video(SRB2 srb2, SurfaceHolder sh) { - this.sh = sh; - fb = ByteBuffer.allocateDirect(fbSize()); - bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); - } - - private int fbSize() { - // naively assuming RGBA8888 now, even though that is entirely wrong. - // ... well, at least, that's what the Canvas/Bitmap will expect. - return width * height * 4; - } - - public void gotFrame() { - - Canvas canvas = sh.lockCanvas(); - canvas.drawARGB(0xff, 0, 0, 0); - // ugh, an extra copy. the only way to avoid this, I suppose, - // is to use the surface in native code directly. - bmp.copyPixelsFromBuffer(fb); - canvas.drawBitmap(bmp, 0, 0, null); - sh.unlockCanvasAndPost(canvas); - - } -} diff --git a/src/Android.mk b/src/Android.mk deleted file mode 100644 index 035d48887..000000000 --- a/src/Android.mk +++ /dev/null @@ -1,90 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -srb_module_tags := eng user - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := am_map.c \ - command.c \ - comptime.c \ - console.c \ - d_clisrv.c \ - d_main.c \ - d_net.c \ - d_netcmd.c \ - d_netfil.c \ - dehacked.c \ - f_finale.c \ - f_wipe.c \ - filesrch.c \ - g_game.c \ - g_input.c \ - hu_stuff.c \ - i_tcp.c \ - info.c \ - lzf.c \ - m_argv.c \ - m_bbox.c \ - m_cheat.c \ - m_fixed.c \ - m_menu.c \ - m_misc.c \ - m_queue.c \ - m_random.c \ - md5.c \ - mserv.c \ - p_ceilng.c \ - p_enemy.c \ - p_fab.c \ - p_floor.c \ - p_inter.c \ - p_lights.c \ - p_map.c \ - p_maputl.c \ - p_mobj.c \ - p_polyobj.c \ - p_saveg.c \ - p_setup.c \ - p_sight.c \ - p_spec.c \ - p_telept.c \ - p_tick.c \ - p_user.c \ - r_bsp.c \ - r_data.c \ - r_draw.c \ - r_main.c \ - r_plane.c \ - r_segs.c \ - r_sky.c \ - r_splats.c \ - r_things.c \ - s_sound.c \ - screen.c \ - sounds.c \ - st_stuff.c \ - string.c \ - tables.c \ - v_video.c \ - w_wad.c \ - y_inter.c \ - z_zone.c \ - android/i_cdmus.c \ - android/i_main.c \ - android/i_net.c \ - android/i_sound.c \ - android/i_system.c \ - android/i_video.c - -LOCAL_CFLAGS += -DPLATFORM_ANDROID -DNONX86 -DLINUX -DDEBUGMODE -DNOPIX -DUNIXCOMMON -DNOTERMIOS - -LOCAL_MODULE := libsrb2 - -# we live in an APK, so no prelink for us! -LOCAL_PRELINK_MODULE := false - -LOCAL_SHARED_LIBRARIES += liblog libdl - -LOCAL_CFLAGS += -Idalvik/libnativehelper/include/nativehelper - -include $(BUILD_SHARED_LIBRARY) diff --git a/src/android/README b/src/android/README deleted file mode 100644 index a8d35b598..000000000 --- a/src/android/README +++ /dev/null @@ -1,43 +0,0 @@ -SRB2 for Google Android! - -SYNOPSIS - -Port of SRB2 to Android, tested against version 1.6 (donut). - -I did this with a full Android tree, rather than the NDK thing. - -BUILDING - -Assuming a pretty standard Android tree, at $REPO, and the SRB2 -tree at $REPO/packages/apps/srb2 (that is, the *whole* SRB2 -tree, not just this android/ directory): - - cd $REPO - source build/envsetup.sh # this gives us the mm command, - # which is useful for selectively - # building only one component. - cd packages/apps/srb2 - mm - -An APK is dumped out at (or similar): -out/target/product/generic/system/app/SRB2.apk - -Naturally, an SRB2 APK is architecture specific. Since most -Android devices are currently ARMEL, this is pretty okay. - -NB. It appears that the Java app (the thing that becomes the APK) -is *not* rebuilt if changes are only made to libsrb2. Grr. - -REGENERATION OF JNI HEADERS - -Whenever the Java classes in org.srb2.nativecode change, -the C header files that describe the JNI interface to them -need to be regnererated. Make sure you have the project -built (so that the jar files are up to date), and then: - - cd $REPO/out/target/common/obj/APPS/SRB2_intermediates - - javah -classpath classes.jar -o $REPO/packages/apps/srb2/src/android/jni_main.h org.srb2.nativecode.Main - -# ... and no, I don't know how to mash all that into the -# Android.mk build system... diff --git a/src/android/i_cdmus.c b/src/android/i_cdmus.c deleted file mode 100644 index 12063745b..000000000 --- a/src/android/i_cdmus.c +++ /dev/null @@ -1,37 +0,0 @@ -#include "../command.h" -#include "../s_sound.h" -#include "../i_sound.h" - -// -// CD MUSIC I/O -// - -UINT8 cdaudio_started = 0; - -consvar_t cd_volume = CVAR_INIT ("cd_volume","18",CV_SAVE,soundvolume_cons_t, NULL); -consvar_t cdUpdate = CVAR_INIT ("cd_update","1",CV_SAVE, NULL, NULL); - - -void I_InitCD(void){} - -void I_StopCD(void){} - -void I_PauseCD(void){} - -void I_ResumeCD(void){} - -void I_ShutdownCD(void){} - -void I_UpdateCD(void){} - -void I_PlayCD(UINT8 track, UINT8 looping) -{ - (void)track; - (void)looping; -} - -boolean I_SetVolumeCD(INT32 volume) -{ - (void)volume; - return false; -} diff --git a/src/android/i_main.c b/src/android/i_main.c deleted file mode 100644 index 8696f3fc7..000000000 --- a/src/android/i_main.c +++ /dev/null @@ -1,53 +0,0 @@ -#define LOG_TAG "SRB2-main" -#include "utils/Log.h" - -#include "../doomdef.h" -#include "../d_main.h" -#include "../m_argv.h" - -#include "i_video.h" - -#include "jni_main.h" - -int srb2_main() -{ - // startup SRB2 - CONS_Printf ("Setting up SRB2Kart (fo' real)..."); - D_SRB2Main(); - CONS_Printf ("Entering main game loop..."); - // never return - D_SRB2Loop(); - LOGD("Control left SRB2Kart. Good bye."); - - // return to OS - return 0; -} - -JNIEXPORT jint JNICALL Java_org_srb2_nativecode_Main_main -(JNIEnv * env, jobject self, jobject video) { - jobject fbBuf; - jfieldID fbBufField; - - // a global reference to JNI Env, so my callbacks can use it: - jni_env = env; - androidVideo = video; - - jclass videoClass = (*env)->FindClass(env, "org/srb2/nativecode/Video"); - if(videoClass == NULL) { - LOGE("Could not find Video class from JNI!"); - return -1; - } - fbBufField = (*env)->GetFieldID(env, videoClass, "fb", "Ljava/nio/ByteBuffer;"); - fbBuf = (*env)->GetObjectField(env, video, fbBufField); - if(fbBuf == NULL) { - LOGE("Couldn't get Video object from JNI!"); - return -1; - } - videoFrameCB = (*env)->GetMethodID(env, videoClass, "gotFrame", "()V"); - if(videoFrameCB == NULL) { - LOGE("Couldn't get method ID of Video#gotFrame() callback!"); - return -1; - } - android_surface = (UINT8*) (*env)->GetDirectBufferAddress(env, fbBuf); - return srb2_main(); -} diff --git a/src/android/i_net.c b/src/android/i_net.c deleted file mode 100644 index f6e642022..000000000 --- a/src/android/i_net.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "../i_net.h" - -boolean I_InitNetwork(void) -{ - return false; -} diff --git a/src/android/i_sound.c b/src/android/i_sound.c deleted file mode 100644 index b5a1c3646..000000000 --- a/src/android/i_sound.c +++ /dev/null @@ -1,214 +0,0 @@ -#include "../i_sound.h" - -UINT8 sound_started = 0; - -void *I_GetSfx(sfxinfo_t *sfx) -{ - (void)sfx; - return NULL; -} - -void I_FreeSfx(sfxinfo_t *sfx) -{ - (void)sfx; -} - -void I_StartupSound(void){} - -void I_ShutdownSound(void){} - -// -// SFX I/O -// - -INT32 I_StartSound(sfxenum_t id, INT32 vol, INT32 sep, INT32 pitch, INT32 priority, INT32 channel) -{ - (void)id; - (void)vol; - (void)sep; - (void)pitch; - (void)priority; - (void)channel; - return -1; -} - -void I_StopSound(INT32 handle) -{ - (void)handle; -} - -INT32 I_SoundIsPlaying(INT32 handle) -{ - (void)handle; - return false; -} - -void I_UpdateSoundParams(INT32 handle, INT32 vol, INT32 sep, INT32 pitch) -{ - (void)handle; - (void)vol; - (void)sep; - (void)pitch; -} - -void I_SetSfxVolume(INT32 volume) -{ - (void)volume; -} - -/// ------------------------ -// MUSIC SYSTEM -/// ------------------------ - -UINT8 music_started = 0; -UINT8 digmusic_started = 0; - -void I_InitMusic(void){} - -void I_ShutdownMusic(void){} - -/// ------------------------ -// MUSIC PROPERTIES -/// ------------------------ - -musictype_t I_SongType(void) -{ - return MU_NONE; -} - -boolean I_SongPlaying(void) -{ - return false; -} - -boolean I_SongPaused(void) -{ - return false; -} - -/// ------------------------ -// MUSIC EFFECTS -/// ------------------------ - -boolean I_SetSongSpeed(float speed) -{ - (void)speed; - return false; -} - -/// ------------------------ -// MUSIC SEEKING -/// ------------------------ - -UINT32 I_GetSongLength(void) -{ - return 0; -} - -boolean I_SetSongLoopPoint(UINT32 looppoint) -{ - (void)looppoint; - return false; -} - -UINT32 I_GetSongLoopPoint(void) -{ - return 0; -} - -boolean I_SetSongPosition(UINT32 position) -{ - (void)position; - return false; -} - -UINT32 I_GetSongPosition(void) -{ - return 0; -} - -/// ------------------------ -// MUSIC PLAYBACK -/// ------------------------ - -UINT8 midimusic_started = 0; - -boolean I_LoadSong(char *data, size_t len) -{ - (void)data; - (void)len; - return -1; -} - -void I_UnloadSong() -{ - -} - -boolean I_PlaySong(boolean looping) -{ - (void)handle; - (void)looping; - return false; -} - -void I_StopSong(void) -{ - (void)handle; -} - -void I_PauseSong(void) -{ - (void)handle; -} - -void I_ResumeSong(void) -{ - (void)handle; -} - -void I_SetMusicVolume(INT32 volume) -{ - (void)volume; -} - -/// ------------------------ -// MUSIC FADING -/// ------------------------ - -void I_SetInternalMusicVolume(UINT8 volume) -{ - (void)volume; -} - -void I_StopFadingSong(void) -{ -} - -boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void)); -{ - (void)target_volume; - (void)source_volume; - (void)ms; - return false; -} - -boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)); -{ - (void)target_volume; - (void)ms; - return false; -} - -boolean I_FadeOutStopSong(UINT32 ms) -{ - (void)ms; - return false; -} - -boolean I_FadeInPlaySong(UINT32 ms, boolean looping) -{ - (void)ms; - (void)looping; - return false; -} diff --git a/src/android/i_system.c b/src/android/i_system.c deleted file mode 100644 index fe7fa863d..000000000 --- a/src/android/i_system.c +++ /dev/null @@ -1,276 +0,0 @@ -#define LOG_TAG "SRB2" - -#include "../doomdef.h" -#include "../i_system.h" - -#include -#include -#include -#include -#include -#include - -#include - -#define MEMINFO_FILE "/proc/meminfo" -#define MEMTOTAL "MemTotal:" -#define MEMFREE "MemFree:" - -UINT8 graphics_started = 0; - -UINT8 keyboard_started = 0; - -static INT64 start_time; // as microseconds since the epoch - -// I should probably return how much memory is remaining -// for this process, considering Android's process memory limit. -UINT32 I_GetFreeMem(UINT32 *total) -{ - // what the heck? sysinfo() is partially missing in bionic? - /* struct sysinfo si; */ - /* if(sysinfo(&si) != 0) { */ - /* I_Error("Couldn't invoke sysinfo()...?"); */ - /* } */ - /* return si.freeram; */ - char buf[1024]; - char *memTag; - UINT32 freeKBytes; - UINT32 totalKBytes; - INT32 n; - INT32 meminfo_fd = -1; - - meminfo_fd = open(MEMINFO_FILE, O_RDONLY); - n = read(meminfo_fd, buf, 1023); - close(meminfo_fd); - - if (n < 0) - { - // Error - *total = 0L; - return 0; - } - - buf[n] = '\0'; - if (NULL == (memTag = strstr(buf, MEMTOTAL))) - { - // Error - *total = 0L; - return 0; - } - - memTag += sizeof (MEMTOTAL); - totalKBytes = atoi(memTag); - - if (NULL == (memTag = strstr(buf, MEMFREE))) - { - // Error - *total = 0L; - return 0; - } - - memTag += sizeof (MEMFREE); - freeKBytes = atoi(memTag); - - if (total) - *total = totalKBytes << 10; - return freeKBytes << 10; -} - -INT64 current_time_in_ps() { - struct timeval t; - gettimeofday(&t, NULL); - return (t.tv_sec * (INT64)1000000) + t.tv_usec; -} - -void I_Sleep(UINT32 ms){} - -precise_t I_GetPreciseTime(void) -{ - return 0; -} - -UINT64 I_GetPrecisePrecision(void) -{ - return 1000000; -} - -void I_GetEvent(void){} - -void I_OsPolling(void){} - -ticcmd_t *I_BaseTiccmd(void) -{ - return NULL; -} - -ticcmd_t *I_BaseTiccmd2(void) -{ - return NULL; -} - -void I_Quit(void) -{ - LOGD("SRB2Kart quitting!"); - exit(0); -} - -void I_Error(const char *error, ...) -{ - va_list argptr; - char logbuf[8192]; - - va_start(argptr, error); - vsprintf(logbuf, error, argptr); - va_end(argptr); - - LOGE(logbuf); - exit(-1); -} - -void I_Tactile(FFType Type, const JoyFF_t *Effect) -{ - (void)Type; - (void)Effect; -} - -void I_Tactile2(FFType Type, const JoyFF_t *Effect) -{ - (void)Type; - (void)Effect; -} - -void I_JoyScale(void){} - -void I_JoyScale2(void){} - -void I_InitJoystick(void){} - -void I_InitJoystick2(void){} - -INT32 I_NumJoys(void) -{ - return 0; -} - -const char *I_GetJoyName(INT32 joyindex) -{ - (void)joyindex; - return NULL; -} - -void I_SetupMumble(void) -{ -} - -#ifndef NOMUMBLE -void I_UpdateMumble(const mobj_t *mobj, const listener_t listener) -{ - (void)mobj; - (void)listener; -} -#endif - -void I_OutputMsg(const char *fmt, ...) -{ - va_list argptr; - char logbuf[8192]; - - va_start(argptr, fmt); - vsprintf(logbuf, fmt, argptr); - va_end(argptr); - - LOGD(logbuf); -} - -void I_StartupMouse(void){} - -void I_StartupMouse2(void){} - -void I_StartupKeyboard(void){} - -INT32 I_GetKey(void) -{ - return 0; -} - -void I_StartupTimer(void) { - struct timeval t; - gettimeofday(&t, NULL); - start_time = (t.tv_sec * 1000000) + t.tv_usec; -} - -void I_AddExitFunc(void (*func)()) -{ - (void)func; -} - -void I_RemoveExitFunc(void (*func)()) -{ - (void)func; -} - -INT32 I_StartupSystem(void) -{ - return -1; -} - -void I_ShutdownSystem(void){} - -void I_GetDiskFreeSpace(INT64* freespace) -{ - *freespace = 0; -} - -char *I_GetUserName(void) -{ - return "Android"; -} - -INT32 I_mkdir(const char *dirname, INT32 unixright) -{ - (void)dirname; - (void)unixright; - return -1; -} - -const char *I_LocateWad(void) -{ - return "/sdcard/srb2"; -} - -void I_GetJoystickEvents(void){} - -void I_GetJoystick2Events(void){} - -void I_GetMouseEvents(void){} - -void I_UpdateMouseGrab(void){} - -char *I_GetEnv(const char *name) -{ - LOGW("I_GetEnv() called?!"); - (void)name; - return NULL; -} - -INT32 I_PutEnv(char *variable) -{ - (void)variable; - return -1; -} - -INT32 I_ClipboardCopy(const char *data, size_t size) -{ - (void)data; - (void)size; - return -1; -} - -char *I_ClipboardPaste(void) -{ - return NULL; -} - -void I_RegisterSysCommands(void) {} - -#include "../sdl/dosstr.c" diff --git a/src/android/i_video.c b/src/android/i_video.c deleted file mode 100644 index bf0decb74..000000000 --- a/src/android/i_video.c +++ /dev/null @@ -1,92 +0,0 @@ -#include "../doomdef.h" -#include "../command.h" -#include "../i_video.h" -#include "../v_video.h" -#include "../screen.h" - -#include "i_video.h" - -#include "utils/Log.h" - -rendermode_t rendermode = render_soft; -rendermode_t chosenrendermode = render_none; - -boolean highcolor = false; - -boolean allow_fullscreen = false; - - - -consvar_t cv_vidwait = CVAR_INIT ("vid_wait", "On", CV_SAVE, CV_OnOff, NULL); - -void I_StartupGraphics(void){} -void I_ShutdownGraphics(void){} - -void VID_StartupOpenGL(void){} - -void I_SetPalette(RGBA_t *palette) -{ - (void)palette; -} - -INT32 VID_NumModes(void) -{ - return 1; -} - -INT32 VID_GetModeForSize(INT32 w, INT32 h) -{ - (void)w; - (void)h; - return 0; -} - -void VID_PrepareModeList(void){} - -INT32 VID_SetMode(INT32 modenum) -{ - vid.modenum = 0; - vid.width = 320; - vid.height = 240; - vid.bpp = 1; - vid.buffer = android_surface; - return 0; -} - -boolean VID_CheckRenderer(void) -{ - return false; -} - -void VID_CheckGLLoaded(rendermode_t oldrender) -{ - (void)oldrender; -} - -const char *VID_GetModeName(INT32 modenum) -{ - return "A320x240"; -} - -void I_UpdateNoBlit(void){} - -void I_FinishUpdate(void) { - LOGD("FRAME!"); - (*jni_env)->CallVoidMethod(jni_env, androidVideo, videoFrameCB); -} - -void I_UpdateNoVsync(void) {} - -void I_WaitVBL(INT32 count) -{ - (void)count; -} - -void I_ReadScreen(UINT8 *scr) -{ - (void)scr; -} - -void I_BeginRead(void){} - -void I_EndRead(void){} diff --git a/src/android/i_video.h b/src/android/i_video.h deleted file mode 100644 index aa0e78f3d..000000000 --- a/src/android/i_video.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _SRB2_ANDROID_VIDEO_ -#define _SRB2_ANDROID_VIDEO_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -UINT8 *android_surface; - -JNIEnv* jni_env; -jobject androidVideo; -jmethodID videoFrameCB; - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif diff --git a/src/android/jni_main.h b/src/android/jni_main.h deleted file mode 100644 index da7f70331..000000000 --- a/src/android/jni_main.h +++ /dev/null @@ -1,21 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class org_srb2_nativecode_Main */ - -#ifndef _Included_org_srb2_nativecode_Main -#define _Included_org_srb2_nativecode_Main -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_srb2_nativecode_Main - * Method: main - * Signature: (Lorg/srb2/nativecode/Video;)I - */ -JNIEXPORT jint JNICALL Java_org_srb2_nativecode_Main_main - (JNIEnv *, jobject, jobject); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/d_main.cpp b/src/d_main.cpp index b91a0ad80..bfa21733d 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1920,10 +1920,6 @@ const char *D_Home(void) { const char *userhome = NULL; -#ifdef ANDROID - return "/data/data/org.srb2/"; -#endif - if (M_CheckParm("-home") && M_IsNextParm()) userhome = M_GetNextParm(); else From 5b50bc72dfc2b540e2c39ce455bedc5e592943e8 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Mon, 26 May 2025 09:13:20 -0400 Subject: [PATCH 29/33] Fix up antigrief --- src/k_kart.c | 4 ++-- src/p_user.c | 23 ++++++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 840044bac..37dad4b12 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -10888,7 +10888,7 @@ void K_CheckSpectateStatus(boolean considermapreset) return; // Organize by spectate wait timer (if there's more than one to sort) - if (cv_maxplayers.value && numjoiners > 1) + if (cv_ingamecap.value && numjoiners > 1) { UINT8 oldrespawnlist[MAXPLAYERS]; memcpy(oldrespawnlist, respawnlist, numjoiners); @@ -10919,7 +10919,7 @@ void K_CheckSpectateStatus(boolean considermapreset) for (i = 0; i < numjoiners; i++) { // Hit the in-game player cap while adding people? - if (cv_maxplayers.value && numingame >= cv_maxplayers.value) + if (cv_ingamecap.value && numingame >= cv_ingamecap.value) { if (numbots > 0) { diff --git a/src/p_user.c b/src/p_user.c index 117e01a81..cfdb53d23 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3992,16 +3992,21 @@ void P_PlayerThink(player_t *player) if (netgame && cv_antigrief.value != 0 && (gametyperules & GTR_CIRCUIT)) { - if (!player->spectator && !player->exiting && !(player->pflags & PF_NOCONTEST)) + INT32 i; + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].spectator) + continue; + if (&players[i] == player) + continue; + break; + } + + if (i < MAXPLAYERS && !player->spectator && !player->exiting && !(player->pflags & PF_NOCONTEST)) { const tic_t griefval = cv_antigrief.value * TICRATE; const UINT8 n = player - players; - if (n != serverplayer -#ifndef DEVELOP - && !IsPlayerAdmin(n) -#endif - ) { if (player->grieftime > griefval) { @@ -4010,7 +4015,11 @@ void P_PlayerThink(player_t *player) if (server) { - if (player->griefstrikes > 2) + if ((player->griefstrikes > 2) +#ifndef DEVELOP + && !IsPlayerAdmin(n) +#endif + && !P_IsLocalPlayer(player)) // P_IsMachineLocalPlayer for DRRR { // Send kick SendKick(n, KICK_MSG_GRIEF); From c06e3d3352299cad94ced7469744927b609010e2 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Mon, 26 May 2025 10:38:44 -0400 Subject: [PATCH 30/33] Catch Animdefs error instead of I_Erroring --- src/p_spec.c | 4 ++-- src/sdl/i_system.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 06cda1111..bbe27f166 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -237,9 +237,9 @@ void P_InitPicAnims(void) if (lastanim->numpics < 2) { - free(anims); - I_Error("P_InitPicAnims: bad cycle from %s to %s", + CONS_Alert(CONS_WARNING, "P_InitPicAnims: bad cycle from %s to %s.\n", animdefs->startname, animdefs->endname); + continue; } lastanim->speed = animdef->speed; diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index d26831bb1..d5fde7000 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -355,15 +355,15 @@ static void I_ShowErrorMessageBox(const char *messagefordevelopers, boolean dump finalmessage, sizeof(finalmessage), "\"SRB2Kart V2\" has encountered an unrecoverable error and needs to close.\n" - "The %s log file is located at (%s).\n" + "The %slog file is located at (%s).\n" "\n" "\n" "%s", dumpmade ? #if defined (UNIXBACKTRACE) - "crash-log.txt" + "crash-log.txt " #elif defined (_WIN32) - ".rpt crash dump" + ".rpt crash dump " #endif : "", logfilename, From 5683b62155f7dbbae541bfe6b7fb572b5d7bd7c7 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Mon, 26 May 2025 17:13:02 +0200 Subject: [PATCH 31/33] Fix Slipgate Cup the Correct Way(tm) --- src/p_spec.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index bbe27f166..cafaa679d 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -135,7 +135,7 @@ static animdef_t *animdefs = NULL; // A prototype; here instead of p_spec.h, so they're "private" void P_ParseANIMDEFSLump(INT32 wadNum, UINT16 lumpnum); -void P_ParseAnimationDefintion(SINT8 istexture); +void P_ParseAnimationDefintion(SINT8 istexture, boolean compat); static boolean P_FindTextureForAnimation(anim_t *anim, animdef_t *animdef) { @@ -237,9 +237,9 @@ void P_InitPicAnims(void) if (lastanim->numpics < 2) { - CONS_Alert(CONS_WARNING, "P_InitPicAnims: bad cycle from %s to %s.\n", + free(anims); + I_Error("P_InitPicAnims: bad cycle from %s to %s", animdefs->startname, animdefs->endname); - continue; } lastanim->speed = animdef->speed; @@ -260,6 +260,7 @@ void P_ParseANIMDEFSLump(INT32 wadNum, UINT16 lumpnum) char *animdefsText; char *animdefsToken; char *p; + boolean compat = wadfiles[wadNum]->compatmode; // Since lumps AREN'T \0-terminated like I'd assumed they should be, I'll // need to make a space of memory where I can ensure that it will terminate @@ -286,12 +287,12 @@ void P_ParseANIMDEFSLump(INT32 wadNum, UINT16 lumpnum) if (stricmp(animdefsToken, "TEXTURE") == 0) { Z_Free(animdefsToken); - P_ParseAnimationDefintion(1); + P_ParseAnimationDefintion(1, compat); } else if (stricmp(animdefsToken, "FLAT") == 0) { Z_Free(animdefsToken); - P_ParseAnimationDefintion(0); + P_ParseAnimationDefintion(0, compat); } else if (stricmp(animdefsToken, "OSCILLATE") == 0) { @@ -311,7 +312,7 @@ void P_ParseANIMDEFSLump(INT32 wadNum, UINT16 lumpnum) Z_Free((void *)animdefsText); } -void P_ParseAnimationDefintion(SINT8 istexture) +void P_ParseAnimationDefintion(SINT8 istexture, boolean compat) { char *animdefsToken; size_t animdefsTokenLength; @@ -354,7 +355,7 @@ void P_ParseAnimationDefintion(SINT8 istexture) // Search for existing animdef for (i = 0; i < maxanims; i++) - if (animdefs[i].istexture == istexture // Check if it's the same type! + if ((compat || animdefs[i].istexture == istexture) // Check if it's the same type! && stricmp(animdefsToken, animdefs[i].startname) == 0) { //CONS_Alert(CONS_NOTICE, "Duplicate animation: %s\n", animdefsToken); From 91ec80d9ed812b2ad4cfd41fc26a3efcc0a2fd1c Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Mon, 26 May 2025 17:34:33 +0200 Subject: [PATCH 32/33] Fix the bad cycle message --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index cafaa679d..c993fa684 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -239,7 +239,7 @@ void P_InitPicAnims(void) { free(anims); I_Error("P_InitPicAnims: bad cycle from %s to %s", - animdefs->startname, animdefs->endname); + animdef->startname, animdef->endname); } lastanim->speed = animdef->speed; From 6127729ca62130556de1f58d3872a248cdefb2e5 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Mon, 26 May 2025 11:47:46 -0400 Subject: [PATCH 33/33] Fix Thwomps causing I_Error in tclasses --- src/p_saveg.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index 4f41f8383..2ff54f651 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3966,6 +3966,7 @@ static thinker_t* LoadThwompThinker(savebuffer_t *save, actionf_p1 thinker) ht->delay = READINT32(save->p); ht->tag = READINT16(save->p); ht->sound = READUINT16(save->p); + ht->initDelay = READINT32(save->p); if (ht->sector) {