]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
allow multiple playerstats URIs, separated by space
authorRudolf Polzer <divVerent@xonotic.org>
Thu, 6 Oct 2011 14:12:04 +0000 (16:12 +0200)
committerRudolf Polzer <divVerent@xonotic.org>
Thu, 6 Oct 2011 14:12:17 +0000 (16:12 +0200)
TODO: should this maybe rather be in urllib? not sure

qcsrc/server/playerstats.qc

index a2af63fe9ab74faa96232042640b8cb52b3ceb12..4a9dac388ed1b859c121fd879f1986d5a7e81f3b 100644 (file)
@@ -3,8 +3,8 @@ string teamstats_last;
 string playerstats_last;
 string events_last;
 .float playerstats_addedglobalinfo;
-float playerstats_requested;
 .string playerstats_id;
+float playerstats_sendtry;
 
 void PlayerStats_Init()
 {
@@ -198,6 +198,7 @@ void PlayerStats_ready(entity fh, entity pass, float status)
        string e, en;
        string nn, tt;
        string s;
+       float n;
 
        switch(status)
        {
@@ -256,6 +257,15 @@ void PlayerStats_ready(entity fh, entity pass, float status)
                case URL_READY_ERROR:
                default:
                        print("Player stats writing failed: ", ftos(status), "\n");
+                       ++playerstats_sendtry;
+                       n = tokenize_console(autocvar_g_playerstats_uri);
+                       if(playerstats_sendtry < n)
+                       {
+                               print("Trying next URL...\n");
+                               url_fopen(argv(playerstats_sendtry), FILE_APPEND, PlayerStats_ready, world);
+                               return;
+                       }
+                       print("Failed permanently.\n");
                        playerstats_waitforme = TRUE;
                        if(playerstats_db >= 0)
                        {
@@ -269,16 +279,17 @@ void PlayerStats_ready(entity fh, entity pass, float status)
 //#NO AUTOCVARS START
 void PlayerStats_Shutdown()
 {
-       string uri;
+       float n;
 
        if(playerstats_db < 0)
                return;
 
-       uri = autocvar_g_playerstats_uri;
-       if(uri != "")
+       playerstats_sendtry = 0;
+       n = tokenize_console(autocvar_g_playerstats_uri);
+       if(n > 0)
        {
                playerstats_waitforme = FALSE;
-               url_fopen(uri, FILE_APPEND, PlayerStats_ready, world);
+               url_fopen(argv(0), FILE_APPEND, PlayerStats_ready, world);
        }
        else
        {