2020-12-09 14:56:32 +00:00
|
|
|
#pragma once
|
2019-09-19 22:42:45 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
2020-11-08 08:47:32 +00:00
|
|
|
Copyright (C) 2020 Christoph Oelckers & Mitchell Richters
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-11-08 08:47:32 +00:00
|
|
|
This file is part of Raze.
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-11-08 08:47:32 +00:00
|
|
|
Raze is free software; you can redistribute it and/or
|
2019-09-19 22:42:45 +00:00
|
|
|
modify it under the terms of the GNU General Public License version 2
|
2020-11-08 08:47:32 +00:00
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
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"
|
2020-12-09 14:56:32 +00:00
|
|
|
#include "blood.h"
|
2020-07-29 21:18:08 +00:00
|
|
|
#include "gamestate.h"
|
2020-12-09 14:56:32 +00:00
|
|
|
#include "inputstate.h"
|
|
|
|
#include "gamestruct.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-11-07 02:23:16 +00:00
|
|
|
PLAYER* pPlayer = &gPlayer[myconnectindex];
|
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
|
|
|
|
2020-11-30 22:40:16 +00:00
|
|
|
if (!SyncInput() && gamestate == GS_LEVEL)
|
2020-11-07 02:23:16 +00:00
|
|
|
{
|
2020-09-16 12:02:05 +00:00
|
|
|
// Perform unsynchronised angle/horizon if not dead.
|
|
|
|
if (gView->pXSprite->health != 0)
|
|
|
|
{
|
2020-11-07 07:25:06 +00:00
|
|
|
applylook(&pPlayer->angle, input.avel, &pPlayer->input.actions, scaleAdjust);
|
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
|