diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 0962311d8..c0705d7d8 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1578,7 +1578,7 @@ static bool movefireball(DDukeActor* actor) spr->zvel = proj->zv; } } - spr->yrepeat = spr->xrepeat = (short)(s->xrepeat * siz); + spr->yrepeat = spr->xrepeat = (uint8_t)(s->xrepeat * siz); spr->cstat = s->cstat; spr->extra = 0; diff --git a/source/games/duke/src/actors_lava.cpp b/source/games/duke/src/actors_lava.cpp index 290b1932f..396269616 100644 --- a/source/games/duke/src/actors_lava.cpp +++ b/source/games/duke/src/actors_lava.cpp @@ -557,7 +557,7 @@ void thunder(void) struct player_struct* p; int r1, r2; short startwall, endwall, i, j; - unsigned char shade; + uint8_t shade; p = &ps[screenpeek]; @@ -612,10 +612,10 @@ void thunder(void) { startwall = sector[lightninsector[i]].wallptr; endwall = startwall + sector[lightninsector[i]].wallnum; - sector[lightninsector[i]].floorshade = lightninsectorshade[i]; - sector[lightninsector[i]].ceilingshade = lightninsectorshade[i]; + sector[lightninsector[i]].floorshade = (int8_t)lightninsectorshade[i]; + sector[lightninsector[i]].ceilingshade = (int8_t)lightninsectorshade[i]; for (j = startwall; j < endwall; j++) - wall[j].shade = lightninsectorshade[i]; + wall[j].shade = (int8_t)lightninsectorshade[i]; } } } diff --git a/source/games/duke/src/gamevar.cpp b/source/games/duke/src/gamevar.cpp index 56a5dfa99..68b73a236 100644 --- a/source/games/duke/src/gamevar.cpp +++ b/source/games/duke/src/gamevar.cpp @@ -122,10 +122,10 @@ int AddGameVar(const char* pszLabel, intptr_t lValue, unsigned dwFlags) if (aGameVars[i].dwFlags & GAMEVAR_FLAG_SYSTEM && !(dwFlags & (GAMEVAR_FLAG_PLONG | GAMEVAR_FLAG_PFUNC))) { // if existing is system, they only get to change default value.... - aGameVars[i].lValue = lValue; + aGameVars[i].lValue = (int)lValue; if (!(dwFlags & GAMEVAR_FLAG_NODEFAULT)) { - aGameVars[i].defaultValue = lValue; + aGameVars[i].defaultValue = (int)lValue; } } else @@ -138,11 +138,11 @@ int AddGameVar(const char* pszLabel, intptr_t lValue, unsigned dwFlags) } else { - aGameVars[i].lValue = lValue; + aGameVars[i].lValue = (int)lValue; } if (!(dwFlags & GAMEVAR_FLAG_NODEFAULT)) { - aGameVars[i].defaultValue = lValue; + aGameVars[i].defaultValue = (int)lValue; } } @@ -161,7 +161,7 @@ int AddGameVar(const char* pszLabel, intptr_t lValue, unsigned dwFlags) aGameVars[i].plArray.Resize(MAXPLAYERS); for (j = 0; j < MAXPLAYERS; j++) { - aGameVars[i].plArray[j] = lValue; + aGameVars[i].plArray[j] = (int)lValue; } } else if (aGameVars[i].dwFlags & GAMEVAR_FLAG_PERACTOR) @@ -169,7 +169,7 @@ int AddGameVar(const char* pszLabel, intptr_t lValue, unsigned dwFlags) aGameVars[i].plArray.Resize(MAXSPRITES); for (j = 0; j < MAXSPRITES; j++) { - aGameVars[i].plArray[j] = lValue; + aGameVars[i].plArray[j] = (int)lValue; } } return 1; diff --git a/source/games/duke/src/hudweapon_d.cpp b/source/games/duke/src/hudweapon_d.cpp index 8f7058736..b1b8ef20f 100644 --- a/source/games/duke/src/hudweapon_d.cpp +++ b/source/games/duke/src/hudweapon_d.cpp @@ -63,21 +63,20 @@ inline static void hud_drawpal(double x, double y, int tilenum, int shade, int o void displayloogie(player_struct* p) { - int i, a, y, z; + double a, y; + int z; double x; if (p->loogcnt == 0) return; y = (p->loogcnt << 2); - for (i = 0; i < p->numloogs; i++) + for (int i = 0; i < p->numloogs; i++) { - a = abs(bsinf((p->loogcnt + i) << 5, -5)); + a = fabs(bsinf((p->loogcnt + i) << 5, -5)); z = 4096 + ((p->loogcnt + i) << 9); x = -getavel(p->i) + bsinf((p->loogcnt + i) << 6, -10); - hud_drawsprite( - (p->loogiex[i] + x), (200 + p->loogiey[i] - y), z - (i << 8), 256 - a, - LOOGIE, 0, 0, 2); + hud_drawsprite((p->loogiex[i] + x), (200 + p->loogiey[i] - y), z - (i << 8), 256 - a, LOOGIE, 0, 0, 2); } } @@ -90,16 +89,16 @@ void displayloogie(player_struct* p) int animatefist(int gs, player_struct* p, double look_anghalf, double looking_arc, double plravel, int fistpal) { short fisti; - int fistzoom; + double fistzoom; double fistz; fisti = p->fist_incs; if (fisti > 32) fisti = 32; if (fisti <= 0) return 0; - fistzoom = 65536L - bcosf(fisti << 6, 2); - if (fistzoom > 90612L) - fistzoom = 90612L; + fistzoom = 65536 - bcosf(fisti << 6, 2); + if (fistzoom > 90612) + fistzoom = 90612; if (fistzoom < 40920) fistzoom = 40290; fistz = 194 + bsinf((6 + fisti) << 7, -9); @@ -107,7 +106,7 @@ int animatefist(int gs, player_struct* p, double look_anghalf, double looking_ar hud_drawsprite( (-fisti + 222 + plravel), (looking_arc + fistz), - fistzoom, 0, FIST, gs, fistpal, 2); + int(fistzoom), 0, FIST, gs, fistpal, 2); return 1; } @@ -323,12 +322,12 @@ void displayweapon_d(int snum, double smoothratio) looking_arc += 32 - (i >> 1); fistsign += i >> 1; } - cw = weapon_xoffset; + double owo = weapon_xoffset; weapon_xoffset += bsinf(fistsign, -10); hud_draw(weapon_xoffset + 250 - look_anghalf, looking_arc + 258 - fabs(bsinf(fistsign, -8)), FIST, shade, o); - weapon_xoffset = cw; + weapon_xoffset = owo; weapon_xoffset -= bsinf(fistsign, -10); hud_draw(weapon_xoffset + 40 - look_anghalf, looking_arc + 200 + fabs(bsinf(fistsign, -8)), diff --git a/source/games/duke/src/hudweapon_r.cpp b/source/games/duke/src/hudweapon_r.cpp index d04c09b18..6fd360121 100644 --- a/source/games/duke/src/hudweapon_r.cpp +++ b/source/games/duke/src/hudweapon_r.cpp @@ -298,10 +298,10 @@ void displayweapon_r(int snum, double smoothratio) looking_arc += 32 - (i >> 1); fistsign += i >> 1; } - cw = weapon_xoffset; + double owo = weapon_xoffset; weapon_xoffset += bsinf(fistsign, -10); hud_draw(weapon_xoffset + 250 - look_anghalf, looking_arc + 258 - abs(bsinf(fistsign, -8)), FIST, shade, o); - weapon_xoffset = cw; + weapon_xoffset = owo; weapon_xoffset -= bsinf(fistsign, -10); hud_draw(weapon_xoffset + 40 - look_anghalf, looking_arc + 200 + abs(bsinf(fistsign, -8)), FIST, shade, o | 4); } diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 856703d6d..bcafc4276 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -762,9 +762,9 @@ static void shootrpg(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, i if (isWorldTour()) // Twentieth Anniversary World Tour { float siz = actor->s->yrepeat / 80.0f; - xoffs *= siz; - yoffs *= siz; - aoffs *= siz; + xoffs = int(xoffs * siz); + yoffs = int(yoffs * siz); + aoffs = int(aoffs * siz); } spj->x += xoffs; diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 0c2befe90..80fd74852 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -65,16 +65,11 @@ void incur_damage_r(struct player_struct* p) switch (gut) { - double ddamage; case 1: - ddamage = damage; - ddamage *= 0.75; - damage = ddamage; + damage = damage * 3 / 4; break; case 2: - ddamage = damage; - ddamage *= 0.25; - damage = ddamage; + damage /= 4; break; } @@ -1695,7 +1690,7 @@ static void onMotorcycle(int snum, ESyncBits &actions) if (p->MotoSpeed != 0 && p->on_ground == 1) { if (!p->VBumpNow && (krand() & 3) == 2) - p->VBumpTarget = (p->MotoSpeed / 16.) * ((krand() & 7) - 4); + p->VBumpTarget = short((p->MotoSpeed / 16.) * ((krand() & 7) - 4)); if (p->vehTurnLeft || p->moto_drink < 0) { @@ -1750,7 +1745,7 @@ static void onMotorcycle(int snum, ESyncBits &actions) p->horizon.addadjustment(horiz - FixedToFloat(p->horizon.horiz.asq16())); } - int currSpeed = p->MotoSpeed; + int currSpeed = int(p->MotoSpeed); short velAdjustment; if (p->MotoSpeed >= 20 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight)) { @@ -1965,7 +1960,7 @@ static void onBoat(int snum, ESyncBits &actions) if (p->MotoSpeed != 0 && p->on_ground == 1) { if (!p->VBumpNow && (krand() & 15) == 14) - p->VBumpTarget = (p->MotoSpeed / 16.) * ((krand() & 3) - 2); + p->VBumpTarget = short((p->MotoSpeed / 16.) * ((krand() & 3) - 2)); if (p->vehTurnLeft && p->moto_drink < 0) { @@ -2020,7 +2015,7 @@ static void onBoat(int snum, ESyncBits &actions) if (p->MotoSpeed > 0 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight)) { - int currSpeed = p->MotoSpeed * 4.; + int currSpeed = int(p->MotoSpeed * 4.); short velAdjustment = p->vehTurnLeft ? -10 : 10; auto angAdjustment = (velAdjustment < 0 ? 350 : -350) << BAMBITS; @@ -2128,7 +2123,7 @@ static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int } else { - p->poszv += gs.gravity - 80 + (120 - p->MotoSpeed); + p->poszv += gs.gravity - 80 + int(120 - p->MotoSpeed); if (!S_CheckActorSoundPlaying(pact, 189) && !S_CheckActorSoundPlaying(pact, 190)) S_PlayActorSound(190, pact); } @@ -2464,8 +2459,8 @@ void onMotorcycleHit(int snum, DDukeActor* victim) if (numplayers == 1) { Collision coll; - movesprite_ex(victim, bcos(p->TiltStatus * 20 + p->angle.ang.asbuild(), -8), - bsin(p->TiltStatus * 20 + p->angle.ang.asbuild(), -8), s->zvel, CLIPMASK0, coll); + int ang = int(p->TiltStatus * 20 + p->angle.ang.asbuild()); + movesprite_ex(victim, bcos(ang, -8), bsin(ang, -8), s->zvel, CLIPMASK0, coll); } } else @@ -2526,8 +2521,8 @@ void onBoatHit(int snum, DDukeActor* victim) if (numplayers == 1) { Collision coll; - movesprite_ex(victim, bcos(p->TiltStatus * 20 + p->angle.ang.asbuild(), -9), - bsin(p->TiltStatus * 20 + p->angle.ang.asbuild(), -9), s->zvel, CLIPMASK0, coll); + int ang = int(p->TiltStatus * 20 + p->angle.ang.asbuild()); + movesprite_ex(victim, bcos(ang, -9), bsin(ang, -9), s->zvel, CLIPMASK0, coll); } } else diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index cb86ffc62..4d25e99bc 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -658,7 +658,7 @@ void prelevel_r(int g) deletesprite(i); if (spr->picnum == RRTILE34) { - sectorextra[spr->sectnum] = spr->lotag; + sectorextra[spr->sectnum] = uint8_t(spr->lotag); deletesprite(i); } } diff --git a/source/games/duke/src/sbar_r.cpp b/source/games/duke/src/sbar_r.cpp index 5de101c20..72d887140 100644 --- a/source/games/duke/src/sbar_r.cpp +++ b/source/games/duke/src/sbar_r.cpp @@ -248,7 +248,7 @@ public: unsigned icon = p->inven_icon; if (icon > 0) { - int x = 84.5; + int x = 84; DrawGraphic(tileGetTexture(INVENTORYBOX), 77, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); if (icon < ICON_MAX) DrawGraphic(tileGetTexture(item_icons[icon]), x, -15.375, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, -1, -1, scale, scale); @@ -279,13 +279,13 @@ public: y -= 4; DrawInventory(p, 0, y, DI_SCREEN_CENTER_BOTTOM); FullscreenHUD1(p, snum); - PrintLevelStats(scale * tileHeight(BIGALPHANUM) + 10); + PrintLevelStats(int(scale * tileHeight(BIGALPHANUM) + 10)); } else if (style == 2) { DrawInventory(p, 56, -20, DI_SCREEN_CENTER_BOTTOM); FullscreenHUD2(p); - PrintLevelStats(scale * tileHeight(HEALTHBOX) + 4); + PrintLevelStats(int(scale * tileHeight(HEALTHBOX) + 4)); } else { @@ -353,11 +353,11 @@ public: double left = (320 - tileWidth(BOTTOMSTATUSBAR) * scale) / 2; double top = 200 - h; - BeginStatusBar(320, 200, wh + h); + BeginStatusBar(320, 200, int(wh + h)); DrawInventory(p, 160, hud_size <= Hud_Stbar? 148 : 154, 0); if (hud_size <= Hud_Stbar) - DrawWeaponBar(p, top); + DrawWeaponBar(p, (int)top); if (hud_size == Hud_StbarOverlay) Set43ClipRect(); DrawGraphic(tileGetTexture(BOTTOMSTATUSBAR), left, top, DI_ITEM_LEFT_TOP, 1, -1, -1, scale, scale); diff --git a/source/games/duke/src/sounds.cpp b/source/games/duke/src/sounds.cpp index 9f890b316..3e1a61df1 100644 --- a/source/games/duke/src/sounds.cpp +++ b/source/games/duke/src/sounds.cpp @@ -196,7 +196,7 @@ static inline int S_GetPitch(int num) float S_ConvertPitch(int lpitch) { - return pow(2, lpitch / 1200.); // I hope I got this right that ASS uses a linear scale where 1200 is a full octave. + return powf(2, lpitch / 1200.f); // I hope I got this right that ASS uses a linear scale where 1200 is a full octave. } int S_GetUserFlags(int num) @@ -413,7 +413,7 @@ void GameInterface::UpdateSounds(void) if (c != nullptr) { - listener.angle = -ca * BAngRadian; // Build uses a period of 2048. + listener.angle = -float(ca * BAngRadian); // Build uses a period of 2048. listener.velocity.Zero(); listener.position = GetSoundPos(c); listener.underwater = false; @@ -827,7 +827,7 @@ void S_ParseDeveloperCommentary() } } sc.MustGetStringName(";"); - if (Commentaries.Size() <= num) Commentaries.Resize(num + 1); + if (Commentaries.Size() <= (unsigned)num) Commentaries.Resize(num + 1); Commentaries[num] = std::move(path); } //sc.MustGetStringName(";"); @@ -849,7 +849,7 @@ void StopCommentary() bool StartCommentary(int tag, DDukeActor* actor) { - if (wt_commentary && Commentaries.Size() > tag && Commentaries[tag].IsNotEmpty()) + if (wt_commentary && Commentaries.Size() > (unsigned)tag && Commentaries[tag].IsNotEmpty()) { FSoundID id = soundEngine->FindSound(Commentaries[tag]); if (id == 0) diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 9dbbbc151..ea8399dfd 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -50,7 +50,7 @@ struct weaponhit floorz = ceilingz = lastvx = lastvy = aflags = saved_ammo = 0; memset(temp_data, 0, sizeof(temp_data)); } - int GetIndex() const { return this - array(); } + int GetIndex() const { return int(this - array()); } // Wrapper around some ugliness. The 'owner' field gets abused by some actors, so better wrap its real use in access functions to keep things in order. inline weaponhit* GetOwner()