2010-02-15 23:26:55 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 1996-2001 Id Software, Inc.
|
|
|
|
Copyright (C) 2002-2009 John Fitzgibbons and others
|
|
|
|
Copyright (C) 2007-2008 Kristian Duske
|
2014-09-22 08:55:46 +00:00
|
|
|
Copyright (C) 2010-2014 QuakeSpasm developers
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
// host.c -- coordinates spawning and killing of local servers
|
|
|
|
|
|
|
|
#include "quakedef.h"
|
Backported external music files support using decoder libraries and the
new raw samples interface from Hammer of Thyrion (uhexen2) :
- bgmusic.c, bgmusic.h: New BGM interface for background music handling.
Handles streaming music as raw sound samples.
- bgmnull.c: BGM source for cases where the engine is configured for no
sound.
- cl_main.c: Include bgmusic.h. Call BGM_Stop() and CDAudio_Stop() in
CL_Disconnect().
- cd_sdl.c: Moved bgmvolume boundary checking to bgmusic.c upon value
changes.
- gl_vidnt.c, gl_vidsdl.c, cl_parse.c: Include bgmusic.h. Add BGM_Pause()
and BGM_Resume() calls along with CDAudio_ counterparts.
- cl_parse.c: Replace CDAudio_Play() call by the new BGM_PlayCDtrack()
which first tries CDAudio_Play() and then streaming music if it fails.
- host.c: Include bgmusic.h. Call BGM_Update() just before S_Update()
in Host_Frame(). In Host_Init(), call BGM_Init() after other audio init
calls. In Host_Shutdown(), call BGM_Shutdown() before all other audio
shutdown calls.
- snd_dma.c: Include snd_codec.h and bgmusic.h. Call S_CodecInit() from
S_Init(). Call S_CodecShutdown() from S_Shutdown().
- snd_codec.c, snd_codec.h: New public codec interface for streaming
music as raw samples. Adapted from quake2 and ioquake3 with changes.
Individual codecs are responsible for handling any necessary byte swap
operations.
- snd_codeci.h: New header for snd_codec internals.
- snd_wave.c, snd_wave.h: Codec for WAV format streaming music. Adapted
from ioquake3 with changes.
- snd_vorbis.c, snd_vorbis.h: Codec for Ogg/Vorbis format streaming music.
- snd_mp3.c, snd_mp3.h: Codec for MP3 format streaming music using libmad.
Adapted from the SoX project with changes.
- Makefile: Adjusted for the new sources. Added switches USE_CODEC_WAVE,
USE_CODEC_MP3, USE_CODEC_VORBIS for enabling and disabling individual
codecs.
- Windows makefiles and project files as well as other CodeBlocks project
files will be updated shortly.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@374 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-01-05 19:50:43 +00:00
|
|
|
#include "bgmusic.h"
|
2010-08-14 20:55:39 +00:00
|
|
|
#include <setjmp.h>
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
A server can allways be started, even if the system started out as a client
|
|
|
|
to a remote system.
|
|
|
|
|
|
|
|
A client can NOT be started if the system started as a dedicated server.
|
|
|
|
|
|
|
|
Memory is cleared / released when a server or client begins, not when they end.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2011-04-19 16:41:45 +00:00
|
|
|
quakeparms_t *host_parms;
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
qboolean host_initialized; // true if into command execution
|
|
|
|
|
|
|
|
double host_frametime;
|
|
|
|
double realtime; // without any filtering or bounding
|
|
|
|
double oldrealtime; // last frame run
|
|
|
|
|
2011-12-23 12:03:49 +00:00
|
|
|
int host_framecount;
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-12-23 12:03:49 +00:00
|
|
|
int host_hunklevel;
|
|
|
|
|
|
|
|
int minimum_memory;
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
client_t *host_client; // current client
|
|
|
|
|
|
|
|
jmp_buf host_abortserver;
|
|
|
|
|
|
|
|
byte *host_colormap;
|
|
|
|
|
2011-12-28 22:01:33 +00:00
|
|
|
cvar_t host_framerate = {"host_framerate","0",CVAR_NONE}; // set for slow motion
|
|
|
|
cvar_t host_speeds = {"host_speeds","0",CVAR_NONE}; // set for running times
|
|
|
|
cvar_t host_maxfps = {"host_maxfps", "72", CVAR_ARCHIVE}; //johnfitz
|
|
|
|
cvar_t host_timescale = {"host_timescale", "0", CVAR_NONE}; //johnfitz
|
max_edicts: raise to 8192 (from 2048) and make non-archived, to reduce the need for players to mess with it to get maps/mods to run.
Some measurements on the size of the sv.edicts hunk allocation, with this change, on various mods (it depends on the number of QC entity fields):
id1 7MB, quoth 11 MB, arcadim 21 MB, rrp 9MB, ne_ruins 16MB.
Since this is a Hunk_Alloc, the whole 10-20MB is cleared to zero which will allocate that much physical ram.
We could probably change it to a malloc later, and not clear the memory, so physical ram is only allocated when the memory is cleared in ED_Alloc.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1278 af15c1b1-3010-417e-b628-4374ebc0bcbd
2016-01-10 23:03:06 +00:00
|
|
|
cvar_t max_edicts = {"max_edicts", "8192", CVAR_NONE}; //johnfitz //ericw -- changed from 2048 to 8192, removed CVAR_ARCHIVE
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-12-28 22:01:33 +00:00
|
|
|
cvar_t sys_ticrate = {"sys_ticrate","0.05",CVAR_NONE}; // dedicated server
|
|
|
|
cvar_t serverprofile = {"serverprofile","0",CVAR_NONE};
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-12-28 22:01:33 +00:00
|
|
|
cvar_t fraglimit = {"fraglimit","0",CVAR_NOTIFY|CVAR_SERVERINFO};
|
|
|
|
cvar_t timelimit = {"timelimit","0",CVAR_NOTIFY|CVAR_SERVERINFO};
|
|
|
|
cvar_t teamplay = {"teamplay","0",CVAR_NOTIFY|CVAR_SERVERINFO};
|
|
|
|
cvar_t samelevel = {"samelevel","0",CVAR_NONE};
|
|
|
|
cvar_t noexit = {"noexit","0",CVAR_NOTIFY|CVAR_SERVERINFO};
|
|
|
|
cvar_t skill = {"skill","1",CVAR_NONE}; // 0 - 3
|
|
|
|
cvar_t deathmatch = {"deathmatch","0",CVAR_NONE}; // 0, 1, or 2
|
|
|
|
cvar_t coop = {"coop","0",CVAR_NONE}; // 0 or 1
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-12-28 22:01:33 +00:00
|
|
|
cvar_t pausable = {"pausable","1",CVAR_NONE};
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-12-28 22:01:33 +00:00
|
|
|
cvar_t developer = {"developer","0",CVAR_NONE};
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-12-28 22:01:33 +00:00
|
|
|
cvar_t temp1 = {"temp1","0",CVAR_NONE};
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-12-28 22:01:33 +00:00
|
|
|
cvar_t devstats = {"devstats","0",CVAR_NONE}; //johnfitz -- track developer statistics that vary every frame
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2010-04-22 19:02:29 +00:00
|
|
|
devstats_t dev_stats, dev_peakstats;
|
|
|
|
overflowtimes_t dev_overflows; //this stores the last time overflow messages were displayed, not the last time overflows occured
|
|
|
|
|
2010-02-15 23:26:55 +00:00
|
|
|
/*
|
|
|
|
================
|
|
|
|
Max_Edicts_f -- johnfitz
|
|
|
|
================
|
|
|
|
*/
|
2011-12-24 14:04:01 +00:00
|
|
|
static void Max_Edicts_f (cvar_t *var)
|
2010-02-15 23:26:55 +00:00
|
|
|
{
|
|
|
|
//TODO: clamp it here?
|
|
|
|
if (cls.state == ca_connected || sv.active)
|
|
|
|
Con_Printf ("Changes to max_edicts will not take effect until the next time a map is loaded.\n");
|
|
|
|
}
|
|
|
|
|
2017-09-12 23:27:26 +00:00
|
|
|
/*
|
|
|
|
================
|
|
|
|
Max_Fps_f -- ericw
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
static void Max_Fps_f (cvar_t *var)
|
|
|
|
{
|
|
|
|
if (host_maxfps.value > 72)
|
2017-09-13 00:04:31 +00:00
|
|
|
Con_Warning ("host_maxfps above 72 breaks physics.\n");
|
2017-09-12 23:27:26 +00:00
|
|
|
}
|
|
|
|
|
2010-02-15 23:26:55 +00:00
|
|
|
/*
|
|
|
|
================
|
|
|
|
Host_EndGame
|
|
|
|
================
|
|
|
|
*/
|
Constified Con_DebugLog, Con_Print, Con_Printf, Con_Warning, Con_DPrintf,
Con_DPrintf2, Con_SafePrintf, Con_CenterPrintf, Con_LogCenterPrint,
Con_NotifyBox, PL_ErrorDialog, PR_RunError, Host_EndGame, Host_Error,
SV_ClientPrintf, SV_BroadcastPrintf, Host_ClientCommands, Sys_DebugLog,
Sys_Error, Sys_Printf, BOPS_Error and va. Added noreturn attribute to
Sys_Error, Sys_Quit, BOPS_Error, PR_RunError, Host_EndGame and Host_Error.
Added format printf attribute to Con_DebugLog, Con_Printf, Con_Warning,
Con_DPrintf, Con_DPrintf2, Con_SafePrintf, Con_CenterPrintf, PL_ErrorDialog,
PR_RunError, Host_EndGame, Host_Error, SV_ClientPrintf, SV_BroadcastPrintf,
Host_ClientCommands, Sys_DebugLog, Sys_Error, Sys_Printf and va. Adjusted
Host_Status_f and NET_Ban_f for the new attributes. Fixed broken format
strings in Con_Dump_f, Mod_LoadTexinfo, PR_AllocStringSlots and FloorDivMod.
Defined __attribute__ macros in quakedef.h so that we don't break non-gcc
compilers.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@154 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-04-26 16:30:40 +00:00
|
|
|
void Host_EndGame (const char *message, ...)
|
2010-02-15 23:26:55 +00:00
|
|
|
{
|
|
|
|
va_list argptr;
|
|
|
|
char string[1024];
|
|
|
|
|
|
|
|
va_start (argptr,message);
|
2010-08-31 16:57:12 +00:00
|
|
|
q_vsnprintf (string, sizeof(string), message, argptr);
|
2010-02-15 23:26:55 +00:00
|
|
|
va_end (argptr);
|
|
|
|
Con_DPrintf ("Host_EndGame: %s\n",string);
|
|
|
|
|
|
|
|
if (sv.active)
|
|
|
|
Host_ShutdownServer (false);
|
|
|
|
|
|
|
|
if (cls.state == ca_dedicated)
|
|
|
|
Sys_Error ("Host_EndGame: %s\n",string); // dedicated servers exit
|
|
|
|
|
|
|
|
if (cls.demonum != -1)
|
|
|
|
CL_NextDemo ();
|
|
|
|
else
|
|
|
|
CL_Disconnect ();
|
|
|
|
|
|
|
|
longjmp (host_abortserver, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
Host_Error
|
|
|
|
|
|
|
|
This shuts down both the client and server
|
|
|
|
================
|
|
|
|
*/
|
Constified Con_DebugLog, Con_Print, Con_Printf, Con_Warning, Con_DPrintf,
Con_DPrintf2, Con_SafePrintf, Con_CenterPrintf, Con_LogCenterPrint,
Con_NotifyBox, PL_ErrorDialog, PR_RunError, Host_EndGame, Host_Error,
SV_ClientPrintf, SV_BroadcastPrintf, Host_ClientCommands, Sys_DebugLog,
Sys_Error, Sys_Printf, BOPS_Error and va. Added noreturn attribute to
Sys_Error, Sys_Quit, BOPS_Error, PR_RunError, Host_EndGame and Host_Error.
Added format printf attribute to Con_DebugLog, Con_Printf, Con_Warning,
Con_DPrintf, Con_DPrintf2, Con_SafePrintf, Con_CenterPrintf, PL_ErrorDialog,
PR_RunError, Host_EndGame, Host_Error, SV_ClientPrintf, SV_BroadcastPrintf,
Host_ClientCommands, Sys_DebugLog, Sys_Error, Sys_Printf and va. Adjusted
Host_Status_f and NET_Ban_f for the new attributes. Fixed broken format
strings in Con_Dump_f, Mod_LoadTexinfo, PR_AllocStringSlots and FloorDivMod.
Defined __attribute__ macros in quakedef.h so that we don't break non-gcc
compilers.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@154 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-04-26 16:30:40 +00:00
|
|
|
void Host_Error (const char *error, ...)
|
2010-02-15 23:26:55 +00:00
|
|
|
{
|
|
|
|
va_list argptr;
|
|
|
|
char string[1024];
|
|
|
|
static qboolean inerror = false;
|
|
|
|
|
|
|
|
if (inerror)
|
|
|
|
Sys_Error ("Host_Error: recursively entered");
|
|
|
|
inerror = true;
|
|
|
|
|
|
|
|
SCR_EndLoadingPlaque (); // reenable screen updates
|
|
|
|
|
|
|
|
va_start (argptr,error);
|
2010-08-31 16:57:12 +00:00
|
|
|
q_vsnprintf (string, sizeof(string), error, argptr);
|
2010-02-15 23:26:55 +00:00
|
|
|
va_end (argptr);
|
|
|
|
Con_Printf ("Host_Error: %s\n",string);
|
|
|
|
|
|
|
|
if (sv.active)
|
|
|
|
Host_ShutdownServer (false);
|
|
|
|
|
|
|
|
if (cls.state == ca_dedicated)
|
|
|
|
Sys_Error ("Host_Error: %s\n",string); // dedicated servers exit
|
|
|
|
|
|
|
|
CL_Disconnect ();
|
|
|
|
cls.demonum = -1;
|
|
|
|
cl.intermission = 0; //johnfitz -- for errors during intermissions (changelevel with no map found, etc.)
|
|
|
|
|
|
|
|
inerror = false;
|
|
|
|
|
|
|
|
longjmp (host_abortserver, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
Host_FindMaxClients
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void Host_FindMaxClients (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
svs.maxclients = 1;
|
|
|
|
|
|
|
|
i = COM_CheckParm ("-dedicated");
|
|
|
|
if (i)
|
|
|
|
{
|
|
|
|
cls.state = ca_dedicated;
|
|
|
|
if (i != (com_argc - 1))
|
|
|
|
{
|
|
|
|
svs.maxclients = Q_atoi (com_argv[i+1]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
svs.maxclients = 8;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cls.state = ca_disconnected;
|
|
|
|
|
|
|
|
i = COM_CheckParm ("-listen");
|
|
|
|
if (i)
|
|
|
|
{
|
|
|
|
if (cls.state == ca_dedicated)
|
|
|
|
Sys_Error ("Only one of -dedicated or -listen can be specified");
|
|
|
|
if (i != (com_argc - 1))
|
|
|
|
svs.maxclients = Q_atoi (com_argv[i+1]);
|
|
|
|
else
|
|
|
|
svs.maxclients = 8;
|
|
|
|
}
|
|
|
|
if (svs.maxclients < 1)
|
|
|
|
svs.maxclients = 8;
|
|
|
|
else if (svs.maxclients > MAX_SCOREBOARD)
|
|
|
|
svs.maxclients = MAX_SCOREBOARD;
|
|
|
|
|
|
|
|
svs.maxclientslimit = svs.maxclients;
|
|
|
|
if (svs.maxclientslimit < 4)
|
|
|
|
svs.maxclientslimit = 4;
|
host_cmd.c, console.c, gl_draw.c, image.c, gl_model.c, r_sprite.c, cl_parse.c,
gl_warp.c, host.c, gl_mesh.c, gl_sky.c, gl_texmgr.c, cvar.c, sv_main.c, cvar.h,
gl_screen.c, r_brush.c, gl_vidsdl.c, zone.c, cl_main.c, cmd.c, snd_dma.c,
snd_mem.c, common.c, sv_phys.c: Added explicit casts to eliminate -Wc++-compat
warnings.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@170 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-05-31 07:42:36 +00:00
|
|
|
svs.clients = (struct client_s *) Hunk_AllocName (svs.maxclientslimit*sizeof(client_t), "clients");
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
if (svs.maxclients > 1)
|
2011-12-29 21:21:11 +00:00
|
|
|
Cvar_SetQuick (&deathmatch, "1");
|
2010-02-15 23:26:55 +00:00
|
|
|
else
|
2011-12-29 21:21:11 +00:00
|
|
|
Cvar_SetQuick (&deathmatch, "0");
|
2010-02-15 23:26:55 +00:00
|
|
|
}
|
|
|
|
|
2011-06-27 13:20:52 +00:00
|
|
|
void Host_Version_f (void)
|
|
|
|
{
|
|
|
|
Con_Printf ("Quake Version %1.2f\n", VERSION);
|
2017-05-29 04:17:49 +00:00
|
|
|
Con_Printf ("QuakeSpasm Version " QUAKESPASM_VER_STRING "\n");
|
2016-04-29 20:00:50 +00:00
|
|
|
Con_Printf ("Exe: " __TIME__ " " __DATE__ "\n");
|
2011-06-27 13:20:52 +00:00
|
|
|
}
|
|
|
|
|
2011-12-28 22:01:33 +00:00
|
|
|
/* cvar callback functions : */
|
|
|
|
void Host_Callback_Notify (cvar_t *var)
|
|
|
|
{
|
|
|
|
if (sv.active)
|
|
|
|
SV_BroadcastPrintf ("\"%s\" changed to \"%s\"\n", var->name, var->string);
|
|
|
|
}
|
|
|
|
|
2010-02-15 23:26:55 +00:00
|
|
|
/*
|
|
|
|
=======================
|
|
|
|
Host_InitLocal
|
|
|
|
======================
|
|
|
|
*/
|
|
|
|
void Host_InitLocal (void)
|
|
|
|
{
|
2011-06-27 13:20:52 +00:00
|
|
|
Cmd_AddCommand ("version", Host_Version_f);
|
|
|
|
|
2010-02-15 23:26:55 +00:00
|
|
|
Host_InitCommands ();
|
|
|
|
|
2011-12-28 22:01:33 +00:00
|
|
|
Cvar_RegisterVariable (&host_framerate);
|
|
|
|
Cvar_RegisterVariable (&host_speeds);
|
|
|
|
Cvar_RegisterVariable (&host_maxfps); //johnfitz
|
2017-09-12 23:27:26 +00:00
|
|
|
Cvar_SetCallback (&host_maxfps, Max_Fps_f);
|
2011-12-28 22:01:33 +00:00
|
|
|
Cvar_RegisterVariable (&host_timescale); //johnfitz
|
|
|
|
|
|
|
|
Cvar_RegisterVariable (&max_edicts); //johnfitz
|
|
|
|
Cvar_SetCallback (&max_edicts, Max_Edicts_f);
|
|
|
|
Cvar_RegisterVariable (&devstats); //johnfitz
|
|
|
|
|
|
|
|
Cvar_RegisterVariable (&sys_ticrate);
|
|
|
|
Cvar_RegisterVariable (&sys_throttle);
|
|
|
|
Cvar_RegisterVariable (&serverprofile);
|
|
|
|
|
|
|
|
Cvar_RegisterVariable (&fraglimit);
|
|
|
|
Cvar_RegisterVariable (&timelimit);
|
|
|
|
Cvar_RegisterVariable (&teamplay);
|
|
|
|
Cvar_SetCallback (&fraglimit, Host_Callback_Notify);
|
|
|
|
Cvar_SetCallback (&timelimit, Host_Callback_Notify);
|
|
|
|
Cvar_SetCallback (&teamplay, Host_Callback_Notify);
|
|
|
|
Cvar_RegisterVariable (&samelevel);
|
|
|
|
Cvar_RegisterVariable (&noexit);
|
|
|
|
Cvar_SetCallback (&noexit, Host_Callback_Notify);
|
|
|
|
Cvar_RegisterVariable (&skill);
|
|
|
|
Cvar_RegisterVariable (&developer);
|
|
|
|
Cvar_RegisterVariable (&coop);
|
|
|
|
Cvar_RegisterVariable (&deathmatch);
|
|
|
|
|
|
|
|
Cvar_RegisterVariable (&pausable);
|
|
|
|
|
|
|
|
Cvar_RegisterVariable (&temp1);
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
Host_FindMaxClients ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
Host_WriteConfiguration
|
|
|
|
|
|
|
|
Writes key bindings and archived cvars to config.cfg
|
|
|
|
===============
|
|
|
|
*/
|
|
|
|
void Host_WriteConfiguration (void)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
|
|
|
|
// dedicated servers initialize the host but don't parse and set the
|
|
|
|
// config.cfg cvars
|
|
|
|
if (host_initialized & !isDedicated)
|
|
|
|
{
|
|
|
|
f = fopen (va("%s/config.cfg", com_gamedir), "w");
|
|
|
|
if (!f)
|
|
|
|
{
|
|
|
|
Con_Printf ("Couldn't write config.cfg.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
VID_SyncCvars (); //johnfitz -- write actual current mode to config file, in case cvars were messed with
|
|
|
|
|
|
|
|
Key_WriteBindings (f);
|
|
|
|
Cvar_WriteVariables (f);
|
|
|
|
|
|
|
|
//johnfitz -- extra commands to preserve state
|
|
|
|
fprintf (f, "vid_restart\n");
|
|
|
|
if (in_mlook.state & 1) fprintf (f, "+mlook\n");
|
|
|
|
//johnfitz
|
|
|
|
|
|
|
|
fclose (f);
|
|
|
|
|
|
|
|
//johnfitz -- also save fitzquake.rc
|
|
|
|
#if 0
|
|
|
|
f = fopen (va("%s/fitzquake.rc", GAMENAME), "w"); //always save in id1
|
|
|
|
if (!f)
|
|
|
|
{
|
|
|
|
Con_Printf ("Couldn't write fitzquake.rc.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Cvar_WriteVariables (f);
|
|
|
|
fprintf (f, "vid_restart\n");
|
|
|
|
if (in_mlook.state & 1) fprintf (f, "+mlook\n");
|
|
|
|
|
|
|
|
fclose (f);
|
|
|
|
#endif
|
|
|
|
//johnfitz
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
SV_ClientPrintf
|
|
|
|
|
|
|
|
Sends text across to be displayed
|
|
|
|
FIXME: make this just a stuffed echo?
|
|
|
|
=================
|
|
|
|
*/
|
Constified Con_DebugLog, Con_Print, Con_Printf, Con_Warning, Con_DPrintf,
Con_DPrintf2, Con_SafePrintf, Con_CenterPrintf, Con_LogCenterPrint,
Con_NotifyBox, PL_ErrorDialog, PR_RunError, Host_EndGame, Host_Error,
SV_ClientPrintf, SV_BroadcastPrintf, Host_ClientCommands, Sys_DebugLog,
Sys_Error, Sys_Printf, BOPS_Error and va. Added noreturn attribute to
Sys_Error, Sys_Quit, BOPS_Error, PR_RunError, Host_EndGame and Host_Error.
Added format printf attribute to Con_DebugLog, Con_Printf, Con_Warning,
Con_DPrintf, Con_DPrintf2, Con_SafePrintf, Con_CenterPrintf, PL_ErrorDialog,
PR_RunError, Host_EndGame, Host_Error, SV_ClientPrintf, SV_BroadcastPrintf,
Host_ClientCommands, Sys_DebugLog, Sys_Error, Sys_Printf and va. Adjusted
Host_Status_f and NET_Ban_f for the new attributes. Fixed broken format
strings in Con_Dump_f, Mod_LoadTexinfo, PR_AllocStringSlots and FloorDivMod.
Defined __attribute__ macros in quakedef.h so that we don't break non-gcc
compilers.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@154 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-04-26 16:30:40 +00:00
|
|
|
void SV_ClientPrintf (const char *fmt, ...)
|
2010-02-15 23:26:55 +00:00
|
|
|
{
|
|
|
|
va_list argptr;
|
|
|
|
char string[1024];
|
|
|
|
|
|
|
|
va_start (argptr,fmt);
|
2010-08-31 16:57:12 +00:00
|
|
|
q_vsnprintf (string, sizeof(string), fmt,argptr);
|
2010-02-15 23:26:55 +00:00
|
|
|
va_end (argptr);
|
|
|
|
|
|
|
|
MSG_WriteByte (&host_client->message, svc_print);
|
|
|
|
MSG_WriteString (&host_client->message, string);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
SV_BroadcastPrintf
|
|
|
|
|
|
|
|
Sends text to all active clients
|
|
|
|
=================
|
|
|
|
*/
|
Constified Con_DebugLog, Con_Print, Con_Printf, Con_Warning, Con_DPrintf,
Con_DPrintf2, Con_SafePrintf, Con_CenterPrintf, Con_LogCenterPrint,
Con_NotifyBox, PL_ErrorDialog, PR_RunError, Host_EndGame, Host_Error,
SV_ClientPrintf, SV_BroadcastPrintf, Host_ClientCommands, Sys_DebugLog,
Sys_Error, Sys_Printf, BOPS_Error and va. Added noreturn attribute to
Sys_Error, Sys_Quit, BOPS_Error, PR_RunError, Host_EndGame and Host_Error.
Added format printf attribute to Con_DebugLog, Con_Printf, Con_Warning,
Con_DPrintf, Con_DPrintf2, Con_SafePrintf, Con_CenterPrintf, PL_ErrorDialog,
PR_RunError, Host_EndGame, Host_Error, SV_ClientPrintf, SV_BroadcastPrintf,
Host_ClientCommands, Sys_DebugLog, Sys_Error, Sys_Printf and va. Adjusted
Host_Status_f and NET_Ban_f for the new attributes. Fixed broken format
strings in Con_Dump_f, Mod_LoadTexinfo, PR_AllocStringSlots and FloorDivMod.
Defined __attribute__ macros in quakedef.h so that we don't break non-gcc
compilers.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@154 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-04-26 16:30:40 +00:00
|
|
|
void SV_BroadcastPrintf (const char *fmt, ...)
|
2010-02-15 23:26:55 +00:00
|
|
|
{
|
|
|
|
va_list argptr;
|
|
|
|
char string[1024];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
va_start (argptr,fmt);
|
2010-08-31 16:57:12 +00:00
|
|
|
q_vsnprintf (string, sizeof(string), fmt, argptr);
|
2010-02-15 23:26:55 +00:00
|
|
|
va_end (argptr);
|
|
|
|
|
2012-11-06 08:56:09 +00:00
|
|
|
for (i = 0; i < svs.maxclients; i++)
|
|
|
|
{
|
2010-02-15 23:26:55 +00:00
|
|
|
if (svs.clients[i].active && svs.clients[i].spawned)
|
|
|
|
{
|
|
|
|
MSG_WriteByte (&svs.clients[i].message, svc_print);
|
|
|
|
MSG_WriteString (&svs.clients[i].message, string);
|
|
|
|
}
|
2012-11-06 08:56:09 +00:00
|
|
|
}
|
2010-02-15 23:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Host_ClientCommands
|
|
|
|
|
|
|
|
Send text over to the client to be executed
|
|
|
|
=================
|
|
|
|
*/
|
Constified Con_DebugLog, Con_Print, Con_Printf, Con_Warning, Con_DPrintf,
Con_DPrintf2, Con_SafePrintf, Con_CenterPrintf, Con_LogCenterPrint,
Con_NotifyBox, PL_ErrorDialog, PR_RunError, Host_EndGame, Host_Error,
SV_ClientPrintf, SV_BroadcastPrintf, Host_ClientCommands, Sys_DebugLog,
Sys_Error, Sys_Printf, BOPS_Error and va. Added noreturn attribute to
Sys_Error, Sys_Quit, BOPS_Error, PR_RunError, Host_EndGame and Host_Error.
Added format printf attribute to Con_DebugLog, Con_Printf, Con_Warning,
Con_DPrintf, Con_DPrintf2, Con_SafePrintf, Con_CenterPrintf, PL_ErrorDialog,
PR_RunError, Host_EndGame, Host_Error, SV_ClientPrintf, SV_BroadcastPrintf,
Host_ClientCommands, Sys_DebugLog, Sys_Error, Sys_Printf and va. Adjusted
Host_Status_f and NET_Ban_f for the new attributes. Fixed broken format
strings in Con_Dump_f, Mod_LoadTexinfo, PR_AllocStringSlots and FloorDivMod.
Defined __attribute__ macros in quakedef.h so that we don't break non-gcc
compilers.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@154 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-04-26 16:30:40 +00:00
|
|
|
void Host_ClientCommands (const char *fmt, ...)
|
2010-02-15 23:26:55 +00:00
|
|
|
{
|
|
|
|
va_list argptr;
|
|
|
|
char string[1024];
|
|
|
|
|
|
|
|
va_start (argptr,fmt);
|
2010-08-31 16:57:12 +00:00
|
|
|
q_vsnprintf (string, sizeof(string), fmt, argptr);
|
2010-02-15 23:26:55 +00:00
|
|
|
va_end (argptr);
|
|
|
|
|
|
|
|
MSG_WriteByte (&host_client->message, svc_stufftext);
|
|
|
|
MSG_WriteString (&host_client->message, string);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
SV_DropClient
|
|
|
|
|
|
|
|
Called when the player is getting totally kicked off the host
|
|
|
|
if (crash = true), don't bother sending signofs
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void SV_DropClient (qboolean crash)
|
|
|
|
{
|
|
|
|
int saveSelf;
|
|
|
|
int i;
|
|
|
|
client_t *client;
|
|
|
|
|
|
|
|
if (!crash)
|
|
|
|
{
|
|
|
|
// send any final messages (don't check for errors)
|
|
|
|
if (NET_CanSendMessage (host_client->netconnection))
|
|
|
|
{
|
|
|
|
MSG_WriteByte (&host_client->message, svc_disconnect);
|
|
|
|
NET_SendMessage (host_client->netconnection, &host_client->message);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (host_client->edict && host_client->spawned)
|
|
|
|
{
|
|
|
|
// call the prog function for removing a client
|
|
|
|
// this will set the body to a dead frame, among other things
|
|
|
|
saveSelf = pr_global_struct->self;
|
|
|
|
pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
|
|
|
|
PR_ExecuteProgram (pr_global_struct->ClientDisconnect);
|
|
|
|
pr_global_struct->self = saveSelf;
|
|
|
|
}
|
|
|
|
|
|
|
|
Sys_Printf ("Client %s removed\n",host_client->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
// break the net connection
|
|
|
|
NET_Close (host_client->netconnection);
|
|
|
|
host_client->netconnection = NULL;
|
|
|
|
|
|
|
|
// free the client (the body stays around)
|
|
|
|
host_client->active = false;
|
|
|
|
host_client->name[0] = 0;
|
|
|
|
host_client->old_frags = -999999;
|
|
|
|
net_activeconnections--;
|
|
|
|
|
|
|
|
// send notification to all clients
|
2012-11-06 08:56:09 +00:00
|
|
|
for (i = 0, client = svs.clients; i < svs.maxclients; i++, client++)
|
2010-02-15 23:26:55 +00:00
|
|
|
{
|
|
|
|
if (!client->active)
|
|
|
|
continue;
|
|
|
|
MSG_WriteByte (&client->message, svc_updatename);
|
|
|
|
MSG_WriteByte (&client->message, host_client - svs.clients);
|
|
|
|
MSG_WriteString (&client->message, "");
|
|
|
|
MSG_WriteByte (&client->message, svc_updatefrags);
|
|
|
|
MSG_WriteByte (&client->message, host_client - svs.clients);
|
|
|
|
MSG_WriteShort (&client->message, 0);
|
|
|
|
MSG_WriteByte (&client->message, svc_updatecolors);
|
|
|
|
MSG_WriteByte (&client->message, host_client - svs.clients);
|
|
|
|
MSG_WriteByte (&client->message, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Host_ShutdownServer
|
|
|
|
|
|
|
|
This only happens at the end of a game, not between levels
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void Host_ShutdownServer(qboolean crash)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int count;
|
|
|
|
sizebuf_t buf;
|
chase.c, cl_input.c, cl_parse.c, client.h, common.c, common.h, console.h,
cvar.h, draw.h, gl_draw.c, gl_fog.c, gl_mesh.c, gl_model.c, gl_model.h,
gl_rmain.c, gl_rmisc.c, gl_screen.c, gl_sky.c, gl_texmgr.c, glquake.h,
host.c, keys.c, keys.h, main.c, menu.c, menu.h, pr_cmds.c, quakedef.h,
r_alias.c, r_brush.c, r_part.c, r_sprite.c, r_world.c, sbar.c, sbar.h,
screen.h, snd_dma.c, snd_mem.c, snd_mix.c, sv_main.c, sys_sdl.c, vid.h,
view.h, world.c, world.h: Loads of warning fixes about missing function
prototypes, missing parens around &, missing braces leading to ambiguous
else statements and unused and uninitialized variables. There are still a
couple of unitialised variables here and there, but not much. The warnings
about strict aliasing violations need taking care of.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@21 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-02-16 12:01:07 +00:00
|
|
|
byte message[4];
|
2010-02-15 23:26:55 +00:00
|
|
|
double start;
|
|
|
|
|
|
|
|
if (!sv.active)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sv.active = false;
|
|
|
|
|
|
|
|
// stop all client sounds immediately
|
|
|
|
if (cls.state == ca_connected)
|
|
|
|
CL_Disconnect ();
|
|
|
|
|
|
|
|
// flush any pending messages - like the score!!!
|
2011-12-12 16:01:01 +00:00
|
|
|
start = Sys_DoubleTime();
|
2010-02-15 23:26:55 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
count = 0;
|
|
|
|
for (i=0, host_client = svs.clients ; i<svs.maxclients ; i++, host_client++)
|
|
|
|
{
|
|
|
|
if (host_client->active && host_client->message.cursize)
|
|
|
|
{
|
|
|
|
if (NET_CanSendMessage (host_client->netconnection))
|
|
|
|
{
|
|
|
|
NET_SendMessage(host_client->netconnection, &host_client->message);
|
|
|
|
SZ_Clear (&host_client->message);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NET_GetMessage(host_client->netconnection);
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-12-12 16:01:01 +00:00
|
|
|
if ((Sys_DoubleTime() - start) > 3.0)
|
2010-02-15 23:26:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
while (count);
|
|
|
|
|
|
|
|
// make sure all the clients know we're disconnecting
|
|
|
|
buf.data = message;
|
|
|
|
buf.maxsize = 4;
|
|
|
|
buf.cursize = 0;
|
|
|
|
MSG_WriteByte(&buf, svc_disconnect);
|
2010-06-20 15:00:57 +00:00
|
|
|
count = NET_SendToAll(&buf, 5.0);
|
2010-02-15 23:26:55 +00:00
|
|
|
if (count)
|
|
|
|
Con_Printf("Host_ShutdownServer: NET_SendToAll failed for %u clients\n", count);
|
|
|
|
|
2012-11-06 08:56:09 +00:00
|
|
|
for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++)
|
2010-02-15 23:26:55 +00:00
|
|
|
if (host_client->active)
|
|
|
|
SV_DropClient(crash);
|
|
|
|
|
|
|
|
//
|
|
|
|
// clear structures
|
|
|
|
//
|
2012-11-06 08:56:09 +00:00
|
|
|
// memset (&sv, 0, sizeof(sv)); // ServerSpawn already do this by Host_ClearMemory
|
2010-02-15 23:26:55 +00:00
|
|
|
memset (svs.clients, 0, svs.maxclientslimit*sizeof(client_t));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
Host_ClearMemory
|
|
|
|
|
|
|
|
This clears all the memory used by both the client and server, but does
|
|
|
|
not reinitialize anything.
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void Host_ClearMemory (void)
|
|
|
|
{
|
|
|
|
Con_DPrintf ("Clearing memory\n");
|
|
|
|
D_FlushCaches ();
|
|
|
|
Mod_ClearAll ();
|
2011-07-05 06:50:23 +00:00
|
|
|
/* host_hunklevel MUST be set at this point */
|
|
|
|
Hunk_FreeToLowMark (host_hunklevel);
|
2010-02-15 23:26:55 +00:00
|
|
|
cls.signon = 0;
|
2016-06-25 05:21:22 +00:00
|
|
|
free(sv.edicts); // ericw -- sv.edicts switched to use malloc()
|
2010-02-15 23:26:55 +00:00
|
|
|
memset (&sv, 0, sizeof(sv));
|
|
|
|
memset (&cl, 0, sizeof(cl));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
//
|
|
|
|
// Host Frame
|
|
|
|
//
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
Host_FilterTime
|
|
|
|
|
|
|
|
Returns false if the time is too short to run a frame
|
|
|
|
===================
|
|
|
|
*/
|
|
|
|
qboolean Host_FilterTime (float time)
|
|
|
|
{
|
|
|
|
float maxfps; //johnfitz
|
|
|
|
|
|
|
|
realtime += time;
|
|
|
|
|
|
|
|
//johnfitz -- max fps cvar
|
|
|
|
maxfps = CLAMP (10.0, host_maxfps.value, 1000.0);
|
|
|
|
if (!cls.timedemo && realtime - oldrealtime < 1.0/maxfps)
|
|
|
|
return false; // framerate is too high
|
|
|
|
//johnfitz
|
|
|
|
|
|
|
|
host_frametime = realtime - oldrealtime;
|
|
|
|
oldrealtime = realtime;
|
|
|
|
|
|
|
|
//johnfitz -- host_timescale is more intuitive than host_framerate
|
|
|
|
if (host_timescale.value > 0)
|
|
|
|
host_frametime *= host_timescale.value;
|
|
|
|
//johnfitz
|
|
|
|
else if (host_framerate.value > 0)
|
|
|
|
host_frametime = host_framerate.value;
|
|
|
|
else // don't allow really long or short frames
|
|
|
|
host_frametime = CLAMP (0.001, host_frametime, 0.1); //johnfitz -- use CLAMP
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
Host_GetConsoleCommands
|
|
|
|
|
|
|
|
Add them exactly as if they had been typed at the console
|
|
|
|
===================
|
|
|
|
*/
|
|
|
|
void Host_GetConsoleCommands (void)
|
|
|
|
{
|
2011-12-12 12:02:37 +00:00
|
|
|
const char *cmd;
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-12-15 15:51:28 +00:00
|
|
|
if (!isDedicated)
|
|
|
|
return; // no stdin necessary in graphical mode
|
|
|
|
|
2010-02-15 23:26:55 +00:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
cmd = Sys_ConsoleInput ();
|
|
|
|
if (!cmd)
|
|
|
|
break;
|
|
|
|
Cbuf_AddText (cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Host_ServerFrame
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void Host_ServerFrame (void)
|
|
|
|
{
|
|
|
|
int i, active; //johnfitz
|
|
|
|
edict_t *ent; //johnfitz
|
|
|
|
|
|
|
|
// run the world state
|
|
|
|
pr_global_struct->frametime = host_frametime;
|
|
|
|
|
|
|
|
// set the time and clear the general datagram
|
|
|
|
SV_ClearDatagram ();
|
|
|
|
|
|
|
|
// check for new clients
|
|
|
|
SV_CheckForNewClients ();
|
|
|
|
|
|
|
|
// read client messages
|
|
|
|
SV_RunClients ();
|
|
|
|
|
|
|
|
// move things around and think
|
|
|
|
// always pause in single player if in console or menus
|
|
|
|
if (!sv.paused && (svs.maxclients > 1 || key_dest == key_game) )
|
|
|
|
SV_Physics ();
|
|
|
|
|
|
|
|
//johnfitz -- devstats
|
|
|
|
if (cls.signon == SIGNONS)
|
|
|
|
{
|
|
|
|
for (i=0, active=0; i<sv.num_edicts; i++)
|
|
|
|
{
|
|
|
|
ent = EDICT_NUM(i);
|
|
|
|
if (!ent->free)
|
|
|
|
active++;
|
|
|
|
}
|
|
|
|
if (active > 600 && dev_peakstats.edicts <= 600)
|
2017-03-30 06:26:16 +00:00
|
|
|
Con_DWarning ("%i edicts exceeds standard limit of 600 (max = %d).\n", active, sv.max_edicts);
|
2010-02-15 23:26:55 +00:00
|
|
|
dev_stats.edicts = active;
|
2011-01-10 10:35:40 +00:00
|
|
|
dev_peakstats.edicts = q_max(active, dev_peakstats.edicts);
|
2010-02-15 23:26:55 +00:00
|
|
|
}
|
|
|
|
//johnfitz
|
|
|
|
|
|
|
|
// send all messages to the clients
|
|
|
|
SV_SendClientMessages ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Host_Frame
|
|
|
|
|
|
|
|
Runs all active servers
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void _Host_Frame (float time)
|
|
|
|
{
|
|
|
|
static double time1 = 0;
|
|
|
|
static double time2 = 0;
|
|
|
|
static double time3 = 0;
|
|
|
|
int pass1, pass2, pass3;
|
|
|
|
|
|
|
|
if (setjmp (host_abortserver) )
|
|
|
|
return; // something bad happened, or the server disconnected
|
|
|
|
|
|
|
|
// keep the random time dependent
|
|
|
|
rand ();
|
|
|
|
|
|
|
|
// decide the simulation time
|
|
|
|
if (!Host_FilterTime (time))
|
|
|
|
return; // don't run too fast, or packets will flood out
|
|
|
|
|
|
|
|
// get new key events
|
2012-10-23 08:44:20 +00:00
|
|
|
Key_UpdateForDest ();
|
2014-09-23 19:10:02 +00:00
|
|
|
IN_UpdateInputMode ();
|
2011-12-16 14:11:37 +00:00
|
|
|
Sys_SendKeyEvents ();
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
// allow mice or other external controllers to add commands
|
|
|
|
IN_Commands ();
|
|
|
|
|
|
|
|
// process console commands
|
|
|
|
Cbuf_Execute ();
|
|
|
|
|
|
|
|
NET_Poll();
|
|
|
|
|
|
|
|
// if running the server locally, make intentions now
|
|
|
|
if (sv.active)
|
|
|
|
CL_SendCmd ();
|
|
|
|
|
|
|
|
//-------------------
|
|
|
|
//
|
|
|
|
// server operations
|
|
|
|
//
|
|
|
|
//-------------------
|
|
|
|
|
|
|
|
// check for commands typed to the host
|
|
|
|
Host_GetConsoleCommands ();
|
|
|
|
|
|
|
|
if (sv.active)
|
|
|
|
Host_ServerFrame ();
|
|
|
|
|
|
|
|
//-------------------
|
|
|
|
//
|
|
|
|
// client operations
|
|
|
|
//
|
|
|
|
//-------------------
|
|
|
|
|
|
|
|
// if running the server remotely, send intentions now after
|
|
|
|
// the incoming messages have been read
|
|
|
|
if (!sv.active)
|
|
|
|
CL_SendCmd ();
|
|
|
|
|
|
|
|
// fetch results from server
|
|
|
|
if (cls.state == ca_connected)
|
|
|
|
CL_ReadFromServer ();
|
|
|
|
|
|
|
|
// update video
|
|
|
|
if (host_speeds.value)
|
2011-12-12 16:01:01 +00:00
|
|
|
time1 = Sys_DoubleTime ();
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
SCR_UpdateScreen ();
|
|
|
|
|
|
|
|
CL_RunParticles (); //johnfitz -- seperated from rendering
|
|
|
|
|
|
|
|
if (host_speeds.value)
|
2011-12-12 16:01:01 +00:00
|
|
|
time2 = Sys_DoubleTime ();
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
// update audio
|
Backported external music files support using decoder libraries and the
new raw samples interface from Hammer of Thyrion (uhexen2) :
- bgmusic.c, bgmusic.h: New BGM interface for background music handling.
Handles streaming music as raw sound samples.
- bgmnull.c: BGM source for cases where the engine is configured for no
sound.
- cl_main.c: Include bgmusic.h. Call BGM_Stop() and CDAudio_Stop() in
CL_Disconnect().
- cd_sdl.c: Moved bgmvolume boundary checking to bgmusic.c upon value
changes.
- gl_vidnt.c, gl_vidsdl.c, cl_parse.c: Include bgmusic.h. Add BGM_Pause()
and BGM_Resume() calls along with CDAudio_ counterparts.
- cl_parse.c: Replace CDAudio_Play() call by the new BGM_PlayCDtrack()
which first tries CDAudio_Play() and then streaming music if it fails.
- host.c: Include bgmusic.h. Call BGM_Update() just before S_Update()
in Host_Frame(). In Host_Init(), call BGM_Init() after other audio init
calls. In Host_Shutdown(), call BGM_Shutdown() before all other audio
shutdown calls.
- snd_dma.c: Include snd_codec.h and bgmusic.h. Call S_CodecInit() from
S_Init(). Call S_CodecShutdown() from S_Shutdown().
- snd_codec.c, snd_codec.h: New public codec interface for streaming
music as raw samples. Adapted from quake2 and ioquake3 with changes.
Individual codecs are responsible for handling any necessary byte swap
operations.
- snd_codeci.h: New header for snd_codec internals.
- snd_wave.c, snd_wave.h: Codec for WAV format streaming music. Adapted
from ioquake3 with changes.
- snd_vorbis.c, snd_vorbis.h: Codec for Ogg/Vorbis format streaming music.
- snd_mp3.c, snd_mp3.h: Codec for MP3 format streaming music using libmad.
Adapted from the SoX project with changes.
- Makefile: Adjusted for the new sources. Added switches USE_CODEC_WAVE,
USE_CODEC_MP3, USE_CODEC_VORBIS for enabling and disabling individual
codecs.
- Windows makefiles and project files as well as other CodeBlocks project
files will be updated shortly.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@374 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-01-05 19:50:43 +00:00
|
|
|
BGM_Update(); // adds music raw samples and/or advances midi driver
|
2010-02-15 23:26:55 +00:00
|
|
|
if (cls.signon == SIGNONS)
|
|
|
|
{
|
|
|
|
S_Update (r_origin, vpn, vright, vup);
|
|
|
|
CL_DecayLights ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin);
|
|
|
|
|
|
|
|
CDAudio_Update();
|
|
|
|
|
|
|
|
if (host_speeds.value)
|
|
|
|
{
|
|
|
|
pass1 = (time1 - time3)*1000;
|
2011-12-12 16:01:01 +00:00
|
|
|
time3 = Sys_DoubleTime ();
|
2010-02-15 23:26:55 +00:00
|
|
|
pass2 = (time2 - time1)*1000;
|
|
|
|
pass3 = (time3 - time2)*1000;
|
|
|
|
Con_Printf ("%3i tot %3i server %3i gfx %3i snd\n",
|
|
|
|
pass1+pass2+pass3, pass1, pass2, pass3);
|
|
|
|
}
|
|
|
|
|
|
|
|
host_framecount++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Host_Frame (float time)
|
|
|
|
{
|
|
|
|
double time1, time2;
|
|
|
|
static double timetotal;
|
|
|
|
static int timecount;
|
|
|
|
int i, c, m;
|
|
|
|
|
|
|
|
if (!serverprofile.value)
|
|
|
|
{
|
|
|
|
_Host_Frame (time);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-12 16:01:01 +00:00
|
|
|
time1 = Sys_DoubleTime ();
|
2010-02-15 23:26:55 +00:00
|
|
|
_Host_Frame (time);
|
2011-12-12 16:01:01 +00:00
|
|
|
time2 = Sys_DoubleTime ();
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
timetotal += time2 - time1;
|
|
|
|
timecount++;
|
|
|
|
|
|
|
|
if (timecount < 1000)
|
|
|
|
return;
|
|
|
|
|
|
|
|
m = timetotal*1000/timecount;
|
|
|
|
timecount = 0;
|
|
|
|
timetotal = 0;
|
|
|
|
c = 0;
|
2012-11-06 08:56:09 +00:00
|
|
|
for (i = 0; i < svs.maxclients; i++)
|
2010-02-15 23:26:55 +00:00
|
|
|
{
|
|
|
|
if (svs.clients[i].active)
|
|
|
|
c++;
|
|
|
|
}
|
|
|
|
|
|
|
|
Con_Printf ("serverprofile: %2i clients %2i msec\n", c, m);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
Host_Init
|
|
|
|
====================
|
|
|
|
*/
|
2011-04-19 16:41:45 +00:00
|
|
|
void Host_Init (void)
|
2010-02-15 23:26:55 +00:00
|
|
|
{
|
|
|
|
if (standard_quake)
|
|
|
|
minimum_memory = MINIMUM_MEMORY;
|
2012-11-06 08:56:09 +00:00
|
|
|
else minimum_memory = MINIMUM_MEMORY_LEVELPAK;
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
if (COM_CheckParm ("-minmemory"))
|
2011-04-19 16:41:45 +00:00
|
|
|
host_parms->memsize = minimum_memory;
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-04-19 16:41:45 +00:00
|
|
|
if (host_parms->memsize < minimum_memory)
|
|
|
|
Sys_Error ("Only %4.1f megs of memory available, can't execute game", host_parms->memsize / (float)0x100000);
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-04-19 16:41:45 +00:00
|
|
|
com_argc = host_parms->argc;
|
|
|
|
com_argv = host_parms->argv;
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-04-19 16:41:45 +00:00
|
|
|
Memory_Init (host_parms->membase, host_parms->memsize);
|
2010-02-15 23:26:55 +00:00
|
|
|
Cbuf_Init ();
|
|
|
|
Cmd_Init ();
|
2011-04-19 16:41:45 +00:00
|
|
|
LOG_Init (host_parms);
|
2010-02-15 23:26:55 +00:00
|
|
|
Cvar_Init (); //johnfitz
|
2011-04-19 16:41:45 +00:00
|
|
|
COM_Init ();
|
2011-12-29 15:10:18 +00:00
|
|
|
COM_InitFilesystem ();
|
2010-02-15 23:26:55 +00:00
|
|
|
Host_InitLocal ();
|
|
|
|
W_LoadWadFile (); //johnfitz -- filename is now hard-coded for honesty
|
2010-06-26 08:16:58 +00:00
|
|
|
if (cls.state != ca_dedicated)
|
|
|
|
{
|
|
|
|
Key_Init ();
|
|
|
|
Con_Init ();
|
|
|
|
}
|
2010-02-15 23:26:55 +00:00
|
|
|
PR_Init ();
|
|
|
|
Mod_Init ();
|
|
|
|
NET_Init ();
|
|
|
|
SV_Init ();
|
|
|
|
|
2016-04-29 20:00:50 +00:00
|
|
|
Con_Printf ("Exe: " __TIME__ " " __DATE__ "\n");
|
2011-04-19 16:41:45 +00:00
|
|
|
Con_Printf ("%4.1f megabyte heap\n", host_parms->memsize/ (1024*1024.0));
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
if (cls.state != ca_dedicated)
|
|
|
|
{
|
2011-01-02 21:45:16 +00:00
|
|
|
host_colormap = (byte *)COM_LoadHunkFile ("gfx/colormap.lmp", NULL);
|
2010-02-15 23:26:55 +00:00
|
|
|
if (!host_colormap)
|
|
|
|
Sys_Error ("Couldn't load gfx/colormap.lmp");
|
|
|
|
|
2010-06-26 08:16:58 +00:00
|
|
|
V_Init ();
|
|
|
|
Chase_Init ();
|
|
|
|
M_Init ();
|
|
|
|
ExtraMaps_Init (); //johnfitz
|
|
|
|
Modlist_Init (); //johnfitz
|
2015-05-30 02:28:58 +00:00
|
|
|
DemoList_Init (); //ericw
|
2010-02-15 23:26:55 +00:00
|
|
|
VID_Init ();
|
2012-11-06 08:56:09 +00:00
|
|
|
IN_Init ();
|
2010-02-15 23:26:55 +00:00
|
|
|
TexMgr_Init (); //johnfitz
|
|
|
|
Draw_Init ();
|
|
|
|
SCR_Init ();
|
|
|
|
R_Init ();
|
|
|
|
S_Init ();
|
|
|
|
CDAudio_Init ();
|
Backported external music files support using decoder libraries and the
new raw samples interface from Hammer of Thyrion (uhexen2) :
- bgmusic.c, bgmusic.h: New BGM interface for background music handling.
Handles streaming music as raw sound samples.
- bgmnull.c: BGM source for cases where the engine is configured for no
sound.
- cl_main.c: Include bgmusic.h. Call BGM_Stop() and CDAudio_Stop() in
CL_Disconnect().
- cd_sdl.c: Moved bgmvolume boundary checking to bgmusic.c upon value
changes.
- gl_vidnt.c, gl_vidsdl.c, cl_parse.c: Include bgmusic.h. Add BGM_Pause()
and BGM_Resume() calls along with CDAudio_ counterparts.
- cl_parse.c: Replace CDAudio_Play() call by the new BGM_PlayCDtrack()
which first tries CDAudio_Play() and then streaming music if it fails.
- host.c: Include bgmusic.h. Call BGM_Update() just before S_Update()
in Host_Frame(). In Host_Init(), call BGM_Init() after other audio init
calls. In Host_Shutdown(), call BGM_Shutdown() before all other audio
shutdown calls.
- snd_dma.c: Include snd_codec.h and bgmusic.h. Call S_CodecInit() from
S_Init(). Call S_CodecShutdown() from S_Shutdown().
- snd_codec.c, snd_codec.h: New public codec interface for streaming
music as raw samples. Adapted from quake2 and ioquake3 with changes.
Individual codecs are responsible for handling any necessary byte swap
operations.
- snd_codeci.h: New header for snd_codec internals.
- snd_wave.c, snd_wave.h: Codec for WAV format streaming music. Adapted
from ioquake3 with changes.
- snd_vorbis.c, snd_vorbis.h: Codec for Ogg/Vorbis format streaming music.
- snd_mp3.c, snd_mp3.h: Codec for MP3 format streaming music using libmad.
Adapted from the SoX project with changes.
- Makefile: Adjusted for the new sources. Added switches USE_CODEC_WAVE,
USE_CODEC_MP3, USE_CODEC_VORBIS for enabling and disabling individual
codecs.
- Windows makefiles and project files as well as other CodeBlocks project
files will be updated shortly.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@374 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-01-05 19:50:43 +00:00
|
|
|
BGM_Init();
|
2010-02-15 23:26:55 +00:00
|
|
|
Sbar_Init ();
|
|
|
|
CL_Init ();
|
2010-06-26 08:45:40 +00:00
|
|
|
}
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
Hunk_AllocName (0, "-HOST_HUNKLEVEL-");
|
|
|
|
host_hunklevel = Hunk_LowMark ();
|
|
|
|
|
|
|
|
host_initialized = true;
|
2011-07-05 06:45:31 +00:00
|
|
|
Con_Printf ("\n========= Quake Initialized =========\n\n");
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-07-05 06:45:31 +00:00
|
|
|
if (cls.state != ca_dedicated)
|
|
|
|
{
|
|
|
|
Cbuf_InsertText ("exec quake.rc\n");
|
|
|
|
// johnfitz -- in case the vid mode was locked during vid_init, we can unlock it now.
|
|
|
|
// note: two leading newlines because the command buffer swallows one of them.
|
|
|
|
Cbuf_AddText ("\n\nvid_unlock\n");
|
|
|
|
}
|
2010-06-26 08:45:40 +00:00
|
|
|
|
|
|
|
if (cls.state == ca_dedicated)
|
|
|
|
{
|
|
|
|
Cbuf_AddText ("exec autoexec.cfg\n");
|
|
|
|
Cbuf_AddText ("stuffcmds");
|
|
|
|
Cbuf_Execute ();
|
|
|
|
if (!sv.active)
|
|
|
|
Cbuf_AddText ("map start\n");
|
|
|
|
}
|
2010-02-15 23:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
Host_Shutdown
|
|
|
|
|
|
|
|
FIXME: this is a callback from Sys_Quit and Sys_Error. It would be better
|
|
|
|
to run quit through here before the final handoff to the sys code.
|
|
|
|
===============
|
|
|
|
*/
|
|
|
|
void Host_Shutdown(void)
|
|
|
|
{
|
|
|
|
static qboolean isdown = false;
|
|
|
|
|
|
|
|
if (isdown)
|
|
|
|
{
|
|
|
|
printf ("recursive shutdown\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
isdown = true;
|
|
|
|
|
|
|
|
// keep Con_Printf from trying to update the screen
|
|
|
|
scr_disabled_for_loading = true;
|
|
|
|
|
|
|
|
Host_WriteConfiguration ();
|
|
|
|
|
|
|
|
NET_Shutdown ();
|
|
|
|
|
|
|
|
if (cls.state != ca_dedicated)
|
|
|
|
{
|
2010-06-26 00:31:12 +00:00
|
|
|
if (con_initialized)
|
|
|
|
History_Shutdown ();
|
Backported external music files support using decoder libraries and the
new raw samples interface from Hammer of Thyrion (uhexen2) :
- bgmusic.c, bgmusic.h: New BGM interface for background music handling.
Handles streaming music as raw sound samples.
- bgmnull.c: BGM source for cases where the engine is configured for no
sound.
- cl_main.c: Include bgmusic.h. Call BGM_Stop() and CDAudio_Stop() in
CL_Disconnect().
- cd_sdl.c: Moved bgmvolume boundary checking to bgmusic.c upon value
changes.
- gl_vidnt.c, gl_vidsdl.c, cl_parse.c: Include bgmusic.h. Add BGM_Pause()
and BGM_Resume() calls along with CDAudio_ counterparts.
- cl_parse.c: Replace CDAudio_Play() call by the new BGM_PlayCDtrack()
which first tries CDAudio_Play() and then streaming music if it fails.
- host.c: Include bgmusic.h. Call BGM_Update() just before S_Update()
in Host_Frame(). In Host_Init(), call BGM_Init() after other audio init
calls. In Host_Shutdown(), call BGM_Shutdown() before all other audio
shutdown calls.
- snd_dma.c: Include snd_codec.h and bgmusic.h. Call S_CodecInit() from
S_Init(). Call S_CodecShutdown() from S_Shutdown().
- snd_codec.c, snd_codec.h: New public codec interface for streaming
music as raw samples. Adapted from quake2 and ioquake3 with changes.
Individual codecs are responsible for handling any necessary byte swap
operations.
- snd_codeci.h: New header for snd_codec internals.
- snd_wave.c, snd_wave.h: Codec for WAV format streaming music. Adapted
from ioquake3 with changes.
- snd_vorbis.c, snd_vorbis.h: Codec for Ogg/Vorbis format streaming music.
- snd_mp3.c, snd_mp3.h: Codec for MP3 format streaming music using libmad.
Adapted from the SoX project with changes.
- Makefile: Adjusted for the new sources. Added switches USE_CODEC_WAVE,
USE_CODEC_MP3, USE_CODEC_VORBIS for enabling and disabling individual
codecs.
- Windows makefiles and project files as well as other CodeBlocks project
files will be updated shortly.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@374 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-01-05 19:50:43 +00:00
|
|
|
BGM_Shutdown();
|
2010-06-26 00:31:12 +00:00
|
|
|
CDAudio_Shutdown ();
|
|
|
|
S_Shutdown ();
|
2012-11-06 08:56:09 +00:00
|
|
|
IN_Shutdown ();
|
2010-02-15 23:26:55 +00:00
|
|
|
VID_Shutdown();
|
|
|
|
}
|
2010-08-23 09:49:03 +00:00
|
|
|
|
2010-04-27 08:24:13 +00:00
|
|
|
LOG_Close ();
|
2010-02-15 23:26:55 +00:00
|
|
|
}
|
|
|
|
|