shithub: choc

Download patch

ref: 9bef9730fb26727a9b505a89615b6ef0425fe64a
parent: 5de8de49ccc2c14b7de14da465510b2368080dd4
author: Simon Howard <[email protected]>
date: Sat Sep 20 18:58:53 EDT 2008

Remove heretic duplicate versions of M_AddToBox, M_ClearBox, SlopeDiv
and use common versions.

Subversion-branch: /branches/raven-branch
Subversion-revision: 1260

--- a/src/heretic/doomdata.h
+++ b/src/heretic/doomdata.h
@@ -107,9 +107,6 @@
     short offset;
 } mapseg_t;
 
-enum
-{ BOXTOP, BOXBOTTOM, BOXLEFT, BOXRIGHT };       // bbox coordinates
-
 #define	NF_SUBSECTOR	0x8000
 typedef struct
 {
--- a/src/heretic/doomdef.h
+++ b/src/heretic/doomdef.h
@@ -914,10 +914,6 @@
 void M_ForceUppercase(char *text);
 // Changes a string to uppercase
 
-void M_ClearBox(fixed_t * box);
-void M_AddToBox(fixed_t * box, fixed_t x, fixed_t y);
-// bounding box functions
-
 void M_LoadDefaults(void);
 
 void M_SaveDefaults(void);
--- a/src/heretic/m_misc.c
+++ b/src/heretic/m_misc.c
@@ -86,24 +86,6 @@
     return true;
 }
 
-void M_ClearBox(fixed_t * box)
-{
-    box[BOXTOP] = box[BOXRIGHT] = INT_MIN;
-    box[BOXBOTTOM] = box[BOXLEFT] = INT_MAX;
-}
-
-void M_AddToBox(fixed_t * box, fixed_t x, fixed_t y)
-{
-    if (x < box[BOXLEFT])
-        box[BOXLEFT] = x;
-    else if (x > box[BOXRIGHT])
-        box[BOXRIGHT] = x;
-    if (y < box[BOXBOTTOM])
-        box[BOXBOTTOM] = y;
-    else if (y > box[BOXTOP])
-        box[BOXTOP] = y;
-}
-
 //---------------------------------------------------------------------------
 //
 // PROC M_ForceUppercase
--- a/src/heretic/p_map.c
+++ b/src/heretic/p_map.c
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 
 #include "doomdef.h"
+#include "m_bbox.h"
 #include "m_random.h"
 #include "p_local.h"
 #include "s_sound.h"
--- a/src/heretic/p_maputl.c
+++ b/src/heretic/p_maputl.c
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 
 #include "doomdef.h"
+#include "m_bbox.h"
 #include "p_local.h"
 
 
--- a/src/heretic/p_setup.c
+++ b/src/heretic/p_setup.c
@@ -29,6 +29,7 @@
 #include "doomdef.h"
 #include "i_swap.h"
 #include "m_argv.h"
+#include "m_bbox.h"
 #include "p_local.h"
 #include "s_sound.h"
 
--- a/src/heretic/r_bsp.c
+++ b/src/heretic/r_bsp.c
@@ -23,6 +23,7 @@
 // R_bsp.c
 
 #include "doomdef.h"
+#include "m_bbox.h"
 #include "r_local.h"
 
 seg_t *curline;
--- a/src/heretic/r_main.c
+++ b/src/heretic/r_main.c
@@ -25,11 +25,10 @@
 #include <stdlib.h>
 #include <math.h>
 #include "doomdef.h"
+#include "m_bbox.h"
 #include "r_local.h"
-/*
+#include "tables.h"
 
-*/
-
 int viewangleoffset;
 
 #ifdef __WATCOMC__
@@ -204,24 +203,6 @@
 =
 ===============================================================================
 */
-
-// to get a global angle from cartesian coordinates, the coordinates are
-// flipped until they are in the first octant of the coordinate system, then
-// the y (<=x) is scaled and divided by x to get a tangent (slope) value
-// which is looked up in the tantoangle[] table.  The +1 size is to handle
-// the case when x==y without additional checking.
-#define	SLOPERANGE	2048
-#define	SLOPEBITS	11
-#define	DBITS		(FRACBITS-SLOPEBITS)
-
-int SlopeDiv(unsigned num, unsigned den)
-{
-    unsigned ans;
-    if (den < 512)
-        return SLOPERANGE;
-    ans = (num << 3) / (den >> 8);
-    return ans <= SLOPERANGE ? ans : SLOPERANGE;
-}
 
 angle_t R_PointToAngle(fixed_t x, fixed_t y)
 {
--- a/src/tables.c
+++ b/src/tables.c
@@ -38,32 +38,36 @@
 //    
 //-----------------------------------------------------------------------------
 
-
-
-
-
 #include "tables.h"
 
+// to get a global angle from cartesian coordinates, the coordinates are
+// flipped until they are in the first octant of the coordinate system, then
+// the y (<=x) is scaled and divided by x to get a tangent (slope) value
+// which is looked up in the tantoangle[] table.  The +1 size is to handle
+// the case when x==y without additional checking.
 
-
-
-int
-SlopeDiv
-( unsigned	num,
-  unsigned	den)
+int SlopeDiv(unsigned int num, unsigned int den)
 {
-    unsigned 	ans;
+    unsigned ans;
     
     if (den < 512)
-	return SLOPERANGE;
+    {
+        return SLOPERANGE;
+    }
+    else
+    {
+        ans = (num << 3) / (den >> 8);
 
-    ans = (num<<3)/(den>>8);
-
-    return ans <= SLOPERANGE ? ans : SLOPERANGE;
+        if (ans <= SLOPERANGE)
+        {
+            return ans;
+        }
+        else
+        {
+            return SLOPERANGE;
+        }
+    }
 }
-
-
-
 
 const int finetangent[4096] =
 {
--- a/src/tables.h
+++ b/src/tables.h
@@ -87,10 +87,7 @@
 
 // Utility function,
 //  called by R_PointToAngle.
-int
-SlopeDiv
-( unsigned	num,
-  unsigned	den);
+int SlopeDiv(unsigned int num, unsigned int den);
 
 
 #endif