Skip to content

Commit 578d12f

Browse files
author
Spoike
committed
Fix some updater issues.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6168 fc73d0e0-1445-4013-8a0c-d673dee63da5
1 parent 2ed9c6a commit 578d12f

File tree

8 files changed

+187
-17
lines changed

8 files changed

+187
-17
lines changed

engine/client/m_download.c

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ static struct pm_source_s
241241
#define SRCFL_ENABLED (1u<<6) //source was explicitly enabled.
242242
#define SRCFL_PROMPTED (1u<<7) //source was explicitly enabled.
243243
#define SRCFL_ONCE (1u<<8) //autoupdates are disabled, but the user is viewing packages anyway. enabled via a prompt.
244+
#define SRCFL_UNSAFE (1u<<9) //ignore signing requirements.
244245
unsigned int flags;
245246
struct dl_download *curdl; //the download context
246247

@@ -532,6 +533,10 @@ static void PM_ValidatePackage(package_t *p)
532533
if (!(p->flags & (DPF_NATIVE|DPF_CACHED)))
533534
Con_Printf("WARNING: %s (%s) no longer exists\n", p->name, n);
534535
}
536+
537+
//if no files were present, unmark it.
538+
if (!(p->flags & (DPF_NATIVE|DPF_CACHED)))
539+
p->flags &= ~DPF_ENABLED;
535540
}
536541
else
537542
{
@@ -981,6 +986,7 @@ static void PM_AddSubListModule(void *module, plugupdatesourcefuncs_t *funcs, co
981986
Z_Free(pm_source[i].prefix);
982987
pm_source[i].prefix = Z_StrDup(prefix);
983988
}
989+
pm_source[i].flags |= flags & SRCFL_UNSAFE;
984990
break;
985991
}
986992
}
@@ -1395,7 +1401,7 @@ static qboolean PM_ParsePackageList(const char *f, unsigned int parseflags, cons
13951401
if (!f)
13961402
return forcewrite;
13971403

1398-
source.validated = (parseflags & DPF_ENABLED)?VH_CORRECT/*FIXME*/:VH_UNSUPPORTED;
1404+
source.validated = (parseflags & (DPF_ENABLED|DPF_SIGNATUREACCEPTED))?VH_CORRECT/*FIXME*/:VH_UNSUPPORTED;
13991405
Q_strncpyz(source.gamedir, FS_GetGamedir(false), sizeof(source.gamedir));
14001406

14011407
if (url)
@@ -2004,6 +2010,7 @@ static void PM_PreparePackageList(void)
20042010
//figure out what we've previously installed.
20052011
if (fs_manifest && !loadedinstalled)
20062012
{
2013+
int parm;
20072014
qofs_t sz = 0;
20082015
char *f = FS_MallocFile(INSTALLEDFILES, FS_ROOT, &sz);
20092016
loadedinstalled = true;
@@ -2013,16 +2020,28 @@ static void PM_PreparePackageList(void)
20132020
PM_WriteInstalledPackages();
20142021
BZ_Free(f);
20152022
}
2016-
//make sure our sources are okay.
2017-
if (fs_manifest && fs_manifest->downloadsurl && *fs_manifest->downloadsurl)
2023+
2024+
parm = COM_CheckParm ("-updatesrc");
2025+
if (parm)
2026+
{
2027+
unsigned int fl = SRCFL_USER;
2028+
if (COM_CheckParm ("-unsafe"))
2029+
fl |= SRCFL_UNSAFE;
2030+
do
2031+
{
2032+
PM_AddSubList(com_argv[parm+1], NULL, fl); //enable it by default. functionality is kinda broken otherwise.
2033+
parm = COM_CheckNextParm ("-updatesrc", parm);
2034+
} while (parm && parm < com_argc-1);
2035+
}
2036+
else if (fs_manifest && fs_manifest->downloadsurl && *fs_manifest->downloadsurl)
20182037
{
20192038
unsigned int fl = SRCFL_MANIFEST;
20202039
char *s = fs_manifest->downloadsurl;
20212040
if (fs_manifest->security==MANIFEST_SECURITY_NOT)
20222041
fl |= SRCFL_DISABLED; //don't trust it, don't even prompt.
20232042

20242043
while ((s = COM_Parse(s)))
2025-
PM_AddSubList(com_token, NULL, SRCFL_MANIFEST); //enable it by default. functionality is kinda broken otherwise.
2044+
PM_AddSubList(com_token, NULL, fl); //enable it by default. functionality is kinda broken otherwise.
20262045
}
20272046

20282047
#ifdef PLUGINS
@@ -2160,7 +2179,7 @@ static package_t *PM_FindExactPackage(const char *packagename, const char *arch,
21602179
if (*version == '<' && strcmp(p->version, version+1)>=0)
21612180
continue;
21622181
}
2163-
if (!r || strcmp(r->version, p->version)>0)
2182+
if (!r || strcmp(p->version, r->version)>0)
21642183
r = p;
21652184
}
21662185
}
@@ -2662,7 +2681,10 @@ static void PM_ListDownloaded(struct dl_download *dl)
26622681
if (f)
26632682
{
26642683
pm_source[listidx].status = SRCSTAT_OBTAINED;
2665-
PM_ParsePackageList(f, 0, dl->url, pm_source[listidx].prefix);
2684+
if (pm_source[listidx].flags & SRCFL_UNSAFE)
2685+
PM_ParsePackageList(f, DPF_SIGNATUREACCEPTED, dl->url, pm_source[listidx].prefix);
2686+
else
2687+
PM_ParsePackageList(f, 0, dl->url, pm_source[listidx].prefix);
26662688
PM_ResortPackages();
26672689
}
26682690
else if (dl->replycode == HTTP_DNSFAILURE)
@@ -3669,7 +3691,7 @@ static void QDECL HashFile_Flush (struct vfsfile_s *file)
36693691
}
36703692
static qboolean QDECL HashFile_Close (struct vfsfile_s *file)
36713693
{
3672-
qbyte digest[256];
3694+
qbyte digest[DIGEST_MAXSIZE];
36733695
hashfile_t *f = (hashfile_t*)file;
36743696
if (!VFS_CLOSE(f->f))
36753697
f->fail = true; //something went wrong.
@@ -3685,14 +3707,23 @@ static qboolean QDECL HashFile_Close (struct vfsfile_s *file)
36853707
}
36863708
else if (memcmp(digest, f->need, f->hashfunc->digestsize))
36873709
{
3688-
qbyte base64[512];
3710+
qbyte base64[(DIGEST_MAXSIZE*2)+16];
36893711
Con_Printf("Invalid hash for downloaded file %s, try again later?\n", f->fname);
36903712

3691-
Base64_EncodeBlock(digest, f->hashfunc->digestsize, base64, sizeof(base64)-1);
3692-
base64[sizeof(base64)-1] = 0;
3693-
Con_Printf("%s vs", base64);
3694-
Base64_EncodeBlock(f->need, f->hashfunc->digestsize, base64, sizeof(base64)-1);
3695-
Con_Printf("%s\n", base64);
3713+
if (f->hashfunc == &hash_sha1)
3714+
{
3715+
base64[Base16_EncodeBlock(digest, f->hashfunc->digestsize, base64, sizeof(base64)-1)] = 0;
3716+
Con_Printf("%s vs ", base64);
3717+
base64[Base16_EncodeBlock(f->need, f->hashfunc->digestsize, base64, sizeof(base64)-1)] = 0;
3718+
Con_Printf("%s\n", base64);
3719+
}
3720+
else
3721+
{
3722+
base64[Base64_EncodeBlock(digest, f->hashfunc->digestsize, base64, sizeof(base64)-1)] = 0;
3723+
Con_Printf("%s vs ", base64);
3724+
base64[Base64_EncodeBlock(f->need, f->hashfunc->digestsize, base64, sizeof(base64)-1)] = 0;
3725+
Con_Printf("%s\n", base64);
3726+
}
36963727
f->fail = true;
36973728
}
36983729

engine/common/fs.c

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,93 @@ static void COM_Locate_f (void)
11991199
Con_Printf("Not found\n");
12001200
}
12011201

1202+
static void COM_CalcHash_Thread(void *ctx, void *fname, size_t a, size_t b)
1203+
{
1204+
int h;
1205+
struct
1206+
{
1207+
const char *name;
1208+
hashfunc_t *hash;
1209+
void *ctx;
1210+
} hashes[] =
1211+
{
1212+
// {"crc16", &hash_crc16},
1213+
{"sha1", &hash_sha1},
1214+
#if defined(HAVE_SERVER) || defined(HAVE_CLIENT)
1215+
// {"sha224", &hash_sha224},
1216+
{"sha256", &hash_sha256},
1217+
// {"sha384", &hash_sha384},
1218+
// {"sha512", &hash_sha512},
1219+
#endif
1220+
};
1221+
qbyte digest[DIGEST_MAXSIZE];
1222+
qbyte digesttext[DIGEST_MAXSIZE*2+1];
1223+
qbyte block[65536];
1224+
int csize;
1225+
quint64_t fsize = 0;
1226+
quint64_t tsize = 0;
1227+
unsigned int pct, opct=~0;
1228+
vfsfile_t *f = FS_OpenVFS(fname, "rb", FS_GAME);
1229+
1230+
if (f)
1231+
{
1232+
tsize = VFS_GETLEN(f);
1233+
Con_Printf("%s: Processing...\r", (char*)fname);
1234+
1235+
for (h = 0; h < countof(hashes); h++)
1236+
{
1237+
hashes[h].ctx = Z_Malloc(hashes[h].hash->contextsize);
1238+
hashes[h].hash->init(hashes[h].ctx);
1239+
}
1240+
1241+
for(;;)
1242+
{
1243+
csize = VFS_READ(f, block, sizeof(block));
1244+
if (csize <= 0)
1245+
break;
1246+
fsize += csize;
1247+
for (h = 0; h < countof(hashes); h++)
1248+
{
1249+
hashes[h].hash->process(hashes[h].ctx, block, csize);
1250+
}
1251+
pct = (100*fsize)/tsize;
1252+
if (pct != opct)
1253+
{
1254+
Con_Printf("%s: %i%%...\r", (char*)fname, pct);
1255+
opct = pct;
1256+
}
1257+
}
1258+
1259+
VFS_CLOSE(f);
1260+
1261+
Con_Printf("%s: ", (char*)fname);
1262+
if (fsize > 1024*1024*1024*(quint64_t)16)
1263+
Con_Printf("%g GB\n", fsize/(1024.0*1024*1024));
1264+
else if (fsize > 1024*1024*16)
1265+
Con_Printf("%g MB\n", fsize/(1024.0*1024));
1266+
else if (fsize > 1024*16)
1267+
Con_Printf("%g KB\n", fsize/(1024.0));
1268+
else
1269+
Con_Printf("%u bytes\n", (unsigned)fsize);
1270+
for (h = 0; h < countof(hashes); h++)
1271+
{
1272+
hashes[h].hash->terminate(digest, hashes[h].ctx);
1273+
Z_Free(hashes[h].ctx);
1274+
1275+
digesttext[Base16_EncodeBlock(digest, hashes[h].hash->digestsize, digesttext, sizeof(digesttext)-1)] = 0;
1276+
Con_Printf(" %s: %s\n", hashes[h].name, digesttext);
1277+
}
1278+
}
1279+
Z_Free(fname);
1280+
}
1281+
static void COM_CalcHash_f(void)
1282+
{
1283+
if (Cmd_Argc() != 2)
1284+
Con_Printf("%s <FILENAME>: computes various hashes of the specified file\n", Cmd_Argv(0));
1285+
else
1286+
COM_AddWork(WG_LOADER, COM_CalcHash_Thread, NULL, Z_StrDup(Cmd_Argv(1)), 0, 0);
1287+
}
1288+
12021289
/*
12031290
============
12041291
COM_WriteFile
@@ -7269,6 +7356,8 @@ void COM_InitFilesystem (void)
72697356
Cmd_AddCommandAD("flocate", COM_Locate_f, FS_ArbitraryFile_c, "Searches for a named file, and displays where it can be found in the OS's filesystem"); //prints the pak or whatever where this file can be found.
72707357
Cmd_AddCommandAD("which", COM_Locate_f, FS_ArbitraryFile_c, "Searches for a named file, and displays where it can be found in the OS's filesystem"); //prints the pak or whatever where this file can be found.
72717358

7359+
Cmd_AddCommandAD("fs_hash", COM_CalcHash_f, FS_ArbitraryFile_c, "Computes a hash of the specified file.");
7360+
72727361

72737362
//
72747363
// -basedir <path>

engine/common/net_ssl_gnutls.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ static int (VARGS *qgnutls_credentials_set)(gnutls_session_t, gnutls_credentials
154154
static int (VARGS *qgnutls_init)(gnutls_session_t * session, gnutls_connection_end_t con_end);
155155
static void (VARGS *qgnutls_deinit)(gnutls_session_t session);
156156
static int (VARGS *qgnutls_set_default_priority)(gnutls_session_t session);
157+
#ifdef HAVE_DTLS
157158
static int (VARGS *qgnutls_set_default_priority_append)(gnutls_session_t session, const char *add_prio, const char **err_pos, unsigned flags);
159+
#endif
158160

159161
static int (VARGS *qgnutls_certificate_allocate_credentials)(gnutls_certificate_credentials_t *sc);
160162
static int (VARGS *qgnutls_anon_allocate_client_credentials)(gnutls_anon_client_credentials_t *sc);
@@ -232,6 +234,13 @@ static int (VARGS *qgnutls_certificate_set_x509_key_mem)(gnutls_certificate_cre
232234
static int (VARGS *qgnutls_certificate_get_x509_key)(gnutls_certificate_credentials_t res, unsigned index, gnutls_x509_privkey_t *key);
233235
static void (VARGS *qgnutls_certificate_free_credentials)(gnutls_certificate_credentials_t sc);
234236

237+
#ifdef GNUTLS_DYNAMIC
238+
static int VARGS fallback_gnutls_set_default_priority_append(gnutls_session_t session, const char *add_prio, const char **err_pos, unsigned flags)
239+
{
240+
return qgnutls_set_default_priority(session);
241+
}
242+
#endif
243+
235244
static qboolean Init_GNUTLS(void)
236245
{
237246
#ifdef GNUTLS_HAVE_SYSTEMTRUST
@@ -351,7 +360,6 @@ static qboolean Init_GNUTLS(void)
351360
{(void**)&qgnutls_init, "gnutls_init"},
352361
{(void**)&qgnutls_deinit, "gnutls_deinit"},
353362
{(void**)&qgnutls_set_default_priority, "gnutls_set_default_priority"},
354-
{(void**)&qgnutls_set_default_priority_append, "gnutls_set_default_priority_append"},
355363
{(void**)&qgnutls_certificate_allocate_credentials, "gnutls_certificate_allocate_credentials"},
356364
{(void**)&qgnutls_anon_allocate_client_credentials, "gnutls_anon_allocate_client_credentials"},
357365
{(void**)&qgnutls_global_init, "gnutls_global_init"},
@@ -441,6 +449,10 @@ static qboolean Init_GNUTLS(void)
441449
#endif
442450
if (!hmod)
443451
return false;
452+
453+
qgnutls_set_default_priority_append = Sys_GetAddressForName(hmod, "gnutls_set_default_priority_append");
454+
if (!qgnutls_set_default_priority_append)
455+
qgnutls_set_default_priority_append = fallback_gnutls_set_default_priority_append;
444456
#else
445457
#define GNUTLS_FUNC(name) q##name = name;
446458
#define GNUTLS_FUNCPTR(name) q##name = &name;

engine/common/sha1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This file came to FTE via EzQuake.
2323
typedef struct
2424
{
2525
unsigned int state[5];
26-
size_t count[2];
26+
unsigned int count[2];
2727
unsigned char buffer[64];
2828
} SHA1_CTX;
2929
#define SHA1_DIGEST_SIZE 20

engine/gl/gl_model.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5713,7 +5713,7 @@ void Mod_LoadSpriteFrameShader(model_t *spr, int frame, int subframe, mspritefra
57135713
{
57145714
int i;
57155715
/*
5716-
A quick note on tenebrae and sprites: In tenebrae, sprites are always lit, unless the light_lev field is set (which makes it fullbright).
5716+
A quick note on tenebrae and sprites: In tenebrae, sprites are always additive, unless the light_lev field is set (which makes it fullbright).
57175717
While its generally preferable and more consistent to assume lit sprites, this is incompatible with vanilla quake and thus unacceptable to us, but you can set the mod_assumelitsprites cvar if you want it.
57185718
So for better compatibility, we have a whitelist of 'well-known' sprites that tenebrae uses in this way, which we do lighting on.
57195719
You should still be able to use EF_FULLBRIGHT on these, but light_lev is an imprecise setting and will result in issues. Just be specific about fullbright or additive.

engine/server/pr_cmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11924,7 +11924,7 @@ static BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs
1192411924
{"addwantedhostcachekey",PF_Fixme, 0, 0, 0, 623, "void(string key)"},
1192511925
{"getextresponse", PF_Fixme, 0, 0, 0, 624, "string()"},
1192611926
{"netaddress_resolve",PF_netaddress_resolve,0, 0, 0, 625, "string(string dnsname, optional float defport)"},
11927-
{"getgamedirinfo", PF_Fixme, 0, 0, 0, 626, "string(float n, float prop)"},
11927+
{"getgamedirinfo", PF_Fixme, 0, 0, 0, 626, D("string(float n, float prop)", "Queries properties about an indexed gamedir (or -1 for the current gamedir). Returns null strings when out of bounds. Use the GDDI_* constants for the prop arg.")},
1192811928
{"getpackagemanagerinfo",PF_Fixme, 0, 0, 0, 0, D("string(int n, int prop)", "Queries information about a package from the engine's package manager subsystem. Actions can be taken via the pkg console command.")},
1192911929
{"sprintf", PF_sprintf, 0, 0, 0, 627, D("string(string fmt, ...)", "'prints' to a formatted temp-string. Mostly acts as in C, however %d assumes floats (fteqcc has arg checking. Use it.).\ntype conversions: l=arg is an int, h=arg is a float, and will work as a prefix for any float or int representation.\nfloat representations: d=decimal, e,E=exponent-notation, f,F=floating-point notation, g,G=terse float, c=char code, x,X=hex\nother representations: i=int, s=string, S=quoted and marked-up string, v=vector, p=pointer\nso %ld will accept an int arg, while %hi will expect a float arg.\nentities, fields, and functions will generally need to be printed as ints with %i.")},
1193011930
{"getsurfacenumtriangles",PF_getsurfacenumtriangles,0,0,0, 628, "float(entity e, float s)"},

fte.m4

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ define(`WINPLUG',`category "Plugins"
9595
FILE(fteplug_$1_x64.REVISION.dll)
9696
URL(win64/fteplug_$1_x64.dll)
9797
}')dnl
98+
define(`WIN64PLUG',`category "Plugins"
99+
ver "REVISION"
100+
gamedir ""
101+
license "GPLv2"
102+
{
103+
arch "win_x64"
104+
FILE(fteplug_$1_x64.REVISION.dll)
105+
URL(win64/fteplug_$1_x64.dll)
106+
}')dnl
98107
define(`LINPLUG',`{
99108
arch "linux_amd64"
100109
FILE(fteplug_$1_amd64.REVISION,.so)
@@ -132,6 +141,7 @@ TEST()dnl
132141
title "IRC Plugin"
133142
replace "IRC Plugin"
134143
desc "Allows you to converse on IRC servers in-game."
144+
desc "Requires manual configuration."
135145
TEST()dnl
136146
}
137147
{
@@ -140,6 +150,28 @@ TEST()dnl
140150
LINPLUG(xmpp)
141151
title "XMPP Plugin"
142152
desc "Allows you to converse on XMPP servers. This also includes a method for NAT holepunching between contacts."
153+
desc "Requires manual configuration."
154+
TEST()dnl
155+
}
156+
{
157+
package "fteplug_openssl"
158+
WINPLUG(openssl)
159+
license "GPLv3" //Apache2+GPLv2=GPLv3
160+
title "OpenSSL Plugin"
161+
author "Spike"
162+
desc "Provides TLS and DTLS support, instead of using Microsoft's probably-outdated libraries."
163+
desc "Required for fully functional DTLS support on windows."
164+
desc "Connecting to QEx servers requires additional setup."
165+
TEST()dnl
166+
}
167+
{
168+
package "fteplug_hl2"
169+
WINPLUG(hl2)
170+
LINPLUG(hl2)
171+
title "HalfLife2 Formats Plugin"
172+
desc "Provides support for HalfLife2 bsp and texture formats."
173+
desc "Some related games may work, but this is not guarenteed."
174+
desc "Requires mod support for full functionality."
143175
TEST()dnl
144176
}
145177
HIDE(`

plugins/qi/qi.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,12 @@ static void QDECL QI_Tick(double realtime, double gametime)
889889
if (dlcontext == -1)
890890
{
891891
QI_RefreshMapList(false);
892+
893+
if (packagemanager)
894+
{
895+
VFS_CLOSE(packagemanager);
896+
packagemanager = NULL;
897+
}
892898
return;
893899
}
894900
archive = false;

0 commit comments

Comments
 (0)