AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   Bzip2 Compression on the fly ! (fastdownload/sv_downloadurl) (https://forums.alliedmods.net/showthread.php?t=102068)

berni 08-29-2009 20:03

Bzip2 Compression on the fly ! (fastdownload/sv_downloadurl)
 
1 Attachment(s)
http://www.ice-gfx.com/pics/sourcemod/bzip2onthefly.png



I always found it annoying, having to compress files everytime I upload a new map/texture/sound to my server manually. That's why I started thinking about if it would be possible to compress files on the fly while the client is downloading it.

And yes, it's possible :wink:

I've spent some hours writing a PHP script and filed it out allot.

Requirements:
  • Apache2 webserver running on the server machine where the gameserver is
  • Apache2 mod_rewrite
  • PHP 5
Features:
  • On the fly bzip2 compression of any files (you can specify the allowed file extensions in config.inc.php)
  • File caching (so already compressed files don't have to be compressed again)
  • Simultanous file sending to clients (clients don't have to wait for the first client to be finished)
  • Multiple server support
  • Specify allowed file extensions
Installation
  1. Simply unzip and upload the attached directory to your webserver directory.
  2. Edit config.inc.php to match your needs
  3. Set chmod of cache to 0770 (rwxrwx---)
  4. Change the sv_downloadurl of your gameserver(s):
Example: sv_downloadurl www.your-domain-or-ip.tld/bzip2_onthefly/configname

Put this line into your cfg/server.cfg file.

Enjoy :wink:

Note: Doesn't work for TF2 (and other orangebox games ?) atm.

Chris-_- 08-29-2009 20:12

Re: Bzip2 Compression on the fly !
 
Whoa!

busy.orange 08-30-2009 04:02

Re: Bzip2 Compression on the fly !
 
looks awesome :D

Dragonshadow 08-30-2009 08:50

Re: Bzip2 Compression on the fly !
 
Why does it have to be running on the same machine as the gameserver? Wouldn't that kind've negate the whole purpose of fastdl?

berni 08-30-2009 09:50

Re: Bzip2 Compression on the fly !
 
Quote:

Originally Posted by Dragonshadow (Post 917814)
Why does it have to be running on the same machine as the gameserver? Wouldn't that kind've negate the whole purpose of fastdl?

Show me how you want to zip a file without the source file ! difficult eh :wink:
What's the purpose of fastdownload for you ? Well a webserver can give you faster download rates than the gameserver.
Well, if you have your gameserver running on a 3 Mbit Box, I wouldn't recommend you to use this.
The webserver just needs access to the files of the gameserver over the local filesystem, but if both servers are in the same network and you can mount the server over the local network it should also work, never tried that tho.

berni 09-05-2009 11:35

Re: Bzip2 Compression on the fly !
 
Updated
  • Fixed wrong path description in the config file (Path has to include the gamedir)

busy.orange 09-12-2009 08:32

Re: Bzip2 Compression on the fly ! (fastdownload/sv_downloadurl)
 
1 Attachment(s)
I tested today on TF2 server.
TF2 client can't open bz2. (winrar opens normal)

define("BUFFER_SIZE", 4096);

Attach maps downloaded on my server

berni 09-12-2009 08:51

Re: Bzip2 Compression on the fly ! (fastdownload/sv_downloadurl)
 
I need more details how you configured your server, can I message you somewhere ?
TF2 should be able to open bz2 compressed maps like Hl2dm too.

berni 09-12-2009 11:12

Re: Bzip2 Compression on the fly ! (fastdownload/sv_downloadurl)
 
I'm not able to get this working for TF2 atm.
Orangebox seems to use a different bzip2 compression, unable to decompress the generated files.

Dragonshadow 09-12-2009 21:44

Re: Bzip2 Compression on the fly ! (fastdownload/sv_downloadurl)
 
I just compress everything into bzip with 7zip since I use a external webserver lol.

devicenull 09-20-2009 23:21

Re: Bzip2 Compression on the fly ! (fastdownload/sv_downloadurl)
 
Remove all the ending ?> tags, and I'm betting it will work.

berni 09-22-2009 12:55

Re: Bzip2 Compression on the fly ! (fastdownload/sv_downloadurl)
 
Quote:

Originally Posted by devicenull (Post 939243)
Remove all the ending ?> tags, and I'm betting it will work.

?

devicenull 09-23-2009 17:47

Re: Bzip2 Compression on the fly ! (fastdownload/sv_downloadurl)
 
Quote:

Originally Posted by berni (Post 940696)
?

In your PHP files. Remove the ending ?> php tag (which is optional). There are reasons behind this, but it's easier if you just do it :p

bl4nk 09-24-2009 00:48

Re: Bzip2 Compression on the fly ! (fastdownload/sv_downloadurl)
 
Isn't it because at the end of the tag whitespace is inserted and that causes problems with headers and such?

PoLoIvAn 03-17-2010 15:59

Re: Bzip2 Compression on the fly ! (fastdownload/sv_downloadurl)
 
I can't get this working..

Everytime I get a "Wrong Request". Could you please help me?

Thank you in advance.

DontWannaName 03-18-2010 00:24

Re: Bzip2 Compression on the fly ! (fastdownload/sv_downloadurl)
 
Why would you want to upload the full map to your website if you could just upload the bzip which is usually half the size :/ Some people have really bad upload speeds, even cable limits you to 300 or so kb/s.

berni 03-26-2010 08:16

Re: Bzip2 Compression on the fly ! (fastdownload/sv_downloadurl)
 
Quote:

Originally Posted by DontWannaName (Post 1121137)
Why would you want to upload the full map to your website if you could just upload the bzip which is usually half the size :/ Some people have really bad upload speeds, even cable limits you to 300 or so kb/s.

On my server I'm pointing my webserver to the gameserver files for specific directories, that means I don't have to upload any files twice.

I'm not supporting this bzip2 tool I made anymore, because I believe it's not working how it should. When compressing parts of a file on the fly, the HL2 client somehow doesn't like it.

NouveauJoueur 09-08-2010 19:53

Re: Bzip2 Compression on the fly ! (fastdownload/sv_downloadurl)
 
You don't need to upload it twice, just make a copy of it, bzip2, and make your webserver point at .bz2 files only, skipping .bsp files.

The best if I understood your case would be to create a folder compressedmaps/ where you'll copy and compress all maps you upload to your gameserver and then make your webserver point to this folder.

so http://www.mywebserversformaps.com/cstrike/maps/

would point to yourgameserver/compressedmaps/

You could even make a script that checks every 5 - 10 seconds if a new .bsp file has been uploaded/created in the maps directory to auto-copy it and then auto-bzip2 it in the compressedmaps folder, and set the good chmod wich would make it downloadable from http://www.mywebserversformaps.com/cstrike/maps/ in a few sec with only 1 upload.


All times are GMT -4. The time now is 18:20.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.