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
00047
00048
00049
00050
00051
00052
00053 const F32 PARCEL_POST_HEIGHT = 0.666f;
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
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
00087
00088 LLParcel* getParcel() { return mParcel; }
00089
00090
00091
00092 S32 getSelfCount() const { return mSelectedSelfCount; }
00093
00094
00095 S32 getClaimableArea() const;
00096 bool hasOthersSelected() const;
00097
00098
00099 BOOL getMultipleOwners() const;
00100
00101
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
00140 S32 getSelectedArea() const;
00141
00142 void resetSegments(U8* segments);
00143
00144
00145 void writeHighlightSegments(F32 west, F32 south, F32 east, F32 north);
00146
00147
00148
00149 void writeSegmentsFromBitmap(U8* bitmap, U8* segments);
00150
00151 void writeAgentParcelFromBitmap(U8* bitmap);
00152
00153
00154 void selectCollisionParcel();
00155
00156
00157 LLHandle<LLParcelSelection> selectParcelAt(const LLVector3d& pos_global);
00158
00159
00160
00161 LLParcelSelectionHandle selectParcelInRectangle();
00162
00163
00164 LLParcelSelectionHandle selectLand(const LLVector3d &corner1, const LLVector3d &corner2,
00165 BOOL snap_to_parcel);
00166
00167
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
00185
00186
00187
00188 LLParcelSelectionHandle getParcelSelection() const;
00189
00190
00191
00192
00193
00194 LLParcelSelectionHandle getFloatingParcelSelection() const;
00195
00196
00197 LLParcel *getAgentParcel() const;
00198
00199 BOOL inAgentParcel(const LLVector3d &pos_global) const;
00200
00201
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
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
00230 void sendParcelGodForceToContent();
00231
00232
00233
00234
00235
00236 void sendParcelPropertiesUpdate(LLParcel* parcel);
00237
00238
00239 void sendParcelAccessListUpdate(U32 which);
00240
00241
00242 void sendParcelAccessListRequest(U32 flags);
00243
00244
00245
00246
00247 void sendParcelDwellRequest();
00248
00249
00250 void requestHoverParcelProperties(const LLVector3d& pos_global);
00251
00252 bool canAgentBuyParcel(LLParcel*, bool forGroup) const;
00253
00254
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
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
00275 void sendParcelBuy(ParcelBuyInfo*);
00276 void deleteParcelBuy(ParcelBuyInfo*&);
00277
00278 void sendParcelDeed(const LLUUID& group_id);
00279
00280
00281 void sendParcelRelease();
00282
00283
00284 const LLString& getAgentParcelName() const;
00285
00286
00287
00288
00289
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
00299
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
00309
00310
00311
00312
00313
00314
00315
00316
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
00327
00328 private:
00329 BOOL mSelected;
00330
00331 LLParcel* mCurrentParcel;
00332 LLParcelSelectionHandle mCurrentParcelSelection;
00333 LLParcelSelectionHandle mFloatingParcelSelection;
00334 S32 mRequestResult;
00335 LLVector3d mWestSouth;
00336 LLVector3d mEastNorth;
00337 F32 mSelectedDwell;
00338
00339 LLParcel *mAgentParcel;
00340 S32 mAgentParcelSequenceID;
00341
00342 LLParcel* mHoverParcel;
00343 S32 mHoverRequestResult;
00344 LLVector3d mHoverWestSouth;
00345 LLVector3d mHoverEastNorth;
00346
00347 LLDynamicArray<LLParcelObserver*> mObservers;
00348
00349
00350
00351
00352
00353
00354 S32 mParcelsPerEdge;
00355 U8* mHighlightSegments;
00356 U8* mAgentParcelOverlay;
00357
00358
00359
00360 static U8* sPackedOverlay;
00361
00362
00363
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
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