1
0
Fork 0
forked from fte/fteqw

add net_enabled cvar. set to 0 to block all network stuff (might need a map change to take full effect).

fix capturedemo and qwd files.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4885 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2015-06-05 03:45:01 +00:00
parent df8758c986
commit 3a994a3a99
6 changed files with 60 additions and 34 deletions

View file

@ -363,7 +363,7 @@ void CL_ProgressDemoTime(void)
{ {
extern cvar_t cl_demospeed; extern cvar_t cl_demospeed;
if (cl.parsecount && Media_PausedDemo()) if (cl.parsecount && Media_PausedDemo(true))
{ //console visible whilst democapturing { //console visible whilst democapturing
cls.netchan.last_received = realtime; cls.netchan.last_received = realtime;
return; return;
@ -1634,6 +1634,8 @@ void CL_PlayDemoStream(vfsfile_t *file, struct dl_download *dl, char *filename,
CL_Disconnect_f (); CL_Disconnect_f ();
demo_flushcache(); demo_flushcache();
NET_InitClient(true);
// //
// open the demo file // open the demo file
// //
@ -1703,6 +1705,8 @@ void CL_PlayDemoFile(vfsfile_t *f, char *demoname, qboolean issyspath)
VFS_READ(f, &type, sizeof(type)); VFS_READ(f, &type, sizeof(type));
VFS_READ(f, &protocol, sizeof(protocol)); VFS_READ(f, &protocol, sizeof(protocol));
VFS_SEEK(f, start); VFS_SEEK(f, start);
len = LittleLong(len);
protocol = LittleLong(protocol);
if (len > 5 && type == svcq2_serverdata && protocol == PROTOCOL_VERSION_Q2) if (len > 5 && type == svcq2_serverdata && protocol == PROTOCOL_VERSION_Q2)
{ {
CL_PlayDemoStream(f, NULL, demoname, issyspath, DPB_QUAKE2, 0); CL_PlayDemoStream(f, NULL, demoname, issyspath, DPB_QUAKE2, 0);

View file

@ -677,6 +677,9 @@ void CL_CheckForResend (void)
pext2 = 0; pext2 = 0;
connectinfo.trying = true; connectinfo.trying = true;
connectinfo.istransfer = false; connectinfo.istransfer = false;
NET_InitClient(true);
Q_strncpyz (cls.servername, "internalserver", sizeof(cls.servername)); Q_strncpyz (cls.servername, "internalserver", sizeof(cls.servername));
Cvar_ForceSet(&cl_servername, cls.servername); Cvar_ForceSet(&cl_servername, cls.servername);
NET_StringToAdr(cls.servername, 0, &connectinfo.adr); NET_StringToAdr(cls.servername, 0, &connectinfo.adr);
@ -842,6 +845,8 @@ void CL_CheckForResend (void)
if (connectinfo.time && realtime - connectinfo.time < 5.0) if (connectinfo.time && realtime - connectinfo.time < 5.0)
return; return;
NET_InitClient(false);
t1 = Sys_DoubleTime (); t1 = Sys_DoubleTime ();
if (!connectinfo.istransfer) if (!connectinfo.istransfer)
{ {
@ -5171,7 +5176,6 @@ void Host_Init (quakeparms_t *parms)
#endif #endif
Host_FixupModelNames(); Host_FixupModelNames();
NET_InitClient ();
Netchan_Init (); Netchan_Init ();
Renderer_Init(); Renderer_Init();
Mod_Init(true); Mod_Init(true);

View file

@ -2861,12 +2861,17 @@ void Media_CapturePause_f (void)
capturepaused = !capturepaused; capturepaused = !capturepaused;
} }
qboolean Media_PausedDemo (void) qboolean Media_PausedDemo (qboolean fortiming)
{ {
//if fortiming is set, then timing might need to advance if we still need to parse the demo to get the first valid data out of it.
if (capturepaused)
return true;
//capturedemo doesn't record any frames when the console is visible //capturedemo doesn't record any frames when the console is visible
//but that's okay, as we don't load any demo frames either. //but that's okay, as we don't load any demo frames either.
if ((cls.demoplayback && Media_Capturing()) || capturepaused) if ((cls.demoplayback && Media_Capturing()))
if (Key_Dest_Has(~kdm_game) || scr_con_current > 0 || !cl.validsequence || capturepaused) if (Key_Dest_Has(~kdm_game) || scr_con_current > 0 || (!fortiming&&!cl.validsequence))
return true; return true;
return false; return false;
@ -2908,7 +2913,7 @@ void Media_RecordFrame (void)
captureframe = 0; captureframe = 0;
} }
*/ */
if (Media_PausedDemo()) if (Media_PausedDemo(false))
{ {
int y = vid.height -32-16; int y = vid.height -32-16;
if (y < scr_con_current) y = scr_con_current; if (y < scr_con_current) y = scr_con_current;

View file

@ -482,7 +482,7 @@ extern struct model_s *currentmodel;
qboolean Media_ShowFilm(void); qboolean Media_ShowFilm(void);
void Media_CaptureDemoEnd(void); void Media_CaptureDemoEnd(void);
void Media_RecordFrame (void); void Media_RecordFrame (void);
qboolean Media_PausedDemo (void); qboolean Media_PausedDemo (qboolean fortiming);
int Media_Capturing (void); int Media_Capturing (void);
double Media_TweekCaptureFrameTime(double oldtime, double time); double Media_TweekCaptureFrameTime(double oldtime, double time);

View file

@ -86,7 +86,7 @@ struct ftenet_connections_s;
void NET_Init (void); void NET_Init (void);
void NET_Tick (void); void NET_Tick (void);
void SVNET_RegisterCvars(void); void SVNET_RegisterCvars(void);
void NET_InitClient (void); void NET_InitClient (qboolean loopbackonly);
void NET_InitServer (void); void NET_InitServer (void);
qboolean NET_WasSpecialPacket(netsrc_t netsrc); qboolean NET_WasSpecialPacket(netsrc_t netsrc);
void NET_CloseServer (void); void NET_CloseServer (void);

View file

@ -77,6 +77,7 @@ void IPX_CloseSocket (int socket);
#endif #endif
cvar_t net_hybriddualstack = CVAR("net_hybriddualstack", "1"); cvar_t net_hybriddualstack = CVAR("net_hybriddualstack", "1");
cvar_t net_fakeloss = CVARFD("net_fakeloss", "0", CVAR_CHEAT, "Simulates packetloss in both receiving and sending, on a scale from 0 to 1."); cvar_t net_fakeloss = CVARFD("net_fakeloss", "0", CVAR_CHEAT, "Simulates packetloss in both receiving and sending, on a scale from 0 to 1.");
cvar_t net_enabled = CVARD("net_enabled", "1", "If 0, disables all network access, including name resolution and socket creation. Does not affect loopback/internal connections.");
extern cvar_t sv_public, sv_listen_qw, sv_listen_nq, sv_listen_dp, sv_listen_q3; extern cvar_t sv_public, sv_listen_qw, sv_listen_nq, sv_listen_dp, sv_listen_q3;
@ -938,8 +939,6 @@ size_t NET_StringToAdr2 (const char *s, int defaultport, netadr_t *a, size_t num
memset(a, 0, sizeof(*a)*numaddresses); memset(a, 0, sizeof(*a)*numaddresses);
Con_DPrintf("Resolving address: %s\n", s);
if (!numaddresses) if (!numaddresses)
return false; return false;
@ -948,6 +947,7 @@ size_t NET_StringToAdr2 (const char *s, int defaultport, netadr_t *a, size_t num
a->type = NA_LOOPBACK; a->type = NA_LOOPBACK;
return true; return true;
} }
if (!strncmp(s, "QLoopBack", 9)) if (!strncmp(s, "QLoopBack", 9))
{ {
a->type = NA_LOOPBACK; a->type = NA_LOOPBACK;
@ -958,6 +958,10 @@ size_t NET_StringToAdr2 (const char *s, int defaultport, netadr_t *a, size_t num
return true; return true;
} }
if (!net_enabled.ival)
return false;
Con_DPrintf("Resolving address: %s\n", s);
#ifdef HAVE_WEBSOCKCL #ifdef HAVE_WEBSOCKCL
if (!strncmp (s, "ws://", 5) || !strncmp (s, "wss://", 6)) if (!strncmp (s, "ws://", 5) || !strncmp (s, "wss://", 6))
{ {
@ -2557,17 +2561,19 @@ qboolean FTENET_Generic_SendPacket(ftenet_generic_connection_t *con, int length,
qboolean NET_PortToAdr (int adrfamily, const char *s, netadr_t *a) qboolean NET_PortToAdr (int adrfamily, const char *s, netadr_t *a)
{ {
char *e; char *e;
int port; if (net_enabled.ival || adrfamily == NA_LOOPBACK)
port = strtoul(s, &e, 10);
if (*e) //if *e then its not just a single number in there, so treat it as a proper address.
return NET_StringToAdr(s, 0, a);
else if (e != s) //if we actually read something (even a 0)
{ {
memset(a, 0, sizeof(*a)); int port = strtoul(s, &e, 10);
a->port = htons((unsigned short)port); if (*e) //if *e then its not just a single number in there, so treat it as a proper address.
a->type = adrfamily; return NET_StringToAdr(s, 0, a);
else if (e != s) //if we actually read something (even a 0)
{
memset(a, 0, sizeof(*a));
a->port = htons((unsigned short)port);
a->type = adrfamily;
return a->type != NA_INVALID; return a->type != NA_INVALID;
}
} }
a->type = NA_INVALID; a->type = NA_INVALID;
return false; return false;
@ -5553,23 +5559,27 @@ NET_Init
*/ */
void NET_Init (void) void NET_Init (void)
{ {
#if defined(_WIN32) && defined(HAVE_PACKET) Cvar_Register(&net_enabled, "networking");
int r; if (!net_enabled.ival)
#ifdef IPPROTO_IPV6
dllfunction_t fncs[] =
{ {
{(void**)&pgetaddrinfo, "getaddrinfo"}, #if defined(_WIN32) && defined(HAVE_PACKET)
{(void**)&pfreeaddrinfo, "freeaddrinfo"}, int r;
{NULL, NULL} #ifdef IPPROTO_IPV6
}; dllfunction_t fncs[] =
Sys_LoadLibrary("ws2_32.dll", fncs); {
{(void**)&pgetaddrinfo, "getaddrinfo"},
{(void**)&pfreeaddrinfo, "freeaddrinfo"},
{NULL, NULL}
};
Sys_LoadLibrary("ws2_32.dll", fncs);
#endif #endif
r = WSAStartup (MAKEWORD(2, 2), &winsockdata); r = WSAStartup (MAKEWORD(2, 2), &winsockdata);
if (r) if (r)
Sys_Error ("Winsock initialization failed."); Sys_Error ("Winsock initialization failed.");
#endif #endif
}
Cvar_Register(&net_hybriddualstack, "networking"); Cvar_Register(&net_hybriddualstack, "networking");
Cvar_Register(&net_fakeloss, "networking"); Cvar_Register(&net_fakeloss, "networking");
@ -5591,7 +5601,7 @@ void NET_Init (void)
Net_Master_Init(); Net_Master_Init();
} }
#ifndef SERVERONLY #ifndef SERVERONLY
void NET_InitClient(void) void NET_InitClient(qboolean loopbackonly)
{ {
const char *port; const char *port;
int p; int p;
@ -5608,10 +5618,13 @@ void NET_InitClient(void)
port = com_argv[p+1]; port = com_argv[p+1];
} }
cls.sockets = FTENET_CreateCollection(false); if (!cls.sockets)
cls.sockets = FTENET_CreateCollection(false);
#ifndef CLIENTONLY #ifndef CLIENTONLY
FTENET_AddToCollection(cls.sockets, "CLLoopback", "1", NA_LOOPBACK, true); FTENET_AddToCollection(cls.sockets, "CLLoopback", "1", NA_LOOPBACK, true);
#endif #endif
if (loopbackonly)
port = "";
#ifdef HAVE_IPV4 #ifdef HAVE_IPV4
FTENET_AddToCollection(cls.sockets, "CLUDP4", port, NA_IP, true); FTENET_AddToCollection(cls.sockets, "CLUDP4", port, NA_IP, true);
#endif #endif