2019-09-19 22:42:45 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 Nuke.YKT
|
|
|
|
|
|
|
|
This file is part of NBlood.
|
|
|
|
|
|
|
|
NBlood 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-09-21 18:59:54 +00:00
|
|
|
|
|
|
|
#include "ns.h" // Must come before everything else!
|
|
|
|
|
2020-02-16 20:31:29 +00:00
|
|
|
#include "mmulti.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
#include "view.h"
|
2020-07-29 21:18:08 +00:00
|
|
|
#include "gamestate.h"
|
2020-10-04 16:31:48 +00:00
|
|
|
#include "razemenu.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
BEGIN_BLD_NS
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-09-14 05:14:22 +00:00
|
|
|
static InputPacket gInput;
|
2020-01-30 13:05:34 +00:00
|
|
|
|
2020-09-21 07:00:07 +00:00
|
|
|
void UpdatePlayerSpriteAngle(PLAYER* pPlayer);
|
2020-09-16 08:22:01 +00:00
|
|
|
|
2020-09-24 12:32:37 +00:00
|
|
|
void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput)
|
2020-09-16 10:23:59 +00:00
|
|
|
{
|
2020-09-24 12:32:37 +00:00
|
|
|
if (paused || M_Active())
|
2020-06-24 13:11:42 +00:00
|
|
|
{
|
2020-09-24 12:32:37 +00:00
|
|
|
gInput = {};
|
|
|
|
return;
|
2020-09-16 10:23:59 +00:00
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-09-24 12:32:37 +00:00
|
|
|
double const scaleAdjust = InputScale();
|
|
|
|
InputPacket input {};
|
2020-06-24 13:11:42 +00:00
|
|
|
|
2020-09-24 12:32:37 +00:00
|
|
|
ApplyGlobalInput(gInput, hidInput);
|
2020-09-25 12:26:50 +00:00
|
|
|
processMovement(&input, &gInput, hidInput, scaleAdjust);
|
2020-09-16 08:22:01 +00:00
|
|
|
|
|
|
|
if (!cl_syncinput && gamestate == GS_LEVEL)
|
|
|
|
{
|
2020-09-16 10:23:59 +00:00
|
|
|
PLAYER* pPlayer = &gPlayer[myconnectindex];
|
2020-09-16 11:59:19 +00:00
|
|
|
|
2020-09-16 12:02:05 +00:00
|
|
|
// Perform unsynchronised angle/horizon if not dead.
|
|
|
|
if (gView->pXSprite->health != 0)
|
|
|
|
{
|
2020-10-08 03:47:30 +00:00
|
|
|
applylook(&pPlayer->angle, input.avel, &pPlayer->input.actions, scaleAdjust, pPlayer->posture != 0);
|
2020-10-07 07:22:07 +00:00
|
|
|
sethorizon(&pPlayer->horizon.horiz, input.horz, &pPlayer->input.actions, scaleAdjust);
|
2020-09-16 12:02:05 +00:00
|
|
|
}
|
2020-09-16 11:59:19 +00:00
|
|
|
|
2020-10-07 20:55:54 +00:00
|
|
|
pPlayer->angle.processhelpers(scaleAdjust);
|
2020-10-07 06:16:58 +00:00
|
|
|
pPlayer->horizon.processhelpers(scaleAdjust);
|
2020-09-24 12:32:37 +00:00
|
|
|
UpdatePlayerSpriteAngle(pPlayer);
|
2020-09-16 08:22:01 +00:00
|
|
|
}
|
2020-09-16 10:23:59 +00:00
|
|
|
|
2020-09-01 21:34:04 +00:00
|
|
|
if (packet)
|
|
|
|
{
|
|
|
|
*packet = gInput;
|
|
|
|
gInput = {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
gInput = {};
|
|
|
|
}
|
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
END_BLD_NS
|