From 26957f5357490ddd70ad56b0a6db13beb27d6103 Mon Sep 17 00:00:00 2001 From: carnie Date: Tue, 25 Jun 2013 07:44:57 +0100 Subject: [PATCH] Remote resources support. 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. --- code/_compile_options.dm | 5 +++++ code/modules/client/client defines.dm | 2 ++ code/modules/client/client procs.dm | 11 +++++++++++ code/world.dm | 9 +++++++++ config/external_rsc_urls.txt | 0 5 files changed, 27 insertions(+) create mode 100644 config/external_rsc_urls.txt diff --git a/code/_compile_options.dm b/code/_compile_options.dm index adebd47b98c..6b6ce01d996 100644 --- a/code/_compile_options.dm +++ b/code/_compile_options.dm @@ -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 diff --git a/code/modules/client/client defines.dm b/code/modules/client/client defines.dm index b88ee8fadd3..803a255248a 100644 --- a/code/modules/client/client defines.dm +++ b/code/modules/client/client defines.dm @@ -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 diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index 3056a000378..cd82301784a 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -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 @@ -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 diff --git a/code/world.dm b/code/world.dm index c7fa563a996..02cdc3315cb 100644 --- a/code/world.dm +++ b/code/world.dm @@ -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) diff --git a/config/external_rsc_urls.txt b/config/external_rsc_urls.txt new file mode 100644 index 00000000000..e69de29bb2d