]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
First ToS versioning attempt
authorz411 <z411@omaera.org>
Wed, 24 Nov 2021 04:41:39 +0000 (01:41 -0300)
committerz411 <z411@omaera.org>
Wed, 24 Nov 2021 04:41:39 +0000 (01:41 -0300)
qcsrc/menu/xonotic/.util.qc.kate-swp [new file with mode: 0644]
qcsrc/menu/xonotic/dialog_termsofservice.qc
qcsrc/menu/xonotic/dialog_termsofservice.qh
qcsrc/menu/xonotic/mainwindow.qc
qcsrc/menu/xonotic/util.qc
qcsrc/menu/xonotic/util.qh

diff --git a/qcsrc/menu/xonotic/.util.qc.kate-swp b/qcsrc/menu/xonotic/.util.qc.kate-swp
new file mode 100644 (file)
index 0000000..4f3893a
Binary files /dev/null and b/qcsrc/menu/xonotic/.util.qc.kate-swp differ
index b3f252f0c9a4e95f483b32f5a7d8a8c23454876d..c0c26c9fd62d523714cf4e6a0bdc4ab9a13c647e 100644 (file)
@@ -26,7 +26,7 @@ void DontAccept_Clicked(entity btn, entity me)
 
 void XonoticToSDialog_loadXonoticToS(entity me)
 {
-    string ToSText = "";
+    /*string ToSText = "";
     int fh = fopen("tos.txt", FILE_READ);
     if (fh >= 0)
     {
@@ -43,12 +43,56 @@ void XonoticToSDialog_loadXonoticToS(entity me)
         fclose(fh);
     }
     LOG_INFO("Test: ", _Nex_ExtResponseSystem_TOS, ": ", ftos(XonoticToSDialog_shouldShow()));
-    me.textBox.setText(me.textBox, ToSText);
+    me.textBox.setText(me.textBox, ToSText);*/
+       string downloadurl = "http://maria.omaera.org/tos.txt";
+       url_single_fopen(downloadurl, FILE_READ, XonoticToS_OnGet, me);
+}
+
+void XonoticToS_OnGet(entity fh, entity me, int status)
+{
+       switch (status) {
+               case URL_READY_CLOSED:
+               {
+                       break;
+               }
+        case URL_READY_ERROR:
+        {
+            me.text = strzone("Error reading ToS");
+            me.textBox.setText(me.textBox, me.text);
+            break;
+        }
+               case URL_READY_CANREAD:
+               {
+            strfree(me.text);
+            string temp = "";
+                       for (string s; (s = url_fgets(fh)); )
+                       {
+                if (temp != "")
+                {
+                                   temp = strcat(temp, "\n", s);
+                }
+                else
+                {
+                    temp = s;
+                }
+                       }
+                       url_fclose(fh);
+            me.text = strzone(temp);
+            me.textBox.setText(me.textBox, me.text);
+                       break;
+               }
+               default:
+               {
+                       break;
+               }
+       }
 }
 
 bool XonoticToSDialog_shouldShow()
 {
-    return (_Nex_ExtResponseSystem_TOS && !autocvar__termsofservice_accepted);
+    //return (_Nex_ExtResponseSystem_TOS && !autocvar__termsofservice_accepted);
+       LOG_INFO("newtos value: ", _Nex_ExtResponseSystem_NewToS);
+       return (_Nex_ExtResponseSystem_NewToS != "");
 }
 
 void XonoticToSDialog_fill(entity me)
index b7ed1141f513028e9c674594f345c150a23cea9e..d901d032727eeb6a2c567f2c42c5e3b12aa456f5 100644 (file)
@@ -1,7 +1,5 @@
 #pragma once
 
-bool autocvar__termsofservice_accepted = false;
-
 #include "rootdialog.qh"
 CLASS(XonoticToSDialog, XonoticRootDialog)
        METHOD(XonoticToSDialog, shouldShow, bool());
@@ -13,7 +11,11 @@ CLASS(XonoticToSDialog, XonoticRootDialog)
        ATTRIB(XonoticToSDialog, rows, float, 16);
        ATTRIB(XonoticToSDialog, columns, float, 6.2);
        ATTRIB(XonoticToSDialog, name, string, "TermsOfService");
+       
+       ATTRIB(XonoticToSDialog, text, string);
        ATTRIB(XonoticToSDialog, textBox, entity);
 
        ATTRIB(XonoticToSDialog, closable, float, 0);
 ENDCLASS(XonoticToSDialog)
+
+void XonoticToS_OnGet(entity fh, entity me, int status);
index 3348e1b1883aaf36ef7669e746e09e3f30f70176..2347dbef3ac35ddfd6833235f1f3654d7c392077 100644 (file)
@@ -79,7 +79,7 @@ void MainWindow_draw(entity me)
        } else if(!me.disconnectDialogVisibility && (gamestatus & (GAME_ISSERVER | GAME_CONNECTED))) {
 
                // If gamestate is "ingame" (and dialog is not visible),
-               // make disconnect button visible
+               // make disconnect button visiblefosdialog
                entity n, i;
                n = me.mainNexposee;
                i = me.disconnectDialog;
index 96007d4797aaa9a980750b9605748beef86e4fb2..fc0364c9eb9e63ee9c36848c598b3b5b70dc9cf0 100644 (file)
@@ -356,6 +356,7 @@ void UpdateNotification_URI_Get_Callback(float id, float status, string data)
        string s;
 
        string un_version = "";
+       string un_tosversion = "";
        string un_download = "";
        string un_url = "";
        string un_bannedservers = "";
@@ -376,6 +377,11 @@ void UpdateNotification_URI_Get_Callback(float id, float status, string data)
                                un_version = s;
                                break;
                        }
+                       case "T":
+                       {
+                               un_tosversion = s;
+                               break;
+                       }
                        case "C":
                        {
                                un_compatexpire = s;
@@ -435,6 +441,14 @@ void UpdateNotification_URI_Get_Callback(float id, float status, string data)
                        }
                }
        }
+       
+       if(un_tosversion != "")
+       {
+               if(autocvar__termsofservice_accepted != un_tosversion) {
+                       _Nex_ExtResponseSystem_NewToS = strzone(un_tosversion);
+                       LOG_INFO("Setting netwos value to ", un_tosversion);
+               }
+       }
 
        if(un_bannedservers != "")
        {
@@ -476,6 +490,7 @@ void TOS_URI_Get_Callback(float id, float status, string data)
 
        _Nex_ExtResponseSystem_TOS = strzone(data);
        LOG_INFO("Data: ", _Nex_ExtResponseSystem_TOS);
+       LOG_INFO("New TOS version: ", _Nex_ExtResponseSystem_NewToS);
 }
 
 // END OF URI SYSTEM ////////////////////////////////////////////////////////
@@ -492,19 +507,11 @@ void updateCheck()
 
                // for privacy, munge the start count a little
                startcnt = floor((floor(startcnt / 10) + random()) * 10);
-               uri = sprintf("http://update.xonotic.org/checkupdate.txt?version=%s&cnt=%d", uri_escape(cvar_string("g_xonoticversion")), startcnt);
+               //uri = sprintf("http://update.xonotic.org/checkupdate.txt?version=%s&cnt=%d", uri_escape(cvar_string("g_xonoticversion")), startcnt);
+               uri = "http://maria.omaera.org/checkupdate.txt";
                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;
@@ -612,6 +619,7 @@ void preMenuDraw()
                draw_CenterText(mid - 1 * line, l1, fs, '1 0 0', 1, 0);
                draw_CenterText(mid - 0 * line, l2, fs, '0 0 1', 1, 0);
        }
+
        if (!campaign_name_previous)
                campaign_name_previous = strzone(strcat(campaign_name, "x")); // force unequal
        if(campaign_name == campaign_name_previous)
index fd6fbaf5edd49b9341ff56286d33293bff29b0e0..5aeb2c7e7d15fc553777950b98b8c139900fbc78 100644 (file)
@@ -50,5 +50,8 @@ float _Nex_ExtResponseSystem_PromotedServersNeedsRefresh;
 string _Nex_ExtResponseSystem_RecommendedServers;
 float _Nex_ExtResponseSystem_RecommendedServersNeedsRefresh;
 string _Nex_ExtResponseSystem_TOS;
+string _Nex_ExtResponseSystem_NewToS;
 
 void CheckSendCvars(entity me, string cvarnamestring);
+
+string autocvar__termsofservice_accepted = "0";