PageRenderTime 639ms CodeModel.GetById 296ms app.highlight 17ms RepoModel.GetById 152ms 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
  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
 28/* File Inclusions */
 29#include "llviewerprecompiledheaders.h"
 30
 31#include "llhomelocationresponder.h"
 32#include "llsdutil.h"
 33#include "llagent.h"
 34#include "llviewerregion.h"
 35
 36void LLHomeLocationResponder::result( const LLSD& content )
 37{
 38  LLVector3 agent_pos;
 39  bool      error = true;
 40		
 41  do {
 42	
 43    // was the call to /agent/<agent-id>/home-location successful?
 44    // If not, we keep error set to true
 45    if( ! content.has("success") )
 46    {
 47      break;
 48    }
 49		
 50    if( 0 != strncmp("true", content["success"].asString().c_str(), 4 ) )
 51    {
 52      break;
 53    }
 54		
 55    // did the simulator return a "justified" home location?
 56    // If no, we keep error set to true
 57    if( ! content.has( "HomeLocation" ) )
 58    {
 59      break;
 60    }
 61		
 62    if( ! content["HomeLocation"].has("LocationPos") )
 63    {
 64      break;
 65    }
 66		
 67    if( ! content["HomeLocation"]["LocationPos"].has("X") )
 68    {
 69      break;
 70    }
 71
 72    agent_pos.mV[VX] = content["HomeLocation"]["LocationPos"]["X"].asInteger();
 73		
 74    if( ! content["HomeLocation"]["LocationPos"].has("Y") )
 75    {
 76      break;
 77    }
 78
 79    agent_pos.mV[VY] = content["HomeLocation"]["LocationPos"]["Y"].asInteger();
 80		
 81    if( ! content["HomeLocation"]["LocationPos"].has("Z") )
 82    {
 83      break;
 84    }
 85
 86    agent_pos.mV[VZ] = content["HomeLocation"]["LocationPos"]["Z"].asInteger();
 87		
 88    error = false;
 89  } while( 0 );
 90	
 91  if( ! error )
 92  {
 93    llinfos << "setting home position" << llendl;
 94		
 95    LLViewerRegion *viewer_region = gAgent.getRegion();
 96    gAgent.setHomePosRegion( viewer_region->getHandle(), agent_pos );
 97  }
 98}
 99
100void LLHomeLocationResponder::error( U32 status, const std::string& reason )
101{
102  llinfos << "received error(" << reason  << ")" << llendl;
103}