2012-11-26 18:58:24 +00:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
|
|
|
|
Doom 3 BFG Edition GPL Source Code
|
2022-09-05 20:25:33 +00:00
|
|
|
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Doom 3 BFG Edition Source Code 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 Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
|
|
|
|
|
|
|
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
|
|
|
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Precompiled.h"
|
|
|
|
#include "globaldata.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "m_menu.h"
|
|
|
|
#include "i_system.h"
|
|
|
|
#include "i_video.h"
|
|
|
|
#include "i_net.h"
|
|
|
|
#include "g_game.h"
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "doomstat.h"
|
|
|
|
|
|
|
|
#include "doomlib.h"
|
|
|
|
#include "Main.h"
|
|
|
|
#include "d3xp/Game_local.h"
|
|
|
|
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
void I_GetEvents( controller_t* );
|
|
|
|
void D_ProcessEvents( void );
|
|
|
|
void G_BuildTiccmd( ticcmd_t* cmd, idUserCmdMgr*, int newTics );
|
|
|
|
void D_DoAdvanceDemo( void );
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
extern bool globalNetworking;
|
|
|
|
|
|
|
|
//
|
|
|
|
// NETWORKING
|
|
|
|
//
|
|
|
|
// ::g->gametic is the tic about to (or currently being) run
|
|
|
|
// ::g->maketic is the tick that hasn't had control made for it yet
|
2022-09-05 20:25:33 +00:00
|
|
|
// ::g->nettics[] has the maketics for all ::g->players
|
2012-11-26 18:58:24 +00:00
|
|
|
//
|
|
|
|
// a ::g->gametic cannot be run until ::g->nettics[] > ::g->gametic for all ::g->players
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define NET_TIMEOUT 1 * TICRATE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
2022-09-05 20:25:33 +00:00
|
|
|
int NetbufferSize( void )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
2022-09-05 20:25:33 +00:00
|
|
|
int size = ( intptr_t ) & ( ( ( doomdata_t* )0 )->cmds[::g->netbuffer->numtics] );
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2022-09-05 20:25:33 +00:00
|
|
|
// Checksum
|
2012-11-26 18:58:24 +00:00
|
|
|
//
|
2022-09-05 20:25:33 +00:00
|
|
|
unsigned NetbufferChecksum( void )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
unsigned c;
|
2022-09-05 20:25:33 +00:00
|
|
|
int i, l;
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
c = 0x1234567;
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( globalNetworking )
|
|
|
|
{
|
|
|
|
l = ( NetbufferSize() - ( intptr_t ) & ( ( ( doomdata_t* )0 )->retransmitfrom ) ) / 4;
|
|
|
|
for( i = 0 ; i < l ; i++ )
|
|
|
|
{
|
|
|
|
c += ( ( unsigned* )&::g->netbuffer->retransmitfrom )[i] * ( i + 1 );
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return c & NCMD_CHECKSUM;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
2022-09-05 20:25:33 +00:00
|
|
|
int ExpandTics( int low )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
int delta;
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
delta = low - ( ::g->maketic & 0xff );
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( delta >= -64 && delta <= 64 )
|
|
|
|
{
|
|
|
|
return ( ::g->maketic & ~0xff ) + low;
|
|
|
|
}
|
|
|
|
if( delta > 64 )
|
|
|
|
{
|
|
|
|
return ( ::g->maketic & ~0xff ) - 256 + low;
|
|
|
|
}
|
|
|
|
if( delta < -64 )
|
|
|
|
{
|
|
|
|
return ( ::g->maketic & ~0xff ) + 256 + low;
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
I_Error( "ExpandTics: strange value %i at ::g->maketic %i", low, ::g->maketic );
|
2012-11-26 18:58:24 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// HSendPacket
|
|
|
|
//
|
|
|
|
void
|
|
|
|
HSendPacket
|
2022-09-05 20:25:33 +00:00
|
|
|
( int node,
|
|
|
|
int flags )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
2022-09-05 20:25:33 +00:00
|
|
|
::g->netbuffer->checksum = NetbufferChecksum() | flags;
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( !node )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
::g->reboundstore = *::g->netbuffer;
|
|
|
|
::g->reboundpacket = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->demoplayback )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( !::g->netgame )
|
|
|
|
{
|
|
|
|
I_Error( "Tried to transmit to another node" );
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
::g->doomcom.command = CMD_SEND;
|
|
|
|
::g->doomcom.remotenode = node;
|
2022-09-05 20:25:33 +00:00
|
|
|
::g->doomcom.datalength = NetbufferSize();
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->debugfile )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int realretrans;
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->netbuffer->checksum & NCMD_RETRANSMIT )
|
|
|
|
{
|
|
|
|
realretrans = ExpandTics( ::g->netbuffer->retransmitfrom );
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
else
|
2022-09-05 20:25:33 +00:00
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
realretrans = -1;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
fprintf( ::g->debugfile, "send (%i + %i, R %i) [%i] ",
|
|
|
|
ExpandTics( ::g->netbuffer->starttic ),
|
|
|
|
::g->netbuffer->numtics, realretrans, ::g->doomcom.datalength );
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
for( i = 0 ; i < ::g->doomcom.datalength ; i++ )
|
|
|
|
{
|
|
|
|
fprintf( ::g->debugfile, "%i ", ( ( byte* )::g->netbuffer )[i] );
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
fprintf( ::g->debugfile, "\n" );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
I_NetCmd();
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// HGetPacket
|
|
|
|
// Returns false if no packet is waiting
|
|
|
|
//
|
2022-09-05 20:25:33 +00:00
|
|
|
qboolean HGetPacket( void )
|
|
|
|
{
|
|
|
|
if( ::g->reboundpacket )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
*::g->netbuffer = ::g->reboundstore;
|
|
|
|
::g->doomcom.remotenode = 0;
|
|
|
|
::g->reboundpacket = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( !::g->netgame )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->demoplayback )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
::g->doomcom.command = CMD_GET;
|
2022-09-05 20:25:33 +00:00
|
|
|
I_NetCmd();
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->doomcom.remotenode == -1 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->doomcom.datalength != NetbufferSize() )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->debugfile )
|
|
|
|
{
|
|
|
|
fprintf( ::g->debugfile, "bad packet length %i\n", ::g->doomcom.datalength );
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ALAN NETWORKING -- this fails a lot on 4 player split debug!!
|
|
|
|
// TODO: Networking
|
|
|
|
#ifdef ID_ENABLE_DOOM_CLASSIC_NETWORKING
|
2022-09-05 20:25:33 +00:00
|
|
|
if( !gameLocal->IsSplitscreen() && NetbufferChecksum() != ( ::g->netbuffer->checksum & NCMD_CHECKSUM ) )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->debugfile )
|
|
|
|
{
|
|
|
|
fprintf( ::g->debugfile, "bad packet checksum\n" );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->debugfile )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
int realretrans;
|
|
|
|
int i;
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->netbuffer->checksum & NCMD_SETUP )
|
|
|
|
{
|
|
|
|
fprintf( ::g->debugfile, "setup packet\n" );
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
else
|
|
|
|
{
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->netbuffer->checksum & NCMD_RETRANSMIT )
|
|
|
|
{
|
|
|
|
realretrans = ExpandTics( ::g->netbuffer->retransmitfrom );
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
else
|
2022-09-05 20:25:33 +00:00
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
realretrans = -1;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
fprintf( ::g->debugfile, "get %i = (%i + %i, R %i)[%i] ",
|
|
|
|
::g->doomcom.remotenode,
|
|
|
|
ExpandTics( ::g->netbuffer->starttic ),
|
|
|
|
::g->netbuffer->numtics, realretrans, ::g->doomcom.datalength );
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
for( i = 0 ; i < ::g->doomcom.datalength ; i++ )
|
|
|
|
{
|
|
|
|
fprintf( ::g->debugfile, "%i ", ( ( byte* )::g->netbuffer )[i] );
|
|
|
|
}
|
|
|
|
fprintf( ::g->debugfile, "\n" );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-05 20:25:33 +00:00
|
|
|
return true;
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// GetPackets
|
|
|
|
//
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
void GetPackets( void )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
int netconsole;
|
|
|
|
int netnode;
|
2022-09-05 20:25:33 +00:00
|
|
|
ticcmd_t* src, *dest;
|
2012-11-26 18:58:24 +00:00
|
|
|
int realend;
|
|
|
|
int realstart;
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
while( HGetPacket() )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->netbuffer->checksum & NCMD_SETUP )
|
|
|
|
{
|
|
|
|
continue; // extra setup packet
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
netconsole = ::g->netbuffer->player & ~PL_DRONE;
|
|
|
|
netnode = ::g->doomcom.remotenode;
|
|
|
|
|
|
|
|
// to save bytes, only the low byte of tic numbers are sent
|
|
|
|
// Figure out what the rest of the bytes are
|
2022-09-05 20:25:33 +00:00
|
|
|
realstart = ExpandTics( ::g->netbuffer->starttic );
|
|
|
|
realend = ( realstart +::g->netbuffer->numtics );
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
// check for exiting the game
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->netbuffer->checksum & NCMD_EXIT )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
2022-09-05 20:25:33 +00:00
|
|
|
if( !::g->nodeingame[netnode] )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
continue;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->nodeingame[netnode] = false;
|
|
|
|
::g->playeringame[netconsole] = false;
|
2022-09-05 20:25:33 +00:00
|
|
|
strcpy( ::g->exitmsg, "Player 1 left the game" );
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->exitmsg[7] += netconsole;
|
|
|
|
::g->players[::g->consoleplayer].message = ::g->exitmsg;
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->demorecording )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
G_CheckDemoStatus();
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check for a remote game kill
|
2022-09-05 20:25:33 +00:00
|
|
|
/*
|
|
|
|
if (::g->netbuffer->checksum & NCMD_KILL)
|
|
|
|
I_Error ("Killed by network driver");
|
|
|
|
*/
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
::g->nodeforplayer[netconsole] = netnode;
|
|
|
|
|
|
|
|
// check for retransmit request
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->resendcount[netnode] <= 0
|
|
|
|
&& ( ::g->netbuffer->checksum & NCMD_RETRANSMIT ) )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
2022-09-05 20:25:33 +00:00
|
|
|
::g->resendto[netnode] = ExpandTics( ::g->netbuffer->retransmitfrom );
|
|
|
|
if( ::g->debugfile )
|
|
|
|
{
|
|
|
|
fprintf( ::g->debugfile, "retransmit from %i\n", ::g->resendto[netnode] );
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->resendcount[netnode] = RESENDCOUNT;
|
|
|
|
}
|
|
|
|
else
|
2022-09-05 20:25:33 +00:00
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->resendcount[netnode]--;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
// check for out of order / duplicated packet
|
|
|
|
if( realend == ::g->nettics[netnode] )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
continue;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( realend < ::g->nettics[netnode] )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->debugfile )
|
|
|
|
fprintf( ::g->debugfile,
|
|
|
|
"out of order packet (%i + %i)\n" ,
|
|
|
|
realstart, ::g->netbuffer->numtics );
|
2012-11-26 18:58:24 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check for a missed packet
|
2022-09-05 20:25:33 +00:00
|
|
|
if( realstart > ::g->nettics[netnode] )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
// stop processing until the other system resends the missed tics
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->debugfile )
|
|
|
|
fprintf( ::g->debugfile,
|
|
|
|
"missed tics from %i (%i - %i)\n",
|
|
|
|
netnode, realstart, ::g->nettics[netnode] );
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->remoteresend[netnode] = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// update command store from the packet
|
|
|
|
{
|
|
|
|
int start;
|
|
|
|
|
|
|
|
::g->remoteresend[netnode] = false;
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
start = ::g->nettics[netnode] - realstart;
|
2012-11-26 18:58:24 +00:00
|
|
|
src = &::g->netbuffer->cmds[start];
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
while( ::g->nettics[netnode] < realend )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
2022-09-05 20:25:33 +00:00
|
|
|
dest = &::g->netcmds[netconsole][::g->nettics[netnode] % BACKUPTICS];
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->nettics[netnode]++;
|
|
|
|
*dest = *src;
|
|
|
|
src++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// NetUpdate
|
|
|
|
// Builds ticcmds for console player,
|
|
|
|
// sends out a packet
|
|
|
|
//
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
void NetUpdate( idUserCmdMgr* userCmdMgr )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
int nowtime;
|
|
|
|
int newtics;
|
2022-09-05 20:25:33 +00:00
|
|
|
int i, j;
|
2012-11-26 18:58:24 +00:00
|
|
|
int realstart;
|
|
|
|
int gameticdiv;
|
|
|
|
|
|
|
|
// check time
|
2022-09-05 20:25:33 +00:00
|
|
|
nowtime = I_GetTime() /::g->ticdup;
|
2012-11-26 18:58:24 +00:00
|
|
|
newtics = nowtime - ::g->gametime;
|
|
|
|
::g->gametime = nowtime;
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( newtics <= 0 ) // nothing new to update
|
|
|
|
{
|
|
|
|
goto listen;
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->skiptics <= newtics )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
newtics -= ::g->skiptics;
|
|
|
|
::g->skiptics = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
::g->skiptics -= newtics;
|
|
|
|
newtics = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
::g->netbuffer->player = ::g->consoleplayer;
|
|
|
|
|
|
|
|
// build new ticcmds for console player
|
2022-09-05 20:25:33 +00:00
|
|
|
gameticdiv = ::g->gametic /::g->ticdup;
|
|
|
|
for( i = 0 ; i < newtics ; i++ )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
//I_GetEvents( ::g->I_StartTicCallback () );
|
2022-09-05 20:25:33 +00:00
|
|
|
D_ProcessEvents();
|
|
|
|
if( ::g->maketic - gameticdiv >= BACKUPTICS / 2 - 1 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
printf( "Out of room for ticcmds: maketic = %d, gameticdiv = %d\n", ::g->maketic, gameticdiv );
|
|
|
|
break; // can't hold any more
|
|
|
|
}
|
|
|
|
|
|
|
|
//I_Printf ("mk:%i ",::g->maketic);
|
|
|
|
|
|
|
|
// Grab the latest tech5 command
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
G_BuildTiccmd( &::g->localcmds[::g->maketic % BACKUPTICS], userCmdMgr, newtics );
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->maketic++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->singletics )
|
|
|
|
{
|
|
|
|
return; // singletic update is syncronous
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
// send the packet to the other ::g->nodes
|
2022-09-05 20:25:33 +00:00
|
|
|
for( i = 0 ; i < ::g->doomcom.numnodes ; i++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->nodeingame[i] )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->netbuffer->starttic = realstart = ::g->resendto[i];
|
|
|
|
::g->netbuffer->numtics = ::g->maketic - realstart;
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->netbuffer->numtics > BACKUPTICS )
|
|
|
|
{
|
|
|
|
I_Error( "NetUpdate: ::g->netbuffer->numtics > BACKUPTICS" );
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
::g->resendto[i] = ::g->maketic - ::g->doomcom.extratics;
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
for( j = 0 ; j < ::g->netbuffer->numtics ; j++ )
|
|
|
|
::g->netbuffer->cmds[j] =
|
|
|
|
::g->localcmds[( realstart + j ) % BACKUPTICS];
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->remoteresend[i] )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
::g->netbuffer->retransmitfrom = ::g->nettics[i];
|
2022-09-05 20:25:33 +00:00
|
|
|
HSendPacket( i, NCMD_RETRANSMIT );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
::g->netbuffer->retransmitfrom = 0;
|
2022-09-05 20:25:33 +00:00
|
|
|
HSendPacket( i, 0 );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// listen for other packets
|
|
|
|
listen:
|
2022-09-05 20:25:33 +00:00
|
|
|
GetPackets();
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// CheckAbort
|
|
|
|
//
|
2022-09-05 20:25:33 +00:00
|
|
|
void CheckAbort( void )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
// DHM - Time starts at 0 tics when starting a multiplayer game, so we can
|
|
|
|
// check for timeouts easily. If we're still waiting after N seconds, abort.
|
2022-09-05 20:25:33 +00:00
|
|
|
if( I_GetTime() > NET_TIMEOUT )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// TOOD: Show error & leave net game.
|
|
|
|
printf( "NET GAME TIMED OUT!\n" );
|
|
|
|
//gameLocal->showFatalErrorMessage( XuiLookupStringTable(globalStrings,L"Timed out waiting for match start.") );
|
|
|
|
|
|
|
|
|
|
|
|
D_QuitNetGame();
|
|
|
|
|
|
|
|
session->QuitMatch();
|
|
|
|
common->Dialog().AddDialog( GDM_OPPONENT_CONNECTION_LOST, DIALOG_ACCEPT, NULL, NULL, false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// D_ArbitrateNetStart
|
|
|
|
//
|
2022-09-05 20:25:33 +00:00
|
|
|
bool D_ArbitrateNetStart( void )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
::g->autostart = true;
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->doomcom.consoleplayer )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
// listen for setup info from key player
|
2022-09-05 20:25:33 +00:00
|
|
|
CheckAbort();
|
|
|
|
if( !HGetPacket() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
|
|
|
if( ::g->netbuffer->checksum & NCMD_SETUP )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
printf( "Received setup info\n" );
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->netbuffer->player != VERSION )
|
|
|
|
{
|
|
|
|
I_Error( "Different DOOM versions cannot play a net game!" );
|
|
|
|
}
|
|
|
|
::g->startskill = ( skill_t )( ::g->netbuffer->retransmitfrom & 15 );
|
|
|
|
::g->deathmatch = ( ::g->netbuffer->retransmitfrom & 0xc0 ) >> 6;
|
|
|
|
::g->nomonsters = ( ::g->netbuffer->retransmitfrom & 0x20 ) > 0;
|
|
|
|
::g->respawnparm = ( ::g->netbuffer->retransmitfrom & 0x10 ) > 0;
|
2012-11-26 18:58:24 +00:00
|
|
|
// VV original xbox doom :: don't do this.. it will be setup from the launcher
|
|
|
|
//::g->startmap = ::g->netbuffer->starttic & 0x3f;
|
|
|
|
//::g->startepisode = ::g->netbuffer->starttic >> 6;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// key player, send the setup info
|
2022-09-05 20:25:33 +00:00
|
|
|
CheckAbort();
|
|
|
|
for( i = 0 ; i < ::g->doomcom.numnodes ; i++ )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
printf( "Sending setup info to node %d\n", i );
|
|
|
|
|
|
|
|
::g->netbuffer->retransmitfrom = ::g->startskill;
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->deathmatch )
|
|
|
|
{
|
|
|
|
::g->netbuffer->retransmitfrom |= ( ::g->deathmatch << 6 );
|
|
|
|
}
|
|
|
|
if( ::g->nomonsters )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->netbuffer->retransmitfrom |= 0x20;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
|
|
|
if( ::g->respawnparm )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->netbuffer->retransmitfrom |= 0x10;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->netbuffer->starttic = ::g->startepisode * 64 + ::g->startmap;
|
|
|
|
::g->netbuffer->player = VERSION;
|
|
|
|
::g->netbuffer->numtics = 0;
|
2022-09-05 20:25:33 +00:00
|
|
|
HSendPacket( i, NCMD_SETUP );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
while( HGetPacket() )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
2022-09-05 20:25:33 +00:00
|
|
|
::g->gotinfo[::g->netbuffer->player & 0x7f] = true;
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
for( i = 1 ; i < ::g->doomcom.numnodes ; i++ )
|
|
|
|
{
|
|
|
|
if( !::g->gotinfo[i] )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
break;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( i >= ::g->doomcom.numnodes )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// D_CheckNetGame
|
|
|
|
// Works out player numbers among the net participants
|
|
|
|
//
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
void D_CheckNetGame( void )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
for( i = 0 ; i < MAXNETNODES ; i++ )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
::g->nodeingame[i] = false;
|
|
|
|
::g->nettics[i] = 0;
|
|
|
|
::g->remoteresend[i] = false; // set when local needs tics
|
|
|
|
::g->resendto[i] = 0; // which tic to start sending
|
|
|
|
}
|
|
|
|
|
|
|
|
// I_InitNetwork sets ::g->doomcom and ::g->netgame
|
2022-09-05 20:25:33 +00:00
|
|
|
I_InitNetwork();
|
2012-11-26 18:58:24 +00:00
|
|
|
#ifdef ID_ENABLE_DOOM_CLASSIC_NETWORKING
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->doomcom.id != DOOMCOM_ID )
|
|
|
|
{
|
|
|
|
I_Error( "Doomcom buffer invalid!" );
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
::g->netbuffer = &::g->doomcom.data;
|
|
|
|
::g->consoleplayer = ::g->displayplayer = ::g->doomcom.consoleplayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool D_PollNetworkStart()
|
|
|
|
{
|
|
|
|
int i;
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->netgame )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
2022-09-05 20:25:33 +00:00
|
|
|
if( D_ArbitrateNetStart() == false )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
I_Printf( "startskill %i deathmatch: %i startmap: %i startepisode: %i\n",
|
|
|
|
::g->startskill, ::g->deathmatch, ::g->startmap, ::g->startepisode );
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
// read values out of ::g->doomcom
|
|
|
|
::g->ticdup = ::g->doomcom.ticdup;
|
2022-09-05 20:25:33 +00:00
|
|
|
::g->maxsend = BACKUPTICS / ( 2 *::g->ticdup ) - 1;
|
|
|
|
if( ::g->maxsend < 1 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->maxsend = 1;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
for( i = 0 ; i < ::g->doomcom.numplayers ; i++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->playeringame[i] = true;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
|
|
|
for( i = 0 ; i < ::g->doomcom.numnodes ; i++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->nodeingame[i] = true;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
I_Printf( "player %i of %i (%i ::g->nodes)\n",
|
|
|
|
::g->consoleplayer + 1, ::g->doomcom.numplayers, ::g->doomcom.numnodes );
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// D_QuitNetGame
|
|
|
|
// Called before quitting to leave a net game
|
|
|
|
// without hanging the other ::g->players
|
|
|
|
//
|
2022-09-05 20:25:33 +00:00
|
|
|
void D_QuitNetGame( void )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ( !::g->netgame && !::g->usergame ) || ::g->consoleplayer == -1 || ::g->demoplayback || ::g->netbuffer == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
// send a quit packet to the other nodes
|
|
|
|
::g->netbuffer->player = ::g->consoleplayer;
|
|
|
|
::g->netbuffer->numtics = 0;
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
for( i = 1; i < ::g->doomcom.numnodes; i++ )
|
|
|
|
{
|
|
|
|
if( ::g->nodeingame[i] )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
HSendPacket( i, NCMD_EXIT );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DoomLib::SendNetwork();
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
for( i = 1 ; i < MAXNETNODES ; i++ )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
::g->nodeingame[i] = false;
|
|
|
|
::g->nettics[i] = 0;
|
|
|
|
::g->remoteresend[i] = false; // set when local needs tics
|
|
|
|
::g->resendto[i] = 0; // which tic to start sending
|
|
|
|
}
|
|
|
|
|
|
|
|
//memset (&::g->doomcom, 0, sizeof(::g->doomcom) );
|
|
|
|
|
|
|
|
// Reset singleplayer state
|
|
|
|
::g->doomcom.id = DOOMCOM_ID;
|
|
|
|
::g->doomcom.ticdup = 1;
|
|
|
|
::g->doomcom.extratics = 0;
|
|
|
|
::g->doomcom.numplayers = ::g->doomcom.numnodes = 1;
|
|
|
|
::g->doomcom.deathmatch = false;
|
|
|
|
::g->doomcom.consoleplayer = 0;
|
|
|
|
::g->netgame = false;
|
|
|
|
|
|
|
|
::g->netbuffer = &::g->doomcom.data;
|
|
|
|
::g->consoleplayer = ::g->displayplayer = ::g->doomcom.consoleplayer;
|
|
|
|
|
|
|
|
::g->ticdup = ::g->doomcom.ticdup;
|
2022-09-05 20:25:33 +00:00
|
|
|
::g->maxsend = BACKUPTICS / ( 2 *::g->ticdup ) - 1;
|
|
|
|
if( ::g->maxsend < 1 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->maxsend = 1;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
for( i = 0 ; i < ::g->doomcom.numplayers ; i++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->playeringame[i] = true;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
|
|
|
for( i = 0 ; i < ::g->doomcom.numnodes ; i++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->nodeingame[i] = true;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// TryRunTics
|
|
|
|
//
|
2022-09-05 20:25:33 +00:00
|
|
|
bool TryRunTics( idUserCmdMgr* userCmdMgr )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int lowtic_node = -1;
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
// get real tics
|
|
|
|
::g->trt_entertic = I_GetTime() /::g->ticdup;
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->trt_realtics = ::g->trt_entertic - ::g->oldtrt_entertics;
|
|
|
|
::g->oldtrt_entertics = ::g->trt_entertic;
|
|
|
|
|
|
|
|
// get available tics
|
2022-09-05 20:25:33 +00:00
|
|
|
NetUpdate( userCmdMgr );
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
::g->trt_lowtic = MAXINT;
|
|
|
|
::g->trt_numplaying = 0;
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
for( i = 0 ; i < ::g->doomcom.numnodes ; i++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->nodeingame[i] )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->trt_numplaying++;
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->nettics[i] < ::g->trt_lowtic )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->trt_lowtic = ::g->nettics[i];
|
|
|
|
lowtic_node = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
::g->trt_availabletics = ::g->trt_lowtic - ::g->gametic /::g->ticdup;
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
// decide how many tics to run
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->trt_realtics < ::g->trt_availabletics - 1 )
|
|
|
|
{
|
|
|
|
::g->trt_counts = ::g->trt_realtics + 1;
|
|
|
|
}
|
|
|
|
else if( ::g->trt_realtics < ::g->trt_availabletics )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->trt_counts = ::g->trt_realtics;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->trt_counts = ::g->trt_availabletics;
|
|
|
|
}
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->trt_counts < 1 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->trt_counts = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
::g->frameon++;
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->debugfile )
|
|
|
|
{
|
|
|
|
fprintf( ::g->debugfile, "=======real: %i avail: %i game: %i\n", ::g->trt_realtics, ::g->trt_availabletics, ::g->trt_counts );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( !::g->demoplayback )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// ideally ::g->nettics[0] should be 1 - 3 tics above ::g->trt_lowtic
|
|
|
|
// if we are consistantly slower, speed up time
|
2022-09-05 20:25:33 +00:00
|
|
|
for( i = 0 ; i < MAXPLAYERS ; i++ )
|
|
|
|
{
|
|
|
|
if( ::g->playeringame[i] )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->consoleplayer == i )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// the key player does not adapt
|
|
|
|
}
|
2022-09-05 20:25:33 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if( ::g->nettics[0] <= ::g->nettics[::g->nodeforplayer[i]] )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->gametime--;
|
|
|
|
//OutputDebugString("-");
|
|
|
|
}
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
::g->frameskip[::g->frameon & 3] = ( ::g->oldnettics > ::g->nettics[::g->nodeforplayer[i]] );
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->oldnettics = ::g->nettics[0];
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->frameskip[0] && ::g->frameskip[1] && ::g->frameskip[2] && ::g->frameskip[3] )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->skiptics = 1;
|
|
|
|
//OutputDebugString("+");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// wait for new tics if needed
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->trt_lowtic < ::g->gametic /::g->ticdup + ::g->trt_counts )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
int lagtime = 0;
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->trt_lowtic < ::g->gametic /::g->ticdup )
|
|
|
|
{
|
|
|
|
I_Error( "TryRunTics: ::g->trt_lowtic < gametic" );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->lastnettic == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->lastnettic = ::g->trt_entertic;
|
|
|
|
}
|
|
|
|
lagtime = ::g->trt_entertic - ::g->lastnettic;
|
|
|
|
|
|
|
|
// Detect if a client has stopped sending updates, remove them from the game after 5 secs.
|
2022-09-05 20:25:33 +00:00
|
|
|
if( common->IsMultiplayer() && ( !::g->demoplayback && ::g->netgame ) && lagtime >= TICRATE )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( lagtime > NET_TIMEOUT )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( lowtic_node == ::g->nodeforplayer[::g->consoleplayer] )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
#ifdef ID_ENABLE_DOOM_CLASSIC_NETWORKING
|
|
|
|
#ifndef __PS3__
|
2022-09-05 20:25:33 +00:00
|
|
|
gameLocal->showFatalErrorMessage( XuiLookupStringTable( globalStrings, L"You have been disconnected from the match." ) );
|
2012-11-26 18:58:24 +00:00
|
|
|
gameLocal->Interface.QuitCurrentGame();
|
|
|
|
#endif
|
|
|
|
#endif
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( ::g->nodeingame[lowtic_node] )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
int i, consoleNum = lowtic_node;
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
for( i = 0; i < ::g->doomcom.numnodes; i++ )
|
|
|
|
{
|
|
|
|
if( ::g->nodeforplayer[i] == lowtic_node )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
consoleNum = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
::g->nodeingame[lowtic_node] = false;
|
|
|
|
::g->playeringame[consoleNum] = false;
|
2022-09-05 20:25:33 +00:00
|
|
|
strcpy( ::g->exitmsg, "Player 1 left the game" );
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->exitmsg[7] += consoleNum;
|
|
|
|
::g->players[::g->consoleplayer].message = ::g->exitmsg;
|
|
|
|
|
|
|
|
// Stop a demo record now, as playback doesn't support losing players
|
|
|
|
G_CheckDemoStatus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
::g->lastnettic = 0;
|
|
|
|
|
|
|
|
// run the count * ::g->ticdup dics
|
2022-09-05 20:25:33 +00:00
|
|
|
while( ::g->trt_counts-- )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
2022-09-05 20:25:33 +00:00
|
|
|
for( i = 0 ; i < ::g->ticdup ; i++ )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->gametic /::g->ticdup > ::g->trt_lowtic )
|
|
|
|
{
|
|
|
|
I_Error( "gametic(%d) greater than trt_lowtic(%d), trt_counts(%d)", ::g->gametic, ::g->trt_lowtic, ::g->trt_counts );
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
if( ::g->advancedemo )
|
|
|
|
{
|
|
|
|
D_DoAdvanceDemo();
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
M_Ticker();
|
|
|
|
G_Ticker();
|
2012-11-26 18:58:24 +00:00
|
|
|
::g->gametic++;
|
|
|
|
|
|
|
|
// modify command for duplicated tics
|
2022-09-05 20:25:33 +00:00
|
|
|
if( i != ::g->ticdup - 1 )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
2022-09-05 20:25:33 +00:00
|
|
|
ticcmd_t* cmd;
|
2012-11-26 18:58:24 +00:00
|
|
|
int buf;
|
|
|
|
int j;
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
buf = ( ::g->gametic /::g->ticdup ) % BACKUPTICS;
|
|
|
|
for( j = 0 ; j < MAXPLAYERS ; j++ )
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
cmd = &::g->netcmds[j][buf];
|
2022-09-05 20:25:33 +00:00
|
|
|
if( cmd->buttons & BT_SPECIAL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
cmd->buttons = 0;
|
2022-09-05 20:25:33 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-05 20:25:33 +00:00
|
|
|
NetUpdate( userCmdMgr ); // check for new console commands
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|