//static qboolean QW_CL_IsUploading(void);
static void QW_CL_StopUpload(void);
void CL_VM_UpdateIntermissionState(int intermission);
-qboolean CL_VM_Event_Sound(int sound_num, int volume, int channel, float attenuation, int ent, vec3_t pos);
+qboolean CL_VM_Event_Sound(int sound_num, float volume, int channel, float attenuation, int ent, vec3_t pos);
/*
==================
qfile_t *file;
// see if the file already exists
- file = FS_Open(filename, "rb", true, false);
+ file = FS_OpenVirtualFile(filename, true);
if (file)
{
FS_Close(file);
&& !FS_FileExists(va("dlcache/%s.%i.%i", csqc_progname.string, csqc_progsize.integer, csqc_progcrc.integer)))
{
Con_Printf("Downloading new CSQC code to dlcache/%s.%i.%i\n", csqc_progname.string, csqc_progsize.integer, csqc_progcrc.integer);
- Cmd_ForwardStringToServer(va("download %s", csqc_progname.string));
+ if(cl_serverextension_download.integer == 2 && FS_HasZlib())
+ Cmd_ForwardStringToServer(va("download %s deflate", csqc_progname.string));
+ else
+ Cmd_ForwardStringToServer(va("download %s", csqc_progname.string));
return;
}
}
continue;
if (cls.signon < SIGNONS)
CL_KeepaliveMessage(true);
- if (!FS_FileExists(cl.model_name[cl.downloadmodel_current]))
+ if (strcmp(cl.model_name[cl.downloadmodel_current], "null") && !FS_FileExists(cl.model_name[cl.downloadmodel_current]))
{
if (cl.downloadmodel_current == 1)
Con_Printf("Map %s not found\n", cl.model_name[cl.downloadmodel_current]);
size_t existingsize;
const char *extension;
- // finished file
- // save to disk only if we don't already have it
- // (this is mainly for playing back demos)
- existingcrc = FS_CRCFile(cls.qw_downloadname, &existingsize);
- if (existingsize || gamemode == GAME_NEXUIZ || !strcmp(cls.qw_downloadname, csqc_progname.string))
- // let csprogs ALWAYS go to dlcache, to prevent "viral csprogs"; also, never put files outside dlcache for Nexuiz
+ if(cls.qw_download_deflate)
+ {
+ unsigned char *out;
+ size_t inflated_size;
+ out = FS_Inflate(cls.qw_downloadmemory, cls.qw_downloadmemorycursize, &inflated_size, tempmempool);
+ Mem_Free(cls.qw_downloadmemory);
+ Con_Printf("Inflated download: new size: %u (%g%%)\n", (unsigned)inflated_size, 100.0 - 100.0*(cls.qw_downloadmemorycursize / (float)inflated_size));
+ cls.qw_downloadmemory = out;
+ cls.qw_downloadmemorycursize = inflated_size;
+ }
+
+ if(!cls.qw_downloadmemory)
{
- if ((int)existingsize != size || existingcrc != crc)
+ Con_Printf("Download \"%s\" is corrupt (see above!)\n", cls.qw_downloadname);
+ }
+ else
+ {
+ crc = CRC_Block(cls.qw_downloadmemory, cls.qw_downloadmemorycursize);
+ size = cls.qw_downloadmemorycursize;
+ // finished file
+ // save to disk only if we don't already have it
+ // (this is mainly for playing back demos)
+ existingcrc = FS_CRCFile(cls.qw_downloadname, &existingsize);
+ if (existingsize || gamemode == GAME_NEXUIZ || !strcmp(cls.qw_downloadname, csqc_progname.string))
+ // let csprogs ALWAYS go to dlcache, to prevent "viral csprogs"; also, never put files outside dlcache for Nexuiz
{
- // we have a mismatching file, pick another name for it
- char name[MAX_QPATH*2];
- dpsnprintf(name, sizeof(name), "dlcache/%s.%i.%i", cls.qw_downloadname, size, crc);
- if (!FS_FileExists(name))
+ if ((int)existingsize != size || existingcrc != crc)
{
- Con_Printf("Downloaded \"%s\" (%i bytes, %i CRC)\n", name, size, crc);
- FS_WriteFile(name, cls.qw_downloadmemory, cls.qw_downloadmemorycursize);
+ // we have a mismatching file, pick another name for it
+ char name[MAX_QPATH*2];
+ dpsnprintf(name, sizeof(name), "dlcache/%s.%i.%i", cls.qw_downloadname, size, crc);
+ if (!FS_FileExists(name))
+ {
+ Con_Printf("Downloaded \"%s\" (%i bytes, %i CRC)\n", name, size, crc);
+ FS_WriteFile(name, cls.qw_downloadmemory, cls.qw_downloadmemorycursize);
+ }
}
}
- }
- else
- {
- // we either don't have it or have a mismatching file...
- // so it's time to accept the file
- // but if we already have a mismatching file we need to rename
- // this new one, and if we already have this file in renamed form,
- // we do nothing
- Con_Printf("Downloaded \"%s\" (%i bytes, %i CRC)\n", cls.qw_downloadname, size, crc);
- FS_WriteFile(cls.qw_downloadname, cls.qw_downloadmemory, cls.qw_downloadmemorycursize);
- extension = FS_FileExtension(cls.qw_downloadname);
- if (!strcasecmp(extension, "pak") || !strcasecmp(extension, "pk3"))
- FS_Rescan();
+ else
+ {
+ // we either don't have it or have a mismatching file...
+ // so it's time to accept the file
+ // but if we already have a mismatching file we need to rename
+ // this new one, and if we already have this file in renamed form,
+ // we do nothing
+ Con_Printf("Downloaded \"%s\" (%i bytes, %i CRC)\n", cls.qw_downloadname, size, crc);
+ FS_WriteFile(cls.qw_downloadname, cls.qw_downloadmemory, cls.qw_downloadmemorycursize);
+ extension = FS_FileExtension(cls.qw_downloadname);
+ if (!strcasecmp(extension, "pak") || !strcasecmp(extension, "pk3"))
+ FS_Rescan();
+ }
}
}
else if (cls.qw_downloadmemory && size)
// we're really beginning a download now, so initialize stuff
strlcpy(cls.qw_downloadname, Cmd_Argv(2), sizeof(cls.qw_downloadname));
cls.qw_downloadmemorymaxsize = size;
- cls.qw_downloadmemory = Mem_Alloc(cls.permanentmempool, cls.qw_downloadmemorymaxsize);
+ cls.qw_downloadmemory = (unsigned char *) Mem_Alloc(cls.permanentmempool, cls.qw_downloadmemorymaxsize);
cls.qw_downloadnumber++;
+ cls.qw_download_deflate = false;
+ if(Cmd_Argc() >= 4)
+ {
+ if(!strcmp(Cmd_Argv(3), "deflate"))
+ cls.qw_download_deflate = true;
+ // check further encodings here
+ }
+
Cmd_ForwardStringToServer("sv_startdownload");
}
cl.movevars_wallfriction = 0;
cl.movevars_timescale = 1;
cl.movevars_jumpvelocity = 270;
- cl.movevars_edgefriction = 2;
+ cl.movevars_edgefriction = 1;
cl.movevars_maxairspeed = 30;
cl.movevars_stepheight = 18;
cl.movevars_airaccel_qw = 1;
// parse gametype
cl.gametype = MSG_ReadByte ();
+ // the original id singleplayer demos are bugged and contain
+ // GAME_DEATHMATCH even for singleplayer
+ if (cl.maxclients == 1 && cls.protocol == PROTOCOL_QUAKE)
+ cl.gametype = GAME_COOP;
// parse signon message
str = MSG_ReadString ();
Con_Printf ("Auto-recording to %s.\n", demofile);
- cls.demofile = FS_Open (demofile, "wb", false, false);
+ cls.demofile = FS_OpenRealFile(demofile, "wb", false);
if (cls.demofile)
{
cls.forcetrack = -1;
FS_Printf (cls.demofile, "%i\n", cls.forcetrack);
cls.demorecording = true;
strlcpy(cls.demoname, demofile, sizeof(cls.demoname));
+ cls.demo_lastcsprogssize = -1;
+ cls.demo_lastcsprogscrc = -1;
}
else
Con_Print ("ERROR: couldn't open.\n");
// (this used to happen, sometimes affecting skin and frame)
// colormap is client index + 1
- if ((!s->flags & RENDER_COLORMAPPED) && s->colormap > cl.maxclients)
+ if (!(s->flags & RENDER_COLORMAPPED) && s->colormap > cl.maxclients)
Con_DPrintf("CL_ValidateState: colormap (%i) > cl.maxclients (%i)\n", s->colormap, cl.maxclients);
model = cl.model_precache[s->modelindex];
{
cl_iplog_item_t *olditems = cl_iplog_items;
cl_iplog_maxitems = max(1024, cl_iplog_maxitems + 256);
- cl_iplog_items = Mem_Alloc(cls.permanentmempool, cl_iplog_maxitems * sizeof(cl_iplog_item_t));
+ cl_iplog_items = (cl_iplog_item_t *) Mem_Alloc(cls.permanentmempool, cl_iplog_maxitems * sizeof(cl_iplog_item_t));
if (olditems)
{
if (cl_iplog_numitems)
Mem_Free(olditems);
}
}
- cl_iplog_items[cl_iplog_numitems].address = Mem_Alloc(cls.permanentmempool, strlen(address) + 1);
- cl_iplog_items[cl_iplog_numitems].name = Mem_Alloc(cls.permanentmempool, strlen(name) + 1);
+ cl_iplog_items[cl_iplog_numitems].address = (char *) Mem_Alloc(cls.permanentmempool, strlen(address) + 1);
+ cl_iplog_items[cl_iplog_numitems].name = (char *) Mem_Alloc(cls.permanentmempool, strlen(name) + 1);
strlcpy(cl_iplog_items[cl_iplog_numitems].address, address, strlen(address) + 1);
// TODO: maybe it would be better to strip weird characters from name when
// copying it here rather than using a straight strcpy?
text++;
if (line[0] == '/' && line[1] == '/')
continue; // skip comments if anyone happens to add them
- for (i = 0;i < len && line[i] > ' ';i++)
+ for (i = 0;i < len && !ISWHITESPACE(line[i]);i++)
address[i] = line[i];
address[i] = 0;
// skip exactly one space character
}
extern cvar_t slowmo;
+extern void CSQC_UpdateNetworkTimes(double newtime, double oldtime);
static void CL_NetworkTimeReceived(double newtime)
{
double timehigh;
cl.fixangle[0] = false;
if (!cls.demoplayback)
VectorCopy(cl.mviewangles[0], cl.mviewangles[1]);
+ // update the csqc's server timestamps, critical for proper sync
+ CSQC_UpdateNetworkTimes(cl.mtime[0], cl.mtime[1]);
}
#define SHOWNET(x) if(cl_shownet.integer==2)Con_Printf("%3i:%s(%i)\n", msg_readcount-1, x, cmd);