mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[net] Remove client references from net_main
This is progress towards #23. There are still some references to host_time and host_client (via nq's server.h), and a lot of references to sv and svs, but this is definitely a step in the right direction.
This commit is contained in:
parent
b2d4fa0ccf
commit
ef574e67d0
13 changed files with 41 additions and 40 deletions
|
@ -270,9 +270,11 @@ extern double net_time;
|
|||
extern struct msg_s *net_message;
|
||||
extern unsigned net_activeconnections;
|
||||
|
||||
struct cbuf_s;
|
||||
|
||||
/** Initialize the networking sub-system.
|
||||
*/
|
||||
void NET_Init (void);
|
||||
void NET_Init (struct cbuf_s *cbuf);
|
||||
|
||||
/** Check for new connections.
|
||||
|
||||
|
@ -447,6 +449,7 @@ typedef struct {
|
|||
|
||||
extern int net_numdrivers;
|
||||
extern net_driver_t net_drivers[MAX_NET_DRIVERS];
|
||||
extern int net_is_dedicated;
|
||||
|
||||
///@}
|
||||
|
||||
|
|
|
@ -47,9 +47,10 @@
|
|||
#include "netmain.h"
|
||||
#include "net_vcr.h"
|
||||
|
||||
#include "../nq/include/host.h"
|
||||
#include "../nq/include/server.h"
|
||||
|
||||
int net_is_dedicated = 0;
|
||||
|
||||
qsocket_t *net_activeSockets = NULL;
|
||||
qsocket_t *net_freeSockets = NULL;
|
||||
int net_numsockets = 0;
|
||||
|
@ -102,6 +103,8 @@ double net_time;
|
|||
static int hostCacheCount = 0;
|
||||
static hostcache_t hostcache[HOSTCACHESIZE];
|
||||
|
||||
static cbuf_t *net_cbuf;
|
||||
|
||||
double
|
||||
SetNetTime (void)
|
||||
{
|
||||
|
@ -219,10 +222,10 @@ MaxPlayers_f (void)
|
|||
}
|
||||
|
||||
if ((n == 1) && listening)
|
||||
Cbuf_AddText (host_cbuf, "listen 0\n");
|
||||
Cbuf_AddText (net_cbuf, "listen 0\n");
|
||||
|
||||
if ((n > 1) && (!listening))
|
||||
Cbuf_AddText (host_cbuf, "listen 1\n");
|
||||
Cbuf_AddText (net_cbuf, "listen 1\n");
|
||||
|
||||
svs.maxclients = n;
|
||||
if (n == 1)
|
||||
|
@ -253,8 +256,8 @@ NET_Port_f (void)
|
|||
|
||||
if (listening) {
|
||||
// force a change to the new port
|
||||
Cbuf_AddText (host_cbuf, "listen 0\n");
|
||||
Cbuf_AddText (host_cbuf, "listen 1\n");
|
||||
Cbuf_AddText (net_cbuf, "listen 0\n");
|
||||
Cbuf_AddText (net_cbuf, "listen 1\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -796,12 +799,14 @@ NET_shutdown (void *data)
|
|||
}
|
||||
|
||||
void
|
||||
NET_Init (void)
|
||||
NET_Init (cbuf_t *cbuf)
|
||||
{
|
||||
int i;
|
||||
int controlSocket;
|
||||
qsocket_t *s;
|
||||
|
||||
net_cbuf = cbuf;
|
||||
|
||||
Sys_RegisterShutdown (NET_shutdown, 0);
|
||||
|
||||
if (COM_CheckParm ("-playback")) {
|
||||
|
@ -826,10 +831,10 @@ NET_Init (void)
|
|||
}
|
||||
net_hostport = DEFAULTnet_hostport;
|
||||
|
||||
if (COM_CheckParm ("-listen") || cls.state == ca_dedicated)
|
||||
if (COM_CheckParm ("-listen") || net_is_dedicated)
|
||||
listening = true;
|
||||
net_numsockets = svs.maxclientslimit;
|
||||
if (cls.state != ca_dedicated)
|
||||
if (!net_is_dedicated)
|
||||
net_numsockets++;
|
||||
|
||||
SetNetTime ();
|
||||
|
|
|
@ -46,9 +46,7 @@
|
|||
|
||||
#include "netmain.h"
|
||||
|
||||
#include "../nq/include/client.h"
|
||||
#include "../nq/include/server.h"
|
||||
#include "../nq/include/game.h"
|
||||
|
||||
// This is enables a simple IP banning mechanism
|
||||
#define BAN_TEST
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "netmain.h"
|
||||
#include "net_loop.h"
|
||||
|
||||
#include "../nq/include/client.h"
|
||||
#include "../nq/include/server.h"
|
||||
|
||||
qboolean localconnectpending = false;
|
||||
|
@ -45,7 +44,7 @@ qsocket_t *loop_server = NULL;
|
|||
__attribute__((pure)) int
|
||||
Loop_Init (void)
|
||||
{
|
||||
if (cls.state == ca_dedicated)
|
||||
if (net_is_dedicated)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
net_wins.c
|
||||
|
||||
|
|
|
@ -70,7 +70,6 @@ typedef enum {
|
|||
#define MAX_DEMONAME 16
|
||||
|
||||
typedef enum {
|
||||
ca_dedicated, // a dedicated server with no ability to start a client
|
||||
ca_disconnected, // full screen console with no connection
|
||||
ca_connected, // talking to a server
|
||||
ca_active, // everything is in, so frames can be rendered
|
||||
|
|
|
@ -306,7 +306,7 @@ CL_Disconnect_f (void)
|
|||
void
|
||||
CL_EstablishConnection (const char *host)
|
||||
{
|
||||
if (cls.state == ca_dedicated)
|
||||
if (net_is_dedicated)
|
||||
return;
|
||||
|
||||
if (cls.demoplayback)
|
||||
|
@ -510,8 +510,6 @@ CL_SetState (cactive_t state)
|
|||
r_funcs->R_ClearState ();
|
||||
}
|
||||
switch (state) {
|
||||
case ca_dedicated:
|
||||
break;
|
||||
case ca_disconnected:
|
||||
CL_ClearState ();
|
||||
cls.signon = so_none;
|
||||
|
|
|
@ -157,7 +157,7 @@ Host_EndGame (const char *message, ...)
|
|||
if (sv.active)
|
||||
Host_ShutdownServer (false);
|
||||
|
||||
if (cls.state == ca_dedicated)
|
||||
if (net_is_dedicated)
|
||||
Sys_Error ("Host_EndGame: %s", str->str); // dedicated servers exit
|
||||
|
||||
if (cls.demonum != -1)
|
||||
|
@ -197,7 +197,7 @@ Host_Error (const char *error, ...)
|
|||
if (sv.active)
|
||||
Host_ShutdownServer (false);
|
||||
|
||||
if (cls.state == ca_dedicated)
|
||||
if (net_is_dedicated)
|
||||
Sys_Error ("Host_Error: %s", str->str); // dedicated servers exit
|
||||
|
||||
Sys_Printf ("Host_Error: %s\n", str->str);
|
||||
|
@ -219,17 +219,17 @@ Host_FindMaxClients (void)
|
|||
|
||||
i = COM_CheckParm ("-dedicated");
|
||||
if (i) {
|
||||
cls.state = ca_dedicated;
|
||||
if (i != (com_argc - 1)) {
|
||||
svs.maxclients = atoi (com_argv[i + 1]);
|
||||
} else
|
||||
svs.maxclients = 8;
|
||||
} else
|
||||
cls.state = ca_disconnected;
|
||||
}
|
||||
cls.state = ca_disconnected;
|
||||
net_is_dedicated = i;
|
||||
|
||||
i = COM_CheckParm ("-listen");
|
||||
if (i) {
|
||||
if (cls.state == ca_dedicated)
|
||||
if (net_is_dedicated)
|
||||
Sys_Error ("Only one of -dedicated or -listen can be specified");
|
||||
if (i != (com_argc - 1))
|
||||
svs.maxclients = atoi (com_argv[i + 1]);
|
||||
|
@ -676,10 +676,10 @@ _Host_Frame (float time)
|
|||
return;
|
||||
}
|
||||
|
||||
if (cls.state != ca_dedicated)
|
||||
if (!net_is_dedicated)
|
||||
IN_ProcessEvents ();
|
||||
|
||||
if (cls.state == ca_dedicated)
|
||||
if (net_is_dedicated)
|
||||
Con_ProcessInput ();
|
||||
|
||||
GIB_Thread_Execute ();
|
||||
|
@ -708,7 +708,7 @@ _Host_Frame (float time)
|
|||
Host_ServerFrame ();
|
||||
}
|
||||
|
||||
if (cls.state != ca_dedicated)
|
||||
if (!net_is_dedicated)
|
||||
Host_ClientFrame ();
|
||||
else
|
||||
host_time += host_frametime; //FIXME is this needed? vcr stuff
|
||||
|
@ -920,13 +920,13 @@ Host_Init (void)
|
|||
Host_InitVCR (&host_parms);
|
||||
Host_InitLocal ();
|
||||
|
||||
NET_Init ();
|
||||
NET_Init (host_cbuf);
|
||||
|
||||
Mod_Init ();
|
||||
|
||||
SV_Init ();
|
||||
|
||||
if (cls.state != ca_dedicated)
|
||||
if (!net_is_dedicated)
|
||||
CL_Init (host_cbuf);
|
||||
|
||||
if (con_module) {
|
||||
|
|
|
@ -303,7 +303,7 @@ Host_Map_f (void)
|
|||
if (!sv.active)
|
||||
return;
|
||||
|
||||
if (cls.state != ca_dedicated) {
|
||||
if (!net_is_dedicated) {
|
||||
Cmd_ExecuteString ("connect local", src_command);
|
||||
}
|
||||
}
|
||||
|
@ -717,7 +717,7 @@ Host_Loadgame_f (void)
|
|||
for (i = 0; i < NUM_SPAWN_PARMS; i++)
|
||||
svs.clients->spawn_parms[i] = spawn_parms[i];
|
||||
|
||||
if (cls.state != ca_dedicated) {
|
||||
if (!net_is_dedicated) {
|
||||
CL_EstablishConnection ("local");
|
||||
Host_Reconnect_f ();
|
||||
}
|
||||
|
@ -790,7 +790,7 @@ Host_Say (qboolean teamonly)
|
|||
qboolean fromServer = false;
|
||||
|
||||
if (cmd_source == src_command) {
|
||||
if (cls.state == ca_dedicated) {
|
||||
if (net_is_dedicated) {
|
||||
fromServer = true;
|
||||
teamonly = false;
|
||||
} else {
|
||||
|
@ -1134,7 +1134,7 @@ Host_Kick_f (void)
|
|||
|
||||
if (i < svs.maxclients) {
|
||||
if (cmd_source == src_command)
|
||||
if (cls.state == ca_dedicated)
|
||||
if (net_is_dedicated)
|
||||
who = "Console";
|
||||
else
|
||||
who = cl_name->string;
|
||||
|
@ -1403,7 +1403,7 @@ Host_Startdemos_f (void)
|
|||
{
|
||||
int i, c;
|
||||
|
||||
if (cls.state == ca_dedicated) {
|
||||
if (net_is_dedicated) {
|
||||
if (!sv.active)
|
||||
Cbuf_AddText (host_cbuf, "map start\n");
|
||||
return;
|
||||
|
@ -1434,7 +1434,7 @@ Host_Startdemos_f (void)
|
|||
static void
|
||||
Host_Demos_f (void)
|
||||
{
|
||||
if (cls.state == ca_dedicated)
|
||||
if (net_is_dedicated)
|
||||
return;
|
||||
if (cls.demonum == -1)
|
||||
cls.demonum = 1;
|
||||
|
@ -1450,7 +1450,7 @@ Host_Demos_f (void)
|
|||
static void
|
||||
Host_Stopdemo_f (void)
|
||||
{
|
||||
if (cls.state == ca_dedicated)
|
||||
if (net_is_dedicated)
|
||||
return;
|
||||
if (!cls.demoplayback)
|
||||
return;
|
||||
|
|
|
@ -1064,7 +1064,7 @@ SV_SendReconnect (void)
|
|||
MSG_WriteString (&msg, "reconnect\n");
|
||||
NET_SendToAll (&msg, 5.0);
|
||||
|
||||
if (cls.state != ca_dedicated)
|
||||
if (!net_is_dedicated)
|
||||
Cmd_ExecuteString ("reconnect\n", src_command);
|
||||
}
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ SDL_main (int argc, char *argv[])
|
|||
newtime = Sys_DoubleTime ();
|
||||
time = newtime - oldtime;
|
||||
|
||||
if (cls.state == ca_dedicated) { // play vcrfiles at max speed
|
||||
if (net_is_dedicated) { // play vcrfiles at max speed
|
||||
if (time < sys_ticrate->value && (!vcrFile || recording)) {
|
||||
usleep (1);
|
||||
continue; // not time to run a server-only tic yet
|
||||
|
|
|
@ -91,7 +91,7 @@ main (int argc, const char **argv)
|
|||
newtime = Sys_DoubleTime ();
|
||||
time = newtime - oldtime;
|
||||
|
||||
if (cls.state == ca_dedicated) { // play vcrfiles at max speed
|
||||
if (net_is_dedicated) { // play vcrfiles at max speed
|
||||
if (time < sys_ticrate->value && (!vcrFile || recording)) {
|
||||
usleep (1);
|
||||
continue; // not time to run a server-only tic yet
|
||||
|
|
|
@ -228,7 +228,7 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
|
|||
newtime = Sys_DoubleTime ();
|
||||
time = newtime - oldtime;
|
||||
|
||||
if (cls.state == ca_dedicated) { // play vcrfiles at max speed
|
||||
if (net_is_dedicated) { // play vcrfiles at max speed
|
||||
if (time < sys_ticrate->value && (!vcrFile || recording)) {
|
||||
Sleep (1);
|
||||
continue; // not time to run a server-only tic yet
|
||||
|
|
Loading…
Reference in a new issue