aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/kowopenregionsettings.cpp
blob: 6257147d9ebf4d18bd10cac8070f653c3dc8394a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*
 * @file kowopenregionsettings.cpp
 * @brief Handler for OpenRegionInfo event queue message.
 *
 * Copyright (c) 2010, Patrick Sapinski
 *
 * The source code in this file ("Source Code") is provided to you
 * under the terms of the GNU General Public License, version 2.0
 * ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in
 * this distribution, or online at
 * http://secondlifegrid.net/programs/open_source/licensing/gplv2
 *
 * There are special exceptions to the terms and conditions of the GPL as
 * it is applied to this Source Code. View the full text of the exception
 * in the file doc/FLOSS-exception.txt in this software distribution, or
 * online at
 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
 *
 * By copying, modifying or distributing this software, you acknowledge
 * that you have read and understood your obligations described above,
 * and agree to abide by those obligations.
 *
 * ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO
 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
 * COMPLETENESS OR PERFORMANCE.
 */

#include "llviewerprecompiledheaders.h"
#include "llhttpnode.h"
#include "hippolimits.h"
#include "llfloatertools.h"
#include "llviewercontrol.h"
#include "llagent.h"
#include "llsurface.h"
#include "llviewerregion.h"
#include "llviewerobject.h"
#include "llfloaterregioninfo.h"
#include "llfloaterworldmap.h"
#include "viewertime.h"

//DEBUG includes
//#include "llsdserialize.h" //LLSDNotationStreamer - for dumping LLSD to string

class OpenRegionInfoUpdate : public LLHTTPNode
{
	/*virtual*/ void post(
		LLHTTPNode::ResponsePtr response,
		const LLSD& context,
		const LLSD& input) const
	{
		if (!input || !context || !input.isMap() || !input.has("body"))
		{
			llinfos << "malformed OpenRegionInfo update!" << llendl;	 
			return;
		}

		LLSD body = input["body"];
		//llinfos << "data: " << LLSDNotationStreamer(body) << llendl;	 
		//llinfos << "data: " << LLSDXMLStreamer(body) << llendl;	 	 
		
		//set the default limits/settings for this simulator type, as limits from our
		//previous region may not exist in this one
		gHippoLimits->setLimits();

		//limits are also reset in llviewermessage.cpp when we detect a new server
		//version, in case the destination simulator does not support OpenRegionInfo.

		BOOL limitschanged = FALSE;

		if ( body.has("AllowMinimap") )
		{
			gHippoLimits->mAllowMinimap = body["AllowMinimap"].asInteger() == 1;
		}
		if ( body.has("AllowPhysicalPrims") )
		{
			gHippoLimits->mAllowPhysicalPrims = body["AllowPhysicalPrims"].asInteger() == 1;
			limitschanged = TRUE;
		}
		if ( body.has("DrawDistance") )
		{
			F32 distance = body["DrawDistance"].asReal();
			if (distance > 0)
			{
				gAgent.mDrawDistance = distance;
			}
		}
		if ( body.has("ForceDrawDistance") )
		{
			gAgent.mLockedDrawDistance = body["ForceDrawDistance"].asInteger() == 1;
		}
		if ( body.has("LSLFunctions") )
		{
			//IMPLEMENT ME
		}
		if ( body.has("MaxDragDistance") )
		{
			gHippoLimits->mMaxDragDistance = body["MaxDragDistance"].asReal();
		}
		if ( body.has("MinHoleSize") )
		{
			//Note: does NOT update correctly
			gHippoLimits->mMinHoleSize = body["MinHoleSize"].asReal();
			limitschanged = TRUE;
		}
		if ( body.has("MaxHollowSize") )
		{
			//Note: does NOT update correctly
			gHippoLimits->mMaxHollow = body["MaxHollowSize"].asReal();
			limitschanged = TRUE;
		}
		if ( body.has("MaxInventoryItemsTransfer") )
		{
			gHippoLimits->mMaxInventoryItemsTransfer = body["MaxInventoryItemsTransfer"].asReal();
		}
		if ( body.has("MaxLinkCount") )
		{
			gHippoLimits->mMaxLinkedPrims = body["MaxLinkCount"].asInteger();
		}
		if ( body.has("MaxLinkCountPhys") )
		{
			gHippoLimits->mMaxPhysLinkedPrims = body["MaxLinkCountPhys"].asInteger();
		}
		if ( body.has("MaxPos") )
		{
			gHippoLimits->mMaxPrimXPos = body["MaxPosX"].asReal();
			gHippoLimits->mMaxPrimYPos = body["MaxPosY"].asReal();
			gHippoLimits->mMaxPrimZPos = body["MaxPosZ"].asReal();
			limitschanged = TRUE;
		}
		if ( body.has("MinPos") )
		{
			gHippoLimits->mMinPrimXPos = body["MinPosX"].asReal();
			gHippoLimits->mMinPrimYPos = body["MinPosY"].asReal();
			gHippoLimits->mMinPrimZPos = body["MinPosZ"].asReal();
			limitschanged = TRUE;
		}
		if ( body.has("MaxPrimScale") )
		{
			gHippoLimits->mMaxPrimScale = body["MaxPrimScale"].asReal();
			limitschanged = TRUE;
		}
		if ( body.has("MaxPhysPrimScale") )
		{
			//IMPLEMENT ME
		}
		if ( body.has("MinPrimScale") )
		{
			gHippoLimits->mMinPrimScale = body["MinPrimScale"].asReal();
			limitschanged = TRUE;
		}
		if ( body.has("OffsetOfUTC") )
		{
			gSavedSettings.setS32("TimeOffset", body["OffsetOfUTC"].asInteger());
			gSavedSettings.setBOOL("UseTimeOffset", true);
			ViewerTime::sUseTimeOffset = true;
			ViewerTime::sTimeOffset = gSavedSettings.getS32("TimeOffset");
		}
		if ( body.has("OffsetOfUTCDST") )
		{
			gSavedSettings.setBOOL("TimeOffsetDST", body["OffsetOfUTCDST"].asInteger() == 1 ? TRUE : FALSE);
			ViewerTime::sTimeOffsetDST = gSavedSettings.getBOOL("TimeOffsetDST");
		}
		if ( body.has("RenderWater") )
		{
			gHippoLimits->mRenderWater = body["RenderWater"].asInteger() == 1 ? TRUE : FALSE;
			gAgent.getRegion()->rebuildWater();
		}
		if ( body.has("SayDistance") )
		{
			gSavedSettings.setU32("ChatDistance", body["SayDistance"].asReal());
		}
		if ( body.has("ShoutDistance") )
		{
			//IMPLEMENT ME
		}
		if ( body.has("WhisperDistance") )
		{
			//IMPLEMENT ME
		}
		if ( body.has("ToggleTeenMode") )
		{
			gHippoLimits->mEnableTeenMode = body["ToggleTeenMode"].asInteger() == 1 ? TRUE : FALSE;
		}
		if ( body.has("SetTeenMode") )
		{
			gAgent.setTeen( body["SetTeenMode"].asInteger() == 1 ? TRUE : FALSE );
			LLFloaterWorldMap::reloadIcons(NULL);
			llinfos << "PG status set to " << (S32)gAgent.isTeen() << llendl;
		}
		if ( body.has("ShowTags") )
		{
			gHippoLimits->mRenderName = body["ShowTags"].asReal();
		}
		if ( body.has("EnforceMaxBuild") )
		{
			gHippoLimits->mEnforceMaxBuild = body["EnforceMaxBuild"].asInteger() == 1 ? TRUE : FALSE;
			limitschanged = TRUE;
		}
		if ( body.has("MaxGroups") )
		{
			gHippoLimits->mMaxAgentGroups = body["MaxGroups"].asReal();
		}
		if ( body.has("AllowParcelWindLight") )
		{
			gHippoLimits->mAllowParcelWindLight = body["AllowParcelWindLight"].asInteger() == 1;
		}


		if (limitschanged)
			gFloaterTools->updateToolsSizeLimits();

		//Update the floater if its around
		LLPanelRegionOpenSettingsInfo* floater = LLFloaterRegionInfo::getPanelOpenSettings();

		if (floater != NULL)
		{
			floater->refreshFromRegion(gAgent.getRegion());
		}
	}
};

LLHTTPRegistration<OpenRegionInfoUpdate>
gHTTPRegistrationOpenRegionInfoUpdate(
	"/message/OpenRegionInfo");