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"
|
|
|
|
#include "serial.h"
|
|
|
|
#include "network.h"
|
|
|
|
#include <string.h>
|
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
BEGIN_PS_NS
|
|
|
|
|
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()
|
|
|
|
{
|
2019-08-31 17:09:42 +00:00
|
|
|
int i;
|
|
|
|
for (i = 6; i >= 0; i--)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2019-11-24 09:03:19 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Weapon_1+i))
|
2019-08-31 07:47:15 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-08-31 17:09:42 +00:00
|
|
|
i++;
|
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)
|
|
|
|
| (buttonMap.ButtonDown(gamefunc_Jump)<<0) | (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()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void LogoffPlayer(int nPlayer)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
if (nPlayer == nLocalPlayer)
|
|
|
|
return;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (PlayerList[nPlayer].someNetVal == -1)
|
|
|
|
return;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
memset(&sPlayerInput[nPlayer], 0, sizeof(sPlayerInput));
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
sprite[nDoppleSprite[nPlayer]].cstat = 0x8000u;
|
|
|
|
sprite[nPlayerFloorSprite[nPlayer]].cstat = 0x8000u;
|
|
|
|
sprite[PlayerList[nPlayer].nSprite].cstat = 0x8000u;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
PlayerList[nPlayer].someNetVal = -1;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
StatusMessage(150, "Player %d has left the game", nPlayer);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
// TODO ClearPlayerInput(&sPlayerInput[nPlayer]);
|
2019-08-31 07:47:15 +00:00
|
|
|
nNetPlayerCount--;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateInputs()
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
nNetMoveFrames = moveframes;
|
|
|
|
|
|
|
|
if (nNetPlayerCount)
|
|
|
|
{
|
|
|
|
if (bSerialPlay) {
|
|
|
|
UpdateSerialInputs();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
UpdateNetInputs();
|
|
|
|
}
|
|
|
|
|
|
|
|
nNetMoves++;
|
|
|
|
|
|
|
|
if (!nNetMoves) {
|
|
|
|
nNetMoves++;
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
ClearSpaceBar_
|
2019-08-31 07:47:15 +00:00
|
|
|
GetLocalInput_
|
|
|
|
GetModemInput_
|
|
|
|
BackupInput_
|
|
|
|
SendInput_
|
|
|
|
SendToUnAckd_
|
|
|
|
LogoffPlayer_
|
|
|
|
UpdateInputs_
|
|
|
|
faketimerhandler_
|
2019-08-26 03:59:14 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
void WaitNoKey(int nSecs, void (*pFunc) (void))
|
|
|
|
{
|
2019-09-06 05:18:12 +00:00
|
|
|
int nTotalTime = (kTimerTicks * nSecs) + (int)totalclock;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-09-06 05:18:12 +00:00
|
|
|
while (nTotalTime > (int)totalclock)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2019-08-31 15:04:06 +00:00
|
|
|
HandleAsync();
|
2019-08-31 07:47:15 +00:00
|
|
|
if (pFunc) {
|
|
|
|
pFunc();
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int WaitAnyKey(int nSecs)
|
|
|
|
{
|
2019-09-06 05:18:12 +00:00
|
|
|
int nTotalTime = (int)totalclock + (kTimerTicks * nSecs);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
while (1)
|
|
|
|
{
|
2019-08-31 15:04:06 +00:00
|
|
|
HandleAsync();
|
2019-09-06 05:18:12 +00:00
|
|
|
if (nTotalTime <= (int)totalclock || nSecs == -1) {
|
2019-08-31 07:47:15 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2019-12-25 23:21:04 +00:00
|
|
|
if (inputState.CheckAllInput()) return 1;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2019-08-31 07:47:15 +00:00
|
|
|
Name: _nLocalPlayer
|
2019-08-26 03:59:14 +00:00
|
|
|
Name: _nNetPlayerCount
|
|
|
|
Name: _nModemPlayer
|
|
|
|
Name: _nNetMoves
|
|
|
|
Name: _lLocalButtons
|
|
|
|
Name: _lLocalCodes
|
|
|
|
Name: _nInputStack
|
|
|
|
Name: _bSyncNet
|
|
|
|
Name: _lStartupTime
|
|
|
|
Name: _bStackNode
|
|
|
|
Name: _sSync
|
|
|
|
Name: _nTypeStack
|
|
|
|
Name: _sPlayerInput
|
|
|
|
Name: _pStackPtr
|
|
|
|
Name: _sInputStack
|
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
*/
|
|
|
|
END_PS_NS
|