]> git.xonotic.org Git - xonotic/xonotic.git/blob - Docs/mapdownload.txt
make the algorithm a bit more customizable
[xonotic/xonotic.git] / Docs / mapdownload.txt
1 map download:
2 ______________
3
4
5 CLIENT SIDE:
6
7 Should already work without configuration. You can however use the following
8 cvars for further tuning:
9
10    cl_curl_enabled              download support enabled (master switch, default: 1)
11    cl_curl_maxdownloads         maximum number of downloads at once (default: 1)
12    cl_curl_maxspeed             maximum total speed in KiB/s (default: 100)
13
14 Downloaded packages end up in |Nexuiz/data/dlcache/| or
15 |~/.nexuiz/data/dlcache/| and are only used till you exit Nexuiz.
16  If you want to play them localy or use them to setup a server of your
17 own you can "accept" the packages by moving it one level up - right
18 next to your config.cfg.
19
20 You should regularily clean up your cache to save space and make the maps
21 you really want available from the menu.
22
23
24 SERVER SIDE:
25
26 First of all, you need a HTTP or FTP server to host your PK3s. You can either
27 use some web space provider, or set up your own. For this, use any FTP or HTTP
28 server software you want (HTTP: lighttpd, Apache, thttpd; FTP: Filezilla,
29 vsftpd). HTTP is to be preferred because it works better for firewalled
30 players.
31
32 On the server, you need to set up where to download the PK3s of the maps you
33 are running. You can either use the cvar
34
35    sv_curl_defaulturl           default download URL
36
37 to set it to some site, or put a file named "curl_urls.txt" in the data
38 directory of the following format:
39
40    pattern        url
41    pattern        url
42    pattern        url
43    ...
44
45 where always the first wildcard pattern match is taken.
46
47    data*          -
48    strale*        http://stralemaps.invalid/
49    *              http://all.the.other.stuff.invalid/id/here.php?pak=
50    foo*           http://wont.get.here.invalid/
51
52 The pk3 name will be appended to the URL by DarkPlaces. Note that you NEED to
53 append a trailing slash if you refer to a directory. If you specify a "-" as
54 URL, the package will not be offered for download.
55
56
57 INFORMATION FOR MIRROR/MAP SERVER ADMINS:
58
59 The Referer is always set to dp://serverhost:serverport/, the User-Agent
60 always starts with "Nexuiz". Look at this sample log line:
61
62 141.2.16.3 - - [06/Jun/2006:19:43:14 +0000] "GET /~polzer/temp/nexmaps.php?filename=o-fun.pk3 HTTP/1.1" 302 - "dp://141.2.16.3:26000/" "Nexuiz Linux 21:26:17 Jun  6 2006"
63
64
65 If you want to set up a redirection service, here is a sample PHP code for you
66 to start from:
67
68 <?
69
70 function findmap($filename)
71 {
72     # insert your database query or whatever you want here
73     if($filename == "foo.pk3")
74         return "http://barserver.invalid/foo.pk3";
75     return FALSE;
76 }
77
78 function bailout($code, $title, $message)
79 {
80     header("HTTP/1.1 $code $title");
81     echo "<html><title>$title</title><h1>$title</h1>$message</html>";
82     exit(0);
83 }   
84
85 $filename = $_GET['filename'];
86
87 $useragent = getenv("HTTP_USER_AGENT");
88 if(strpos($useragent, "Nexuiz ") !== 0)
89     bailout(403, "Forbidden", "You're not a Nexuiz client.");
90     
91 $url = findmap($filename);
92 if(!$url)
93     bailout(404, "Not Found", "Well... try another file name?");
94     
95 header("HTTP/1.1 302 Moved Temporarily");
96 header("Location: $url");
97
98 ?>