- Fix all GCC warnings in the game-side code.

* Most of these were due to mixed spaces/tabs playing nastiness with non-braced if/else statements.
This commit is contained in:
Mitchell Richters 2023-10-04 18:11:00 +11:00 committed by Christoph Oelckers
parent 084be1a45c
commit 526db7f8b0
21 changed files with 66 additions and 72 deletions

View file

@ -61,7 +61,8 @@ bool AllowedKillType(DBloodActor* actor)
{
if (!actor || actor->spr.statnum != kStatDude)
return false;
auto type = actor->GetType();
auto type = actor->GetType();
return type != kDudeBat && type != kDudeRat && type != kDudeInnocent && type != kDudeBurningInnocent;
}

View file

@ -4333,7 +4333,7 @@ bool condCheckPlayer(DBloodActor* aCond, int cmpOp, bool PUSH)
case 0: // check if this player is connected
if (!condCmp(pPlayer->pnum + 1, arg1, arg2, cmpOp) || pPlayer->GetActor() == nullptr) return false;
else if (PUSH) condPush(aCond, pPlayer->GetActor());
return (pPlayer->pnum >= 0);
return true;
case 1: return condCmp((gGameOptions.nGameType != 3) ? 0 : pPlayer->teamId + 1, arg1, arg2, cmpOp); // compare team
case 2: return (arg1 > 0 && arg1 < 8 && pPlayer->hasKey[arg1 - 1]);
case 3: return (arg1 > 0 && arg1 < 15 && pPlayer->hasWeapon[arg1 - 1]);

View file

@ -746,7 +746,7 @@ void checkdive(DDukeActor* transporter, DDukeActor* transported)
int onfloorz = transporter->temp_data[4];
Collision coll;
double ll = abs(transported->vel.Z), ll2;
double ll = abs(transported->vel.Z), ll2 = 0;
if (transported->vel.Z >= 0)
warpdir = 2;
else

View file

@ -54,7 +54,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
t = tsprites.get(j);
h = static_cast<DDukeActor*>(t->ownerActor);
if (!(h->flags2 & SFLAG2_FORCESECTORSHADE) && ((t->cstat & CSTAT_SPRITE_ALIGNMENT_WALL)) || (badguy(static_cast<DDukeActor*>(t->ownerActor)) && t->extra > 0) || t->statnum == STAT_PLAYER)
if ((!(h->flags2 & SFLAG2_FORCESECTORSHADE) && (t->cstat & CSTAT_SPRITE_ALIGNMENT_WALL)) || (badguy(static_cast<DDukeActor*>(t->ownerActor)) && t->extra > 0) || t->statnum == STAT_PLAYER)
{
if (h->sector()->shadedsector == 1 && h->spr.statnum != STAT_ACTOR)
{

View file

@ -49,7 +49,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
t = tsprites.get(j);
h = static_cast<DDukeActor*>(t->ownerActor);
if (!(h->flags2 & SFLAG2_FORCESECTORSHADE) && ((t->cstat & CSTAT_SPRITE_ALIGNMENT_WALL)) || badguy(static_cast<DDukeActor*>(t->ownerActor)) || t->statnum == STAT_PLAYER)
if ((!(h->flags2 & SFLAG2_FORCESECTORSHADE) && (t->cstat & CSTAT_SPRITE_ALIGNMENT_WALL)) || badguy(static_cast<DDukeActor*>(t->ownerActor)) || t->statnum == STAT_PLAYER)
{
if (h->sector()->shadedsector == 1 && h->spr.statnum != 1)
{

View file

@ -201,7 +201,7 @@ DDukeActor* aim(DDukeActor* actor, int abase, bool force, bool* b)
{
DAngle aang = mapangle(abase);
bool gotshrinker, gotfreezer;
bool gotshrinker = false, gotfreezer = false;
static const int aimstats[] = { STAT_PLAYER, STAT_DUMMYPLAYER, STAT_ACTOR, STAT_ZOMBIEACTOR };
DAngle a = actor->spr.Angles.Yaw;
@ -266,12 +266,7 @@ DDukeActor* aim(DDukeActor* actor, int abase, bool force, bool* b)
DDukeActor* aimed = nullptr;
// if(actor->isPlayer() && ps[actor->PlayerIndex()].aim_mode) return -1;
if (isRR())
{
gotshrinker = false;
gotfreezer = false;
}
else if (actor->isPlayer())
if (!isRR() && actor->isPlayer())
{
const auto plr = getPlayer(actor->PlayerIndex());

View file

@ -48,7 +48,7 @@ BEGIN_DUKE_NS
void prelevel_d(int g, TArray<DDukeActor*>& actors)
{
int j, lotaglist;
unsigned j;
TArray<short> lotags;
prelevel_common(g);
@ -85,7 +85,6 @@ void prelevel_d(int g, TArray<DDukeActor*>& actors)
spriteinit(actor, actors);
}
}
lotaglist = 0;
it.Reset(STAT_DEFAULT);
while (auto actor = it.Next())

View file

@ -43,8 +43,7 @@ BEGIN_DUKE_NS
void prelevel_r(int g, TArray<DDukeActor*>& actors)
{
DDukePlayer* p;
int j;
int lotaglist;
unsigned j;
TArray<short> lotags;
int speed = 0;
int dist;
@ -235,8 +234,6 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
}
}
lotaglist = 0;
it.Reset(STAT_DEFAULT);
while (auto ac = it.Next())
{

View file

@ -97,10 +97,10 @@ DExhumedActor* BuildAnim(DExhumedActor* pActor, const FName seqFile, int seqInde
if (nFlag & 0x80)
pActor->spr.cstat |= CSTAT_SPRITE_TRANSLUCENT; // set transluscence
pActor->spr.pos = pos;
pActor->spr.pos = pos;
pActor->spr.cstat = 0;
pActor->clipdist = 2.5;
pActor->spr.scale = DVector2(nScale, nScale);
pActor->spr.scale = DVector2(nScale, nScale);
setvalidpic(pActor);
pActor->spr.Angles.Yaw = nullAngle;
pActor->spr.xoffset = 0;

View file

@ -391,6 +391,7 @@ MOVEEND:
hitactor = coll.actor();
goto HITSPRITE;
}
break;
default:
if (coll.exbits)
goto HITSECT;

View file

@ -69,7 +69,7 @@ public:
Type& operator[](size_t index)
{
return DataList[index];
return DataList[std::min(index, (size_t)count-1)];
}
void Serialize(FSerializer& arc, const char* key)

View file

@ -301,7 +301,7 @@ static Collision CheckCloseRange(DExhumedPlayer* const pPlayer, DVector3& pos, s
if (sqrtNum >= ecx * ecx)
return c;
pos = hit.hitpos;
pos = hit.hitpos;
*ppSector = hit.hitSector;
if (hit.actor()) {

View file

@ -586,10 +586,10 @@ double PlotCourseToSprite(DExhumedActor* pActor1, DExhumedActor* pActor2)
{
if (pActor1 == nullptr || pActor2 == nullptr)
return -1;
auto vect = pActor2->spr.pos.XY() - pActor1->spr.pos.XY();
pActor1->spr.Angles.Yaw = vect.Angle();
return vect.Length();
auto vect = pActor2->spr.pos.XY() - pActor1->spr.pos.XY();
pActor1->spr.Angles.Yaw = vect.Angle();
return vect.Length();
}
@ -606,7 +606,7 @@ DExhumedActor* FindPlayer(DExhumedActor* pActor, int nDistance, bool dontengage)
if (nDistance < 0)
nDistance = 100;
auto pSector =pActor->sector();
auto pSector =pActor->sector();
nDistance <<= 4;
DExhumedActor* pPlayerActor = nullptr;

View file

@ -311,17 +311,17 @@ void RestartPlayer(DExhumedPlayer* const pPlayer)
if (pPlayer->nRun < 0)
pPlayer->nRun = runlist_AddRunRec(NewRun, pPlayer->pnum, 0xA0000);
if (!(currentLevel->gameflags & LEVEL_EX_MULTI))
{
RestoreMinAmmo(pPlayer);
}
else
{
ResetPlayerWeapons(pPlayer);
pPlayer->nMagic = 0;
}
if (!(currentLevel->gameflags & LEVEL_EX_MULTI))
{
RestoreMinAmmo(pPlayer);
}
else
{
ResetPlayerWeapons(pPlayer);
pPlayer->nMagic = 0;
}
BuildRa(pPlayer->pnum);
BuildRa(pPlayer->pnum);
}
//---------------------------------------------------------------------------
@ -775,7 +775,7 @@ static void doPickupWeapon(DExhumedPlayer* pPlayer, DExhumedActor* pPickupActor,
static void doPickupHealth(DExhumedPlayer* pPlayer, DExhumedActor* pPickupActor, int nItem, const int nAmount, int nSound)
{
if (!pPickupActor->spr.hitag || nAmount > 0 && pPlayer->nHealth >= 800)
if (!pPickupActor->spr.hitag || (nAmount > 0 && pPlayer->nHealth >= 800))
return;
int tintRed = 0, tintGreen = 16;

View file

@ -126,7 +126,7 @@ static TMap<FName, TArray<Seq>> FileSeqMap;
//
//---------------------------------------------------------------------------
const TArray<Seq>* const getFileSeqs(const FName nSeqFile)
TArray<Seq>* getFileSeqs(const FName nSeqFile)
{
return FileSeqMap.CheckKey(nSeqFile);
}

View file

@ -46,7 +46,7 @@ struct SeqFrame
return chunks.Size() ? chunks[0].tex : FNullTextureID();
}
const void playSound(DExhumedActor* const pActor) const
void playSound(DExhumedActor* const pActor) const
{
if (sound == -1)
return;
@ -84,9 +84,9 @@ void seq_PlotSequence(const int nSprite, const FName seqFile, const int16_t seqI
void seq_PlotArrowSequence(const int nSprite, const FName seqFile, const int16_t seqIndex, const int frameIndex);
void seq_DrawPilotLightSeq(double xPos, double yPos, double nAngle);
const TArray<Seq>* const getFileSeqs(const FName nSeqFile);
TArray<Seq>* getFileSeqs(const FName nSeqFile);
inline const Seq* const getSequence(const FName nSeqFile, const unsigned nSeqIndex = 0)
inline Seq* getSequence(const FName nSeqFile, const unsigned nSeqIndex = 0)
{
return getFileSeqs(nSeqFile)->Data(nSeqIndex);
}

View file

@ -412,7 +412,7 @@ void EXSoundEngine::CalcPosVel(int type, const void* source, const float pt[3],
{
if (pos != nullptr)
{
DVector3 campos;
DVector3 campos{};
if (nSnakeCam > -1)
{
Snake* pSnake = &SnakeList[nSnakeCam];
@ -487,8 +487,8 @@ void GameInterface::UpdateSounds()
const auto pActor = getPlayer(nLocalPlayer)->GetActor();
DVector3 pos;
DAngle ang;
DVector3 pos{};
DAngle ang{};
if (nSnakeCam > -1)
{
Snake* pSnake = &SnakeList[nSnakeCam];

View file

@ -2129,6 +2129,7 @@ struct ANIM
case ANIM_Spritez:
if (animactor == nullptr) return;
animactor->spr.pos.Z = value;
break;
case ANIM_Userz:
if (animactor == nullptr) return;
animactor->user.pos.Z = value;

View file

@ -299,7 +299,7 @@ void SpawnMidSplash(DSWActor* actor)
if (RANDOM_P2(1024) < 512)
actorNew->spr.cstat |= (CSTAT_SPRITE_XFLIP);
actor->user.change.Zero();
actor->user.change.Zero();
if (actor->user.Flags & (SPR_UNDERWATER))
actorNew->user.Flags |= (SPR_UNDERWATER);
@ -325,7 +325,7 @@ void SpawnFloorSplash(DSWActor* actor)
if (RANDOM_P2(1024) < 512)
actorNew->spr.cstat |= (CSTAT_SPRITE_XFLIP);
actor->user.change.Zero();
actor->user.change.Zero();
if (actor->user.Flags & (SPR_UNDERWATER))
actorNew->user.Flags |= (SPR_UNDERWATER);
@ -1370,7 +1370,7 @@ int InitChemBomb(DSWActor* actor)
if (SpriteInUnderwaterArea(actorNew))
actorNew->user.Flags |= (SPR_UNDERWATER);
actorNew->vel.Z = RandomZVel();
actorNew->vel.Z = RandomZVel();
actorNew->clipdist = 0;
if (actor->user.ID == MUSHROOM_CLOUD || actor->user.ID == 3121 || actor->user.ID == SUMO_RUN_R0) // 3121 == GRENADE_EXP

View file

@ -1744,7 +1744,7 @@ void DoPlayerSlide(DSWPlayer* pp)
if (pp->sop)
return;
pp->slide_vect *= PLAYER_SLIDE_FRICTION;
pp->slide_vect *= PLAYER_SLIDE_FRICTION;
if (abs(pp->slide_vect.X) < 0.05 && abs(pp->slide_vect.Y) < 0.05)
pp->slide_vect.Zero();
@ -2416,8 +2416,8 @@ void DoPlayerMoveVehicle(DSWPlayer* pp)
}
else
{
pp->vect += pp->cmd.ucmd.vel.XY() * INPUT_SCALE;
pp->vect *= TANK_FRICTION;
pp->vect += pp->cmd.ucmd.vel.XY() * INPUT_SCALE;
pp->vect *= TANK_FRICTION;
pp->vect = (pp->vect + (pp->ovect*1))/2;
}
@ -3081,8 +3081,8 @@ void DoPlayerClimb(DSWPlayer* pp)
if (Prediction)
return;
pp->vect += pp->cmd.ucmd.vel.XY() * INPUT_SCALE;
pp->vect *= PLAYER_CLIMB_FRICTION;
pp->vect += pp->cmd.ucmd.vel.XY() * INPUT_SCALE;
pp->vect *= PLAYER_CLIMB_FRICTION;
if (abs(pp->vect.X) < 0.05 && abs(pp->vect.Y) < 0.05)
pp->vect.X = pp->vect.Y = 0;
@ -4518,7 +4518,7 @@ void DoPlayerCurrent(DSWPlayer* pp)
if (!sectu)
return;
auto vect = sectu->angle.ToVector() / 256. * sectu->speed * synctics; // 16384 >> 4 - Beware of clipmove's odd format for vect!
auto vect = sectu->angle.ToVector() / 256. * sectu->speed * synctics; // 16384 >> 4 - Beware of clipmove's odd format for vect!
push_ret = pushmove(pp->GetActor()->spr.pos.XY(), pp->GetActor()->getOffsetZ(), &pp->cursector, pp->GetActor()->clipdist, pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER);
if (push_ret < 0)

View file

@ -3931,7 +3931,7 @@ int SpawnBlood(DSWActor* actor, DSWActor* weapActor, DAngle hit_angle, const DVe
actorNew->user.jump_speed += RandomRange(p->max_jspeed - p->min_jspeed);
actorNew->user.jump_speed = -actorNew->user.jump_speed;
UpdateChangeXY(actorNew);
UpdateChangeXY(actorNew);
// for FastShrap
actorNew->user.change.Z = (abs(actorNew->user.jump_speed*4) - RandomRange(abs(actorNew->user.jump_speed)*8)) * JUMP_FACTOR;
@ -9556,8 +9556,8 @@ int DoElectro(DSWActor* actor)
if (actor->user.Counter > 0)
MissileSeek(actor, 30, DAngle90/*, 3, 52, 2*/);
auto vec = actor->spr.Angles.Yaw.ToVector() * actor->vel.X;
double daz = actor->vel.Z;
auto vec = actor->spr.Angles.Yaw.ToVector() * actor->vel.X;
double daz = actor->vel.Z;
actor->user.coll = move_missile(actor, DVector3(vec, daz), CEILING_DIST, FLOOR_DIST, CLIPMASK_MISSILE, MISSILEMOVETICS);
@ -11251,7 +11251,7 @@ int DoRing(DSWActor* actor)
else
z = ActorZOfMiddle(own) + 30;
actor->spr.pos = DVector3(own->spr.pos.XY(), z);
actor->spr.pos = DVector3(own->spr.pos.XY(), z);
// go out until its time to come back in
if (actor->user.Counter2 == false)
@ -11607,7 +11607,7 @@ void InitVulcanBoulder(DSWActor* actor)
zvel_rand = 40;
}
UpdateChangeXY(actorNew);
UpdateChangeXY(actorNew);
actorNew->user.change.Z = -zvel -RandomRange(zvel_rand);
}
@ -12760,7 +12760,7 @@ int InitStar(DSWPlayer* pp)
zvel = actorNew->vel.Z;
}
UpdateChangeXY(actorNew);
UpdateChangeXY(actorNew);
actorNew->user.change.Z = zvel;
if (pp->Flags & (PF_DIVING) || SpriteInUnderwaterArea(actorNew))
@ -13276,7 +13276,7 @@ int InitRail(DSWPlayer* pp)
else
zvel = actorNew->vel.Z; // Let autoaiming set zvel now
UpdateChangeXY(actorNew);
UpdateChangeXY(actorNew);
actorNew->user.change.Z = zvel;
return 0;
@ -13349,7 +13349,7 @@ int InitZillaRail(DSWActor* actor)
else
zvel = actorNew->vel.Z; // Let autoaiming set zvel now
UpdateChangeXY(actorNew);
UpdateChangeXY(actorNew);
actorNew->user.change.Z = zvel;
return 0;
@ -13459,7 +13459,7 @@ int InitRocket(DSWPlayer* pp)
else
zvel = actorNew->vel.Z; // Let autoaiming set zvel now
UpdateChangeXY(actorNew);
UpdateChangeXY(actorNew);
actorNew->user.change.Z = zvel;
return 0;
@ -13563,7 +13563,7 @@ int InitBunnyRocket(DSWPlayer* pp)
else
zvel = actorNew->vel.Z; // Let autoaiming set zvel now
UpdateChangeXY(actorNew);
UpdateChangeXY(actorNew);
actorNew->user.change.Z = zvel;
actorNew->user.spal = actorNew->spr.pal = PALETTE_PLAYER1;
@ -13656,7 +13656,7 @@ int InitNuke(DSWPlayer* pp)
else
zvel = actorNew->vel.Z; // Let autoaiming set zvel now
UpdateChangeXY(actorNew);
UpdateChangeXY(actorNew);
actorNew->user.change.Z = zvel;
PlayerDamageSlide(pp, -40, pp->GetActor()->spr.Angles.Yaw + DAngle180); // Recoil slide
@ -13731,7 +13731,7 @@ int InitEnemyNuke(DSWActor* actor)
else
zvel = actorNew->vel.Z; // Let autoaiming set zvel now
UpdateChangeXY(actorNew);
UpdateChangeXY(actorNew);
actorNew->user.change.Z = zvel;
return 0;
@ -16626,7 +16626,7 @@ int InitEnemyMine(DSWActor* actor)
actorNew->spr.Angles.Yaw += DAngle90;
actorNew->user.change. Z = -5000 / 256.;
UpdateChangeXY(actorNew);
UpdateChangeXY(actorNew);
return 0;
}
@ -16722,7 +16722,7 @@ int InitFireball(DSWPlayer* pp)
actorNew->spr.Angles.Yaw -= mapangle(9);
}
UpdateChangeXY(actorNew);
UpdateChangeXY(actorNew);
actorNew->user.change.Z = zvel;
return 0;
@ -17321,7 +17321,7 @@ int SpawnSmokePuff(DSWActor* actor)
actorNew->spr.Angles.Yaw = RandomAngle();
actorNew->vel.X = RandomRangeF(2);
UpdateChangeXY(actorNew);
UpdateChangeXY(actorNew);
actorNew->vel.Z = 4 + RandomRangeF(4);
return false;
@ -17742,9 +17742,9 @@ int QueueFootPrint(DSWActor* actor)
if (TestDontStickSector(actor->sector()))
return -1; // Not on special sectors you don't
if (!isAwayFromWall(actor, 5.25))
return -1; // not if it goes ouzside the sector
if (!isAwayFromWall(actor, 5.25))
return -1; // not if it goes ouzside the sector
// So, are we like, done checking now!?
if (FloorBloodQueue[FloorBloodQueueHead] != nullptr)