shithub: choc

Download patch

ref: fd43740b94137503a58bc4819a83c616ad660c0d
parent: d57be3f239cc500bb600c6b9f932ae742dc2b8c7
author: James Haley <haleyjd@hotmail.com>
date: Thu Sep 23 22:12:18 EDT 2010

Implementation of teleflags for EV_Teleport. Fix to somewhat serious bug
that let 0-damage tracers pass through walls. Other changes are only
comments or formatting.

Subversion-branch: /branches/strife-branch
Subversion-revision: 2132

--- a/src/strife/p_map.c
+++ b/src/strife/p_map.c
@@ -1140,10 +1140,10 @@
                 P_SpawnPuff(x, y, z); // Spawn bullet puffs.
             else
                 P_SpawnMobj(x, y, z, MT_STRIFEPUFF3);
-
-            // don't go any farther
-            return false;	
         }
+        
+        // don't go any farther
+        return false;	
     }
 
     // shoot a thing
--- a/src/strife/p_maputl.c
+++ b/src/strife/p_maputl.c
@@ -685,6 +685,8 @@
 // P_TraverseIntercepts
 // Returns true if the traverser function returns true
 // for all lines.
+//
+// [STRIFE] Verified unmodified.
 // 
 boolean
 P_TraverseIntercepts
--- a/src/strife/p_mobj.c
+++ b/src/strife/p_mobj.c
@@ -987,12 +987,13 @@
 
 //
 // P_SpawnSparkPuff
+//
 // villsa [STRIFE] new function
 //
-
 mobj_t* P_SpawnSparkPuff(fixed_t x, fixed_t y, fixed_t z)
 {
-    return P_SpawnMobj(x, y, ((P_Random() - P_Random()) << 10) + z, MT_SPARKPUFF);
+    int t = P_Random();
+    return P_SpawnMobj(x, y, ((t - P_Random()) << 10) + z, MT_SPARKPUFF);
 }
 
 
--- a/src/strife/p_spec.c
+++ b/src/strife/p_spec.c
@@ -788,8 +788,8 @@
         break;
 
     case 39:
-        // TELEPORT! - [STRIFE] Verified unmodified.
-        EV_Teleport( line, side, thing );
+        // TELEPORT! - [STRIFE] Verified unmodified (except for 0 flags param)
+        EV_Teleport( line, side, thing, TF_NORMAL );
         line->special = 0;
         break;
 
@@ -902,10 +902,11 @@
         break;
 
     case 125:
-        // TELEPORT MonsterONLY - [STRIFE] Verified unmodified.
+        // TELEPORT MonsterONLY - [STRIFE] Verified unmodified
+        //    (except for 0 flags parameter)
         if (!thing->player)
         {
-            EV_Teleport( line, side, thing );
+            EV_Teleport( line, side, thing, TF_NORMAL );
             line->special = 0;
         }
         break;
@@ -1220,8 +1221,8 @@
         break;
 
     case 97:
-        // TELEPORT! - [STRIFE] Verified unmodified.
-        EV_Teleport( line, side, thing );
+        // TELEPORT! - [STRIFE] Verified unmodified (except for 0 flags param)
+        EV_Teleport( line, side, thing, TF_NORMAL );
         break;
 
     case 98:
@@ -1250,9 +1251,9 @@
         break;
 
     case 126:
-        // TELEPORT MonsterONLY. - [STRIFE] Verified unmodified.
+        // TELEPORT MonsterONLY. - [STRIFE] Verified unmodified (except for 0 flags param)
         if (!thing->player)
-            EV_Teleport( line, side, thing );
+            EV_Teleport( line, side, thing, TF_NORMAL );
         break;
 
     case 128:
@@ -1357,16 +1358,12 @@
 
     case 185:
         // haleyjd 09/21/10: [STRIFE] Silent Teleport (used for Converter)
-        // STRIFE-TODO: Figure out the flags that have been added to EV_Teleport!
-        // flag = 51;
-        EV_Teleport(line, side, thing /*, flag*/);
+        EV_Teleport(line, side, thing, TF_FULLSILENCE);
         break;
 
     case 195:
         // haleyjd 09/21/10: [STRIFE] Silent Teleport and Change Zombie
-        // STRIFE-TODO: Figure out the flags that have been added to EV_Teleport!
-        // flag = 51;
-        EV_Teleport(line, side, thing /*, flag*/);
+        EV_Teleport(line, side, thing, TF_FULLSILENCE);
         P_SetMobjState(thing, S_AGRD_00); // 419
         break;
 
@@ -1378,9 +1375,8 @@
         break;
 
     case 231:
-        // haleyjd 09/21/10: [STRIFE] WR Teleport ???? - STRIFE-TODO: figure out flags
-        // flag = 33;
-        EV_Teleport(line, side, thing /*, flag*/);
+        // haleyjd 09/21/10: [STRIFE] WR Teleport (Silent at Source)
+        EV_Teleport(line, side, thing, TF_SRCSILENCE);
         break;
         
         // haleyjd 09/21/10: Moved one-time-use lines up above with the others.
@@ -1406,9 +1402,8 @@
         ok = 0;
         switch(line->special)
         {
-        case 46:
+        case 46:  // OPEN DOOR IMPACT
         case 182: // villsa [STRIFE] for windows
-            // OPEN DOOR IMPACT
             ok = 1;
             break;
         }
--- a/src/strife/p_spec.h
+++ b/src/strife/p_spec.h
@@ -655,10 +655,28 @@
 //
 // P_TELEPT
 //
+
+// [STRIFE] Teleportation flags - teleflags
+// Not to be conflated with telefrags, though they be tangentially related ;)
+typedef enum teleflags
+{
+    TF_NOSRCSND = 0x01,
+    TF_NODSTSND = 0x02,
+    TF_NODSTFOG = 0x10,
+    TF_NOSRCFOG = 0x20,
+
+    TF_NORMAL      = 0,
+    TF_DSTSILENCE  = (TF_NODSTSND|TF_NODSTFOG),    // 0x12 (18) (Not used)
+    TF_SRCSILENCE  = (TF_NOSRCSND|TF_NOSRCFOG),    // 0x21 (33)
+    TF_FULLSILENCE = (TF_SRCSILENCE|TF_DSTSILENCE) // 0x33 (51)
+
+} teleflags_e;
+
 int
 EV_Teleport
-( line_t*	line,
-  int		side,
-  mobj_t*	thing );
+( line_t*       line,
+  int           side,
+  mobj_t*       thing,
+  teleflags_e   flags);
 
 #endif
--- a/src/strife/p_telept.c
+++ b/src/strife/p_telept.c
@@ -46,65 +46,69 @@
 //
 // TELEPORTATION
 //
+// haleyjd 09/22/10: [STRIFE] Modified to take a flags parameter to control
+// silent teleportation.
+//
 int
 EV_Teleport
-( line_t*	line,
-  int		side,
-  mobj_t*	thing )
+( line_t*       line,
+  int           side,
+  mobj_t*       thing,
+  teleflags_e   flags)
 {
-    int		i;
-    int		tag;
-    mobj_t*	m;
-    mobj_t*	fog;
-    unsigned	an;
-    thinker_t*	thinker;
-    sector_t*	sector;
-    fixed_t	oldx;
-    fixed_t	oldy;
-    fixed_t	oldz;
+    int         i;
+    int         tag;
+    mobj_t*     m;
+    mobj_t*     fog;
+    unsigned    an;
+    thinker_t*  thinker;
+    sector_t*   sector;
+    fixed_t     oldx;
+    fixed_t     oldy;
+    fixed_t     oldz;
 
     // don't teleport missiles
     if (thing->flags & MF_MISSILE)
-	return 0;		
+        return 0;
 
     // Don't teleport if hit back of line,
     //  so you can get out of teleporter.
-    if (side == 1)		
-	return 0;	
+    if (side == 1)
+        return 0;
 
-    
+
     tag = line->tag;
     for (i = 0; i < numsectors; i++)
     {
-	if (sectors[ i ].tag == tag )
-	{
-	    thinker = thinkercap.next;
-	    for (thinker = thinkercap.next;
-		 thinker != &thinkercap;
-		 thinker = thinker->next)
-	    {
-		// not a mobj
-		if (thinker->function.acp1 != (actionf_p1)P_MobjThinker)
-		    continue;	
+        if (sectors[ i ].tag == tag )
+        {
+            thinker = thinkercap.next;
+            for (thinker = thinkercap.next;
+                thinker != &thinkercap;
+                thinker = thinker->next)
+            {
+                // not a mobj
+                if (thinker->function.acp1 != (actionf_p1)P_MobjThinker)
+                    continue;	
 
-		m = (mobj_t *)thinker;
-		
-		// not a teleportman
-		if (m->type != MT_TELEPORTMAN )
-		    continue;		
+                m = (mobj_t *)thinker;
 
-		sector = m->subsector->sector;
-		// wrong sector
-		if (sector-sectors != i )
-		    continue;	
+                // not a teleportman
+                if (m->type != MT_TELEPORTMAN )
+                    continue;		
 
-		oldx = thing->x;
-		oldy = thing->y;
-		oldz = thing->z;
-				
-		if (!P_TeleportMove (thing, m->x, m->y))
-		    return 0;
-		
+                sector = m->subsector->sector;
+                // wrong sector
+                if (sector-sectors != i )
+                    continue;	
+
+                oldx = thing->x;
+                oldy = thing->y;
+                oldz = thing->z;
+
+                if (!P_TeleportMove (thing, m->x, m->y))
+                    return 0;
+
                 // fraggle: this was changed in final doom, 
                 // problem between normal doom2 1.9 and final doom
                 //
@@ -112,30 +116,39 @@
                 // it does not have this quirk.
 
                 if (gameversion < exe_final || gameversion == exe_chex)
-		    thing->z = thing->floorz;
-                
-		if (thing->player)
-		    thing->player->viewz = thing->z+thing->player->viewheight;
-				
-		// spawn teleport fog at source and destination
-		fog = P_SpawnMobj (oldx, oldy, oldz, MT_TFOG);
-		S_StartSound (fog, sfx_telept);
-		an = m->angle >> ANGLETOFINESHIFT;
-		fog = P_SpawnMobj (m->x+20*finecosine[an], m->y+20*finesine[an]
-				   , thing->z, MT_TFOG);
+                    thing->z = thing->floorz;
+
+                if (thing->player)
+                    thing->player->viewz = thing->z+thing->player->viewheight;
 
-		// emit sound, where?
-		S_StartSound (fog, sfx_telept);
-		
-		// don't move for a bit
-		if (thing->player)
-		    thing->reactiontime = 18;	
-
-		thing->angle = m->angle;
-		thing->momx = thing->momy = thing->momz = 0;
-		return 1;
-	    }	
-	}
+                // spawn teleport fog at source and destination
+                // haleyjd 09/22/10: [STRIFE] controlled by teleport flags
+                // BUG: Behavior would be undefined if this function were passed
+                // any combination of teleflags that has the NO*FOG but not the
+                // corresponding NO*SND flag - fortunately this is never done
+                // anywhere in the code.
+                if(!(flags & TF_NOSRCFOG))
+                    fog = P_SpawnMobj (oldx, oldy, oldz, MT_TFOG);
+                if(!(flags & TF_NOSRCSND))
+                    S_StartSound (fog, sfx_telept);
+                
+                an = m->angle >> ANGLETOFINESHIFT;
+                
+                if(!(flags & TF_NODSTFOG))
+                    fog = P_SpawnMobj (m->x+20*finecosine[an], m->y+20*finesine[an], 
+                                       thing->z, MT_TFOG);
+                if(!(flags & TF_NODSTSND))
+                    S_StartSound (fog, sfx_telept);
+
+                // don't move for a bit
+                if (thing->player)
+                    thing->reactiontime = 18;	
+
+                thing->angle = m->angle;
+                thing->momx = thing->momy = thing->momz = 0;
+                return 1;
+            }	
+        }
     }
     return 0;
 }