/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

  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. #ifndef LL_LLVIEWERPARCELMGR_H
  27. #define LL_LLVIEWERPARCELMGR_H
  28. #include "v3dmath.h"
  29. #include "lldarray.h"
  30. #include "llframetimer.h"
  31. #include "llsingleton.h"
  32. #include "llparcelselection.h"
  33. #include "llui.h"
  34. #include <boost/function.hpp>
  35. #include <boost/signals2.hpp>
  36. class LLUUID;
  37. class LLMessageSystem;
  38. class LLParcel;
  39. class LLViewerTexture;
  40. class LLViewerRegion;
  41. const F32 DWELL_NAN = -1.0f; // A dwell having this value will be displayed as Loading...
  42. // Constants for sendLandOwner
  43. //const U32 NO_NEIGHBOR_JOIN = 0x0;
  44. //const U32 ALL_NEIGHBOR_JOIN = U32( NORTH_MASK
  45. // | SOUTH_MASK
  46. // | EAST_MASK
  47. // | WEST_MASK);
  48. // Specify the type of land transfer taking place
  49. //enum ELandTransferType
  50. //{
  51. // LTT_RELEASE_LAND = 0x1,
  52. // LTT_CLAIM_LAND = 0x2,
  53. // LTT_BUY_LAND = 0x4,
  54. // LTT_DEED_LAND = 0x8,
  55. // LTT_FOR_GROUP = 0x16
  56. //};
  57. // Base class for people who want to "observe" changes in the viewer
  58. // parcel selection.
  59. //FIXME: this should be done by grabbing a floating parcel selection and observing changes on it, not the parcel mgr
  60. //--RN
  61. class LLParcelObserver
  62. {
  63. public:
  64. virtual ~LLParcelObserver() {};
  65. virtual void changed() = 0;
  66. };
  67. class LLViewerParcelMgr : public LLSingleton<LLViewerParcelMgr>
  68. {
  69. public:
  70. typedef boost::function<void (const LLVector3d&)> teleport_finished_callback_t;
  71. typedef boost::signals2::signal<void (const LLVector3d&)> teleport_finished_signal_t;
  72. typedef boost::function<void()> parcel_changed_callback_t;
  73. typedef boost::signals2::signal<void()> parcel_changed_signal_t;
  74. LLViewerParcelMgr();
  75. ~LLViewerParcelMgr();
  76. static void cleanupGlobals();
  77. BOOL selectionEmpty() const;
  78. F32 getSelectionWidth() const { return F32(mEastNorth.mdV[VX] - mWestSouth.mdV[VX]); }
  79. F32 getSelectionHeight() const { return F32(mEastNorth.mdV[VY] - mWestSouth.mdV[VY]); }
  80. BOOL getSelection(LLVector3d &min, LLVector3d &max) { min = mWestSouth; max = mEastNorth; return !selectionEmpty();}
  81. LLViewerRegion* getSelectionRegion();
  82. F32 getDwelling() const { return mSelectedDwell;}
  83. void getDisplayInfo(S32* area, S32* claim, S32* rent, BOOL* for_sale, F32* dwell);
  84. // Returns selected area
  85. S32 getSelectedArea() const;
  86. void resetSegments(U8* segments);
  87. // write a rectangle's worth of line segments into the highlight array
  88. void writeHighlightSegments(F32 west, F32 south, F32 east, F32 north);
  89. // Write highlight segments from a packed bitmap of the appropriate
  90. // parcel.
  91. void writeSegmentsFromBitmap(U8* bitmap, U8* segments);
  92. void writeAgentParcelFromBitmap(U8* bitmap);
  93. // Select the collision parcel
  94. void selectCollisionParcel();
  95. // Select the parcel at a specific point
  96. LLParcelSelectionHandle selectParcelAt(const LLVector3d& pos_global);
  97. // Take the current rectangle select, and select the parcel contained
  98. // within it.
  99. LLParcelSelectionHandle selectParcelInRectangle();
  100. // Select a piece of land
  101. LLParcelSelectionHandle selectLand(const LLVector3d &corner1, const LLVector3d &corner2,
  102. BOOL snap_to_parcel);
  103. // Clear the selection, and stop drawing the highlight.
  104. void deselectLand();
  105. void deselectUnused();
  106. void addObserver(LLParcelObserver* observer);
  107. void removeObserver(LLParcelObserver* observer);
  108. void notifyObservers();
  109. void setSelectionVisible(BOOL visible) { mRenderSelection = visible; }
  110. BOOL isOwnedAt(const LLVector3d& pos_global) const;
  111. BOOL isOwnedSelfAt(const LLVector3d& pos_global) const;
  112. BOOL isOwnedOtherAt(const LLVector3d& pos_global) const;
  113. BOOL isSoundLocal(const LLVector3d &pos_global) const;
  114. BOOL canHearSound(const LLVector3d &pos_global) const;
  115. // Returns a reference counted pointer to current parcel selection.
  116. // Selection does not change to reflect new selections made by user
  117. // Use this when implementing a task UI that refers to a specific
  118. // selection.
  119. LLParcelSelectionHandle getParcelSelection() const;
  120. // Returns a reference counted pointer to current parcel selection.
  121. // Pointer tracks whatever the user has currently selected.
  122. // Use this when implementing an inspector UI.
  123. // http://en.wikipedia.org/wiki/Inspector_window
  124. LLParcelSelectionHandle getFloatingParcelSelection() const;
  125. //LLParcel *getParcelSelection() const;
  126. LLParcel *getAgentParcel() const;
  127. BOOL inAgentParcel(const LLVector3d &pos_global) const;
  128. // Returns a pointer only when it has valid data.
  129. LLParcel* getHoverParcel() const;
  130. LLParcel* getCollisionParcel() const;
  131. // Can this agent build on the parcel he is on?
  132. // Used for parcel property icons in nav bar.
  133. bool allowAgentBuild() const;
  134. bool allowAgentBuild(const LLParcel* parcel) const;
  135. // Can this agent speak on the parcel he is on?
  136. // Used for parcel property icons in nav bar.
  137. bool allowAgentVoice() const;
  138. bool allowAgentVoice(const LLViewerRegion* region, const LLParcel* parcel) const;
  139. // Can this agent start flying on this parcel?
  140. // Used for parcel property icons in nav bar.
  141. bool allowAgentFly(const LLViewerRegion* region, const LLParcel* parcel) const;
  142. // Can this agent be pushed by llPushObject() on this parcel?
  143. // Used for parcel property icons in nav bar.
  144. bool allowAgentPush(const LLViewerRegion* region, const LLParcel* parcel) const;
  145. // Can scripts written by non-parcel-owners run on the agent's current
  146. // parcel? Used for parcel property icons in nav bar.
  147. bool allowAgentScripts(const LLViewerRegion* region, const LLParcel* parcel) const;
  148. // Can the agent be damaged here?
  149. // Used for parcel property icons in nav bar.
  150. bool allowAgentDamage(const LLViewerRegion* region, const LLParcel* parcel) const;
  151. F32 getHoverParcelWidth() const
  152. { return F32(mHoverEastNorth.mdV[VX] - mHoverWestSouth.mdV[VX]); }
  153. F32 getHoverParcelHeight() const
  154. { return F32(mHoverEastNorth.mdV[VY] - mHoverWestSouth.mdV[VY]); }
  155. // UTILITIES
  156. void render();
  157. void renderParcelCollision();
  158. void renderRect( const LLVector3d &west_south_bottom,
  159. const LLVector3d &east_north_top );
  160. void renderOneSegment(F32 x1, F32 y1, F32 x2, F32 y2, F32 height, U8 direction, LLViewerRegion* regionp);
  161. void renderHighlightSegments(const U8* segments, LLViewerRegion* regionp);
  162. void renderCollisionSegments(U8* segments, BOOL use_pass, LLViewerRegion* regionp);
  163. void sendParcelGodForceOwner(const LLUUID& owner_id);
  164. // make the selected parcel a content parcel.
  165. void sendParcelGodForceToContent();
  166. // Pack information about this parcel and send it to the region
  167. // containing the southwest corner of the selection.
  168. // If want_reply_to_update, simulator will send back a ParcelProperties
  169. // message.
  170. void sendParcelPropertiesUpdate(LLParcel* parcel, bool use_agent_region = false);
  171. // Takes an Access List flag, like AL_ACCESS or AL_BAN
  172. void sendParcelAccessListUpdate(U32 which);
  173. // Takes an Access List flag, like AL_ACCESS or AL_BAN
  174. void sendParcelAccessListRequest(U32 flags);
  175. // asks for the parcel's media url filter list
  176. void requestParcelMediaURLFilter();
  177. // receive the response
  178. void receiveParcelMediaURLFilter(const LLSD &content);
  179. // Dwell is not part of the usual parcel update information because the
  180. // simulator doesn't actually know the per-parcel dwell. Ack! We have
  181. // to get it out of the database.
  182. void sendParcelDwellRequest();
  183. // If the point is outside the current hover parcel, request more data
  184. void setHoverParcel(const LLVector3d& pos_global);
  185. bool canAgentBuyParcel(LLParcel*, bool forGroup) const;
  186. // void startClaimLand(BOOL is_for_group = FALSE);
  187. void startBuyLand(BOOL is_for_group = FALSE);
  188. void startSellLand();
  189. void startReleaseLand();
  190. void startDivideLand();
  191. void startJoinLand();
  192. void startDeedLandToGroup();
  193. void reclaimParcel();
  194. void buyPass();
  195. // Buying Land
  196. class ParcelBuyInfo;
  197. ParcelBuyInfo* setupParcelBuy(const LLUUID& agent_id,
  198. const LLUUID& session_id,
  199. const LLUUID& group_id,
  200. BOOL is_group_owned,
  201. BOOL is_claim,
  202. BOOL remove_contribution);
  203. // callers responsibility to call deleteParcelBuy() on return value
  204. void sendParcelBuy(ParcelBuyInfo*);
  205. void deleteParcelBuy(ParcelBuyInfo* *info);
  206. void sendParcelDeed(const LLUUID& group_id);
  207. // Send the ParcelRelease message
  208. void sendParcelRelease();
  209. // accessors for mAgentParcel
  210. const std::string& getAgentParcelName() const;
  211. // Create a landmark at the "appropriate" location for the
  212. // currently selected parcel.
  213. // *NOTE: Taken out 2005-03-21. Phoenix.
  214. //void makeLandmarkAtSelection();
  215. static void processParcelOverlay(LLMessageSystem *msg, void **user_data);
  216. static void processParcelProperties(LLMessageSystem *msg, void **user_data);
  217. static void processParcelAccessListReply(LLMessageSystem *msg, void **user);
  218. static void processParcelDwellReply(LLMessageSystem *msg, void **user);
  219. void dump();
  220. // Whether or not the collision border around the parcel is there because
  221. // the agent is banned or not in the allowed group
  222. BOOL isCollisionBanned();
  223. boost::signals2::connection addAgentParcelChangedCallback(parcel_changed_callback_t cb);
  224. boost::signals2::connection setTeleportFinishedCallback(teleport_finished_callback_t cb);
  225. boost::signals2::connection setTeleportFailedCallback(parcel_changed_callback_t cb);
  226. void onTeleportFinished(bool local, const LLVector3d& new_pos);
  227. void onTeleportFailed();
  228. static BOOL isParcelOwnedByAgent(const LLParcel* parcelp, U64 group_proxy_power);
  229. static BOOL isParcelModifiableByAgent(const LLParcel* parcelp, U64 group_proxy_power);
  230. private:
  231. static bool releaseAlertCB(const LLSD& notification, const LLSD& response);
  232. // If the user is claiming land and the current selection
  233. // borders a piece of land the user already owns, ask if he
  234. // wants to join this land to the other piece.
  235. //void askJoinIfNecessary(ELandTransferType land_transfer_type);
  236. //static void joinAlertCB(S32 option, void* data);
  237. //void buyAskMoney(ELandTransferType land_transfer_type);
  238. // move land from current owner to it's group.
  239. void deedLandToGroup();
  240. static bool deedAlertCB(const LLSD& notification, const LLSD& response);
  241. static bool callbackDivideLand(const LLSD& notification, const LLSD& response);
  242. static bool callbackJoinLand(const LLSD& notification, const LLSD& response);
  243. //void finishClaim(BOOL user_to_user_sale, U32 join);
  244. LLViewerTexture* getBlockedImage() const;
  245. LLViewerTexture* getPassImage() const;
  246. private:
  247. BOOL mSelected;
  248. LLParcel* mCurrentParcel; // selected parcel info
  249. LLParcelSelectionHandle mCurrentParcelSelection;
  250. LLParcelSelectionHandle mFloatingParcelSelection;
  251. S32 mRequestResult; // result of last parcel request
  252. LLVector3d mWestSouth;
  253. LLVector3d mEastNorth;
  254. F32 mSelectedDwell;
  255. LLParcel *mAgentParcel; // info for parcel agent is in
  256. S32 mAgentParcelSequenceID; // incrementing counter to suppress out of order updates
  257. LLParcel* mHoverParcel;
  258. S32 mHoverRequestResult;
  259. LLVector3d mHoverWestSouth;
  260. LLVector3d mHoverEastNorth;
  261. LLDynamicArray<LLParcelObserver*> mObservers;
  262. BOOL mTeleportInProgress;
  263. teleport_finished_signal_t mTeleportFinishedSignal;
  264. parcel_changed_signal_t mTeleportFailedSignal;
  265. parcel_changed_signal_t mAgentParcelChangedSignal;
  266. // Array of pieces of parcel edges to potentially draw
  267. // Has (parcels_per_edge + 1) * (parcels_per_edge + 1) elements so
  268. // we can represent edges of the grid.
  269. // WEST_MASK = draw west edge
  270. // SOUTH_MASK = draw south edge
  271. S32 mParcelsPerEdge;
  272. U8* mHighlightSegments;
  273. U8* mAgentParcelOverlay;
  274. // Raw data buffer for unpacking parcel overlay chunks
  275. // Size = parcels_per_edge * parcels_per_edge / parcel_overlay_chunks
  276. static U8* sPackedOverlay;
  277. // Watch for pending collisions with a parcel you can't access.
  278. // If it's coming, draw the parcel's boundaries.
  279. LLParcel* mCollisionParcel;
  280. U8* mCollisionSegments;
  281. BOOL mRenderCollision;
  282. BOOL mRenderSelection;
  283. S32 mCollisionBanned;
  284. LLFrameTimer mCollisionTimer;
  285. LLViewerTexture* mBlockedImage;
  286. LLViewerTexture* mPassImage;
  287. // Media
  288. S32 mMediaParcelId;
  289. U64 mMediaRegionId;
  290. };
  291. void sanitize_corners(const LLVector3d &corner1, const LLVector3d &corner2,
  292. LLVector3d &west_south_bottom, LLVector3d &east_north_top);
  293. #endif