PageRenderTime 99ms CodeModel.GetById 35ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llhomelocationresponder.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 103 lines | 54 code | 18 blank | 31 comment | 9 complexity | 2095e9671e61bb02c2a6f6d3778bfe54 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llhomelocationresponder.cpp
  3. * @author Meadhbh Hamrick
  4. * @brief Processes responses to the HomeLocation CapReq
  5. *
  6. * $LicenseInfo:firstyear=2008&license=viewerlgpl$
  7. * Second Life Viewer Source Code
  8. * Copyright (C) 2010, Linden Research, Inc.
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation;
  13. * version 2.1 of the License only.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  25. * $/LicenseInfo$
  26. */
  27. /* File Inclusions */
  28. #include "llviewerprecompiledheaders.h"
  29. #include "llhomelocationresponder.h"
  30. #include "llsdutil.h"
  31. #include "llagent.h"
  32. #include "llviewerregion.h"
  33. void LLHomeLocationResponder::result( const LLSD& content )
  34. {
  35. LLVector3 agent_pos;
  36. bool error = true;
  37. do {
  38. // was the call to /agent/<agent-id>/home-location successful?
  39. // If not, we keep error set to true
  40. if( ! content.has("success") )
  41. {
  42. break;
  43. }
  44. if( 0 != strncmp("true", content["success"].asString().c_str(), 4 ) )
  45. {
  46. break;
  47. }
  48. // did the simulator return a "justified" home location?
  49. // If no, we keep error set to true
  50. if( ! content.has( "HomeLocation" ) )
  51. {
  52. break;
  53. }
  54. if( ! content["HomeLocation"].has("LocationPos") )
  55. {
  56. break;
  57. }
  58. if( ! content["HomeLocation"]["LocationPos"].has("X") )
  59. {
  60. break;
  61. }
  62. agent_pos.mV[VX] = content["HomeLocation"]["LocationPos"]["X"].asInteger();
  63. if( ! content["HomeLocation"]["LocationPos"].has("Y") )
  64. {
  65. break;
  66. }
  67. agent_pos.mV[VY] = content["HomeLocation"]["LocationPos"]["Y"].asInteger();
  68. if( ! content["HomeLocation"]["LocationPos"].has("Z") )
  69. {
  70. break;
  71. }
  72. agent_pos.mV[VZ] = content["HomeLocation"]["LocationPos"]["Z"].asInteger();
  73. error = false;
  74. } while( 0 );
  75. if( ! error )
  76. {
  77. llinfos << "setting home position" << llendl;
  78. LLViewerRegion *viewer_region = gAgent.getRegion();
  79. gAgent.setHomePosRegion( viewer_region->getHandle(), agent_pos );
  80. }
  81. }
  82. void LLHomeLocationResponder::error( U32 status, const std::string& reason )
  83. {
  84. llinfos << "received error(" << reason << ")" << llendl;
  85. }