Skip to content

Commit

Permalink
the client will check for updates every 5 minutes, refs #32
Browse files Browse the repository at this point in the history
  • Loading branch information
jackeri committed Dec 18, 2014
1 parent a38b66e commit 68e0196
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
27 changes: 24 additions & 3 deletions src/client/cl_main.c
Expand Up @@ -760,6 +760,26 @@ void CL_RequestMotd(void)
NET_OutOfBandPrint(NS_CLIENT, autoupdate.motdServer, "getmotd \"%s\"", info);
}

void CL_RequestMasterData(qboolean force)
{
if (!force && autoupdate.masterDataChecked > 0 && cls.realtime - autoupdate.masterDataChecked < 300000)
{
return;
}

//Only check when we are not running a game
if (cls.state >= CA_LOADING)
{
return;
}

autoupdate.masterDataChecked = cls.realtime;

// fire a message off to the motd server and check for update
CL_RequestMotd();
CL_CheckAutoUpdate();
}

/*
======================================================================
CONSOLE COMMANDS
Expand Down Expand Up @@ -951,9 +971,7 @@ void CL_Connect_f(void)
Cvar_Set("r_uiFullScreen", "0");
Cvar_Set("ui_connecting", "1");

// fire a message off to the motd server and check for update
CL_RequestMotd();
CL_CheckAutoUpdate();
CL_RequestMasterData(qtrue);

// clear any previous "server full" type messages
clc.serverMessage[0] = 0;
Expand Down Expand Up @@ -2541,6 +2559,9 @@ void CL_Frame(int msec)
// resend a connection request if necessary
CL_CheckForResend();

// request motd and update data from the master server
CL_RequestMasterData(qfalse);

// decide on the serverTime to render
CL_SetCGameTime();

Expand Down
3 changes: 1 addition & 2 deletions src/client/cl_ui.c
Expand Up @@ -1231,8 +1231,7 @@ intptr_t CL_UISystemCalls(intptr_t *args)
CL_TranslateStringMod(VMA(1), VMA(2));
return 0;
case UI_CHECKAUTOUPDATE:
CL_RequestMotd();
CL_CheckAutoUpdate();
CL_RequestMasterData(qfalse);
return 0;
case UI_GET_AUTOUPDATE:
CL_GetAutoUpdate();
Expand Down
7 changes: 1 addition & 6 deletions src/client/cl_update.c
Expand Up @@ -63,12 +63,6 @@ void CL_CheckAutoUpdate(void)
return;
}

// Only check once per session
if (autoupdate.updateChecked)
{
return;
}

// Resolve update server
Com_Printf("Updater: resolving %s... ", UPDATE_SERVER_NAME);

Expand Down Expand Up @@ -434,6 +428,7 @@ void CL_UpdateVarsClean(int flags)
Cvar_Set("com_updatefiles", "");
Cvar_Set("com_updatemessage", "");
Cvar_Set("com_updatefiles", "");
autoupdate.masterDataChecked = 0;
case CLEAR_FLAGS:
autoupdate.updateChecked = qfalse;
autoupdate.forceUpdate = qfalse;
Expand Down
1 change: 1 addition & 0 deletions src/client/client.h
Expand Up @@ -452,6 +452,7 @@ void CL_AddReliableCommand(const char *cmd);
void CL_StartHunkUsers(void);

void CL_RequestMotd(void);
void CL_RequestMasterData(qboolean force);

void CL_Disconnect_f(void);
void CL_GetChallengePacket(void);
Expand Down
1 change: 1 addition & 0 deletions src/qcommon/qcommon.h
Expand Up @@ -286,6 +286,7 @@ typedef struct

char motdChallenge[MAX_TOKEN_CHARS];

int masterDataChecked;
} autoupdate_t;

extern autoupdate_t autoupdate;
Expand Down

0 comments on commit 68e0196

Please sign in to comment.