ref: 61e77600041ba534d824943320e7ddddb8e4f6ce
parent: a4d274e6419f89992dfef416ee9deadded533629
author: Simon Howard <fraggle@gmail.com>
date: Mon Sep 15 20:07:46 EDT 2008
Clean up some warnings in the Hexen code. Subversion-branch: /branches/raven-branch Subversion-revision: 1232
--- a/src/hexen/h2def.h
+++ b/src/hexen/h2def.h
@@ -1193,11 +1193,11 @@
// Changes a string to uppercase
int M_Random(void);
+int P_Random(void);
// returns a number from 0 to 255
extern unsigned char rndtable[256];
extern int prndindex;
-#define P_Random() rndtable[(++prndindex)&0xff]
// as M_Random, but used only by the play simulation
void M_ClearRandom(void);
--- a/src/hexen/m_misc.c
+++ b/src/hexen/m_misc.c
@@ -168,6 +168,12 @@
int rndindex = 0;
int prndindex = 0;
+int P_Random(void)
+{
+ prndindex = (prndindex + 1) & 0xff;
+ return rndtable[prndindex];
+}
+
int M_Random(void)
{
rndindex = (rndindex + 1) & 0xff;
--- a/src/hexen/p_enemy.c
+++ b/src/hexen/p_enemy.c
@@ -3533,7 +3533,7 @@
{
mobj_t *mo;
int x, y, z;
- int rtype;
+ int rtype = 0;
switch (P_Random() % 5)
{
@@ -3970,7 +3970,7 @@
break;
default:
I_Error("corrupted sorcerer");
- break;
+ return;
}
actor->angle = angle;
angle >>= ANGLETOFINESHIFT;
@@ -5047,7 +5047,7 @@
void A_KoraxMissile(mobj_t * actor)
{
int type = P_Random() % 6;
- int sound;
+ int sound = 0;
S_StartSound(actor, SFX_KORAX_ATTACK);
--- a/src/hexen/p_maputl.c
+++ b/src/hexen/p_maputl.c
@@ -98,7 +98,7 @@
int P_BoxOnLineSide(fixed_t * tmbox, line_t * ld)
{
- int p1, p2;
+ int p1 = 0, p2 = 0;
switch (ld->slopetype)
{
@@ -839,7 +839,8 @@
if (startX >= 0 && startX < bmapwidth && startY >= 0
&& startY < bmapheight)
{
- if (target = RoughBlockCheck(mo, startY * bmapwidth + startX))
+ target = RoughBlockCheck(mo, startY * bmapwidth + startX);
+ if (target != NULL)
{ // found a target right away
return target;
}
@@ -892,7 +893,8 @@
// Trace the first block section (along the top)
for (; blockIndex <= firstStop; blockIndex++)
{
- if (target = RoughBlockCheck(mo, blockIndex))
+ target = RoughBlockCheck(mo, blockIndex);
+ if (target != NULL)
{
return target;
}
@@ -900,7 +902,8 @@
// Trace the second block section (right edge)
for (blockIndex--; blockIndex <= secondStop; blockIndex += bmapwidth)
{
- if (target = RoughBlockCheck(mo, blockIndex))
+ target = RoughBlockCheck(mo, blockIndex);
+ if (target != NULL)
{
return target;
}
@@ -908,7 +911,8 @@
// Trace the third block section (bottom edge)
for (blockIndex -= bmapwidth; blockIndex >= thirdStop; blockIndex--)
{
- if (target = RoughBlockCheck(mo, blockIndex))
+ target = RoughBlockCheck(mo, blockIndex);
+ if (target != NULL)
{
return target;
}
@@ -916,7 +920,8 @@
// Trace the final block section (left edge)
for (blockIndex++; blockIndex > finalStop; blockIndex -= bmapwidth)
{
- if (target = RoughBlockCheck(mo, blockIndex))
+ target = RoughBlockCheck(mo, blockIndex);
+ if (target != NULL)
{
return target;
}
--- a/src/hexen/p_mobj.c
+++ b/src/hexen/p_mobj.c
@@ -1351,7 +1351,7 @@
break;
default:
I_Error("P_SpawnPlayer: Unknown class type");
- break;
+ return;
}
// Set translation table data
--- a/src/hexen/p_plats.c
+++ b/src/hexen/p_plats.c
@@ -224,11 +224,13 @@
for (i = 0; i < MAXPLATS; i++)
{
- if ((activeplats[i])->tag = args[0])
+ activeplats[i]->tag = args[0];
+
+ if (activeplats[i]->tag != 0)
{
- (activeplats[i])->sector->specialdata = NULL;
- P_TagFinished((activeplats[i])->sector->tag);
- P_RemoveThinker(&(activeplats[i])->thinker);
+ activeplats[i]->sector->specialdata = NULL;
+ P_TagFinished(activeplats[i]->sector->tag);
+ P_RemoveThinker(&activeplats[i]->thinker);
activeplats[i] = NULL;
return;
--- a/src/hexen/p_pspr.c
+++ b/src/hexen/p_pspr.c
@@ -922,7 +922,7 @@
void A_LightningClip(mobj_t * actor)
{
mobj_t *cMo;
- mobj_t *target;
+ mobj_t *target = NULL;
int zigZag;
if (actor->type == MT_LIGHTNING_FLOOR)
@@ -1968,7 +1968,8 @@
{
mobj_t *target;
- if (target = P_RoughMonsterSearch(actor, 6))
+ target = P_RoughMonsterSearch(actor, 6);
+ if (target != NULL)
{
actor->special1 = (int) target;
actor->flags |= MF_NOCLIP | MF_SKULLFLY;
--- a/src/hexen/p_setup.c
+++ b/src/hexen/p_setup.c
@@ -657,7 +657,6 @@
int i;
int parm;
char lumpname[9];
- char auxName[128];
int lumpnum;
mobj_t *mobj;
--- a/src/hexen/p_telept.c
+++ b/src/hexen/p_telept.c
@@ -181,11 +181,15 @@
}
count = 1 + (P_Random() % count);
searcher = -1;
+ mo = NULL;
+
for (i = 0; i < count; i++)
{
mo = P_FindMobjFromTID(tid, &searcher);
}
- if (!mo)
+ if (mo == NULL)
+ {
I_Error("Can't find teleport mapspot\n");
+ }
return P_Teleport(thing, mo->x, mo->y, mo->angle, fog);
}
--- a/src/hexen/p_user.c
+++ b/src/hexen/p_user.c
@@ -543,6 +543,7 @@
default:
I_Error("P_UndoPlayerMorph: Unknown player class %d\n",
player->class);
+ return false;
}
if (P_TestMobjLocation(mo) == false)
{ // Didn't fit
--- a/src/hexen/po_man.c
+++ b/src/hexen/po_man.c
@@ -129,7 +129,8 @@
polyobj_t *poly;
polyNum = args[0];
- if (poly = GetPolyobj(polyNum))
+ poly = GetPolyobj(polyNum);
+ if (poly != NULL)
{
if (poly->specialdata && !overRide)
{ // poly is already moving
@@ -164,7 +165,7 @@
SN_StartSequence((mobj_t *) & poly->startSpot, SEQ_DOOR_STONE +
poly->seqType);
- while (mirror = GetPolyobjMirror(polyNum))
+ while ((mirror = GetPolyobjMirror(polyNum)) != 0)
{
poly = GetPolyobj(mirror);
if (poly && poly->specialdata && !overRide)
@@ -191,7 +192,8 @@
{
pe->dist = ANGLE_MAX - 1;
}
- if (poly = GetPolyobj(polyNum))
+ poly = GetPolyobj(polyNum);
+ if (poly != NULL)
{
poly->specialdata = pe;
}
@@ -259,7 +261,8 @@
angle_t an;
polyNum = args[0];
- if (poly = GetPolyobj(polyNum))
+ poly = GetPolyobj(polyNum);
+ if (poly != NULL)
{
if (poly->specialdata && !overRide)
{ // poly is already moving
@@ -293,7 +296,7 @@
SN_StartSequence((mobj_t *) & poly->startSpot, SEQ_DOOR_STONE +
poly->seqType);
- while (mirror = GetPolyobjMirror(polyNum))
+ while ((mirror = GetPolyobjMirror(polyNum)) != 0)
{
poly = GetPolyobj(mirror);
if (poly && poly->specialdata && !overRide)
@@ -463,10 +466,11 @@
int polyNum;
polydoor_t *pd;
polyobj_t *poly;
- angle_t an;
+ angle_t an = 0;
polyNum = args[0];
- if (poly = GetPolyobj(polyNum))
+ poly = GetPolyobj(polyNum);
+ if (poly != NULL)
{
if (poly->specialdata)
{ // poly is already moving
@@ -509,7 +513,7 @@
poly->specialdata = pd;
- while (mirror = GetPolyobjMirror(polyNum))
+ while ((mirror = GetPolyobjMirror(polyNum)) != 0)
{
poly = GetPolyobj(mirror);
if (poly && poly->specialdata)
--- a/src/hexen/r_segs.c
+++ b/src/hexen/r_segs.c
@@ -182,7 +182,7 @@
fixed_t texturecolumn;
int top, bottom;
-// texturecolumn = 0; // shut up compiler warning
+ texturecolumn = 0; // shut up compiler warning
for (; rw_x < rw_stopx; rw_x++)
{
--- a/src/hexen/sb_bar.c
+++ b/src/hexen/sb_bar.c
@@ -1978,8 +1978,6 @@
int ones;
int map;
char mapName[9];
- char auxName[128];
- FILE *fp;
tens = cheat->args[0] - '0';
ones = cheat->args[1] - '0';
--- a/src/hexen/sn_sonix.c
+++ b/src/hexen/sn_sonix.c
@@ -183,8 +183,8 @@
{
int i, j;
int inSequence;
- int *tempDataStart;
- int *tempDataPtr;
+ int *tempDataStart = NULL;
+ int *tempDataPtr = NULL;
inSequence = -1;
ActiveSequences = 0;
--- a/src/hexen/sv_save.c
+++ b/src/hexen/sv_save.c
@@ -379,7 +379,7 @@
SavePtr.b = SaveBuffer + HXS_DESCRIPTION_LENGTH;
// Check the version text
- if (strcmp(SavePtr.b, HXS_VERSION_TEXT))
+ if (strcmp((char *) SavePtr.b, HXS_VERSION_TEXT))
{ // Bad version
return;
}
@@ -475,8 +475,8 @@
boolean rClass;
boolean playerWasReborn;
boolean oldWeaponowned[NUMWEAPONS];
- int oldKeys;
- int oldPieces;
+ int oldKeys = 0;
+ int oldPieces = 0;
int bestWeapon;
if (!deathmatch)