diff --git a/lzma/C/LzmaEnc.c b/lzma/C/LzmaEnc.c index da39520c65..870399d35a 100644 --- a/lzma/C/LzmaEnc.c +++ b/lzma/C/LzmaEnc.c @@ -2086,7 +2086,7 @@ void LzmaEnc_Finish(CLzmaEncHandle pp) if (p->mtMode) MatchFinderMt_ReleaseStream(&p->matchFinderMt); #else - pp = pp; + (void)pp; #endif } diff --git a/src/actor.h b/src/actor.h index b7a8614a74..78c82066c1 100644 --- a/src/actor.h +++ b/src/actor.h @@ -845,7 +845,8 @@ public: DWORD fillcolor; // Color to draw when STYLE_Shaded // interaction info - fixed_t pitch, roll; + fixed_t pitch; + angle_t roll; // This was fixed_t before, which is probably wrong FBlockNode *BlockNode; // links in blocks (if needed) struct sector_t *Sector; subsector_t * subsector; diff --git a/src/b_func.cpp b/src/b_func.cpp index 1c29c2cf63..2800c01c5d 100644 --- a/src/b_func.cpp +++ b/src/b_func.cpp @@ -123,7 +123,7 @@ bool DBot::Check_LOS (AActor *to, angle_t vangle) if (vangle == 0) return false; //Looker seems to be blind. - return (angle_t)abs (R_PointToAngle2 (player->mo->x, player->mo->y, to->x, to->y) - player->mo->angle) <= vangle/2; + return absangle(R_PointToAngle2 (player->mo->x, player->mo->y, to->x, to->y) - player->mo->angle) <= vangle/2; } //------------------------------------- @@ -210,7 +210,7 @@ void DBot::Dofire (ticcmd_t *cmd) { angle = an; //have to be somewhat precise. to avoid suicide. - if (abs (angle - player->mo->angle) < 12*ANGLE_1) + if (absangle(angle - player->mo->angle) < 12*ANGLE_1) { t_rocket = 9; no_fire = false; @@ -252,7 +252,7 @@ shootmissile: angle -= m; } - if (abs (angle - player->mo->angle) < 4*ANGLE_1) + if (absangle(angle - player->mo->angle) < 4*ANGLE_1) { increase = !increase; } diff --git a/src/d_net.cpp b/src/d_net.cpp index 9ab4b61799..bc5ccdba95 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -230,7 +230,7 @@ static struct TicSpecial specialsize = MAX(specialsize * 2, needed + 30); - DPrintf ("Expanding special size to %d\n", specialsize); + DPrintf ("Expanding special size to %zu\n", specialsize); for (i = 0; i < BACKUPTICS; i++) streams[i] = (BYTE *)M_Realloc (streams[i], specialsize); diff --git a/src/g_game.cpp b/src/g_game.cpp index 007604a1cb..c442ee8751 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1020,11 +1020,11 @@ void G_Ticker () { if (playeringame[i]) { - if ((players[i].playerstate == PST_GONE)) + if (players[i].playerstate == PST_GONE) { G_DoPlayerPop(i); } - if ((players[i].playerstate == PST_REBORN || players[i].playerstate == PST_ENTER)) + if (players[i].playerstate == PST_REBORN || players[i].playerstate == PST_ENTER) { G_DoReborn(i, false); } diff --git a/src/g_hexen/a_dragon.cpp b/src/g_hexen/a_dragon.cpp index 22c92b4d72..fdf2428afe 100644 --- a/src/g_hexen/a_dragon.cpp +++ b/src/g_hexen/a_dragon.cpp @@ -78,8 +78,8 @@ static void DragonSeek (AActor *actor, angle_t thresh, angle_t turnMax) if (target->flags&MF_SHOOTABLE && pr_dragonseek() < 64) { // attack the destination mobj if it's attackable AActor *oldTarget; - - if (abs(actor->angle-R_PointToAngle2(actor->x, actor->y, + + if (absangle(actor->angle-R_PointToAngle2(actor->x, actor->y, target->x, target->y)) < ANGLE_45/2) { oldTarget = actor->target; @@ -121,9 +121,9 @@ static void DragonSeek (AActor *actor, angle_t thresh, angle_t turnMax) } angleToSpot = R_PointToAngle2(actor->x, actor->y, mo->x, mo->y); - if ((angle_t)abs(angleToSpot-angleToTarget) < bestAngle) + if (absangle(angleToSpot-angleToTarget) < bestAngle) { - bestAngle = abs(angleToSpot-angleToTarget); + bestAngle = absangle(angleToSpot-angleToTarget); bestActor = mo; } } @@ -198,14 +198,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonFlight) } angle = R_PointToAngle2(self->x, self->y, self->target->x, self->target->y); - if (abs(self->angle-angle) < ANGLE_45/2 && self->CheckMeleeRange()) + if (absangle(self->angle-angle) < ANGLE_45/2 && self->CheckMeleeRange()) { int damage = pr_dragonflight.HitDice (8); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self); S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); } - else if (abs(self->angle-angle) <= ANGLE_1*20) + else if (absangle(self->angle-angle) <= ANGLE_1*20) { self->SetState (self->MissileState); S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); diff --git a/src/g_hexen/a_heresiarch.cpp b/src/g_hexen/a_heresiarch.cpp index 15e6da9c18..9ca0a70e80 100644 --- a/src/g_hexen/a_heresiarch.cpp +++ b/src/g_hexen/a_heresiarch.cpp @@ -314,7 +314,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcBallOrbit) case SORC_STOPPING: // Balls stopping if ((parent->StopBall == RUNTIME_TYPE(actor)) && (parent->args[1] > SORCBALL_SPEED_ROTATIONS) && - (abs(angle - (parent->angle>>ANGLETOFINESHIFT)) < (30<<5))) + (absangle(angle - (parent->angle>>ANGLETOFINESHIFT)) < (30<<5))) { // Can stop now actor->target->args[3] = SORC_FIRESPELL; diff --git a/src/g_hexen/a_hexenspecialdecs.cpp b/src/g_hexen/a_hexenspecialdecs.cpp index 5485d8d1f2..9d0c098fe4 100644 --- a/src/g_hexen/a_hexenspecialdecs.cpp +++ b/src/g_hexen/a_hexenspecialdecs.cpp @@ -109,14 +109,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_PotteryCheck) if (playeringame[i]) { AActor *pmo = players[i].mo; - if (P_CheckSight (self, pmo) && (abs (R_PointToAngle2 (pmo->x, + if (P_CheckSight (self, pmo) && (absangle(R_PointToAngle2 (pmo->x, pmo->y, self->x, self->y) - pmo->angle) <= ANGLE_45)) { // Previous state (pottery bit waiting state) self->SetState (self->state - 1); return; } } - } + } } // Lynched corpse (no heart) ------------------------------------------------ diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 24a8506148..55b49b65ed 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2754,7 +2754,7 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch, a // 0 means no limit. Also, if we turn in a single step anyways, no need to go through the algorithms. // It also means that there is no need to check for going past the other. - if (max_turn && (max_turn < (angle_t)abs(self->angle - other_angle))) + if (max_turn && (max_turn < absangle(self->angle - other_angle))) { if (self->angle > other_angle) { diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 0137ce9e09..608ecb4072 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -2951,7 +2951,7 @@ bool AActor::AdjustReflectionAngle (AActor *thing, angle_t &angle) if (thing->flags4&MF4_SHIELDREFLECT) { // Shield reflection (from the Centaur - if (abs (angle - thing->angle)>>24 > 45) + if (absangle(angle - thing->angle)>>24 > 45) return true; // Let missile explode if (thing->IsKindOf (RUNTIME_CLASS(AHolySpirit))) // shouldn't this be handled by another flag??? diff --git a/src/p_setup.cpp b/src/p_setup.cpp index c0810cc291..e374f0249e 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -1311,7 +1311,7 @@ void P_LoadSegs (MapData * map) ptp_angle = R_PointToAngle2 (li->v1->x, li->v1->y, li->v2->x, li->v2->y); dis = 0; - delta_angle = (abs(ptp_angle-(segangle<<16))>>ANGLETOFINESHIFT)*360/FINEANGLES; + delta_angle = (absangle(ptp_angle-(segangle<<16))>>ANGLETOFINESHIFT)*360/FINEANGLES; if (delta_angle != 0) { diff --git a/src/r_data/colormaps.h b/src/r_data/colormaps.h index 81f9080e0c..f3a2ad9ff5 100644 --- a/src/r_data/colormaps.h +++ b/src/r_data/colormaps.h @@ -56,13 +56,13 @@ extern TArray SpecialColormaps; // some utility functions to store special colormaps in powerup blends #define SPECIALCOLORMAP_MASK 0x00b60000 -inline int MakeSpecialColormap(int index) +inline uint32 MakeSpecialColormap(int index) { assert(index >= 0 && index < 65536); return index | SPECIALCOLORMAP_MASK; } -inline bool IsSpecialColormap(int map) +inline bool IsSpecialColormap(uint32 map) { return (map & 0xFFFF0000) == SPECIALCOLORMAP_MASK; } @@ -86,4 +86,4 @@ extern bool NormalLightHasFixedLights; FDynamicColormap *GetSpecialLights (PalEntry lightcolor, PalEntry fadecolor, int desaturate); -#endif \ No newline at end of file +#endif diff --git a/src/tables.h b/src/tables.h index 04a66376e6..dbe9af0c17 100644 --- a/src/tables.h +++ b/src/tables.h @@ -36,6 +36,7 @@ #ifndef __TABLES_H__ #define __TABLES_H__ +#include #include #include "basictypes.h" @@ -92,14 +93,15 @@ extern fixed_t finetangent[FINEANGLES/2]; typedef uint32 angle_t; -// Avoid "ambiguous call to overloaded function" errors -// Only to be used when you have subtracted two angles. -#ifndef __GNUC__ -inline angle_t abs (angle_t ang) +// Previously seen all over the place, code like this: abs(ang1 - ang2) +// Clang warns (and is absolutely correct) that technically, this +// could be optimized away and do nothing: +// warning: taking the absolute value of unsigned type 'unsigned int' has no effect +// note: remove the call to 'abs' since unsigned values cannot be negative +inline angle_t absangle(angle_t a) { - return (angle_t)abs((SDWORD)ang); + return (angle_t)abs((int32)a); } -#endif // Effective size is 2049; // The +1 size is to handle the case when x==y diff --git a/tools/zipdir/zipdir.c b/tools/zipdir/zipdir.c index 1479952e09..db6a57e1ef 100644 --- a/tools/zipdir/zipdir.c +++ b/tools/zipdir/zipdir.c @@ -871,8 +871,8 @@ int append_to_zip(FILE *zip_file, file_sorted_t *filep, FILE *ozip, BYTE *odir) LocalFileHeader local; uLong crc; file_entry_t *file; - char *readbuf; - char *compbuf[2]; + Byte *readbuf; + Byte *compbuf[2]; unsigned int comp_len[2]; int offset[2]; int method[2]; @@ -937,7 +937,7 @@ int append_to_zip(FILE *zip_file, file_sorted_t *filep, FILE *ozip, BYTE *odir) if (odir != NULL && ozip != NULL) { CentralDirectoryEntry *dirent; - + dirent = find_file_in_zip(odir, filep->path_in_zip, len, crc, file->date, file->time); if (dirent != NULL) { @@ -1256,7 +1256,7 @@ int compress_lzma(Byte *out, unsigned int *outlen, const Byte *in, unsigned int int compress_bzip2(Byte *out, unsigned int *outlen, const Byte *in, unsigned int inlen) { - if (BZ_OK == BZ2_bzBuffToBuffCompress(out, outlen, (char *)in, inlen, 9, 0, 0)) + if (BZ_OK == BZ2_bzBuffToBuffCompress((char *)out, outlen, (char *)in, inlen, 9, 0, 0)) { return 0; } @@ -1525,7 +1525,7 @@ int copy_zip_file(FILE *zip, file_entry_t *file, FILE *ozip, CentralDirectoryEnt return 0; } // Check to be sure name matches. - if (strncmp(buf, (char *)(ent + 1), LittleShort(lfh.NameLength)) != 0) + if (strncmp((char *)buf, (char *)(ent + 1), LittleShort(lfh.NameLength)) != 0) { free(buf); return 0;