diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 249545a3d..aec358c6b 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -74,6 +74,7 @@ char gUserMapFilename[BMAX_PATH]; short BloodVersion = 0x115; int gNetPlayers; +int gQuitRequest; int gChokeCounter = 0; @@ -81,7 +82,6 @@ double g_gameUpdateTime, g_gameUpdateAndDrawTime; double g_gameUpdateAvgTime = 0.001; bool gQuitGame; -int gQuitRequest; enum gametokens { @@ -522,7 +522,6 @@ bool gRestartGame = false; void ProcessFrame(void) { - char buffer[128]; for (int i = connecthead; i >= 0; i = connectpoint2[i]) { auto& inp = gPlayer[i].input; @@ -538,6 +537,7 @@ void ProcessFrame(void) } gNetFifoTail++; +#if 0 for (int i = connecthead; i >= 0; i = connectpoint2[i]) { if (gPlayer[i].input.syncFlags.quit) @@ -561,6 +561,7 @@ void ProcessFrame(void) return; } } +#endif viewClearInterpolations(); { if (paused || gEndGameMgr.at0 || (gGameOptions.nGameType == 0 && M_Active())) @@ -703,7 +704,6 @@ void GameInterface::app_init() Printf(PRINT_NONOTIFY, "Initializing sound system\n"); sndInit(); registerosdcommands(); - registerinputcommands(); gChoke.sub_83ff0(518, sub_84230); UpdateDacs(0, true); @@ -792,8 +792,10 @@ static void drawBackground() { twod->ClearScreen(); DrawTexture(twod, tileGetTexture(2518, true), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE); +#if 0 if (gQuitRequest && !gQuitGame) netBroadcastMyLogoff(gQuitRequest == 2); +#endif } static void commonTicker() diff --git a/source/blood/src/blood.h b/source/blood/src/blood.h index 71b77fc59..10fecd4a6 100644 --- a/source/blood/src/blood.h +++ b/source/blood/src/blood.h @@ -87,7 +87,6 @@ struct GameInterface : ::GameInterface void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position, bool bg) override; void QuitToTitle() override; FString GetCoordString() override; - void clearlocalinputstate() override; ReservedSpace GetReservedScreenSpace(int viewsize) override; GameStats getStats() override; diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index 51e71e09d..253fa90cc 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -44,8 +44,6 @@ InputPacket gInput, gNetInput; bool bSilentAim = false; int iTurnCount = 0; -static int WeaponToSend; -static SYNCFLAGS BitsToSend; void ctrlInit(void) { @@ -131,7 +129,7 @@ void ctrlGetInput(void) InputPacket input = {}; bool mouseaim = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming); - if (!mouseaim) gInput.syncFlags.lookCenter = 1; + if (!mouseaim) gInput.actions |= SB_CENTERVIEW; if (numplayers == 1) { @@ -141,15 +139,8 @@ void ctrlGetInput(void) CONTROL_GetInput(&info); - if (gQuitRequest) - gInput.syncFlags.quit = 1; - - gInput.syncFlags.value |= BitsToSend.value; ApplyGlobalInput(gInput, &info); - BitsToSend.value = 0; - WeaponToSend = 0; - if (buttonMap.ButtonDown(gamefunc_Shrink_Screen)) { if (automapMode != am_off) @@ -200,7 +191,7 @@ void ctrlGetInput(void) gInput.syncFlags.lookDown |= buttonMap.ButtonDown(gamefunc_Look_Down); if (buttonMap.ButtonDown(gamefunc_Look_Up) || buttonMap.ButtonDown(gamefunc_Look_Down)) - gInput.syncFlags.lookCenter = 1; + gInput.actions |= SB_CENTERVIEW; else { gInput.syncFlags.lookUp |= buttonMap.ButtonDown(gamefunc_Aim_Up); @@ -332,26 +323,4 @@ void ctrlGetInput(void) } } -//--------------------------------------------------------------------------- -// -// CCMD based input. The basics are from Randi's ZDuke but this uses dynamic -// registration to only have the commands active when this game module runs. -// -//--------------------------------------------------------------------------- - -void registerinputcommands() -{ - C_RegisterFunction("centerview", nullptr, [](CCmdFuncPtr)->int { BitsToSend.lookCenter = 1; return CCMD_OK; }); - C_RegisterFunction("holsterweapon", nullptr, [](CCmdFuncPtr)->int { BitsToSend.holsterWeapon = 1; return CCMD_OK; }); - C_RegisterFunction("turnaround", nullptr, [](CCmdFuncPtr)->int { BitsToSend.spin180 = 1; return CCMD_OK; }); -} - -// This is called from ImputState::ClearAllInput and resets all static state being used here. -void GameInterface::clearlocalinputstate() -{ - WeaponToSend = 0; - BitsToSend.value = 0; -} - - END_BLD_NS diff --git a/source/blood/src/d_menu.cpp b/source/blood/src/d_menu.cpp index 00c78acd9..6a6182dc3 100644 --- a/source/blood/src/d_menu.cpp +++ b/source/blood/src/d_menu.cpp @@ -295,8 +295,7 @@ void GameInterface::QuitToTitle() gQuitGame = true; gRestartGame = true; } - else - gQuitRequest = 2; + //else gQuitRequest = 2; } END_BLD_NS diff --git a/source/blood/src/misc.h b/source/blood/src/misc.h index 1afdcbf49..e6d5762a7 100644 --- a/source/blood/src/misc.h +++ b/source/blood/src/misc.h @@ -42,7 +42,6 @@ void sub_5571C(char mode); void sub_557C4(int x, int y, int interpolation); void DrawMirrors(int x, int y, int z, fix16_t a, fix16_t horiz, int smooth, int viewPlayer); int32_t registerosdcommands(void); -void registerinputcommands(void); int qanimateoffs(int a1, int a2); int32_t qgetpalookup(int32_t a1, int32_t a2); void HookReplaceFunctions(); diff --git a/source/core/inputstate.cpp b/source/core/inputstate.cpp index db2f46148..0529da3dc 100644 --- a/source/core/inputstate.cpp +++ b/source/core/inputstate.cpp @@ -295,6 +295,21 @@ CCMD(invuse) ActionsToSend |= SB_INVUSE; } +CCMD(centerview) +{ + ActionsToSend |= SB_CENTERVIEW; +} + +CCMD(turnaround) +{ + ActionsToSend |= SB_TURNAROUND; +} + +CCMD(holsterweapon) +{ + ActionsToSend |= SB_HOLSTER; +} + CCMD(pause) { sendPause = true; @@ -328,4 +343,25 @@ void ApplyGlobalInput(InputPacket& input, ControlInfo *info) input.actions |= ActionsToSend; ActionsToSend = 0; -} \ No newline at end of file +} + +#if 0 +void registerinputcommands() +{ + C_RegisterFunction("centerview", nullptr, [](CCmdFuncPtr)->int { BitsToSend.lookCenter = 1; return CCMD_OK; }); + C_RegisterFunction("holsterweapon", nullptr, [](CCmdFuncPtr)->int { BitsToSend.holsterWeapon = 1; return CCMD_OK; }); + C_RegisterFunction("turnaround", nullptr, [](CCmdFuncPtr)->int { BitsToSend.spin180 = 1; return CCMD_OK; }); +} + +//--------------------------------------------------------------------------- +// +// CCMD based input. The basics are from Randi's ZDuke but this uses dynamic +// registration to only have the commands active when this game module runs. +// +//--------------------------------------------------------------------------- + + C_RegisterFunction("backoff", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_ESCAPE; return CCMD_OK; }); +} + + +#endif diff --git a/source/core/inputstate.h b/source/core/inputstate.h index 1c28311d8..d33614389 100644 --- a/source/core/inputstate.h +++ b/source/core/inputstate.h @@ -66,11 +66,11 @@ int32_t handleevents(void); enum GameFunction_t { - gamefunc_Move_Forward, - gamefunc_Move_Backward, - gamefunc_Turn_Left, - gamefunc_Turn_Right, - gamefunc_Strafe, + gamefunc_Move_Forward, // + gamefunc_Move_Backward, // + gamefunc_Turn_Left, // + gamefunc_Turn_Right, // + gamefunc_Strafe, // gamefunc_Fire, gamefunc_Open, gamefunc_Run, @@ -81,8 +81,8 @@ enum GameFunction_t gamefunc_Look_Down, gamefunc_Look_Left, gamefunc_Look_Right, - gamefunc_Strafe_Left, - gamefunc_Strafe_Right, + gamefunc_Strafe_Left, // + gamefunc_Strafe_Right, // gamefunc_Aim_Up, gamefunc_Aim_Down, gamefunc_Shrink_Screen, // Automap only diff --git a/source/core/packet.h b/source/core/packet.h index e856e962a..53d9de8ba 100644 --- a/source/core/packet.h +++ b/source/core/packet.h @@ -18,14 +18,17 @@ enum ESyncBits_ : uint32_t SB_INVPREV = 1 << 11, SB_INVNEXT = 1 << 12, SB_INVUSE = 1 << 13, - + SB_CENTERVIEW = 1 << 14, + SB_TURNAROUND = 1 << 15, + SB_HOLSTER = 1 << 16, SB_WEAPONMASK_BITS = (15u * SB_FIRST_WEAPON_BIT), // Weapons take up 4 bits SB_ITEMUSE_BITS = (127u * SB_ITEM_BIT_1), SB_BUTTON_MASK = 0, // all input from buttons (i.e. active while held) - SB_INTERFACE_MASK = (SB_INVPREV|SB_INVNEXT|SB_INVUSE), // all input from CCMDs - SB_INTERFACE_BITS = (SB_WEAPONMASK_BITS | SB_ITEMUSE_BITS | SB_INTERFACE_MASK) + SB_INTERFACE_MASK = (SB_INVPREV|SB_INVNEXT|SB_INVUSE|SB_CENTERVIEW|SB_TURNAROUND|SB_HOLSTER), // all input from CCMDs + SB_INTERFACE_BITS = (SB_WEAPONMASK_BITS | SB_ITEMUSE_BITS | SB_INTERFACE_MASK), + SB_ALL = ~0u }; // enforce type safe operations on the input bits. @@ -67,19 +70,13 @@ enum EDukeSyncBits_ : uint32_t SKB_LOOK_RIGHT = 1 << 7, SKB_LOOK_UP = 1 << 13, SKB_LOOK_DOWN = 1 << 14, - SKB_MULTIFLAG = 1 << 17, - SKB_CENTER_VIEW = 1 << 18, - SKB_HOLSTER = 1 << 19, SKB_QUICK_KICK = 1 << 22, SKB_AIMMODE = 1 << 23, - SKB_GAMEQUIT = 1 << 26, - SKB_TURNAROUND = 1 << 28, SKB_OPEN = 1 << 29, SKB_ESCAPE = 1u << 31, SKB_INTERFACE_BITS = (SKB_QUICK_KICK | \ - SKB_HOLSTER | \ - SKB_TURNAROUND | SKB_OPEN | SKB_ESCAPE), + SKB_OPEN | SKB_ESCAPE), SKB_NONE = 0, SKB_ALL = ~0u @@ -102,15 +99,12 @@ union SYNCFLAGS unsigned int shoot2 : 1; unsigned int lookUp : 1; unsigned int lookDown : 1; + + unsigned int action : 1; unsigned int jab : 1; - unsigned int holsterWeapon : 1; - unsigned int lookCenter : 1; unsigned int lookLeft : 1; unsigned int lookRight : 1; - unsigned int spin180 : 1; - unsigned int quit : 1; - unsigned int restart : 1; }; }; @@ -122,9 +116,7 @@ union SYNCFLAGS #define SK_AUTO_AIM 7 -#define SK_CENTER_VIEW 8 -#define SK_MESSAGE 11 #define SK_LOOK_UP 12 #define SK_LOOK_DOWN 13 #define SK_CRAWL_LOCK 14 @@ -137,11 +129,7 @@ union SYNCFLAGS #define SK_CRAWL 20 #define SK_SNAP_UP 21 #define SK_SNAP_DOWN 22 -#define SK_QUIT_GAME 23 -#define SK_TURN_180 25 - -#define SK_HIDE_WEAPON 30 #define SK_SPACE_BAR 31 diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 099eca5cc..8221d88af 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -51,6 +51,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS +extern short bPlayerPan; +extern short bLockPan; extern const char* s_buildRev; extern const char* s_buildTimestamp; @@ -58,7 +60,6 @@ BEGIN_PS_NS void uploadCinemaPalettes(); int32_t registerosdcommands(void); -void registerinputcommands(); void InitFonts(); int htimer = 0; @@ -584,7 +585,17 @@ void GameTicker() } } - + if (localInput.actions & SB_CENTERVIEW) + { + bLockPan = false; + bPlayerPan = false; + PlayerList[nLocalPlayer].q16horiz = fix16_from_int(92); + nDestVertPan[nLocalPlayer] = fix16_from_int(92); + } + if (localInput.actions & SB_TURNAROUND) + { + // todo + } sPlayerInput[nLocalPlayer].xVel = lPlayerXVel; @@ -687,7 +698,6 @@ void GameInterface::app_init() SetCheats(excheats, countof(excheats)); registerosdcommands(); - registerinputcommands(); if (nNetPlayerCount == -1) { nNetPlayerCount = nCfgNetPlayers - 1; diff --git a/source/exhumed/src/exhumed.h b/source/exhumed/src/exhumed.h index a68d9b27a..8848d506c 100644 --- a/source/exhumed/src/exhumed.h +++ b/source/exhumed/src/exhumed.h @@ -252,7 +252,6 @@ struct GameInterface : ::GameInterface bool SaveGame(FSaveGameNode* sv) override; bool CanSave() override; ReservedSpace GetReservedScreenSpace(int viewsize) override { return { 0, 24 }; } - void clearlocalinputstate() override; void QuitToTitle(); FString statFPS() override; diff --git a/source/exhumed/src/input.cpp b/source/exhumed/src/input.cpp index 4b748f42f..55e923bbf 100644 --- a/source/exhumed/src/input.cpp +++ b/source/exhumed/src/input.cpp @@ -31,7 +31,6 @@ BEGIN_PS_NS extern short bPlayerPan; extern short bLockPan; -int BitsToSend; bool g_MyAimMode; short nInputStack = 0; @@ -371,32 +370,4 @@ void PlayerInterruptKeys(bool after) } - -//--------------------------------------------------------------------------- -// -// CCMD based input. The basics are from Randi's ZDuke but this uses dynamic -// registration to only have the commands active when this game module runs. -// -//--------------------------------------------------------------------------- - -int ccmd_centerview(CCmdFuncPtr parm); - - -void registerinputcommands() -{ - C_RegisterFunction("centerview", nullptr, ccmd_centerview); - - // These are only here to silence the engine when the keys bound to them are pressed. The functions do not exist. - C_RegisterFunction("turnaround", nullptr, [](CCmdFuncPtr)->int { return CCMD_OK; }); - C_RegisterFunction("holsterweapon", nullptr, [](CCmdFuncPtr)->int { return CCMD_OK; }); - -} - -// This is called from ImputState::ClearAllInput and resets all static state being used here. -void GameInterface::clearlocalinputstate() -{ - BitsToSend = 0; - -} - - END_PS_NS +END_PS_NS diff --git a/source/exhumed/src/player.cpp b/source/exhumed/src/player.cpp index 5b8fecc45..1d8eb9725 100644 --- a/source/exhumed/src/player.cpp +++ b/source/exhumed/src/player.cpp @@ -2870,17 +2870,6 @@ loc_1BD2E: } } -int ccmd_centerview(CCmdFuncPtr parm) -{ - return CCMD_OK; - bLockPan = false; - bPlayerPan = false; - PlayerList[nLocalPlayer].q16horiz = fix16_from_int(92); - nDestVertPan[nLocalPlayer] = fix16_from_int(92); - return CCMD_OK; -} - - static SavegameHelper sgh("player", SV(lPlayerXVel), SV(lPlayerYVel), diff --git a/source/games/duke/src/game.cpp b/source/games/duke/src/game.cpp index caa264c8f..0bd44c3f2 100644 --- a/source/games/duke/src/game.cpp +++ b/source/games/duke/src/game.cpp @@ -47,7 +47,6 @@ BEGIN_DUKE_NS void SetDispatcher(); void InitCheats(); int registerosdcommands(void); -void registerinputcommands(void); //--------------------------------------------------------------------------- // @@ -331,7 +330,6 @@ static void Startup(void) InitCheats(); checkcommandline(); registerosdcommands(); - registerinputcommands(); screenpeek = myconnectindex; ps[myconnectindex].palette = BASEPAL; diff --git a/source/games/duke/src/gameloop.cpp b/source/games/duke/src/gameloop.cpp index c0ec5f9bc..6f46fce67 100644 --- a/source/games/duke/src/gameloop.cpp +++ b/source/games/duke/src/gameloop.cpp @@ -197,6 +197,7 @@ int domovethings() GetNextInput(); updateinterpolations(); +#if 0 j = -1; for (i = connecthead; i >= 0; i = connectpoint2[i]) { @@ -227,6 +228,7 @@ int domovethings() } else j = i; } +#endif //if(ud.recstat == 1) record(); diff --git a/source/games/duke/src/global.cpp b/source/games/duke/src/global.cpp index cbe177461..831fcfb9d 100644 --- a/source/games/duke/src/global.cpp +++ b/source/games/duke/src/global.cpp @@ -65,7 +65,6 @@ int PHEIGHT = PHEIGHT_DUKE; int duke3d_globalflags; InputPacket loc; uint8_t ready2send; -int gamequit; int playerswhenstarted; int show_shareware; int screenpeek; diff --git a/source/games/duke/src/global.h b/source/games/duke/src/global.h index b9ac45b74..19493020b 100644 --- a/source/games/duke/src/global.h +++ b/source/games/duke/src/global.h @@ -52,7 +52,6 @@ extern int32_t PHEIGHT; extern int duke3d_globalflags; extern uint8_t ready2send; extern InputPacket loc; -extern int gamequit; extern int playerswhenstarted; extern int show_shareware; extern int screenpeek; diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index 93b4d0f14..ec03613aa 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -146,6 +146,12 @@ inline ESyncBits PlayerInputBits(int pl, ESyncBits bits) return (sync[pl].actions & bits); } +inline void PlayerSetInput(int pl, ESyncBits bit) +{ + sync[pl].actions |= bit; +} + + inline int PlayerNewWeapon(int pl) { return sync[pl].getNewWeapon(); diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 7e27e95ac..b59cddc1f 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -39,8 +39,6 @@ source as it is released. BEGIN_DUKE_NS -static EDukeSyncBits BitsToSend; - // State timer counters. static int nonsharedtimer; static int turnheldtime; @@ -336,7 +334,7 @@ void hud_input(int snum) // 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(snum, weap); - if (PlayerInput(snum, SKB_HOLSTER)) + if (PlayerInput(snum, SB_HOLSTER)) { if (p->curr_weapon > KNEE_WEAPON) { @@ -564,7 +562,7 @@ void hud_input(int snum) } } - if (PlayerInput(snum, SKB_TURNAROUND) && p->one_eighty_count == 0) + if (PlayerInput(snum, SB_TURNAROUND) && p->one_eighty_count == 0) { SetGameVarID(g_iReturnVarID, 0, -1, snum); OnEvent(EVENT_TURNAROUND, -1, snum, -1); @@ -612,13 +610,6 @@ static void processInputBits(player_struct *p, ControlInfo &info) if (buttonMap.ButtonDown(gamefunc_Fire)) loc.sbits |= SKB_FIRE; if (buttonMap.ButtonDown(gamefunc_Open)) loc.sbits |= SKB_OPEN; - // These 3 bits are only available when not riding a bike or boat. - if (onVehicle) BitsToSend &= ~(SKB_HOLSTER|SKB_TURNAROUND|SKB_CENTER_VIEW); - loc.sbits |= BitsToSend; - BitsToSend = 0; - - if (gamequit) loc.sbits |= SKB_GAMEQUIT; - if (!onVehicle) { if (buttonMap.ButtonDown(gamefunc_Jump)) loc.sbits |= SKB_JUMP; @@ -637,7 +628,12 @@ static void processInputBits(player_struct *p, ControlInfo &info) if (buttonMap.ButtonDown(gamefunc_Quick_Kick)) loc.sbits |= SKB_QUICK_KICK; if (in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming)) loc.sbits |= SKB_AIMMODE; - ApplyGlobalInput(loc, &info); + } + ApplyGlobalInput(loc, &info); + if (onVehicle) + { + // mask out all actions not compatible with vehicles. + loc.actions &= ~(SB_WEAPONMASK_BITS | SB_TURNAROUND | SB_CENTERVIEW | SB_HOLSTER); } if (buttonMap.ButtonDown(gamefunc_Dpad_Aiming)) @@ -1102,7 +1098,6 @@ void GetInput() if (paused) { loc = {}; - if (gamequit) loc.sbits |= SKB_GAMEQUIT; return; } @@ -1145,26 +1140,9 @@ void GetInput() } } -//--------------------------------------------------------------------------- -// -// CCMD based input. The basics are from Randi's ZDuke but this uses dynamic -// registration to only have the commands active when this game module runs. -// -//--------------------------------------------------------------------------- - -void registerinputcommands() -{ - C_RegisterFunction("centerview", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_CENTER_VIEW; return CCMD_OK; }); - C_RegisterFunction("holsterweapon", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_HOLSTER; return CCMD_OK; }); - - C_RegisterFunction("turnaround", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_TURNAROUND; return CCMD_OK; }); - C_RegisterFunction("backoff", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_ESCAPE; return CCMD_OK; }); -} - // This is called from ImputState::ClearAllInput and resets all static state being used here. void GameInterface::clearlocalinputstate() { - BitsToSend = 0; nonsharedtimer = 0; turnheldtime = 0; lastcontroltime = 0; diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 521f1540b..2186a93f2 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -1264,7 +1264,7 @@ void selectweapon_d(int snum, int weap) // playernum, weaponnum if (p->holster_weapon) { - PlayerSetInput(snum, SKB_HOLSTER); + PlayerSetInput(snum, SB_HOLSTER); p->weapon_pos = -9; } else if (j >= MIN_WEAPON && p->gotweapon[j] && (unsigned int)p->curr_weapon != j) switch (j) @@ -2518,14 +2518,14 @@ static void operateweapon(int snum, EDukeSyncBits sb_snum, int psect) // //--------------------------------------------------------------------------- -static void processweapon(int snum, EDukeSyncBits sb_snum, int psect) +static void processweapon(int snum, ESyncBits actions, EDukeSyncBits sb_snum, int psect) { auto p = &ps[snum]; int pi = p->i; auto s = &sprite[pi]; int shrunk = (s->yrepeat < 32); - if (isNamWW2GI() && (sb_snum & SKB_HOLSTER)) // 'Holster Weapon + if (isNamWW2GI() && (actions & SB_HOLSTER)) // 'Holster Weapon { if (isWW2GI()) { @@ -2604,6 +2604,7 @@ void processinput_d(int snum) int j, i, k, doubvel, fz, cz, hz, lz, truefdist; char shrunk; EDukeSyncBits sb_snum; + ESyncBits actions; short psect, psectlotag, pi; struct player_struct* p; spritetype* s; @@ -2615,6 +2616,7 @@ void processinput_d(int snum) resetinputhelpers(p); sb_snum = PlayerInputBits(snum, SKB_ALL); + actions = PlayerInputBits(snum, SB_ALL); auto sb_fvel = PlayerInputForwardVel(snum); auto sb_svel = PlayerInputSideVel(snum); @@ -2737,8 +2739,8 @@ void processinput_d(int snum) fi.doincrements(p); - if (isWW2GI() && aplWeaponWorksLike[p->curr_weapon][snum] == HANDREMOTE_WEAPON) processweapon(snum, sb_snum, psect); - if (!isWW2GI() && p->curr_weapon == HANDREMOTE_WEAPON) processweapon(snum, sb_snum, psect); + if (isWW2GI() && aplWeaponWorksLike[p->curr_weapon][snum] == HANDREMOTE_WEAPON) processweapon(snum, actions, sb_snum, psect); + if (!isWW2GI() && p->curr_weapon == HANDREMOTE_WEAPON) processweapon(snum, actions, sb_snum, psect); return; } @@ -3001,7 +3003,7 @@ HORIZONLY: } // center_view - if (sb_snum & SKB_CENTER_VIEW || p->hard_landing) + if (actions & SB_CENTERVIEW || p->hard_landing) { playerCenterView(snum); } @@ -3066,12 +3068,7 @@ HORIZONLY: } // HACKS - processweapon(snum, sb_snum, psect); -} - -void processweapon_d(int s, EDukeSyncBits ss, int p) -{ - processweapon(s, ss, p); + processweapon(snum, actions, sb_snum, psect); } void processmove_d(int snum, EDukeSyncBits sb_snum, int psect, int fz, int cz, int shrunk, int truefdist) diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index e176dab8f..9aba0c134 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -1067,7 +1067,7 @@ void selectweapon_r(int snum, int weap) if (p->holster_weapon) { - PlayerSetInput(snum, SKB_HOLSTER); + PlayerSetInput(snum, SB_HOLSTER); p->weapon_pos = -9; } else if (j >= MIN_WEAPON && p->gotweapon[j] && p->curr_weapon != j) switch (j) @@ -3402,6 +3402,7 @@ void processinput_r(int snum) int j, i, k, doubvel, fz, cz, hz, lz, truefdist, var60; char shrunk; EDukeSyncBits sb_snum; + ESyncBits actions; short psect, psectlotag, pi; struct player_struct* p; spritetype* s; @@ -3413,6 +3414,7 @@ void processinput_r(int snum) resetinputhelpers(p); sb_snum = PlayerInputBits(snum, SKB_ALL); + actions = PlayerInputBits(snum, SB_ALL); auto sb_fvel = PlayerInputForwardVel(snum); auto sb_svel = PlayerInputSideVel(snum); @@ -4027,7 +4029,7 @@ HORIZONLY: return; } - if (sb_snum & SKB_CENTER_VIEW || p->hard_landing) + if (actions & SB_CENTERVIEW || p->hard_landing) { playerCenterView(snum); } @@ -4103,11 +4105,6 @@ HORIZONLY: // //--------------------------------------------------------------------------- -void processweapon_r(int s, EDukeSyncBits ss, int p) -{ - processweapon(s, ss, p); -} - void processmove_r(int snum, EDukeSyncBits sb_snum, int psect, int fz, int cz, int shrunk, int truefdist) { int psectlotag = sector[psect].lotag; diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index e67c1283d..afb15ed02 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -198,7 +198,6 @@ void GameInterface::app_init() Printf("Copyright (c) 1997 3D Realms Entertainment\n"); registerosdcommands(); - registerinputcommands(); engineInit(); auto pal = fileSystem.LoadFile("3drealms.pal", 0); diff --git a/source/sw/src/game.h b/source/sw/src/game.h index b1b4244a0..a3bae2c55 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -2223,7 +2223,6 @@ void LoadSaveMsg(const char *msg); void UpdateStatusBar(int arg); void InitFonts(); int32_t registerosdcommands(void); -void registerinputcommands(); void SW_InitMultiPsky(void); extern int PlayClock; @@ -2269,7 +2268,6 @@ struct GameInterface : ::GameInterface void SetAmbience(bool on) override { if (on) StartAmbientSound(); else StopAmbientSound(); } FString GetCoordString() override; ReservedSpace GetReservedScreenSpace(int viewsize) override; - void clearlocalinputstate() override; void QuitToTitle() override; void ResetFollowPos(bool message) override; diff --git a/source/sw/src/input.cpp b/source/sw/src/input.cpp index 49bbdaa18..5941e0f85 100644 --- a/source/sw/src/input.cpp +++ b/source/sw/src/input.cpp @@ -34,11 +34,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms BEGIN_SW_NS -SWBOOL MultiPlayQuitFlag = FALSE; - -int BitsToSend = 0; - - void FunctionKeys(PLAYERp pp) { @@ -118,9 +113,6 @@ getinput(InputPacket *loc, SWBOOL tied) lastInputTicks = currentHiTicks; - // MAKE SURE THIS WILL GET SET - SET_LOC_KEY(loc->bits, SK_QUIT_GAME, MultiPlayQuitFlag); - bool mouseaim = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming); if (!CommEnabled) @@ -419,9 +411,6 @@ getinput(InputPacket *loc, SWBOOL tied) } - loc->bits |= BitsToSend; - BitsToSend = 0; - SET_LOC_KEY(loc->bits, SK_OPERATE, buttonMap.ButtonDown(gamefunc_Open)); SET_LOC_KEY(loc->bits, SK_JUMP, buttonMap.ButtonDown(gamefunc_Jump)); SET_LOC_KEY(loc->bits, SK_CRAWL, buttonMap.ButtonDown(gamefunc_Crouch)); @@ -459,27 +448,4 @@ getinput(InputPacket *loc, SWBOOL tied) FunctionKeys(pp); } - -//--------------------------------------------------------------------------- -// -// CCMD based input. The basics are from Randi's ZDuke but this uses dynamic -// registration to only have the commands active when this game module runs. -// -//--------------------------------------------------------------------------- - -void registerinputcommands() -{ - C_RegisterFunction("centerview", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= BIT(SK_CENTER_VIEW); return CCMD_OK; }); - C_RegisterFunction("holsterweapon", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= BIT(SK_HIDE_WEAPON); return CCMD_OK; }); - - C_RegisterFunction("turnaround", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= BIT(SK_TURN_180); return CCMD_OK; }); -} - -// This is called from ImputState::ClearAllInput and resets all static state being used here. -void GameInterface::clearlocalinputstate() -{ - BitsToSend = 0; - -} - END_SW_NS diff --git a/source/sw/src/panel.cpp b/source/sw/src/panel.cpp index e10e2d9b7..eb85154a1 100644 --- a/source/sw/src/panel.cpp +++ b/source/sw/src/panel.cpp @@ -6627,18 +6627,18 @@ pWeaponUnHideKeys(PANEL_SPRITEp psp, PANEL_STATEp state) return FALSE; } - if (TEST_SYNC_KEY(psp->PlayerP, SK_HIDE_WEAPON)) + if (psp->PlayerP->input.actions & SB_HOLSTER) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_HIDE_WEAPON)) + if (psp->PlayerP->KeyPressBits & SB_HOLSTER) { - FLAG_KEY_RELEASE(psp->PlayerP, SK_HIDE_WEAPON); + psp->PlayerP->KeyPressBits &= ~SB_HOLSTER; pSetState(psp, state); return TRUE; } } else { - FLAG_KEY_RESET(psp->PlayerP, SK_HIDE_WEAPON); + psp->PlayerP->KeyPressBits |= SB_HOLSTER; } if (TEST_SYNC_KEY(psp->PlayerP, SK_SHOOT)) @@ -6671,19 +6671,19 @@ pWeaponHideKeys(PANEL_SPRITEp psp, PANEL_STATEp state) return TRUE; } - if (TEST_SYNC_KEY(psp->PlayerP, SK_HIDE_WEAPON)) + if (psp->PlayerP->input.actions & SB_HOLSTER) { - if (FLAG_KEY_PRESSED(psp->PlayerP, SK_HIDE_WEAPON)) + if (psp->PlayerP->KeyPressBits & SB_HOLSTER) { + psp->PlayerP->KeyPressBits &= ~SB_HOLSTER; PutStringInfo(psp->PlayerP,"Weapon Holstered"); - FLAG_KEY_RELEASE(psp->PlayerP, SK_HIDE_WEAPON); pSetState(psp, state); return TRUE; } } else { - FLAG_KEY_RESET(psp->PlayerP, SK_HIDE_WEAPON); + psp->PlayerP->KeyPressBits |= SB_HOLSTER; } return FALSE; diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index 21ad39895..51b389f3f 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -1566,13 +1566,13 @@ DoPlayerTurn(PLAYERp pp, fix16_t *pq16ang, fix16_t q16angvel) if (!TEST(pp->Flags, PF_TURN_180)) { - if (TEST_SYNC_KEY(pp, SK_TURN_180)) + if (pp->input.actions & SB_TURNAROUND) { - if (FLAG_KEY_PRESSED(pp, SK_TURN_180)) + if (pp->KeyPressBits & SB_TURNAROUND) { short delta_ang; - FLAG_KEY_RELEASE(pp, SK_TURN_180); + pp->KeyPressBits &= ~SB_TURNAROUND; pp->turn180_target = NORM_ANGLE(fix16_to_int(*pq16ang) + 1024); @@ -1591,7 +1591,7 @@ DoPlayerTurn(PLAYERp pp, fix16_t *pq16ang, fix16_t q16angvel) } else { - FLAG_KEY_RESET(pp, SK_TURN_180); + pp->KeyPressBits |= SB_TURNAROUND; } } @@ -1938,7 +1938,7 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16aimvel) SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING); } - if (TEST_SYNC_KEY(pp, SK_CENTER_VIEW)) + if (pp->input.actions & SB_CENTERVIEW) { if (PedanticMode) pp->q16horizbase = fix16_from_int(100); diff --git a/source/sw/src/predict.cpp b/source/sw/src/predict.cpp index a98af3b8d..a7892620b 100644 --- a/source/sw/src/predict.cpp +++ b/source/sw/src/predict.cpp @@ -83,18 +83,16 @@ DoPrediction(PLAYERp ppp) // get rid of input bits so it doesn't go into other code branches that would // get it out of sync - ppp->input.actions &= ~(SB_WEAPONMASK_BITS|SB_ITEMUSE_BITS); - ppp->KeyPressBits |= (SB_WEAPONMASK_BITS|SB_ITEMUSE_BITS|SB_INVNEXT|SB_INVPREV|SB_INVUSE); + ppp->input.actions &= ~(SB_WEAPONMASK_BITS|SB_ITEMUSE_BITS|SB_HOLSTER|SB_CENTERVIEW); + ppp->KeyPressBits |= (SB_WEAPONMASK_BITS|SB_ITEMUSE_BITS|SB_INVNEXT|SB_INVPREV|SB_INVUSE|SB_HOLSTER|SB_CENTERVIEW); RESET(ppp->input.bits, - BIT(SK_SHOOT)|BIT(SK_OPERATE)|BIT(SK_HIDE_WEAPON)| - BIT(SK_AUTO_AIM)| - BIT(SK_CENTER_VIEW) + BIT(SK_SHOOT)|BIT(SK_OPERATE)| + BIT(SK_AUTO_AIM) ); SET(ppp->KeyPressFlags, - BIT(SK_SHOOT)|BIT(SK_OPERATE)|BIT(SK_HIDE_WEAPON)| - BIT(SK_AUTO_AIM)| - BIT(SK_CENTER_VIEW) + BIT(SK_SHOOT)|BIT(SK_OPERATE)| + BIT(SK_AUTO_AIM) ); // back up things so they won't get stepped on