mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-18 14:41:55 +00:00
- fixed most warnings GCC pointed out in game code.
This commit is contained in:
parent
f7fdc5af41
commit
c6bd5c04c7
22 changed files with 97 additions and 72 deletions
|
@ -576,6 +576,7 @@ void ParseScript(int lumpnum)
|
|||
rfs.SkipBeyondValue('\n');
|
||||
}
|
||||
}
|
||||
[[fallthrough]];
|
||||
}
|
||||
case kTagResource: // really light blue..
|
||||
{
|
||||
|
|
|
@ -314,7 +314,7 @@ void GameInterface::Ticker()
|
|||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
team_ticker[i] = team_ticker[i] -= 4;
|
||||
team_ticker[i] -= 4;
|
||||
if (team_ticker[i] < 0)
|
||||
team_ticker[i] = 0;
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ static int parseArgs(char *pzArgs, int *nArg1, int *nArg2)
|
|||
{
|
||||
if (!nArg1 || !nArg2 || strlen(pzArgs) < 3)
|
||||
return -1;
|
||||
*nArg1 = pzArgs[0] - '0';
|
||||
*nArg1 = pzArgs[0] - '0';
|
||||
int a1 = pzArgs[1] == ' ' ? 0 : pzArgs[1] - '0';
|
||||
*nArg2 = a1 * 10 + (pzArgs[2] - '0');
|
||||
return 2;
|
||||
|
|
|
@ -493,7 +493,7 @@ void nnExtResetGlobals()
|
|||
memset(gImpactSpritesList, 0, sizeof(gImpactSpritesList));
|
||||
|
||||
// reset tracking conditions, if any
|
||||
for (int i = 0; i < countof(gCondition); i++)
|
||||
for (size_t i = 0; i < countof(gCondition); i++)
|
||||
{
|
||||
TRCONDITION* pCond = &gCondition[i];
|
||||
for (unsigned k = 0; k < kMaxTracedObjects; k++)
|
||||
|
@ -2601,7 +2601,7 @@ void usePropertiesChanger(DBloodActor* sourceactor, int objType, int objIndex, D
|
|||
// data3 = set wall hitag
|
||||
if (valueIsBetween(pXSource->data3, -1, 32767))
|
||||
{
|
||||
if ((pSource->flags & kModernTypeFlag1)) pWall->hitag = pWall->hitag |= pXSource->data3;
|
||||
if ((pSource->flags & kModernTypeFlag1)) pWall->hitag |= pXSource->data3;
|
||||
else pWall->hitag = pXSource->data3;
|
||||
}
|
||||
|
||||
|
@ -2611,7 +2611,7 @@ void usePropertiesChanger(DBloodActor* sourceactor, int objType, int objIndex, D
|
|||
old = pWall->cstat;
|
||||
|
||||
// set new cstat
|
||||
if ((pSource->flags & kModernTypeFlag1)) pWall->cstat = pWall->cstat |= pXSource->data4; // relative
|
||||
if ((pSource->flags & kModernTypeFlag1)) pWall->cstat |= pXSource->data4; // relative
|
||||
else pWall->cstat = pXSource->data4; // absolute
|
||||
|
||||
// and hanlde exceptions
|
||||
|
@ -5062,12 +5062,11 @@ bool aiFightMatesHaveSameTarget(DBloodActor* leaderactor, DBloodActor* targetact
|
|||
|
||||
for (int i = bucketHead[rx]; i < bucketHead[rx + 1]; i++)
|
||||
{
|
||||
if (rxBucket[i].type != OBJ_SPRITE)
|
||||
continue;
|
||||
if (rxBucket[i].type != OBJ_SPRITE) continue;
|
||||
|
||||
auto mate = rxBucket[i].actor;
|
||||
if (!mate || !mate->hasX() || mate == leaderactor || !mate->IsDudeActor())
|
||||
continue;
|
||||
auto mate = rxBucket[i].actor;
|
||||
if (!mate || !mate->hasX() || mate == leaderactor || !mate->IsDudeActor())
|
||||
continue;
|
||||
|
||||
if (mate->GetTarget() == targetactor && allow-- <= 0)
|
||||
return true;
|
||||
|
@ -9059,8 +9058,8 @@ bool incDecGoalValueIsReached(DBloodActor* actor)
|
|||
{
|
||||
XSPRITE* pXSprite = &actor->x();
|
||||
if (pXSprite->data3 != pXSprite->sysData1) return false;
|
||||
char buffer[5];
|
||||
snprintf(buffer, 5, "%d", abs(pXSprite->data1));
|
||||
char buffer[7];
|
||||
snprintf(buffer, 7, "%d", abs(pXSprite->data1));
|
||||
int len = int(strlen(buffer));
|
||||
int rx = -1;
|
||||
|
||||
|
|
|
@ -5099,7 +5099,7 @@ int dodge(DDukeActor* actor)
|
|||
int furthestangle(DDukeActor *actor, int angs)
|
||||
{
|
||||
auto s = actor->s;
|
||||
int j, hitsect, hitwall, furthest_angle, angincs;
|
||||
int j, hitsect, hitwall, furthest_angle = 0, angincs;
|
||||
int hx, hy, hz, d, greatestd;
|
||||
DDukeActor* dd;
|
||||
|
||||
|
|
|
@ -345,6 +345,10 @@ void dojaildoor(void)
|
|||
auto wal = &wall[j];
|
||||
switch (jaildoordir[i])
|
||||
{
|
||||
default: // make case of bad parameters well defined.
|
||||
x = wal->x;
|
||||
y = wal->y;
|
||||
break;
|
||||
case 10:
|
||||
x = wal->x;
|
||||
y = wal->y + speed;
|
||||
|
@ -427,23 +431,28 @@ void moveminecart(void)
|
|||
endwall = startwall + sectp->wallnum;
|
||||
for (j = startwall; j < endwall; j++)
|
||||
{
|
||||
auto wal = &wall[j];
|
||||
switch (minecartdir[i])
|
||||
{
|
||||
default: // make case of bad parameters well defined.
|
||||
x = wal->x;
|
||||
y = wal->y;
|
||||
break;
|
||||
case 10:
|
||||
x = wall[j].x;
|
||||
y = wall[j].y + speed;
|
||||
x = wal->x;
|
||||
y = wal->y + speed;
|
||||
break;
|
||||
case 20:
|
||||
x = wall[j].x - speed;
|
||||
y = wall[j].y;
|
||||
x = wal->x - speed;
|
||||
y = wal->y;
|
||||
break;
|
||||
case 30:
|
||||
x = wall[j].x;
|
||||
y = wall[j].y - speed;
|
||||
x = wal->x;
|
||||
y = wal->y - speed;
|
||||
break;
|
||||
case 40:
|
||||
x = wall[j].x + speed;
|
||||
y = wall[j].y;
|
||||
x = wal->x + speed;
|
||||
y = wal->y;
|
||||
break;
|
||||
}
|
||||
dragpoint(j,x,y);
|
||||
|
@ -561,7 +570,7 @@ void thunder(void)
|
|||
{
|
||||
struct player_struct* p;
|
||||
int r1, r2;
|
||||
int startwall, endwall, i, j;
|
||||
int startwall, endwall, i = 0, j;
|
||||
uint8_t shade;
|
||||
|
||||
p = &ps[screenpeek];
|
||||
|
|
|
@ -1572,7 +1572,7 @@ void movetransports_r(void)
|
|||
{
|
||||
uint8_t warpdir, warpspriteto;
|
||||
int k, p, sectlotag;
|
||||
int ll2, ll, onfloorz;
|
||||
int ll2 = 0, ll, onfloorz;
|
||||
Collision coll;
|
||||
|
||||
//Transporters
|
||||
|
@ -4104,14 +4104,13 @@ void fall_r(DDukeActor* ac, int g_p)
|
|||
|
||||
void destroyit(DDukeActor *actor)
|
||||
{
|
||||
int lotag, hitag;
|
||||
int lotag = 0, hitag = 0;
|
||||
int wi, wj;
|
||||
int wallstart2, wallend2;
|
||||
int sectnum;
|
||||
int wallstart, wallend;
|
||||
DDukeActor* spr = nullptr;
|
||||
|
||||
hitag = 0;
|
||||
DukeSectIterator it1(actor->s->sectnum);
|
||||
while (auto a2 = it1.Next())
|
||||
{
|
||||
|
|
|
@ -164,7 +164,7 @@ int checkpins(int sect)
|
|||
|
||||
void resetpins(int sect)
|
||||
{
|
||||
int i, tag;
|
||||
int i, tag = 0;
|
||||
int x, y;
|
||||
DukeSectIterator it(sect);
|
||||
while (auto a2 = it.Next())
|
||||
|
|
|
@ -2989,7 +2989,7 @@ int ParseState::parse(void)
|
|||
lMaxDistVar = *(insptr++);
|
||||
lVarID = *(insptr++);
|
||||
lMaxDist = GetGameVarID(lMaxDistVar, g_ac, g_p);
|
||||
DDukeActor* lFound;
|
||||
DDukeActor* lFound = nullptr;
|
||||
lDist = 32767; // big number
|
||||
|
||||
DukeStatIterator it(STAT_ACTOR);
|
||||
|
|
|
@ -148,7 +148,7 @@ static void shootfireball(DDukeActor *actor, int p, int sx, int sy, int sz, int
|
|||
static void shootflamethrowerflame(DDukeActor* actor, int p, int sx, int sy, int sz, int sa)
|
||||
{
|
||||
auto s = actor->s;
|
||||
int vel, zvel;
|
||||
int vel, zvel = 0;
|
||||
|
||||
if (s->extra >= 0)
|
||||
s->shade = -96;
|
||||
|
|
|
@ -209,7 +209,7 @@ static void shootweapon(DDukeActor* actor, int p, int sx, int sy, int sz, int sa
|
|||
{
|
||||
auto s = actor->s;
|
||||
int sect = s->sectnum;
|
||||
int zvel;
|
||||
int zvel = 0;
|
||||
int hitsect, hitwall;
|
||||
int hitx, hity, hitz;
|
||||
DDukeActor* hitsprt;
|
||||
|
|
|
@ -499,6 +499,7 @@ void prelevel_r(int g)
|
|||
{
|
||||
int ii;
|
||||
int childsectnum = -1;
|
||||
dist = 0;
|
||||
DukeSectIterator it(i);
|
||||
while (auto act = it.Next())
|
||||
{
|
||||
|
|
|
@ -624,7 +624,7 @@ void spawneffector(DDukeActor* actor)
|
|||
auto sectp = sp->sector();
|
||||
int sect = sp->sectnum;
|
||||
auto t = actor->temp_data;
|
||||
int startwall, endwall, x, y, d, s, clostest;
|
||||
int startwall, endwall, x, y, d, s, clostest = 0;
|
||||
|
||||
sp->yvel = sectp->extra;
|
||||
sp->cstat |= 32768;
|
||||
|
|
|
@ -288,7 +288,7 @@ int BelowNear(DExhumedActor* pActor, int x, int y, int walldist, int nSector)
|
|||
|
||||
if (GlobalSectorList.Size() > nearstart)
|
||||
{
|
||||
short edx;
|
||||
int edx = 0;
|
||||
|
||||
for (unsigned i = nearstart; i < GlobalSectorList.Size(); i++)
|
||||
{
|
||||
|
@ -697,8 +697,8 @@ int GetAngleToSprite(DExhumedActor* a1, DExhumedActor* a2)
|
|||
if (!a1 || !a2)
|
||||
return -1;
|
||||
|
||||
auto pSprite1 = &a1->s();
|
||||
auto pSprite2 = &a2->s();
|
||||
auto pSprite1 = &a1->s();
|
||||
auto pSprite2 = &a2->s();
|
||||
|
||||
return GetMyAngle(pSprite2->x - pSprite1->x, pSprite2->y - pSprite1->y);
|
||||
}
|
||||
|
@ -708,8 +708,8 @@ int PlotCourseToSprite(DExhumedActor* pActor1, DExhumedActor* pActor2)
|
|||
if (pActor1 == nullptr || pActor2 == nullptr)
|
||||
return -1;
|
||||
|
||||
auto pSprite1 = &pActor1->s();
|
||||
auto pSprite2 = &pActor2->s();
|
||||
auto pSprite1 = &pActor1->s();
|
||||
auto pSprite2 = &pActor2->s();
|
||||
int x = pSprite2->x - pSprite1->x;
|
||||
int y = pSprite2->y - pSprite1->y;
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ bool WarpCheat(cheatseq_t* c)
|
|||
if (TEST(pp->Flags, PF_DEAD))
|
||||
return true;
|
||||
|
||||
DeferredStartGame(maprec, g_nextskill);
|
||||
DeferredStartGame(maprec, g_nextskill);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ void GameInterface::app_init()
|
|||
for (int i = 0; i < MAX_SW_PLAYERS; i++)
|
||||
INITLIST(&Player[i].PanelSpriteList);
|
||||
|
||||
LoadCustomInfoFromScript("engine/swcustom.txt"); // load the internal definitions. These also apply to the shareware version.
|
||||
LoadCustomInfoFromScript("engine/swcustom.txt"); // load the internal definitions. These also apply to the shareware version.
|
||||
if (!SW_SHAREWARE)
|
||||
LoadCustomInfoFromScript("swcustom.txt"); // Load user customisation information
|
||||
|
||||
|
|
|
@ -854,6 +854,14 @@ struct PLAYERstruct
|
|||
PANEL_SPRITEp Next, Prev;
|
||||
} PanelSpriteList;
|
||||
|
||||
// hack stuff to get a working pointer to this list element without running into type punning warnings with GCC.
|
||||
// The list uses itself as sentinel element despite the type mismatch.
|
||||
PANEL_SPRITEp GetPanelSpriteList()
|
||||
{
|
||||
void* p = &PanelSpriteList;
|
||||
return reinterpret_cast<PANEL_SPRITEp>(p);
|
||||
}
|
||||
|
||||
// Key stuff
|
||||
unsigned char HasKey[8];
|
||||
|
||||
|
|
|
@ -97,12 +97,15 @@ static int &getvalue(so_interp::interp_data& element, bool write)
|
|||
case soi_sprx:
|
||||
if (element.actorofang)
|
||||
return element.actorofang->s().x;
|
||||
break;
|
||||
case soi_spry:
|
||||
if (element.actorofang)
|
||||
return element.actorofang->s().y;
|
||||
break;
|
||||
case soi_sprz:
|
||||
if (element.actorofang)
|
||||
return element.actorofang->s().z;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -39,22 +39,21 @@ typedef
|
|||
struct List *Prev;
|
||||
} LISTHEAD, *LIST;
|
||||
|
||||
#define FIRST(list) (list->Next)
|
||||
#define LAST(list) (list->Prev)
|
||||
inline void INITLIST(void* listp)
|
||||
{
|
||||
LIST list = (LIST)listp;
|
||||
list->Prev = list->Next = list;
|
||||
}
|
||||
|
||||
|
||||
#define INITLIST(list) ( ((LIST) list)->Prev = ((LIST) list)->Next = (LIST) list)
|
||||
|
||||
|
||||
#define INSERT(list, nodep) ( ((LIST) nodep)->Prev = (LIST) list, \
|
||||
((LIST) nodep)->Next = ((LIST) list)->Next, \
|
||||
((LIST) list)->Next = (LIST) nodep, \
|
||||
((LIST) nodep)->Next->Prev = (LIST) nodep)
|
||||
|
||||
#define INSERT_TAIL(list, nodep) ( ((LIST) nodep)->Next = (LIST) list, \
|
||||
((LIST) nodep)->Prev = ((LIST) list)->Prev, \
|
||||
((LIST) list)->Prev = (LIST) nodep, \
|
||||
((LIST) nodep)->Prev->Next = (LIST) nodep)
|
||||
inline void INSERT(void* listp, void* nodepp)
|
||||
{
|
||||
LIST list = (LIST)listp;
|
||||
LIST nodep = (LIST)nodepp;
|
||||
nodep->Prev = list;
|
||||
nodep->Next = list->Next;
|
||||
list->Next = nodep;
|
||||
nodep->Next->Prev = nodep;
|
||||
}
|
||||
|
||||
inline void REMOVE(PANEL_SPRITEp nodep)
|
||||
{
|
||||
|
@ -62,11 +61,11 @@ inline void REMOVE(PANEL_SPRITEp nodep)
|
|||
nodep->Next->Prev = nodep->Prev;
|
||||
}
|
||||
|
||||
#define TRAVERSE(l, o, n) ASSERT(((LIST)l)->Next && ((LIST)l)->Prev); for (o = (decltype(o))(((LIST)l)->Next); \
|
||||
n = o->Next, (LIST) o != (LIST) l; \
|
||||
o = n)
|
||||
|
||||
#define EMPTY(list) (((LIST) list)->Next == (LIST) list)
|
||||
inline bool EMPTY(void* listp)
|
||||
{
|
||||
LIST list = (LIST)listp;
|
||||
return list->Next == list;
|
||||
}
|
||||
|
||||
END_SW_NS
|
||||
|
||||
|
|
|
@ -116,9 +116,10 @@ void pNullAnimator(PANEL_SPRITEp)
|
|||
|
||||
PANEL_SPRITEp pFindMatchingSprite(PLAYERp pp, int x, int y, short pri)
|
||||
{
|
||||
PANEL_SPRITEp psp=nullptr, next;
|
||||
PANEL_SPRITEp next;
|
||||
|
||||
TRAVERSE(&pp->PanelSpriteList, psp, next)
|
||||
auto list = pp->GetPanelSpriteList();
|
||||
for (auto psp = list->Next; next = psp->Next, psp != list; psp = next)
|
||||
{
|
||||
// early out
|
||||
if (psp->priority > pri)
|
||||
|
@ -135,9 +136,10 @@ PANEL_SPRITEp pFindMatchingSprite(PLAYERp pp, int x, int y, short pri)
|
|||
|
||||
PANEL_SPRITEp pFindMatchingSpriteID(PLAYERp pp, short id, int x, int y, short pri)
|
||||
{
|
||||
PANEL_SPRITEp psp=nullptr, next;
|
||||
PANEL_SPRITEp next;
|
||||
|
||||
TRAVERSE(&pp->PanelSpriteList, psp, next)
|
||||
auto list = pp->GetPanelSpriteList();
|
||||
for (auto psp = list->Next; next = psp->Next, psp != list; psp = next)
|
||||
{
|
||||
// early out
|
||||
if (psp->priority > pri)
|
||||
|
@ -154,11 +156,12 @@ PANEL_SPRITEp pFindMatchingSpriteID(PLAYERp pp, short id, int x, int y, short pr
|
|||
|
||||
bool pKillScreenSpiteIDs(PLAYERp pp, short id)
|
||||
{
|
||||
PANEL_SPRITEp psp=nullptr, next;
|
||||
PANEL_SPRITEp next;
|
||||
bool found = false;
|
||||
|
||||
// Kill ALL sprites with the correct id
|
||||
TRAVERSE(&pp->PanelSpriteList, psp, next)
|
||||
auto list = pp->GetPanelSpriteList();
|
||||
for (auto psp = list->Next; next = psp->Next, psp != list; psp = next)
|
||||
{
|
||||
if (psp->ID == id)
|
||||
{
|
||||
|
@ -327,7 +330,6 @@ void PlayerUpdateHealth(PLAYERp pp, short value)
|
|||
|
||||
void PlayerUpdateAmmo(PLAYERp pp, short UpdateWeaponNum, short value)
|
||||
{
|
||||
USERp u = pp->Actor()->u();
|
||||
short x,y;
|
||||
short WeaponNum;
|
||||
|
||||
|
@ -924,7 +926,8 @@ void RetractCurWpn(PLAYERp pp)
|
|||
else
|
||||
{
|
||||
// check for any outstanding siblings that need to go away also
|
||||
TRAVERSE(&pp->PanelSpriteList, cur, nxt)
|
||||
auto list = pp->GetPanelSpriteList();
|
||||
for (auto cur = list->Next; nxt = cur->Next, cur != list; cur = nxt)
|
||||
{
|
||||
if (cur->sibling && cur->sibling == pp->CurWpn)
|
||||
{
|
||||
|
@ -6410,7 +6413,8 @@ InsertPanelSprite(PLAYERp pp, PANEL_SPRITEp psp)
|
|||
}
|
||||
|
||||
// search for first pri in list thats less than the new pri
|
||||
TRAVERSE(&pp->PanelSpriteList, cur, nxt)
|
||||
auto list = pp->GetPanelSpriteList();
|
||||
for (auto cur = list->Next; nxt = cur->Next, cur != list; cur = nxt)
|
||||
{
|
||||
// if the next pointer is the end of the list, insert it
|
||||
if ((LIST) cur->Next == (LIST) &pp->PanelSpriteList)
|
||||
|
@ -6568,7 +6572,7 @@ void
|
|||
pDisplaySprites(PLAYERp pp, double smoothratio)
|
||||
{
|
||||
USERp u = pp->Actor()->u();
|
||||
PANEL_SPRITEp psp=nullptr, next=nullptr;
|
||||
PANEL_SPRITEp next=nullptr;
|
||||
short shade, picnum, overlay_shade = 0;
|
||||
double x, y;
|
||||
unsigned i;
|
||||
|
@ -6580,7 +6584,8 @@ pDisplaySprites(PLAYERp pp, double smoothratio)
|
|||
double const look_anghalf = pp->angle.look_anghalf(smoothratio);
|
||||
double const looking_arc = pp->angle.looking_arc(smoothratio);
|
||||
|
||||
TRAVERSE(&pp->PanelSpriteList, psp, next)
|
||||
auto list = pp->GetPanelSpriteList();
|
||||
for (auto psp = list->Next; next = psp->Next, psp != list; psp = next)
|
||||
{
|
||||
ang = psp->rotate_ang;
|
||||
shade = 0;
|
||||
|
@ -6856,9 +6861,10 @@ pDisplaySprites(PLAYERp pp, double smoothratio)
|
|||
void
|
||||
pSpriteControl(PLAYERp pp)
|
||||
{
|
||||
PANEL_SPRITEp psp=nullptr, next=nullptr;
|
||||
PANEL_SPRITEp next=nullptr;
|
||||
|
||||
TRAVERSE(&pp->PanelSpriteList, psp, next)
|
||||
auto list = pp->GetPanelSpriteList();
|
||||
for (auto psp = list->Next; next = psp->Next, psp != list; psp = next)
|
||||
{
|
||||
// reminder - if these give an assertion look for pKillSprites
|
||||
// somewhere else other than by themselves
|
||||
|
|
|
@ -2192,7 +2192,7 @@ OperateContinuousTrigger(PLAYERp pp)
|
|||
if (pp->cursectnum < 0)
|
||||
return;
|
||||
|
||||
switch (sector[pp->cursectnum].lotag)
|
||||
switch (sector[pp->cursectnum].lotag)
|
||||
{
|
||||
case TAG_TRIGGER_MISSILE_TRAP:
|
||||
{
|
||||
|
|
|
@ -1861,11 +1861,11 @@ SpriteSetup(void)
|
|||
PicAnimOff(PLAYER_NINJA_RUN_R0);
|
||||
|
||||
// Clear Sprite Extension structure
|
||||
memset(&SectUser[0], 0, sizeof(SectUser));
|
||||
|
||||
// Clear all extra bits - they are set by sprites
|
||||
for (i = 0; i < numsectors; i++)
|
||||
{
|
||||
SectUser[i].Clear();
|
||||
sector[i].extra = 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue