{
int i;
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
return -1;
// COMMANDLINEOPTION: Sound: -nocdaudio disables CD audio support
*/
void CL_Disconnect(void)
{
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
return;
if (COM_CheckParm("-profilegameonly"))
*/
void CL_EstablishConnection(const char *host, int firstarg)
{
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
return;
// don't connect to a server if we're benchmarking a demo
if(!thisrecursive)
{
- if(cls.state != ca_dedicated)
+ if(!sv_dedicated)
{
if(countdownupdate <= 0) // check if time stepped backwards
{
int old_key_consoleactive;
// don't do anything if not initialized yet
- if (vid_hidden || cls.state == ca_dedicated)
+ if (vid_hidden || sv_dedicated)
return;
// limit update rate
typedef enum cactive_e
{
ca_uninitialized, // during early startup
- ca_dedicated, // a dedicated server with no ability to start a client
ca_disconnected, // full screen console with no connection
ca_connected // valid netcon, talking to a server
}
// send to log file
Log_ConPrint(line);
// send to scrollable buffer
- if (con_initialized && cls.state != ca_dedicated)
+ if (con_initialized && !sv_dedicated)
{
Con_PrintToHistory(line, mask);
}
}
}
#endif
- if ((var->flags & CVAR_USERINFO) && cls.state != ca_dedicated)
+ if ((var->flags & CVAR_USERINFO) && !sv_dedicated)
CL_SetInfo(var->name, var->string, true, false, false, false);
- else if ((var->flags & CVAR_NQUSERINFOHACK) && cls.state != ca_dedicated)
+ else if ((var->flags & CVAR_NQUSERINFOHACK) && !sv_dedicated)
{
// update the cls.userinfo to have proper values for the
// silly nq config variables.
int mymiplevel;
char vabuf[1024];
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
return NULL;
// return an existing skinframe if already loaded
skinframe_t *skinframe;
char vabuf[1024];
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
return NULL;
// if already loaded just return it, otherwise make a new skinframe
int featuresmask;
skinframe_t *skinframe;
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
return NULL;
// if already loaded just return it, otherwise make a new skinframe
skinframe_t *skinframe;
char vabuf[1024];
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
return NULL;
// if already loaded just return it, otherwise make a new skinframe
{
skinframe_t *skinframe;
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
return NULL;
skinframe = R_SkinFrame_Find("missing", TEXF_FORCENEAREST, 0, 0, 0, true);
unsigned char *temppixels = NULL;
qboolean swaprb;
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
return NULL;
// see if we need to swap red and blue (BGRA <-> RGBA conversion)
gltexturepool_t *pool = (gltexturepool_t *)rtexturepool;
textypeinfo_t *texinfo;
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
return NULL;
texinfo = R_GetTexTypeInfo(textype, TEXF_RENDERTARGET | TEXF_CLAMP);
KTX_dimensions sizes;
#endif
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
return NULL;
#ifdef __ANDROID__
int host_framecount = 0;
// LordHavoc: set when quit is executed
qboolean host_shuttingdown = false;
+// dedicated server
+qboolean sv_dedicated = false;
// the accumulated mainloop time since application started (with filtering), without any slowmo or clamping
double realtime;
Host_ShutdownServer ();
SV_UnlockThreadMutex();
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
Sys_Error ("Host_Error: %s",hosterrorstring2); // dedicated servers exit
CL_Disconnect ();
if (i)
{
#endif
- cls.state = ca_dedicated;
+ sv_dedicated = true;
// check for -dedicated specifying how many players
if (i && i + 1 < com_argc && atoi (com_argv[i+1]) >= 1)
svs.maxclients = atoi (com_argv[i+1]);
// dedicated servers initialize the host but don't parse and set the
// config.cfg cvars
// LordHavoc: don't save a config if it crashed in startup
- if (host_framecount >= 3 && cls.state != ca_dedicated && !COM_CheckParm("-benchmark") && !COM_CheckParm("-capturedemo"))
+ if (host_framecount >= 3 && !sv_dedicated && !COM_CheckParm("-benchmark") && !COM_CheckParm("-capturedemo"))
{
f = FS_OpenRealFile(file, "wb", false);
if (!f)
}
}
- if (sv_echobprint.integer && cls.state == ca_dedicated)
+ if (sv_echobprint.integer && sv_dedicated)
Con_Print(msg);
}
//Con_Printf("%6.0f %6.0f\n", cl_timer * 1000000.0, sv_timer * 1000000.0);
// if the accumulators haven't become positive yet, wait a while
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
wait = sv_timer * -1000000.0;
else if (!sv.active || svs.threaded)
wait = cl_timer * -1000000.0;
//
//-------------------
- if (cls.state != ca_dedicated && (cl_timer > 0 || cls.timedemo || ((vid_activewindow ? cl_maxfps : cl_maxidlefps).value < 1)))
+ if (!sv_dedicated && (cl_timer > 0 || cls.timedemo || ((vid_activewindow ? cl_maxfps : cl_maxidlefps).value < 1)))
{
R_TimeReport("---");
Collision_Cache_NewFrame();
qboolean vid_opened = false;
void Host_StartVideo(void)
{
- if (!vid_opened && cls.state != ca_dedicated)
+ if (!vid_opened && !sv_dedicated)
{
vid_opened = true;
// make sure we open sockets before opening video because the Windows Firewall "unblock?" dialog can screw up the graphics context on some graphics drivers
Thread_Init();
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
Cmd_AddCommand ("disconnect", CL_Disconnect_f, "disconnect from server (or disconnect all clients if running a server)");
else
{
SCR_BeginLoadingPlaque(true);
#ifdef CONFIG_MENU
- if (cls.state != ca_dedicated)
+ if (!sv_dedicated)
{
MR_Init();
}
Cbuf_Execute();
}
- if (cls.state == ca_dedicated || COM_CheckParm("-listen"))
+ if (sv_dedicated || COM_CheckParm("-listen"))
if (!sv.active && !cls.demoplayback && !cls.connect_trying)
{
Cbuf_AddText("startmap_dm\n");
//Host_StartVideo();
- if (cls.state != ca_dedicated)
+ if (!sv_dedicated)
SV_StartThread();
}
NetConn_Shutdown ();
//PR_Shutdown ();
- if (cls.state != ca_dedicated)
+ if (!sv_dedicated)
{
#ifdef CONFIG_CLIENT
R_Modules_Shutdown();
if (cmd_source == src_command)
{
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
{
fromServer = true;
teamonly = false;
SV_ClientPrint(text);
host_client = save;
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
Con_Print(&text[1]);
}
if (cmd_source == src_command)
{
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
fromServer = true;
else
{
{
if (cmd_source == src_client)
{
- if(cls.state == ca_dedicated || host_client != &svs.clients[0]) // non-admin
+ if(sv_dedicated || host_client != &svs.clients[0]) // non-admin
{
print("Pause not allowed.\n");
return;
PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict);
prog->ExecuteProgram(prog, PRVM_serverfunction(ClientConnect), "QC function ClientConnect is missing");
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
Con_Printf("%s connected\n", host_client->name);
PRVM_serverglobalfloat(time) = sv.time;
{
if (cmd_source == src_command)
{
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
who = "Console";
else
who = cl_name.string;
{
int i, c;
- if (cls.state == ca_dedicated || COM_CheckParm("-listen") || COM_CheckParm("-benchmark") || COM_CheckParm("-demo") || COM_CheckParm("-capturedemo"))
+ if (sv_dedicated || COM_CheckParm("-listen") || COM_CheckParm("-benchmark") || COM_CheckParm("-demo") || COM_CheckParm("-capturedemo"))
return;
c = Cmd_Argc() - 1;
*/
static void Host_Demos_f (void)
{
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
return;
if (cls.demonum == -1)
cls.demonum = 1;
return;
old = host_client;
- if (cls.state != ca_dedicated)
+ if (!sv_dedicated)
i = 1;
else
i = 0;
static void Mod_BuildAliasSkinFromSkinFrame(texture_t *texture, skinframe_t *skinframe)
{
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
return;
// hack
if (!skinframe)
unsigned int *alphapixels = (unsigned int *)Mem_Alloc(tempmempool, w*h*sizeof(unsigned char[4]));
// allocate a texture pool if we need it
- if (loadmodel->texturepool == NULL && cls.state != ca_dedicated)
+ if (loadmodel->texturepool == NULL && !sv_dedicated)
loadmodel->texturepool = R_AllocTexturePool();
if (bytesperpixel == 4)
loadmodel->data_textures = (texture_t *)Mem_Alloc(loadmodel->mempool, loadmodel->num_textures * sizeof(texture_t));
// fill out all slots with notexture
- if (cls.state != ca_dedicated)
+ if (!sv_dedicated)
skinframe = R_SkinFrame_LoadMissing();
else
skinframe = NULL;
strlcpy(tx->name, "NO TEXTURE FOUND", sizeof(tx->name));
tx->width = 16;
tx->height = 16;
- if (cls.state != ca_dedicated)
+ if (!sv_dedicated)
{
tx->numskinframes = 1;
tx->skinframerate = 1;
tx->surfaceflags = mod_q1bsp_texture_solid.surfaceflags;
}
- if (cls.state != ca_dedicated)
+ if (!sv_dedicated)
{
// LordHavoc: HL sky textures are entirely different than quake
if (!loadmodel->brush.ishlbsp && !strncmp(tx->name, "sky", 3) && mtwidth == mtheight * 2)
;
// now that we've decided the lightmap texture size, we can do the rest
- if (cls.state != ca_dedicated)
+ if (!sv_dedicated)
{
int stainmapsize = 0;
mod_alloclightmap_state_t allocState;
int j;
int numshadowmeshtriangles = 0;
msurface_t *surface;
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
return 0;
// make a single combined shadow mesh to allow optimized shadow volume creation
external = false;
loadmodel->brushq3.lightmapsize = 128;
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
return;
if(mod_q3bsp_nolightmaps.integer)
loadmodel->brushq3.data_deluxemaps = (rtexture_t **)Mem_Alloc(loadmodel->mempool, loadmodel->brushq3.num_mergedlightmaps * sizeof(rtexture_t *));
// allocate a texture pool if we need it
- if (loadmodel->texturepool == NULL && cls.state != ca_dedicated)
+ if (loadmodel->texturepool == NULL && !sv_dedicated)
loadmodel->texturepool = R_AllocTexturePool();
mergedpixels = (unsigned char *) Mem_Alloc(tempmempool, mergedwidth * mergedheight * 4);
else
out->effect = loadmodel->brushq3.data_effects + n;
- if (cls.state != ca_dedicated)
+ if (!sv_dedicated)
{
out->lightmaptexture = NULL;
out->deluxemaptexture = r_texture_blanknormalmap;
VectorClear(out->maxs);
if (out->num_vertices)
{
- if (cls.state != ca_dedicated && out->lightmaptexture)
+ if (!sv_dedicated && out->lightmaptexture)
{
// figure out which part of the merged lightmap this fits into
int lightmapindex = LittleLong(in->lightmapindex) >> (loadmodel->brushq3.deluxemapping ? 1 : 0);
texture->skinframerate = primarylayer->framerate;
for (j = 0;j < primarylayer->numframes;j++)
{
- if(cls.state == ca_dedicated)
+ if(sv_dedicated)
{
texture->skinframes[j] = NULL;
}
texture->backgroundskinframerate = backgroundlayer->framerate;
for (j = 0;j < backgroundlayer->numframes;j++)
{
- if(cls.state == ca_dedicated)
+ if(sv_dedicated)
{
texture->skinframes[j] = NULL;
}
texture->supercontents = SUPERCONTENTS_SOLID | SUPERCONTENTS_OPAQUE;
}
texture->numskinframes = 1;
- if(cls.state == ca_dedicated)
+ if(sv_dedicated)
{
texture->skinframes[0] = NULL;
success = false;
if (modelradius < x + y)
modelradius = x + y;
- if (cls.state != ca_dedicated)
+ if (!sv_dedicated)
{
skinframe = NULL;
// note: Nehahra's null.spr has width == 0 and height == 0
modelradius = x + y;
}
- if (cls.state != ca_dedicated)
+ if (!sv_dedicated)
{
for (i = 0;i < loadmodel->numframes;i++)
{
Con_Printf("Server using port %i\n", port);
if (sv_netport.integer != port)
Cvar_SetValueQuick(&sv_netport, port);
- if (cls.state != ca_dedicated)
+ if (!sv_dedicated)
NetConn_OpenServerPort(NULL, LHNETADDRESSTYPE_LOOP, 1, 1);
if (opennetports)
{
// TODO add logic to automatically close sockets if needed
LHNET_DefaultDSCP(net_tos_dscp.integer);
- if (cls.state != ca_dedicated)
+ if (!sv_dedicated)
{
if (clientport2 != cl_netport.integer)
{
{
VM_SAFEPARMCOUNT(0,VM_serverstate);
- PRVM_G_FLOAT(OFS_RETURN) = sv.active && (svs.maxclients > 1 || cls.state == ca_dedicated);
+ PRVM_G_FLOAT(OFS_RETURN) = sv.active && (svs.maxclients > 1 || sv_dedicated);
}
/*
{
VM_SAFEPARMCOUNT(0,VM_clientstate);
-
- switch( cls.state ) {
- case ca_uninitialized:
- case ca_dedicated:
- PRVM_G_FLOAT(OFS_RETURN) = 0;
- break;
- case ca_disconnected:
- PRVM_G_FLOAT(OFS_RETURN) = 1;
- break;
- case ca_connected:
- PRVM_G_FLOAT(OFS_RETURN) = 2;
- break;
- default:
- // should never be reached!
- break;
+ if(sv_dedicated)
+ PRVM_G_FLOAT(OFS_RETURN) = 0;
+ else
+ {
+ switch( cls.state ) {
+ case ca_uninitialized:
+ case ca_disconnected:
+ PRVM_G_FLOAT(OFS_RETURN) = 1;
+ break;
+ case ca_connected:
+ PRVM_G_FLOAT(OFS_RETURN) = 2;
+ break;
+ default:
+ // should never be reached!
+ break;
+ }
}
}
#endif
#include "csprogs.h"
+extern qboolean sv_dedicated;
+
extern qboolean noclip_anglehack;
extern cvar_t developer;
// SV_LockThreadMutex();
- if(cls.state == ca_dedicated)
+ if(sv_dedicated)
Sys_MakeProcessNice();
- if (cls.state != ca_dedicated)
+ if (!sv_dedicated)
{
SCR_BeginLoadingPlaque(false);
S_StopAllSounds();
{
Con_Printf("Couldn't load map %s\n", modelname);
- if(cls.state == ca_dedicated)
+ if(sv_dedicated)
Sys_MakeProcessMean();
// SV_UnlockThreadMutex();
SV_Physics ();
}
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
Mod_PurgeUnused();
// create a baseline for more efficient communications
Con_DPrint("Server spawned.\n");
NetConn_Heartbeat (2);
- if(cls.state == ca_dedicated)
+ if(sv_dedicated)
Sys_MakeProcessMean();
// SV_UnlockThreadMutex();
char *Sys_ConsoleInput(void)
{
- //if (cls.state == ca_dedicated)
+ //if (sv_dedicated)
{
static char text[MAX_INPUTLINE];
static unsigned int len = 0;
char *Sys_ConsoleInput(void)
{
-// if (cls.state == ca_dedicated)
+// if (sv_dedicated)
{
static char text[MAX_INPUTLINE];
int len = 0;
Con_Printf ("Quake Error: %s\n", text);
// close video so the message box is visible, unless we already tried that
- if (!in_sys_error0 && cls.state != ca_dedicated)
+ if (!in_sys_error0 && !sv_dedicated)
{
in_sys_error0 = 1;
VID_Shutdown();
}
- if (!in_sys_error3 && cls.state != ca_dedicated)
+ if (!in_sys_error3 && !sv_dedicated)
{
in_sys_error3 = true;
MessageBox(NULL, text, "Quake Error", MB_OK | MB_SETFOREGROUND | MB_ICONSTOP);
CloseHandle (tevent);
#endif
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
FreeConsole ();
#ifdef QHOST
int ch;
DWORD numread, numevents, dummy;
- if (cls.state != ca_dedicated)
+ if (!sv_dedicated)
return NULL;
for ( ;; )
hinput = GetStdHandle (STD_INPUT_HANDLE);
// LordHavoc: can't check cls.state because it hasn't been initialized yet
- // if (cls.state == ca_dedicated)
+ // if (sv_dedicated)
if (COM_CheckParm("-dedicated"))
{
//if ((houtput == 0) || (houtput == INVALID_HANDLE_VALUE)) // LordHavoc: on Windows XP this is never 0 or invalid, but hinput is invalid
qboolean gamma_changed = false;
// LordHavoc: don't mess with gamma tables if running dedicated
- if (cls.state == ca_dedicated)
+ if (sv_dedicated)
return;
wantgamma = v_hwgamma.integer;