llfloatergodtools.cpp 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323
  1. /**
  2. * @file llfloatergodtools.cpp
  3. * @brief The on-screen rectangle with tool options.
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #include "llviewerprecompiledheaders.h"
  33. #include "llfloatergodtools.h"
  34. #include "llcombobox.h"
  35. #include "llfloater.h"
  36. #include "llhost.h"
  37. #include "lllineeditor.h"
  38. #include "llnotifications.h"
  39. #include "llregionflags.h"
  40. #include "lluictrl.h"
  41. #include "lluictrlfactory.h"
  42. #include "llxfermanager.h"
  43. #include "llmessage.h"
  44. #include "llagent.h"
  45. #include "llfloateravatarpicker.h"
  46. #include "llfloatertopobjects.h"
  47. //MK
  48. #include "mkrlinterface.h"
  49. //mk
  50. #include "llselectmgr.h"
  51. #include "llviewercontrol.h"
  52. #include "llviewerparcelmgr.h"
  53. #include "llviewerregion.h"
  54. #include "llworld.h"
  55. constexpr F32 SECONDS_BETWEEN_UPDATE_REQUESTS = 5.f;
  56. //*****************************************************************************
  57. // LLFloaterGodTools
  58. //*****************************************************************************
  59. LLFloaterGodTools::LLFloaterGodTools(const LLSD&)
  60. : mCurrentHost(LLHost()),
  61. mUpdateTimer()
  62. {
  63. LLCallbackMap::map_t factory_map;
  64. factory_map["grid"] = LLCallbackMap(createPanelGrid, this);
  65. factory_map["region"] = LLCallbackMap(createPanelRegion, this);
  66. factory_map["objects"] = LLCallbackMap(createPanelObjects, this);
  67. factory_map["request"] = LLCallbackMap(createPanelRequest, this);
  68. LLUICtrlFactory::getInstance()->buildFloater(this, "floater_god_tools.xml",
  69. &factory_map);
  70. }
  71. ///virtual
  72. bool LLFloaterGodTools::postBuild()
  73. {
  74. childSetTabChangeCallback("GodTools Tabs", "grid", onTabChanged, this);
  75. childSetTabChangeCallback("GodTools Tabs", "region", onTabChanged, this);
  76. childSetTabChangeCallback("GodTools Tabs", "objects", onTabChanged, this);
  77. childSetTabChangeCallback("GodTools Tabs", "request", onTabChanged, this);
  78. childShowTab("GodTools Tabs", "region");
  79. center();
  80. setFocus(true);
  81. return true;
  82. }
  83. //virtual
  84. void LLFloaterGodTools::onOpen()
  85. {
  86. LLPanel* panel = childGetVisibleTab("GodTools Tabs");
  87. panel->setFocus(true);
  88. if (mPanelObjectTools)
  89. {
  90. mPanelObjectTools->setTargetAvatar(LLUUID::null);
  91. }
  92. if (gAgent.getRegionHost() != mCurrentHost)
  93. {
  94. // we're in a new region
  95. sendRegionInfoRequest();
  96. }
  97. }
  98. //static
  99. void* LLFloaterGodTools::createPanelGrid(void* userdata)
  100. {
  101. return new LLPanelGridTools("grid");
  102. }
  103. //static
  104. void* LLFloaterGodTools::createPanelRegion(void* userdata)
  105. {
  106. LLFloaterGodTools* self = (LLFloaterGodTools*)userdata;
  107. self->mPanelRegionTools = new LLPanelRegionTools("region");
  108. return self->mPanelRegionTools;
  109. }
  110. //static
  111. void* LLFloaterGodTools::createPanelObjects(void* userdata)
  112. {
  113. LLFloaterGodTools* self = (LLFloaterGodTools*)userdata;
  114. self->mPanelObjectTools = new LLPanelObjectTools("objects");
  115. return self->mPanelObjectTools;
  116. }
  117. //static
  118. void* LLFloaterGodTools::createPanelRequest(void* userdata)
  119. {
  120. return new LLPanelRequestTools("region");
  121. }
  122. U64 LLFloaterGodTools::computeRegionFlags() const
  123. {
  124. if (!gAgent.getRegion()) return 0;
  125. U64 flags = gAgent.getRegion()->getRegionFlags();
  126. if (mPanelRegionTools) flags = mPanelRegionTools->computeRegionFlags(flags);
  127. if (mPanelObjectTools) flags = mPanelObjectTools->computeRegionFlags(flags);
  128. return flags;
  129. }
  130. // virtual
  131. void LLFloaterGodTools::draw()
  132. {
  133. if (mCurrentHost.isInvalid())
  134. {
  135. if (mUpdateTimer.getElapsedTimeF32() > SECONDS_BETWEEN_UPDATE_REQUESTS)
  136. {
  137. sendRegionInfoRequest();
  138. }
  139. }
  140. else if (gAgent.getRegionHost() != mCurrentHost)
  141. {
  142. sendRegionInfoRequest();
  143. }
  144. LLFloater::draw();
  145. }
  146. //static
  147. void LLFloaterGodTools::onTabChanged(void* data, bool from_click)
  148. {
  149. LLPanel* panel = (LLPanel*)data;
  150. if (panel)
  151. {
  152. panel->setFocus(true);
  153. }
  154. }
  155. //static
  156. void LLFloaterGodTools::updateFromRegionInfo()
  157. {
  158. LLFloaterGodTools* self = findInstance();
  159. // Push values to god tools, if available
  160. if (self && self->mPanelRegionTools && self->mPanelObjectTools &&
  161. gAgent.isGodlike())
  162. {
  163. LLPanelRegionTools* rtool = self->mPanelRegionTools;
  164. // We know we are in the agent's region, else this method would not
  165. // have been called by LLViewerRegion::processRegionInfo()
  166. self->mCurrentHost = gAgent.getRegionHost();
  167. // Store locally
  168. rtool->setSimName(LLRegionInfoModel::sSimName);
  169. rtool->setEstateID(LLRegionInfoModel::sEstateID);
  170. rtool->setParentEstateID(LLRegionInfoModel::sParentEstateID);
  171. rtool->setCheckFlags(LLRegionInfoModel::sRegionFlags);
  172. rtool->setBillableFactor(LLRegionInfoModel::sBillableFactor);
  173. rtool->setPricePerMeter(LLRegionInfoModel::sPricePerMeter);
  174. rtool->setRedirectGridX(LLRegionInfoModel::sRedirectGridX);
  175. rtool->setRedirectGridY(LLRegionInfoModel::sRedirectGridY);
  176. rtool->enableAllWidgets();
  177. LLPanelObjectTools* otool = self->mPanelObjectTools;
  178. otool->setCheckFlags(LLRegionInfoModel::sRegionFlags);
  179. otool->enableAllWidgets();
  180. LLViewerRegion* regionp = gAgent.getRegion();
  181. if (!regionp)
  182. {
  183. // -1 implies non-existent
  184. rtool->setGridPosX(-1);
  185. rtool->setGridPosY(-1);
  186. }
  187. else
  188. {
  189. // Compute the grid position of the region
  190. LLVector3d global_pos =
  191. regionp->getPosGlobalFromRegion(LLVector3::zero);
  192. S32 grid_pos_x = (S32) (global_pos.mdV[VX] / 256.0f);
  193. S32 grid_pos_y = (S32) (global_pos.mdV[VY] / 256.0f);
  194. rtool->setGridPosX(grid_pos_x);
  195. rtool->setGridPosY(grid_pos_y);
  196. }
  197. }
  198. }
  199. void LLFloaterGodTools::sendRegionInfoRequest()
  200. {
  201. if (mPanelRegionTools)
  202. {
  203. mPanelRegionTools->clearAllWidgets();
  204. }
  205. if (mPanelObjectTools)
  206. {
  207. mPanelObjectTools->clearAllWidgets();
  208. }
  209. mCurrentHost = LLHost();
  210. mUpdateTimer.reset();
  211. LLMessageSystem* msg = gMessageSystemp;
  212. if (msg)
  213. {
  214. msg->newMessage(_PREHASH_RequestRegionInfo);
  215. msg->nextBlock(_PREHASH_AgentData);
  216. msg->addUUID(_PREHASH_AgentID, gAgentID);
  217. msg->addUUID(_PREHASH_SessionID, gAgentSessionID);
  218. gAgent.sendReliableMessage();
  219. }
  220. }
  221. void LLFloaterGodTools::sendGodUpdateRegionInfo()
  222. {
  223. if (mPanelRegionTools && gAgent.isGodlike() && gAgent.getRegion() &&
  224. gAgent.getRegionHost() == mCurrentHost)
  225. {
  226. U64 region_flags = computeRegionFlags();
  227. LLMessageSystem* msg = gMessageSystemp;
  228. msg->newMessage("GodUpdateRegionInfo");
  229. msg->nextBlockFast(_PREHASH_AgentData);
  230. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  231. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  232. msg->nextBlockFast(_PREHASH_RegionInfo);
  233. msg->addStringFast(_PREHASH_SimName,
  234. mPanelRegionTools->getSimName());
  235. msg->addU32Fast(_PREHASH_EstateID, mPanelRegionTools->getEstateID());
  236. msg->addU32Fast(_PREHASH_ParentEstateID,
  237. mPanelRegionTools->getParentEstateID());
  238. // Legacy flags
  239. msg->addU32Fast(_PREHASH_RegionFlags, U32(region_flags));
  240. msg->addF32Fast(_PREHASH_BillableFactor,
  241. mPanelRegionTools->getBillableFactor());
  242. msg->addS32Fast(_PREHASH_PricePerMeter,
  243. mPanelRegionTools->getPricePerMeter());
  244. msg->addS32Fast(_PREHASH_RedirectGridX,
  245. mPanelRegionTools->getRedirectGridX());
  246. msg->addS32Fast(_PREHASH_RedirectGridY,
  247. mPanelRegionTools->getRedirectGridY());
  248. msg->nextBlockFast(_PREHASH_RegionInfo2);
  249. msg->addU64Fast(_PREHASH_RegionFlagsExtended, region_flags);
  250. gAgent.sendReliableMessage();
  251. }
  252. }
  253. //*****************************************************************************
  254. // LLPanelRegionTools
  255. //*****************************************************************************
  256. // || Region |______________________________________
  257. // | |
  258. // | Sim Name: [________________________________] |
  259. // | ^ ^ |
  260. // | LEFT R1 Estate id: [----] |
  261. // | Parent id: [----] |
  262. // | [X] Prelude Grid Pos: [--] [--] |
  263. // | [X] Visible Redirect Pos: [--] [--] |
  264. // | [X] Damage Bill Factor [8_______] |
  265. // | [X] Block Terraform PricePerMeter[8_______] |
  266. // | [Apply] |
  267. // | |
  268. // | [Bake Terrain] [Select Region] |
  269. // | [Revert Terrain] [Autosave Now] |
  270. // | [Swap Terrain] |
  271. // | |
  272. // |________________________________________________|
  273. // ^ ^ ^
  274. // LEFT R2 RIGHT
  275. // Floats because spinners only support floats. JC
  276. constexpr F32 BILLABLE_FACTOR_DEFAULT = 1.f;
  277. constexpr F32 PRICE_PER_METER_DEFAULT = 1.f;
  278. LLPanelRegionTools::LLPanelRegionTools(const std::string& title)
  279. : LLPanel(title)
  280. {
  281. }
  282. //virtual
  283. bool LLPanelRegionTools::postBuild()
  284. {
  285. childSetCommitCallback("region name", onChangeAnything, this);
  286. childSetKeystrokeCallback("region name", onChangeSimName, this);
  287. childSetPrevalidate("region name", &LLLineEditor::prevalidatePrintableNotPipe);
  288. childSetCommitCallback("check prelude", onChangePrelude, this);
  289. childSetCommitCallback("check fixed sun", onChangeAnything, this);
  290. childSetCommitCallback("check reset home", onChangeAnything, this);
  291. childSetCommitCallback("check visible", onChangeAnything, this);
  292. childSetCommitCallback("check damage", onChangeAnything, this);
  293. childSetCommitCallback("block dwell", onChangeAnything, this);
  294. childSetCommitCallback("block terraform", onChangeAnything, this);
  295. childSetCommitCallback("is sandbox", onChangeAnything, this);
  296. childSetAction("Bake Terrain", onBakeTerrain, this);
  297. childSetAction("Revert Terrain", onRevertTerrain, this);
  298. childSetAction("Swap Terrain", onSwapTerrain, this);
  299. childSetCommitCallback("estate", onChangeAnything, this);
  300. childSetPrevalidate("estate", &LLLineEditor::prevalidatePositiveS32);
  301. childSetCommitCallback("parentestate", onChangeAnything, this);
  302. childSetPrevalidate("parentestate", &LLLineEditor::prevalidatePositiveS32);
  303. childDisable("parentestate");
  304. childSetCommitCallback("gridposx", onChangeAnything, this);
  305. childSetPrevalidate("gridposx", &LLLineEditor::prevalidatePositiveS32);
  306. childDisable("gridposx");
  307. childSetCommitCallback("gridposy", onChangeAnything, this);
  308. childSetPrevalidate("gridposy", &LLLineEditor::prevalidatePositiveS32);
  309. childDisable("gridposy");
  310. childSetCommitCallback("redirectx", onChangeAnything, this);
  311. childSetPrevalidate("redirectx", &LLLineEditor::prevalidatePositiveS32);
  312. childSetCommitCallback("redirecty", onChangeAnything, this);
  313. childSetPrevalidate("redirecty", &LLLineEditor::prevalidatePositiveS32);
  314. childSetCommitCallback("billable factor", onChangeAnything, this);
  315. childSetCommitCallback("land cost", onChangeAnything, this);
  316. childSetAction("Refresh", onRefresh, this);
  317. childSetAction("Apply", onApplyChanges, this);
  318. childSetAction("Select Region", onSelectRegion, this);
  319. childSetAction("Autosave now", onSaveState, this);
  320. return true;
  321. }
  322. U64 LLPanelRegionTools::computeRegionFlags(U64 flags) const
  323. {
  324. flags &= getRegionFlagsMask();
  325. flags |= getRegionFlags();
  326. return flags;
  327. }
  328. void LLPanelRegionTools::clearAllWidgets()
  329. {
  330. // clear all widgets
  331. childSetValue("region name", "unknown");
  332. childSetFocus("region name", false);
  333. childSetValue("check prelude", false);
  334. childDisable("check prelude");
  335. childSetValue("check fixed sun", false);
  336. childDisable("check fixed sun");
  337. childSetValue("check reset home", false);
  338. childDisable("check reset home");
  339. childSetValue("check damage", false);
  340. childDisable("check damage");
  341. childSetValue("check visible", false);
  342. childDisable("check visible");
  343. childSetValue("block terraform", false);
  344. childDisable("block terraform");
  345. childSetValue("block dwell", false);
  346. childDisable("block dwell");
  347. childSetValue("is sandbox", false);
  348. childDisable("is sandbox");
  349. childSetValue("billable factor", BILLABLE_FACTOR_DEFAULT);
  350. childDisable("billable factor");
  351. childSetValue("land cost", PRICE_PER_METER_DEFAULT);
  352. childDisable("land cost");
  353. childDisable("Apply");
  354. childDisable("Bake Terrain");
  355. childDisable("Autosave now");
  356. }
  357. void LLPanelRegionTools::enableAllWidgets()
  358. {
  359. // enable all of the widgets
  360. childEnable("check prelude");
  361. childEnable("check fixed sun");
  362. childEnable("check reset home");
  363. childEnable("check damage");
  364. childDisable("check visible"); // use estates to update...
  365. childEnable("block terraform");
  366. childEnable("block dwell");
  367. childEnable("is sandbox");
  368. childEnable("billable factor");
  369. childEnable("land cost");
  370. childDisable("Apply"); // don't enable this one
  371. childEnable("Bake Terrain");
  372. childEnable("Autosave now");
  373. }
  374. //static
  375. void LLPanelRegionTools::onSaveState(void* userdata)
  376. {
  377. if (gAgent.isGodlike())
  378. {
  379. // Send message to save world state
  380. LLMessageSystem* msg = gMessageSystemp;
  381. msg->newMessageFast(_PREHASH_StateSave);
  382. msg->nextBlockFast(_PREHASH_AgentData);
  383. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  384. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  385. msg->nextBlockFast(_PREHASH_DataBlock);
  386. msg->addStringFast(_PREHASH_Filename, NULL);
  387. gAgent.sendReliableMessage();
  388. }
  389. }
  390. const std::string LLPanelRegionTools::getSimName() const
  391. {
  392. return childGetValue("region name");
  393. }
  394. U32 LLPanelRegionTools::getEstateID() const
  395. {
  396. U32 id = (U32)childGetValue("estate").asInteger();
  397. return id;
  398. }
  399. U32 LLPanelRegionTools::getParentEstateID() const
  400. {
  401. U32 id = (U32)childGetValue("parentestate").asInteger();
  402. return id;
  403. }
  404. S32 LLPanelRegionTools::getRedirectGridX() const
  405. {
  406. return childGetValue("redirectx").asInteger();
  407. }
  408. S32 LLPanelRegionTools::getRedirectGridY() const
  409. {
  410. return childGetValue("redirecty").asInteger();
  411. }
  412. S32 LLPanelRegionTools::getGridPosX() const
  413. {
  414. return childGetValue("gridposx").asInteger();
  415. }
  416. S32 LLPanelRegionTools::getGridPosY() const
  417. {
  418. return childGetValue("gridposy").asInteger();
  419. }
  420. U64 LLPanelRegionTools::getRegionFlags() const
  421. {
  422. U64 flags = 0x0;
  423. flags = childGetValue("check prelude").asBoolean() ? set_prelude_flags(flags)
  424. : unset_prelude_flags(flags);
  425. // override prelude
  426. if (childGetValue("check fixed sun").asBoolean())
  427. {
  428. flags |= REGION_FLAGS_SUN_FIXED;
  429. }
  430. if (childGetValue("check reset home").asBoolean())
  431. {
  432. flags |= REGION_FLAGS_RESET_HOME_ON_TELEPORT;
  433. }
  434. if (childGetValue("check visible").asBoolean())
  435. {
  436. flags |= REGION_FLAGS_EXTERNALLY_VISIBLE;
  437. }
  438. if (childGetValue("check damage").asBoolean())
  439. {
  440. flags |= REGION_FLAGS_ALLOW_DAMAGE;
  441. }
  442. if (childGetValue("block terraform").asBoolean())
  443. {
  444. flags |= REGION_FLAGS_BLOCK_TERRAFORM;
  445. }
  446. if (childGetValue("block dwell").asBoolean())
  447. {
  448. flags |= REGION_FLAGS_BLOCK_DWELL;
  449. }
  450. if (childGetValue("is sandbox").asBoolean())
  451. {
  452. flags |= REGION_FLAGS_SANDBOX;
  453. }
  454. return flags;
  455. }
  456. U64 LLPanelRegionTools::getRegionFlagsMask() const
  457. {
  458. U64 flags = 0xFFFFFFFFFFFFFFFFULL;
  459. flags = childGetValue("check prelude").asBoolean() ? set_prelude_flags(flags)
  460. : unset_prelude_flags(flags);
  461. if (!childGetValue("check fixed sun").asBoolean())
  462. {
  463. flags &= ~REGION_FLAGS_SUN_FIXED;
  464. }
  465. if (!childGetValue("check reset home").asBoolean())
  466. {
  467. flags &= ~REGION_FLAGS_RESET_HOME_ON_TELEPORT;
  468. }
  469. if (!childGetValue("check visible").asBoolean())
  470. {
  471. flags &= ~REGION_FLAGS_EXTERNALLY_VISIBLE;
  472. }
  473. if (!childGetValue("check damage").asBoolean())
  474. {
  475. flags &= ~REGION_FLAGS_ALLOW_DAMAGE;
  476. }
  477. if (!childGetValue("block terraform").asBoolean())
  478. {
  479. flags &= ~REGION_FLAGS_BLOCK_TERRAFORM;
  480. }
  481. if (!childGetValue("block dwell").asBoolean())
  482. {
  483. flags &= ~REGION_FLAGS_BLOCK_DWELL;
  484. }
  485. if (!childGetValue("is sandbox").asBoolean())
  486. {
  487. flags &= ~REGION_FLAGS_SANDBOX;
  488. }
  489. return flags;
  490. }
  491. F32 LLPanelRegionTools::getBillableFactor() const
  492. {
  493. return (F32)childGetValue("billable factor").asReal();
  494. }
  495. S32 LLPanelRegionTools::getPricePerMeter() const
  496. {
  497. return childGetValue("land cost");
  498. }
  499. void LLPanelRegionTools::setSimName(const std::string& name)
  500. {
  501. //MK
  502. if (gRLenabled && gRLInterface.mContainsShowloc)
  503. {
  504. childSetVisible("region name", false);
  505. }
  506. else
  507. {
  508. childSetVisible("region name", true);
  509. }
  510. //mk
  511. childSetValue("region name", name);
  512. }
  513. void LLPanelRegionTools::setEstateID(U32 id)
  514. {
  515. childSetValue("estate", (S32)id);
  516. }
  517. void LLPanelRegionTools::setGridPosX(S32 pos)
  518. {
  519. childSetValue("gridposx", pos);
  520. }
  521. void LLPanelRegionTools::setGridPosY(S32 pos)
  522. {
  523. childSetValue("gridposy", pos);
  524. }
  525. void LLPanelRegionTools::setRedirectGridX(S32 pos)
  526. {
  527. childSetValue("redirectx", pos);
  528. }
  529. void LLPanelRegionTools::setRedirectGridY(S32 pos)
  530. {
  531. childSetValue("redirecty", pos);
  532. }
  533. void LLPanelRegionTools::setParentEstateID(U32 id)
  534. {
  535. childSetValue("parentestate", (S32)id);
  536. }
  537. void LLPanelRegionTools::setCheckFlags(U64 flags)
  538. {
  539. childSetValue("check prelude", is_prelude(flags));
  540. childSetValue("check fixed sun", (flags & REGION_FLAGS_SUN_FIXED) != 0);
  541. childSetValue("check reset home",
  542. (flags & REGION_FLAGS_RESET_HOME_ON_TELEPORT) != 0);
  543. childSetValue("check damage", (flags & REGION_FLAGS_ALLOW_DAMAGE) != 0);
  544. childSetValue("check visible",
  545. (flags & REGION_FLAGS_EXTERNALLY_VISIBLE) != 0);
  546. childSetValue("block terraform",
  547. (flags & REGION_FLAGS_BLOCK_TERRAFORM) != 0);
  548. childSetValue("block dwell", (flags & REGION_FLAGS_BLOCK_DWELL) != 0);
  549. childSetValue("is sandbox", (flags & REGION_FLAGS_SANDBOX) != 0);
  550. }
  551. void LLPanelRegionTools::setBillableFactor(F32 billable_factor)
  552. {
  553. childSetValue("billable factor", billable_factor);
  554. }
  555. void LLPanelRegionTools::setPricePerMeter(S32 price)
  556. {
  557. childSetValue("land cost", price);
  558. }
  559. //static
  560. void LLPanelRegionTools::onChangeAnything(LLUICtrl* ctrl, void* userdata)
  561. {
  562. LLPanelRegionTools* self = (LLPanelRegionTools*)userdata;
  563. if (self && LLFloaterGodTools::findInstance() && gAgent.isGodlike())
  564. {
  565. self->childEnable("Apply");
  566. }
  567. }
  568. //static
  569. void LLPanelRegionTools::onChangePrelude(LLUICtrl* ctrl, void* userdata)
  570. {
  571. // checking prelude auto-checks fixed sun
  572. LLPanelRegionTools* self = (LLPanelRegionTools*)userdata;
  573. if (self && self->childGetValue("check prelude").asBoolean())
  574. {
  575. self->childSetValue("check fixed sun", true);
  576. self->childSetValue("check reset home", true);
  577. }
  578. // pass on to default onChange handler
  579. onChangeAnything(ctrl, userdata);
  580. }
  581. //static
  582. void LLPanelRegionTools::onChangeSimName(LLLineEditor* caller, void* userdata)
  583. {
  584. LLPanelRegionTools* self = (LLPanelRegionTools*)userdata;
  585. if (self && LLFloaterGodTools::findInstance() && gAgent.isGodlike())
  586. {
  587. self->childEnable("Apply");
  588. }
  589. }
  590. //static
  591. void LLPanelRegionTools::onRefresh(void*)
  592. {
  593. LLFloaterGodTools* fgt = LLFloaterGodTools::findInstance();
  594. if (fgt && gAgent.getRegion() && gAgent.isGodlike())
  595. {
  596. fgt->sendRegionInfoRequest();
  597. }
  598. }
  599. //static
  600. void LLPanelRegionTools::onApplyChanges(void* userdata)
  601. {
  602. LLPanelRegionTools* self = (LLPanelRegionTools*)userdata;
  603. LLFloaterGodTools* fgt = LLFloaterGodTools::findInstance();
  604. if (self && fgt && gAgent.getRegion() && gAgent.isGodlike())
  605. {
  606. self->childDisable("Apply");
  607. fgt->sendGodUpdateRegionInfo();
  608. }
  609. }
  610. //static
  611. void LLPanelRegionTools::onBakeTerrain(void* userdata)
  612. {
  613. LLPanelRequestTools::sendRequest("terrain", "bake",
  614. gAgent.getRegionHost());
  615. }
  616. //static
  617. void LLPanelRegionTools::onRevertTerrain(void* userdata)
  618. {
  619. LLPanelRequestTools::sendRequest("terrain", "revert",
  620. gAgent.getRegionHost());
  621. }
  622. //static
  623. void LLPanelRegionTools::onSwapTerrain(void* userdata)
  624. {
  625. LLPanelRequestTools::sendRequest("terrain", "swap",
  626. gAgent.getRegionHost());
  627. }
  628. //static
  629. void LLPanelRegionTools::onSelectRegion(void* userdata)
  630. {
  631. LLViewerRegion* regionp =
  632. gWorld.getRegionFromPosGlobal(gAgent.getPositionGlobal());
  633. if (regionp)
  634. {
  635. LLVector3d origin = regionp->getOriginGlobal();
  636. LLVector3d north_east(REGION_WIDTH_METERS, REGION_WIDTH_METERS, 0);
  637. gViewerParcelMgr.selectLand(origin, origin + north_east, false);
  638. }
  639. }
  640. //*****************************************************************************
  641. // Class LLPanelGridTools
  642. //*****************************************************************************
  643. // || Grid |_____________________________________
  644. // | |
  645. // | |
  646. // | Sun Phase: >--------[]---------< [________] |
  647. // | |
  648. // | ^ ^ |
  649. // | LEFT R1 |
  650. // | |
  651. // | [Kick all users] |
  652. // | |
  653. // | |
  654. // | |
  655. // | |
  656. // | |
  657. // |_______________________________________________|
  658. // ^ ^ ^
  659. // LEFT R2 RIGHT
  660. LLPanelGridTools::LLPanelGridTools(const std::string& name)
  661. : LLPanel(name)
  662. {
  663. }
  664. //virtual
  665. bool LLPanelGridTools::postBuild()
  666. {
  667. childSetAction("Kick all users", onClickKickAll, this);
  668. childSetAction("Flush This Region's Map Visibility Caches",
  669. onClickFlushMapVisibilityCaches, this);
  670. return true;
  671. }
  672. //static
  673. void LLPanelGridTools::onClickKickAll(void* userdata)
  674. {
  675. gNotifications.add("KickAllUsers", LLSD(), LLSD(),
  676. LLPanelGridTools::confirmKick);
  677. }
  678. bool LLPanelGridTools::confirmKick(const LLSD& notification,
  679. const LLSD& response)
  680. {
  681. if (LLNotification::getSelectedOption(notification, response) == 0)
  682. {
  683. LLSD payload;
  684. payload["kick_message"] = response["message"].asString();
  685. gNotifications.add("ConfirmKick", LLSD(), payload, finishKick);
  686. }
  687. return false;
  688. }
  689. //static
  690. bool LLPanelGridTools::finishKick(const LLSD& notification,
  691. const LLSD& response)
  692. {
  693. if (LLNotification::getSelectedOption(notification, response) == 0)
  694. {
  695. LLMessageSystem* msg = gMessageSystemp;
  696. msg->newMessageFast(_PREHASH_GodKickUser);
  697. msg->nextBlockFast(_PREHASH_UserInfo);
  698. msg->addUUIDFast(_PREHASH_GodID, gAgentID);
  699. msg->addUUIDFast(_PREHASH_GodSessionID, gAgentSessionID);
  700. msg->addUUIDFast(_PREHASH_AgentID, LL_UUID_ALL_AGENTS);
  701. msg->addU32("KickFlags", KICK_FLAGS_DEFAULT );
  702. msg->addStringFast(_PREHASH_Reason,
  703. notification["payload"]["kick_message"].asString());
  704. gAgent.sendReliableMessage();
  705. }
  706. return false;
  707. }
  708. //static
  709. void LLPanelGridTools::onClickFlushMapVisibilityCaches(void* data)
  710. {
  711. gNotifications.add("FlushMapVisibilityCaches", LLSD(), LLSD(),
  712. flushMapVisibilityCachesConfirm);
  713. }
  714. //static
  715. bool LLPanelGridTools::flushMapVisibilityCachesConfirm(const LLSD& notification,
  716. const LLSD& response)
  717. {
  718. S32 option = LLNotification::getSelectedOption(notification, response);
  719. if (option != 0) return false;
  720. // HACK: Send this as an EstateOwnerRequest so it gets routed
  721. // correctly by the spaceserver. JC
  722. LLMessageSystem* msg = gMessageSystemp;
  723. msg->newMessage("EstateOwnerMessage");
  724. msg->nextBlockFast(_PREHASH_AgentData);
  725. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  726. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  727. msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); // not used
  728. msg->nextBlock("MethodData");
  729. msg->addString("Method", "refreshmapvisibility");
  730. msg->addUUID("Invoice", LLUUID::null);
  731. msg->nextBlock("ParamList");
  732. msg->addString("Parameter", gAgentID.asString());
  733. gAgent.sendReliableMessage();
  734. return false;
  735. }
  736. //*****************************************************************************
  737. // LLPanelObjectTools
  738. //*****************************************************************************
  739. // || Object |_______________________________________________________
  740. // | |
  741. // | Sim Name: Foo |
  742. // | ^ ^ |
  743. // | LEFT R1 |
  744. // | |
  745. // | [X] Disable Scripts [X] Disable Collisions [X] Disable Physics |
  746. // | [ Apply ] |
  747. // | |
  748. // | [Set Target Avatar] Avatar Name |
  749. // | [Delete Target's Objects on Public Land ] |
  750. // | [Delete All Target's Objects ] |
  751. // | [Delete All Scripted Objects on Public Land] |
  752. // | [Get Top Colliders ] |
  753. // | [Get Top Scripts ] |
  754. // |_________________________________________________________________|
  755. // ^ ^
  756. // LEFT RIGHT
  757. // Default constructor
  758. LLPanelObjectTools::LLPanelObjectTools(const std::string& name)
  759. : LLPanel(name),
  760. mTargetAvatar()
  761. {
  762. }
  763. //virtual
  764. bool LLPanelObjectTools::postBuild()
  765. {
  766. childSetCommitCallback("disable scripts", onChangeAnything, this);
  767. childSetCommitCallback("disable collisions", onChangeAnything, this);
  768. childSetCommitCallback("disable physics", onChangeAnything, this);
  769. childSetAction("Apply", onApplyChanges, this);
  770. childSetAction("Set Target", onClickSet, this);
  771. childSetAction("Delete Target's Scripted Objects On Others Land",
  772. onClickDeletePublicOwnedBy, this);
  773. childSetAction("Delete Target's Scripted Objects On *Any* Land",
  774. onClickDeleteAllScriptedOwnedBy, this);
  775. childSetAction("Delete *ALL* Of Target's Objects",
  776. onClickDeleteAllOwnedBy, this);
  777. childSetAction("Get Top Colliders", onGetTopColliders, this);
  778. childSetAction("Get Top Scripts", onGetTopScripts, this);
  779. childSetAction("Scripts digest", onGetScriptDigest, this);
  780. return true;
  781. }
  782. void LLPanelObjectTools::setTargetAvatar(const LLUUID& target_id)
  783. {
  784. mTargetAvatar = target_id;
  785. if (target_id.isNull())
  786. {
  787. childSetValue("target_avatar_name", "(no target)");
  788. }
  789. }
  790. //virtual
  791. void LLPanelObjectTools::refresh()
  792. {
  793. //MK
  794. if (gRLenabled && gRLInterface.mContainsShowloc)
  795. {
  796. childSetVisible("region name", false);
  797. }
  798. else
  799. {
  800. childSetVisible("region name", true);
  801. }
  802. //mk
  803. LLViewerRegion *regionp = gAgent.getRegion();
  804. if (regionp)
  805. {
  806. childSetText("region name", regionp->getName());
  807. }
  808. }
  809. U64 LLPanelObjectTools::computeRegionFlags(U64 flags) const
  810. {
  811. if (childGetValue("disable scripts").asBoolean())
  812. {
  813. flags |= REGION_FLAGS_SKIP_SCRIPTS;
  814. }
  815. else
  816. {
  817. flags &= ~REGION_FLAGS_SKIP_SCRIPTS;
  818. }
  819. if (childGetValue("disable collisions").asBoolean())
  820. {
  821. flags |= REGION_FLAGS_SKIP_COLLISIONS;
  822. }
  823. else
  824. {
  825. flags &= ~REGION_FLAGS_SKIP_COLLISIONS;
  826. }
  827. if (childGetValue("disable physics").asBoolean())
  828. {
  829. flags |= REGION_FLAGS_SKIP_PHYSICS;
  830. }
  831. else
  832. {
  833. flags &= ~REGION_FLAGS_SKIP_PHYSICS;
  834. }
  835. return flags;
  836. }
  837. void LLPanelObjectTools::setCheckFlags(U64 flags)
  838. {
  839. childSetValue("disable scripts", (flags & REGION_FLAGS_SKIP_SCRIPTS) != 0);
  840. childSetValue("disable collisions",
  841. (flags & REGION_FLAGS_SKIP_COLLISIONS) != 0);
  842. childSetValue("disable physics", (flags & REGION_FLAGS_SKIP_PHYSICS) != 0);
  843. }
  844. void LLPanelObjectTools::clearAllWidgets()
  845. {
  846. childSetValue("disable scripts", false);
  847. childDisable("disable scripts");
  848. childDisable("Apply");
  849. childDisable("Set Target");
  850. childDisable("Delete Target's Scripted Objects On Others Land");
  851. childDisable("Delete Target's Scripted Objects On *Any* Land");
  852. childDisable("Delete *ALL* Of Target's Objects");
  853. }
  854. void LLPanelObjectTools::enableAllWidgets()
  855. {
  856. childEnable("disable scripts");
  857. childDisable("Apply"); // don't enable this one
  858. childEnable("Set Target");
  859. childEnable("Delete Target's Scripted Objects On Others Land");
  860. childEnable("Delete Target's Scripted Objects On *Any* Land");
  861. childEnable("Delete *ALL* Of Target's Objects");
  862. childEnable("Get Top Colliders");
  863. childEnable("Get Top Scripts");
  864. }
  865. //static
  866. void LLPanelObjectTools::onGetTopColliders(void*)
  867. {
  868. if (LLFloaterGodTools::findInstance() && gAgent.isGodlike())
  869. {
  870. LLFloaterTopObjects::showInstance();
  871. LLFloaterTopObjects::setMode(STAT_REPORT_TOP_COLLIDERS);
  872. LLFloaterTopObjects::sendRefreshRequest();
  873. }
  874. }
  875. //static
  876. void LLPanelObjectTools::onGetTopScripts(void*)
  877. {
  878. if (LLFloaterGodTools::findInstance() && gAgent.isGodlike())
  879. {
  880. LLFloaterTopObjects::showInstance();
  881. LLFloaterTopObjects::setMode(STAT_REPORT_TOP_SCRIPTS);
  882. LLFloaterTopObjects::sendRefreshRequest();
  883. }
  884. }
  885. //static
  886. void LLPanelObjectTools::onGetScriptDigest(void*)
  887. {
  888. if (LLFloaterGodTools::findInstance() && gAgent.isGodlike())
  889. {
  890. // get the list of scripts and number of occurences of each
  891. // (useful for finding self-replicating objects)
  892. LLPanelRequestTools::sendRequest("scriptdigest", "0",
  893. gAgent.getRegionHost());
  894. }
  895. }
  896. void LLPanelObjectTools::onClickDeletePublicOwnedBy(void* userdata)
  897. {
  898. // Bring up view-modal dialog
  899. LLPanelObjectTools* self = (LLPanelObjectTools*)userdata;
  900. if (self && self->mTargetAvatar.notNull())
  901. {
  902. self->mSimWideDeletesFlags = SWD_SCRIPTED_ONLY | SWD_OTHERS_LAND_ONLY;
  903. LLSD args;
  904. args["AVATAR_NAME"] = self->childGetValue("target_avatar_name").asString();
  905. LLSD payload;
  906. payload["avatar_id"] = self->mTargetAvatar;
  907. payload["flags"] = (S32)self->mSimWideDeletesFlags;
  908. gNotifications.add("GodDeleteAllScriptedPublicObjectsByUser", args,
  909. payload, callbackSimWideDeletes);
  910. }
  911. }
  912. //static
  913. void LLPanelObjectTools::onClickDeleteAllScriptedOwnedBy(void* userdata)
  914. {
  915. // Bring up view-modal dialog
  916. LLPanelObjectTools* self = (LLPanelObjectTools*)userdata;
  917. if (self->mTargetAvatar.notNull())
  918. {
  919. self->mSimWideDeletesFlags = SWD_SCRIPTED_ONLY;
  920. LLSD args;
  921. args["AVATAR_NAME"] = self->childGetValue("target_avatar_name").asString();
  922. LLSD payload;
  923. payload["avatar_id"] = self->mTargetAvatar;
  924. payload["flags"] = (S32)self->mSimWideDeletesFlags;
  925. gNotifications.add("GodDeleteAllScriptedObjectsByUser", args, payload,
  926. callbackSimWideDeletes);
  927. }
  928. }
  929. //static
  930. void LLPanelObjectTools::onClickDeleteAllOwnedBy(void* userdata)
  931. {
  932. // Bring up view-modal dialog
  933. LLPanelObjectTools* self = (LLPanelObjectTools*)userdata;
  934. if (self->mTargetAvatar.notNull())
  935. {
  936. self->mSimWideDeletesFlags = 0;
  937. LLSD args;
  938. args["AVATAR_NAME"] = self->childGetValue("target_avatar_name").asString();
  939. LLSD payload;
  940. payload["avatar_id"] = self->mTargetAvatar;
  941. payload["flags"] = (S32)self->mSimWideDeletesFlags;
  942. gNotifications.add("GodDeleteAllObjectsByUser", args, payload,
  943. callbackSimWideDeletes);
  944. }
  945. }
  946. //static
  947. bool LLPanelObjectTools::callbackSimWideDeletes(const LLSD& notification,
  948. const LLSD& response)
  949. {
  950. S32 option = LLNotification::getSelectedOption(notification, response);
  951. if (option == 0)
  952. {
  953. if (notification["payload"]["avatar_id"].asUUID().notNull())
  954. {
  955. send_sim_wide_deletes(notification["payload"]["avatar_id"].asUUID(),
  956. notification["payload"]["flags"].asInteger());
  957. }
  958. }
  959. return false;
  960. }
  961. void LLPanelObjectTools::onClickSet(void* userdata)
  962. {
  963. LLPanelObjectTools* self = (LLPanelObjectTools*)userdata;
  964. if (self)
  965. {
  966. LLFloaterAvatarPicker* pickerp =
  967. LLFloaterAvatarPicker::show(callbackAvatarID, userdata);
  968. if (pickerp && gFloaterViewp)
  969. {
  970. LLFloater* parentp = gFloaterViewp->getParentFloater(self);
  971. if (parentp)
  972. {
  973. parentp->addDependentFloater(pickerp);
  974. }
  975. }
  976. }
  977. }
  978. void LLPanelObjectTools::onClickSetBySelection(void* userdata)
  979. {
  980. LLPanelObjectTools* self = (LLPanelObjectTools*)userdata;
  981. if (!self) return;
  982. LLSelectNode* node = gSelectMgr.getSelection()->getFirstRootNode(NULL,
  983. true);
  984. if (!node) return;
  985. std::string owner_name;
  986. LLUUID owner_id;
  987. gSelectMgr.selectGetOwner(owner_id, owner_name);
  988. self->mTargetAvatar = owner_id;
  989. std::string name = "Object " + node->mName + " owned by " + owner_name;
  990. self->childSetValue("target_avatar_name", name);
  991. }
  992. //static
  993. void LLPanelObjectTools::callbackAvatarID(const std::vector<std::string>& names,
  994. const uuid_vec_t& ids,
  995. void* userdata)
  996. {
  997. LLPanelObjectTools* self = (LLPanelObjectTools*)userdata;
  998. if (self && !ids.empty() && !names.empty())
  999. {
  1000. self->mTargetAvatar = ids[0];
  1001. self->childSetValue("target_avatar_name", names[0]);
  1002. self->refresh();
  1003. }
  1004. }
  1005. //static
  1006. void LLPanelObjectTools::onChangeAnything(LLUICtrl*, void* userdata)
  1007. {
  1008. LLPanelObjectTools* self = (LLPanelObjectTools*)userdata;
  1009. if (self && LLFloaterGodTools::findInstance() && gAgent.isGodlike())
  1010. {
  1011. self->childEnable("Apply");
  1012. }
  1013. }
  1014. //static
  1015. void LLPanelObjectTools::onApplyChanges(void* userdata)
  1016. {
  1017. LLPanelObjectTools* self = (LLPanelObjectTools*)userdata;
  1018. LLFloaterGodTools* fgt = LLFloaterGodTools::findInstance();
  1019. if (self && fgt && gAgent.isGodlike() && gAgent.getRegion())
  1020. {
  1021. self->childDisable("Apply");
  1022. fgt->sendGodUpdateRegionInfo();
  1023. }
  1024. }
  1025. // --------------------
  1026. // LLPanelRequestTools
  1027. // --------------------
  1028. const std::string SELECTION = "Selection";
  1029. const std::string AGENT_REGION = "Agent Region";
  1030. LLPanelRequestTools::LLPanelRequestTools(const std::string& name)
  1031. : LLPanel(name)
  1032. {
  1033. }
  1034. //virtual
  1035. bool LLPanelRequestTools::postBuild()
  1036. {
  1037. childSetAction("Make Request", onClickRequest, this);
  1038. refresh();
  1039. return true;
  1040. }
  1041. //virtual
  1042. void LLPanelRequestTools::refresh()
  1043. {
  1044. LLComboBox* combop = getChild<LLComboBox>("destination");
  1045. std::string buffer = combop->getValue();
  1046. combop->operateOnAll(LLComboBox::OP_DELETE);
  1047. combop->addSimpleElement(SELECTION);
  1048. combop->addSimpleElement(AGENT_REGION);
  1049. for (LLWorld::region_list_t::const_iterator
  1050. iter = gWorld.getRegionList().begin(),
  1051. end = gWorld.getRegionList().end();
  1052. iter != end; ++iter)
  1053. {
  1054. LLViewerRegion* regionp = *iter;
  1055. std::string name = regionp->getName();
  1056. //MK
  1057. if (gRLenabled && gRLInterface.mContainsShowloc)
  1058. {
  1059. name = "(Hidden)";
  1060. }
  1061. //mk
  1062. if (!name.empty())
  1063. {
  1064. combop->addSimpleElement(name);
  1065. }
  1066. }
  1067. if (!buffer.empty())
  1068. {
  1069. combop->selectByValue(buffer);
  1070. }
  1071. else
  1072. {
  1073. combop->selectByValue(SELECTION);
  1074. }
  1075. }
  1076. //static
  1077. void LLPanelRequestTools::sendRequest(const std::string& request,
  1078. const std::string& parameter,
  1079. const LLHost& host)
  1080. {
  1081. LLMessageSystem* msg = gMessageSystemp;
  1082. msg->newMessage("GodlikeMessage");
  1083. msg->nextBlockFast(_PREHASH_AgentData);
  1084. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  1085. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  1086. msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); // not used
  1087. msg->nextBlock("MethodData");
  1088. msg->addString("Method", request);
  1089. msg->addUUID("Invoice", LLUUID::null);
  1090. msg->nextBlock("ParamList");
  1091. msg->addString("Parameter", parameter);
  1092. msg->sendReliable(host);
  1093. }
  1094. //static
  1095. void LLPanelRequestTools::onClickRequest(void* data)
  1096. {
  1097. LLPanelRequestTools* self = (LLPanelRequestTools*)data;
  1098. const std::string dest = self->childGetValue("destination").asString();
  1099. if (dest == SELECTION)
  1100. {
  1101. std::string req = self->childGetValue("request");
  1102. req = req.substr(0, req.find_first_of(" "));
  1103. std::string param = self->childGetValue("parameter");
  1104. gSelectMgr.sendGodlikeRequest(req, param);
  1105. }
  1106. else if (dest == AGENT_REGION)
  1107. {
  1108. self->sendRequest(gAgent.getRegionHost());
  1109. }
  1110. else
  1111. {
  1112. // find region by name
  1113. for (LLWorld::region_list_t::const_iterator
  1114. iter = gWorld.getRegionList().begin(),
  1115. end = gWorld.getRegionList().end();
  1116. iter != end; ++iter)
  1117. {
  1118. LLViewerRegion* regionp = *iter;
  1119. if (regionp && dest == regionp->getName())
  1120. {
  1121. // found it
  1122. self->sendRequest(regionp->getHost());
  1123. }
  1124. }
  1125. }
  1126. }
  1127. void terrain_download_done(void** data, S32 status, LLExtStat ext_status)
  1128. {
  1129. gNotifications.add("TerrainDownloaded");
  1130. }
  1131. void LLPanelRequestTools::sendRequest(const LLHost& host)
  1132. {
  1133. // intercept viewer local actions here
  1134. std::string req = childGetValue("request");
  1135. if (req == "terrain download")
  1136. {
  1137. if (!gXferManagerp)
  1138. {
  1139. llwarns << "No transfer manager. Aborted." << llendl;
  1140. return;
  1141. }
  1142. gXferManagerp->requestFile("terrain.raw", "terrain.raw", LL_PATH_NONE,
  1143. host, false, terrain_download_done, NULL);
  1144. }
  1145. else
  1146. {
  1147. req = req.substr(0, req.find_first_of(" "));
  1148. sendRequest(req, childGetValue("parameter").asString(), host);
  1149. }
  1150. }
  1151. // Flags are SWD_ flags.
  1152. void send_sim_wide_deletes(const LLUUID& owner_id, U32 flags)
  1153. {
  1154. LLMessageSystem* msg = gMessageSystemp;
  1155. msg->newMessageFast(_PREHASH_SimWideDeletes);
  1156. msg->nextBlockFast(_PREHASH_AgentData);
  1157. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  1158. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  1159. msg->nextBlockFast(_PREHASH_DataBlock);
  1160. msg->addUUIDFast(_PREHASH_TargetID, owner_id);
  1161. msg->addU32Fast(_PREHASH_Flags, flags);
  1162. gAgent.sendReliableMessage();
  1163. }