partial autodownload rewrite

* own source file for autodownload
* use cleaned up zip functions
* use new http get function (no more curl)
* enforce strict file naming rules and file size limits
* ping all package servers on every game start to determine ping times
* support media file update lists (also kept on package servers)
* allow users to manually prioritise package servers
* automatically select server with newest media file revision

new or changed commands:

addpckserver hostname [priority]
  Adds a host name to the list of package servers. If a priority is given,
  it influences the sorting of servers. Servers with higher priority are
  queried first. If servers have the same priority, they are sorted by
  ping. Default priority is zero.

getpackageserver
  Returns a table with four columns of all configured package servers. The
  columns are: host name, priority, ping and resolved.
  "resolved" is a flag, indicating, if the server answered the ping during
  game start.

removed cubescript idents: sortpckservers gamestarts
DOCREF addpckserver getpckserver
This commit is contained in:
ac-stef
2015-09-07 14:53:56 +02:00
parent c8313a946e
commit 7988443b1d
16 changed files with 616 additions and 585 deletions
+26 -4
View File
@@ -643,7 +643,29 @@ int sl_waitthread(void *ti)
}
#endif
void parseupdatelist(hashtable<const char *, int> &ht, char *buf, const char *prefix, const char *suffix)
{
for(char *d = buf; *d; d++) if(!isalnum(*d) && !strchr("._-() /\n", *d)) *d = ' '; // allowed chars in media path strings (except ' ')
char *p, *l = buf, *m;
int rev, *revp, plen = prefix ? (int)strlen(prefix) : 0, slen = suffix ? (int)strlen(suffix) : 0;
do
{
if((p = strchr(l, '\n'))) *p = '\0'; // break into single lines
l += strspn(l, " "); // skip leading spaces
if((m = strchr(l, ' ')) && (rev = atoi(m + 1))) // string has a space and a number != 0 after it
{
*m = '\0';
if((!plen || !strncmp(l, prefix, plen)) && // prefix is either not required or present
(!slen || (m - l > slen && !strcmp(m - slen, suffix)))) // suffix is either not required or present
{
l += plen; // skip prefix
m[-slen] = '\0'; // cut suffix
revp = ht.access(l);
if(revp) *revp = rev;
else ht.access(newstring(l), rev);
}
}
l = p + 1;
}
while(p);
}