Skip to content

Commit

Permalink
client: update is copied to the appropriate directory, warning fix, r…
Browse files Browse the repository at this point in the history
…efs #32
  • Loading branch information
JanSimek committed Feb 4, 2013
1 parent 61fa3e1 commit e9b64de
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 21 deletions.
47 changes: 30 additions & 17 deletions src/client/cl_main.c
Expand Up @@ -1067,7 +1067,7 @@ void CL_Disconnect(qboolean showMainMenu)
Cvar_Set("cl_downloadName", "");

autoupdateStarted = qfalse;
Cvar_Set("cl_updatefiles", "");
// TODO: clean autoupdate cvars
}

if (clc.demofile)
Expand Down Expand Up @@ -1763,27 +1763,30 @@ void CL_DownloadsComplete(void)
{
if (strlen(cl_updatefiles->string) > 4)
{
/*
char *fn;
fn = FS_BuildOSPath(Cvar_VariableString("fs_homepath"), AUTOUPDATE_DIR, cl_updatefiles->string);
#ifndef _WIN32
#ifndef _WIN32
Sys_Chmod(fn, S_IXUSR);
#endif
#endif
// will either exit with a successful process spawn, or will Com_Error ERR_DROP
// so we need to clear the disconnected download data if needed
if (cls.bWWWDlDisconnected)
{
cls.bWWWDlDisconnected = qfalse;
CL_ClearStaticDownload();
cls.bWWWDlDisconnected = qfalse;
CL_ClearStaticDownload();
}
Sys_StartProcess(fn, qtrue);
// reinitialize the filesystem if the game directory or checksum has changed
// - after Legacy mod update
FS_ConditionalRestart(clc.checksumFeed);
*/
}
autoupdateStarted = qfalse;

if (!cls.bWWWDlDisconnected)
{
CL_Disconnect(qtrue);
}
CL_Disconnect(qtrue);

// we can reset that now
cls.bWWWDlDisconnected = qfalse;
Expand Down Expand Up @@ -1952,27 +1955,33 @@ void CL_InitDownloads(void)
cls.bWWWDlDisconnected = qfalse;
CL_ClearStaticDownload();

#ifdef FEATURE_AUTOUPDATE
if (autoupdateStarted && NET_CompareAdr(cls.autoupdateServer, clc.serverAddress))
{
if (strlen(cl_updatefiles->string) > 4)
{
clc.bWWWDl = qtrue;
cls.bWWWDlDisconnected = qtrue;
cls.state == CA_CONNECTED;

// download format: @%s/%s@%s/%s
Q_strncpyz(clc.downloadList, cl_updatefiles->string, MAX_INFO_STRING);
// download format: @remotename@localname
Q_strncpyz(clc.downloadList, va("@%s@%s", cl_updatefiles->string, cl_updatefiles->string), MAX_INFO_STRING);
Q_strncpyz(cls.originalDownloadName, cl_updatefiles->string, sizeof(cls.originalDownloadName));
Q_strncpyz(cls.downloadName, va("%s/%s", UPDATE_SERVER_NAME, cl_updatefiles->string), sizeof(cls.downloadName));
Q_strncpyz(cls.downloadTempName, FS_BuildOSPath(Cvar_VariableString("fs_homepath"), AUTOUPDATE_DIR, va("%s.tmp", cls.originalDownloadName)), sizeof(cls.downloadTempName));

// Cvar_SetValue("cl_downloadSize", clc.downloadSize);

if (!DL_BeginDownload(FS_BuildOSPath(Cvar_VariableString("fs_homepath"), AUTOUPDATE_DIR, cl_updatefiles->string),
va("%s/%s", UPDATE_SERVER_NAME, cl_updatefiles->string)))
if (!DL_BeginDownload(cls.downloadTempName, cls.downloadName))
{
Com_Printf(S_COLOR_RED "ERROR: Downloading new update failed.\n");
Com_Printf(S_COLOR_RED "ERROR: Downloading new update file \"%s\" failed.\n", cls.downloadName);
clc.bWWWDlAborting = qtrue;
}

return;
}
}
else
#endif /* FEATURE_AUTOUPDATE */
{
// whatever autodownlad configuration, store missing files in a cvar, use later in the ui maybe
if (FS_ComparePaks(missingfiles, sizeof(missingfiles), qfalse))
Expand Down Expand Up @@ -2531,16 +2540,20 @@ void CL_ConnectionlessPacket(netadr_t from, msg_t *msg)
*/
void CL_PacketEvent(netadr_t from, msg_t *msg)
{
int headerBytes;
int headerBytes;

#ifdef FEATURE_AUTOUPDATE
static qboolean autoupdateRedirected = qfalse;

// Update server doesn't understand netchan packets
if (autoupdateStarted && !autoupdateRedirected)
if (NET_CompareAdr(cls.autoupdateServer, clc.serverAddress)
&& autoupdateStarted && !autoupdateRedirected)
{
autoupdateRedirected = qtrue;
CL_InitDownloads();
return;
}
#endif /* FEATURE_AUTOUPDATE */

if (msg->cursize >= 4 && *( int * ) msg->data == -1)
{
Expand Down
4 changes: 2 additions & 2 deletions src/client/client.h
Expand Up @@ -482,8 +482,8 @@ qboolean CL_GetLimboString(int index, char *buf);

qboolean CL_OpenAVIForWriting(const char *filename);
void CL_TakeVideoFrame(void);
void CL_WriteAVIVideoFrame(const byte * imageBuffer, int size);
void CL_WriteAVIAudioFrame(const byte * pcmBuffer, int size);
void CL_WriteAVIVideoFrame(const byte *imageBuffer, int size);
void CL_WriteAVIAudioFrame(const byte *pcmBuffer, int size);
qboolean CL_CloseAVI(void);
qboolean CL_VideoRecording(void);

Expand Down
10 changes: 8 additions & 2 deletions src/qcommon/files.c
Expand Up @@ -518,7 +518,13 @@ void FS_CopyFile(char *fromOSPath, char *toOSPath)
int len;
byte *buf;

Com_Printf("copy %s to %s\n", fromOSPath, toOSPath);
if ((!fromOSPath || fromOSPath[0] == '\0') || (!toOSPath || toOSPath[0] == '\0'))
{
Com_Printf(S_COLOR_YELLOW "WARNING: cannot copy files. Empty path passed to FS_CopyFile\n");
return;
}

Com_Printf("Copying %s to %s\n", fromOSPath, toOSPath);

if (strstr(fromOSPath, "journal.dat") || strstr(fromOSPath, "journaldata.dat"))
{
Expand Down Expand Up @@ -555,7 +561,7 @@ void FS_CopyFile(char *fromOSPath, char *toOSPath)
f = fopen(toOSPath, "wb");
if (!f)
{
free(buf); //DAJ free as well
free(buf);
return;
}
if (fwrite(buf, 1, len, f) != len)
Expand Down

0 comments on commit e9b64de

Please sign in to comment.