]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Experiment with downloading the terms of service instead of using a local file
authorMario <mario.mario@y7mail.com>
Wed, 23 Dec 2020 09:35:48 +0000 (19:35 +1000)
committerMario <mario.mario@y7mail.com>
Wed, 23 Dec 2020 09:35:48 +0000 (19:35 +1000)
qcsrc/lib/urllib.qh
qcsrc/menu/xonotic/dialog_termsofservice.qc
qcsrc/menu/xonotic/util.qc
qcsrc/menu/xonotic/util.qh

index 8918ca0a2a695df6ade44e96df9837b271adc3a4..639b5db73e0615f6caa49b1cc494892faf38ab0f 100644 (file)
@@ -7,6 +7,7 @@ const int URI_GET_IPBAN_END = 16;
 const int URI_GET_CURL = 17;
 const int URI_GET_CURL_END = 32;
 const int URI_GET_UPDATENOTIFICATION = 33;
+const int URI_GET_TOS = 34;
 const int URI_GET_URLLIB = 128;
 const int URI_GET_URLLIB_END = 191;
 
index 85c82c451b7786af234112732135b2466952fa9e..b3f252f0c9a4e95f483b32f5a7d8a8c23454876d 100644 (file)
@@ -6,6 +6,7 @@
 #include "textbox.qh"
 #include "textlabel.qh"
 #include "button.qh"
+#include "util.qh"
 
 void Close_Clicked(entity btn, entity me)
 {
@@ -41,12 +42,13 @@ void XonoticToSDialog_loadXonoticToS(entity me)
         }
         fclose(fh);
     }
+    LOG_INFO("Test: ", _Nex_ExtResponseSystem_TOS, ": ", ftos(XonoticToSDialog_shouldShow()));
     me.textBox.setText(me.textBox, ToSText);
 }
 
 bool XonoticToSDialog_shouldShow()
 {
-    return (fexists("tos.txt") && !autocvar__termsofservice_accepted);
+    return (_Nex_ExtResponseSystem_TOS && !autocvar__termsofservice_accepted);
 }
 
 void XonoticToSDialog_fill(entity me)
index e77049d200153e9c2f15fb0ca097edd1c1649fe3..96007d4797aaa9a980750b9605748beef86e4fb2 100644 (file)
@@ -307,6 +307,10 @@ void URI_Get_Callback(float id, float status, string data)
        {
                UpdateNotification_URI_Get_Callback(id, status, data);
        }
+       else if (id == URI_GET_TOS)
+       {
+               TOS_URI_Get_Callback(id, status, data);
+       }
        else
        {
                LOG_INFOF("Received HTTP request data for an invalid id %d.", id);
@@ -457,6 +461,23 @@ void UpdateNotification_URI_Get_Callback(float id, float status, string data)
        }
 }
 
+void TOS_URI_Get_Callback(float id, float status, string data)
+{
+       if(_Nex_ExtResponseSystem_TOS)
+       {
+               LOG_TRACE("error: TOS_URI_Get_Callback has been called before");
+               return;
+       }
+       if(status != 0)
+       {
+               LOG_TRACEF("error receiving tos: status is %d", status);
+               return;
+       }
+
+       _Nex_ExtResponseSystem_TOS = strzone(data);
+       LOG_INFO("Data: ", _Nex_ExtResponseSystem_TOS);
+}
+
 // END OF URI SYSTEM ////////////////////////////////////////////////////////
 
 void updateCheck()
@@ -475,6 +496,15 @@ void updateCheck()
                uri_get(uri, URI_GET_UPDATENOTIFICATION);
        }
 
+       // Terms of Service updater, re-using the existing external response system!
+       if(_Nex_ExtResponseSystem_Queried == 1)
+       {
+               _Nex_ExtResponseSystem_Queried = 2;
+
+               string tosurl = "http://update.xonotic.org/tos.txt";
+               uri_get(tosurl, URI_GET_TOS);
+       }
+
        if(_Nex_ExtResponseSystem_PacksStep > 0)
        {
                float n, i;
index f5bd636d81f98c1b481b0919776ed2051d5fddaf..fd6fbaf5edd49b9341ff56286d33293bff29b0e0 100644 (file)
@@ -27,6 +27,8 @@ float updateCompression();
 
 void UpdateNotification_URI_Get_Callback(float id, float status, string data);
 
+void TOS_URI_Get_Callback(float id, float status, string data);
+
 // game type list box stuff (does not NEED to contain all game types, other
 // types stay available via console)
 entity GameType_GetID(int cnt);
@@ -47,5 +49,6 @@ string _Nex_ExtResponseSystem_PromotedServers;
 float _Nex_ExtResponseSystem_PromotedServersNeedsRefresh;
 string _Nex_ExtResponseSystem_RecommendedServers;
 float _Nex_ExtResponseSystem_RecommendedServersNeedsRefresh;
+string _Nex_ExtResponseSystem_TOS;
 
 void CheckSendCvars(entity me, string cvarnamestring);