shithub: choc

Download patch

ref: 55bb7e8935369cb392c705969ed626fe9c0c391c
parent: 61e77600041ba534d824943320e7ddddb8e4f6ce
author: Simon Howard <fraggle@gmail.com>
date: Tue Sep 16 21:05:14 EDT 2008

Convert MAXINT/MININT -> INT_MAX/INT_MIN in Heretic/Hexen code.

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

--- a/src/heretic/am_map.c
+++ b/src/heretic/am_map.c
@@ -178,9 +178,9 @@
 
   dy = ml->a.y - ml->b.y;
   dx = ml->b.x - ml->a.x;
-  if (!dy) is->islp = (dx<0?-MAXINT:MAXINT);
+  if (!dy) is->islp = (dx<0?-INT_MAX:INT_MAX);
   else is->islp = FixedDiv(dx, dy);
-  if (!dx) is->slp = (dy<0?-MAXINT:MAXINT);
+  if (!dx) is->slp = (dy<0?-INT_MAX:INT_MAX);
   else is->slp = FixedDiv(dy, dx);
 }
 */
@@ -244,8 +244,8 @@
     int i;
     fixed_t a, b;
 
-    min_x = min_y = MAXINT;
-    max_x = max_y = -MAXINT;
+    min_x = min_y = INT_MAX;
+    max_x = max_y = -INT_MAX;
     for (i = 0; i < numvertexes; i++)
     {
         if (vertexes[i].x < min_x)
@@ -275,7 +275,7 @@
     if (m_paninc.x || m_paninc.y)
     {
         followplayer = 0;
-        f_oldloc.x = MAXINT;
+        f_oldloc.x = INT_MAX;
     }
 
     m_x += m_paninc.x;
@@ -328,7 +328,7 @@
     automapactive = true;
     fb = screen;
 
-    f_oldloc.x = MAXINT;
+    f_oldloc.x = INT_MAX;
     amclock = 0;
     lightlev = 0;
 
@@ -567,7 +567,7 @@
                 break;
             case AM_FOLLOWKEY:
                 followplayer = !followplayer;
-                f_oldloc.x = MAXINT;
+                f_oldloc.x = INT_MAX;
                 P_SetMessage(plr,
                              followplayer ? AMSTR_FOLLOWON : AMSTR_FOLLOWOFF,
                              true);
@@ -669,7 +669,7 @@
 	 dmapx = (MTOF(plr->mo->x)-MTOF(f_oldloc.x)); //fixed point
 	 dmapy = (MTOF(f_oldloc.y)-MTOF(plr->mo->y));
 
-	 if(f_oldloc.x == MAXINT) //to eliminate an error when the user first
+	 if(f_oldloc.x == INT_MAX) //to eliminate an error when the user first
 		dmapx=0;  //goes into the automap.
 	 mapxstart += dmapx;
 	 mapystart += dmapy;
@@ -743,7 +743,7 @@
 
         oldplr.x = plr->mo->x;
         oldplr.y = plr->mo->y;
-//              if(f_oldloc.x == MAXINT) //to eliminate an error when the user first
+//              if(f_oldloc.x == INT_MAX) //to eliminate an error when the user first
 //                      dmapx=0;  //goes into the automap.
         mapxstart += dmapx >> 1;
         mapystart += dmapy >> 1;
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -75,7 +75,7 @@
 {
     if ((abs(a) >> 14) >= abs(b))
     {
-        return ((a ^ b) < 0 ? MININT : MAXINT);
+        return ((a ^ b) < 0 ? INT_MIN : INT_MAX);
     }
     return (FixedDiv2(a, b));
 }
--- a/src/heretic/d_net.c
+++ b/src/heretic/d_net.c
@@ -689,7 +689,7 @@
 //
     NetUpdate();
 
-    lowtic = MAXINT;
+    lowtic = INT_MAX;
     numplaying = 0;
     for (i = 0; i < doomcom->numnodes; i++)
         if (nodeingame[i])
@@ -757,7 +757,7 @@
     {
 
         NetUpdate();
-        lowtic = MAXINT;
+        lowtic = INT_MAX;
 
         for (i = 0; i < doomcom->numnodes; i++)
             if (nodeingame[i] && nettics[i] < lowtic)
--- a/src/heretic/doomdef.h
+++ b/src/heretic/doomdef.h
@@ -32,6 +32,7 @@
 #define	strcasecmp strcmpi
 #define	strncasecmp strnicmp
 #endif
+#include <limits.h>
 
 #define VERSION 130
 #define VERSION_TEXT "v1.3"
@@ -88,17 +89,6 @@
 
 #define	KEY_LALT			KEY_RALT
 
-
-
-#define MAXCHAR ((char)0x7f)
-#define MAXSHORT ((short)0x7fff)
-#define MAXINT	((int)0x7fffffff)       /* max pos 32-bit int */
-#define MAXLONG ((long)0x7fffffff)
-
-#define MINCHAR ((char)0x80)
-#define MINSHORT ((short)0x8000)
-#define MININT 	((int)0x80000000)       /* max negative 32-bit integer */
-#define MINLONG ((long)0x80000000)
 
 #define	FINEANGLES			8192
 #define	FINEMASK			(FINEANGLES-1)
--- a/src/heretic/in_lude.c
+++ b/src/heretic/in_lude.c
@@ -400,7 +400,7 @@
                 oldintertime = intertime + 200;
                 break;
             case 2:
-                oldintertime = MAXINT;
+                oldintertime = INT_MAX;
                 break;
             case 3:
                 cnt = 10;
--- a/src/heretic/m_misc.c
+++ b/src/heretic/m_misc.c
@@ -171,8 +171,8 @@
 
 void M_ClearBox(fixed_t * box)
 {
-    box[BOXTOP] = box[BOXRIGHT] = MININT;
-    box[BOXBOTTOM] = box[BOXLEFT] = MAXINT;
+    box[BOXTOP] = box[BOXRIGHT] = INT_MIN;
+    box[BOXBOTTOM] = box[BOXLEFT] = INT_MAX;
 }
 
 void M_AddToBox(fixed_t * box, fixed_t x, fixed_t y)
--- a/src/heretic/p_floor.c
+++ b/src/heretic/p_floor.c
@@ -318,7 +318,7 @@
                 break;
             case raiseToTexture:
                 {
-                    int minsize = MAXINT;
+                    int minsize = INT_MAX;
                     side_t *side;
 
                     floor->direction = 1;
--- a/src/heretic/p_local.h
+++ b/src/heretic/p_local.h
@@ -134,9 +134,9 @@
 #define FLOOR_LAVA 2
 #define FLOOR_SLUDGE 3
 
-#define ONFLOORZ MININT
-#define ONCEILINGZ MAXINT
-#define FLOATRANDZ (MAXINT-1)
+#define ONFLOORZ INT_MIN
+#define ONCEILINGZ INT_MAX
+#define FLOATRANDZ (INT_MAX-1)
 
 extern mobjtype_t PuffType;
 extern mobj_t *MissileMobj;
--- a/src/heretic/p_maputl.c
+++ b/src/heretic/p_maputl.c
@@ -622,7 +622,7 @@
 
     while (count--)
     {
-        dist = MAXINT;
+        dist = INT_MAX;
         for (scan = intercepts; scan < intercept_p; scan++)
             if (scan->frac < dist)
             {
@@ -645,7 +645,7 @@
 
         if (!func(in))
             return false;       // don't bother going farther
-        in->frac = MAXINT;
+        in->frac = INT_MAX;
     }
 
     return true;                // everything was traversed
--- a/src/heretic/p_sight.c
+++ b/src/heretic/p_sight.c
@@ -171,7 +171,7 @@
 
     while (count--)
     {
-        dist = MAXINT;
+        dist = INT_MAX;
         for (scan = intercepts; scan < intercept_p; scan++)
             if (scan->frac < dist)
             {
@@ -181,7 +181,7 @@
 
         if (!PTR_SightTraverse(in))
             return false;       // don't bother going farther
-        in->frac = MAXINT;
+        in->frac = INT_MAX;
     }
 
     return true;                // everything was traversed
--- a/src/heretic/p_spec.c
+++ b/src/heretic/p_spec.c
@@ -441,7 +441,7 @@
     int i;
     line_t *check;
     sector_t *other;
-    fixed_t height = MAXINT;
+    fixed_t height = INT_MAX;
 
     for (i = 0; i < sec->linecount; i++)
     {
--- a/src/heretic/r_main.c
+++ b/src/heretic/r_main.c
@@ -71,7 +71,7 @@
 angle_t xtoviewangle[SCREENWIDTH + 1];
 
 // the finetangentgent[angle+FINEANGLES/4] table holds the fixed_t tangent
-// values for view angles, ranging from MININT to 0 to MAXINT.
+// values for view angles, ranging from INT_MIN to 0 to INT_MAX.
 // fixed_t              finetangent[FINEANGLES/2];
 
 // fixed_t              finesine[5*FINEANGLES/4];
--- a/src/heretic/r_segs.c
+++ b/src/heretic/r_segs.c
@@ -140,7 +140,7 @@
     for (dc_x = x1; dc_x <= x2; dc_x++)
     {
         // calculate lighting
-        if (maskedtexturecol[dc_x] != MAXSHORT)
+        if (maskedtexturecol[dc_x] != SHRT_MAX)
         {
             if (!fixedcolormap)
             {
@@ -161,7 +161,7 @@
                                             maskedtexturecol[dc_x]) - 3);
 
             R_DrawMaskedColumn(col, -1);
-            maskedtexturecol[dc_x] = MAXSHORT;
+            maskedtexturecol[dc_x] = SHRT_MAX;
         }
         spryscale += rw_scalestep;
     }
@@ -444,8 +444,8 @@
         ds_p->silhouette = SIL_BOTH;
         ds_p->sprtopclip = screenheightarray;
         ds_p->sprbottomclip = negonearray;
-        ds_p->bsilheight = MAXINT;
-        ds_p->tsilheight = MININT;
+        ds_p->bsilheight = INT_MAX;
+        ds_p->tsilheight = INT_MIN;
     }
     else
     {
@@ -462,7 +462,7 @@
         else if (backsector->floorheight > viewz)
         {
             ds_p->silhouette = SIL_BOTTOM;
-            ds_p->bsilheight = MAXINT;
+            ds_p->bsilheight = INT_MAX;
 //                      ds_p->sprbottomclip = negonearray;
         }
         if (frontsector->ceilingheight < backsector->ceilingheight)
@@ -473,7 +473,7 @@
         else if (backsector->ceilingheight < viewz)
         {
             ds_p->silhouette |= SIL_TOP;
-            ds_p->tsilheight = MININT;
+            ds_p->tsilheight = INT_MIN;
 //                      ds_p->sprtopclip = screenheightarray;
         }
 
@@ -480,13 +480,13 @@
         if (backsector->ceilingheight <= frontsector->floorheight)
         {
             ds_p->sprbottomclip = negonearray;
-            ds_p->bsilheight = MAXINT;
+            ds_p->bsilheight = INT_MAX;
             ds_p->silhouette |= SIL_BOTTOM;
         }
         if (backsector->floorheight >= frontsector->ceilingheight)
         {
             ds_p->sprtopclip = screenheightarray;
-            ds_p->tsilheight = MININT;
+            ds_p->tsilheight = INT_MIN;
             ds_p->silhouette |= SIL_TOP;
         }
         worldhigh = backsector->ceilingheight - viewz;
@@ -660,12 +660,12 @@
     if (maskedtexture && !(ds_p->silhouette & SIL_TOP))
     {
         ds_p->silhouette |= SIL_TOP;
-        ds_p->tsilheight = MININT;
+        ds_p->tsilheight = INT_MIN;
     }
     if (maskedtexture && !(ds_p->silhouette & SIL_BOTTOM))
     {
         ds_p->silhouette |= SIL_BOTTOM;
-        ds_p->bsilheight = MAXINT;
+        ds_p->bsilheight = INT_MAX;
     }
     ds_p++;
 }
--- a/src/heretic/r_things.c
+++ b/src/heretic/r_things.c
@@ -851,7 +851,7 @@
     vsprsortedhead.next = vsprsortedhead.prev = &vsprsortedhead;
     for (i = 0; i < count; i++)
     {
-        bestscale = MAXINT;
+        bestscale = INT_MAX;
         for (ds = unsorted.next; ds != &unsorted; ds = ds->next)
         {
             if (ds->scale < bestscale)
--- a/src/hexen/am_map.c
+++ b/src/hexen/am_map.c
@@ -126,9 +126,9 @@
 
   dy = ml->a.y - ml->b.y;
   dx = ml->b.x - ml->a.x;
-  if (!dy) is->islp = (dx<0?-MAXINT:MAXINT);
+  if (!dy) is->islp = (dx<0?-INT_MAX:INT_MAX);
   else is->islp = FixedDiv(dx, dy);
-  if (!dx) is->slp = (dy<0?-MAXINT:MAXINT);
+  if (!dx) is->slp = (dy<0?-INT_MAX:INT_MAX);
   else is->slp = FixedDiv(dy, dx);
 }
 */
@@ -192,8 +192,8 @@
     int i;
     fixed_t a, b;
 
-    min_x = min_y = MAXINT;
-    max_x = max_y = -MAXINT;
+    min_x = min_y = INT_MAX;
+    max_x = max_y = -INT_MAX;
     for (i = 0; i < numvertexes; i++)
     {
         if (vertexes[i].x < min_x)
@@ -223,7 +223,7 @@
     if (m_paninc.x || m_paninc.y)
     {
         followplayer = 0;
-        f_oldloc.x = MAXINT;
+        f_oldloc.x = INT_MAX;
     }
 
     m_x += m_paninc.x;
@@ -276,7 +276,7 @@
     automapactive = true;
     fb = screen;
 
-    f_oldloc.x = MAXINT;
+    f_oldloc.x = INT_MAX;
     amclock = 0;
     lightlev = 0;
 
@@ -487,7 +487,7 @@
                 break;
             case AM_FOLLOWKEY:
                 followplayer = !followplayer;
-                f_oldloc.x = MAXINT;
+                f_oldloc.x = INT_MAX;
                 P_SetMessage(plr,
                              followplayer ? AMSTR_FOLLOWON : AMSTR_FOLLOWOFF,
                              true);
@@ -576,7 +576,7 @@
 	 dmapx = (MTOF(plr->mo->x)-MTOF(f_oldloc.x)); //fixed point
 	 dmapy = (MTOF(f_oldloc.y)-MTOF(plr->mo->y));
 
-	 if(f_oldloc.x == MAXINT) //to eliminate an error when the user first
+	 if(f_oldloc.x == INT_MAX) //to eliminate an error when the user first
 		dmapx=0;  //goes into the automap.
 	 mapxstart += dmapx;
 	 mapystart += dmapy;
@@ -650,7 +650,7 @@
 
         oldplr.x = plr->mo->x;
         oldplr.y = plr->mo->y;
-//              if(f_oldloc.x == MAXINT) //to eliminate an error when the user first
+//              if(f_oldloc.x == INT_MAX) //to eliminate an error when the user first
 //                      dmapx=0;  //goes into the automap.
         mapxstart += dmapx >> 1;
         mapystart += dmapy >> 1;
--- a/src/hexen/d_net.c
+++ b/src/hexen/d_net.c
@@ -823,7 +823,7 @@
 //
     NetUpdate();
 
-    lowtic = MAXINT;
+    lowtic = INT_MAX;
     numplaying = 0;
     for (i = 0; i < doomcom->numnodes; i++)
         if (nodeingame[i])
@@ -891,7 +891,7 @@
     {
 
         NetUpdate();
-        lowtic = MAXINT;
+        lowtic = INT_MAX;
 
         for (i = 0; i < doomcom->numnodes; i++)
             if (nodeingame[i] && nettics[i] < lowtic)
--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -844,7 +844,7 @@
 {
     if ((abs(a) >> 14) >= abs(b))
     {
-        return ((a ^ b) < 0 ? MININT : MAXINT);
+        return ((a ^ b) < 0 ? INT_MIN : INT_MAX);
     }
     return (FixedDiv2(a, b));
 }
--- a/src/hexen/h2def.h
+++ b/src/hexen/h2def.h
@@ -27,6 +27,8 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <values.h>
+
 #include "st_start.h"
 #ifdef __WATCOMC__
 #include <malloc.h>
@@ -117,16 +119,6 @@
 #define KEY_ZERO			0x30
 #define KEY_BACKSLASH		0x5C
 
-
-#define MAXCHAR ((char)0x7f)
-#define MAXSHORT ((short)0x7fff)
-#define MAXINT	((int)0x7fffffff)       /* max pos 32-bit int */
-#define MAXLONG ((long)0x7fffffff)
-
-#define MINCHAR ((char)0x80)
-#define MINSHORT ((short)0x8000)
-#define MININT 	((int)0x80000000)       /* max negative 32-bit integer */
-#define MINLONG ((long)0x80000000)
 
 #define	FINEANGLES			8192
 #define	FINEMASK			(FINEANGLES-1)
--- a/src/hexen/info.c
+++ b/src/hexen/info.c
@@ -5288,7 +5288,7 @@
      0,                         // speed
      1,                         // radius
      1,                         // height
-     MAXINT,                    // mass
+     INT_MAX,                    // mass
      0,                         // damage
      SFX_NONE,                  // activesound
      MF_NOGRAVITY | MF_NOBLOCKMAP | MF_SHADOW | MF_NOCLIP | MF_DROPOFF, // flags
@@ -5882,7 +5882,7 @@
      0,                         // speed
      15 * FRACUNIT,             // radius
      180 * FRACUNIT,            // height
-     MAXINT,                    // mass
+     INT_MAX,                    // mass
      0,                         // damage
      SFX_NONE,                  // activesound
      MF_SOLID | MF_SHOOTABLE | MF_NOBLOOD,      // flags
@@ -8312,7 +8312,7 @@
      0,                         // speed
      8 * FRACUNIT,              // radius
      24 * FRACUNIT,             // height
-     MAXINT,                    // mass
+     INT_MAX,                    // mass
      0,                         // damage
      SFX_NONE,                  // activesound
      MF_SOLID | MF_SHOOTABLE | MF_NOBLOOD,      // flags
@@ -8339,7 +8339,7 @@
      0,                         // speed
      16 * FRACUNIT,             // radius
      40 * FRACUNIT,             // height
-     MAXINT,                    // mass
+     INT_MAX,                    // mass
      0,                         // damage
      SFX_NONE,                  // activesound
      MF_SOLID | MF_SHOOTABLE | MF_NOBLOOD,      // flags
@@ -8393,7 +8393,7 @@
      0,                         // speed
      6 * FRACUNIT,              // radius
      20 * FRACUNIT,             // height
-     MAXINT,                    // mass
+     INT_MAX,                    // mass
      0,                         // damage
      SFX_NONE,                  // activesound
      MF_SHOOTABLE | MF_SOLID | MF_NOBLOOD,      // flags
@@ -8528,7 +8528,7 @@
      0,                         // speed
      16 * FRACUNIT,             // radius
      72 * FRACUNIT,             // height
-     MAXINT,                    // mass
+     INT_MAX,                    // mass
      0,                         // damage
      SFX_NONE,                  // activesound
      MF_SOLID | MF_SHOOTABLE | MF_NOBLOOD,      // flags
@@ -8582,7 +8582,7 @@
      0,                         // speed
      56 * FRACUNIT,             // radius
      120 * FRACUNIT,            // height
-     MAXINT,                    // mass
+     INT_MAX,                    // mass
      0,                         // damage
      SFX_NONE,                  // activesound
      MF_SOLID | MF_SHOOTABLE | MF_NOBLOOD | MF_NOGRAVITY | MF_SPAWNCEILING,     // flags
@@ -8663,7 +8663,7 @@
      0,                         // speed
      11 * FRACUNIT,             // radius
      130 * FRACUNIT,            // height
-     MAXINT,                    // mass
+     INT_MAX,                    // mass
      0,                         // damage
      SFX_NONE,                  // activesound
      MF_SOLID | MF_SHOOTABLE | MF_NOBLOOD,      // flags
@@ -11660,7 +11660,7 @@
      12,                        // speed
      32 * FRACUNIT,             // radius
      70 * FRACUNIT,             // height
-     MAXINT,                    // mass
+     INT_MAX,                    // mass
      0,                         // damage
      SFX_NONE,                  // activesound
      MF_SOLID | MF_COUNTKILL | MF_NOBLOOD,      // flags
@@ -11984,7 +11984,7 @@
      10 * FRACUNIT,             // speed
      20 * FRACUNIT,             // radius
      65 * FRACUNIT,             // height
-     MAXINT,                    // mass
+     INT_MAX,                    // mass
      0,                         // damage
      SFX_DRAGON_ACTIVE,         // activesound
      MF_SOLID | MF_SHOOTABLE | MF_COUNTKILL | MF_FLOAT | MF_NOGRAVITY | MF_NOBLOOD,     // flags
--- a/src/hexen/m_misc.c
+++ b/src/hexen/m_misc.c
@@ -188,8 +188,8 @@
 
 void M_ClearBox(fixed_t * box)
 {
-    box[BOXTOP] = box[BOXRIGHT] = MININT;
-    box[BOXBOTTOM] = box[BOXLEFT] = MAXINT;
+    box[BOXTOP] = box[BOXRIGHT] = INT_MIN;
+    box[BOXBOTTOM] = box[BOXLEFT] = INT_MAX;
 }
 
 void M_AddToBox(fixed_t * box, fixed_t x, fixed_t y)
--- a/src/hexen/p_local.h
+++ b/src/hexen/p_local.h
@@ -135,10 +135,10 @@
     FLOOR_SLUDGE
 };
 
-#define ONFLOORZ MININT
-#define ONCEILINGZ MAXINT
-#define FLOATRANDZ (MAXINT-1)
-#define FROMCEILINGZ128 (MAXINT-2)
+#define ONFLOORZ INT_MIN
+#define ONCEILINGZ INT_MAX
+#define FLOATRANDZ (INT_MAX-1)
+#define FROMCEILINGZ128 (INT_MAX-2)
 
 extern mobjtype_t PuffType;
 extern mobj_t *MissileMobj;
--- a/src/hexen/p_map.c
+++ b/src/hexen/p_map.c
@@ -505,7 +505,7 @@
         {
             if (thing->flags & MF_SHOOTABLE && thing != tmthing->target)
             {
-                if (thing->info->mass != MAXINT)
+                if (thing->info->mass != INT_MAX)
                 {
                     thing->momx += tmthing->momx >> 4;
                     thing->momy += tmthing->momy >> 4;
--- a/src/hexen/p_maputl.c
+++ b/src/hexen/p_maputl.c
@@ -653,7 +653,7 @@
 
     while (count--)
     {
-        dist = MAXINT;
+        dist = INT_MAX;
         for (scan = intercepts; scan < intercept_p; scan++)
             if (scan->frac < dist)
             {
@@ -676,7 +676,7 @@
 
         if (!func(in))
             return false;       // don't bother going farther
-        in->frac = MAXINT;
+        in->frac = INT_MAX;
     }
 
     return true;                // everything was traversed
--- a/src/hexen/p_sight.c
+++ b/src/hexen/p_sight.c
@@ -215,7 +215,7 @@
 
     while (count--)
     {
-        dist = MAXINT;
+        dist = INT_MAX;
         for (scan = intercepts; scan < intercept_p; scan++)
             if (scan->frac < dist)
             {
@@ -225,7 +225,7 @@
 
         if (!PTR_SightTraverse(in))
             return false;       // don't bother going farther
-        in->frac = MAXINT;
+        in->frac = INT_MAX;
     }
 
     return true;                // everything was traversed
--- a/src/hexen/p_spec.c
+++ b/src/hexen/p_spec.c
@@ -274,7 +274,7 @@
     int i;
     line_t *check;
     sector_t *other;
-    fixed_t height = MAXINT;
+    fixed_t height = INT_MAX;
 
     for (i = 0; i < sec->linecount; i++)
     {
--- a/src/hexen/r_main.c
+++ b/src/hexen/r_main.c
@@ -67,7 +67,7 @@
 angle_t xtoviewangle[SCREENWIDTH + 1];
 
 // the finetangentgent[angle+FINEANGLES/4] table holds the fixed_t tangent
-// values for view angles, ranging from MININT to 0 to MAXINT.
+// values for view angles, ranging from INT_MIN to 0 to INT_MAX.
 // fixed_t              finetangent[FINEANGLES/2];
 
 // fixed_t              finesine[5*FINEANGLES/4];
--- a/src/hexen/r_segs.c
+++ b/src/hexen/r_segs.c
@@ -131,7 +131,7 @@
     for (dc_x = x1; dc_x <= x2; dc_x++)
     {
         // calculate lighting
-        if (maskedtexturecol[dc_x] != MAXSHORT)
+        if (maskedtexturecol[dc_x] != SHRT_MAX)
         {
             if (!fixedcolormap)
             {
@@ -152,7 +152,7 @@
                                             maskedtexturecol[dc_x]) - 3);
 
             R_DrawMaskedColumn(col, -1);
-            maskedtexturecol[dc_x] = MAXSHORT;
+            maskedtexturecol[dc_x] = SHRT_MAX;
         }
         spryscale += rw_scalestep;
     }
@@ -435,8 +435,8 @@
         ds_p->silhouette = SIL_BOTH;
         ds_p->sprtopclip = screenheightarray;
         ds_p->sprbottomclip = negonearray;
-        ds_p->bsilheight = MAXINT;
-        ds_p->tsilheight = MININT;
+        ds_p->bsilheight = INT_MAX;
+        ds_p->tsilheight = INT_MIN;
     }
     else
     {
@@ -453,7 +453,7 @@
         else if (backsector->floorheight > viewz)
         {
             ds_p->silhouette = SIL_BOTTOM;
-            ds_p->bsilheight = MAXINT;
+            ds_p->bsilheight = INT_MAX;
 //                      ds_p->sprbottomclip = negonearray;
         }
         if (frontsector->ceilingheight < backsector->ceilingheight)
@@ -464,7 +464,7 @@
         else if (backsector->ceilingheight < viewz)
         {
             ds_p->silhouette |= SIL_TOP;
-            ds_p->tsilheight = MININT;
+            ds_p->tsilheight = INT_MIN;
 //                      ds_p->sprtopclip = screenheightarray;
         }
 
@@ -471,13 +471,13 @@
         if (backsector->ceilingheight <= frontsector->floorheight)
         {
             ds_p->sprbottomclip = negonearray;
-            ds_p->bsilheight = MAXINT;
+            ds_p->bsilheight = INT_MAX;
             ds_p->silhouette |= SIL_BOTTOM;
         }
         if (backsector->floorheight >= frontsector->ceilingheight)
         {
             ds_p->sprtopclip = screenheightarray;
-            ds_p->tsilheight = MININT;
+            ds_p->tsilheight = INT_MIN;
             ds_p->silhouette |= SIL_TOP;
         }
         worldhigh = backsector->ceilingheight - viewz;
@@ -652,12 +652,12 @@
     if (maskedtexture && !(ds_p->silhouette & SIL_TOP))
     {
         ds_p->silhouette |= SIL_TOP;
-        ds_p->tsilheight = MININT;
+        ds_p->tsilheight = INT_MIN;
     }
     if (maskedtexture && !(ds_p->silhouette & SIL_BOTTOM))
     {
         ds_p->silhouette |= SIL_BOTTOM;
-        ds_p->bsilheight = MAXINT;
+        ds_p->bsilheight = INT_MAX;
     }
     ds_p++;
 }
--- a/src/hexen/r_things.c
+++ b/src/hexen/r_things.c
@@ -879,7 +879,7 @@
     vsprsortedhead.next = vsprsortedhead.prev = &vsprsortedhead;
     for (i = 0; i < count; i++)
     {
-        bestscale = MAXINT;
+        bestscale = INT_MAX;
         for (ds = unsorted.next; ds != &unsorted; ds = ds->next)
         {
             if (ds->scale < bestscale)