Merge branch 'master' into newrenderer2

This commit is contained in:
Mitchell Richters 2021-04-01 16:49:07 +11:00
commit 88695ef554
18 changed files with 356 additions and 308 deletions

View file

@ -39,7 +39,7 @@ jobs:
name: "Linux GCC 7",
os: ubuntu-20.04,
extra_options: "-DCMAKE_C_COMPILER=/usr/bin/gcc-7 -DCMAKE_CXX_COMPILER=/usr/bin/g++-7",
deps_cmdline: "sudo apt update && sudo apt install libsdl2-dev libvpx-dev libgtk2.0-dev",
deps_cmdline: "sudo apt update && sudo apt install libsdl2-dev libvpx-dev libgtk2.0-dev gcc-7 g++-7",
build_type: "RelWithDebInfo"
}
- {

View file

@ -60,6 +60,7 @@ enum
constexpr double BAngRadian = pi::pi() * (1. / 1024.);
constexpr double BRadAngScale = 1. / BAngRadian;
constexpr double BAngToDegree = 360. / 2048.;
extern int16_t sintable[2048];
@ -398,6 +399,7 @@ class fixedhoriz
friend constexpr fixedhoriz q16horiz(fixed_t v);
friend constexpr fixedhoriz buildhoriz(int v);
friend fixedhoriz buildfhoriz(double v);
friend fixedhoriz pitchhoriz(double v);
friend fixedhoriz bamhoriz(int32_t v);
@ -496,6 +498,7 @@ public:
inline constexpr fixedhoriz q16horiz(fixed_t v) { return fixedhoriz(v); }
inline constexpr fixedhoriz buildhoriz(int v) { return fixedhoriz(IntToFixed(v)); }
inline fixedhoriz buildfhoriz(double v) { return fixedhoriz(FloatToFixed(v)); }
inline fixedhoriz pitchhoriz(double v) { return fixedhoriz(PitchToHoriz(v)); }
inline fixedhoriz bamhoriz(int32_t v) { return pitchhoriz(BAMToPitch(v)); }

View file

@ -77,7 +77,6 @@ CVARD(Bool, cl_slopetilting, false, CVAR_ARCHIVE, "enable/disable slope tilting"
CVARD(Int, cl_showweapon, 1, CVAR_ARCHIVE, "enable/disable show weapons") // only implemented in Blood
CVARD(Bool, cl_sointerpolation, true, CVAR_ARCHIVE, "enable/disable sector object interpolation") // only implemented in SW
CVARD(Bool, cl_syncinput, false, CVAR_ARCHIVE, "enable/disable synchronized input with game's ticrate") // only implemented in Duke
CVARD(Bool, cl_dukefixrpgrecoil, false, CVAR_ARCHIVE, "soften recoil of Duke 3D's RPG")
CVARD(Bool, cl_smoothsway, false, CVAR_ARCHIVE, "move SW weapon left and right smoothly while bobbing")
CVARD(Bool, cl_showmagamt, false, CVAR_ARCHIVE, "show the amount of rounds left in the magazine of your weapon on the modern HUD")
CVARD(Bool, cl_nomeleeblur, false, CVAR_ARCHIVE, "enable/disable blur effect with melee weapons in SW")

View file

@ -22,7 +22,6 @@ EXTERN_CVAR(Int, cl_weaponswitch)
EXTERN_CVAR(Float, crosshairscale)
EXTERN_CVAR(Bool, cl_sointerpolation)
EXTERN_CVAR(Bool, cl_syncinput)
EXTERN_CVAR(Bool, cl_dukefixrpgrecoil)
EXTERN_CVAR(Bool, cl_smoothsway)
EXTERN_CVAR(Bool, cl_showmagamt)
EXTERN_CVAR(Bool, cl_nomeleeblur)

View file

@ -155,8 +155,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)
@ -200,7 +199,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))

View file

@ -12,8 +12,8 @@ lookangle getincanglebam(binangle a, binangle na);
struct PlayerHorizon
{
fixedhoriz horiz, ohoriz, horizoff, ohorizoff;
double adjustment, target;
fixedhoriz horiz, ohoriz, horizoff, ohorizoff, target;
double adjustment;
void backup()
{
@ -44,30 +44,58 @@ struct PlayerHorizon
adjustment = 0;
}
void settarget(int value, bool backup = false)
{
if (!SyncInput() && !backup)
{
target = buildhoriz(value);
if (target.asq16() == 0) target = q16horiz(1);
}
else
{
horiz = buildhoriz(value);
if (backup) ohoriz = horiz;
}
}
void settarget(double value, bool backup = false)
{
if (!SyncInput() && !backup)
{
target = value * FRACUNIT;
if (target == 0) target += 1;
target = buildfhoriz(value);
if (target.asq16() == 0) target = q16horiz(1);
}
else
{
horiz = q16horiz(FloatToFixed(value));
horiz = buildfhoriz(value);
if (backup) ohoriz = horiz;
}
}
void settarget(fixedhoriz value, bool backup = false)
{
if (!SyncInput() && !backup)
{
target = value;
if (target.asq16() == 0) target = q16horiz(1);
}
else
{
horiz = value;
if (backup) ohoriz = horiz;
}
}
void processhelpers(double const scaleAdjust)
{
if (target)
if (target.asq16())
{
horiz += q16horiz(xs_CRoundToInt(scaleAdjust * (target - horiz.asq16())));
horiz += q16horiz(xs_CRoundToInt(scaleAdjust * (target - horiz).asq16()));
if (abs(horiz.asq16() - target) < FRACUNIT)
if (abs((horiz - target).asq16()) < FRACUNIT)
{
horiz = q16horiz(target);
target = 0;
horiz = target;
target = q16horiz(0);
}
}
else if (adjustment)
@ -97,9 +125,9 @@ struct PlayerHorizon
struct PlayerAngle
{
binangle ang, oang;
binangle ang, oang, target;
lookangle look_ang, olook_ang, rotscrnang, orotscrnang, spin;
double adjustment, target;
double adjustment;
void backup()
{
@ -172,12 +200,12 @@ struct PlayerAngle
{
if (!SyncInput() && !backup)
{
target = (ang + getincanglebam(ang, buildang(value))).asbam();
if (target == 0) target += 1;
target = buildang(value & 2047);
if (target.asbam() == 0) target = bamang(1);
}
else
{
ang = buildang(value);
ang = buildang(value & 2047);
if (backup) oang = ang;
}
}
@ -186,12 +214,12 @@ struct PlayerAngle
{
if (!SyncInput() && !backup)
{
target = (ang + getincanglebam(ang, buildfang(value))).asbam();
if (target == 0) target += 1;
target = buildfang(fmod(value, 2048));
if (target.asbam() == 0) target = bamang(1);
}
else
{
ang = buildfang(value);
ang = buildfang(fmod(value, 2048));
if (backup) oang = ang;
}
}
@ -200,8 +228,8 @@ struct PlayerAngle
{
if (!SyncInput() && !backup)
{
target = (ang + getincanglebam(ang, value)).asbam();
if (target == 0) target += 1;
target = value;
if (target.asbam() == 0) target = bamang(1);
}
else
{
@ -212,14 +240,14 @@ struct PlayerAngle
void processhelpers(double const scaleAdjust)
{
if (target)
if (target.asbam())
{
ang += bamang(xs_CRoundToUInt(scaleAdjust * (target - ang.asbam())));
ang += bamang(xs_CRoundToUInt(scaleAdjust * getincanglebam(ang, target).asbam()));
if (abs(ang.asbam() - target) < BAMUNIT)
if (getincanglebam(ang, target).asbam() < BAMUNIT)
{
ang = bamang(target);
target = 0;
ang = target;
target = bamang(0);
}
}
else if (adjustment)

View file

@ -119,13 +119,26 @@ void InputState::ClearAllInput()
{
memset(KeyStatus, 0, sizeof(KeyStatus));
AnyKeyStatus = false;
ActionsToSend = 0;
WeaponToSend = 0;
dpad_lock = 0;
lastCheck = 0;
crouch_toggle = false;
if (gamestate != GS_LEVEL)
{
ActionsToSend = 0;
crouch_toggle = false;
gi->clearlocalinputstate(); // also clear game local input state.
}
else if (gamestate == GS_LEVEL && crouch_toggle)
{
ActionsToSend |= SB_CROUCH;
}
else
{
ActionsToSend = 0;
}
buttonMap.ResetButtonStates(); // this is important. If all input is cleared, the buttons must be cleared as well.
gi->clearlocalinputstate(); // also clear game local input state.
resetTurnHeldAmt();
}

View file

@ -88,7 +88,7 @@ struct RegistryPathInfo
};
static const char * gameroot[] = { "/gameroot", nullptr};
static const char * swaddons[] = { "/gameroot", "/gameroot/addons", nullptr};
static const char * swaddons[] = { "/gameroot/addons", "/gameroot", nullptr};
static const char * dukeaddons[] = { "/gameroot", "/gameroot/addons/dc", "/gameroot/addons/nw", "/gameroot/addons/vacation", nullptr};
static const char * dn3d[] = { "/Duke Nukem 3D", nullptr};
static const char * nam[] = { "/NAM", nullptr};

View file

@ -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;

View file

@ -857,7 +857,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;
}

View file

@ -575,7 +575,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;

File diff suppressed because it is too large Load diff

View file

@ -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;
}

View file

@ -2611,7 +2611,7 @@ static void operateweapon(int snum, ESyncBits actions, int psect)
fi.shoot(pact, RPG);
checkavailweapon(p);
}
else if (p->kickback_pic == (cl_dukefixrpgrecoil ? 13 : 20))
else if (p->kickback_pic == 20)
p->okickback_pic = p->kickback_pic = 0;
break;
}

View file

@ -413,8 +413,8 @@ public:
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)
{

View file

@ -250,7 +250,7 @@ public:
{
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;

View file

@ -1814,7 +1814,7 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang,
double sc = czoom * (spr->yrepeat) / 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);
}

View file

@ -569,7 +569,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);