mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
Improve interaction between cheat entry and player input
git-svn-id: https://svn.eduke32.com/eduke32@8369 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # source/duke3d/src/cheats.cpp # source/duke3d/src/player.cpp
This commit is contained in:
parent
cf0a74a888
commit
c851da92a6
3 changed files with 33 additions and 26 deletions
|
@ -22,9 +22,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
#include "ns.h" // Must come before everything else!
|
||||
|
||||
#include "cheats.h"
|
||||
|
||||
#include "duke3d.h"
|
||||
#include "osdcmds.h"
|
||||
#include "cheats.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
|
@ -242,10 +243,12 @@ static void G_CheatGetInv(DukePlayer_t *pPlayer)
|
|||
static void end_cheat(DukePlayer_t * const pPlayer)
|
||||
{
|
||||
pPlayer->cheat_phase = 0;
|
||||
g_cheatBufLen = 0;
|
||||
inputState.keyFlushChars();
|
||||
KB_ClearKeysDown();
|
||||
}
|
||||
|
||||
static int32_t cheatbuflen;
|
||||
int g_cheatBufLen;
|
||||
static int8_t cheatbuf[MAXCHEATLEN];
|
||||
|
||||
void G_DoCheats(void)
|
||||
|
@ -311,31 +314,33 @@ void G_DoCheats(void)
|
|||
if (!((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9')))
|
||||
{
|
||||
pPlayer->cheat_phase = 0;
|
||||
g_cheatBufLen = 0;
|
||||
// P_DoQuote(QUOTE_46,pPlayer);
|
||||
return;
|
||||
}
|
||||
|
||||
cheatbuf[cheatbuflen++] = (int8_t) ch;
|
||||
cheatbuf[g_cheatBufLen++] = (int8_t) ch;
|
||||
// This assertion is not obvious, but it should hold because of the
|
||||
// cheat string matching logic below.
|
||||
Bassert(cheatbuflen < (signed)sizeof(cheatbuf));
|
||||
cheatbuf[cheatbuflen] = 0;
|
||||
Bassert(g_cheatBufLen < (signed)sizeof(cheatbuf));
|
||||
cheatbuf[g_cheatBufLen] = 0;
|
||||
// inputState.ClearKeysDown();
|
||||
|
||||
for (cheatNum=0; cheatNum < NUMCHEATCODES; cheatNum++)
|
||||
{
|
||||
for (bssize_t j = 0; j<cheatbuflen; j++)
|
||||
for (bssize_t j = 0; j<g_cheatBufLen; j++)
|
||||
{
|
||||
if (cheatbuf[j] == CheatStrings[cheatNum][j] || (CheatStrings[cheatNum][j] == '#' && ch >= '0' && ch <= '9'))
|
||||
{
|
||||
if (CheatStrings[cheatNum][j+1] == 0) goto FOUNDCHEAT;
|
||||
if (j == cheatbuflen-1) return;
|
||||
if (j == g_cheatBufLen-1) return;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
}
|
||||
|
||||
pPlayer->cheat_phase = 0;
|
||||
g_cheatBufLen = 0;
|
||||
return;
|
||||
|
||||
FOUNDCHEAT:;
|
||||
|
@ -458,8 +463,7 @@ void G_DoCheats(void)
|
|||
|
||||
case CHEAT_ALLEN:
|
||||
P_DoQuote(QUOTE_CHEAT_ALLEN, pPlayer);
|
||||
pPlayer->cheat_phase = 0;
|
||||
inputState.ClearKeyStatus(sc_N);
|
||||
end_cheat(pPlayer);
|
||||
return;
|
||||
|
||||
case CHEAT_CORNHOLIO:
|
||||
|
@ -622,8 +626,7 @@ void G_DoCheats(void)
|
|||
|
||||
case CHEAT_CASHMAN:
|
||||
ud.cashman = 1-ud.cashman;
|
||||
inputState.ClearKeyStatus(sc_N);
|
||||
pPlayer->cheat_phase = 0;
|
||||
end_cheat(pPlayer);
|
||||
return;
|
||||
|
||||
case CHEAT_ITEMS:
|
||||
|
@ -666,7 +669,6 @@ void G_DoCheats(void)
|
|||
|
||||
case CHEAT_BETA:
|
||||
P_DoQuote(QUOTE_CHEAT_BETA, pPlayer);
|
||||
inputState.ClearKeyStatus(sc_H);
|
||||
end_cheat(pPlayer);
|
||||
return;
|
||||
|
||||
|
@ -695,8 +697,8 @@ void G_DoCheats(void)
|
|||
case CHEAT_RESERVED3:
|
||||
ud.eog = 1;
|
||||
pPlayer->player_par = 0;
|
||||
pPlayer->gm |= MODE_EOL;
|
||||
inputState.keyFlushChars();
|
||||
pPlayer->gm |= MODE_EOL;;
|
||||
end_cheat(pPlayer);
|
||||
return;
|
||||
|
||||
default:
|
||||
|
@ -731,13 +733,14 @@ void G_DoCheats(void)
|
|||
{
|
||||
pPlayer->cheat_phase = 1;
|
||||
// P_DoQuote(QUOTE_25,pPlayer);
|
||||
cheatbuflen = 0;
|
||||
}
|
||||
g_cheatBufLen = 0;
|
||||
inputState.keyFlushChars();
|
||||
}
|
||||
else if (pPlayer->cheat_phase != 0)
|
||||
{
|
||||
pPlayer->cheat_phase = 0;
|
||||
g_cheatBufLen = 0;
|
||||
inputState.ClearKeyStatus((uint8_t) CheatKeys[0]);
|
||||
inputState.ClearKeyStatus((uint8_t) CheatKeys[1]);
|
||||
}
|
||||
|
|
|
@ -28,8 +28,9 @@ BEGIN_DUKE_NS
|
|||
#define MAXCHEATDESC 64
|
||||
#define NUMCHEATCODES (int32_t) ARRAY_SIZE(CheatStrings)
|
||||
|
||||
extern void G_DoCheats(void);
|
||||
extern void G_SetupCheats(void);
|
||||
void G_DoCheats(void);
|
||||
void G_SetupCheats(void);
|
||||
extern int g_cheatBufLen;
|
||||
|
||||
enum cheatindex_t
|
||||
{
|
||||
|
|
|
@ -2894,7 +2894,7 @@ void P_GetInput(int const playerNum)
|
|||
auto const pPlayer = g_player[playerNum].ps;
|
||||
ControlInfo info;
|
||||
|
||||
if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !inputState.GetKeyStatus(sc_Pause)))
|
||||
if (g_cheatBufLen > 1 || (pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !inputState.GetKeyStatus(sc_Pause)))
|
||||
{
|
||||
if (!(pPlayer->gm&MODE_MENU))
|
||||
CONTROL_GetInput(&info);
|
||||
|
@ -3024,7 +3024,9 @@ void P_GetInput(int const playerNum)
|
|||
int const sectorLotag = pPlayer->cursectnum != -1 ? sector[pPlayer->cursectnum].lotag : 0;
|
||||
int const crouchable = sectorLotag != 2 && (sectorLotag != 1 || pPlayer->spritebridge);
|
||||
|
||||
if (pPlayer->cheat_phase == 0 && buttonMap.ButtonDown(gamefunc_Toggle_Crouch))
|
||||
if (pPlayer->cheat_phase < 1)
|
||||
{
|
||||
if (buttonMap.ButtonDown(gamefunc_Toggle_Crouch))
|
||||
{
|
||||
pPlayer->crouch_toggle = !pPlayer->crouch_toggle && crouchable;
|
||||
|
||||
|
@ -3038,6 +3040,7 @@ void P_GetInput(int const playerNum)
|
|||
int const crouching = buttonMap.ButtonDown(gamefunc_Crouch) || buttonMap.ButtonDown(gamefunc_Toggle_Crouch) || pPlayer->crouch_toggle;
|
||||
|
||||
localInput.bits |= (buttonMap.ButtonDown(gamefunc_Jump) << SK_JUMP) | (crouching << SK_CROUCH);
|
||||
}
|
||||
|
||||
localInput.bits |= (buttonMap.ButtonDown(gamefunc_Aim_Up) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && input.fvel > 0)) << SK_AIM_UP;
|
||||
localInput.bits |= (buttonMap.ButtonDown(gamefunc_Aim_Down) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && input.fvel < 0)) << SK_AIM_DOWN;
|
||||
|
|
Loading…
Reference in a new issue