PageRenderTime 43ms CodeModel.GetById 1ms app.highlight 29ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llviewerparcelmgr.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 380 lines | 174 code | 87 blank | 119 comment | 0 complexity | 9d54230fdadaf2a16f1e8cb1ec74ba09 MD5 | raw file
Possible License(s): LGPL-2.1
  1/** 
  2 * @file llviewerparcelmgr.h
  3 * @brief Viewer-side representation of owned land
  4 *
  5 * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLVIEWERPARCELMGR_H
 28#define LL_LLVIEWERPARCELMGR_H
 29
 30#include "v3dmath.h"
 31#include "lldarray.h"
 32#include "llframetimer.h"
 33#include "llsingleton.h"
 34#include "llparcelselection.h"
 35#include "llui.h"
 36
 37#include <boost/function.hpp>
 38#include <boost/signals2.hpp>
 39
 40class LLUUID;
 41class LLMessageSystem;
 42class LLParcel;
 43class LLViewerTexture;
 44class LLViewerRegion;
 45
 46const F32 DWELL_NAN = -1.0f;	// A dwell having this value will be displayed as Loading...
 47
 48// Constants for sendLandOwner
 49//const U32 NO_NEIGHBOR_JOIN = 0x0;
 50//const U32 ALL_NEIGHBOR_JOIN = U32(  NORTH_MASK 
 51//							  | SOUTH_MASK 
 52//							  | EAST_MASK 
 53//							  | WEST_MASK);
 54
 55// Specify the type of land transfer taking place
 56//enum ELandTransferType
 57//{
 58//	LTT_RELEASE_LAND = 0x1,
 59//	LTT_CLAIM_LAND = 0x2,
 60//	LTT_BUY_LAND = 0x4,
 61//	LTT_DEED_LAND = 0x8,
 62//	LTT_FOR_GROUP = 0x16
 63//};
 64
 65// Base class for people who want to "observe" changes in the viewer
 66// parcel selection.
 67
 68//FIXME: this should be done by grabbing a floating parcel selection and observing changes on it, not the parcel mgr
 69//--RN
 70class LLParcelObserver
 71{
 72public:
 73	virtual ~LLParcelObserver() {};
 74	virtual void changed() = 0;
 75};
 76
 77class LLViewerParcelMgr : public LLSingleton<LLViewerParcelMgr>
 78{
 79
 80public:
 81	typedef boost::function<void (const LLVector3d&)> teleport_finished_callback_t;
 82	typedef boost::signals2::signal<void (const LLVector3d&)> teleport_finished_signal_t;
 83	typedef boost::function<void()> parcel_changed_callback_t;
 84	typedef boost::signals2::signal<void()> parcel_changed_signal_t;
 85
 86	LLViewerParcelMgr();
 87	~LLViewerParcelMgr();
 88
 89	static void cleanupGlobals();
 90
 91	BOOL	selectionEmpty() const;
 92	F32		getSelectionWidth() const	{ return F32(mEastNorth.mdV[VX] - mWestSouth.mdV[VX]); }
 93	F32		getSelectionHeight() const	{ return F32(mEastNorth.mdV[VY] - mWestSouth.mdV[VY]); }
 94	BOOL	getSelection(LLVector3d &min, LLVector3d &max) { min = mWestSouth; max = mEastNorth; return !selectionEmpty();}
 95	LLViewerRegion* getSelectionRegion();
 96	F32		getDwelling() const { return mSelectedDwell;}
 97
 98	void	getDisplayInfo(S32* area, S32* claim, S32* rent, BOOL* for_sale, F32* dwell);
 99
100	// Returns selected area
101	S32 getSelectedArea() const;
102
103	void resetSegments(U8* segments);
104
105	// write a rectangle's worth of line segments into the highlight array
106	void writeHighlightSegments(F32 west, F32 south, F32 east, F32 north);
107
108	// Write highlight segments from a packed bitmap of the appropriate
109	// parcel.
110	void writeSegmentsFromBitmap(U8* bitmap, U8* segments);
111
112	void writeAgentParcelFromBitmap(U8* bitmap);
113
114	// Select the collision parcel
115	void selectCollisionParcel();
116
117	// Select the parcel at a specific point
118	LLParcelSelectionHandle selectParcelAt(const LLVector3d& pos_global);
119
120	// Take the current rectangle select, and select the parcel contained
121	// within it.
122	LLParcelSelectionHandle selectParcelInRectangle();
123
124	// Select a piece of land
125	LLParcelSelectionHandle selectLand(const LLVector3d &corner1, const LLVector3d &corner2, 
126					   BOOL snap_to_parcel);
127
128	// Clear the selection, and stop drawing the highlight.
129	void	deselectLand();
130	void	deselectUnused();
131
132	void addObserver(LLParcelObserver* observer);
133	void removeObserver(LLParcelObserver* observer);
134	void notifyObservers();
135
136	void setSelectionVisible(BOOL visible) { mRenderSelection = visible; }
137
138	BOOL	isOwnedAt(const LLVector3d& pos_global) const;
139	BOOL	isOwnedSelfAt(const LLVector3d& pos_global) const;
140	BOOL	isOwnedOtherAt(const LLVector3d& pos_global) const;
141	BOOL	isSoundLocal(const LLVector3d &pos_global) const;
142
143	BOOL	canHearSound(const LLVector3d &pos_global) const;
144
145	// Returns a reference counted pointer to current parcel selection.  
146	// Selection does not change to reflect new selections made by user
147	// Use this when implementing a task UI that refers to a specific
148	// selection.
149	LLParcelSelectionHandle getParcelSelection() const;
150
151	// Returns a reference counted pointer to current parcel selection.
152	// Pointer tracks whatever the user has currently selected.
153	// Use this when implementing an inspector UI.
154	// http://en.wikipedia.org/wiki/Inspector_window
155	LLParcelSelectionHandle getFloatingParcelSelection() const;
156
157	//LLParcel *getParcelSelection() const;
158	LLParcel *getAgentParcel() const;
159
160	BOOL	inAgentParcel(const LLVector3d &pos_global) const;
161
162	// Returns a pointer only when it has valid data.
163	LLParcel*	getHoverParcel() const;
164
165	LLParcel*	getCollisionParcel() const;
166
167	// Can this agent build on the parcel he is on?
168	// Used for parcel property icons in nav bar.
169	bool	allowAgentBuild() const;
170	bool	allowAgentBuild(const LLParcel* parcel) const;
171	
172	// Can this agent speak on the parcel he is on?
173	// Used for parcel property icons in nav bar.
174	bool	allowAgentVoice() const;
175	bool	allowAgentVoice(const LLViewerRegion* region, const LLParcel* parcel) const;
176
177	// Can this agent start flying on this parcel?
178	// Used for parcel property icons in nav bar.
179	bool	allowAgentFly(const LLViewerRegion* region, const LLParcel* parcel) const;
180	
181	// Can this agent be pushed by llPushObject() on this parcel?
182	// Used for parcel property icons in nav bar.
183	bool	allowAgentPush(const LLViewerRegion* region, const LLParcel* parcel) const;
184	
185	// Can scripts written by non-parcel-owners run on the agent's current
186	// parcel?  Used for parcel property icons in nav bar.
187	bool	allowAgentScripts(const LLViewerRegion* region, const LLParcel* parcel) const;
188	
189	// Can the agent be damaged here?
190	// Used for parcel property icons in nav bar.
191	bool	allowAgentDamage(const LLViewerRegion* region, const LLParcel* parcel) const;
192
193	F32		getHoverParcelWidth() const		
194				{ return F32(mHoverEastNorth.mdV[VX] - mHoverWestSouth.mdV[VX]); }
195
196	F32		getHoverParcelHeight() const
197				{ return F32(mHoverEastNorth.mdV[VY] - mHoverWestSouth.mdV[VY]); }
198
199	// UTILITIES
200	void	render();
201	void	renderParcelCollision();
202
203	void	renderRect(	const LLVector3d &west_south_bottom, 
204						const LLVector3d &east_north_top );
205	void	renderOneSegment(F32 x1, F32 y1, F32 x2, F32 y2, F32 height, U8 direction, LLViewerRegion* regionp);
206	void	renderHighlightSegments(const U8* segments, LLViewerRegion* regionp);
207	void	renderCollisionSegments(U8* segments, BOOL use_pass, LLViewerRegion* regionp);
208
209	void	sendParcelGodForceOwner(const LLUUID& owner_id);
210
211	// make the selected parcel a content parcel. 
212	void sendParcelGodForceToContent();
213
214	// Pack information about this parcel and send it to the region
215	// containing the southwest corner of the selection.
216	// If want_reply_to_update, simulator will send back a ParcelProperties
217	// message.
218	void	sendParcelPropertiesUpdate(LLParcel* parcel, bool use_agent_region = false);
219
220	// Takes an Access List flag, like AL_ACCESS or AL_BAN
221	void	sendParcelAccessListUpdate(U32 which);
222
223	// Takes an Access List flag, like AL_ACCESS or AL_BAN
224	void	sendParcelAccessListRequest(U32 flags);
225
226	// asks for the parcel's media url filter list
227	void    requestParcelMediaURLFilter();
228	// receive the response
229	void    receiveParcelMediaURLFilter(const LLSD &content);
230	
231	// Dwell is not part of the usual parcel update information because the
232	// simulator doesn't actually know the per-parcel dwell.  Ack!  We have
233	// to get it out of the database.
234	void	sendParcelDwellRequest();
235
236	// If the point is outside the current hover parcel, request more data
237	void	setHoverParcel(const LLVector3d& pos_global);
238
239	bool	canAgentBuyParcel(LLParcel*, bool forGroup) const;
240	
241//	void	startClaimLand(BOOL is_for_group = FALSE);
242	void	startBuyLand(BOOL is_for_group = FALSE);
243	void	startSellLand();
244	void	startReleaseLand();
245	void	startDivideLand();
246	void	startJoinLand();
247	void	startDeedLandToGroup();
248	void reclaimParcel();
249
250	void	buyPass();
251
252	// Buying Land
253	
254	class ParcelBuyInfo;
255	ParcelBuyInfo* setupParcelBuy(const LLUUID& agent_id,
256								  const LLUUID& session_id,						 
257								  const LLUUID& group_id,
258								  BOOL is_group_owned,
259								  BOOL is_claim,
260								  BOOL remove_contribution);
261		// callers responsibility to call deleteParcelBuy() on return value
262	void sendParcelBuy(ParcelBuyInfo*);
263	void deleteParcelBuy(ParcelBuyInfo* *info);
264					   
265	void sendParcelDeed(const LLUUID& group_id);
266
267	// Send the ParcelRelease message
268	void sendParcelRelease();
269
270	// accessors for mAgentParcel
271	const std::string& getAgentParcelName() const;
272
273	// Create a landmark at the "appropriate" location for the
274	// currently selected parcel.
275	// *NOTE: Taken out 2005-03-21. Phoenix.
276	//void makeLandmarkAtSelection();
277
278	static void processParcelOverlay(LLMessageSystem *msg, void **user_data);
279	static void processParcelProperties(LLMessageSystem *msg, void **user_data);
280	static void processParcelAccessListReply(LLMessageSystem *msg, void **user);
281	static void processParcelDwellReply(LLMessageSystem *msg, void **user);
282
283	void dump();
284
285	// Whether or not the collision border around the parcel is there because
286	// the agent is banned or not in the allowed group
287	BOOL isCollisionBanned();
288
289	boost::signals2::connection addAgentParcelChangedCallback(parcel_changed_callback_t cb);
290	boost::signals2::connection setTeleportFinishedCallback(teleport_finished_callback_t cb);
291	boost::signals2::connection setTeleportFailedCallback(parcel_changed_callback_t cb);
292	void onTeleportFinished(bool local, const LLVector3d& new_pos);
293	void onTeleportFailed();
294
295	static BOOL isParcelOwnedByAgent(const LLParcel* parcelp, U64 group_proxy_power);
296	static BOOL isParcelModifiableByAgent(const LLParcel* parcelp, U64 group_proxy_power);
297
298private:
299	static bool releaseAlertCB(const LLSD& notification, const LLSD& response);
300
301	// If the user is claiming land and the current selection 
302	// borders a piece of land the user already owns, ask if he
303	// wants to join this land to the other piece.
304	//void	askJoinIfNecessary(ELandTransferType land_transfer_type);
305	//static void joinAlertCB(S32 option, void* data);
306
307	//void buyAskMoney(ELandTransferType land_transfer_type);
308
309	// move land from current owner to it's group.
310	void deedLandToGroup();
311
312	static bool deedAlertCB(const LLSD& notification, const LLSD& response);
313
314	static bool callbackDivideLand(const LLSD& notification, const LLSD& response);
315	static bool callbackJoinLand(const LLSD& notification, const LLSD& response);
316
317	//void	finishClaim(BOOL user_to_user_sale, U32 join);
318	LLViewerTexture* getBlockedImage() const;
319	LLViewerTexture* getPassImage() const;
320
321private:
322	BOOL						mSelected;
323
324	LLParcel*					mCurrentParcel;			// selected parcel info
325	LLParcelSelectionHandle		mCurrentParcelSelection;
326	LLParcelSelectionHandle		mFloatingParcelSelection;
327	S32							mRequestResult;		// result of last parcel request
328	LLVector3d					mWestSouth;
329	LLVector3d					mEastNorth;
330	F32							mSelectedDwell;
331
332	LLParcel					*mAgentParcel;		// info for parcel agent is in
333	S32							mAgentParcelSequenceID;	// incrementing counter to suppress out of order updates
334
335	LLParcel*					mHoverParcel;
336	S32							mHoverRequestResult;
337	LLVector3d					mHoverWestSouth;
338	LLVector3d					mHoverEastNorth;
339
340	LLDynamicArray<LLParcelObserver*> mObservers;
341
342	BOOL						mTeleportInProgress;
343	teleport_finished_signal_t	mTeleportFinishedSignal;
344	parcel_changed_signal_t		mTeleportFailedSignal;
345	parcel_changed_signal_t		mAgentParcelChangedSignal;
346
347	// Array of pieces of parcel edges to potentially draw
348	// Has (parcels_per_edge + 1) * (parcels_per_edge + 1) elements so
349	// we can represent edges of the grid.
350	// WEST_MASK = draw west edge
351	// SOUTH_MASK = draw south edge
352	S32							mParcelsPerEdge;
353	U8*							mHighlightSegments;
354	U8*							mAgentParcelOverlay;
355
356	// Raw data buffer for unpacking parcel overlay chunks
357	// Size = parcels_per_edge * parcels_per_edge / parcel_overlay_chunks
358	static U8*					sPackedOverlay;
359
360	// Watch for pending collisions with a parcel you can't access.
361	// If it's coming, draw the parcel's boundaries.
362	LLParcel*					mCollisionParcel;
363	U8*							mCollisionSegments;
364	BOOL						mRenderCollision; 
365	BOOL						mRenderSelection;
366	S32							mCollisionBanned;     
367	LLFrameTimer				mCollisionTimer;
368	LLViewerTexture*			mBlockedImage;
369	LLViewerTexture*			mPassImage;
370
371	// Media
372	S32 						mMediaParcelId;
373	U64 						mMediaRegionId;
374};
375
376
377void sanitize_corners(const LLVector3d &corner1, const LLVector3d &corner2,
378						LLVector3d &west_south_bottom, LLVector3d &east_north_top);
379
380#endif