From 98e2fecd37834c238b666fa50bc2e0f8ca6f021f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 12 Oct 2022 19:00:43 +0200 Subject: [PATCH] - another bunch of type conversion warnings fixed. the ones in the findplayer functions are not critical in singleplayer. --- source/common/utility/vectors.h | 2 +- source/games/blood/src/aibeast.cpp | 4 ++-- source/games/blood/src/gib.cpp | 6 +++--- source/games/blood/src/nnexts.cpp | 4 ++-- source/games/blood/src/sectorfx.cpp | 8 ++++---- source/games/duke/src/ccmds.cpp | 2 +- source/games/duke/src/player_d.cpp | 4 ++-- source/games/duke/src/player_r.cpp | 4 ++-- source/games/duke/src/player_w.cpp | 2 +- source/games/duke/src/render.cpp | 2 +- source/games/duke/src/sectors.cpp | 6 ++---- source/games/duke/src/sounds.cpp | 2 +- source/games/duke/src/spawn.cpp | 4 ++-- source/games/exhumed/src/lighting.cpp | 2 +- source/games/exhumed/src/move.cpp | 4 ++-- source/games/exhumed/src/player.cpp | 2 +- source/games/sw/src/track.cpp | 2 +- 17 files changed, 29 insertions(+), 31 deletions(-) diff --git a/source/common/utility/vectors.h b/source/common/utility/vectors.h index 3f2423e2c..b4c4152a8 100644 --- a/source/common/utility/vectors.h +++ b/source/common/utility/vectors.h @@ -1281,7 +1281,7 @@ public: return TAngle(f * (90. / 0x40000000)); } - static constexpr TAngle fromBuild(int bang) + static constexpr TAngle fromBuild(double bang) { return TAngle(bang * (90. / 512)); } diff --git a/source/games/blood/src/aibeast.cpp b/source/games/blood/src/aibeast.cpp index 8d71f8c87..c80d15a9f 100644 --- a/source/games/blood/src/aibeast.cpp +++ b/source/games/blood/src/aibeast.cpp @@ -118,7 +118,7 @@ void StompSeqCallback(int, DBloodActor* actor) if (nDist2 <= 0) nDamage = nBaseDamage + nBaseDamage2; else - nDamage = nBaseDamage + nBaseDamage2 * ((nDist - nDist2) / nDist); + nDamage = nBaseDamage + int(nBaseDamage2 * ((nDist - nDist2) / nDist)); if (actor2->IsPlayerActor()) gPlayer[actor2->spr.type - kDudePlayer1].quakeEffect += nDamage * 4; actDamageSprite(actor, actor2, kDamageFall, nDamage << 4); @@ -145,7 +145,7 @@ void StompSeqCallback(int, DBloodActor* actor) if (nDist2 <= 0) nDamage = nBaseDamage + nBaseDamage2; else - nDamage = nBaseDamage + nBaseDamage2 * ((nDist - nDist2) / nDist); + nDamage = nBaseDamage + int(nBaseDamage2 * ((nDist - nDist2) / nDist)); if (actor2->IsPlayerActor()) gPlayer[actor2->spr.type - kDudePlayer1].quakeEffect += nDamage * 4; diff --git a/source/games/blood/src/gib.cpp b/source/games/blood/src/gib.cpp index 8051bcde6..4e87a511e 100644 --- a/source/games/blood/src/gib.cpp +++ b/source/games/blood/src/gib.cpp @@ -461,9 +461,9 @@ void GibFX(walltype* pWall, GIBFX* pGFX, double ceilZ, const DVector3& spread, D } else { - pGib->vel.X = Random2F((pVel->X * 17179869184.) / 120); - pGib->vel.Y = Random2F((pVel->Y * 17179869184.) / 120); - pGib->vel.Z = -Random2F((pVel->Z * 17179869184.) / 120); + pGib->vel.X = Random2F(int((pVel->X * 17179869184.) / 120)); + pGib->vel.Y = Random2F(int((pVel->Y * 17179869184.) / 120)); + pGib->vel.Z = -Random2F(int((pVel->Z * 17179869184.) / 120)); } } } diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index bae9ef2b7..e96daf597 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -2530,7 +2530,7 @@ void usePropertiesChanger(DBloodActor* sourceactor, int objType, sectortype* pSe pWall->allocX(); break; case 2: - pWall->sectorp()->slopewallofs = max(pWall - pWall->sectorp()->firstWall(), 0); + pWall->sectorp()->slopewallofs = max(int(pWall - pWall->sectorp()->firstWall()), 0); break; } } @@ -6857,7 +6857,7 @@ void useSectorLightChanger(DBloodActor* sourceactor, sectortype* pSector) if (relative) pXSector->amplitude = ClipRange(pXSector->amplitude + sourceactor->xspr.data2, -127, 127); else - pXSector->amplitude = sourceactor->xspr.data2; + pXSector->amplitude = (int8_t)sourceactor->xspr.data2; } if (valueIsBetween(sourceactor->xspr.data3, -1, 32767)) diff --git a/source/games/blood/src/sectorfx.cpp b/source/games/blood/src/sectorfx.cpp index a6d794805..666ea39f8 100644 --- a/source/games/blood/src/sectorfx.cpp +++ b/source/games/blood/src/sectorfx.cpp @@ -291,8 +291,8 @@ void DoSectorPanning(void) int yBits = tileHeight(nTile) >> int((pSector->floorstat & CSTAT_SECTOR_TEXHALF) != 0); double px = angle.Cos() * (speed << 2) / xBits; double py = angle.Sin() * (speed << 2) / xBits; - pSector->addfloorxpan(px * (1.f / 256)); - pSector->addfloorypan(-py * (1.f / 256)); + pSector->addfloorxpan((float)px * (1.f / 256)); + pSector->addfloorypan(-(float)py * (1.f / 256)); } if (pXSector->panCeiling) // Ceiling { @@ -303,8 +303,8 @@ void DoSectorPanning(void) int yBits = tileHeight(nTile) >> int((pSector->ceilingstat & CSTAT_SECTOR_TEXHALF) != 0); double px = angle.Cos() * (speed << 2) / xBits; double py = angle.Sin() * (speed << 2) / xBits; - pSector->addceilingxpan(px * (1.f / 256)); - pSector->addceilingypan(-py * (1.f / 256)); + pSector->addceilingxpan((float)px * (1.f / 256)); + pSector->addceilingypan(-(float)py * (1.f / 256)); } } } diff --git a/source/games/duke/src/ccmds.cpp b/source/games/duke/src/ccmds.cpp index 710aa82a4..91412d285 100644 --- a/source/games/duke/src/ccmds.cpp +++ b/source/games/duke/src/ccmds.cpp @@ -67,7 +67,7 @@ static int ccmd_spawn(CCmdFuncPtr parm) ang = DAngle::fromDeg(atoi(parm->parms[3])); set |= 4; [[fallthrough]]; case 3: // cstat - cstat = ESpriteFlags::FromInt(atol(parm->parms[2])); set |= 2; + cstat = ESpriteFlags::FromInt(atoi(parm->parms[2])); set |= 2; [[fallthrough]]; case 2: // pal pal = (uint8_t)atol(parm->parms[1]); set |= 1; diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 7a4ba5a23..2f8f85c47 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -749,7 +749,7 @@ static void shootrpg(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int atw if (isWorldTour()) // Twentieth Anniversary World Tour { - float siz = actor->spr.scale.Y * 0.8; + double siz = actor->spr.scale.Y * 0.8; spawnofs *= siz; aoffs *= siz; } @@ -2820,7 +2820,7 @@ void processinput_d(int snum) if (p->GetActor()->spr.scale.X < 0.625 && p->jetpack_on == 0) { p->ofistsign = p->fistsign; - p->fistsign += p->GetActor()->vel.X * 16; + p->fistsign += int(p->GetActor()->vel.X * 16); } if (p->transporter_hold > 0) diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 6ba0b5a2c..b7f1da35e 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -2721,7 +2721,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp) spawned->spr.pos.Z += 8; } - int hd = hits(p->GetActor()); + double hd = hits(p->GetActor()); if (hd < 32) { spawned->spr.angle += DAngle180; @@ -3498,7 +3498,7 @@ void processinput_r(int snum) if (p->GetActor()->spr.scale.X < 0.125 && p->jetpack_on == 0) { p->ofistsign = p->fistsign; - p->fistsign += p->GetActor()->vel.X * 16; + p->fistsign += int(p->GetActor()->vel.X * 16); } if (p->transporter_hold > 0) diff --git a/source/games/duke/src/player_w.cpp b/source/games/duke/src/player_w.cpp index cbf7518fd..25bad7f27 100644 --- a/source/games/duke/src/player_w.cpp +++ b/source/games/duke/src/player_w.cpp @@ -361,7 +361,7 @@ void operateweapon_ww(int snum, ESyncBits actions) spawned->spr.pos.Z += 8; } - int hd = hits(p->GetActor()); + double hd = hits(p->GetActor()); if (hd < 32) { spawned->spr.angle += DAngle180; diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index 464b6ae88..09a15d155 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -238,7 +238,7 @@ void displayrooms(int snum, double interpfrac, bool sceneonly) setgamepalette(BASEPAL); - float fov = r_fov; + float fov = (float)r_fov; auto sect = p->cursector; DDukeActor* viewer; diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index 005cc9b32..ea68dabbf 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -222,7 +222,6 @@ bool isanearoperator(int lotag) int findplayer(const DDukeActor* actor, double* d) { int j, closest_player; - int x; const auto s = actor->spr.pos; if (ud.multimode < 2) @@ -236,7 +235,7 @@ int findplayer(const DDukeActor* actor, double* d) for (j = connecthead; j >= 0; j = connectpoint2[j]) { - x = (ps[j].opos - s).plusZ(28).Sum(); + double x = (ps[j].opos - s).plusZ(28).Sum(); if (x < closest && ps[j].GetActor()->spr.extra > 0) { closest_player = j; @@ -257,7 +256,6 @@ int findplayer(const DDukeActor* actor, double* d) int findotherplayer(int p, double* d) { int j, closest_player; - int x; double closest = 0x7fffffff; closest_player = p; @@ -265,7 +263,7 @@ int findotherplayer(int p, double* d) for (j = connecthead; j >= 0; j = connectpoint2[j]) if (p != j && ps[j].GetActor()->spr.extra > 0) { - x = (ps[j].opos - ps[p].pos).Sum(); + double x = (ps[j].opos - ps[p].pos).Sum(); if (x < closest) { diff --git a/source/games/duke/src/sounds.cpp b/source/games/duke/src/sounds.cpp index d4f31fc24..663b12889 100644 --- a/source/games/duke/src/sounds.cpp +++ b/source/games/duke/src/sounds.cpp @@ -371,7 +371,7 @@ void DukeSoundEngine::CalcPosVel(int type, const void* source, const float pt[3] } if ((chanflags & CHANF_LISTENERZ) && type != SOURCE_None) { - pos->Y = campos.Z / 256.f; + pos->Y = (float)campos.Z / 256.f; } } } diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 6c5f95443..63a288744 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -1010,7 +1010,7 @@ void spawneffector(DDukeActor* actor, TArray* actors) void lotsofglass(DDukeActor *actor, walltype* wal, int n) { - int j, z; + int j; sectortype* sect = nullptr; if (wal == nullptr) @@ -1041,7 +1041,7 @@ void lotsofglass(DDukeActor *actor, walltype* wal, int n) updatesector(DVector3(pos, sect->floorz), §); if (sect) { - z = sect->floorz - krandf(abs(sect->ceilingz - sect->floorz)); + double z = sect->floorz - krandf(abs(sect->ceilingz - sect->floorz)); if (fabs(z) > 32) z = actor->spr.pos.Z - 32 + krandf(64); DAngle angl = actor->spr.angle - DAngle180; diff --git a/source/games/exhumed/src/lighting.cpp b/source/games/exhumed/src/lighting.cpp index 841d9dc0f..7bc26852a 100644 --- a/source/games/exhumed/src/lighting.cpp +++ b/source/games/exhumed/src/lighting.cpp @@ -723,7 +723,7 @@ void AddFlow(walltype* pWall, int nSpeed, int b) int nPic = pWall->picnum; sFlowInfo[nFlow].angcos = 0; - sFlowInfo[nFlow].angsin = b == 2 ? 1 : -1; + sFlowInfo[nFlow].angsin = b == 2 ? 1.f : -1.f; sFlowInfo[nFlow].pWall = pWall; sFlowInfo[nFlow].type = b; diff --git a/source/games/exhumed/src/move.cpp b/source/games/exhumed/src/move.cpp index e8a756c3f..71557af36 100644 --- a/source/games/exhumed/src/move.cpp +++ b/source/games/exhumed/src/move.cpp @@ -637,11 +637,11 @@ DExhumedActor* FindPlayer(DExhumedActor* pActor, int nDistance, bool dontengage) if ((pPlayerActor->spr.cstat & CSTAT_SPRITE_BLOCK_ALL) && (!(pPlayerActor->spr.cstat & CSTAT_SPRITE_INVISIBLE))) { - int v9 = abs(pPlayerActor->spr.pos.X - pActor->spr.pos.X); + double v9 = abs(pPlayerActor->spr.pos.X - pActor->spr.pos.X); if (v9 < nDistance) { - int v10 = abs(pPlayerActor->spr.pos.Y - pActor->spr.pos.Y); + double v10 = abs(pPlayerActor->spr.pos.Y - pActor->spr.pos.Y); if (v10 < nDistance && cansee(pPlayerActor->spr.pos.plusZ(-30), pPlayerActor->sector(), pActor->spr.pos.plusZ(-GetActorHeight(pActor)), pSector)) { diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 05949620c..316fe89e3 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -1166,7 +1166,7 @@ sectdone: PlayerList[nPlayer].ototalvel = PlayerList[nPlayer].totalvel; - PlayerList[nPlayer].totalvel = playerPos.Length() * 16; + PlayerList[nPlayer].totalvel = int(playerPos.Length() * worldtoint); auto pViewSect = pPlayerActor->sector(); diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index 12f7274bc..2ee206da8 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -700,7 +700,7 @@ void SectorObjectSetupBounds(SECTOR_OBJECT* sop) KillActor(BoundActor); // set radius for explosion checking - based on bounding box - child->user.Radius = ((vhigh.X - vlow.X) + (vhigh.Y - vlow.Y)) * (0.75 * 0.25) * worldtoint; // trying to get it a good size + child->user.Radius = int(((vhigh.X - vlow.X) + (vhigh.Y - vlow.Y)) * (0.75 * 0.25) * worldtoint); // trying to get it a good size // search for center sprite if it exists