MCPcopy Create free account
hub / github.com/demoth/jake2 / SV_BeginDownload_f

Method SV_BeginDownload_f

server/src/main/java/jake2/server/SV_USER.java:272–336  ·  view source on GitHub ↗
(List<String> args, GameImportsImpl gameImports, client_t client)

Source from the content-addressed store, hash-verified

270 * ================== SV_BeginDownload_f ==================
271 */
272 private static void SV_BeginDownload_f(List<String> args, GameImportsImpl gameImports, client_t client) {
273 int offset = 0;
274
275 if (args.size() < 2)
276 return;
277
278 String name = args.get(1);
279
280 if (args.size() > 2)
281 offset = Lib.atoi(args.get(2)); // downloaded offset
282
283 // hacked by zoid to allow more conrol over download
284 // first off, no .. or global allow check
285
286 if (name.contains("..")
287 || SV_MAIN.allow_download.value == 0 // leading dot is no good
288 || name.charAt(0) == '.' // leading slash bad as well, must be
289 // in subdir
290 || name.charAt(0) == '/' // next up, skin check
291 || (name.startsWith("players/") && 0 == SV_MAIN.allow_download_players.value) // now
292 // models
293 || (name.startsWith("models/") && 0 == SV_MAIN.allow_download_models.value) // now
294 // sounds
295 || (name.startsWith("sound/") && 0 == SV_MAIN.allow_download_sounds.value)
296 // now maps (note special case for maps, must not be in pak)
297 || (name.startsWith("maps/") && 0 == SV_MAIN.allow_download_maps.value) // MUST
298 // be
299 // in a
300 // subdirectory
301 || name.indexOf('/') == -1) { // don't allow anything with ..
302 // path
303
304 // refuse
305 client.netchan.reliablePending.add(new DownloadMessage());
306 return;
307 }
308
309 client.download = FS.LoadFile(name);
310
311 // rst: this handles loading errors, no message yet visible
312 if (client.download == null) {
313 return;
314 }
315
316 client.downloadsize = client.download.length;
317 client.downloadcount = offset;
318
319 if (offset > client.downloadsize)
320 client.downloadcount = client.downloadsize;
321
322 // special check for maps, if it came from a pak file, don't allow download ZOID
323 if (name.startsWith("maps/") && FS.FOpenFile(name).fromPack) {
324 Com.DPrintf("Couldn't download " + name + " to " + client.name + "\n");
325 if (client.download != null) {
326 client.download = null;
327 }
328
329 // refuse

Callers

nothing calls this directly

Calls 8

atoiMethod · 0.95
LoadFileMethod · 0.95
FOpenFileMethod · 0.95
DPrintfMethod · 0.95
SV_NextDownload_fMethod · 0.95
sizeMethod · 0.80
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected