2019-11-20 16:21:32 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 sirlemonhead, Nuke.YKT
|
|
|
|
This file is part of PCExhumed.
|
|
|
|
PCExhumed is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-11-22 23:11:37 +00:00
|
|
|
#include "ns.h"
|
2019-11-24 09:03:19 +00:00
|
|
|
#include "ps_input.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include "exhumed.h"
|
|
|
|
#include "player.h"
|
2020-08-23 05:41:29 +00:00
|
|
|
#include "status.h"
|
|
|
|
#include "view.h"
|
2020-09-21 08:36:04 +00:00
|
|
|
#include "menu.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
BEGIN_PS_NS
|
|
|
|
|
2020-09-21 08:36:04 +00:00
|
|
|
static int turn;
|
|
|
|
static int counter;
|
|
|
|
|
2019-08-26 03:59:14 +00:00
|
|
|
short nInputStack = 0;
|
|
|
|
|
|
|
|
short bStackNode[kMaxPlayers];
|
|
|
|
|
|
|
|
short nTypeStack[kMaxPlayers];
|
|
|
|
PlayerInput sPlayerInput[kMaxPlayers];
|
|
|
|
|
|
|
|
int *pStackPtr;
|
|
|
|
|
|
|
|
// (nInputStack * 32) - 11;
|
|
|
|
|
|
|
|
void PushInput(PlayerInput *pInput, int edx)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
if (!bStackNode[edx])
|
|
|
|
{
|
2019-08-26 03:59:14 +00:00
|
|
|
// memcpy(sInputStack[nInputStack], pInput,
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int PopInput()
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
if (!nInputStack)
|
|
|
|
return -1;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
nInputStack--;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
// TEMP
|
|
|
|
return 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InitInput()
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
memset(nTypeStack, 0, sizeof(nTypeStack));
|
|
|
|
nInputStack = 0;
|
|
|
|
memset(bStackNode, 0, sizeof(bStackNode));
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
// pStackPtr = &sInputStack;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClearSpaceBar(short nPlayer)
|
|
|
|
{
|
2020-08-28 20:51:05 +00:00
|
|
|
sPlayerInput[nPlayer].actions &= SB_OPEN;
|
2019-11-24 09:03:19 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Open);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BackupInput()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void SendInput()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-08-18 08:28:19 +00:00
|
|
|
|
2020-08-23 05:41:29 +00:00
|
|
|
void CheckKeys2()
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2020-08-23 14:11:18 +00:00
|
|
|
if (PlayerList[nLocalPlayer].nHealth <= 0)
|
2020-08-23 05:41:29 +00:00
|
|
|
{
|
|
|
|
SetAirFrame();
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2020-08-23 14:11:18 +00:00
|
|
|
|
2020-09-24 12:32:37 +00:00
|
|
|
void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput)
|
2020-08-26 22:58:21 +00:00
|
|
|
{
|
2020-09-24 12:32:37 +00:00
|
|
|
if (paused || M_Active())
|
2020-08-26 22:58:21 +00:00
|
|
|
{
|
2020-09-24 12:32:37 +00:00
|
|
|
localInput = {};
|
|
|
|
return;
|
2020-08-26 22:58:21 +00:00
|
|
|
}
|
|
|
|
|
2020-09-24 12:32:37 +00:00
|
|
|
if (packet != nullptr)
|
2020-09-21 08:36:04 +00:00
|
|
|
{
|
2020-09-24 12:32:37 +00:00
|
|
|
localInput = {};
|
|
|
|
ApplyGlobalInput(localInput, hidInput);
|
|
|
|
if (PlayerList[nLocalPlayer].nHealth == 0) localInput.actions &= SB_OPEN;
|
2020-09-21 08:36:04 +00:00
|
|
|
}
|
2020-08-26 22:58:21 +00:00
|
|
|
|
2020-09-24 14:17:16 +00:00
|
|
|
double const scaleAdjust = InputScale();
|
|
|
|
InputPacket input {};
|
2020-08-26 22:58:21 +00:00
|
|
|
|
2020-09-24 12:32:37 +00:00
|
|
|
if (PlayerList[nLocalPlayer].nHealth == 0)
|
2020-08-26 22:58:21 +00:00
|
|
|
{
|
2020-09-24 12:32:37 +00:00
|
|
|
lPlayerYVel = 0;
|
|
|
|
lPlayerXVel = 0;
|
2020-08-26 22:58:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-25 12:26:50 +00:00
|
|
|
processMovement(&input, &localInput, hidInput, scaleAdjust);
|
2020-08-26 22:58:21 +00:00
|
|
|
}
|
|
|
|
|
2020-09-21 09:28:39 +00:00
|
|
|
if (!cl_syncinput)
|
2020-08-26 22:58:21 +00:00
|
|
|
{
|
2020-09-21 08:36:04 +00:00
|
|
|
Player* pPlayer = &PlayerList[nLocalPlayer];
|
2020-08-26 22:58:21 +00:00
|
|
|
|
2020-09-21 09:28:39 +00:00
|
|
|
if (!nFreeze)
|
|
|
|
{
|
2020-09-24 12:32:37 +00:00
|
|
|
applylook(&pPlayer->q16angle, &pPlayer->q16look_ang, &pPlayer->q16rotscrnang, &pPlayer->spin, input.q16avel, &sPlayerInput[nLocalPlayer].actions, scaleAdjust, eyelevel[nLocalPlayer] > -14080);
|
2020-10-07 06:40:59 +00:00
|
|
|
sethorizon(&pPlayer->horizon.horiz, input.q16horz, &sPlayerInput[nLocalPlayer].actions, scaleAdjust);
|
2020-09-21 09:28:39 +00:00
|
|
|
}
|
|
|
|
|
2020-10-07 06:40:59 +00:00
|
|
|
// temporary vals to pass through to playerProcessHelpers().
|
|
|
|
fixed_t horiz = 0;
|
|
|
|
fixed_t target = 0;
|
|
|
|
double adjust = 0;
|
|
|
|
playerProcessHelpers(&pPlayer->q16angle, &pPlayer->angAdjust, &pPlayer->angTarget, &horiz, &adjust, &target, scaleAdjust);
|
|
|
|
pPlayer->horizon.processhelpers(scaleAdjust);
|
2020-09-24 12:32:37 +00:00
|
|
|
UpdatePlayerSpriteAngle(pPlayer);
|
2020-09-21 08:36:04 +00:00
|
|
|
}
|
2020-08-26 22:58:21 +00:00
|
|
|
|
2020-09-24 12:32:37 +00:00
|
|
|
if (packet)
|
2020-09-21 08:36:04 +00:00
|
|
|
{
|
2020-09-24 12:32:37 +00:00
|
|
|
*packet = localInput;
|
2020-08-26 22:58:21 +00:00
|
|
|
}
|
2020-09-02 20:55:57 +00:00
|
|
|
}
|
|
|
|
|
2020-09-23 14:15:51 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2020-09-23 14:20:40 +00:00
|
|
|
// This is called from InputState::ClearAllInput and resets all static state being used here.
|
2020-09-23 14:15:51 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void GameInterface::clearlocalinputstate()
|
|
|
|
{
|
|
|
|
localInput = {};
|
|
|
|
turn = 0;
|
|
|
|
counter = 0;
|
|
|
|
}
|
|
|
|
|
2020-08-27 22:03:35 +00:00
|
|
|
END_PS_NS
|