llviewerparcelmgr.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLVIEWERPARCELMGR_H
00033 #define LL_LLVIEWERPARCELMGR_H
00034 
00035 #include "v3dmath.h"
00036 #include "lldarray.h"
00037 #include "llframetimer.h"
00038 #include "llmemory.h"
00039 #include "llviewerimage.h"
00040 
00041 class LLUUID;
00042 class LLMessageSystem;
00043 class LLParcel;
00044 class LLViewerRegion;
00045 
00046 // Constants for sendLandOwner
00047 //const U32 NO_NEIGHBOR_JOIN = 0x0;
00048 //const U32 ALL_NEIGHBOR_JOIN = U32(  NORTH_MASK 
00049 //                                                        | SOUTH_MASK 
00050 //                                                        | EAST_MASK 
00051 //                                                        | WEST_MASK);
00052 
00053 const F32 PARCEL_POST_HEIGHT = 0.666f;
00054 //const F32 PARCEL_POST_HEIGHT = 20.f;
00055 
00056 // Specify the type of land transfer taking place
00057 //enum ELandTransferType
00058 //{
00059 //      LTT_RELEASE_LAND = 0x1,
00060 //      LTT_CLAIM_LAND = 0x2,
00061 //      LTT_BUY_LAND = 0x4,
00062 //      LTT_DEED_LAND = 0x8,
00063 //      LTT_FOR_GROUP = 0x16
00064 //};
00065 
00066 // Base class for people who want to "observe" changes in the viewer
00067 // parcel selection.
00068 class LLParcelObserver
00069 {
00070 public:
00071         virtual ~LLParcelObserver() {};
00072         virtual void changed() = 0;
00073 };
00074 
00075 class LLParcelSelection : public LLRefCount
00076 {
00077         friend class LLViewerParcelMgr;
00078 
00079 protected:
00080         ~LLParcelSelection();
00081 
00082 public:
00083         LLParcelSelection(LLParcel* parcel);
00084         LLParcelSelection();
00085 
00086         // this can return NULL at any time, as parcel selection
00087         // might have been invalidated.
00088         LLParcel* getParcel() { return mParcel; }
00089 
00090         // Return the number of grid units that are owned by you within
00091         // the selection (computed by server).
00092         S32 getSelfCount() const { return mSelectedSelfCount; }
00093 
00094         // Returns area that will actually be claimed in meters squared.
00095         S32             getClaimableArea() const;
00096         bool    hasOthersSelected() const;
00097 
00098         // Does the selection have multiple land owners in it?
00099         BOOL    getMultipleOwners() const;
00100 
00101         // Is the entire parcel selected, or just a part?
00102         BOOL    getWholeParcelSelected() const;
00103 
00104 protected:
00105         void setParcel(LLParcel* parcel) { mParcel = parcel; }
00106 
00107 protected:
00108 
00109         LLParcel*       mParcel;
00110         BOOL            mSelectedMultipleOwners;
00111         BOOL            mWholeParcelSelected;
00112         S32                     mSelectedSelfCount;
00113         S32                     mSelectedOtherCount;
00114         S32                     mSelectedPublicCount;
00115 };
00116 
00117 typedef LLHandle<LLParcelSelection> LLParcelSelectionHandle;
00118 
00119 class LLViewerParcelMgr
00120 {
00121 
00122 public:
00123         LLViewerParcelMgr();
00124         ~LLViewerParcelMgr();
00125 
00126         static void cleanupGlobals();
00127 
00128         BOOL    selectionEmpty() const;
00129         F32             getSelectionWidth() const       { return F32(mEastNorth.mdV[VX] - mWestSouth.mdV[VX]); }
00130         F32             getSelectionHeight() const      { return F32(mEastNorth.mdV[VY] - mWestSouth.mdV[VY]); }
00131         BOOL    getSelection(LLVector3d &min, LLVector3d &max) { min = mWestSouth; max = mEastNorth; return !selectionEmpty();}
00132         LLViewerRegion* getSelectionRegion();
00133         F32             getDwelling() const { return mSelectedDwell;}
00134 
00135         void    getDisplayInfo(S32* area, S32* claim, S32* rent, BOOL* for_sale, F32* dwell);
00136 
00137         void    getPrimInfo(S32 &sw_max, S32 &sw_total, S32 &max, S32 &total, S32 &owner, S32 &group, S32 &other, S32& selected, F32 &parcel_object_bonus, S32 &other_clean);
00138 
00139         // Returns selected area
00140         S32 getSelectedArea() const;
00141 
00142         void resetSegments(U8* segments);
00143 
00144         // write a rectangle's worth of line segments into the highlight array
00145         void writeHighlightSegments(F32 west, F32 south, F32 east, F32 north);
00146 
00147         // Write highlight segments from a packed bitmap of the appropriate
00148         // parcel.
00149         void writeSegmentsFromBitmap(U8* bitmap, U8* segments);
00150 
00151         void writeAgentParcelFromBitmap(U8* bitmap);
00152 
00153         // Select the collision parcel
00154         void selectCollisionParcel();
00155 
00156         // Select the parcel at a specific point
00157         LLHandle<LLParcelSelection> selectParcelAt(const LLVector3d& pos_global);
00158 
00159         // Take the current rectangle select, and select the parcel contained
00160         // within it.
00161         LLParcelSelectionHandle selectParcelInRectangle();
00162 
00163         // Select a piece of land
00164         LLParcelSelectionHandle selectLand(const LLVector3d &corner1, const LLVector3d &corner2, 
00165                                            BOOL snap_to_parcel);
00166 
00167         // Clear the selection, and stop drawing the highlight.
00168         void    deselectLand();
00169         void    deselectUnused();
00170 
00171         void addObserver(LLParcelObserver* observer);
00172         void removeObserver(LLParcelObserver* observer);
00173         void notifyObservers();
00174 
00175         void setSelectionVisible(BOOL visible) { mRenderSelection = visible; }
00176 
00177         BOOL    isOwnedAt(const LLVector3d& pos_global) const;
00178         BOOL    isOwnedSelfAt(const LLVector3d& pos_global) const;
00179         BOOL    isOwnedOtherAt(const LLVector3d& pos_global) const;
00180         BOOL    isSoundLocal(const LLVector3d &pos_global) const;
00181 
00182         BOOL    canHearSound(const LLVector3d &pos_global) const;
00183 
00184         // Returns a reference counted pointer to current parcel selection.  
00185         // Selection does not change to reflect new selections made by user
00186         // Use this when implementing a task UI that refers to a specific
00187         // selection.
00188         LLParcelSelectionHandle getParcelSelection() const;
00189 
00190         // Returns a reference counted pointer to current parcel selection.
00191         // Pointer tracks whatever the user has currently selected.
00192         // Use this when implementing an inspector UI.
00193         // http://en.wikipedia.org/wiki/Inspector_window
00194         LLParcelSelectionHandle getFloatingParcelSelection() const;
00195 
00196         //LLParcel *getParcelSelection() const;
00197         LLParcel *getAgentParcel() const;
00198 
00199         BOOL    inAgentParcel(const LLVector3d &pos_global) const;
00200 
00201         // Returns a pointer only when it has valid data.
00202         LLParcel*       getHoverParcel() const;
00203 
00204         LLParcel*       getCollisionParcel() const;
00205 
00206         BOOL    agentCanTakeDamage() const;
00207         BOOL    agentCanFly() const;
00208         F32             agentDrawDistance() const;
00209         BOOL    agentCanBuild() const;
00210 
00211         F32             getHoverParcelWidth() const             
00212                                 { return F32(mHoverEastNorth.mdV[VX] - mHoverWestSouth.mdV[VX]); }
00213 
00214         F32             getHoverParcelHeight() const
00215                                 { return F32(mHoverEastNorth.mdV[VY] - mHoverWestSouth.mdV[VY]); }
00216 
00217         // UTILITIES
00218         void    render();
00219         void    renderParcelCollision();
00220 
00221         void    renderRect(     const LLVector3d &west_south_bottom, 
00222                                                 const LLVector3d &east_north_top );
00223         void    renderOneSegment(F32 x1, F32 y1, F32 x2, F32 y2, F32 height, U8 direction, LLViewerRegion* regionp);
00224         void    renderHighlightSegments(const U8* segments, LLViewerRegion* regionp);
00225         void    renderCollisionSegments(U8* segments, BOOL use_pass, LLViewerRegion* regionp);
00226 
00227         void    sendParcelGodForceOwner(const LLUUID& owner_id);
00228 
00229         // make the selected parcel a content parcel. 
00230         void sendParcelGodForceToContent();
00231 
00232         // Pack information about this parcel and send it to the region
00233         // containing the southwest corner of the selection.
00234         // If want_reply_to_update, simulator will send back a ParcelProperties
00235         // message.
00236         void    sendParcelPropertiesUpdate(LLParcel* parcel);
00237 
00238         // Takes an Access List flag, like AL_ACCESS or AL_BAN
00239         void    sendParcelAccessListUpdate(U32 which);
00240 
00241         // Takes an Access List flag, like AL_ACCESS or AL_BAN
00242         void    sendParcelAccessListRequest(U32 flags);
00243 
00244         // Dwell is not part of the usual parcel update information because the
00245         // simulator doesn't actually know the per-parcel dwell.  Ack!  We have
00246         // to get it out of the database.
00247         void    sendParcelDwellRequest();
00248 
00249         // If the point is outside the current hover parcel, request more data
00250         void    requestHoverParcelProperties(const LLVector3d& pos_global);
00251 
00252         bool    canAgentBuyParcel(LLParcel*, bool forGroup) const;
00253         
00254 //      void    startClaimLand(BOOL is_for_group = FALSE);
00255         void    startBuyLand(BOOL is_for_group = FALSE);
00256         void    startSellLand();
00257         void    startReleaseLand();
00258         void    startDivideLand();
00259         void    startJoinLand();
00260         void    startDeedLandToGroup();
00261         void reclaimParcel();
00262 
00263         void    buyPass();
00264 
00265         // Buying Land
00266         
00267         class ParcelBuyInfo;
00268         ParcelBuyInfo* setupParcelBuy(const LLUUID& agent_id,
00269                                                                   const LLUUID& session_id,                                              
00270                                                                   const LLUUID& group_id,
00271                                                                   BOOL is_group_owned,
00272                                                                   BOOL is_claim,
00273                                                                   BOOL remove_contribution);
00274                 // callers responsibility to call deleteParcelBuy() on return value
00275         void sendParcelBuy(ParcelBuyInfo*);
00276         void deleteParcelBuy(ParcelBuyInfo*&);
00277                                            
00278         void sendParcelDeed(const LLUUID& group_id);
00279 
00280         // Send the ParcelRelease message
00281         void sendParcelRelease();
00282 
00283         // accessors for mAgentParcel
00284         const LLString& getAgentParcelName() const;
00285 
00286         // Create a landmark at the "appropriate" location for the
00287         // currently selected parcel.
00288         // *NOTE: Taken out 2005-03-21. Phoenix.
00289         //void makeLandmarkAtSelection();
00290 
00291         static void processParcelOverlay(LLMessageSystem *msg, void **user_data);
00292         static void processParcelProperties(LLMessageSystem *msg, void **user_data);
00293         static void processParcelAccessListReply(LLMessageSystem *msg, void **user);
00294         static void processParcelDwellReply(LLMessageSystem *msg, void **user);
00295 
00296         void dump();
00297 
00298         // Whether or not the collision border around the parcel is there because
00299         // the agent is banned or not in the allowed group
00300         BOOL isCollisionBanned();
00301 
00302         static BOOL isParcelOwnedByAgent(const LLParcel* parcelp, U64 group_proxy_power);
00303         static BOOL isParcelModifiableByAgent(const LLParcel* parcelp, U64 group_proxy_power);
00304 
00305 protected:
00306         static void releaseAlertCB(S32 option, void *data);
00307 
00308         // If the user is claiming land and the current selection 
00309         // borders a piece of land the user already owns, ask if he
00310         // wants to join this land to the other piece.
00311         //void  askJoinIfNecessary(ELandTransferType land_transfer_type);
00312         //static void joinAlertCB(S32 option, void* data);
00313 
00314         //void buyAskMoney(ELandTransferType land_transfer_type);
00315 
00316         // move land from current owner to it's group.
00317         void deedLandToGroup();
00318 
00319         static void claimAlertCB(S32 option, void* data);
00320         static void buyAlertCB(S32 option, void* data);
00321         static void deedAlertCB(S32 option, void*);
00322 
00323         static void callbackDivideLand(S32 option, void* data);
00324         static void callbackJoinLand(S32 option, void* data);
00325 
00326         //void  finishClaim(BOOL user_to_user_sale, U32 join);
00327 
00328 private:
00329         BOOL                                            mSelected;
00330 
00331         LLParcel*                                       mCurrentParcel;                 // selected parcel info
00332         LLParcelSelectionHandle         mCurrentParcelSelection;
00333         LLParcelSelectionHandle         mFloatingParcelSelection;
00334         S32                                                     mRequestResult;         // result of last parcel request
00335         LLVector3d                                      mWestSouth;
00336         LLVector3d                                      mEastNorth;
00337         F32                                                     mSelectedDwell;
00338 
00339         LLParcel                                        *mAgentParcel;          // info for parcel agent is in
00340         S32                                                     mAgentParcelSequenceID; // incrementing counter to suppress out of order updates
00341 
00342         LLParcel*                                       mHoverParcel;
00343         S32                                                     mHoverRequestResult;
00344         LLVector3d                                      mHoverWestSouth;
00345         LLVector3d                                      mHoverEastNorth;
00346 
00347         LLDynamicArray<LLParcelObserver*> mObservers;
00348 
00349         // Array of pieces of parcel edges to potentially draw
00350         // Has (parcels_per_edge + 1) * (parcels_per_edge + 1) elements so
00351         // we can represent edges of the grid.
00352         // WEST_MASK = draw west edge
00353         // SOUTH_MASK = draw south edge
00354         S32                                                     mParcelsPerEdge;
00355         U8*                                                     mHighlightSegments;
00356         U8*                                                     mAgentParcelOverlay;
00357 
00358         // Raw data buffer for unpacking parcel overlay chunks
00359         // Size = parcels_per_edge * parcels_per_edge / parcel_overlay_chunks
00360         static U8*                                      sPackedOverlay;
00361 
00362         // Watch for pending collisions with a parcel you can't access.
00363         // If it's coming, draw the parcel's boundaries.
00364         LLParcel*                                       mCollisionParcel;
00365         U8*                                                     mCollisionSegments;
00366         BOOL                                            mRenderCollision; 
00367         BOOL                                            mRenderSelection;
00368         S32                                                     mCollisionBanned;     
00369         LLFrameTimer                            mCollisionTimer;
00370         LLUUID                                          mBlockedImageID;
00371         LLUUID                                          mPassImageID;
00372         LLPointer<LLViewerImage>        mBlockedImage;
00373         LLPointer<LLViewerImage>        mPassImage;
00374 
00375         // Media
00376         S32                                             mMediaParcelId;
00377         U64                                             mMediaRegionId;
00378 };
00379 
00380 extern LLViewerParcelMgr *gParcelMgr;
00381 
00382 void sanitize_corners(const LLVector3d &corner1, const LLVector3d &corner2,
00383                                                 LLVector3d &west_south_bottom, LLVector3d &east_north_top);
00384 
00385 #endif

Generated on Thu Jul 1 06:09:33 2010 for Second Life Viewer by  doxygen 1.4.7