diff --git a/source/common/utility/cmdlib.h b/source/common/utility/cmdlib.h index f0eef9b40..392d0f46d 100644 --- a/source/common/utility/cmdlib.h +++ b/source/common/utility/cmdlib.h @@ -80,11 +80,16 @@ bool ScanDirectory(TArray &list, const char *dirpath); bool IsAbsPath(const char*); FString M_ZLibError(int zerrnum); -inline int32_t Scale(int32_t a, int32_t b, int32_t c) +inline constexpr int32_t Scale(int32_t a, int32_t b, int32_t c) { return (int32_t)(((int64_t)a * b) / c); } +inline constexpr double Scale(double a, double b, double c) +{ + return (a * b) / c; +} + class FileReader; struct MD5Context; diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index e1ae1e9cc..974f8463f 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -2550,7 +2550,7 @@ static void ConcussSprite(DBloodActor* source, DBloodActor* actor, const DVector if (actor->spr.flags & kPhysMove) { - int mass = 0; + double mass = 0; if (actor->IsDudeActor()) { mass = getDudeInfo(actor->spr.type)->mass; @@ -2573,14 +2573,11 @@ static void ConcussSprite(DBloodActor* source, DBloodActor* actor, const DVector if (mass > 0) { - int size = (tileWidth(actor->spr.picnum) * actor->spr.xrepeat * tileHeight(actor->spr.picnum) * actor->spr.yrepeat) >> 1; - int t = Scale(damage, size, mass); - actor->add_int_bvel_x((int)MulScaleF(t, vect.X, 12)); - actor->add_int_bvel_y((int)MulScaleF(t, vect.Y, 12)); - actor->add_int_bvel_z((int)MulScaleF(t, vect.Z, 12)); + double size = FixedToFloat<29>(tileWidth(actor->spr.picnum) * actor->spr.xrepeat * tileHeight(actor->spr.picnum) * actor->spr.yrepeat); + actor->vel += vect * Scale(damage, size, mass); } } - actDamageSprite(source, actor, kDamageExplode, damage); + actDamageSprite(source, actor, kDamageExplode, int(damage)); } //---------------------------------------------------------------------------