From: Mario Date: Wed, 23 Dec 2020 09:35:48 +0000 (+1000) Subject: Experiment with downloading the terms of service instead of using a local file X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1189d42dac1da12b765717f481eed1f432bc6e00;p=xonotic%2Fxonotic-data.pk3dir.git Experiment with downloading the terms of service instead of using a local file --- diff --git a/qcsrc/lib/urllib.qh b/qcsrc/lib/urllib.qh index 8918ca0a2..639b5db73 100644 --- a/qcsrc/lib/urllib.qh +++ b/qcsrc/lib/urllib.qh @@ -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; diff --git a/qcsrc/menu/xonotic/dialog_termsofservice.qc b/qcsrc/menu/xonotic/dialog_termsofservice.qc index 85c82c451..b3f252f0c 100644 --- a/qcsrc/menu/xonotic/dialog_termsofservice.qc +++ b/qcsrc/menu/xonotic/dialog_termsofservice.qc @@ -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) diff --git a/qcsrc/menu/xonotic/util.qc b/qcsrc/menu/xonotic/util.qc index e77049d20..96007d479 100644 --- a/qcsrc/menu/xonotic/util.qc +++ b/qcsrc/menu/xonotic/util.qc @@ -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; diff --git a/qcsrc/menu/xonotic/util.qh b/qcsrc/menu/xonotic/util.qh index f5bd636d8..fd6fbaf5e 100644 --- a/qcsrc/menu/xonotic/util.qh +++ b/qcsrc/menu/xonotic/util.qh @@ -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);