From 937e1fc37ac252dddae582588b36c8bff69cdb47 Mon Sep 17 00:00:00 2001 From: z411 Date: Wed, 24 Nov 2021 01:41:39 -0300 Subject: [PATCH] First ToS versioning attempt --- qcsrc/menu/xonotic/.util.qc.kate-swp | Bin 0 -> 703 bytes qcsrc/menu/xonotic/dialog_termsofservice.qc | 50 ++++++++++++++++++-- qcsrc/menu/xonotic/dialog_termsofservice.qh | 6 ++- qcsrc/menu/xonotic/mainwindow.qc | 2 +- qcsrc/menu/xonotic/util.qc | 28 +++++++---- qcsrc/menu/xonotic/util.qh | 3 ++ 6 files changed, 73 insertions(+), 16 deletions(-) create mode 100644 qcsrc/menu/xonotic/.util.qc.kate-swp diff --git a/qcsrc/menu/xonotic/.util.qc.kate-swp b/qcsrc/menu/xonotic/.util.qc.kate-swp new file mode 100644 index 0000000000000000000000000000000000000000..4f3893a545fe2577df669191e4411cde038af81c GIT binary patch literal 703 zcmbV}%}T>S5XU#EU-jD>?|Z7AZ1Lcwc#qi9^8Lpm=G`GLSTRMo7vgyFvcopGSS={%aET8e9aH`>x?nytJHgae^DRP!^!jI zQ{yUpn|^v1jM?|b+D-F4m<^Uyc4q=?K}=@hRAg*H)?Cl^vWWdFQbL4N#vHg!JP*Dm zUI1(2MQ}vCRPbf+F8O6}OuPcl^SyeaZ`vgZRh?Q>6bT1|1P6LBnkzbn-Z)mKeQts4YBm%}7bBN+*i=;$^M`mv5i z1EqyjN{5N=@gv@seykhR4b`1=vKVL;jUUYh3nR}Mll@;8oQCT9AG=t4>Fu&Q+x-S8 C26o~A literal 0 HcmV?d00001 diff --git a/qcsrc/menu/xonotic/dialog_termsofservice.qc b/qcsrc/menu/xonotic/dialog_termsofservice.qc index b3f252f0c..c0c26c9fd 100644 --- a/qcsrc/menu/xonotic/dialog_termsofservice.qc +++ b/qcsrc/menu/xonotic/dialog_termsofservice.qc @@ -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) diff --git a/qcsrc/menu/xonotic/dialog_termsofservice.qh b/qcsrc/menu/xonotic/dialog_termsofservice.qh index b7ed1141f..d901d0327 100644 --- a/qcsrc/menu/xonotic/dialog_termsofservice.qh +++ b/qcsrc/menu/xonotic/dialog_termsofservice.qh @@ -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); diff --git a/qcsrc/menu/xonotic/mainwindow.qc b/qcsrc/menu/xonotic/mainwindow.qc index 3348e1b18..2347dbef3 100644 --- a/qcsrc/menu/xonotic/mainwindow.qc +++ b/qcsrc/menu/xonotic/mainwindow.qc @@ -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; diff --git a/qcsrc/menu/xonotic/util.qc b/qcsrc/menu/xonotic/util.qc index 96007d479..fc0364c9e 100644 --- a/qcsrc/menu/xonotic/util.qc +++ b/qcsrc/menu/xonotic/util.qc @@ -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) diff --git a/qcsrc/menu/xonotic/util.qh b/qcsrc/menu/xonotic/util.qh index fd6fbaf5e..5aeb2c7e7 100644 --- a/qcsrc/menu/xonotic/util.qh +++ b/qcsrc/menu/xonotic/util.qh @@ -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"; -- 2.39.2