diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llhomelocationresponder.cpp | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/linden/indra/newview/llhomelocationresponder.cpp b/linden/indra/newview/llhomelocationresponder.cpp new file mode 100644 index 0000000..58ea684 --- /dev/null +++ b/linden/indra/newview/llhomelocationresponder.cpp | |||
@@ -0,0 +1,108 @@ | |||
1 | /** | ||
2 | * @file llhomelocationresponder.cpp | ||
3 | * @author Meadhbh Hamrick | ||
4 | * @brief Processes responses to the HomeLocation CapReq | ||
5 | * | ||
6 | * $LicenseInfo:firstyear=2008&license=viewergpl$ | ||
7 | * | ||
8 | * Copyright (c) 2008-2009, Linden Research, Inc. | ||
9 | * | ||
10 | * Second Life Viewer Source Code | ||
11 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
12 | * to you under the terms of the GNU General Public License, version 2.0 | ||
13 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
14 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
15 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
16 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
17 | * | ||
18 | * There are special exceptions to the terms and conditions of the GPL as | ||
19 | * it is applied to this Source Code. View the full text of the exception | ||
20 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
21 | * online at 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 | |||
33 | /* File Inclusions */ | ||
34 | #include "llviewerprecompiledheaders.h" | ||
35 | |||
36 | #include "llhomelocationresponder.h" | ||
37 | #include "llsdutil.h" | ||
38 | #include "llagent.h" | ||
39 | #include "llviewerregion.h" | ||
40 | |||
41 | void LLHomeLocationResponder::result( const LLSD& content ) | ||
42 | { | ||
43 | LLVector3 agent_pos; | ||
44 | bool error = true; | ||
45 | |||
46 | do { | ||
47 | |||
48 | // was the call to /agent/<agent-id>/home-location successful? | ||
49 | // If not, we keep error set to true | ||
50 | if( ! content.has("success") ) | ||
51 | { | ||
52 | break; | ||
53 | } | ||
54 | |||
55 | if( 0 != strncmp("true", content["success"].asString().c_str(), 4 ) ) | ||
56 | { | ||
57 | break; | ||
58 | } | ||
59 | |||
60 | // did the simulator return a "justified" home location? | ||
61 | // If no, we keep error set to true | ||
62 | if( ! content.has( "HomeLocation" ) ) | ||
63 | { | ||
64 | break; | ||
65 | } | ||
66 | |||
67 | if( ! content["HomeLocation"].has("LocationPos") ) | ||
68 | { | ||
69 | break; | ||
70 | } | ||
71 | |||
72 | if( ! content["HomeLocation"]["LocationPos"].has("X") ) | ||
73 | { | ||
74 | break; | ||
75 | } | ||
76 | |||
77 | agent_pos.mV[VX] = content["HomeLocation"]["LocationPos"]["X"].asInteger(); | ||
78 | |||
79 | if( ! content["HomeLocation"]["LocationPos"].has("Y") ) | ||
80 | { | ||
81 | break; | ||
82 | } | ||
83 | |||
84 | agent_pos.mV[VY] = content["HomeLocation"]["LocationPos"]["Y"].asInteger(); | ||
85 | |||
86 | if( ! content["HomeLocation"]["LocationPos"].has("Z") ) | ||
87 | { | ||
88 | break; | ||
89 | } | ||
90 | |||
91 | agent_pos.mV[VZ] = content["HomeLocation"]["LocationPos"]["Z"].asInteger(); | ||
92 | |||
93 | error = false; | ||
94 | } while( 0 ); | ||
95 | |||
96 | if( ! error ) | ||
97 | { | ||
98 | llinfos << "setting home position" << llendl; | ||
99 | |||
100 | LLViewerRegion *viewer_region = gAgent.getRegion(); | ||
101 | gAgent.setHomePosRegion( viewer_region->getHandle(), agent_pos ); | ||
102 | } | ||
103 | } | ||
104 | |||
105 | void LLHomeLocationResponder::error( const LLSD& content ) | ||
106 | { | ||
107 | llinfos << "received error(" << ll_pretty_print_sd( content ) << ")" << llendl; | ||
108 | } | ||