}
}
-static void NetConn_UpdateServerStuff(void);
void NetConn_OpenServerPorts(int opennetports)
{
int port;
NetConn_CloseServerPorts();
- NetConn_UpdateServerStuff();
+ NetConn_UpdateSockets();
port = bound(0, sv_netport.integer, 65535);
if (port == 0)
port = 26000;
conn->peeraddress = *peeraddress;
conn->canSend = true;
conn->lastMessageTime = realtime;
+ conn->message.data = conn->messagedata;
+ conn->message.maxsize = sizeof(conn->messagedata);
+ conn->message.cursize = 0;
// LordHavoc: (inspired by ProQuake) use a short connect timeout to
// reduce effectiveness of connection request floods
conn->timeout = realtime + net_connecttimeout.value;
static int clientport = -1;
static int clientport2 = -1;
static int hostport = -1;
-static void NetConn_UpdateServerStuff(void)
+void NetConn_UpdateSockets(void)
{
if (cls.state != ca_dedicated)
{
CL_Disconnect();
// if we're connecting to a remote server, shut down any local server
if (LHNETADDRESS_GetAddressType(peeraddress) != LHNETADDRESSTYPE_LOOP && sv.active)
- Host_ShutdownServer (false);
+ Host_ShutdownServer ();
// allocate a net connection to keep track of things
cls.netcon = NetConn_Open(mysocket, peeraddress);
Con_Printf("Connection accepted to %s\n", cls.netcon->address);
int i, length;
lhnetaddress_t peeraddress;
netconn_t *conn;
- NetConn_UpdateServerStuff();
+ NetConn_UpdateSockets();
if (cls.connect_trying && cls.connect_nextsendtime < realtime)
{
if (cls.connect_remainingtries == 0)
{
Con_Print("Connection timed out\n");
CL_Disconnect();
- Host_ShutdownServer (false);
+ Host_ShutdownServer ();
}
for (conn = netconn_list;conn;conn = conn->next)
NetConn_ReSendMessage(conn);
int i, length;
lhnetaddress_t peeraddress;
netconn_t *conn;
- NetConn_UpdateServerStuff();
+ NetConn_UpdateSockets();
for (i = 0;i < sv_numsockets;i++)
while (sv_sockets[i] && (length = NetConn_Read(sv_sockets[i], readbuffer, sizeof(readbuffer), &peeraddress)) > 0)
NetConn_ServerParsePacket(sv_sockets[i], readbuffer, length, &peeraddress);
}
}
-int NetConn_SendToAll(sizebuf_t *data, double blocktime)
-{
- int i, count = 0;
- unsigned char sent[MAX_SCOREBOARD];
-
- memset(sent, 0, sizeof(sent));
-
- // simultaneously wait for the first CanSendMessage and send the message,
- // then wait for a second CanSendMessage (verifying it was received), or
- // the client drops and is no longer counted
- // the loop aborts when either it runs out of clients to send to, or a
- // timeout expires
- blocktime += Sys_DoubleTime();
- do
- {
- count = 0;
- // run a network frame to check for packets
- NetConn_ClientFrame();SV_VM_Begin();NetConn_ServerFrame();SV_VM_End();
- for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
- {
- if (host_client->netconnection)
- {
- if (NetConn_CanSendMessage(host_client->netconnection))
- {
- if (!sent[i])
- NetConn_SendReliableMessage(host_client->netconnection, data);
- sent[i] = true;
- }
- if (!NetConn_CanSendMessage(host_client->netconnection))
- count++;
- }
- }
- }
- while (count && Sys_DoubleTime() < blocktime);
- return count;
-}
-
static void Net_Heartbeat_f(void)
{
if (sv.active)