shithub: choc

Download patch

ref: 15fdcbbe5899bde4831d100db63117ba2c00a4dd
parent: 9f4c5a6ed4e490fb51aa207c2def75fcb2622584
author: Samuel Villareal <[email protected]>
date: Thu Sep 9 22:36:05 EDT 2010

+ Fixed a minor fluke in P_ChangeSwitchTexture
+ R_SoundNumForDoor implemented
+ opensound/closesound variables added to vldoor_t struct

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

--- a/src/strife/p_spec.h
+++ b/src/strife/p_spec.h
@@ -360,20 +360,26 @@
 
 typedef struct
 {
-    thinker_t	thinker;
-    vldoor_e	type;
-    sector_t*	sector;
-    fixed_t	topheight;
-    fixed_t	speed;
+    thinker_t   thinker;
+    vldoor_e    type;
+    sector_t*   sector;
+    fixed_t     topheight;
+    fixed_t     speed;
 
     // 1 = up, 0 = waiting at top, -1 = down
-    int             direction;
+    int         direction;
     
     // tics to wait at the top
-    int             topwait;
+    int         topwait;
     // (keep in case a door going down is reset)
     // when it reaches 0, start going down
-    int             topcountdown;
+    int         topcountdown;
+
+    // villsa [STRIFE] new field - sound to play when opening
+    int         opensound;
+
+    // villsa [STRIFE] new field - sound to play when closing
+    int         closesound;
     
 } vldoor_t;
 
--- a/src/strife/p_switch.c
+++ b/src/strife/p_switch.c
@@ -220,7 +220,7 @@
 
     for(i = 0; i < 7; i++)
     {
-        glass = P_SpawnMobj(x2, y2, ONCEILINGZ, MT_JUNK);
+        glass = P_SpawnMobj(x2, y2, ONFLOORZ, MT_JUNK);
         glass->z += (24*FRACUNIT);
         glass->flags |= (MF_SHADOW|MF_MVIS);
 
@@ -312,6 +312,10 @@
 
 		S_StartSound(buttonlist->soundorg,sound);
 		sides[line->sidenum[0]].midtexture = switchlist[i^1];
+
+                // villsa [STRIFE] affect second side of line
+                if(line->flags & ML_TWOSIDED)
+                    sides[line->sidenum[1]].midtexture = switchlist[i^1];
 
 		if(useAgain)
 		    P_StartButton(line, middle,switchlist[i],BUTTONTIME);
--- a/src/strife/r_data.c
+++ b/src/strife/r_data.c
@@ -31,19 +31,14 @@
 #include "i_swap.h"
 #include "i_system.h"
 #include "z_zone.h"
-
-
 #include "w_wad.h"
-
 #include "doomdef.h"
 #include "r_local.h"
 #include "p_local.h"
-
 #include "doomstat.h"
 #include "r_sky.h"
-
-
 #include "r_data.h"
+#include "sounds.h" // villsa [STRIFE]
 
 //
 // Graphics.
@@ -781,6 +776,91 @@
 		 name);
     }
     return i;
+}
+
+//
+// R_SoundNumForDoor
+//
+// villsa [STRIFE] - new function
+// Set sounds associated with door though why
+// on earth is this function placed here?
+//
+void R_SoundNumForDoor(vldoor_t* door)
+{
+    int         i;
+    sector_t    *sector;
+    line_t      *line;
+    texture_t   *texture;
+    char        name[8];
+    char        c1;
+    char        c2;
+
+    // set default sounds
+    door->opensound = sfx_drsmto;
+    door->closesound = sfx_drsmtc;
+
+    for(sector = door->sector, i = 0; i < sector->linecount; i++)
+    {
+        line = sector->lines[i];
+
+        if(!(line->flags & ML_TWOSIDED))
+            continue;
+
+        texture = textures[sides[line->sidenum[0]].toptexture];
+        memcpy(name, texture->name, 8);
+        //memcpy(&v6, texture->index, 0);   // [STRIFE] todo - WHAT?!
+
+        if(strncmp(name, "DOR", 3))
+            continue;
+
+        c1 = name[3];
+        c2 = name[4];
+
+        // S type
+        if(c1 == 'S')
+        {
+            door->opensound = sfx_drston;
+            door->closesound = sfx_drston;
+            return;
+        }
+
+        // M type
+        if(c1 == 'M')
+        {
+            // L subtype
+            if(c2 == 'L')
+            {
+                door->opensound = sfx_drlmto;
+                door->closesound = sfx_drlmtc;
+            }
+            // S subtype
+            else if(c2 == 'S')
+            {
+                door->opensound = sfx_drsmto;
+                door->closesound = sfx_drsmtc;
+            }
+            return;
+        }
+        // W type
+        else if(c1 == 'W')
+        {
+            // L subtype
+            if(c2 == 'L')
+            {
+                door->opensound = sfx_drlwud;
+                door->closesound = sfx_drlwud;
+
+            }
+            // S subtype
+            else if(c2 == 'S')
+            {
+                door->opensound = sfx_drswud;
+                door->closesound = sfx_drswud;
+
+            }
+            return;
+        }
+    }
 }
 
 
--- a/src/strife/r_data.h
+++ b/src/strife/r_data.h
@@ -31,6 +31,7 @@
 
 #include "r_defs.h"
 #include "r_state.h"
+#include "p_spec.h"    // villsa [STRIFE]
 
 
 // Retrieve column data for span blitting.
@@ -55,5 +56,6 @@
 // returns the texture number for the texture name.
 int R_TextureNumForName (char *name);
 int R_CheckTextureNumForName (char *name);
+void R_SoundNumForDoor(vldoor_t* door); // villsa [STRIFE]
 
 #endif