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!
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
#include "build.h"
|
|
|
|
#include "mmulti.h"
|
|
|
|
#include "pragmas.h"
|
|
|
|
#include "compat.h"
|
|
|
|
#include "controls.h"
|
|
|
|
#include "globals.h"
|
|
|
|
#include "network.h"
|
|
|
|
#include "player.h"
|
|
|
|
#include "seq.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "view.h"
|
2020-06-14 16:57:55 +00:00
|
|
|
#include "menu.h"
|
2020-07-29 21:18:08 +00:00
|
|
|
#include "gamestate.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
BEGIN_BLD_NS
|
|
|
|
|
2020-08-16 11:26:57 +00:00
|
|
|
MapRecord *gStartNewGame = 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
int gNetFifoTail = 0;
|
|
|
|
int gNetFifoHead[8];
|
|
|
|
int gPredictTail = 0;
|
2020-08-26 15:12:48 +00:00
|
|
|
InputPacket gFifoInput[256][8];
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
void netResetToSinglePlayer(void)
|
|
|
|
{
|
|
|
|
myconnectindex = connecthead = 0;
|
2020-09-01 17:49:05 +00:00
|
|
|
gNetPlayers = numplayers = 1;
|
2019-09-19 22:42:45 +00:00
|
|
|
connectpoint2[0] = -1;
|
|
|
|
gGameOptions.nGameType = 0;
|
|
|
|
UpdateNetworkMenus();
|
|
|
|
}
|
|
|
|
|
2020-08-03 18:01:08 +00:00
|
|
|
void netReset(void)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-08-25 23:10:14 +00:00
|
|
|
lastTic = -1;
|
2019-09-19 22:42:45 +00:00
|
|
|
gPredictTail = 0;
|
|
|
|
gNetFifoTail = 0;
|
|
|
|
memset(gNetFifoHead, 0, sizeof(gNetFifoHead));
|
|
|
|
}
|
|
|
|
|
|
|
|
void netBroadcastPlayerInfo(int nPlayer)
|
|
|
|
{
|
|
|
|
PROFILE *pProfile = &gProfile[nPlayer];
|
2019-10-27 13:09:56 +00:00
|
|
|
strcpy(pProfile->name, playername);
|
2019-09-19 22:42:45 +00:00
|
|
|
pProfile->skill = gSkill;
|
2019-10-21 22:05:21 +00:00
|
|
|
pProfile->nAutoAim = cl_autoaim;
|
2019-10-22 00:31:14 +00:00
|
|
|
pProfile->nWeaponSwitch = cl_weaponswitch;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void netGetInput(void)
|
|
|
|
{
|
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
|
|
|
if (gNetFifoHead[myconnectindex]-200 > gNetFifoHead[p])
|
|
|
|
return;
|
2020-08-26 15:12:48 +00:00
|
|
|
InputPacket &input = gFifoInput[gNetFifoHead[myconnectindex]&255][myconnectindex];
|
2020-05-27 15:22:58 +00:00
|
|
|
input = gNetInput;
|
2019-09-19 22:42:45 +00:00
|
|
|
gNetFifoHead[myconnectindex]++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void netInitialize(bool bConsole)
|
|
|
|
{
|
2020-08-03 18:01:08 +00:00
|
|
|
netReset();
|
|
|
|
netResetToSinglePlayer();
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
|
|
|
|
END_BLD_NS
|