PageRenderTime 44ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llinventory/llparcel.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 1375 lines | 1070 code | 155 blank | 150 comment | 166 complexity | a55df9cf061afce071d966d52c4d65e5 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llparcel.cpp
  3. * @brief A land parcel.
  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. #include "linden_common.h"
  27. #include "indra_constants.h"
  28. #include <iostream>
  29. #include "llparcel.h"
  30. #include "llstreamtools.h"
  31. #include "llmath.h"
  32. #include "llsd.h"
  33. #include "llsdutil.h"
  34. #include "lltransactiontypes.h"
  35. #include "lltransactionflags.h"
  36. #include "llsdutil_math.h"
  37. #include "message.h"
  38. #include "u64.h"
  39. static const F32 SOME_BIG_NUMBER = 1000.0f;
  40. static const F32 SOME_BIG_NEG_NUMBER = -1000.0f;
  41. static const std::string PARCEL_OWNERSHIP_STATUS_STRING[LLParcel::OS_COUNT+1] =
  42. {
  43. "leased",
  44. "lease_pending",
  45. "abandoned",
  46. "none"
  47. };
  48. // NOTE: Adding parcel categories also requires updating:
  49. // * floater_about_land.xml category combobox
  50. // * Web site "create event" tools
  51. // DO NOT DELETE ITEMS FROM THIS LIST WITHOUT DEEPLY UNDERSTANDING WHAT YOU'RE DOING.
  52. //
  53. static const std::string PARCEL_CATEGORY_STRING[LLParcel::C_COUNT] =
  54. {
  55. "none",
  56. "linden",
  57. "adult",
  58. "arts",
  59. "store", // "business" legacy name
  60. "educational",
  61. "game", // "gaming" legacy name
  62. "gather", // "hangout" legacy name
  63. "newcomer",
  64. "park",
  65. "home", // "residential" legacy name
  66. "shopping",
  67. "stage",
  68. "other",
  69. "rental"
  70. };
  71. static const std::string PARCEL_CATEGORY_UI_STRING[LLParcel::C_COUNT + 1] =
  72. {
  73. "None",
  74. "Linden Location",
  75. "Adult",
  76. "Arts and Culture",
  77. "Business",
  78. "Educational",
  79. "Gaming",
  80. "Hangout",
  81. "Newcomer Friendly",
  82. "Parks and Nature",
  83. "Residential",
  84. "Shopping",
  85. "Stage",
  86. "Other",
  87. "Rental",
  88. "Any", // valid string for parcel searches
  89. };
  90. static const std::string PARCEL_ACTION_STRING[LLParcel::A_COUNT + 1] =
  91. {
  92. "create",
  93. "release",
  94. "absorb",
  95. "absorbed",
  96. "divide",
  97. "division",
  98. "acquire",
  99. "relinquish",
  100. "confirm",
  101. "unknown"
  102. };
  103. //const char* revert_action_to_string(LLParcel::ESaleTimerExpireAction action);
  104. //LLParcel::ESaleTimerExpireAction revert_string_to_action(const char* s);
  105. const std::string& category_to_ui_string(LLParcel::ECategory category);
  106. LLParcel::ECategory category_ui_string_to_category(const std::string& s);
  107. LLParcel::LLParcel()
  108. {
  109. init(LLUUID::null, TRUE, FALSE, FALSE, 0, 0, 0, 0, 0, 1.f, 0);
  110. }
  111. LLParcel::LLParcel(const LLUUID &owner_id,
  112. BOOL modify, BOOL terraform, BOOL damage,
  113. time_t claim_date, S32 claim_price_per_meter,
  114. S32 rent_price_per_meter, S32 area, S32 sim_object_limit, F32 parcel_object_bonus,
  115. BOOL is_group_owned)
  116. {
  117. init( owner_id, modify, terraform, damage, claim_date,
  118. claim_price_per_meter, rent_price_per_meter, area, sim_object_limit, parcel_object_bonus,
  119. is_group_owned);
  120. }
  121. // virtual
  122. LLParcel::~LLParcel()
  123. {
  124. // user list cleaned up by LLDynamicArray destructor.
  125. }
  126. void LLParcel::init(const LLUUID &owner_id,
  127. BOOL modify, BOOL terraform, BOOL damage,
  128. time_t claim_date, S32 claim_price_per_meter,
  129. S32 rent_price_per_meter, S32 area, S32 sim_object_limit, F32 parcel_object_bonus,
  130. BOOL is_group_owned)
  131. {
  132. mID.setNull();
  133. mOwnerID = owner_id;
  134. mGroupOwned = is_group_owned;
  135. mClaimDate = claim_date;
  136. mClaimPricePerMeter = claim_price_per_meter;
  137. mRentPricePerMeter = rent_price_per_meter;
  138. mArea = area;
  139. mDiscountRate = 1.0f;
  140. mDrawDistance = 512.f;
  141. mUserLookAt.setVec(0.0f, 0.f, 0.f);
  142. // Default to using the parcel's landing point, if any.
  143. mLandingType = L_LANDING_POINT;
  144. // *FIX: if owner_id != null, should be owned or sale pending,
  145. // investigate init callers.
  146. mStatus = OS_NONE;
  147. mCategory = C_NONE;
  148. mAuthBuyerID.setNull();
  149. //mBuyerID.setNull();
  150. //mJoinNeighbors = 0x0;
  151. mSaleTimerExpires.setTimerExpirySec(0);
  152. mSaleTimerExpires.stop();
  153. mGraceExtension = 0;
  154. //mExpireAction = STEA_REVERT;
  155. //mRecordTransaction = FALSE;
  156. mAuctionID = 0;
  157. mInEscrow = false;
  158. mParcelFlags = PF_DEFAULT;
  159. setParcelFlag(PF_CREATE_OBJECTS, modify);
  160. setParcelFlag(PF_ALLOW_TERRAFORM, terraform);
  161. setParcelFlag(PF_ALLOW_DAMAGE, damage);
  162. mSalePrice = 10000;
  163. setName(LLStringUtil::null);
  164. setDesc(LLStringUtil::null);
  165. setMusicURL(LLStringUtil::null);
  166. setMediaURL(LLStringUtil::null);
  167. setMediaDesc(LLStringUtil::null);
  168. setMediaType(LLStringUtil::null);
  169. mMediaID.setNull();
  170. mMediaAutoScale = 0;
  171. mMediaLoop = TRUE;
  172. mMediaWidth = 0;
  173. mMediaHeight = 0;
  174. setMediaCurrentURL(LLStringUtil::null);
  175. mMediaURLFilterEnable = FALSE;
  176. mMediaURLFilterList = LLSD::emptyArray();
  177. mMediaAllowNavigate = TRUE;
  178. mMediaURLTimeout = 0.0f;
  179. mMediaPreventCameraZoom = FALSE;
  180. mGroupID.setNull();
  181. mPassPrice = PARCEL_PASS_PRICE_DEFAULT;
  182. mPassHours = PARCEL_PASS_HOURS_DEFAULT;
  183. mAABBMin.setVec(SOME_BIG_NUMBER, SOME_BIG_NUMBER, SOME_BIG_NUMBER);
  184. mAABBMax.setVec(SOME_BIG_NEG_NUMBER, SOME_BIG_NEG_NUMBER, SOME_BIG_NEG_NUMBER);
  185. mLocalID = 0;
  186. //mSimWidePrimCorrection = 0;
  187. setMaxPrimCapacity((S32)(sim_object_limit * area / (F32)(REGION_WIDTH_METERS * REGION_WIDTH_METERS)));
  188. setSimWideMaxPrimCapacity(0);
  189. setSimWidePrimCount(0);
  190. setOwnerPrimCount(0);
  191. setGroupPrimCount(0);
  192. setOtherPrimCount(0);
  193. setSelectedPrimCount(0);
  194. setTempPrimCount(0);
  195. setCleanOtherTime(0);
  196. setRegionPushOverride(FALSE);
  197. setRegionDenyAnonymousOverride(FALSE);
  198. setRegionDenyAgeUnverifiedOverride(FALSE);
  199. setParcelPrimBonus(parcel_object_bonus);
  200. setPreviousOwnerID(LLUUID::null);
  201. setPreviouslyGroupOwned(FALSE);
  202. setSeeAVs(TRUE);
  203. setAllowGroupAVSounds(TRUE);
  204. setAllowAnyAVSounds(TRUE);
  205. setHaveNewParcelLimitData(FALSE);
  206. }
  207. void LLParcel::overrideOwner(const LLUUID& owner_id, BOOL is_group_owned)
  208. {
  209. // Override with system permission (LLUUID::null)
  210. // Overridden parcels have no group
  211. mOwnerID = owner_id;
  212. mGroupOwned = is_group_owned;
  213. if(mGroupOwned)
  214. {
  215. mGroupID = mOwnerID;
  216. }
  217. else
  218. {
  219. mGroupID.setNull();
  220. }
  221. mInEscrow = false;
  222. }
  223. void LLParcel::overrideParcelFlags(U32 flags)
  224. {
  225. mParcelFlags = flags;
  226. }
  227. void LLParcel::setName(const std::string& name)
  228. {
  229. // The escaping here must match the escaping in the database
  230. // abstraction layer.
  231. mName = name;
  232. LLStringFn::replace_nonprintable_in_ascii(mName, LL_UNKNOWN_CHAR);
  233. }
  234. void LLParcel::setDesc(const std::string& desc)
  235. {
  236. // The escaping here must match the escaping in the database
  237. // abstraction layer.
  238. mDesc = desc;
  239. mDesc = rawstr_to_utf8(mDesc);
  240. }
  241. void LLParcel::setMusicURL(const std::string& url)
  242. {
  243. mMusicURL = url;
  244. // The escaping here must match the escaping in the database
  245. // abstraction layer.
  246. // This should really filter the url in some way. Other than
  247. // simply requiring non-printable.
  248. LLStringFn::replace_nonprintable_in_ascii(mMusicURL, LL_UNKNOWN_CHAR);
  249. }
  250. void LLParcel::setMediaURL(const std::string& url)
  251. {
  252. mMediaURL = url;
  253. // The escaping here must match the escaping in the database
  254. // abstraction layer if it's ever added.
  255. // This should really filter the url in some way. Other than
  256. // simply requiring non-printable.
  257. LLStringFn::replace_nonprintable_in_ascii(mMediaURL, LL_UNKNOWN_CHAR);
  258. }
  259. void LLParcel::setMediaDesc(const std::string& desc)
  260. {
  261. // The escaping here must match the escaping in the database
  262. // abstraction layer.
  263. mMediaDesc = desc;
  264. mMediaDesc = rawstr_to_utf8(mMediaDesc);
  265. }
  266. void LLParcel::setMediaType(const std::string& type)
  267. {
  268. // The escaping here must match the escaping in the database
  269. // abstraction layer.
  270. mMediaType = type;
  271. mMediaType = rawstr_to_utf8(mMediaType);
  272. // This code attempts to preserve legacy movie functioning
  273. if(mMediaType.empty() && ! mMediaURL.empty())
  274. {
  275. setMediaType(std::string("video/vnd.secondlife.qt.legacy"));
  276. }
  277. }
  278. void LLParcel::setMediaWidth(S32 width)
  279. {
  280. mMediaWidth = width;
  281. }
  282. void LLParcel::setMediaHeight(S32 height)
  283. {
  284. mMediaHeight = height;
  285. }
  286. void LLParcel::setMediaCurrentURL(const std::string& url)
  287. {
  288. mMediaCurrentURL = url;
  289. // The escaping here must match the escaping in the database
  290. // abstraction layer if it's ever added.
  291. // This should really filter the url in some way. Other than
  292. // simply requiring non-printable.
  293. LLStringFn::replace_nonprintable_in_ascii(mMediaCurrentURL, LL_UNKNOWN_CHAR);
  294. }
  295. void LLParcel::setMediaURLResetTimer(F32 time)
  296. {
  297. mMediaResetTimer.start();
  298. mMediaResetTimer.setTimerExpirySec(time);
  299. }
  300. void LLParcel::setMediaURLFilterList(LLSD list)
  301. {
  302. // sanity check LLSD
  303. // must be array of strings
  304. if (!list.isArray())
  305. {
  306. return;
  307. }
  308. for (S32 i = 0; i < list.size(); i++)
  309. {
  310. if (!list[i].isString())
  311. return;
  312. }
  313. // can't be too big
  314. const S32 MAX_SIZE = 50;
  315. if (list.size() > MAX_SIZE)
  316. {
  317. LLSD new_list = LLSD::emptyArray();
  318. for (S32 i = 0; i < llmin(list.size(), MAX_SIZE); i++)
  319. {
  320. new_list.append(list[i]);
  321. }
  322. list = new_list;
  323. }
  324. mMediaURLFilterList = list;
  325. }
  326. // virtual
  327. void LLParcel::setLocalID(S32 local_id)
  328. {
  329. mLocalID = local_id;
  330. }
  331. void LLParcel::setAllParcelFlags(U32 flags)
  332. {
  333. mParcelFlags = flags;
  334. }
  335. void LLParcel::setParcelFlag(U32 flag, BOOL b)
  336. {
  337. if (b)
  338. {
  339. mParcelFlags |= flag;
  340. }
  341. else
  342. {
  343. mParcelFlags &= ~flag;
  344. }
  345. }
  346. BOOL LLParcel::allowModifyBy(const LLUUID &agent_id, const LLUUID &group_id) const
  347. {
  348. if (agent_id == LLUUID::null)
  349. {
  350. // system always can enter
  351. return TRUE;
  352. }
  353. else if (isPublic())
  354. {
  355. return TRUE;
  356. }
  357. else if (agent_id == mOwnerID)
  358. {
  359. // owner can always perform operations
  360. return TRUE;
  361. }
  362. else if (mParcelFlags & PF_CREATE_OBJECTS)
  363. {
  364. return TRUE;
  365. }
  366. else if ((mParcelFlags & PF_CREATE_GROUP_OBJECTS)
  367. && group_id.notNull() )
  368. {
  369. return (getGroupID() == group_id);
  370. }
  371. return FALSE;
  372. }
  373. BOOL LLParcel::allowTerraformBy(const LLUUID &agent_id) const
  374. {
  375. if (agent_id == LLUUID::null)
  376. {
  377. // system always can enter
  378. return TRUE;
  379. }
  380. else if(OS_LEASED == mStatus)
  381. {
  382. if(agent_id == mOwnerID)
  383. {
  384. // owner can modify leased land
  385. return TRUE;
  386. }
  387. else
  388. {
  389. // otherwise check other people
  390. return mParcelFlags & PF_ALLOW_TERRAFORM;
  391. }
  392. }
  393. else
  394. {
  395. return FALSE;
  396. }
  397. }
  398. bool LLParcel::isAgentBlockedFromParcel(LLParcel* parcelp,
  399. const LLUUID& agent_id,
  400. const uuid_vec_t& group_ids,
  401. const BOOL is_agent_identified,
  402. const BOOL is_agent_transacted,
  403. const BOOL is_agent_ageverified)
  404. {
  405. S32 current_group_access = parcelp->blockAccess(agent_id, LLUUID::null, is_agent_identified, is_agent_transacted, is_agent_ageverified);
  406. S32 count;
  407. bool is_allowed = (current_group_access == BA_ALLOWED) ? true: false;
  408. LLUUID group_id;
  409. count = group_ids.size();
  410. for (int i = 0; i < count && !is_allowed; i++)
  411. {
  412. group_id = group_ids[i];
  413. current_group_access = parcelp->blockAccess(agent_id, group_id, is_agent_identified, is_agent_transacted, is_agent_ageverified);
  414. if (current_group_access == BA_ALLOWED) is_allowed = true;
  415. }
  416. return !is_allowed;
  417. }
  418. BOOL LLParcel::isAgentBanned(const LLUUID& agent_id) const
  419. {
  420. // Test ban list
  421. if (mBanList.find(agent_id) != mBanList.end())
  422. {
  423. return TRUE;
  424. }
  425. return FALSE;
  426. }
  427. S32 LLParcel::blockAccess(const LLUUID& agent_id, const LLUUID& group_id,
  428. const BOOL is_agent_identified,
  429. const BOOL is_agent_transacted,
  430. const BOOL is_agent_ageverified) const
  431. {
  432. // Test ban list
  433. if (isAgentBanned(agent_id))
  434. {
  435. return BA_BANNED;
  436. }
  437. // Always allow owner on (unless he banned himself, useful for
  438. // testing). We will also allow estate owners/managers in if they
  439. // are not explicitly banned.
  440. if (agent_id == mOwnerID)
  441. {
  442. return BA_ALLOWED;
  443. }
  444. // Special case when using pass list where group access is being restricted but not
  445. // using access list. In this case group members are allowed only if they buy a pass.
  446. // We return BA_NOT_IN_LIST if not in list
  447. BOOL passWithGroup = getParcelFlag(PF_USE_PASS_LIST) && !getParcelFlag(PF_USE_ACCESS_LIST)
  448. && getParcelFlag(PF_USE_ACCESS_GROUP) && !mGroupID.isNull() && group_id == mGroupID;
  449. // Test group list
  450. if (getParcelFlag(PF_USE_ACCESS_GROUP)
  451. && !mGroupID.isNull()
  452. && group_id == mGroupID
  453. && !passWithGroup)
  454. {
  455. return BA_ALLOWED;
  456. }
  457. // Test access list
  458. if (getParcelFlag(PF_USE_ACCESS_LIST) || passWithGroup )
  459. {
  460. if (mAccessList.find(agent_id) != mAccessList.end())
  461. {
  462. return BA_ALLOWED;
  463. }
  464. return BA_NOT_ON_LIST;
  465. }
  466. // If we're not doing any other limitations, all users
  467. // can enter, unless
  468. if ( !getParcelFlag(PF_USE_ACCESS_GROUP)
  469. && !getParcelFlag(PF_USE_ACCESS_LIST))
  470. {
  471. //If the land is group owned, and you are in the group, bypass these checks
  472. if(getIsGroupOwned() && group_id == mGroupID)
  473. {
  474. return BA_ALLOWED;
  475. }
  476. // Test for "payment" access levels
  477. // Anonymous - No Payment Info on File
  478. if(getParcelFlag(PF_DENY_ANONYMOUS) && !is_agent_identified && !is_agent_transacted)
  479. {
  480. return BA_NO_ACCESS_LEVEL;
  481. }
  482. // AgeUnverified - Not Age Verified
  483. if(getParcelFlag(PF_DENY_AGEUNVERIFIED) && !is_agent_ageverified)
  484. {
  485. return BA_NOT_AGE_VERIFIED;
  486. }
  487. return BA_ALLOWED;
  488. }
  489. return BA_NOT_IN_GROUP;
  490. }
  491. void LLParcel::setArea(S32 area, S32 sim_object_limit)
  492. {
  493. mArea = area;
  494. setMaxPrimCapacity((S32)(sim_object_limit * area / (F32)(REGION_WIDTH_METERS * REGION_WIDTH_METERS)));
  495. }
  496. void LLParcel::setDiscountRate(F32 rate)
  497. {
  498. // this is to make sure that the rate is at least sane - this is
  499. // not intended to enforce economy rules. It only enfoces that the
  500. // rate is a scaler between 0 and 1.
  501. mDiscountRate = llclampf(rate);
  502. }
  503. //-----------------------------------------------------------
  504. // File input and output
  505. //-----------------------------------------------------------
  506. BOOL LLParcel::importAccessEntry(std::istream& input_stream, LLAccessEntry* entry)
  507. {
  508. skip_to_end_of_next_keyword("{", input_stream);
  509. while (input_stream.good())
  510. {
  511. skip_comments_and_emptyspace(input_stream);
  512. std::string line, keyword, value;
  513. get_line(line, input_stream, MAX_STRING);
  514. get_keyword_and_value(keyword, value, line);
  515. if ("}" == keyword)
  516. {
  517. break;
  518. }
  519. else if ("id" == keyword)
  520. {
  521. entry->mID.set( value );
  522. }
  523. else if ("name" == keyword)
  524. {
  525. // deprecated
  526. }
  527. else if ("time" == keyword)
  528. {
  529. S32 when;
  530. LLStringUtil::convertToS32(value, when);
  531. entry->mTime = when;
  532. }
  533. else if ("flags" == keyword)
  534. {
  535. U32 setting;
  536. LLStringUtil::convertToU32(value, setting);
  537. entry->mFlags = setting;
  538. }
  539. else
  540. {
  541. llwarns << "Unknown keyword in parcel access entry section: <"
  542. << keyword << ">" << llendl;
  543. }
  544. }
  545. return input_stream.good();
  546. }
  547. BOOL LLParcel::importMediaURLFilter(std::istream& input_stream, std::string& url)
  548. {
  549. skip_to_end_of_next_keyword("{", input_stream);
  550. while(input_stream.good())
  551. {
  552. skip_comments_and_emptyspace(input_stream);
  553. std::string line, keyword, value;
  554. get_line(line, input_stream, MAX_STRING);
  555. get_keyword_and_value(keyword, value, line);
  556. if ("}" == keyword)
  557. {
  558. break;
  559. }
  560. else if ("url" == keyword)
  561. {
  562. url = value;
  563. }
  564. else
  565. {
  566. llwarns << "Unknown keyword in parcel media url filter section: <"
  567. << keyword << ">" << llendl;
  568. }
  569. }
  570. return input_stream.good();
  571. }
  572. // Assumes we are in a block "ParcelData"
  573. void LLParcel::packMessage(LLMessageSystem* msg)
  574. {
  575. msg->addU32Fast( _PREHASH_ParcelFlags, getParcelFlags() );
  576. msg->addS32Fast( _PREHASH_SalePrice, getSalePrice() );
  577. msg->addStringFast( _PREHASH_Name, getName() );
  578. msg->addStringFast( _PREHASH_Desc, getDesc() );
  579. msg->addStringFast( _PREHASH_MusicURL, getMusicURL() );
  580. msg->addStringFast( _PREHASH_MediaURL, getMediaURL() );
  581. msg->addU8 ( "MediaAutoScale", getMediaAutoScale () );
  582. msg->addUUIDFast( _PREHASH_MediaID, getMediaID() );
  583. msg->addUUIDFast( _PREHASH_GroupID, getGroupID() );
  584. msg->addS32Fast( _PREHASH_PassPrice, mPassPrice );
  585. msg->addF32Fast( _PREHASH_PassHours, mPassHours );
  586. msg->addU8Fast( _PREHASH_Category, (U8)mCategory);
  587. msg->addUUIDFast( _PREHASH_AuthBuyerID, mAuthBuyerID);
  588. msg->addUUIDFast( _PREHASH_SnapshotID, mSnapshotID);
  589. msg->addVector3Fast(_PREHASH_UserLocation, mUserLocation);
  590. msg->addVector3Fast(_PREHASH_UserLookAt, mUserLookAt);
  591. msg->addU8Fast( _PREHASH_LandingType, (U8)mLandingType);
  592. }
  593. // Assumes we are in a block "ParcelData"
  594. void LLParcel::packMessage(LLSD& msg)
  595. {
  596. // used in the viewer, the sim uses it's own packer
  597. msg["local_id"] = getLocalID();
  598. msg["parcel_flags"] = ll_sd_from_U32(getParcelFlags());
  599. msg["sale_price"] = getSalePrice();
  600. msg["name"] = getName();
  601. msg["description"] = getDesc();
  602. msg["music_url"] = getMusicURL();
  603. msg["media_url"] = getMediaURL();
  604. msg["media_desc"] = getMediaDesc();
  605. msg["media_type"] = getMediaType();
  606. msg["media_width"] = getMediaWidth();
  607. msg["media_height"] = getMediaHeight();
  608. msg["auto_scale"] = getMediaAutoScale();
  609. msg["media_loop"] = getMediaLoop();
  610. msg["media_current_url"] = getMediaCurrentURL();
  611. msg["obscure_media"] = false; // OBSOLETE - no longer used
  612. msg["obscure_music"] = false; // OBSOLETE - no longer used
  613. msg["media_id"] = getMediaID();
  614. msg["media_allow_navigate"] = getMediaAllowNavigate();
  615. msg["media_prevent_camera_zoom"] = getMediaPreventCameraZoom();
  616. msg["media_url_timeout"] = getMediaURLTimeout();
  617. msg["media_url_filter_enable"] = getMediaURLFilterEnable();
  618. msg["media_url_filter_list"] = getMediaURLFilterList();
  619. msg["group_id"] = getGroupID();
  620. msg["pass_price"] = mPassPrice;
  621. msg["pass_hours"] = mPassHours;
  622. msg["category"] = (U8)mCategory;
  623. msg["auth_buyer_id"] = mAuthBuyerID;
  624. msg["snapshot_id"] = mSnapshotID;
  625. msg["user_location"] = ll_sd_from_vector3(mUserLocation);
  626. msg["user_look_at"] = ll_sd_from_vector3(mUserLookAt);
  627. msg["landing_type"] = (U8)mLandingType;
  628. msg["see_avs"] = (LLSD::Boolean) getSeeAVs();
  629. msg["group_av_sounds"] = (LLSD::Boolean) getAllowGroupAVSounds();
  630. msg["any_av_sounds"] = (LLSD::Boolean) getAllowAnyAVSounds();
  631. }
  632. void LLParcel::unpackMessage(LLMessageSystem* msg)
  633. {
  634. std::string buffer;
  635. msg->getU32Fast( _PREHASH_ParcelData,_PREHASH_ParcelFlags, mParcelFlags );
  636. msg->getS32Fast( _PREHASH_ParcelData,_PREHASH_SalePrice, mSalePrice );
  637. msg->getStringFast( _PREHASH_ParcelData,_PREHASH_Name, buffer );
  638. setName(buffer);
  639. msg->getStringFast( _PREHASH_ParcelData,_PREHASH_Desc, buffer );
  640. setDesc(buffer);
  641. msg->getStringFast( _PREHASH_ParcelData,_PREHASH_MusicURL, buffer );
  642. setMusicURL(buffer);
  643. msg->getStringFast( _PREHASH_ParcelData,_PREHASH_MediaURL, buffer );
  644. setMediaURL(buffer);
  645. BOOL see_avs = TRUE; // All default to true for legacy server behavior
  646. BOOL any_av_sounds = TRUE;
  647. BOOL group_av_sounds = TRUE;
  648. bool have_new_parcel_limit_data = (msg->getSizeFast(_PREHASH_ParcelData, _PREHASH_SeeAVs) > 0); // New version of server should send all 3 of these values
  649. have_new_parcel_limit_data &= (msg->getSizeFast(_PREHASH_ParcelData, _PREHASH_AnyAVSounds) > 0);
  650. have_new_parcel_limit_data &= (msg->getSizeFast(_PREHASH_ParcelData, _PREHASH_GroupAVSounds) > 0);
  651. if (have_new_parcel_limit_data)
  652. {
  653. msg->getBOOLFast(_PREHASH_ParcelData, _PREHASH_SeeAVs, see_avs);
  654. msg->getBOOLFast(_PREHASH_ParcelData, _PREHASH_AnyAVSounds, any_av_sounds);
  655. msg->getBOOLFast(_PREHASH_ParcelData, _PREHASH_GroupAVSounds, group_av_sounds);
  656. }
  657. setSeeAVs((bool) see_avs);
  658. setAllowAnyAVSounds((bool) any_av_sounds);
  659. setAllowGroupAVSounds((bool) group_av_sounds);
  660. setHaveNewParcelLimitData(have_new_parcel_limit_data);
  661. // non-optimized version
  662. msg->getU8 ( "ParcelData", "MediaAutoScale", mMediaAutoScale );
  663. msg->getUUIDFast( _PREHASH_ParcelData,_PREHASH_MediaID, mMediaID );
  664. msg->getUUIDFast( _PREHASH_ParcelData,_PREHASH_GroupID, mGroupID );
  665. msg->getS32Fast( _PREHASH_ParcelData,_PREHASH_PassPrice, mPassPrice );
  666. msg->getF32Fast( _PREHASH_ParcelData,_PREHASH_PassHours, mPassHours );
  667. U8 category;
  668. msg->getU8Fast( _PREHASH_ParcelData,_PREHASH_Category, category);
  669. mCategory = (ECategory)category;
  670. msg->getUUIDFast( _PREHASH_ParcelData,_PREHASH_AuthBuyerID, mAuthBuyerID);
  671. msg->getUUIDFast( _PREHASH_ParcelData,_PREHASH_SnapshotID, mSnapshotID);
  672. msg->getVector3Fast(_PREHASH_ParcelData,_PREHASH_UserLocation, mUserLocation);
  673. msg->getVector3Fast(_PREHASH_ParcelData,_PREHASH_UserLookAt, mUserLookAt);
  674. U8 landing_type;
  675. msg->getU8Fast( _PREHASH_ParcelData,_PREHASH_LandingType, landing_type);
  676. mLandingType = (ELandingType)landing_type;
  677. // New Media Data
  678. // Note: the message has been converted to TCP
  679. if(msg->has("MediaData"))
  680. {
  681. msg->getString("MediaData", "MediaDesc", buffer);
  682. setMediaDesc(buffer);
  683. msg->getString("MediaData", "MediaType", buffer);
  684. setMediaType(buffer);
  685. msg->getS32("MediaData", "MediaWidth", mMediaWidth);
  686. msg->getS32("MediaData", "MediaHeight", mMediaHeight);
  687. msg->getU8 ( "MediaData", "MediaLoop", mMediaLoop );
  688. // the ObscureMedia and ObscureMusic flags previously set here are no longer used
  689. }
  690. else
  691. {
  692. setMediaType(std::string("video/vnd.secondlife.qt.legacy"));
  693. setMediaDesc(std::string("No Description available without Server Upgrade"));
  694. mMediaLoop = true;
  695. }
  696. if(msg->getNumberOfBlocks("MediaLinkSharing") > 0)
  697. {
  698. msg->getString("MediaLinkSharing", "MediaCurrentURL", buffer);
  699. setMediaCurrentURL(buffer);
  700. msg->getU8 ( "MediaLinkSharing", "MediaAllowNavigate", mMediaAllowNavigate );
  701. msg->getU8 ( "MediaLinkSharing", "MediaURLFilterEnable", mMediaURLFilterEnable );
  702. msg->getU8 ( "MediaLinkSharing", "MediaPreventCameraZoom", mMediaPreventCameraZoom );
  703. msg->getF32( "MediaLinkSharing", "MediaURLTimeout", mMediaURLTimeout);
  704. }
  705. else
  706. {
  707. setMediaCurrentURL(LLStringUtil::null);
  708. }
  709. }
  710. void LLParcel::packAccessEntries(LLMessageSystem* msg,
  711. const std::map<LLUUID,LLAccessEntry>& list)
  712. {
  713. access_map_const_iterator cit = list.begin();
  714. access_map_const_iterator end = list.end();
  715. if (cit == end)
  716. {
  717. msg->nextBlockFast(_PREHASH_List);
  718. msg->addUUIDFast(_PREHASH_ID, LLUUID::null );
  719. msg->addS32Fast(_PREHASH_Time, 0 );
  720. msg->addU32Fast(_PREHASH_Flags, 0 );
  721. return;
  722. }
  723. for ( ; cit != end; ++cit)
  724. {
  725. const LLAccessEntry& entry = (*cit).second;
  726. msg->nextBlockFast(_PREHASH_List);
  727. msg->addUUIDFast(_PREHASH_ID, entry.mID );
  728. msg->addS32Fast(_PREHASH_Time, entry.mTime );
  729. msg->addU32Fast(_PREHASH_Flags, entry.mFlags );
  730. }
  731. }
  732. void LLParcel::unpackAccessEntries(LLMessageSystem* msg,
  733. std::map<LLUUID,LLAccessEntry>* list)
  734. {
  735. LLUUID id;
  736. S32 time;
  737. U32 flags;
  738. S32 i;
  739. S32 count = msg->getNumberOfBlocksFast(_PREHASH_List);
  740. for (i = 0; i < count; i++)
  741. {
  742. msg->getUUIDFast(_PREHASH_List, _PREHASH_ID, id, i);
  743. msg->getS32Fast( _PREHASH_List, _PREHASH_Time, time, i);
  744. msg->getU32Fast( _PREHASH_List, _PREHASH_Flags, flags, i);
  745. if (id.notNull())
  746. {
  747. LLAccessEntry entry;
  748. entry.mID = id;
  749. entry.mTime = time;
  750. entry.mFlags = flags;
  751. (*list)[entry.mID] = entry;
  752. }
  753. }
  754. }
  755. void LLParcel::expirePasses(S32 now)
  756. {
  757. access_map_iterator itor = mAccessList.begin();
  758. while (itor != mAccessList.end())
  759. {
  760. const LLAccessEntry& entry = (*itor).second;
  761. if (entry.mTime != 0 && entry.mTime < now)
  762. {
  763. mAccessList.erase(itor++);
  764. }
  765. else
  766. {
  767. ++itor;
  768. }
  769. }
  770. }
  771. bool LLParcel::operator==(const LLParcel &rhs) const
  772. {
  773. if (mOwnerID != rhs.mOwnerID)
  774. return FALSE;
  775. if (mParcelFlags != rhs.mParcelFlags)
  776. return FALSE;
  777. if (mClaimDate != rhs.mClaimDate)
  778. return FALSE;
  779. if (mClaimPricePerMeter != rhs.mClaimPricePerMeter)
  780. return FALSE;
  781. if (mRentPricePerMeter != rhs.mRentPricePerMeter)
  782. return FALSE;
  783. return TRUE;
  784. }
  785. // Calculate rent
  786. S32 LLParcel::getTotalRent() const
  787. {
  788. return (S32)floor(0.5f + (F32)mArea * (F32)mRentPricePerMeter * (1.0f - mDiscountRate));
  789. }
  790. F32 LLParcel::getAdjustedRentPerMeter() const
  791. {
  792. return ((F32)mRentPricePerMeter * (1.0f - mDiscountRate));
  793. }
  794. LLVector3 LLParcel::getCenterpoint() const
  795. {
  796. LLVector3 rv;
  797. rv.mV[VX] = (getAABBMin().mV[VX] + getAABBMax().mV[VX]) * 0.5f;
  798. rv.mV[VY] = (getAABBMin().mV[VY] + getAABBMax().mV[VY]) * 0.5f;
  799. rv.mV[VZ] = 0.0f;
  800. return rv;
  801. }
  802. void LLParcel::extendAABB(const LLVector3& box_min, const LLVector3& box_max)
  803. {
  804. // Patch up min corner of AABB
  805. S32 i;
  806. for (i=0; i<3; i++)
  807. {
  808. if (box_min.mV[i] < mAABBMin.mV[i])
  809. {
  810. mAABBMin.mV[i] = box_min.mV[i];
  811. }
  812. }
  813. // Patch up max corner of AABB
  814. for (i=0; i<3; i++)
  815. {
  816. if (box_max.mV[i] > mAABBMax.mV[i])
  817. {
  818. mAABBMax.mV[i] = box_max.mV[i];
  819. }
  820. }
  821. }
  822. BOOL LLParcel::addToAccessList(const LLUUID& agent_id, S32 time)
  823. {
  824. if (mAccessList.size() >= (U32) PARCEL_MAX_ACCESS_LIST)
  825. {
  826. return FALSE;
  827. }
  828. if (agent_id == getOwnerID())
  829. {
  830. // Can't add owner to these lists
  831. return FALSE;
  832. }
  833. access_map_iterator itor = mAccessList.begin();
  834. while (itor != mAccessList.end())
  835. {
  836. const LLAccessEntry& entry = (*itor).second;
  837. if (entry.mID == agent_id)
  838. {
  839. if (time == 0 || (entry.mTime != 0 && entry.mTime < time))
  840. {
  841. mAccessList.erase(itor++);
  842. }
  843. else
  844. {
  845. // existing one expires later
  846. return FALSE;
  847. }
  848. }
  849. else
  850. {
  851. ++itor;
  852. }
  853. }
  854. removeFromBanList(agent_id);
  855. LLAccessEntry new_entry;
  856. new_entry.mID = agent_id;
  857. new_entry.mTime = time;
  858. new_entry.mFlags = 0x0;
  859. mAccessList[new_entry.mID] = new_entry;
  860. return TRUE;
  861. }
  862. BOOL LLParcel::addToBanList(const LLUUID& agent_id, S32 time)
  863. {
  864. if (mBanList.size() >= (U32) PARCEL_MAX_ACCESS_LIST)
  865. {
  866. // Not using ban list, so not a rational thing to do
  867. return FALSE;
  868. }
  869. if (agent_id == getOwnerID())
  870. {
  871. // Can't add owner to these lists
  872. return FALSE;
  873. }
  874. access_map_iterator itor = mBanList.begin();
  875. while (itor != mBanList.end())
  876. {
  877. const LLAccessEntry& entry = (*itor).second;
  878. if (entry.mID == agent_id)
  879. {
  880. if (time == 0 || (entry.mTime != 0 && entry.mTime < time))
  881. {
  882. mBanList.erase(itor++);
  883. }
  884. else
  885. {
  886. // existing one expires later
  887. return FALSE;
  888. }
  889. }
  890. else
  891. {
  892. ++itor;
  893. }
  894. }
  895. removeFromAccessList(agent_id);
  896. LLAccessEntry new_entry;
  897. new_entry.mID = agent_id;
  898. new_entry.mTime = time;
  899. new_entry.mFlags = 0x0;
  900. mBanList[new_entry.mID] = new_entry;
  901. return TRUE;
  902. }
  903. BOOL remove_from_access_array(std::map<LLUUID,LLAccessEntry>* list,
  904. const LLUUID& agent_id)
  905. {
  906. BOOL removed = FALSE;
  907. access_map_iterator itor = list->begin();
  908. while (itor != list->end())
  909. {
  910. const LLAccessEntry& entry = (*itor).second;
  911. if (entry.mID == agent_id)
  912. {
  913. list->erase(itor++);
  914. removed = TRUE;
  915. }
  916. else
  917. {
  918. ++itor;
  919. }
  920. }
  921. return removed;
  922. }
  923. BOOL LLParcel::removeFromAccessList(const LLUUID& agent_id)
  924. {
  925. return remove_from_access_array(&mAccessList, agent_id);
  926. }
  927. BOOL LLParcel::removeFromBanList(const LLUUID& agent_id)
  928. {
  929. return remove_from_access_array(&mBanList, agent_id);
  930. }
  931. // static
  932. const std::string& LLParcel::getOwnershipStatusString(EOwnershipStatus status)
  933. {
  934. return ownership_status_to_string(status);
  935. }
  936. // static
  937. const std::string& LLParcel::getCategoryString(ECategory category)
  938. {
  939. return category_to_string(category);
  940. }
  941. // static
  942. const std::string& LLParcel::getCategoryUIString(ECategory category)
  943. {
  944. return category_to_ui_string(category);
  945. }
  946. // static
  947. LLParcel::ECategory LLParcel::getCategoryFromString(const std::string& string)
  948. {
  949. return category_string_to_category(string);
  950. }
  951. // static
  952. LLParcel::ECategory LLParcel::getCategoryFromUIString(const std::string& string)
  953. {
  954. return category_ui_string_to_category(string);
  955. }
  956. // static
  957. const std::string& LLParcel::getActionString(LLParcel::EAction action)
  958. {
  959. S32 index = 0;
  960. if((action >= 0) && (action < LLParcel::A_COUNT))
  961. {
  962. index = action;
  963. }
  964. else
  965. {
  966. index = A_COUNT;
  967. }
  968. return PARCEL_ACTION_STRING[index];
  969. }
  970. BOOL LLParcel::isSaleTimerExpired(const U64& time)
  971. {
  972. if (mSaleTimerExpires.getStarted() == FALSE)
  973. {
  974. return FALSE;
  975. }
  976. BOOL expired = mSaleTimerExpires.checkExpirationAndReset(0.0);
  977. if (expired)
  978. {
  979. mSaleTimerExpires.stop();
  980. }
  981. return expired;
  982. }
  983. BOOL LLParcel::isMediaResetTimerExpired(const U64& time)
  984. {
  985. if (mMediaResetTimer.getStarted() == FALSE)
  986. {
  987. return FALSE;
  988. }
  989. BOOL expired = mMediaResetTimer.checkExpirationAndReset(0.0);
  990. if (expired)
  991. {
  992. mMediaResetTimer.stop();
  993. }
  994. return expired;
  995. }
  996. void LLParcel::startSale(const LLUUID& buyer_id, BOOL is_buyer_group)
  997. {
  998. // TODO -- this and all Sale related methods need to move out of the LLParcel
  999. // base class and into server-side-only LLSimParcel class
  1000. setPreviousOwnerID(mOwnerID);
  1001. setPreviouslyGroupOwned(mGroupOwned);
  1002. mOwnerID = buyer_id;
  1003. mGroupOwned = is_buyer_group;
  1004. if(mGroupOwned)
  1005. {
  1006. mGroupID = mOwnerID;
  1007. }
  1008. else
  1009. {
  1010. mGroupID.setNull();
  1011. }
  1012. mSaleTimerExpires.start();
  1013. mSaleTimerExpires.setTimerExpirySec(DEFAULT_USEC_SALE_TIMEOUT / SEC_TO_MICROSEC);
  1014. mStatus = OS_LEASE_PENDING;
  1015. mClaimDate = time(NULL);
  1016. setAuctionID(0);
  1017. // clear the autoreturn whenever land changes hands
  1018. setCleanOtherTime(0);
  1019. }
  1020. void LLParcel::expireSale(
  1021. U32& type,
  1022. U8& flags,
  1023. LLUUID& from_id,
  1024. LLUUID& to_id)
  1025. {
  1026. mSaleTimerExpires.setTimerExpirySec(0.0);
  1027. mSaleTimerExpires.stop();
  1028. setPreviousOwnerID(LLUUID::null);
  1029. setPreviouslyGroupOwned(FALSE);
  1030. setSellWithObjects(FALSE);
  1031. type = TRANS_LAND_RELEASE;
  1032. mStatus = OS_NONE;
  1033. flags = pack_transaction_flags(mGroupOwned, FALSE);
  1034. mAuthBuyerID.setNull();
  1035. from_id = mOwnerID;
  1036. mOwnerID.setNull();
  1037. to_id.setNull();
  1038. }
  1039. void LLParcel::completeSale(
  1040. U32& type,
  1041. U8& flags,
  1042. LLUUID& to_id)
  1043. {
  1044. mSaleTimerExpires.setTimerExpirySec(0.0);
  1045. mSaleTimerExpires.stop();
  1046. mStatus = OS_LEASED;
  1047. type = TRANS_LAND_SALE;
  1048. flags = pack_transaction_flags(mGroupOwned, mGroupOwned);
  1049. to_id = mOwnerID;
  1050. mAuthBuyerID.setNull();
  1051. // Purchased parcels are assumed to no longer be for sale.
  1052. // Otherwise someone can snipe the sale.
  1053. setForSale(FALSE);
  1054. setAuctionID(0);
  1055. // Turn off show directory, since it's a recurring fee that
  1056. // the buyer may not want.
  1057. setParcelFlag(PF_SHOW_DIRECTORY, FALSE);
  1058. //should be cleared on sale.
  1059. mAccessList.clear();
  1060. mBanList.clear();
  1061. }
  1062. void LLParcel::clearSale()
  1063. {
  1064. mSaleTimerExpires.setTimerExpirySec(0.0);
  1065. mSaleTimerExpires.stop();
  1066. if(isPublic())
  1067. {
  1068. mStatus = OS_NONE;
  1069. }
  1070. else
  1071. {
  1072. mStatus = OS_LEASED;
  1073. }
  1074. mAuthBuyerID.setNull();
  1075. setForSale(FALSE);
  1076. setAuctionID(0);
  1077. setPreviousOwnerID(LLUUID::null);
  1078. setPreviouslyGroupOwned(FALSE);
  1079. setSellWithObjects(FALSE);
  1080. }
  1081. BOOL LLParcel::isPublic() const
  1082. {
  1083. return (mOwnerID.isNull());
  1084. }
  1085. BOOL LLParcel::isBuyerAuthorized(const LLUUID& buyer_id) const
  1086. {
  1087. if(mAuthBuyerID.isNull())
  1088. {
  1089. return TRUE;
  1090. }
  1091. return (mAuthBuyerID == buyer_id);
  1092. }
  1093. void LLParcel::clearParcel()
  1094. {
  1095. overrideParcelFlags(PF_DEFAULT);
  1096. setName(LLStringUtil::null);
  1097. setDesc(LLStringUtil::null);
  1098. setMediaURL(LLStringUtil::null);
  1099. setMediaType(LLStringUtil::null);
  1100. setMediaID(LLUUID::null);
  1101. setMediaDesc(LLStringUtil::null);
  1102. setMediaAutoScale(0);
  1103. setMediaLoop(TRUE);
  1104. mMediaWidth = 0;
  1105. mMediaHeight = 0;
  1106. setMediaCurrentURL(LLStringUtil::null);
  1107. setMediaURLFilterList(LLSD::emptyArray());
  1108. setMediaURLFilterEnable(FALSE);
  1109. setMediaAllowNavigate(TRUE);
  1110. setMediaPreventCameraZoom(FALSE);
  1111. setMediaURLTimeout(0.0f);
  1112. setMusicURL(LLStringUtil::null);
  1113. setInEscrow(FALSE);
  1114. setAuthorizedBuyerID(LLUUID::null);
  1115. setCategory(C_NONE);
  1116. setSnapshotID(LLUUID::null);
  1117. setUserLocation(LLVector3::zero);
  1118. setUserLookAt(LLVector3::x_axis);
  1119. setLandingType(L_LANDING_POINT);
  1120. setAuctionID(0);
  1121. setGroupID(LLUUID::null);
  1122. setPassPrice(0);
  1123. setPassHours(0.f);
  1124. mAccessList.clear();
  1125. mBanList.clear();
  1126. //mRenterList.reset();
  1127. }
  1128. void LLParcel::dump()
  1129. {
  1130. llinfos << "parcel " << mLocalID << " area " << mArea << llendl;
  1131. llinfos << " name <" << mName << ">" << llendl;
  1132. llinfos << " desc <" << mDesc << ">" << llendl;
  1133. }
  1134. const std::string& ownership_status_to_string(LLParcel::EOwnershipStatus status)
  1135. {
  1136. if(status >= 0 && status < LLParcel::OS_COUNT)
  1137. {
  1138. return PARCEL_OWNERSHIP_STATUS_STRING[status];
  1139. }
  1140. return PARCEL_OWNERSHIP_STATUS_STRING[LLParcel::OS_COUNT];
  1141. }
  1142. LLParcel::EOwnershipStatus ownership_string_to_status(const std::string& s)
  1143. {
  1144. for(S32 i = 0; i < LLParcel::OS_COUNT; ++i)
  1145. {
  1146. if(s == PARCEL_OWNERSHIP_STATUS_STRING[i])
  1147. {
  1148. return (LLParcel::EOwnershipStatus)i;
  1149. }
  1150. }
  1151. return LLParcel::OS_NONE;
  1152. }
  1153. //const char* revert_action_to_string(LLParcel::ESaleTimerExpireAction action)
  1154. //{
  1155. // S32 index = 0;
  1156. // if(action >= 0 && action < LLParcel::STEA_COUNT)
  1157. // {
  1158. // index = action;
  1159. // }
  1160. // return PARCEL_SALE_TIMER_ACTION[index];
  1161. //}
  1162. //LLParcel::ESaleTimerExpireAction revert_string_to_action(const char* s)
  1163. //{
  1164. // for(S32 i = 0; i < LLParcel::STEA_COUNT; ++i)
  1165. // {
  1166. // if(0 == strcmp(s, PARCEL_SALE_TIMER_ACTION[i]))
  1167. // {
  1168. // return (LLParcel::ESaleTimerExpireAction)i;
  1169. // }
  1170. // }
  1171. // return LLParcel::STEA_REVERT;
  1172. //}
  1173. const std::string& category_to_string(LLParcel::ECategory category)
  1174. {
  1175. S32 index = 0;
  1176. if((category >= 0) && (category < LLParcel::C_COUNT))
  1177. {
  1178. index = category;
  1179. }
  1180. return PARCEL_CATEGORY_STRING[index];
  1181. }
  1182. const std::string& category_to_ui_string(LLParcel::ECategory category)
  1183. {
  1184. S32 index = 0;
  1185. if((category >= 0) && (category < LLParcel::C_COUNT))
  1186. {
  1187. index = category;
  1188. }
  1189. else
  1190. {
  1191. // C_ANY = -1 , but the "Any" string is at the end of the list
  1192. index = ((S32) LLParcel::C_COUNT);
  1193. }
  1194. return PARCEL_CATEGORY_UI_STRING[index];
  1195. }
  1196. LLParcel::ECategory category_string_to_category(const std::string& s)
  1197. {
  1198. for(S32 i = 0; i < LLParcel::C_COUNT; ++i)
  1199. {
  1200. if(s == PARCEL_CATEGORY_STRING[i])
  1201. {
  1202. return (LLParcel::ECategory)i;
  1203. }
  1204. }
  1205. llwarns << "Parcel category outside of possibilities " << s << llendl;
  1206. return LLParcel::C_NONE;
  1207. }
  1208. LLParcel::ECategory category_ui_string_to_category(const std::string& s)
  1209. {
  1210. for(S32 i = 0; i < LLParcel::C_COUNT; ++i)
  1211. {
  1212. if(s == PARCEL_CATEGORY_UI_STRING[i])
  1213. {
  1214. return (LLParcel::ECategory)i;
  1215. }
  1216. }
  1217. // "Any" is a valid category for searches, and
  1218. // is a distinct option from "None" and "Other"
  1219. return LLParcel::C_ANY;
  1220. }