- handle the run key.

This commit is contained in:
Christoph Oelckers 2020-08-29 00:57:07 +02:00
parent b9e0f493b2
commit fe7f3a2f9e
13 changed files with 38 additions and 62 deletions

View file

@ -180,12 +180,9 @@ void ctrlGetInput(void)
gInput.syncFlags.lookDown |= buttonMap.ButtonDown(gamefunc_Aim_Down); gInput.syncFlags.lookDown |= buttonMap.ButtonDown(gamefunc_Aim_Down);
} }
int const run = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run)); int const run = !!(gInput.actions & SB_RUN);
int const run2 = false; // What??? buttonMap.ButtonDown(gamefunc_Run);
int const keyMove = (1 + run) << 10; int const keyMove = (1 + run) << 10;
gInput.syncFlags.run |= run;
if (gInput.fvel < keyMove && gInput.fvel > -keyMove) if (gInput.fvel < keyMove && gInput.fvel > -keyMove)
{ {
if (buttonMap.ButtonDown(gamefunc_Move_Forward)) if (buttonMap.ButtonDown(gamefunc_Move_Forward))
@ -244,7 +241,7 @@ void ctrlGetInput(void)
if (turnRight) if (turnRight)
input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(ClipHigh(12 * turnHeldTime, gTurnSpeed)>>2))); input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(ClipHigh(12 * turnHeldTime, gTurnSpeed)>>2)));
if ((run2 || run) && turnHeldTime > 24) if (run && turnHeldTime > 24)
input.q16avel <<= 1; input.q16avel <<= 1;
if (buttonMap.ButtonDown(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Strafe))

View file

@ -1332,7 +1332,7 @@ void ProcessInput(PLAYER *pPlayer)
gViewLookAdjust = 0.f; gViewLookAdjust = 0.f;
} }
pPlayer->isRunning = pInput->syncFlags.run; pPlayer->isRunning = !!(pInput->actions & SB_RUN);
if ((pInput->syncFlags.value & flag_buttonmask_norun) || (pInput->actions & SB_BUTTON_MASK) || pInput->fvel || pInput->svel || pInput->q16avel) if ((pInput->syncFlags.value & flag_buttonmask_norun) || (pInput->actions & SB_BUTTON_MASK) || pInput->fvel || pInput->svel || pInput->q16avel)
pPlayer->restTime = 0; pPlayer->restTime = 0;
else if (pPlayer->restTime >= 0) else if (pPlayer->restTime >= 0)

View file

@ -360,6 +360,8 @@ void ApplyGlobalInput(InputPacket& input, ControlInfo *info)
if (g_gameType & GAMEFLAG_BLOOD) buttonMap.ClearButton(gamefunc_Open); if (g_gameType & GAMEFLAG_BLOOD) buttonMap.ClearButton(gamefunc_Open);
input.actions |= SB_OPEN; input.actions |= SB_OPEN;
} }
if (G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run)))
input.actions |= SB_RUN;
} }

View file

@ -69,7 +69,6 @@ enum EDukeSyncBits_ : uint32_t
{ {
SKB_AIM_UP = 1 << 3, SKB_AIM_UP = 1 << 3,
SKB_AIM_DOWN = 1 << 4, SKB_AIM_DOWN = 1 << 4,
SKB_RUN = 1 << 5,
SKB_LOOK_LEFT = 1 << 6, SKB_LOOK_LEFT = 1 << 6,
SKB_LOOK_RIGHT = 1 << 7, SKB_LOOK_RIGHT = 1 << 7,
SKB_LOOK_UP = 1 << 13, SKB_LOOK_UP = 1 << 13,
@ -95,7 +94,7 @@ union SYNCFLAGS
uint32_t value; uint32_t value;
struct struct
{ {
unsigned int run : 1; unsigned int _run : 1;
unsigned int _jump : 1; unsigned int _jump : 1;
unsigned int _crouch : 1; unsigned int _crouch : 1;
unsigned int _shoot : 1; unsigned int _shoot : 1;
@ -124,7 +123,6 @@ union SYNCFLAGS
#define SK_CRAWL_LOCK 14 #define SK_CRAWL_LOCK 14
#define SK_FLY 15 #define SK_FLY 15
#define SK_RUN 16
#define SK_AIM_UP 21 #define SK_AIM_UP 21
#define SK_AIM_DOWN 22 #define SK_AIM_DOWN 22

View file

@ -178,7 +178,7 @@ void PlayerInterruptKeys(bool after)
// JBF: Run key behaviour is selectable // JBF: Run key behaviour is selectable
int const playerRunning = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run)); int const playerRunning = !!(localInput.actions & SB_RUN);
int const turnAmount = playerRunning ? 12 : 8; int const turnAmount = playerRunning ? 12 : 8;
int const keyMove = playerRunning ? 12 : 6; int const keyMove = playerRunning ? 12 : 6;

View file

@ -112,10 +112,10 @@ void playerJump(int snum, int fz, int cz);
void applylook(int snum, double factor, fixed_t adjustment); void applylook(int snum, double factor, fixed_t adjustment);
void checklook(int snum, int sb_snum); void checklook(int snum, int sb_snum);
void playerCenterView(int snum); void playerCenterView(int snum);
void playerLookUp(int snum, EDukeSyncBits sb_snum); void playerLookUp(int snum, ESyncBits sb_snum);
void playerLookDown(int snum, EDukeSyncBits sb_snum); void playerLookDown(int snum, ESyncBits sb_snum);
void playerAimUp(int snum, EDukeSyncBits sb_snum); void playerAimUp(int snum, ESyncBits sb_snum);
void playerAimDown(int snum, EDukeSyncBits sb_snum); void playerAimDown(int snum, ESyncBits sb_snum);
bool view(struct player_struct* pp, int* vx, int* vy, int* vz, short* vsectnum, int ang, int horiz); bool view(struct player_struct* pp, int* vx, int* vy, int* vz, short* vsectnum, int ang, int horiz);
void tracers(int x1, int y1, int z1, int x2, int y2, int z2, int n); void tracers(int x1, int y1, int z1, int x2, int y2, int z2, int n);
int hits(int i); int hits(int i);

View file

@ -1171,15 +1171,15 @@ int ParseState::parse(void)
j = 1; j = 1;
else if( (l& pstanding) && s >= 0 && s < 8) else if( (l& pstanding) && s >= 0 && s < 8)
j = 1; j = 1;
else if( (l& pwalking) && s >= 8 && !(PlayerInput(g_p, SKB_RUN)) ) else if( (l& pwalking) && s >= 8 && !(PlayerInput(g_p, SB_RUN)) )
j = 1; j = 1;
else if( (l& prunning) && s >= 8 && PlayerInput(g_p, SKB_RUN) ) else if( (l& prunning) && s >= 8 && PlayerInput(g_p, SB_RUN) )
j = 1; j = 1;
else if( (l& phigher) && ps[g_p].posz < (g_sp->z-(48<<8)) ) else if( (l& phigher) && ps[g_p].posz < (g_sp->z-(48<<8)) )
j = 1; j = 1;
else if( (l& pwalkingback) && s <= -8 && !(PlayerInput(g_p, SKB_RUN)) ) else if( (l& pwalkingback) && s <= -8 && !(PlayerInput(g_p, SB_RUN)) )
j = 1; j = 1;
else if( (l& prunningback) && s <= -8 && (PlayerInput(g_p, SKB_RUN)) ) else if( (l& prunningback) && s <= -8 && (PlayerInput(g_p, SB_RUN)) )
j = 1; j = 1;
else if( (l& pkicking) && ( ps[g_p].quick_kick > 0 || ( ps[g_p].curr_weapon == KNEE_WEAPON && ps[g_p].kickback_pic > 0 ) ) ) else if( (l& pkicking) && ( ps[g_p].quick_kick > 0 || ( ps[g_p].curr_weapon == KNEE_WEAPON && ps[g_p].kickback_pic > 0 ) ) )
j = 1; j = 1;

View file

@ -616,7 +616,6 @@ static void processInputBits(player_struct *p, ControlInfo &info)
} }
if (buttonMap.ButtonDown(gamefunc_Aim_Up) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && info.dz > 0)) loc.sbits |= SKB_AIM_UP; if (buttonMap.ButtonDown(gamefunc_Aim_Up) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && info.dz > 0)) loc.sbits |= SKB_AIM_UP;
if ((buttonMap.ButtonDown(gamefunc_Aim_Down) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && info.dz < 0))) loc.sbits |= SKB_AIM_DOWN; if ((buttonMap.ButtonDown(gamefunc_Aim_Down) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && info.dz < 0))) loc.sbits |= SKB_AIM_DOWN;
if (G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run))) loc.sbits |= SKB_RUN;
if (buttonMap.ButtonDown(gamefunc_Look_Left)) loc.sbits |= SKB_LOOK_LEFT; if (buttonMap.ButtonDown(gamefunc_Look_Left)) loc.sbits |= SKB_LOOK_LEFT;
if (buttonMap.ButtonDown(gamefunc_Look_Right)) loc.sbits |= SKB_LOOK_RIGHT; if (buttonMap.ButtonDown(gamefunc_Look_Right)) loc.sbits |= SKB_LOOK_RIGHT;
if (buttonMap.ButtonDown(gamefunc_Look_Up)) loc.sbits |= SKB_LOOK_UP; if (buttonMap.ButtonDown(gamefunc_Look_Up)) loc.sbits |= SKB_LOOK_UP;
@ -634,7 +633,7 @@ static void processInputBits(player_struct *p, ControlInfo &info)
if (onVehicle) if (onVehicle)
{ {
// mask out all actions not compatible with vehicles. // mask out all actions not compatible with vehicles.
loc.actions &= ~(SB_WEAPONMASK_BITS | SB_TURNAROUND | SB_CENTERVIEW | SB_HOLSTER | SB_JUMP | SB_CROUCH); loc.actions &= ~(SB_WEAPONMASK_BITS | SB_TURNAROUND | SB_CENTERVIEW | SB_HOLSTER | SB_JUMP | SB_CROUCH | SB_RUN);
} }
if (buttonMap.ButtonDown(gamefunc_Dpad_Aiming)) if (buttonMap.ButtonDown(gamefunc_Dpad_Aiming))
@ -688,7 +687,7 @@ static void processMovement(player_struct *p, InputPacket &input, ControlInfo &i
bool mouseaim = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming); bool mouseaim = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming);
// JBF: Run key behaviour is selectable // JBF: Run key behaviour is selectable
int running = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run)); int running = !!(loc.actions & SB_RUN);
int turnamount = NORMALTURN << running; int turnamount = NORMALTURN << running;
int keymove = NORMALKEYMOVE << running; int keymove = NORMALKEYMOVE << running;
@ -982,7 +981,7 @@ static void processVehicleInput(player_struct *p, ControlInfo& info, InputPacket
loc.actions |= SB_JUMP; loc.actions |= SB_JUMP;
if (buttonMap.ButtonDown(gamefunc_Move_Backward)) if (buttonMap.ButtonDown(gamefunc_Move_Backward))
loc.sbits |= SKB_AIM_UP; loc.sbits |= SKB_AIM_UP;
if (buttonMap.ButtonDown(gamefunc_Run)) if (loc.buttons & SB_RUN)
loc.actions |= SB_CROUCH; loc.actions |= SB_CROUCH;
} }
@ -1126,9 +1125,9 @@ void GetInput()
} }
else else
{ {
processInputBits(p, info);
processMovement(p, input, info, scaleAdjust); processMovement(p, input, info, scaleAdjust);
checkCrouchToggle(p); checkCrouchToggle(p);
processInputBits(p, info);
FinalizeInput(myconnectindex, input, false); FinalizeInput(myconnectindex, input, false);
} }

View file

@ -1050,7 +1050,7 @@ void playerCenterView(int snum)
} }
} }
void playerLookUp(int snum, EDukeSyncBits sb_snum) void playerLookUp(int snum, ESyncBits actions)
{ {
auto p = &ps[snum]; auto p = &ps[snum];
SetGameVarID(g_iReturnVarID, 0, p->i, snum); SetGameVarID(g_iReturnVarID, 0, p->i, snum);
@ -1058,11 +1058,11 @@ void playerLookUp(int snum, EDukeSyncBits sb_snum)
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
{ {
p->return_to_center = 9; p->return_to_center = 9;
p->pitchAdjust += (sb_snum & SKB_RUN) ? 12 : 24; p->pitchAdjust += (actions & SB_RUN) ? 12 : 24;
} }
} }
void playerLookDown(int snum, EDukeSyncBits sb_snum) void playerLookDown(int snum, ESyncBits actions)
{ {
auto p = &ps[snum]; auto p = &ps[snum];
SetGameVarID(g_iReturnVarID, 0, p->i, snum); SetGameVarID(g_iReturnVarID, 0, p->i, snum);
@ -1070,29 +1070,29 @@ void playerLookDown(int snum, EDukeSyncBits sb_snum)
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
{ {
p->return_to_center = 9; p->return_to_center = 9;
p->pitchAdjust -= (sb_snum & SKB_RUN) ? 12 : 24; p->pitchAdjust -= (actions & SB_RUN) ? 12 : 24;
} }
} }
void playerAimUp(int snum, EDukeSyncBits sb_snum) void playerAimUp(int snum, ESyncBits actions)
{ {
auto p = &ps[snum]; auto p = &ps[snum];
SetGameVarID(g_iReturnVarID, 0, p->i, snum); SetGameVarID(g_iReturnVarID, 0, p->i, snum);
OnEvent(EVENT_AIMUP, p->i, snum, -1); OnEvent(EVENT_AIMUP, p->i, snum, -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
{ {
p->pitchAdjust += (sb_snum & SKB_RUN) ? 6 : 12; p->pitchAdjust += (actions & SB_RUN) ? 6 : 12;
} }
} }
void playerAimDown(int snum, EDukeSyncBits sb_snum) void playerAimDown(int snum, ESyncBits actions)
{ {
auto p = &ps[snum]; auto p = &ps[snum];
SetGameVarID(g_iReturnVarID, 0, p->i, snum); SetGameVarID(g_iReturnVarID, 0, p->i, snum);
OnEvent(EVENT_AIMDOWN, p->i, snum, -1); OnEvent(EVENT_AIMDOWN, p->i, snum, -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
{ {
p->pitchAdjust -= (sb_snum & SKB_RUN) ? 6 : 12; p->pitchAdjust -= (actions & SB_RUN) ? 6 : 12;
} }
} }

View file

@ -3009,19 +3009,19 @@ HORIZONLY:
} }
else if (sb_snum & SKB_LOOK_UP) else if (sb_snum & SKB_LOOK_UP)
{ {
playerLookUp(snum, sb_snum); playerLookUp(snum, actions);
} }
else if (sb_snum & SKB_LOOK_DOWN) else if (sb_snum & SKB_LOOK_DOWN)
{ {
playerLookDown(snum, sb_snum); playerLookDown(snum, actions);
} }
else if (sb_snum & SKB_AIM_UP) else if (sb_snum & SKB_AIM_UP)
{ {
playerAimUp(snum, sb_snum); playerAimUp(snum, actions);
} }
else if (sb_snum & SKB_AIM_DOWN) else if (sb_snum & SKB_AIM_DOWN)
{ // aim_down { // aim_down
playerAimDown(snum, sb_snum); playerAimDown(snum, actions);
} }
if (cl_syncinput) if (cl_syncinput)

View file

@ -4035,19 +4035,19 @@ HORIZONLY:
} }
else if (sb_snum & SKB_LOOK_UP) else if (sb_snum & SKB_LOOK_UP)
{ {
playerLookUp(snum, sb_snum); playerLookUp(snum, actions);
} }
else if (sb_snum & SKB_LOOK_DOWN) else if (sb_snum & SKB_LOOK_DOWN)
{ {
playerLookDown(snum, sb_snum); playerLookDown(snum, actions);
} }
else if ((sb_snum & SKB_AIM_UP) && !p->OnMotorcycle) else if ((sb_snum & SKB_AIM_UP) && !p->OnMotorcycle)
{ {
playerAimUp(snum, sb_snum); playerAimUp(snum, actions);
} }
else if ((sb_snum & SKB_AIM_DOWN) && !p->OnMotorcycle) else if ((sb_snum & SKB_AIM_DOWN) && !p->OnMotorcycle)
{ {
playerAimDown(snum, sb_snum); playerAimDown(snum, actions);
} }
if (p->recoil && p->kickback_pic == 0) if (p->recoil && p->kickback_pic == 0)
{ {

View file

@ -149,7 +149,6 @@ getinput(InputPacket *loc, SWBOOL tied)
SET_LOC_KEY(loc->bits, SK_SPACE_BAR, buttonMap.ButtonDown(gamefunc_Open)); SET_LOC_KEY(loc->bits, SK_SPACE_BAR, buttonMap.ButtonDown(gamefunc_Open));
int const running = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
int32_t turnamount; int32_t turnamount;
int32_t keymove; int32_t keymove;
@ -165,7 +164,7 @@ getinput(InputPacket *loc, SWBOOL tied)
ApplyGlobalInput(*loc, &info); ApplyGlobalInput(*loc, &info);
if (running) if (loc->actions & SB_RUN)
{ {
if (pp->sop_control) if (pp->sop_control)
turnamount = RUNTURN * 3; turnamount = RUNTURN * 3;

View file

@ -2073,7 +2073,7 @@ DoPlayerBob(PLAYERp pp)
dist = 0; dist = 0;
// if running make a longer stride // if running make a longer stride
if (G_CheckAutorun(TEST_SYNC_KEY(pp, SK_RUN))) if (pp->input.actions & SB_RUN)
{ {
//amt = 10; //amt = 10;
amt = 12; amt = 12;
@ -2464,31 +2464,12 @@ MoveScrollMode2D(PLAYERp pp)
if (M_Active()) if (M_Active())
return; return;
#if 0
// Recenter view if told
if (buttonMap.ButtonDown(gamefunc_Center_View))
{
Follow_posx = pp->posx;
Follow_posy = pp->posy;
}
#endif
if (buttonMap.ButtonDown(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Strafe))
mfsvel -= scrl_input.dyaw / 4; mfsvel -= scrl_input.dyaw / 4;
mfsvel -= scrl_input.dx / 4; mfsvel -= scrl_input.dx / 4;
mfvel = -scrl_input.dz /4; mfvel = -scrl_input.dz /4;
#if 0
int const running = !!BUTTON(gamefunc_Run) ^ !!TEST(pp->Flags, PF_LOCK_RUN);
if (running)
{
keymove = NORMALKEYMOVE << 1;
}
else
#endif
{
keymove = NORMALKEYMOVE; keymove = NORMALKEYMOVE;
}
if (buttonMap.ButtonDown(gamefunc_Turn_Left)) if (buttonMap.ButtonDown(gamefunc_Turn_Left))
{ {