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 "engine.h"
|
|
|
|
#include "exhumed.h"
|
|
|
|
#include "player.h"
|
2020-08-23 05:41:29 +00:00
|
|
|
#include "aistuff.h"
|
|
|
|
#include "status.h"
|
|
|
|
#include "view.h"
|
2020-08-24 18:34:18 +00:00
|
|
|
#include "gamecontrol.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
BEGIN_PS_NS
|
|
|
|
|
2020-08-23 14:11:18 +00:00
|
|
|
int WeaponToSend, BitsToSend;
|
|
|
|
|
2019-08-26 03:59:14 +00:00
|
|
|
int nNetMoves = 0;
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
sPlayerInput[nPlayer].buttons &= 0x0FB;
|
2019-11-24 09:03:19 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Open);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GetLocalInput()
|
|
|
|
{
|
2020-08-23 14:11:18 +00:00
|
|
|
int i = WeaponToSend;
|
|
|
|
if (WeaponToSend == PlayerList[nLocalPlayer].nCurrentWeapon)
|
|
|
|
WeaponToSend = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (PlayerList[nLocalPlayer].nHealth)
|
|
|
|
{
|
2019-11-24 09:03:19 +00:00
|
|
|
lLocalButtons = (buttonMap.ButtonDown(gamefunc_Crouch) << 4) | (buttonMap.ButtonDown(gamefunc_Fire) << 3)
|
2020-08-23 14:11:18 +00:00
|
|
|
| (buttonMap.ButtonDown(gamefunc_Jump) << 0);
|
|
|
|
lLocalCodes |= (i << 13);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lLocalButtons = 0;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-24 09:03:19 +00:00
|
|
|
lLocalButtons |= buttonMap.ButtonDown(gamefunc_Open) << 2;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
// TODO ExecRecord(&sPlayerInput[nLocalPlayer], sizeof(PlayerInput));
|
|
|
|
}
|
|
|
|
|
|
|
|
void BackupInput()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void SendInput()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-08-23 05:41:29 +00:00
|
|
|
short nNetMoveFrames = 0;
|
|
|
|
|
|
|
|
void UpdateInputs()
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2020-08-23 05:41:29 +00:00
|
|
|
nNetMoveFrames = moveframes;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-08-23 05:41:29 +00:00
|
|
|
if (nNetPlayerCount)
|
|
|
|
{
|
|
|
|
//UpdateNetInputs();
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-08-23 05:41:29 +00:00
|
|
|
nNetMoves++;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-08-23 05:41:29 +00:00
|
|
|
if (!nNetMoves) {
|
|
|
|
nNetMoves++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-08-23 05:41:29 +00:00
|
|
|
void CheckKeys()
|
|
|
|
{
|
|
|
|
// go to 3rd person view?
|
|
|
|
if (buttonMap.ButtonDown(gamefunc_Third_Person_View))
|
|
|
|
{
|
|
|
|
if (!nFreeze)
|
|
|
|
{
|
|
|
|
if (bCamera) {
|
|
|
|
bCamera = false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bCamera = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bCamera)
|
|
|
|
GrabPalette();
|
|
|
|
}
|
|
|
|
buttonMap.ClearButton(gamefunc_Third_Person_View);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (paused)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2020-08-23 05:41:29 +00:00
|
|
|
static int32_t nonsharedtimer;
|
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-24 17:54:26 +00:00
|
|
|
if (automapMode != am_off)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2020-08-23 05:41:29 +00:00
|
|
|
int const timerOffset = ((int)totalclock - nonsharedtimer);
|
|
|
|
nonsharedtimer += timerOffset;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-08-23 05:41:29 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen))
|
|
|
|
lMapZoom += mulscale6(timerOffset, max<int>(lMapZoom, 256));
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-08-23 05:41:29 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Shrink_Screen))
|
|
|
|
lMapZoom -= mulscale6(timerOffset, max<int>(lMapZoom, 256));
|
|
|
|
|
|
|
|
lMapZoom = clamp(lMapZoom, 48, 2048);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
static int ccmd_slot(CCmdFuncPtr parm)
|
|
|
|
{
|
|
|
|
if (parm->numparms != 1) return CCMD_SHOWHELP;
|
|
|
|
|
|
|
|
auto slot = atoi(parm->parms[0]);
|
|
|
|
if (slot >= 1 && slot <= 7)
|
|
|
|
{
|
|
|
|
WeaponToSend = slot;
|
|
|
|
return CCMD_OK;
|
|
|
|
}
|
|
|
|
return CCMD_SHOWHELP;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ccmd_centerview(CCmdFuncPtr parm);
|
|
|
|
|
|
|
|
|
|
|
|
void registerinputcommands()
|
|
|
|
{
|
|
|
|
C_RegisterFunction("slot", "slot <weaponslot>: select a weapon from the given slot (1-10)", ccmd_slot);
|
2020-08-24 18:34:18 +00:00
|
|
|
C_RegisterFunction("pause", nullptr, [](CCmdFuncPtr)->int { /*BitsToSend |= SKB_PAUSE;*/ sendPause = true; return CCMD_OK; });
|
2020-08-23 14:11:18 +00:00
|
|
|
C_RegisterFunction("centerview", nullptr, ccmd_centerview);
|
|
|
|
C_RegisterFunction("invprev", nullptr, [](CCmdFuncPtr)->int { if (PlayerList[nLocalPlayer].nHealth > 0) SetPrevItem(nLocalPlayer); return CCMD_OK; });
|
|
|
|
C_RegisterFunction("invnext", nullptr, [](CCmdFuncPtr)->int { if (PlayerList[nLocalPlayer].nHealth > 0) SetNextItem(nLocalPlayer); return CCMD_OK; });
|
|
|
|
C_RegisterFunction("invuse", nullptr, [](CCmdFuncPtr)->int { if (PlayerList[nLocalPlayer].nHealth > 0) UseCurItem(nLocalPlayer); return CCMD_OK; });
|
2020-08-25 18:40:30 +00:00
|
|
|
// todo: These still need to be implemented.
|
|
|
|
C_RegisterFunction("weapprev", nullptr, [](CCmdFuncPtr)->int { /*WeaponToSend = 11;*/ return CCMD_OK; });
|
|
|
|
C_RegisterFunction("weapnext", nullptr, [](CCmdFuncPtr)->int { /*WeaponToSend = 12;*/ return CCMD_OK; });
|
|
|
|
|
|
|
|
// 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; });
|
2020-08-23 14:11:18 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is called from ImputState::ClearAllInput and resets all static state being used here.
|
|
|
|
void GameInterface::clearlocalinputstate()
|
|
|
|
{
|
|
|
|
WeaponToSend = 0;
|
|
|
|
BitsToSend = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
END_PS_NS
|