From 902f8c97069c1592a12457b94dbc63c8b99edd33 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 12 Oct 2022 19:00:29 +0200 Subject: [PATCH] - silenced lots of warnings for deliberate type conversions. The ones in d_net.cpp are not in active code. --- source/build/src/clip.cpp | 8 ++-- source/common/utility/i_time.cpp | 2 +- source/common/utility/tarray.h | 2 +- source/core/automap.cpp | 2 +- source/core/coreactor.h | 8 ++-- source/core/d_net.cpp | 4 +- source/core/defparser.cpp | 2 +- source/core/gamefuncs.cpp | 2 +- source/core/gamefuncs.h | 6 +-- source/core/gameinput.cpp | 4 +- source/core/maptypes.h | 2 +- source/core/r_data/gldefs.cpp | 2 +- source/core/rendering/hw_vertexmap.cpp | 2 +- source/core/sectorgeometry.cpp | 7 +++- source/core/vmexports.cpp | 24 ++++++------ source/games/blood/src/d_menu.cpp | 2 +- source/games/blood/src/eventq.h | 2 +- source/games/blood/src/gameutil.cpp | 12 +++--- source/games/blood/src/nnexts.cpp | 2 +- source/games/blood/src/sfx.cpp | 4 +- source/games/duke/src/actors.cpp | 10 ++--- source/games/duke/src/actors_d.cpp | 4 +- source/games/duke/src/actors_lava.cpp | 8 ++-- source/games/duke/src/gameexec.cpp | 52 +++++++++++++------------- source/games/duke/src/gamevar.h | 4 +- source/games/duke/src/input.cpp | 6 +-- source/games/exhumed/src/items.cpp | 2 +- source/games/sw/src/game.h | 2 +- source/games/sw/src/input.cpp | 4 +- 29 files changed, 98 insertions(+), 93 deletions(-) diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index d9fae4546..d05da2a99 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -59,7 +59,7 @@ static inline void get_floorspr_points(DCoreActor *spr, int32_t px, int32_t py, inline int32_t spriteGetZOfSlope(const spritetypebase* tspr, int dax, int day, int heinum) { - return spriteGetZOfSlopef(tspr, DVector2(dax * inttoworld, day * inttoworld), heinum) * zworldtoint; + return int(spriteGetZOfSlopef(tspr, DVector2(dax * inttoworld, day * inttoworld), heinum) * zworldtoint); } @@ -414,11 +414,11 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect, if (p1.X >= clipMin.X && p1.X <= clipMax.X && p1.Y >= clipMin.Y && p1.Y <= clipMax.Y) { double height_, daz_ = actor->spr.pos.Z + actor->GetOffsetAndHeight(height_); - int height = height_ * zworldtoint, daz = daz_ * zworldtoint; + int height = int(height_ * zworldtoint), daz = int(daz_ * zworldtoint); if (pos->Z > daz-height-flordist && pos->Z < daz+ceildist) { - int cd = actor->clipdist * worldtoint; + int cd = int(actor->clipdist * worldtoint); int32_t bsz = cd + walldist; if (diff.X < 0) bsz = -bsz; addclipline(p1.X-bsz, p1.Y-bsz, p1.X-bsz, p1.Y+bsz, obj, false); @@ -432,7 +432,7 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect, case CSTAT_SPRITE_ALIGNMENT_WALL: { double height_, daz_ = actor->spr.pos.Z + actor->GetOffsetAndHeight(height_); - int height = height_ * zworldtoint, daz = daz_ * zworldtoint; + int height = int(height_ * zworldtoint), daz = int(daz_ * zworldtoint); if (pos->Z > daz-height-flordist && pos->Z < daz+ceildist) { diff --git a/source/common/utility/i_time.cpp b/source/common/utility/i_time.cpp index a901a66ae..d9117d8ea 100644 --- a/source/common/utility/i_time.cpp +++ b/source/common/utility/i_time.cpp @@ -68,7 +68,7 @@ static uint64_t GetClockTimeNS() { auto tp = GetTimePoint() - StartupTimeNS; if (TimeScale == 1.0) return tp; - else return tp / 1000 * TimeScale * 1000; + else return uint64_t(tp / 1000 * TimeScale * 1000); } static uint64_t MSToNS(unsigned int ms) diff --git a/source/common/utility/tarray.h b/source/common/utility/tarray.h index 181a9e939..dbd63002b 100644 --- a/source/common/utility/tarray.h +++ b/source/common/utility/tarray.h @@ -332,7 +332,7 @@ public: unsigned IndexOf(const T* elem) const { - return elem - Array; + return unsigned(elem - Array); } unsigned int Find(const T& item) const diff --git a/source/core/automap.cpp b/source/core/automap.cpp index ba6228e6a..84243cc53 100644 --- a/source/core/automap.cpp +++ b/source/core/automap.cpp @@ -184,7 +184,7 @@ static void CalcMapBounds() static void AutomapControl(const DVector2& cangvect) { static double nonsharedtimer; - double ms = screen->FrameTime; + double ms = (double)screen->FrameTime; double interval; if (nonsharedtimer > 0 || ms < nonsharedtimer) diff --git a/source/core/coreactor.h b/source/core/coreactor.h index b8d61be14..89a77532a 100644 --- a/source/core/coreactor.h +++ b/source/core/coreactor.h @@ -168,7 +168,7 @@ public: int native_clipdist() { - return clipdist * 4; + return int(clipdist * 4); } void copy_clipdist(DCoreActor* other) @@ -439,7 +439,7 @@ void SetActor(DCoreActor* actor, const DVector3& newpos); inline int clipmove(DVector3& pos, sectortype** const sect, const DVector2& mvec, double const walldist, double const ceildist, double const flordist, unsigned const cliptype, CollisionBase& result, int clipmoveboxtracenum = 3) { - auto vect = vec3_t(pos.X * worldtoint, pos.Y * worldtoint, pos.Z * zworldtoint); + auto vect = vec3_t(int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint)); int sectno = *sect ? sector.IndexOf(*sect) : -1; result = clipmove_(&vect, §no, FloatToFixed<18>(mvec.X), FloatToFixed<18>(mvec.Y), int(walldist * worldtoint), int(ceildist * zworldtoint), int(flordist * zworldtoint), cliptype, clipmoveboxtracenum); pos = { vect.X * inttoworld, vect.Y * inttoworld, vect.Z * zinttoworld }; @@ -450,9 +450,9 @@ inline int clipmove(DVector3& pos, sectortype** const sect, const DVector2& mvec inline int pushmove(DVector3& pos, sectortype** const sect, double const walldist, double const ceildist, double const flordist, uint32_t const cliptype, bool clear = true) { - auto vect = vec3_t(pos.X * worldtoint, pos.Y * worldtoint, pos.Z * zworldtoint); + auto vect = vec3_t(int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint)); int sectno = *sect ? sector.IndexOf(*sect) : -1; - int res = pushmove_(&vect, §no, walldist * worldtoint, ceildist * zworldtoint, flordist * zworldtoint, cliptype, clear); + int res = pushmove_(&vect, §no, int(walldist * worldtoint), int(ceildist * zworldtoint), int(flordist * zworldtoint), cliptype, clear); pos = { vect.X * inttoworld, vect.Y * inttoworld, vect.Z * zinttoworld }; *sect = sectno == -1 ? nullptr : §or[sectno]; return res; diff --git a/source/core/d_net.cpp b/source/core/d_net.cpp index 7a1fd5ba3..0918c64d2 100644 --- a/source/core/d_net.cpp +++ b/source/core/d_net.cpp @@ -1032,8 +1032,8 @@ void NetUpdate (void) int mod = maketic - ticdup; int modp, tic; - int svel = 0; - int fvel = 0; + float svel = 0; + float fvel = 0; float avel = 0; float horz = 0; diff --git a/source/core/defparser.cpp b/source/core/defparser.cpp index ae460500e..13b90c5f3 100644 --- a/source/core/defparser.cpp +++ b/source/core/defparser.cpp @@ -906,7 +906,7 @@ void parseMultiPsky(FScanner& sc, FScriptPosition& pos) else if (sc.Compare("yoffset")) sc.GetNumber(sky.pmoffset, true); else if (sc.Compare("baseline")) sc.GetNumber(sky.baselineofs, true); else if (sc.Compare("lognumtiles")) sc.GetNumber(sky.lognumtiles, true); - else if (sc.Compare("yscale")) { int intscale; sc.GetNumber(intscale, true); sky.scale = intscale * (1. / 65536.); } + else if (sc.Compare("yscale")) { int intscale; sc.GetNumber(intscale, true); sky.scale = intscale * (1.f / 65536.f); } else if (sc.Compare({ "tile", "panel" })) { if (!sc.CheckString("}")) diff --git a/source/core/gamefuncs.cpp b/source/core/gamefuncs.cpp index cc6e2e03f..3728a13e6 100644 --- a/source/core/gamefuncs.cpp +++ b/source/core/gamefuncs.cpp @@ -171,7 +171,7 @@ int getslopeval(sectortype* sect, const DVector3& pos, double basez) { auto wal = sect->firstWall(); double i = (pos.XY() - wal->pos).dot(wal->delta().Rotated90CCW()); - return i == 0? 0 : SLOPEVAL_FACTOR * (pos.Z - basez) * wal->Length() / i; + return i == 0? 0 : int(SLOPEVAL_FACTOR * (pos.Z - basez) * wal->Length() / i); } //========================================================================== diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index bffc39f7d..099b03500 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -569,9 +569,9 @@ inline int rintersect(int x1, int y1, int z1, int vx, int vy, int vz, int x3, in double result = GetRayIntersect(DVector3(x1 * inttoworld, y1 * inttoworld, z1 * zinttoworld), DVector3(vx * inttoworld, vy * inttoworld, vz * zinttoworld), DVector2(x3 * inttoworld, y3 * inttoworld), DVector2((x4 - x3) * inttoworld, (y4 - y3) * inttoworld), retv); if (result < 0) return -1; - *intx = retv.X * worldtoint; - *inty = retv.Y * worldtoint; - *intz = retv.Z * zworldtoint; + *intx = int(retv.X * worldtoint); + *inty = int(retv.Y * worldtoint); + *intz = int(retv.Z * zworldtoint); return FloatToFixed(result); } diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index 75652d481..75826610f 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -158,8 +158,8 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe if (isRR() && drink_amt >= 66 && drink_amt <= 87) currInput->svel += drink_amt & 1 ? -currInput->fvel : currInput->fvel; // add collected input to game's local input accumulation packet. - inputBuffer->fvel = clamp(inputBuffer->fvel + currInput->fvel, -keymove, keymove); - inputBuffer->svel = clamp(inputBuffer->svel + currInput->svel, -keymove, keymove); + inputBuffer->fvel = clamp(inputBuffer->fvel + currInput->fvel, -(float)keymove, (float)keymove); + inputBuffer->svel = clamp(inputBuffer->svel + currInput->svel, -(float)keymove, (float)keymove); inputBuffer->avel += currInput->avel; inputBuffer->horz += currInput->horz; } diff --git a/source/core/maptypes.h b/source/core/maptypes.h index 0625c351d..4b848490b 100644 --- a/source/core/maptypes.h +++ b/source/core/maptypes.h @@ -370,7 +370,7 @@ struct walltype { DVector2 pos; - vec2_t wall_int_pos() const { return vec2_t(pos.X * worldtoint, pos.Y * worldtoint); }; + vec2_t wall_int_pos() const { return vec2_t(int(pos.X * worldtoint), int(pos.Y * worldtoint)); }; vec2_t int_delta() const { return point2Wall()->wall_int_pos() - wall_int_pos(); } void setPosFromMap(int x, int y) { pos = { x * maptoworld, y * maptoworld }; } diff --git a/source/core/r_data/gldefs.cpp b/source/core/r_data/gldefs.cpp index ce6bcb1a8..3cb46da56 100644 --- a/source/core/r_data/gldefs.cpp +++ b/source/core/r_data/gldefs.cpp @@ -1566,7 +1566,7 @@ class GLDefsParser ExtraUniformCVARData* oldextra = nullptr; sc.MustGetFloat(); - val.Float = oldval.Float = sc.Float; + val.Float = oldval.Float = (float)sc.Float; if (!Args->CheckParm ("-shaderuniformtest")) { diff --git a/source/core/rendering/hw_vertexmap.cpp b/source/core/rendering/hw_vertexmap.cpp index 6d977fd03..b2bdb0a83 100644 --- a/source/core/rendering/hw_vertexmap.cpp +++ b/source/core/rendering/hw_vertexmap.cpp @@ -163,7 +163,7 @@ void vertex_t::RecalcVertexHeights() float heights[2]; auto point = wall[masterwall].pos; - PlanesAtPoint(§or[sect], point.X, point.Y, &heights[0], &heights[1]); + PlanesAtPoint(§or[sect], (float)point.X, (float)point.Y, &heights[0], &heights[1]); for(auto height : heights) { int k; diff --git a/source/core/sectorgeometry.cpp b/source/core/sectorgeometry.cpp index 7bd870c97..be54b3ff6 100644 --- a/source/core/sectorgeometry.cpp +++ b/source/core/sectorgeometry.cpp @@ -42,6 +42,11 @@ #include "hw_sections.h" #include "tesselator.h" +// this is too noisy in this file. +#ifdef _MSC_VER +#pragma warning(disable:4244) +#endif + SectionGeometry sectionGeometry; //========================================================================== @@ -158,7 +163,7 @@ public: // To calculate the inverse Build performs an integer division with significant loss of precision // that can cause the texture to be shifted by multiple pixels. // The code below calculates the amount of this deviation so that it can be added back to the formula. - int x = ix2 - ix1, y = iy2 - iy1; + int x = int(ix2 - ix1), y = int(iy2 - iy1); int len = int(sqrt(double(x) * x + double(y) * y)); if (len != 0) { diff --git a/source/core/vmexports.cpp b/source/core/vmexports.cpp index 17992f83a..98b814c11 100644 --- a/source/core/vmexports.cpp +++ b/source/core/vmexports.cpp @@ -171,7 +171,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, setfloorxpan, sector_setfloorxpan) { PARAM_SELF_STRUCT_PROLOGUE(sectortype); PARAM_FLOAT(xpan); - self->setfloorxpan(xpan); + sector_setfloorxpan(self, xpan); return 0; } @@ -185,7 +185,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, setceilingxpan, sector_setceilingxpan { PARAM_SELF_STRUCT_PROLOGUE(sectortype); PARAM_FLOAT(xpan); - self->setceilingxpan(xpan); + sector_setceilingxpan(self, xpan); return 0; } @@ -199,7 +199,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, addfloorxpan, sector_addfloorxpan) { PARAM_SELF_STRUCT_PROLOGUE(sectortype); PARAM_FLOAT(xpan); - self->addfloorxpan(xpan); + sector_addfloorxpan(self, xpan); return 0; } @@ -213,7 +213,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, addceilingxpan, sector_addceilingxpan { PARAM_SELF_STRUCT_PROLOGUE(sectortype); PARAM_FLOAT(xpan); - self->addceilingxpan(xpan); + sector_addceilingxpan(self, xpan); return 0; } @@ -227,7 +227,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, setfloorypan, sector_setfloorypan) { PARAM_SELF_STRUCT_PROLOGUE(sectortype); PARAM_FLOAT(ypan); - self->setfloorypan(ypan); + sector_setfloorypan(self, ypan); return 0; } @@ -241,7 +241,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, setceilingypan, sector_setceilingypan { PARAM_SELF_STRUCT_PROLOGUE(sectortype); PARAM_FLOAT(ypan); - self->setceilingypan(ypan); + sector_setceilingypan(self, ypan); return 0; } @@ -255,7 +255,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, addfloorypan, sector_addfloorypan) { PARAM_SELF_STRUCT_PROLOGUE(sectortype); PARAM_FLOAT(ypan); - self->addfloorypan(ypan); + sector_addfloorypan(self, ypan); return 0; } @@ -269,7 +269,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, addceilingypan, sector_addceilingypan { PARAM_SELF_STRUCT_PROLOGUE(sectortype); PARAM_FLOAT(ypan); - self->addceilingypan(ypan); + sector_addceilingypan(self, ypan); return 0; } @@ -339,7 +339,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_walltype, setxpan, wall_setxpan) { PARAM_SELF_STRUCT_PROLOGUE(walltype); PARAM_FLOAT(xpan); - self->setxpan(xpan); + wall_setxpan(self, xpan); return 0; } @@ -353,7 +353,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_walltype, addxpan, wall_addxpan) { PARAM_SELF_STRUCT_PROLOGUE(walltype); PARAM_FLOAT(xpan); - self->addxpan(xpan); + wall_addxpan(self, xpan); return 0; } @@ -367,7 +367,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_walltype, setypan, wall_setypan) { PARAM_SELF_STRUCT_PROLOGUE(walltype); PARAM_FLOAT(ypan); - self->setypan(ypan); + wall_setypan(self, ypan); return 0; } @@ -381,7 +381,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_walltype, addypan, wall_addypan) { PARAM_SELF_STRUCT_PROLOGUE(walltype); PARAM_FLOAT(ypan); - self->addypan(ypan); + wall_addypan(self, ypan); return 0; } diff --git a/source/games/blood/src/d_menu.cpp b/source/games/blood/src/d_menu.cpp index f47a665d2..c87f04cf3 100644 --- a/source/games/blood/src/d_menu.cpp +++ b/source/games/blood/src/d_menu.cpp @@ -101,7 +101,7 @@ void CGameMenuItemQAV::Draw(void) { int xdim43 = Scale(twod->GetHeight(), 4, 3); int nCount = (twod->GetWidth() + xdim43 - 1) / xdim43; - int backX = data->x; + double backX = data->x; for (int i = 0; i < nCount; i++) { data->Draw(currentDuration, 10 + kQavOrientationLeft, 0, 0, false, interpfrac); diff --git a/source/games/blood/src/eventq.h b/source/games/blood/src/eventq.h index 83b1ba4a0..8f6164e1e 100644 --- a/source/games/blood/src/eventq.h +++ b/source/games/blood/src/eventq.h @@ -54,7 +54,7 @@ public: DBloodActor* actor() { assert(isActor()); return GC::ReadBarrier(ActorP); } sectortype* sector() { assert(isSector()); return &::sector[index >> 8]; } walltype* wall() { assert(isWall()); return &::wall[index >> 8]; } - int rawindex() { return index >> 8; } + int rawindex() { return int(index >> 8); } bool operator==(const EventObject& other) const { return index == other.index; } bool operator!=(const EventObject& other) const { return index != other.index; } diff --git a/source/games/blood/src/gameutil.cpp b/source/games/blood/src/gameutil.cpp index 3db8cc955..73cae3ddc 100644 --- a/source/games/blood/src/gameutil.cpp +++ b/source/games/blood/src/gameutil.cpp @@ -70,12 +70,12 @@ bool CheckProximity(DBloodActor* actor, const DVector3& pos, sectortype* pSector bool CheckProximityWall(walltype* pWall, const DVector2& pos, int nDist) { - int x = pos.X * (1. / maptoworld); - int y = pos.Y * (1. / maptoworld); - int x1 = pWall->pos.X * (1./maptoworld); - int y1 = pWall->pos.Y * (1./maptoworld); - int x2 = pWall->point2Wall()->pos.X * (1./maptoworld); - int y2 = pWall->point2Wall()->pos.Y * (1./maptoworld); + int x = int(pos.X * (1. / maptoworld)); + int y = int(pos.Y * (1. / maptoworld)); + int x1 = int(pWall->pos.X * (1./maptoworld)); + int y1 = int(pWall->pos.Y * (1./maptoworld)); + int x2 = int(pWall->point2Wall()->pos.X * (1./maptoworld)); + int y2 = int(pWall->point2Wall()->pos.Y * (1./maptoworld)); nDist <<= 4; if (x1 < x2) { diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 0df7a05dc..bae9ef2b7 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -1572,7 +1572,7 @@ void debrisConcuss(DBloodActor* owneractor, int listIndex, const DVector3& pos, dmg = int(dmg * (0x4000 / (0x4000 + dv.LengthSquared()))); bool thing = (actor->spr.type >= kThingBase && actor->spr.type < kThingMax); - int size = (tileWidth(actor->spr.picnum) * actor->spr.scale.X * tileHeight(actor->spr.picnum) * actor->spr.scale.Y) * 2048; + double size = (tileWidth(actor->spr.picnum) * actor->spr.scale.X * tileHeight(actor->spr.picnum) * actor->spr.scale.Y) * 2048; if (actor->xspr.physAttr & kPhysDebrisExplode) { if (actor->spriteMass.mass > 0) diff --git a/source/games/blood/src/sfx.cpp b/source/games/blood/src/sfx.cpp index 070b941fe..ecb196d5d 100644 --- a/source/games/blood/src/sfx.cpp +++ b/source/games/blood/src/sfx.cpp @@ -93,7 +93,7 @@ void BloodSoundEngine::CalcPosVel(int type, const void* source, const float pt[3 auto actor = (DBloodActor*)source; // Engine expects velocity in units per second, not units per tic. - if (vel) *vel = FVector3(actor->vel.X * 30, actor->vel.Z * -30, actor->vel.Y * -30); + if (vel) *vel = FVector3(float(actor->vel.X * 30), float(actor->vel.Z * -30), float(actor->vel.Y * -30)); *pos = GetSoundPos(actor->spr.pos); } else if (type == SOURCE_Ambient) @@ -120,7 +120,7 @@ void GameInterface::UpdateSounds() if (pPlayer->actor) { - listener.angle = -pPlayer->actor->spr.angle.Radians(); + listener.angle = float(-pPlayer->actor->spr.angle.Radians()); listener.velocity.Zero(); listener.position = GetSoundPos(pPlayer->actor->spr.pos); listener.valid = true; diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 8baf826e1..102a49300 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -1412,7 +1412,7 @@ bool rat(DDukeActor* actor, bool makesound) if (ssp(actor, CLIPMASK0)) { if (makesound && (krand() & 255) == 0) S_PlayActorSound(RATTY, actor); - actor->spr.angle += mapangle((krand() & 31) - 15 + BobVal(actor->temp_data[0] << 8) * 8); + actor->spr.angle += mapangle((krand() & 31) - 15 + int(BobVal(actor->temp_data[0] << 8) * 8)); } else { @@ -4141,11 +4141,11 @@ void handle_se20(DDukeActor* actor) SetActor(ps[p].GetActor(), ps[p].pos.plusZ(gs.playerheight)); } - sc->addfloorxpan(-vec.X * 2); - sc->addfloorypan(-vec.Y * 2); + sc->addfloorxpan(-(float)vec.X * 2); + sc->addfloorypan(-(float)vec.Y * 2); - sc->addceilingxpan(-vec.X * 2); - sc->addceilingypan(-vec.Y * 2); + sc->addceilingxpan(-(float)vec.X * 2); + sc->addceilingypan(-(float)vec.Y * 2); } } diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 25eabefcb..7ac372291 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -847,7 +847,7 @@ static void movetripbomb(DDukeActor *actor) } else { - x = actor->spr.extra; + auto ex = actor->spr.extra; actor->spr.extra = 1; auto ang = actor->spr.angle; j = fi.ifhitbyweapon(actor); @@ -855,7 +855,7 @@ static void movetripbomb(DDukeActor *actor) { actor->temp_data[2] = 16; } - actor->spr.extra = x; + actor->spr.extra = ex; actor->spr.angle = ang; } diff --git a/source/games/duke/src/actors_lava.cpp b/source/games/duke/src/actors_lava.cpp index 0600ae5ce..c0230e095 100644 --- a/source/games/duke/src/actors_lava.cpp +++ b/source/games/duke/src/actors_lava.cpp @@ -45,9 +45,9 @@ static short torchtype[64]; struct jaildoor { sectortype* sect; + double dist; + double drag; int speed; - float dist; - float drag; int16_t direction; int16_t sound; int16_t open; @@ -58,9 +58,9 @@ struct minecart { sectortype* sect; sectortype* childsect; + double dist; + double drag; int speed; - float dist; - float drag; int16_t direction; int16_t sound; int16_t open; diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index aa4bcba85..0ef8162d3 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -297,12 +297,12 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, case PLAYER_EXITX: if (bSet) ps[iPlayer].Exit.X = lValue * maptoworld; - else SetGameVarID(lVar2, ps[iPlayer].Exit.X / maptoworld, sActor, sPlayer); + else SetGameVarID(lVar2, int(ps[iPlayer].Exit.X / maptoworld), sActor, sPlayer); break; case PLAYER_EXITY: if (bSet) ps[iPlayer].Exit.Y = lValue * maptoworld; - else SetGameVarID(lVar2, ps[iPlayer].Exit.Y / maptoworld, sActor, sPlayer); + else SetGameVarID(lVar2, int(ps[iPlayer].Exit.Y / maptoworld), sActor, sPlayer); break; case PLAYER_LOOGIEX: @@ -326,15 +326,15 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, break; case PLAYER_POSX: // oh, my... :( Writing to these has been disabled until I know how to do it without the engine shitting all over itself. - if (!bSet) SetGameVarID(lVar2, ps[iPlayer].pos.X * (1/maptoworld), sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, int(ps[iPlayer].pos.X * (1/maptoworld)), sActor, sPlayer); break; case PLAYER_POSY: - if (!bSet) SetGameVarID(lVar2, ps[iPlayer].pos.Y * (1 / maptoworld), sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, int(ps[iPlayer].pos.Y * (1 / maptoworld)), sActor, sPlayer); break; case PLAYER_POSZ: - if (!bSet) SetGameVarID(lVar2, ps[iPlayer].pos.Z * (1 / zmaptoworld), sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, int(ps[iPlayer].pos.Z * (1 / zmaptoworld)), sActor, sPlayer); break; case PLAYER_HORIZ: @@ -369,37 +369,37 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, case PLAYER_BOBPOSX: if (bSet) ps[iPlayer].bobpos.X = lValue * maptoworld; - else SetGameVarID(lVar2, ps[iPlayer].bobpos.X * (1/maptoworld), sActor, sPlayer); + else SetGameVarID(lVar2, int(ps[iPlayer].bobpos.X * (1/maptoworld)), sActor, sPlayer); break; case PLAYER_BOBPOSY: if (bSet) ps[iPlayer].bobpos.Y = lValue * maptoworld; - else SetGameVarID(lVar2, ps[iPlayer].bobpos.Y * (1/maptoworld), sActor, sPlayer); + else SetGameVarID(lVar2, int(ps[iPlayer].bobpos.Y * (1/maptoworld)), sActor, sPlayer); break; case PLAYER_OPOSX: if (bSet) ps[iPlayer].opos.X = lValue * maptoworld; - else SetGameVarID(lVar2, ps[iPlayer].opos.X * (1/maptoworld), sActor, sPlayer); + else SetGameVarID(lVar2, int(ps[iPlayer].opos.X * (1/maptoworld)), sActor, sPlayer); break; case PLAYER_OPOSY: if (bSet) ps[iPlayer].opos.Y = lValue * maptoworld; - else SetGameVarID(lVar2, ps[iPlayer].opos.Y * (1 / maptoworld), sActor, sPlayer); + else SetGameVarID(lVar2, int(ps[iPlayer].opos.Y * (1 / maptoworld)), sActor, sPlayer); break; case PLAYER_OPOSZ: if (bSet) ps[iPlayer].opos.Z = lValue * zmaptoworld; - else SetGameVarID(lVar2, ps[iPlayer].opos.Z * (1 / zmaptoworld), sActor, sPlayer); + else SetGameVarID(lVar2, int(ps[iPlayer].opos.Z * (1 / zmaptoworld)), sActor, sPlayer); break; case PLAYER_PYOFF: if (bSet) ps[iPlayer].pyoff = lValue * zmaptoworld; - else SetGameVarID(lVar2, ps[iPlayer].pyoff / zmaptoworld, sActor, sPlayer); + else SetGameVarID(lVar2, int(ps[iPlayer].pyoff / zmaptoworld), sActor, sPlayer); break; case PLAYER_OPYOFF: if (bSet) ps[iPlayer].opyoff = lValue * zmaptoworld; - else SetGameVarID(lVar2, ps[iPlayer].opyoff / zmaptoworld, sActor, sPlayer); + else SetGameVarID(lVar2, int(ps[iPlayer].opyoff / zmaptoworld), sActor, sPlayer); break; case PLAYER_POSXV: @@ -414,7 +414,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, case PLAYER_POSZV: if (bSet) ps[iPlayer].vel.Z = lValue * zmaptoworld; - else SetGameVarID(lVar2, ps[iPlayer].vel.Z / zmaptoworld, sActor, sPlayer); + else SetGameVarID(lVar2, int(ps[iPlayer].vel.Z / zmaptoworld), sActor, sPlayer); break; case PLAYER_LAST_PISSED_TIME: @@ -424,12 +424,12 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, case PLAYER_TRUEFZ: if (bSet) ps[iPlayer].truefz = lValue * zmaptoworld; - else SetGameVarID(lVar2, ps[iPlayer].truefz * (1/zmaptoworld), sActor, sPlayer); + else SetGameVarID(lVar2, int(ps[iPlayer].truefz * (1/zmaptoworld)), sActor, sPlayer); break; case PLAYER_TRUECZ: if (bSet) ps[iPlayer].truecz = lValue * zmaptoworld; - else SetGameVarID(lVar2, ps[iPlayer].truecz * (1 / zmaptoworld), sActor, sPlayer); + else SetGameVarID(lVar2, int(ps[iPlayer].truecz * (1 / zmaptoworld)), sActor, sPlayer); break; case PLAYER_PLAYER_PAR: @@ -953,10 +953,10 @@ void DoWall(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, i switch (lLabelID) { case WALL_X: - if (!bSet) SetGameVarID(lVar2, wallp->pos.X / maptoworld, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, int(wallp->pos.X / maptoworld), sActor, sPlayer); break; case WALL_Y: - if (!bSet) SetGameVarID(lVar2, wallp->pos.Y / maptoworld, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, int(wallp->pos.Y / maptoworld), sActor, sPlayer); break; case WALL_POINT2: if (!bSet) SetGameVarID(lVar2, wallp->point2, sActor, sPlayer); @@ -1168,13 +1168,13 @@ void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, switch (lLabelID) { case ACTOR_X: - if (!bSet) SetGameVarID(lVar2, act->spr.pos.X / maptoworld, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, int(act->spr.pos.X / maptoworld), sActor, sPlayer); break; case ACTOR_Y: - if (!bSet) SetGameVarID(lVar2, act->spr.pos.Y / maptoworld, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, int(act->spr.pos.Y / maptoworld), sActor, sPlayer); break; case ACTOR_Z: - if (!bSet) SetGameVarID(lVar2, act->spr.pos.Z / zmaptoworld, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, int(act->spr.pos.Z / zmaptoworld), sActor, sPlayer); break; case ACTOR_CSTAT: if (bSet) act->spr.cstat = ESpriteFlags::FromInt(lValue); @@ -1235,7 +1235,7 @@ void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, break; case ACTOR_XVEL: if (bSet) act->vel.X = lValue * maptoworld; - else SetGameVarID(lVar2, act->vel.X / maptoworld, sActor, sPlayer); + else SetGameVarID(lVar2, int(act->vel.X / maptoworld), sActor, sPlayer); break; case ACTOR_YVEL: if (bSet) act->spr.yint = lValue; @@ -1243,7 +1243,7 @@ void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, break; case ACTOR_ZVEL: if (bSet) act->vel.Z = lValue * zmaptoworld; - else SetGameVarID(lVar2, act->vel.Z / zmaptoworld, sActor, sPlayer); + else SetGameVarID(lVar2, int(act->vel.Z / zmaptoworld), sActor, sPlayer); break; case ACTOR_LOTAG: if (bSet) act->spr.lotag = lValue; @@ -1300,19 +1300,19 @@ void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, break; case ACTOR_HTFLOORZ: if (bSet) act->floorz = lValue * zmaptoworld; - else SetGameVarID(lVar2, act->floorz * (1/zmaptoworld), sActor, sPlayer); + else SetGameVarID(lVar2, int(act->floorz * (1/zmaptoworld)), sActor, sPlayer); break; case ACTOR_HTCEILINGZ: if (bSet) act->ceilingz = lValue * zmaptoworld; - else SetGameVarID(lVar2, act->ceilingz * (1/zmaptoworld), sActor, sPlayer); + else SetGameVarID(lVar2, int(act->ceilingz * (1/zmaptoworld)), sActor, sPlayer); break; case ACTOR_HTLASTVX: if (bSet) act->ovel.X = lValue * maptoworld; - else SetGameVarID(lVar2, act->ovel.X / maptoworld, sActor, sPlayer); + else SetGameVarID(lVar2, int(act->ovel.X / maptoworld), sActor, sPlayer); break; case ACTOR_HTLASTVY: if (bSet) act->ovel.Y = lValue * maptoworld; - else SetGameVarID(lVar2, act->ovel.Y / maptoworld, sActor, sPlayer); + else SetGameVarID(lVar2, int(act->ovel.Y / maptoworld), sActor, sPlayer); break; case ACTOR_HTG_T0: if (bSet) act->temp_data[0] = lValue; diff --git a/source/games/duke/src/gamevar.h b/source/games/duke/src/gamevar.h index f5da6c3d5..f03df1977 100644 --- a/source/games/duke/src/gamevar.h +++ b/source/games/duke/src/gamevar.h @@ -25,13 +25,13 @@ class GameVarValue public: GameVarValue() = default; explicit GameVarValue(DDukeActor* actor_) { ActorP = actor_; assert(isActor()); } - explicit GameVarValue(int val) { index = (val << 8) | Value; } + explicit GameVarValue(intptr_t val) { index = (val << 8) | Value; } bool isActor() const { return (index & 7) == Actor; } bool isValue() const { return (index & 7) == Value; } DDukeActor* actor() { assert(isActor()); return GC::ReadBarrier(ActorP); } - int value() { assert(isValue()); return index >> 8; } + int value() { assert(isValue()); return int(index >> 8); } int safeValue() { return isValue() ? value() : actor() == nullptr ? 0 : -1; } // return -1 for valid actors and 0 for null. This allows most comparisons to work. DDukeActor* safeActor() { return isActor() ? actor() : nullptr; } diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index ba1aaefd8..22ce86cf6 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -759,7 +759,7 @@ static void processVehicleInput(player_struct *p, ControlInfo* const hidInput, I input.avel = (float)boatApplyTurn(p, hidInput, kbdLeft, kbdRight, scaleAdjust); } - loc.fvel = clamp(p->MotoSpeed, -(MAXVELMOTO >> 3), MAXVELMOTO) * (1.f / 40.f); + loc.fvel = clamp((float)p->MotoSpeed, -(MAXVELMOTO >> 3), MAXVELMOTO) * (1.f / 40.f); input.avel *= BAngToDegree; loc.avel += input.avel; } @@ -850,8 +850,8 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju { *packet = loc; auto velvect = DVector2(loc.fvel, loc.svel).Rotated(p->angle.ang) + p->fric; - packet->fvel = velvect.X; - packet->svel = velvect.Y; + packet->fvel = (float)velvect.X; + packet->svel = (float)velvect.Y; loc = {}; } } diff --git a/source/games/exhumed/src/items.cpp b/source/games/exhumed/src/items.cpp index 6dbdd4b15..b4857a399 100644 --- a/source/games/exhumed/src/items.cpp +++ b/source/games/exhumed/src/items.cpp @@ -440,7 +440,7 @@ void StartRegenerate(DExhumedActor* pActor) if (pos >= Regenerates.Size()) { // ?? CHECKME - pActor->spr.xint = pActor->spr.scale.X * INV_REPEAT_SCALE; + pActor->spr.xint = int16_t(pActor->spr.scale.X * INV_REPEAT_SCALE); pActor->spr.inittype = pActor->spr.shade; pActor->spr.yint = pActor->spr.pal; } diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index cebc5a81f..335b8c1a2 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -2110,7 +2110,7 @@ struct ANIM animactor->user.pos.Z = value; break; case ANIM_SUdepth: - sector[animindex].depth_fixed = value; + sector[animindex].depth_fixed = (int)value; default: return; } diff --git a/source/games/sw/src/input.cpp b/source/games/sw/src/input.cpp index 8502cf733..47046f33a 100644 --- a/source/games/sw/src/input.cpp +++ b/source/games/sw/src/input.cpp @@ -208,8 +208,8 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju { *packet = loc; auto velvect = DVector2(loc.fvel, loc.svel).Rotated(pp->angle.ang); - packet->fvel = velvect.X; - packet->svel = velvect.Y; + packet->fvel = (float)velvect.X; + packet->svel = (float)velvect.Y; loc = {}; } }