From 9bef9730fb26727a9b505a89615b6ef0425fe64a Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 20 Sep 2008 22:58:53 +0000 Subject: Remove heretic duplicate versions of M_AddToBox, M_ClearBox, SlopeDiv and use common versions. Subversion-branch: /branches/raven-branch Subversion-revision: 1260 --- src/heretic/doomdata.h | 3 --- src/heretic/doomdef.h | 4 ---- src/heretic/m_misc.c | 18 ------------------ src/heretic/p_map.c | 1 + src/heretic/p_maputl.c | 1 + src/heretic/p_setup.c | 1 + src/heretic/r_bsp.c | 1 + src/heretic/r_main.c | 23 ++--------------------- src/tables.c | 40 ++++++++++++++++++++++------------------ src/tables.h | 5 +---- 10 files changed, 29 insertions(+), 68 deletions(-) diff --git a/src/heretic/doomdata.h b/src/heretic/doomdata.h index 8b56c0ed..b55daae4 100644 --- a/src/heretic/doomdata.h +++ b/src/heretic/doomdata.h @@ -107,9 +107,6 @@ typedef struct short offset; } mapseg_t; -enum -{ BOXTOP, BOXBOTTOM, BOXLEFT, BOXRIGHT }; // bbox coordinates - #define NF_SUBSECTOR 0x8000 typedef struct { diff --git a/src/heretic/doomdef.h b/src/heretic/doomdef.h index 02185536..4a4e5299 100644 --- a/src/heretic/doomdef.h +++ b/src/heretic/doomdef.h @@ -914,10 +914,6 @@ boolean M_ValidEpisodeMap(int episode, int map); 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); diff --git a/src/heretic/m_misc.c b/src/heretic/m_misc.c index 26794e9d..465d0fe1 100644 --- a/src/heretic/m_misc.c +++ b/src/heretic/m_misc.c @@ -86,24 +86,6 @@ boolean M_ValidEpisodeMap(int episode, int map) 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 diff --git a/src/heretic/p_map.c b/src/heretic/p_map.c index 6e98830e..8c4bf51b 100644 --- a/src/heretic/p_map.c +++ b/src/heretic/p_map.c @@ -25,6 +25,7 @@ #include #include "doomdef.h" +#include "m_bbox.h" #include "m_random.h" #include "p_local.h" #include "s_sound.h" diff --git a/src/heretic/p_maputl.c b/src/heretic/p_maputl.c index 72e4993c..fb6b7482 100644 --- a/src/heretic/p_maputl.c +++ b/src/heretic/p_maputl.c @@ -26,6 +26,7 @@ #include #include "doomdef.h" +#include "m_bbox.h" #include "p_local.h" diff --git a/src/heretic/p_setup.c b/src/heretic/p_setup.c index f9267d3f..c956cc48 100644 --- 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" diff --git a/src/heretic/r_bsp.c b/src/heretic/r_bsp.c index aed96007..a6b2d340 100644 --- 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; diff --git a/src/heretic/r_main.c b/src/heretic/r_main.c index a83422cf..b19b87c3 100644 --- a/src/heretic/r_main.c +++ b/src/heretic/r_main.c @@ -25,10 +25,9 @@ #include #include #include "doomdef.h" +#include "m_bbox.h" #include "r_local.h" -/* - -*/ +#include "tables.h" int viewangleoffset; @@ -205,24 +204,6 @@ int R_PointOnSegSide(fixed_t x, fixed_t y, seg_t * line) =============================================================================== */ -// 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) { x -= viewx; diff --git a/src/tables.c b/src/tables.c index 9c014513..543fda8c 100644 --- a/src/tables.c +++ b/src/tables.c @@ -38,33 +38,37 @@ // //----------------------------------------------------------------------------- - - - - #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; - - ans = (num<<3)/(den>>8); + { + return SLOPERANGE; + } + else + { + ans = (num << 3) / (den >> 8); - return ans <= SLOPERANGE ? ans : SLOPERANGE; + if (ans <= SLOPERANGE) + { + return ans; + } + else + { + return SLOPERANGE; + } + } } - - - const int finetangent[4096] = { -170910304,-56965752,-34178904,-24413316,-18988036,-15535599,-13145455,-11392683, diff --git a/src/tables.h b/src/tables.h index cc211c24..78057751 100644 --- a/src/tables.h +++ b/src/tables.h @@ -87,10 +87,7 @@ extern const angle_t tantoangle[SLOPERANGE+1]; // Utility function, // called by R_PointToAngle. -int -SlopeDiv -( unsigned num, - unsigned den); +int SlopeDiv(unsigned int num, unsigned int den); #endif -- cgit v1.2.3