mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
Remove reboundstore timeout hack
This commit is contained in:
parent
62cfb0eb81
commit
18bfc3266a
6 changed files with 28 additions and 54 deletions
|
@ -479,6 +479,15 @@ void CL_RemovePlayer(INT32 playernum, kickreason_t reason)
|
|||
P_CheckRacers();
|
||||
}
|
||||
|
||||
void CL_HandleTimeout(void)
|
||||
{
|
||||
LUA_HookBool(false, HOOK(GameQuit));
|
||||
D_QuitNetGame();
|
||||
CL_Reset();
|
||||
D_StartTitle();
|
||||
M_StartMessage(M_GetText("Server Timeout\n\nPress Esc\n"), NULL, MM_NOTHING);
|
||||
}
|
||||
|
||||
void CL_Reset(void)
|
||||
{
|
||||
if (metalrecording)
|
||||
|
@ -1363,21 +1372,6 @@ static void PT_ServerShutdown(SINT8 node)
|
|||
M_StartMessage(M_GetText("Server has shutdown\n\nPress Esc\n"), NULL, MM_NOTHING);
|
||||
}
|
||||
|
||||
/** Called when a PT_NODETIMEOUT packet is received
|
||||
*
|
||||
* \param node The packet sender (should be the server)
|
||||
*
|
||||
*/
|
||||
static void PT_NodeTimeout(SINT8 node)
|
||||
{
|
||||
(void)node;
|
||||
LUA_HookBool(false, HOOK(GameQuit));
|
||||
D_QuitNetGame();
|
||||
CL_Reset();
|
||||
D_StartTitle();
|
||||
M_StartMessage(M_GetText("Server Timeout\n\nPress Esc\n"), NULL, MM_NOTHING);
|
||||
}
|
||||
|
||||
static void PT_Login(SINT8 node, INT32 netconsole)
|
||||
{
|
||||
(void)node;
|
||||
|
@ -1415,32 +1409,10 @@ static void PT_Login(SINT8 node, INT32 netconsole)
|
|||
static void PT_ClientQuit(SINT8 node, INT32 netconsole)
|
||||
{
|
||||
if (client)
|
||||
{
|
||||
if (node == servernode && cl_mode != CL_SEARCHING && netbuffer->packettype == PT_NODETIMEOUT)
|
||||
PT_NodeTimeout(node);
|
||||
return;
|
||||
}
|
||||
|
||||
// nodeingame will be put false in the execution of kick command
|
||||
// this allow to send some packets to the quitting client to have their ack back
|
||||
if (netnodes[node].ingame && netconsole != -1 && playeringame[netconsole])
|
||||
{
|
||||
UINT8 kickmsg;
|
||||
|
||||
if (netbuffer->packettype == PT_NODETIMEOUT)
|
||||
kickmsg = KICK_MSG_TIMEOUT;
|
||||
else
|
||||
kickmsg = KICK_MSG_PLAYER_QUIT;
|
||||
kickmsg |= KICK_MSG_KEEP_BODY;
|
||||
|
||||
SendKick(netconsole, kickmsg);
|
||||
|
||||
if (netnodes[node].player2 != -1 && netnodes[node].player2 >= 0
|
||||
&& playeringame[(UINT8)netnodes[node].player2])
|
||||
{
|
||||
SendKick(netnodes[node].player2, kickmsg);
|
||||
}
|
||||
}
|
||||
SendKicksForNode(node, KICK_MSG_PLAYER_QUIT | KICK_MSG_KEEP_BODY);
|
||||
|
||||
Net_CloseConnection(node);
|
||||
netnodes[node].ingame = false;
|
||||
|
@ -1517,7 +1489,6 @@ static void HandlePacketFromAwayNode(SINT8 node)
|
|||
case PT_FILEACK : PT_FileAck (node ); break;
|
||||
case PT_FILERECEIVED : PT_FileReceived (node ); break;
|
||||
case PT_REQUESTFILE : PT_RequestFile (node ); break;
|
||||
case PT_NODETIMEOUT : PT_ClientQuit (node, -1); break;
|
||||
case PT_CLIENTQUIT : PT_ClientQuit (node, -1); break;
|
||||
case PT_SERVERTICS : PT_ServerTics (node, -1); break;
|
||||
case PT_CLIENTJOIN : PT_ClientJoin (node ); break;
|
||||
|
@ -1566,7 +1537,6 @@ static void HandlePacketFromPlayer(SINT8 node)
|
|||
case PT_TEXTCMD : PT_TextCmd (node, netconsole); break;
|
||||
case PT_TEXTCMD2 : PT_TextCmd (node, netconsole); break;
|
||||
case PT_LOGIN : PT_Login (node, netconsole); break;
|
||||
case PT_NODETIMEOUT : PT_ClientQuit (node, netconsole); break;
|
||||
case PT_CLIENTQUIT : PT_ClientQuit (node, netconsole); break;
|
||||
case PT_CANRECEIVEGAMESTATE: PT_CanReceiveGamestate(node ); break;
|
||||
case PT_ASKLUAFILE : PT_AskLuaFile (node ); break;
|
||||
|
|
|
@ -94,6 +94,7 @@ void CL_RemoveSplitscreenPlayer(void);
|
|||
void CL_Reset(void);
|
||||
void CL_ClearPlayer(INT32 playernum);
|
||||
void CL_RemovePlayer(INT32 playernum, kickreason_t reason);
|
||||
void CL_HandleTimeout(void);
|
||||
// Is there a game running
|
||||
boolean Playing(void);
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "d_netfil.h"
|
||||
#include "d_clisrv.h"
|
||||
#include "tic_command.h"
|
||||
#include "net_command.h"
|
||||
#include "../z_zone.h"
|
||||
#include "i_tcp.h"
|
||||
#include "../d_main.h" // srb2home
|
||||
|
@ -461,14 +462,10 @@ void Net_ConnectionTimeout(INT32 node)
|
|||
return;
|
||||
nodes[node].flags |= NF_TIMEOUT;
|
||||
|
||||
// Send a very special packet to self (hack the reboundstore queue)
|
||||
// Main code will handle it
|
||||
reboundstore[rebound_head].packettype = PT_NODETIMEOUT;
|
||||
reboundstore[rebound_head].ack = 0;
|
||||
reboundstore[rebound_head].ackreturn = 0;
|
||||
reboundstore[rebound_head].u.textcmd[0] = (UINT8)node;
|
||||
reboundsize[rebound_head] = (INT16)(BASEPACKETSIZE + 1);
|
||||
rebound_head = (rebound_head+1) % MAXREBOUND;
|
||||
if (server)
|
||||
SendKicksForNode(node, KICK_MSG_TIMEOUT | KICK_MSG_KEEP_BODY);
|
||||
else
|
||||
CL_HandleTimeout();
|
||||
|
||||
// Do not redo it quickly (if we do not close connection it is
|
||||
// for a good reason!)
|
||||
|
@ -782,7 +779,6 @@ static const char *packettypename[NUMPACKETTYPE] =
|
|||
"TEXTCMD",
|
||||
"TEXTCMD2",
|
||||
"CLIENTJOIN",
|
||||
"NODETIMEOUT",
|
||||
"LOGIN",
|
||||
"TELLFILESNEEDED",
|
||||
"MOREFILESNEEDED",
|
||||
|
@ -1065,10 +1061,7 @@ boolean HGetPacket(void)
|
|||
{
|
||||
M_Memcpy(netbuffer, &reboundstore[rebound_tail], reboundsize[rebound_tail]);
|
||||
doomcom->datalength = reboundsize[rebound_tail];
|
||||
if (netbuffer->packettype == PT_NODETIMEOUT)
|
||||
doomcom->remotenode = netbuffer->u.textcmd[0];
|
||||
else
|
||||
doomcom->remotenode = 0;
|
||||
doomcom->remotenode = 0;
|
||||
|
||||
rebound_tail = (rebound_tail+1) % MAXREBOUND;
|
||||
#ifdef DEBUGFILE
|
||||
|
|
|
@ -315,3 +315,13 @@ void SendKick(UINT8 playernum, UINT8 msg)
|
|||
buf[1] = msg;
|
||||
SendNetXCmd(XD_KICK, &buf, 2);
|
||||
}
|
||||
|
||||
void SendKicksForNode(SINT8 node, UINT8 msg)
|
||||
{
|
||||
if (!netnodes[node].ingame)
|
||||
return;
|
||||
|
||||
for (INT32 playernum = netnodes[node].player; playernum != -1; playernum = netnodes[node].player2)
|
||||
if (playernum != -1 && playeringame[playernum])
|
||||
SendKick(playernum, msg);
|
||||
}
|
||||
|
|
|
@ -58,5 +58,6 @@ size_t TotalTextCmdPerTic(tic_t tic);
|
|||
|
||||
void PT_TextCmd(SINT8 node, INT32 netconsole);
|
||||
void SendKick(UINT8 playernum, UINT8 msg);
|
||||
void SendKicksForNode(SINT8 node, UINT8 msg);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -85,7 +85,6 @@ typedef enum
|
|||
PT_TEXTCMD, // Extra text commands from the client.
|
||||
PT_TEXTCMD2, // Splitscreen text commands.
|
||||
PT_CLIENTJOIN, // Client wants to join; used in start game.
|
||||
PT_NODETIMEOUT, // Packet sent to self if the connection times out.
|
||||
|
||||
PT_LOGIN, // Login attempt from the client.
|
||||
|
||||
|
|
Loading…
Reference in a new issue