mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-29 07:02:12 +00:00
Refuse to autoupdate the engine when the binary looks like it has a revision number in its file name.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5943 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
14dddfd63c
commit
4d4a2943fb
2 changed files with 43 additions and 9 deletions
|
@ -2957,6 +2957,10 @@ qboolean Sys_SetUpdatedBinary(const char *newbinary)
|
||||||
size_t len;
|
size_t len;
|
||||||
static qboolean alreadymoved = false;
|
static qboolean alreadymoved = false;
|
||||||
|
|
||||||
|
//update blocked via commandline. to be doubly sure its checked.
|
||||||
|
if (COM_CheckParm("-noupdate") || COM_CheckParm("--noupdate") || COM_CheckParm("-noautoupdate") || COM_CheckParm("--noautoupdate"))
|
||||||
|
return false;
|
||||||
|
|
||||||
//windows is annoying. we can't delete a file that's in use (no orphaning)
|
//windows is annoying. we can't delete a file that's in use (no orphaning)
|
||||||
//we can normally rename it to something else before writing a new file with the original name.
|
//we can normally rename it to something else before writing a new file with the original name.
|
||||||
//then delete the old file later (sadly only on reboot)
|
//then delete the old file later (sadly only on reboot)
|
||||||
|
@ -3001,10 +3005,26 @@ qboolean Sys_SetUpdatedBinary(const char *newbinary)
|
||||||
}
|
}
|
||||||
qboolean Sys_EngineMayUpdate(void)
|
qboolean Sys_EngineMayUpdate(void)
|
||||||
{
|
{
|
||||||
|
wchar_t enginebinaryw[MAX_OSPATH];
|
||||||
if (!COM_CheckParm("-allowupdate"))
|
if (!COM_CheckParm("-allowupdate"))
|
||||||
{
|
{
|
||||||
|
char enginebinary[MAX_OSPATH*4];
|
||||||
|
char *s;
|
||||||
if (revision_number(true) <= 0)
|
if (revision_number(true) <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
GetModuleFileNameW(NULL, enginebinaryw, countof(enginebinaryw)-1);
|
||||||
|
narrowen(enginebinary, sizeof(enginebinary), enginebinaryw);
|
||||||
|
//if there's 3 consecutive digits or digit.digit then assume the user is doing their own versioning, and disallow engine updates (unless they use the -allowupdate arg).
|
||||||
|
//(that or they ran one of our older builds directly)
|
||||||
|
s = COM_SkipPath(enginebinary);
|
||||||
|
while (*s)
|
||||||
|
{
|
||||||
|
if ( s[0] >= '0' && s[0] <= '9')
|
||||||
|
if ((s[1] >= '0' && s[1] <= '9') || s[1] == '.' || s[1] == '_' || s[1] == '-')
|
||||||
|
if ( s[2] >= '0' && s[2] <= '9')
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//update blocked via commandline
|
//update blocked via commandline
|
||||||
|
|
|
@ -540,9 +540,9 @@ qboolean Sys_SetUpdatedBinary(const char *newbinary)
|
||||||
int i;
|
int i;
|
||||||
struct stat src, dst;
|
struct stat src, dst;
|
||||||
|
|
||||||
//windows is annoying. we can't delete a file that's in use (no orphaning)
|
//update blocked via commandline. just in case.
|
||||||
//we can normally rename it to something else before writing a new file with the original name.
|
if (COM_CheckParm("-noupdate") || COM_CheckParm("--noupdate") || COM_CheckParm("-noautoupdate") || COM_CheckParm("--noautoupdate"))
|
||||||
//then delete the old file later (sadly only on reboot)
|
return false;
|
||||||
|
|
||||||
//get the binary name
|
//get the binary name
|
||||||
i = readlink("/proc/self/exe", enginebinary, sizeof(enginebinary)-1);
|
i = readlink("/proc/self/exe", enginebinary, sizeof(enginebinary)-1);
|
||||||
|
@ -585,20 +585,34 @@ qboolean Sys_EngineMayUpdate(void)
|
||||||
char enginebinary[MAX_OSPATH];
|
char enginebinary[MAX_OSPATH];
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
//if we can't get a revision number from our cflags then don't allow updates (unless forced on).
|
|
||||||
if (!COM_CheckParm("-allowupdate"))
|
|
||||||
if (revision_number(true)<=0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//update blocked via commandline
|
//update blocked via commandline
|
||||||
if (COM_CheckParm("-noupdate") || COM_CheckParm("--noupdate") || COM_CheckParm("-noautoupdate") || COM_CheckParm("--noautoupdate"))
|
if (COM_CheckParm("-noupdate") || COM_CheckParm("--noupdate") || COM_CheckParm("-noautoupdate") || COM_CheckParm("--noautoupdate"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
//check that we can actually do it.
|
//check that we can actually do it.
|
||||||
len = readlink("/proc/self/exe", enginebinary, sizeof(enginebinary)-1);
|
len = readlink("/proc/self/exe", enginebinary, sizeof(enginebinary)-1);
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
//if we can't get a revision number from our cflags then don't allow updates (unless forced on).
|
||||||
|
if (!COM_CheckParm("-allowupdate"))
|
||||||
|
{
|
||||||
|
char *s;
|
||||||
|
if (revision_number(true)<=0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//if there's 3 consecutive digits or digit.digit then assume the user is doing their own versioning, and disallow engine updates (unless they use the -allowupdate arg).
|
||||||
|
//(that or they ran one of our older builds directly)
|
||||||
|
s = COM_SkipPath(enginebinary);
|
||||||
|
while (*s)
|
||||||
|
{
|
||||||
|
if ( s[0] >= '0' && s[0] <= '9')
|
||||||
|
if ((s[1] >= '0' && s[1] <= '9') || s[1] == '.' || s[1] == '_' || s[1] == '-')
|
||||||
|
if ( s[2] >= '0' && s[2] <= '9')
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enginebinary[len] = 0;
|
enginebinary[len] = 0;
|
||||||
if (access(enginebinary, R_OK|W_OK|X_OK) < 0)
|
if (access(enginebinary, R_OK|W_OK|X_OK) < 0)
|
||||||
return false; //can't write it. don't try downloading updates.
|
return false; //can't write it. don't try downloading updates.
|
||||||
|
|
Loading…
Reference in a new issue