Allow showing random MOTDs during TP

Wed, 06 Dec 2017 09:46:16 +0100

author
Ansariel
date
Wed, 06 Dec 2017 09:46:16 +0100
changeset 53544
c0cdfa737f42
parent 53543
98cc3f892231
child 53545
ed0d7e048068

Allow showing random MOTDs during TP

Selection rules for MOTD:
* if main MOTD is defined, show this at login and during TPs
* if random MOTDs are defined and main MOTD not set, show a random MOTD
at login and every TP
* if event MOTD is defined, show event MOTD at login. For TPs, either
show main MOTD if defined, or show a random MOTD if defined

indra/newview/fsdata.cpp file | annotate | diff | revisions
indra/newview/fsdata.h file | annotate | diff | revisions
indra/newview/llviewerdisplay.cpp file | annotate | diff | revisions
     1.1 --- a/indra/newview/fsdata.cpp	Tue Dec 05 17:38:43 2017 +0100
     1.2 +++ b/indra/newview/fsdata.cpp	Wed Dec 06 09:46:16 2017 +0100
     1.3 @@ -390,15 +390,16 @@
     1.4  void FSData::processData(const LLSD& fs_data)
     1.5  {
     1.6  	// Set Message Of The Day if present 
     1.7 -	if(fs_data.has("MOTD"))
     1.8 +	if (fs_data.has("MOTD") && !fs_data["MOTD"].asString().empty())
     1.9  	{
    1.10 -		gAgent.mMOTD.assign(fs_data["MOTD"]);
    1.11 +		mSecondLifeMOTD = fs_data["MOTD"];
    1.12 +		gAgent.mMOTD.assign(mSecondLifeMOTD);
    1.13  	}
    1.14 -	else if(fs_data.has("RandomMOTD")) // only used if MOTD is not presence in the xml file.
    1.15 +	else if (fs_data.has("RandomMOTD") && fs_data["RandomMOTD"].isArray() && fs_data["RandomMOTD"].size() > 0) // only used if MOTD is not present or empty in the xml file.
    1.16  	{
    1.17 -		const LLSD& motd = fs_data["RandomMOTD"];
    1.18 -		LLSD::array_const_iterator iter = motd.beginArray();
    1.19 -		gAgent.mMOTD.assign((iter + (ll_rand((S32)motd.size())))->asString());
    1.20 +		mRandomMOTDs = fs_data["RandomMOTD"];
    1.21 +		LLSD::array_const_iterator iter = mRandomMOTDs.beginArray();
    1.22 +		gAgent.mMOTD.assign((iter + (ll_rand((S32)mRandomMOTDs.size())))->asString());
    1.23  	}
    1.24  	
    1.25  	// If the event falls withen the current date, use that for MOTD instead.
    1.26 @@ -419,12 +420,12 @@
    1.27  		}
    1.28  	}
    1.29  
    1.30 -	if(fs_data.has("OpensimMOTD"))
    1.31 +	if (fs_data.has("OpensimMOTD"))
    1.32  	{
    1.33 -		mOpensimMOTD.assign(fs_data["OpensimMOTD"]);
    1.34 +		mOpenSimMOTD.assign(fs_data["OpensimMOTD"]);
    1.35  	}
    1.36  
    1.37 -	if(fs_data.has("BlockedReleases"))
    1.38 +	if (fs_data.has("BlockedReleases"))
    1.39  	{
    1.40  		const LLSD& blocked = fs_data["BlockedReleases"];
    1.41  		for (LLSD::map_const_iterator iter = blocked.beginMap(); iter != blocked.endMap(); ++iter)
    1.42 @@ -441,24 +442,24 @@
    1.43  
    1.44  	// FSUseLegacyClienttags: 0=Off, 1=Local Clienttags, 2=Download Clienttags
    1.45  	static LLCachedControl<U32> use_legacy_tags(gSavedSettings, "FSUseLegacyClienttags");
    1.46 -	if(use_legacy_tags > 1)
    1.47 +	if (use_legacy_tags > 1)
    1.48  	{
    1.49  		time_t last_modified = 0;
    1.50  		llstat stat_data;
    1.51 -		if(!LLFile::stat(mClientTagsFilename, &stat_data))
    1.52 +		if (!LLFile::stat(mClientTagsFilename, &stat_data))
    1.53  		{
    1.54  			last_modified = stat_data.st_mtime;
    1.55  		}
    1.56  		LL_INFOS("fsdata") << "Downloading client_list_v2.xml from " << LEGACY_CLIENT_LIST_URL << " with last modified of " << last_modified << LL_ENDL;
    1.57  		FSCoreHttpUtil::callbackHttpGet(LEGACY_CLIENT_LIST_URL, last_modified, boost::bind(downloadComplete, _1, LEGACY_CLIENT_LIST_URL, true), boost::bind(downloadComplete, _1, LEGACY_CLIENT_LIST_URL, false));
    1.58  	}
    1.59 -	else if(use_legacy_tags)
    1.60 +	else if (use_legacy_tags)
    1.61  	{
    1.62  		updateClientTagsLocal();
    1.63  	}
    1.64  
    1.65  // [RLVa:KB]
    1.66 -	if ( (RlvActions::isRlvEnabled()) && (fs_data.has("rlva_compat_list")) )
    1.67 +	if ((RlvActions::isRlvEnabled()) && (fs_data.has("rlva_compat_list")))
    1.68  	{
    1.69  		RlvSettings::initCompatibilityMode(fs_data["rlva_compat_list"].asString());
    1.70  	}
    1.71 @@ -551,6 +552,28 @@
    1.72  	}
    1.73  }
    1.74  
    1.75 +// Selection rules for MOTD:
    1.76 +// * if main MOTD is defined, show this at login and during TPs
    1.77 +// * if random MOTDs are defined and main MOTD not set, show a random MOTD
    1.78 +//   at login and every TP
    1.79 +// * if event MOTD is defined, show event MOTD at login. For TPs, either
    1.80 +//   show main MOTD if defined, or show a random MOTD if defined
    1.81 +void FSData::selectNextMOTD()
    1.82 +{
    1.83 +	if (LLGridManager::instance().isInSLMain())
    1.84 +	{
    1.85 +		if (!mSecondLifeMOTD.empty())
    1.86 +		{
    1.87 +			gAgent.mMOTD.assign(mSecondLifeMOTD);
    1.88 +		}
    1.89 +		else if (mRandomMOTDs.isArray() && mRandomMOTDs.size() > 0)
    1.90 +		{
    1.91 +			LLSD::array_const_iterator iter = mRandomMOTDs.beginArray();
    1.92 +			gAgent.mMOTD.assign((iter + (ll_rand((S32)mRandomMOTDs.size())))->asString());
    1.93 +		}
    1.94 +	}
    1.95 +}
    1.96 +
    1.97  //WS: Create a new LLSD based on the data from the mLegacyClientList if
    1.98  LLSD FSData::resolveClientTag(const LLUUID& id, bool new_system, const LLColor4& color)
    1.99  {	
     2.1 --- a/indra/newview/fsdata.h	Tue Dec 05 17:38:43 2017 +0100
     2.2 +++ b/indra/newview/fsdata.h	Wed Dec 06 09:46:16 2017 +0100
     2.3 @@ -40,7 +40,6 @@
     2.4  	virtual ~FSData();
     2.5  
     2.6  public:
     2.7 -
     2.8  	void startDownload();
     2.9  	void downloadAgents();
    2.10  	void processResponder(const LLSD& content, const std::string& url, bool save_to_file, const LLDate& last_modified);
    2.11 @@ -52,12 +51,12 @@
    2.12  	{
    2.13  		SUPPORT		= (1 << 0), //0x01 1
    2.14  		DEVELOPER	= (1 << 1), //0x02 2
    2.15 -		QA		= (1 << 2), //0x04 4
    2.16 +		QA			= (1 << 2), //0x04 4
    2.17  		CHAT_COLOR	= (1 << 3), //0x08 8
    2.18  		NO_SUPPORT	= (1 << 4), //0x10 16
    2.19  		NO_USE		= (1 << 5), //0x20 32
    2.20 -		NO_SPAM		= (1 << 6),  //0x40 64
    2.21 -		GATEWAY		= (1 << 7),	//0x80 128 <FS:JL>
    2.22 +		NO_SPAM		= (1 << 6), //0x40 64
    2.23 +		GATEWAY		= (1 << 7), //0x80 128 <FS:JL>
    2.24  	};
    2.25  
    2.26  	std::set<LLUUID> mSupportGroup;
    2.27 @@ -76,7 +75,9 @@
    2.28  	static LLSD getSystemInfo();
    2.29  	static void callbackReqInfo(const LLSD &notification, const LLSD &response);
    2.30  	
    2.31 -	std::string getOpenSimMOTD() { return mOpensimMOTD; }
    2.32 +	std::string getOpenSimMOTD() { return mOpenSimMOTD; }
    2.33 +	void selectNextMOTD();
    2.34 +
    2.35  	bool getFSDataDone() { return mFSDataDone; }
    2.36  	bool getAgentsDone() { return mAgentsDone; }
    2.37  
    2.38 @@ -98,21 +99,23 @@
    2.39  
    2.40  	LLSD mHeaders;
    2.41  	LLSD mLegacyClientList;
    2.42 -	
    2.43 +	LLSD mRandomMOTDs;
    2.44 +
    2.45  	std::string mFSdataFilename;
    2.46  	std::string mFSdataDefaultsFilename;
    2.47  	std::string mFSdataDefaultsUrl;
    2.48  	std::string mAgentsFilename;
    2.49  	std::string mAssestsFilename;
    2.50  	std::string mClientTagsFilename;
    2.51 -	
    2.52 +
    2.53  	std::string mBaseURL;
    2.54  	std::string mFSDataURL;
    2.55  	std::string mAgentsURL;
    2.56  	std::string mAssetsURL;
    2.57  	
    2.58 -	std::string mOpensimMOTD;
    2.59 -	
    2.60 +	std::string mSecondLifeMOTD;
    2.61 +	std::string mOpenSimMOTD;
    2.62 +
    2.63  	bool mLegacySearch;
    2.64  	bool mFSDataDone;
    2.65  	bool mAgentsDone;
     3.1 --- a/indra/newview/llviewerdisplay.cpp	Tue Dec 05 17:38:43 2017 +0100
     3.2 +++ b/indra/newview/llviewerdisplay.cpp	Wed Dec 06 09:46:16 2017 +0100
     3.3 @@ -82,6 +82,7 @@
     3.4  #include "rlvlocks.h"
     3.5  // [/RLVa:KB]
     3.6  #include "llpresetsmanager.h"
     3.7 +#include "fsdata.h"
     3.8  
     3.9  extern LLPointer<LLViewerTexture> gStartTexture;
    3.10  extern bool gShiftFrame;
    3.11 @@ -501,6 +502,7 @@
    3.12  			gAgent.setTeleportMessage(
    3.13  				LLAgent::sTeleportProgressMessages["requesting"]);
    3.14  			gViewerWindow->setProgressString(LLAgent::sTeleportProgressMessages["requesting"]);
    3.15 +			FSData::instance().selectNextMOTD();
    3.16  			gViewerWindow->setProgressMessage(gAgent.mMOTD);
    3.17  			break;
    3.18  

mercurial