Back to the Vavoom Forum Archives


Forum

Patch for fixing the Heretic floor raise bug

Sat, 12 Jun 2010 17:47:22

Firebrand

I've got the following patch that fixes the Heretic raise floor bug, I had to create a flag to avoid destroying FloorData and SectorMover thinker from sectors affected by this line special (which is what the original game did AFAIK), let me know what you think of it.
Index: progs/common/engine/GameObject.vc
===================================================================
--- progs/common/engine/GameObject.vc	(revision 4303)
+++ progs/common/engine/GameObject.vc	(working copy)
@@ -141,7 +141,9 @@
 	ML_BLOCK_FLOATERS		= 0x00040000,
 	ML_CLIP_MIDTEX			= 0x00080000,	// Automatic for every Strife line
 	ML_WRAP_MIDTEX			= 0x00100000,
-	ML_FIRSTSIDEONLY		= 0x00800000;	// Actiavte only when crossed from front side.
+	ML_FIRSTSIDEONLY		= 0x00800000,	// Actiavte only when crossed from front side.
+	ML_KEEPDATA				= 0x01000000;	// Keep FloorData or CeilingData after activating them.
+											// Used to simulate original Heretic behaviour.
 
 //	These will be converted.
 const int 
Index: progs/common/linespec/FloorMover.vc
===================================================================
--- progs/common/linespec/FloorMover.vc	(revision 4303)
+++ progs/common/linespec/FloorMover.vc	(working copy)
@@ -258,12 +258,22 @@
 		DestHeight = Level.FindNextHighestFloor(Sector, &Spot);
 		Spot.z = DestHeight;
 		FloorDestDist = DotProduct(Sector->floor.normal, Spot);
+		// NO MORE DAMAGE, IF APPLICABLE
 		if (Line)
 		{
 			Sector->floor.pic = Line->frontsector->floor.pic;
+			Sector->special = (Sector->special & SECSPEC_SECRET_MASK) |
+				(Line->frontsector->special & ~SECSPEC_SECRET_MASK);
+			if (Line->flags & ML_KEEPDATA)
+			{
+				// Don't destroy the thinker
+				Not_Keep = false;
+			}
 		}
-		// NO MORE DAMAGE, IF APPLICABLE
-		Sector->special &= SECSPEC_SECRET_MASK;
+		else
+		{
+			Sector->special &= SECSPEC_SECRET_MASK;
+		}
 		SeqName = LineSpecialLevelInfo(Level).DefaultFloorAltSound;
 		break;
 
Index: progs/common/linespec/SectorMover.vc
===================================================================
--- progs/common/linespec/SectorMover.vc	(revision 4303)
+++ progs/common/linespec/SectorMover.vc	(working copy)
@@ -25,6 +25,8 @@
 
 class SectorMover : SectorThinker;
 
+bool Not_Keep;	// This flag let's us know if we can destroy FloorData
+
 //==========================================================================
 //
 //	Finished
@@ -33,14 +35,17 @@
 
 void Finished()
 {
-	if (Sector->FloorData == self)
-		Sector->FloorData = none;
-	if (Sector->CeilingData == self)
-		Sector->CeilingData = none;
-	if (Sector->LightingData == self)
-		Sector->LightingData = none;
-	RemoveAffector();
-	Destroy();
+	if (Not_Keep)
+	{
+		if (Sector->FloorData == self)
+			Sector->FloorData = none;
+		if (Sector->CeilingData == self)
+			Sector->CeilingData = none;
+		if (Sector->LightingData == self)
+			Sector->LightingData = none;
+		RemoveAffector();
+		Destroy();
+	}
 }
 
 //**************************************************************************
@@ -98,7 +103,7 @@
 				/*if (flag)
 				{
 					sector->floor.dist = lastpos;
-					P_ChangeSector(sector, crush);
+					XLevel.ChangeSector(sector, crush);
 					return RES_CRUSHED;
 				}*/
 			}
@@ -233,4 +238,5 @@
 
 defaultproperties
 {
+	Not_Keep = true;
 }
Index: progs/doom/game/MainGameInfo.vc
===================================================================
--- progs/doom/game/MainGameInfo.vc	(revision 4303)
+++ progs/doom/game/MainGameInfo.vc	(working copy)
@@ -540,7 +540,8 @@
 //==========================================================================
 
 void SetLineTrans(int i, int special, int arg1, int arg2, int arg3,
-	int arg4, int arg5, int spac, int repeat, optional int monst)
+	int arg4, int arg5, int spac, int repeat, optional int monst,
+	optional int not_destroy)
 {
 	spec_trans_tab.special = special;
 	spec_trans_tab.arg1 = arg1;
@@ -551,6 +552,7 @@
 	spec_trans_tab.spac = spac;
 	spec_trans_tab.repeat = repeat;
 	spec_trans_tab.monst = monst;
+	spec_trans_tab.not_destroy = not_destroy;
 }
 
 //==========================================================================
@@ -1010,6 +1012,11 @@
 	{
 		line->flags &= ~ML_MONSTERSCANACTIVATE;
 	}
+	// Check to see if we want thinkers destroyed or not
+	if (spec_trans_tab[OldSpec].not_destroy)
+	{
+		line->flags |= ML_KEEPDATA;
+	}
 }
 
 //==========================================================================
Index: progs/heretic/game/MainGameInfo.vc
===================================================================
--- progs/heretic/game/MainGameInfo.vc	(revision 4303)
+++ progs/heretic/game/MainGameInfo.vc	(working copy)
@@ -43,6 +43,7 @@
 	int spac;
 	int repeat;
 	int monst;
+	int not_destroy;
 };
 
 spec_trans_t spec_trans_tab[NUM_SPECIALS];
@@ -210,9 +211,9 @@
 	SetLineTrans(18, LNSPEC_FloorRaiseToNearest, -1, 8, 0, 0, 0, SPAC_Use, false);
 	SetLineTrans(19, LNSPEC_FloorLowerToHighest, -1, 8, 128, 0, 0, SPAC_Cross, false);
 
-	SetLineTrans(20, LNSPEC_FloorRaiseToNearestChange, -1, 4, 0, 0, 0, SPAC_Use, false);
+	SetLineTrans(20, LNSPEC_FloorRaiseToNearestChange, -1, 4, 0, 0, 0, SPAC_Use, false, false, true);
 	SetLineTrans(21, LNSPEC_PlatDownWaitUpStayLip, -1, 32, 105, 0, 0, SPAC_Use, false);
-	SetLineTrans(22, LNSPEC_FloorRaiseToNearestChange, -1, 4, 0, 0, 0, SPAC_Cross, false);
+	SetLineTrans(22, LNSPEC_FloorRaiseToNearestChange, -1, 4, 0, 0, 0, SPAC_Cross, false, false, true);
 	SetLineTrans(23, LNSPEC_FloorLowerToLowest, -1, 8, 0, 0, 0, SPAC_Use, false);
 	SetLineTrans(24, LNSPEC_FloorRaiseToLowestCeiling, -1, 8, 0, 0, 0, SPAC_Impact, false);
 	SetLineTrans(25, LNSPEC_CeilingCrushAndRaiseA, -1, 8, 8, 10, 0, SPAC_Cross, false);
@@ -239,7 +240,7 @@
 	SetLineTrans(44, LNSPEC_CeilingLowerAndCrush, -1, 8, 0, 0, 0, SPAC_Cross, false);
 	SetLineTrans(45, LNSPEC_FloorLowerToHighest, -1, 8, 128, 0, 0, SPAC_Use, true);
 	SetLineTrans(46, LNSPEC_DoorOpen, -1, 16, 0, 0, 0, SPAC_Impact, true, true);
-	SetLineTrans(47, LNSPEC_FloorRaiseToNearestChange, -1, 4, 0, 0, 0, SPAC_Impact, false);
+	SetLineTrans(47, LNSPEC_FloorRaiseToNearestChange, -1, 4, 0, 0, 0, SPAC_Impact, false, false, true);
 	SetLineTrans(48, LNSPEC_ScrollTextureLeft, 64, 0, 0, 0, 0, SPAC_Cross, false);
 	SetLineTrans(49, LNSPEC_CeilingCrushAndRaiseA, -1, 8, 8, 10, 0, SPAC_Use, false);
 
@@ -262,7 +263,7 @@
 	SetLineTrans(65, LNSPEC_FloorRaiseAndCrush, -1, 8, 10, 0, 0, SPAC_Use, true);
 	SetLineTrans(66, LNSPEC_FloorRaiseByValueChangeTex, -1, 4, 3, 0, 0, SPAC_Use, true);
 	SetLineTrans(67, LNSPEC_FloorRaiseByValueChangeTex, -1, 4, 4, 0, 0, SPAC_Use, true);
-	SetLineTrans(68, LNSPEC_FloorRaiseToNearestChange, -1, 4, 0, 0, 0, SPAC_Use, true);
+	SetLineTrans(68, LNSPEC_FloorRaiseToNearestChange, -1, 4, 0, 0, 0, SPAC_Use, true, false, true);
 	SetLineTrans(69, LNSPEC_FloorRaiseToNearest, -1, 8, 0, 0, 0, SPAC_Use, true);
 
 	SetLineTrans(70, LNSPEC_FloorLowerToHighest, -1, 32, 136, 0, 0, SPAC_Use, true);
@@ -292,7 +293,7 @@
 	SetLineTrans(92, LNSPEC_FloorRaiseByValue, -1, 8, 24, 0, 0, SPAC_Cross, true);
 	SetLineTrans(93, LNSPEC_FloorRaiseByValueChange, -1, 8, 24, 0, 0, SPAC_Cross, true);
 	SetLineTrans(94, LNSPEC_FloorRaiseAndCrush, -1, 8, 10, 0, 0, SPAC_Cross, true);
-	SetLineTrans(95, LNSPEC_FloorRaiseToNearestChange, -1, 4, 0, 0, 0, SPAC_Cross, true);
+	SetLineTrans(95, LNSPEC_FloorRaiseToNearestChange, -1, 4, 0, 0, 0, SPAC_Cross, true, false, true);
 	SetLineTrans(96, LNSPEC_FloorRaiseByTexture, -1, 8, 0, 0, 0, SPAC_Cross, true);
 	SetLineTrans(97, LNSPEC_Teleport, 0, -1, 0, 0, 0, SPAC_Cross, true, true);
 	SetLineTrans(98, LNSPEC_FloorLowerToHighest, -1, 32, 136, 0, 0, SPAC_Cross, true);
@@ -315,7 +316,8 @@
 //==========================================================================
 
 void SetLineTrans(int i, int special, int arg1, int arg2, int arg3,
-	int arg4, int arg5, int spac, int repeat, optional int monst)
+	int arg4, int arg5, int spac, int repeat, optional int monst,
+	optional int not_destroy)
 {
 	spec_trans_tab.special = special;
 	spec_trans_tab.arg1 = arg1;
@@ -326,6 +328,7 @@
 	spec_trans_tab.spac = spac;
 	spec_trans_tab.repeat = repeat;
 	spec_trans_tab.monst = monst;
+	spec_trans_tab.not_destroy = not_destroy;
 }
 
 //==========================================================================
@@ -417,6 +420,11 @@
 	{
 		line->flags &= ~ML_MONSTERSCANACTIVATE;
 	}
+	// Check to see if we want thinkers destroyed or not
+	if (spec_trans_tab[OldSpec].not_destroy)
+	{
+		line->flags |= ML_KEEPDATA;
+	}
 }
 
 //==========================================================================
Index: progs/strife/game/MainGameInfo.vc
===================================================================
--- progs/strife/game/MainGameInfo.vc	(revision 4303)
+++ progs/strife/game/MainGameInfo.vc	(working copy)
@@ -344,7 +344,8 @@
 //==========================================================================
 
 void SetLineTrans(int i, int special, int arg1, int arg2, int arg3,
-	int arg4, int arg5, int spac, int repeat, optional int monst)
+	int arg4, int arg5, int spac, int repeat, optional int monst,
+	optional int not_destroy)
 {
 	spec_trans_tab.special = special;
 	spec_trans_tab.arg1 = arg1;
@@ -355,6 +356,7 @@
 	spec_trans_tab.spac = spac;
 	spec_trans_tab.repeat = repeat;
 	spec_trans_tab.monst = monst;
+	spec_trans_tab.not_destroy = not_destroy;
 }
 
 //==========================================================================
@@ -474,6 +476,11 @@
 			print("Translucent flag not compatible with line special");
 		}
 	}
+	// Check to see if we want thinkers destroyed or not
+	if (spec_trans_tab[OldSpec].not_destroy)
+	{
+		line->flags |= ML_KEEPDATA;
+	}
 }
 
 //==========================================================================
Index: source/p_gameobject.h
===================================================================
--- source/p_gameobject.h	(revision 4303)
+++ source/p_gameobject.h	(working copy)
@@ -125,6 +125,8 @@
 	ML_CLIP_MIDTEX			= 0x00080000,	// Automatic for every Strife line
 	ML_WRAP_MIDTEX			= 0x00100000,
 	ML_FIRSTSIDEONLY		= 0x00800000,	// Actiavte only when crossed from front side.
+	ML_KEEPDATA				= 0x01000000,	// Keep FloorData or CeilingData after activating them.
+											// Used to simulate original Heretic behaviour.
 
 	ML_SPAC_SHIFT			= 10,
 	ML_SPAC_MASK			= 0x00001c00,
Sat, 12 Jun 2010 20:36:52

Janis Legzdinsh

Looks fine.

Back to the Vavoom Forum Archives