Skip to content

Commit

Permalink
Remote resources support.
Browse files Browse the repository at this point in the history
There is now a PRELOAD_RSC define in code/_compile_options.dm. Setting it to 0 will allow you to use on-the-fly rsc downloads, or the new remote rsc features.

Normally (PRELOAD_RSC == 1) the game will send you all the resources for the game that existed at compile time, this is the long-delay before joining the game...but it means that the game isn't sluggish later on due to trying to download icons and such. Which is good, but uses a lot of bandwidth.

On-the-fly behaviour (PRELOAD_RSC == 0) is when the game only downloads icons when you see something for the first time...this is often responsible for things being briefly invisible on slow connections.

Remote RSC behaviour (PRELOAD_RSC == 0 and some urls defined in config/external_rsc_urls.txt), is a mixture of the two above behaviours. It allows you to connect without downloading lots of resources immediately. However, once you connect it will select a url from a list of urls which hold zipped up copies of the tgstation.rsc. This allows the load of downloading those large files to be distributed across a few cheap web-servers or free upload sites...whilst the main game-server is freed up for other stuff. Should preloading from a remote url fail, behavior will revert to on-the-fly.
  • Loading branch information
carnie committed Jun 25, 2013
1 parent 08d2877 commit 26957f5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions code/_compile_options.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
//By using the testing("message") proc you can create debug-feedback for people with this
//uncommented, but not visible in the release version)

#define PRELOAD_RSC 1 /*set to:
0 to allow using external resources or on-demand behaviour;
1 to use the default behaviour;
2 for preloading absolutely everything;
*/


//SYSTEM TOGGLES - these allow you to compile the game without some of the laggier systems if your server cannot cope with demand
Expand Down
2 changes: 2 additions & 0 deletions code/modules/client/client defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@
var/player_age = "Requires database" //So admins know why it isn't working - Used to determine how old the account is - in days.
var/related_accounts_ip = "Requires database" //So admins know why it isn't working - Used to determine what other accounts previously logged in from this ip
var/related_accounts_cid = "Requires database" //So admins know why it isn't working - Used to determine what other accounts previously logged in from this computer id

preload_rsc = PRELOAD_RSC
11 changes: 11 additions & 0 deletions code/modules/client/client procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
///////////
//CONNECT//
///////////
#if (PRELOAD_RSC == 0)
var/list/external_rsc_urls
var/next_external_rsc = 0
#endif

/client/New(TopicData)
TopicData = null //Prevent calls to client.Topic from connect

Expand All @@ -89,6 +94,12 @@

unlock_content = IsByondMember()

#if (PRELOAD_RSC == 0)
if(external_rsc_urls && external_rsc_urls.len)
next_external_rsc = Wrap(next_external_rsc+1, 1, external_rsc_urls.len+1)
preload_rsc = external_rsc_urls[next_external_rsc]
#endif

clients += src
directory[ckey] = src

Expand Down
9 changes: 9 additions & 0 deletions code/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
#define RECOMMENDED_VERSION 495

/world/New()
#if (PRELOAD_RSC == 0)
external_rsc_urls = file2list("config/external_rsc_urls.txt","\n")
var/i=1
while(i<=external_rsc_urls.len)
if(external_rsc_urls[i])
i++
else
external_rsc_urls.Cut(i,i+1)
#endif
//logs
var/date_string = time2text(world.realtime, "YYYY/MM-Month/DD-Day")
// if(revdata && istext(revdata.revision) && length(revdata.revision)>7)
Expand Down
Empty file added config/external_rsc_urls.txt
Empty file.

0 comments on commit 26957f5

Please sign in to comment.