spingle/source/net.h

115 lines
3.6 KiB
C
Raw Permalink Normal View History

2019-11-24 20:45:15 -08:00
/*
Copyright (C) 1996-2001 Id Software, Inc.
Copyright (C) 2002-2009 John Fitzgibbons and others
Copyright (C) 2009-2010 Ozkan Sezer
Copyright (C) 2010-2014 QuakeSpasm developers
This program 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 2
of the License, or (at your option) any later version.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
2019-11-25 17:40:18 -08:00
net.h
quake's interface to the networking layer
network functions and data, common to the
whole engine
2019-11-24 20:45:15 -08:00
*/
2019-12-02 07:00:56 -08:00
#ifndef spingle__quake_net_h
#define spingle__quake_net_h
2019-11-24 20:45:15 -08:00
2019-11-25 17:40:18 -08:00
#define NET_NAMELEN 64
2019-11-24 20:45:15 -08:00
2019-11-25 17:40:18 -08:00
#define NET_MAXMESSAGE 64000 /* ericw -- was 32000 */
2019-11-24 20:45:15 -08:00
2019-11-25 17:40:18 -08:00
extern int32_t DEFAULTnet_hostport;
extern int32_t net_hostport;
2019-11-24 20:45:15 -08:00
2019-11-25 17:40:18 -08:00
extern cvar_t hostname;
2019-11-24 20:45:15 -08:00
2019-11-25 17:40:18 -08:00
extern double net_time;
extern sizebuf_t net_message;
extern int32_t net_activeconnections;
2019-11-24 20:45:15 -08:00
2019-11-25 17:40:18 -08:00
void NET_Init(void);
void NET_Shutdown(void);
2019-11-24 20:45:15 -08:00
2019-11-25 17:40:18 -08:00
struct qsocket_s *NET_CheckNewConnections(void);
2019-11-24 20:45:15 -08:00
// returns a new connection number if there is one pending, else -1
2019-11-25 17:40:18 -08:00
struct qsocket_s *NET_Connect(const char *host);
2019-11-24 20:45:15 -08:00
// called by client to connect to a host. Returns -1 if not able to
2019-11-25 17:40:18 -08:00
double NET_QSocketGetTime(const struct qsocket_s *sock);
const char *NET_QSocketGetAddressString(const struct qsocket_s *sock);
2019-11-24 20:45:15 -08:00
2019-11-25 17:40:18 -08:00
bool NET_CanSendMessage(struct qsocket_s *sock);
2019-11-24 20:45:15 -08:00
// Returns true or false if the given qsocket can currently accept a
// message to be transmitted.
2019-11-25 17:40:18 -08:00
int32_t NET_GetMessage(struct qsocket_s *sock);
2019-11-24 20:45:15 -08:00
// returns data in net_message sizebuf
// returns 0 if no data is waiting
// returns 1 if a message was received
// returns 2 if an unreliable message was received
// returns -1 if the connection died
2019-11-25 17:40:18 -08:00
int32_t NET_SendMessage(struct qsocket_s *sock, sizebuf_t *data);
int32_t NET_SendUnreliableMessage(struct qsocket_s *sock, sizebuf_t *data);
2019-11-24 20:45:15 -08:00
// returns 0 if the message connot be delivered reliably, but the connection
// is still considered valid
// returns 1 if the message was sent properly
// returns -1 if the connection died
2019-11-25 17:40:18 -08:00
int32_t NET_SendToAll(sizebuf_t *data, double blocktime);
2019-11-24 20:45:15 -08:00
// This is a reliable *blocking* send to all attached clients.
2019-11-25 17:40:18 -08:00
void NET_Close(struct qsocket_s *sock);
2019-11-24 20:45:15 -08:00
// if a dead connection is returned by a get or send function, this function
// should be called when it is convenient
// Server calls when a client is kicked off for a game related misbehavior
// like an illegal protocal conversation. Client calls when disconnecting
// from a server.
// A netcon_t number will not be reused until this function is called for it
2019-11-25 17:40:18 -08:00
void NET_Poll(void);
2019-11-24 20:45:15 -08:00
// Server list related globals:
2019-11-25 17:40:18 -08:00
extern bool slistInProgress;
extern bool slistSilent;
extern bool slistLocal;
2019-11-24 20:45:15 -08:00
2019-11-25 17:40:18 -08:00
extern int32_t hostCacheCount;
2019-11-24 20:45:15 -08:00
2019-11-25 17:40:18 -08:00
void NET_Slist_f(void);
void NET_SlistSort(void);
const char *NET_SlistPrintServer(int32_t n);
const char *NET_SlistPrintServerName(int32_t n);
2019-11-24 20:45:15 -08:00
/* FIXME: driver related, but public:
*/
2019-11-25 17:40:18 -08:00
extern bool ipxAvailable;
extern bool tcpipAvailable;
extern char my_ipx_address[NET_NAMELEN];
extern char my_tcpip_address[NET_NAMELEN];
2019-11-24 20:45:15 -08:00
2019-12-02 07:00:56 -08:00
#endif