diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 11a1a77cb..ad4701c66 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -339,13 +339,13 @@ void movetransports_d(void) if (onfloorz == 0 && fabs(act->spr.pos.Z - act2->getOffsetZ()) < 24) { - if ((p->jetpack_on == 0) || (p->jetpack_on && (PlayerInput(pnum, SB_JUMP) || p->cmd.ucmd.vel.Z > 0)) || - (p->jetpack_on && (PlayerInput(pnum, SB_CROUCH) || p->cmd.ucmd.vel.Z < 0))) + if ((p->jetpack_on == 0) || (p->jetpack_on && (!!(p->cmd.ucmd.actions & SB_JUMP) || p->cmd.ucmd.vel.Z > 0)) || + (p->jetpack_on && (!!(p->cmd.ucmd.actions & SB_CROUCH) || p->cmd.ucmd.vel.Z < 0))) { act2->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY(); act2->backupvec2(); - if (p->jetpack_on && (PlayerInput(pnum, SB_JUMP) || p->jetpack_on < 11)) + if (p->jetpack_on && (!!(p->cmd.ucmd.actions & SB_JUMP) || p->jetpack_on < 11)) act2->spr.pos.Z = Owner->spr.pos.Z - 24 + gs.playerheight; else act2->spr.pos.Z = Owner->spr.pos.Z + 24 + gs.playerheight; act2->backuppos(); @@ -378,7 +378,7 @@ void movetransports_d(void) } - if (onfloorz && sectlotag == ST_1_ABOVE_WATER && p->on_ground && act2->getOffsetZ() > (sectp->floorz - 16) && (PlayerInput(pnum, SB_CROUCH) || p->cmd.ucmd.vel.Z < 0 || p->vel.Z > 8)) + if (onfloorz && sectlotag == ST_1_ABOVE_WATER && p->on_ground && act2->getOffsetZ() > (sectp->floorz - 16) && (!!(p->cmd.ucmd.actions & SB_CROUCH) || p->cmd.ucmd.vel.Z < 0 || p->vel.Z > 8)) // if( onfloorz && sectlotag == 1 && ps[p].pos.z > (sectp->floorz-(6<<8)) ) { k = 1; diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 707462998..a6faa6e61 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -309,13 +309,13 @@ void movetransports_r(void) if (onfloorz == 0 && fabs(act->spr.pos.Z - act2->getOffsetZ()) < 24) { - if ((p->jetpack_on == 0) || (p->jetpack_on && (PlayerInput(pnum, SB_JUMP) || p->cmd.ucmd.vel.Z > 0)) || - (p->jetpack_on && (PlayerInput(pnum, SB_CROUCH) || p->cmd.ucmd.vel.Z < 0))) + if ((p->jetpack_on == 0) || (p->jetpack_on && (!!(p->cmd.ucmd.actions & SB_JUMP) || p->cmd.ucmd.vel.Z > 0)) || + (p->jetpack_on && (!!(p->cmd.ucmd.actions & SB_CROUCH) || p->cmd.ucmd.vel.Z < 0))) { act2->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY(); act2->backupvec2(); - if (p->jetpack_on && (PlayerInput(pnum, SB_JUMP) || p->jetpack_on < 11)) + if (p->jetpack_on && (!!(p->cmd.ucmd.actions & SB_JUMP) || p->jetpack_on < 11)) act2->spr.pos.Z = Owner->spr.pos.Z - 24 + gs.playerheight; else act2->spr.pos.Z = Owner->spr.pos.Z + 24 + gs.playerheight; act2->backupz(); diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 878ecb64b..b75464a22 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -2002,7 +2002,7 @@ int ParseState::parse(void) double vel = g_ac->vel.X; // sigh.. this was yet another place where number literals were used as bit masks for every single value, making the code totally unreadable. - if( (l& pducking) && p->on_ground && PlayerInput(g_p, SB_CROUCH)) + if( (l& pducking) && p->on_ground && !!(p->cmd.ucmd.actions & SB_CROUCH)) j = 1; else if( (l& pfalling) && p->jumping_counter == 0 && !p->on_ground && p->vel.Z > 8 ) j = 1; @@ -2010,15 +2010,15 @@ int ParseState::parse(void) j = 1; else if( (l& pstanding) && vel >= 0 && vel < 0.5) j = 1; - else if( (l& pwalking) && vel >= 0.5 && !(PlayerInput(g_p, SB_RUN)) ) + else if( (l& pwalking) && vel >= 0.5 && !(!!(p->cmd.ucmd.actions & SB_RUN)) ) j = 1; - else if( (l& prunning) && vel >= 0.5 && PlayerInput(g_p, SB_RUN) ) + else if( (l& prunning) && vel >= 0.5 && !!(p->cmd.ucmd.actions & SB_RUN) ) j = 1; else if( (l& phigher) && pact->getOffsetZ() < g_ac->spr.pos.Z - 48) j = 1; - else if( (l& pwalkingback) && vel <= -0.5 && !(PlayerInput(g_p, SB_RUN)) ) + else if( (l& pwalkingback) && vel <= -0.5 && !(!!(p->cmd.ucmd.actions & SB_RUN)) ) j = 1; - else if( (l& prunningback) && vel <= -0.5 && (PlayerInput(g_p, SB_RUN)) ) + else if( (l& prunningback) && vel <= -0.5 && (!!(p->cmd.ucmd.actions & SB_RUN)) ) j = 1; else if( (l& pkicking) && ( p->quick_kick > 0 || ( p->curr_weapon == KNEE_WEAPON && p->kickback_pic > 0 ) ) ) j = 1; @@ -2080,7 +2080,7 @@ int ParseState::parse(void) parseifelse(int(g_ac->floorz - g_ac->ceilingz) < *insptr); // Note: int cast here is needed to use the same truncation behavior as the old fixed point code. break; case concmd_ifhitspace: - parseifelse(PlayerInput(g_p, SB_OPEN)); + parseifelse(!!(p->cmd.ucmd.actions & SB_OPEN)); break; case concmd_ifoutside: parseifelse(g_ac->sector()->ceilingstat & CSTAT_SECTOR_SKY); diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index ba7f25871..bc86a5334 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -106,11 +106,6 @@ inline bool isIn(int value, const std::initializer_list& list) } // these are mainly here to avoid directly accessing the input data so that it can be more easily refactored later. -inline bool PlayerInput(int pl, ESyncBits bit) -{ - return (!!((getPlayer(pl)->cmd.ucmd.actions) & bit)); -} - inline void PlayerSetItemUsed(int pl, int num) { getPlayer(pl)->cmd.ucmd.setItemUsed(num - 1); diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 9593739a4..f13a29a6b 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -60,7 +60,7 @@ void hud_input(int plnum) auto pact = p->GetActor(); i = p->aim_mode; - p->aim_mode = !PlayerInput(plnum, SB_AIMMODE); + p->aim_mode = !!!(p->cmd.ucmd.actions & SB_AIMMODE); if (p->aim_mode < i) p->cmd.ucmd.actions |= SB_CENTERVIEW; @@ -76,7 +76,7 @@ void hud_input(int plnum) if (isRR()) { - if (PlayerInput(plnum, SB_QUICK_KICK) && p->last_pissed_time == 0) + if (!!(p->cmd.ucmd.actions & SB_QUICK_KICK) && p->last_pissed_time == 0) { if (!isRRRA() || p->GetActor()->spr.extra > 0) { @@ -94,7 +94,7 @@ void hud_input(int plnum) } else { - if (PlayerInput(plnum, SB_QUICK_KICK) && p->quick_kick == 0 && (p->curr_weapon != KNEE_WEAPON || p->kickback_pic == 0)) + if (!!(p->cmd.ucmd.actions & SB_QUICK_KICK) && p->quick_kick == 0 && (p->curr_weapon != KNEE_WEAPON || p->kickback_pic == 0)) { SetGameVarID(g_iReturnVarID, 0, nullptr, plnum); OnEvent(EVENT_QUICKKICK, plnum, nullptr, -1); @@ -106,7 +106,7 @@ void hud_input(int plnum) } } } - if (!PlayerInput(plnum, SB_QUICK_KICK)) p->quick_kick_msg = false; + if (!!!(p->cmd.ucmd.actions & SB_QUICK_KICK)) p->quick_kick_msg = false; if (!(p->cmd.ucmd.actions & SB_INTERFACE_BITS)) p->interface_toggle_flag = 0; @@ -119,7 +119,7 @@ void hud_input(int plnum) if (p->GetActor()->spr.extra <= 0) return; // Activate an inventory item. This just forwards to the other inventory bits. If the inventory selector was taken out of the playsim this could be removed. - if (PlayerInput(plnum, SB_INVUSE) && p->newOwner == nullptr) + if (!!(p->cmd.ucmd.actions & SB_INVUSE) && p->newOwner == nullptr) { SetGameVarID(g_iReturnVarID, 0, nullptr, plnum); OnEvent(EVENT_INVENTORY, plnum, nullptr, -1); @@ -159,11 +159,11 @@ void hud_input(int plnum) return; } - if (PlayerInput(plnum, SB_INVPREV) || PlayerInput(plnum, SB_INVNEXT)) + if (!!(p->cmd.ucmd.actions & SB_INVPREV) || !!(p->cmd.ucmd.actions & SB_INVNEXT)) { p->invdisptime = 26 * 2; - if (PlayerInput(plnum, SB_INVNEXT)) k = 1; + if (!!(p->cmd.ucmd.actions & SB_INVNEXT)) k = 1; else k = 0; dainv = p->inven_icon; @@ -225,13 +225,13 @@ void hud_input(int plnum) else dainv = 0; // These events force us to keep the inventory selector in the playsim as opposed to the UI where it really belongs. - if (PlayerInput(plnum, SB_INVPREV)) + if (!!(p->cmd.ucmd.actions & SB_INVPREV)) { SetGameVarID(g_iReturnVarID, dainv, nullptr, plnum); OnEvent(EVENT_INVENTORYLEFT, plnum, nullptr, -1); dainv = GetGameVarID(g_iReturnVarID, nullptr, plnum).safeValue(); } - if (PlayerInput(plnum, SB_INVNEXT)) + if (!!(p->cmd.ucmd.actions & SB_INVNEXT)) { SetGameVarID(g_iReturnVarID, dainv, nullptr, plnum); OnEvent(EVENT_INVENTORYRIGHT, plnum, nullptr, -1); @@ -250,7 +250,7 @@ void hud_input(int plnum) // Here we have to be extra careful that the weapons do not get mixed up, so let's keep the code for Duke and RR completely separate. fi.selectweapon(plnum, weap); - if (PlayerInput(plnum, SB_HOLSTER)) + if (!!(p->cmd.ucmd.actions & SB_HOLSTER)) { if (p->curr_weapon > KNEE_WEAPON) { @@ -476,7 +476,7 @@ void hud_input(int plnum) } } - if (PlayerInput(plnum, SB_TURNAROUND) && p->Angles.YawSpin == nullAngle && p->on_crane == nullptr) + if (!!(p->cmd.ucmd.actions & SB_TURNAROUND) && p->Angles.YawSpin == nullAngle && p->on_crane == nullptr) { SetGameVarID(g_iReturnVarID, 0, nullptr, plnum); OnEvent(EVENT_TURNAROUND, plnum, nullptr, -1); diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 12d8a2ac8..cfd50e2c5 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -1330,7 +1330,7 @@ int checkp(DDukeActor* self, DDukePlayer* p, int flags) unsigned plindex = unsigned(p->pnum); // sigh.. this was yet another place where number literals were used as bit masks for every single value, making the code totally unreadable. - if ((flags & pducking) && p->on_ground && PlayerInput(plindex, SB_CROUCH)) + if ((flags & pducking) && p->on_ground && !!(p->cmd.ucmd.actions & SB_CROUCH)) j = 1; else if ((flags & pfalling) && p->jumping_counter == 0 && !p->on_ground && p->vel.Z > 8) j = 1; @@ -1338,15 +1338,15 @@ int checkp(DDukeActor* self, DDukePlayer* p, int flags) j = 1; else if ((flags & pstanding) && vel >= 0 && vel < 0.5) j = 1; - else if ((flags & pwalking) && vel >= 0.5 && !(PlayerInput(plindex, SB_RUN))) + else if ((flags & pwalking) && vel >= 0.5 && !(!!(p->cmd.ucmd.actions & SB_RUN))) j = 1; - else if ((flags & prunning) && vel >= 0.5 && PlayerInput(plindex, SB_RUN)) + else if ((flags & prunning) && vel >= 0.5 && !!(p->cmd.ucmd.actions & SB_RUN)) j = 1; else if ((flags & phigher) && p->GetActor()->getOffsetZ() < self->spr.pos.Z - 48) j = 1; - else if ((flags & pwalkingback) && vel <= -0.5 && !(PlayerInput(plindex, SB_RUN))) + else if ((flags & pwalkingback) && vel <= -0.5 && !(!!(p->cmd.ucmd.actions & SB_RUN))) j = 1; - else if ((flags & prunningback) && vel <= -0.5 && (PlayerInput(plindex, SB_RUN))) + else if ((flags & prunningback) && vel <= -0.5 && (!!(p->cmd.ucmd.actions & SB_RUN))) j = 1; else if ((flags & pkicking) && (p->quick_kick > 0 || (p->curr_weapon == KNEE_WEAPON && p->kickback_pic > 0))) j = 1; diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 40d879edf..08f40e751 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -521,7 +521,7 @@ int doincrements_d(DDukePlayer* p) } S_PlayActorSound(DUKE_CRACK_FIRST, pact); } - else if (p->knuckle_incs == 22 || PlayerInput(snum, SB_FIRE)) + else if (p->knuckle_incs == 22 || !!(p->cmd.ucmd.actions & SB_FIRE)) p->knuckle_incs = 0; return 1; diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index fc8c72a49..d7e116e9a 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -586,7 +586,7 @@ int doincrements_r(DDukePlayer* p) else S_PlayActorSound(DUKE_CRACK2, pact); } } - else if (p->knuckle_incs == 22 || PlayerInput(snum, SB_FIRE)) + else if (p->knuckle_incs == 22 || !!(p->cmd.ucmd.actions & SB_FIRE)) p->knuckle_incs = 0; return 1; diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index a47b1d9ce..637f60edf 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -223,7 +223,7 @@ void checksectors_d(int snum) if (chatmodeon || p->GetActor()->spr.extra <= 0) return; - if (ud.cashman && PlayerInput(snum, SB_OPEN)) + if (ud.cashman && !!(p->cmd.ucmd.actions & SB_OPEN)) lotsofstuff(p->GetActor(), 2, DukeMailClass); if (p->newOwner != nullptr) @@ -233,14 +233,14 @@ void checksectors_d(int snum) clearcameras(p); return; } - else if (PlayerInput(snum, SB_ESCAPE)) + else if (!!(p->cmd.ucmd.actions & SB_ESCAPE)) { clearcameras(p); return; } } - if (!(PlayerInput(snum, SB_OPEN))) + if (!(!!(p->cmd.ucmd.actions & SB_OPEN))) p->toggle_key_flag = 0; else if (!p->toggle_key_flag) @@ -312,7 +312,7 @@ void checksectors_d(int snum) return; } - if (!PlayerInput(snum, SB_OPEN)) return; + if (!!!(p->cmd.ucmd.actions & SB_OPEN)) return; else if (p->newOwner != nullptr) { clearcameras(p); diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 6ab9f94fa..50e98169c 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -205,11 +205,11 @@ void checksectors_r(int snum) if (chatmodeon || p->GetActor()->spr.extra <= 0) return; - if (ud.cashman && PlayerInput(snum, SB_OPEN)) + if (ud.cashman && !!(p->cmd.ucmd.actions & SB_OPEN)) lotsofstuff(p->GetActor(), 2, DukeMailClass); - if (!(PlayerInput(snum, SB_OPEN))) + if (!(!!(p->cmd.ucmd.actions & SB_OPEN))) p->toggle_key_flag = 0; else if (!p->toggle_key_flag) @@ -339,7 +339,7 @@ void checksectors_r(int snum) } } - if (!PlayerInput(snum, SB_OPEN)) return; + if (!!!(p->cmd.ucmd.actions & SB_OPEN)) return; if (near.hitWall == nullptr && near.hitSector == nullptr && near.actor() == nullptr) if (hits(p->GetActor()) < 32)