Skip to content

Commit

Permalink
- Make 360. / 2048. a constant expression and replace all uses thro…
Browse files Browse the repository at this point in the history
…ughout code.
  • Loading branch information
mjr4077au committed Mar 31, 2021
1 parent aa35b6a commit 029f880
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions source/core/binaryangle.h
Expand Up @@ -60,6 +60,7 @@ enum

constexpr double BAngRadian = pi::pi() * (1. / 1024.);
constexpr double BRadAngScale = 1. / BAngRadian;
constexpr double BAngToDegree = 360. / 2048.;


//---------------------------------------------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions source/core/gameinput.cpp
Expand Up @@ -154,8 +154,7 @@ void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlIn
int const keymove = gi->playerKeyMove() << running;
int const cntrlvelscale = g_gameType & GAMEFLAG_PSEXHUMED ? 8 : 1;
float const mousevelscale = keymove / 160.f;
double const angtodegscale = 360. / 2048.;
double const hidspeed = ((running ? 1585. : 867.5) / GameTicRate) * angtodegscale;
double const hidspeed = ((running ? 1585. : 867.5) / GameTicRate) * BAngToDegree;

// process mouse and initial controller input.
if (buttonMap.ButtonDown(gamefunc_Strafe) && allowstrafe)
Expand Down Expand Up @@ -199,7 +198,7 @@ void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlIn
// allow Exhumed to use its legacy values given the drastic difference from the other games.
if ((g_gameType & GAMEFLAG_PSEXHUMED) && cl_exhumedoldturn)
{
preambleturn = turnamount = (running ? 12 : 8) * angtodegscale;
preambleturn = turnamount = (running ? 12 : 8) * BAngToDegree;
}

if (buttonMap.ButtonDown(gamefunc_Turn_Left) || (buttonMap.ButtonDown(gamefunc_Strafe_Left) && !allowstrafe))
Expand Down
2 changes: 1 addition & 1 deletion source/games/blood/src/qav.cpp
Expand Up @@ -46,7 +46,7 @@ void DrawFrame(double x, double y, TILE_FRAME *pTile, int stat, int shade, int p
{
auto tex = tileGetTexture(pTile->picnum);
double scale = pTile->z/65536.;
double angle = pTile->angle * (360./2048);
double angle = pTile->angle * BAngToDegree;
int renderstyle = (stat & RS_NOMASK)? STYLE_Normal : STYLE_Translucent;
double alpha = (stat & RS_TRANS1)? glblend[0].def[!!(stat & RS_TRANS2)].alpha : 1.;
int pin = (stat & kQavOrientationLeft)? -1 : (stat & RS_ALIGN_R)? 1:0;
Expand Down
2 changes: 1 addition & 1 deletion source/games/blood/src/view.cpp
Expand Up @@ -882,7 +882,7 @@ FString GameInterface::GetCoordString()
FString out;

out.Format("pos= %d, %d, %d - angle = %2.3f",
gMe->pSprite->x, gMe->pSprite->y, gMe->pSprite->z, gMe->pSprite->ang * (360./2048));
gMe->pSprite->x, gMe->pSprite->y, gMe->pSprite->z, gMe->pSprite->ang * BAngToDegree);

return out;
}
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/game_misc.cpp
Expand Up @@ -577,7 +577,7 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang,
else if (j > (65536 << 1)) j = (65536 << 1);

DrawTexture(twod, tileGetTexture(i), xdim / 2. + spos.x / 4096., ydim / 2. + spos.y / 4096., DTA_TranslationIndex, TRANSLATION(Translation_Remap + setpal(&pp), pspr->pal), DTA_CenterOffset, true,
DTA_Rotate, daang * (-360./2048), DTA_Color, shadeToLight(pspr->shade), DTA_ScaleX, j / 65536., DTA_ScaleY, j / 65536., TAG_DONE);
DTA_Rotate, daang * -BAngToDegree, DTA_Color, shadeToLight(pspr->shade), DTA_ScaleX, j / 65536., DTA_ScaleY, j / 65536., TAG_DONE);
}
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/input.cpp
Expand Up @@ -755,7 +755,7 @@ static void processVehicleInput(player_struct *p, ControlInfo* const hidInput, I
}

input.fvel = xs_CRoundToInt(p->MotoSpeed);
input.avel *= (45. / 256.);
input.avel *= BAngToDegree;
loc.avel += input.avel;
}

Expand Down
4 changes: 2 additions & 2 deletions source/games/duke/src/sbar_r.cpp
Expand Up @@ -413,8 +413,8 @@ class DRedneckStatusBar : public DDukeCommonStatusBar
p->drunkang = 400;
}

DrawRotated(tileGetTexture(GUTMETER), 256, top + 15, DI_ITEM_RELCENTER, p->drunkang * (-360. / 2048), 1, scale, scale, 0xffffffff, 0);
DrawRotated(tileGetTexture(GUTMETER), 292, top + 15, DI_ITEM_RELCENTER, p->eatang * (-360. / 2048), 1, scale, scale, 0xffffffff, 0);
DrawRotated(tileGetTexture(GUTMETER), 256, top + 15, DI_ITEM_RELCENTER, p->drunkang * -BAngToDegree, 1, scale, scale, 0xffffffff, 0);
DrawRotated(tileGetTexture(GUTMETER), 292, top + 15, DI_ITEM_RELCENTER, p->eatang * -BAngToDegree, 1, scale, scale, 0xffffffff, 0);

if (p->drink_amt >= 0 && p->drink_amt <= 30)
{
Expand Down
2 changes: 1 addition & 1 deletion source/games/exhumed/src/movie.cpp
Expand Up @@ -250,7 +250,7 @@ class DLmfPlayer : public DScreenJob
{
twod->ClearScreen();
DrawTexture(twod, decoder.animTex().GetFrame(), 160, 100, DTA_FullscreenScale, FSMode_Fit320x200,
DTA_CenterOffset, true, DTA_FlipY, true, DTA_ScaleX, z / 65536., DTA_ScaleY, z / 65536., DTA_Rotate, (-angle - 512) * (360. / 2048.), TAG_DONE);
DTA_CenterOffset, true, DTA_FlipY, true, DTA_ScaleX, z / 65536., DTA_ScaleY, z / 65536., DTA_Rotate, (-angle - 512) * BAngToDegree, TAG_DONE);
}

lastclock = clock;
Expand Down
2 changes: 1 addition & 1 deletion source/games/sw/src/draw.cpp
Expand Up @@ -1825,7 +1825,7 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang,
double sc = MulScale(czoom * (spr->yrepeat), yxaspect, 16) / 32768.;
if (spnum >= 0)
{
DrawTexture(twod, tileGetTexture(1196 + pspr_ndx[myconnectindex], true), xd, yd, DTA_ScaleX, sc, DTA_ScaleY, sc, DTA_Rotate, daang * (-360. / 2048),
DrawTexture(twod, tileGetTexture(1196 + pspr_ndx[myconnectindex], true), xd, yd, DTA_ScaleX, sc, DTA_ScaleY, sc, DTA_Rotate, daang * -BAngToDegree,
DTA_CenterOffsetRel, true, DTA_TranslationIndex, TRANSLATION(Translation_Remap, spr->pal), DTA_Color, shadeToLight(spr->shade),
DTA_Alpha, (spr->cstat & 2) ? 0.33 : 1., TAG_DONE);
}
Expand Down
2 changes: 1 addition & 1 deletion source/glbackend/glbackend.cpp
Expand Up @@ -557,7 +557,7 @@ void hud_drawsprite(double sx, double sy, int z, double a, int picnum, int dasha
DTA_FlipX, !!(dastat & RS_XFLIPHUD),
DTA_FlipY, !!(dastat & RS_YFLIPHUD),
DTA_Pin, (dastat & RS_ALIGN_R) ? 1 : (dastat & RS_ALIGN_L) ? -1 : 0,
DTA_Rotate, a * (-360./2048),
DTA_Rotate, a * -BAngToDegree,
DTA_FlipOffsets, !(dastat & (/*RS_TOPLEFT |*/ RS_CENTER)),
DTA_Alpha, alpha,
TAG_DONE);
Expand Down

0 comments on commit 029f880

Please sign in to comment.