diff options
author | Jacek Antonelli | 2011-03-18 21:05:23 -0500 |
---|---|---|
committer | Jacek Antonelli | 2011-03-18 21:50:25 -0500 |
commit | e67e3f216fdb0868d05c35f105dd83c5358dd3b0 (patch) | |
tree | 4de6be204ab09d635c1e4ca2215abd2c17ae6671 /linden/indra | |
parent | Fix a bug that only occurs when not running in a debugger. (diff) | |
download | meta-impy-e67e3f216fdb0868d05c35f105dd83c5358dd3b0.zip meta-impy-e67e3f216fdb0868d05c35f105dd83c5358dd3b0.tar.gz meta-impy-e67e3f216fdb0868d05c35f105dd83c5358dd3b0.tar.bz2 meta-impy-e67e3f216fdb0868d05c35f105dd83c5358dd3b0.tar.xz |
Fixed bad line endings (CRLF) in many files.
Windows users, please set "autocrlf = input" or "autocrlf = true" in
your .git/config [core] section to avoid this in the future.
Diffstat (limited to '')
25 files changed, 5529 insertions, 5529 deletions
diff --git a/linden/indra/llcommon/indra_constants.h b/linden/indra/llcommon/indra_constants.h index ae1e04a..b765d4d 100644 --- a/linden/indra/llcommon/indra_constants.h +++ b/linden/indra/llcommon/indra_constants.h | |||
@@ -151,11 +151,11 @@ const U32 PORT_DISCOVERY_RANGE_MAX = PORT_DISCOVERY_RANGE_MIN + 50; | |||
151 | const char LAND_LAYER_CODE = 'L'; | 151 | const char LAND_LAYER_CODE = 'L'; |
152 | const char WATER_LAYER_CODE = 'W'; | 152 | const char WATER_LAYER_CODE = 'W'; |
153 | const char WIND_LAYER_CODE = '7'; | 153 | const char WIND_LAYER_CODE = '7'; |
154 | const char CLOUD_LAYER_CODE = '8'; | 154 | const char CLOUD_LAYER_CODE = '8'; |
155 | 155 | ||
156 | // Extended land layer for Aurora Sim | 156 | // Extended land layer for Aurora Sim |
157 | const char AURORA_LAND_LAYER_CODE = 'M'; | 157 | const char AURORA_LAND_LAYER_CODE = 'M'; |
158 | const char AURORA_WIND_LAYER_CODE = '9'; | 158 | const char AURORA_WIND_LAYER_CODE = '9'; |
159 | const char AURORA_CLOUD_LAYER_CODE = ':'; | 159 | const char AURORA_CLOUD_LAYER_CODE = ':'; |
160 | 160 | ||
161 | // keys | 161 | // keys |
diff --git a/linden/indra/llinventory/llparcel.h b/linden/indra/llinventory/llparcel.h index 366f589..f102ec4 100644 --- a/linden/indra/llinventory/llparcel.h +++ b/linden/indra/llinventory/llparcel.h | |||
@@ -66,7 +66,7 @@ const S32 PARCEL_PASS_PRICE_DEFAULT = 10; | |||
66 | const F32 PARCEL_PASS_HOURS_DEFAULT = 1.f; | 66 | const F32 PARCEL_PASS_HOURS_DEFAULT = 1.f; |
67 | 67 | ||
68 | // Number of "chunks" in which parcel overlay data is sent | 68 | // Number of "chunks" in which parcel overlay data is sent |
69 | // Chunk 0 = southern rows, entire width | 69 | // Chunk 0 = southern rows, entire width |
70 | // NOTE: NOT USABLE FOR VAR SIZED REGIONS! | 70 | // NOTE: NOT USABLE FOR VAR SIZED REGIONS! |
71 | const S32 PARCEL_OVERLAY_CHUNKS = 4; | 71 | const S32 PARCEL_OVERLAY_CHUNKS = 4; |
72 | 72 | ||
diff --git a/linden/indra/llmessage/message_prehash.cpp b/linden/indra/llmessage/message_prehash.cpp index a8b021f..78b9d07 100644 --- a/linden/indra/llmessage/message_prehash.cpp +++ b/linden/indra/llmessage/message_prehash.cpp | |||
@@ -586,8 +586,8 @@ char* _PREHASH_NotecardItemID = LLMessageStringTable::getInstance()->getString(" | |||
586 | char* _PREHASH_LastName = LLMessageStringTable::getInstance()->getString("LastName"); | 586 | char* _PREHASH_LastName = LLMessageStringTable::getInstance()->getString("LastName"); |
587 | char* _PREHASH_From = LLMessageStringTable::getInstance()->getString("From"); | 587 | char* _PREHASH_From = LLMessageStringTable::getInstance()->getString("From"); |
588 | char* _PREHASH_RoleChange = LLMessageStringTable::getInstance()->getString("RoleChange"); | 588 | char* _PREHASH_RoleChange = LLMessageStringTable::getInstance()->getString("RoleChange"); |
589 | char* _PREHASH_Port = LLMessageStringTable::getInstance()->getString("Port"); | 589 | char* _PREHASH_Port = LLMessageStringTable::getInstance()->getString("Port"); |
590 | char* _PREHASH_RegionSizeX = LLMessageStringTable::getInstance()->getString("RegionSizeX"); | 590 | char* _PREHASH_RegionSizeX = LLMessageStringTable::getInstance()->getString("RegionSizeX"); |
591 | char* _PREHASH_RegionSizeY = LLMessageStringTable::getInstance()->getString("RegionSizeY"); | 591 | char* _PREHASH_RegionSizeY = LLMessageStringTable::getInstance()->getString("RegionSizeY"); |
592 | char* _PREHASH_MemberTitle = LLMessageStringTable::getInstance()->getString("MemberTitle"); | 592 | char* _PREHASH_MemberTitle = LLMessageStringTable::getInstance()->getString("MemberTitle"); |
593 | char* _PREHASH_LogParcelChanges = LLMessageStringTable::getInstance()->getString("LogParcelChanges"); | 593 | char* _PREHASH_LogParcelChanges = LLMessageStringTable::getInstance()->getString("LogParcelChanges"); |
diff --git a/linden/indra/llmessage/message_prehash.h b/linden/indra/llmessage/message_prehash.h index adf27ee..64544dd 100644 --- a/linden/indra/llmessage/message_prehash.h +++ b/linden/indra/llmessage/message_prehash.h | |||
@@ -586,8 +586,8 @@ extern char * _PREHASH_NotecardItemID; | |||
586 | extern char * _PREHASH_LastName; | 586 | extern char * _PREHASH_LastName; |
587 | extern char * _PREHASH_From; | 587 | extern char * _PREHASH_From; |
588 | extern char * _PREHASH_RoleChange; | 588 | extern char * _PREHASH_RoleChange; |
589 | extern char * _PREHASH_Port; | 589 | extern char * _PREHASH_Port; |
590 | extern char * _PREHASH_RegionSizeX; | 590 | extern char * _PREHASH_RegionSizeX; |
591 | extern char * _PREHASH_RegionSizeY; | 591 | extern char * _PREHASH_RegionSizeY; |
592 | extern char * _PREHASH_MemberTitle; | 592 | extern char * _PREHASH_MemberTitle; |
593 | extern char * _PREHASH_LogParcelChanges; | 593 | extern char * _PREHASH_LogParcelChanges; |
diff --git a/linden/indra/llmessage/patch_code.cpp b/linden/indra/llmessage/patch_code.cpp index 4b4313d..0cf8d2e 100644 --- a/linden/indra/llmessage/patch_code.cpp +++ b/linden/indra/llmessage/patch_code.cpp | |||
@@ -280,11 +280,11 @@ void decode_patch_header(LLBitPack &bitpack, LLPatchHeader *ph, BOOL b_large_pat | |||
280 | bitpack.bitUnpack(&(ret[1]), 8); | 280 | bitpack.bitUnpack(&(ret[1]), 8); |
281 | bitpack.bitUnpack(&(ret[0]), 2); | 281 | bitpack.bitUnpack(&(ret[0]), 2); |
282 | #else | 282 | #else |
283 | if (b_large_patch) | 283 | if (b_large_patch) |
284 | bitpack.bitUnpack((U8 *)&retvalu32, 32); | 284 | bitpack.bitUnpack((U8 *)&retvalu32, 32); |
285 | else | 285 | else |
286 | bitpack.bitUnpack((U8 *)&retvalu32, 10); | 286 | bitpack.bitUnpack((U8 *)&retvalu32, 10); |
287 | #endif | 287 | #endif |
288 | ph->patchids = retvalu32; | 288 | ph->patchids = retvalu32; |
289 | 289 | ||
290 | gWordBits = (ph->quant_wbits & 0xf) + 2; | 290 | gWordBits = (ph->quant_wbits & 0xf) + 2; |
diff --git a/linden/indra/llwindow/glh/glh_linear.h b/linden/indra/llwindow/glh/glh_linear.h index bb59d7e..04ae1bd 100755 --- a/linden/indra/llwindow/glh/glh_linear.h +++ b/linden/indra/llwindow/glh/glh_linear.h | |||
@@ -1,1621 +1,1621 @@ | |||
1 | /* | 1 | /* |
2 | glh - is a platform-indepenedent C++ OpenGL helper library | 2 | glh - is a platform-indepenedent C++ OpenGL helper library |
3 | 3 | ||
4 | 4 | ||
5 | Copyright (c) 2000 Cass Everitt | 5 | Copyright (c) 2000 Cass Everitt |
6 | Copyright (c) 2000 NVIDIA Corporation | 6 | Copyright (c) 2000 NVIDIA Corporation |
7 | All rights reserved. | 7 | All rights reserved. |
8 | 8 | ||
9 | Redistribution and use in source and binary forms, with or | 9 | Redistribution and use in source and binary forms, with or |
10 | without modification, are permitted provided that the following | 10 | without modification, are permitted provided that the following |
11 | conditions are met: | 11 | conditions are met: |
12 | 12 | ||
13 | * Redistributions of source code must retain the above | 13 | * Redistributions of source code must retain the above |
14 | copyright notice, this list of conditions and the following | 14 | copyright notice, this list of conditions and the following |
15 | disclaimer. | 15 | disclaimer. |
16 | 16 | ||
17 | * Redistributions in binary form must reproduce the above | 17 | * Redistributions in binary form must reproduce the above |
18 | copyright notice, this list of conditions and the following | 18 | copyright notice, this list of conditions and the following |
19 | disclaimer in the documentation and/or other materials | 19 | disclaimer in the documentation and/or other materials |
20 | provided with the distribution. | 20 | provided with the distribution. |
21 | 21 | ||
22 | * The names of contributors to this software may not be used | 22 | * The names of contributors to this software may not be used |
23 | to endorse or promote products derived from this software | 23 | to endorse or promote products derived from this software |
24 | without specific prior written permission. | 24 | without specific prior written permission. |
25 | 25 | ||
26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
27 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 27 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
28 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 28 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
29 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | 29 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
30 | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | 30 | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
31 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | 31 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
32 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 32 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
33 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | 33 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
34 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 34 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
35 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | 35 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
36 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 36 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
37 | POSSIBILITY OF SUCH DAMAGE. | 37 | POSSIBILITY OF SUCH DAMAGE. |
38 | 38 | ||
39 | 39 | ||
40 | Cass Everitt - cass@r3.nu | 40 | Cass Everitt - cass@r3.nu |
41 | */ | 41 | */ |
42 | 42 | ||
43 | /* | 43 | /* |
44 | glh_linear.h | 44 | glh_linear.h |
45 | */ | 45 | */ |
46 | 46 | ||
47 | // Author: Cass W. Everitt | 47 | // Author: Cass W. Everitt |
48 | 48 | ||
49 | #ifndef GLH_LINEAR_H | 49 | #ifndef GLH_LINEAR_H |
50 | #define GLH_LINEAR_H | 50 | #define GLH_LINEAR_H |
51 | 51 | ||
52 | #include <memory.h> | 52 | #include <memory.h> |
53 | #include <math.h> | 53 | #include <math.h> |
54 | #include <assert.h> | 54 | #include <assert.h> |
55 | 55 | ||
56 | // only supports float for now... | 56 | // only supports float for now... |
57 | #define GLH_REAL_IS_FLOAT | 57 | #define GLH_REAL_IS_FLOAT |
58 | 58 | ||
59 | #ifdef GLH_REAL_IS_FLOAT | 59 | #ifdef GLH_REAL_IS_FLOAT |
60 | # define GLH_REAL float | 60 | # define GLH_REAL float |
61 | # define GLH_REAL_NAMESPACE ns_float | 61 | # define GLH_REAL_NAMESPACE ns_float |
62 | #endif | 62 | #endif |
63 | 63 | ||
64 | #define GLH_QUATERNION_NORMALIZATION_THRESHOLD 64 | 64 | #define GLH_QUATERNION_NORMALIZATION_THRESHOLD 64 |
65 | 65 | ||
66 | #define GLH_RAD_TO_DEG GLH_REAL(57.2957795130823208767981548141052) | 66 | #define GLH_RAD_TO_DEG GLH_REAL(57.2957795130823208767981548141052) |
67 | #define GLH_DEG_TO_RAD GLH_REAL(0.0174532925199432957692369076848861) | 67 | #define GLH_DEG_TO_RAD GLH_REAL(0.0174532925199432957692369076848861) |
68 | #define GLH_ZERO GLH_REAL(0.0) | 68 | #define GLH_ZERO GLH_REAL(0.0) |
69 | #define GLH_ONE GLH_REAL(1.0) | 69 | #define GLH_ONE GLH_REAL(1.0) |
70 | #define GLH_TWO GLH_REAL(2.0) | 70 | #define GLH_TWO GLH_REAL(2.0) |
71 | #define GLH_EPSILON GLH_REAL(10e-6) | 71 | #define GLH_EPSILON GLH_REAL(10e-6) |
72 | #define GLH_PI GLH_REAL(3.1415926535897932384626433832795) | 72 | #define GLH_PI GLH_REAL(3.1415926535897932384626433832795) |
73 | 73 | ||
74 | #define equivalent(a,b) (((a < b + GLH_EPSILON) && (a > b - GLH_EPSILON)) ? true : false) | 74 | #define equivalent(a,b) (((a < b + GLH_EPSILON) && (a > b - GLH_EPSILON)) ? true : false) |
75 | 75 | ||
76 | namespace glh | 76 | namespace glh |
77 | { | 77 | { |
78 | 78 | ||
79 | inline GLH_REAL to_degrees(GLH_REAL radians) { return radians*GLH_RAD_TO_DEG; } | 79 | inline GLH_REAL to_degrees(GLH_REAL radians) { return radians*GLH_RAD_TO_DEG; } |
80 | inline GLH_REAL to_radians(GLH_REAL degrees) { return degrees*GLH_DEG_TO_RAD; } | 80 | inline GLH_REAL to_radians(GLH_REAL degrees) { return degrees*GLH_DEG_TO_RAD; } |
81 | 81 | ||
82 | // forward declarations for friend template functions. | 82 | // forward declarations for friend template functions. |
83 | template <int N, class T> class vec; | 83 | template <int N, class T> class vec; |
84 | 84 | ||
85 | // forward declarations for friend template functions. | 85 | // forward declarations for friend template functions. |
86 | template <int N, class T> | 86 | template <int N, class T> |
87 | bool operator == ( const vec<N,T> & v1, const vec<N,T> & v2 ); | 87 | bool operator == ( const vec<N,T> & v1, const vec<N,T> & v2 ); |
88 | 88 | ||
89 | // forward declarations for friend template functions. | 89 | // forward declarations for friend template functions. |
90 | template <int N, class T> | 90 | template <int N, class T> |
91 | bool operator != ( const vec<N,T> & v1, const vec<N,T> & v2 ); | 91 | bool operator != ( const vec<N,T> & v1, const vec<N,T> & v2 ); |
92 | 92 | ||
93 | template <int N, class T> | 93 | template <int N, class T> |
94 | class vec | 94 | class vec |
95 | { | 95 | { |
96 | public: | 96 | public: |
97 | int size() const { return N; } | 97 | int size() const { return N; } |
98 | 98 | ||
99 | vec(const T & t = T()) | 99 | vec(const T & t = T()) |
100 | { for(int i = 0; i < N; i++) v[i] = t; } | 100 | { for(int i = 0; i < N; i++) v[i] = t; } |
101 | vec(const T * tp) | 101 | vec(const T * tp) |
102 | { for(int i = 0; i < N; i++) v[i] = tp[i]; } | 102 | { for(int i = 0; i < N; i++) v[i] = tp[i]; } |
103 | 103 | ||
104 | const T * get_value() const | 104 | const T * get_value() const |
105 | { return v; } | 105 | { return v; } |
106 | 106 | ||
107 | 107 | ||
108 | T dot( const vec<N,T> & rhs ) const | 108 | T dot( const vec<N,T> & rhs ) const |
109 | { | 109 | { |
110 | T r = 0; | 110 | T r = 0; |
111 | for(int i = 0; i < N; i++) r += v[i]*rhs.v[i]; | 111 | for(int i = 0; i < N; i++) r += v[i]*rhs.v[i]; |
112 | return r; | 112 | return r; |
113 | } | 113 | } |
114 | 114 | ||
115 | T length() const | 115 | T length() const |
116 | { | 116 | { |
117 | T r = 0; | 117 | T r = 0; |
118 | for(int i = 0; i < N; i++) r += v[i]*v[i]; | 118 | for(int i = 0; i < N; i++) r += v[i]*v[i]; |
119 | return T(sqrt(r)); | 119 | return T(sqrt(r)); |
120 | } | 120 | } |
121 | 121 | ||
122 | T square_norm() const | 122 | T square_norm() const |
123 | { | 123 | { |
124 | T r = 0; | 124 | T r = 0; |
125 | for(int i = 0; i < N; i++) r += v[i]*v[i]; | 125 | for(int i = 0; i < N; i++) r += v[i]*v[i]; |
126 | return r; | 126 | return r; |
127 | } | 127 | } |
128 | 128 | ||
129 | void negate() | 129 | void negate() |
130 | { for(int i = 0; i < N; i++) v[i] = -v[i]; } | 130 | { for(int i = 0; i < N; i++) v[i] = -v[i]; } |
131 | 131 | ||
132 | 132 | ||
133 | T normalize() | 133 | T normalize() |
134 | { | 134 | { |
135 | T sum(0); | 135 | T sum(0); |
136 | for(int i = 0; i < N; i++) | 136 | for(int i = 0; i < N; i++) |
137 | sum += v[i]*v[i]; | 137 | sum += v[i]*v[i]; |
138 | sum = T(sqrt(sum)); | 138 | sum = T(sqrt(sum)); |
139 | if (sum > GLH_EPSILON) | 139 | if (sum > GLH_EPSILON) |
140 | for(int i = 0; i < N; i++) | 140 | for(int i = 0; i < N; i++) |
141 | v[i] /= sum; | 141 | v[i] /= sum; |
142 | return sum; | 142 | return sum; |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | vec<N,T> & set_value( const T * rhs ) | 146 | vec<N,T> & set_value( const T * rhs ) |
147 | { for(int i = 0; i < N; i++) v[i] = rhs[i]; return *this; } | 147 | { for(int i = 0; i < N; i++) v[i] = rhs[i]; return *this; } |
148 | 148 | ||
149 | T & operator [] ( int i ) | 149 | T & operator [] ( int i ) |
150 | { return v[i]; } | 150 | { return v[i]; } |
151 | 151 | ||
152 | const T & operator [] ( int i ) const | 152 | const T & operator [] ( int i ) const |
153 | { return v[i]; } | 153 | { return v[i]; } |
154 | 154 | ||
155 | vec<N,T> & operator *= ( T d ) | 155 | vec<N,T> & operator *= ( T d ) |
156 | { for(int i = 0; i < N; i++) v[i] *= d; return *this;} | 156 | { for(int i = 0; i < N; i++) v[i] *= d; return *this;} |
157 | 157 | ||
158 | vec<N,T> & operator *= ( const vec<N,T> & u ) | 158 | vec<N,T> & operator *= ( const vec<N,T> & u ) |
159 | { for(int i = 0; i < N; i++) v[i] *= u[i]; return *this;} | 159 | { for(int i = 0; i < N; i++) v[i] *= u[i]; return *this;} |
160 | 160 | ||
161 | vec<N,T> & operator /= ( T d ) | 161 | vec<N,T> & operator /= ( T d ) |
162 | { if(d == 0) return *this; for(int i = 0; i < N; i++) v[i] /= d; return *this;} | 162 | { if(d == 0) return *this; for(int i = 0; i < N; i++) v[i] /= d; return *this;} |
163 | 163 | ||
164 | vec<N,T> & operator += ( const vec<N,T> & u ) | 164 | vec<N,T> & operator += ( const vec<N,T> & u ) |
165 | { for(int i = 0; i < N; i++) v[i] += u.v[i]; return *this;} | 165 | { for(int i = 0; i < N; i++) v[i] += u.v[i]; return *this;} |
166 | 166 | ||
167 | vec<N,T> & operator -= ( const vec<N,T> & u ) | 167 | vec<N,T> & operator -= ( const vec<N,T> & u ) |
168 | { for(int i = 0; i < N; i++) v[i] -= u.v[i]; return *this;} | 168 | { for(int i = 0; i < N; i++) v[i] -= u.v[i]; return *this;} |
169 | 169 | ||
170 | 170 | ||
171 | vec<N,T> operator - () const | 171 | vec<N,T> operator - () const |
172 | { vec<N,T> rv = v; rv.negate(); return rv; } | 172 | { vec<N,T> rv = v; rv.negate(); return rv; } |
173 | 173 | ||
174 | vec<N,T> operator + ( const vec<N,T> &v) const | 174 | vec<N,T> operator + ( const vec<N,T> &v) const |
175 | { vec<N,T> rt(*this); return rt += v; } | 175 | { vec<N,T> rt(*this); return rt += v; } |
176 | 176 | ||
177 | vec<N,T> operator - ( const vec<N,T> &v) const | 177 | vec<N,T> operator - ( const vec<N,T> &v) const |
178 | { vec<N,T> rt(*this); return rt -= v; } | 178 | { vec<N,T> rt(*this); return rt -= v; } |
179 | 179 | ||
180 | vec<N,T> operator * ( T d) const | 180 | vec<N,T> operator * ( T d) const |
181 | { vec<N,T> rt(*this); return rt *= d; } | 181 | { vec<N,T> rt(*this); return rt *= d; } |
182 | 182 | ||
183 | friend bool operator == <> ( const vec<N,T> &v1, const vec<N,T> &v2 ); | 183 | friend bool operator == <> ( const vec<N,T> &v1, const vec<N,T> &v2 ); |
184 | friend bool operator != <> ( const vec<N,T> &v1, const vec<N,T> &v2 ); | 184 | friend bool operator != <> ( const vec<N,T> &v1, const vec<N,T> &v2 ); |
185 | 185 | ||
186 | 186 | ||
187 | //protected: | 187 | //protected: |
188 | T v[N]; | 188 | T v[N]; |
189 | }; | 189 | }; |
190 | 190 | ||
191 | 191 | ||
192 | 192 | ||
193 | // vector friend operators | 193 | // vector friend operators |
194 | 194 | ||
195 | template <int N, class T> inline | 195 | template <int N, class T> inline |
196 | vec<N,T> operator * ( const vec<N,T> & b, T d ) | 196 | vec<N,T> operator * ( const vec<N,T> & b, T d ) |
197 | { | 197 | { |
198 | vec<N,T> rt(b); | 198 | vec<N,T> rt(b); |
199 | return rt *= d; | 199 | return rt *= d; |
200 | } | 200 | } |
201 | 201 | ||
202 | template <int N, class T> inline | 202 | template <int N, class T> inline |
203 | vec<N,T> operator * ( T d, const vec<N,T> & b ) | 203 | vec<N,T> operator * ( T d, const vec<N,T> & b ) |
204 | { return b*d; } | 204 | { return b*d; } |
205 | 205 | ||
206 | template <int N, class T> inline | 206 | template <int N, class T> inline |
207 | vec<N,T> operator * ( const vec<N,T> & b, const vec<N,T> & d ) | 207 | vec<N,T> operator * ( const vec<N,T> & b, const vec<N,T> & d ) |
208 | { | 208 | { |
209 | vec<N,T> rt(b); | 209 | vec<N,T> rt(b); |
210 | return rt *= d; | 210 | return rt *= d; |
211 | } | 211 | } |
212 | 212 | ||
213 | template <int N, class T> inline | 213 | template <int N, class T> inline |
214 | vec<N,T> operator / ( const vec<N,T> & b, T d ) | 214 | vec<N,T> operator / ( const vec<N,T> & b, T d ) |
215 | { vec<N,T> rt(b); return rt /= d; } | 215 | { vec<N,T> rt(b); return rt /= d; } |
216 | 216 | ||
217 | template <int N, class T> inline | 217 | template <int N, class T> inline |
218 | vec<N,T> operator + ( const vec<N,T> & v1, const vec<N,T> & v2 ) | 218 | vec<N,T> operator + ( const vec<N,T> & v1, const vec<N,T> & v2 ) |
219 | { vec<N,T> rt(v1); return rt += v2; } | 219 | { vec<N,T> rt(v1); return rt += v2; } |
220 | 220 | ||
221 | template <int N, class T> inline | 221 | template <int N, class T> inline |
222 | vec<N,T> operator - ( const vec<N,T> & v1, const vec<N,T> & v2 ) | 222 | vec<N,T> operator - ( const vec<N,T> & v1, const vec<N,T> & v2 ) |
223 | { vec<N,T> rt(v1); return rt -= v2; } | 223 | { vec<N,T> rt(v1); return rt -= v2; } |
224 | 224 | ||
225 | 225 | ||
226 | template <int N, class T> inline | 226 | template <int N, class T> inline |
227 | bool operator == ( const vec<N,T> & v1, const vec<N,T> & v2 ) | 227 | bool operator == ( const vec<N,T> & v1, const vec<N,T> & v2 ) |
228 | { | 228 | { |
229 | for(int i = 0; i < N; i++) | 229 | for(int i = 0; i < N; i++) |
230 | if(v1.v[i] != v2.v[i]) | 230 | if(v1.v[i] != v2.v[i]) |
231 | return false; | 231 | return false; |
232 | return true; | 232 | return true; |
233 | } | 233 | } |
234 | 234 | ||
235 | template <int N, class T> inline | 235 | template <int N, class T> inline |
236 | bool operator != ( const vec<N,T> & v1, const vec<N,T> & v2 ) | 236 | bool operator != ( const vec<N,T> & v1, const vec<N,T> & v2 ) |
237 | { return !(v1 == v2); } | 237 | { return !(v1 == v2); } |
238 | 238 | ||
239 | 239 | ||
240 | typedef vec<3,unsigned char> vec3ub; | 240 | typedef vec<3,unsigned char> vec3ub; |
241 | typedef vec<4,unsigned char> vec4ub; | 241 | typedef vec<4,unsigned char> vec4ub; |
242 | 242 | ||
243 | 243 | ||
244 | 244 | ||
245 | 245 | ||
246 | 246 | ||
247 | namespace GLH_REAL_NAMESPACE | 247 | namespace GLH_REAL_NAMESPACE |
248 | { | 248 | { |
249 | typedef GLH_REAL real; | 249 | typedef GLH_REAL real; |
250 | 250 | ||
251 | class line; | 251 | class line; |
252 | class plane; | 252 | class plane; |
253 | class matrix4; | 253 | class matrix4; |
254 | class quaternion; | 254 | class quaternion; |
255 | typedef quaternion rotation; | 255 | typedef quaternion rotation; |
256 | 256 | ||
257 | class vec2 : public vec<2,real> | 257 | class vec2 : public vec<2,real> |
258 | { | 258 | { |
259 | public: | 259 | public: |
260 | vec2(const real & t = real()) : vec<2,real>(t) | 260 | vec2(const real & t = real()) : vec<2,real>(t) |
261 | {} | 261 | {} |
262 | vec2(const vec<2,real> & t) : vec<2,real>(t) | 262 | vec2(const vec<2,real> & t) : vec<2,real>(t) |
263 | {} | 263 | {} |
264 | vec2(const real * tp) : vec<2,real>(tp) | 264 | vec2(const real * tp) : vec<2,real>(tp) |
265 | {} | 265 | {} |
266 | 266 | ||
267 | vec2(real x, real y ) | 267 | vec2(real x, real y ) |
268 | { v[0] = x; v[1] = y; } | 268 | { v[0] = x; v[1] = y; } |
269 | 269 | ||
270 | void get_value(real & x, real & y) const | 270 | void get_value(real & x, real & y) const |
271 | { x = v[0]; y = v[1]; } | 271 | { x = v[0]; y = v[1]; } |
272 | 272 | ||
273 | vec2 & set_value( const real & x, const real & y) | 273 | vec2 & set_value( const real & x, const real & y) |
274 | { v[0] = x; v[1] = y; return *this; } | 274 | { v[0] = x; v[1] = y; return *this; } |
275 | 275 | ||
276 | }; | 276 | }; |
277 | 277 | ||
278 | 278 | ||
279 | class vec3 : public vec<3,real> | 279 | class vec3 : public vec<3,real> |
280 | { | 280 | { |
281 | public: | 281 | public: |
282 | vec3(const real & t = real()) : vec<3,real>(t) | 282 | vec3(const real & t = real()) : vec<3,real>(t) |
283 | {} | 283 | {} |
284 | vec3(const vec<3,real> & t) : vec<3,real>(t) | 284 | vec3(const vec<3,real> & t) : vec<3,real>(t) |
285 | {} | 285 | {} |
286 | vec3(const real * tp) : vec<3,real>(tp) | 286 | vec3(const real * tp) : vec<3,real>(tp) |
287 | {} | 287 | {} |
288 | 288 | ||
289 | vec3(real x, real y, real z) | 289 | vec3(real x, real y, real z) |
290 | { v[0] = x; v[1] = y; v[2] = z; } | 290 | { v[0] = x; v[1] = y; v[2] = z; } |
291 | 291 | ||
292 | void get_value(real & x, real & y, real & z) const | 292 | void get_value(real & x, real & y, real & z) const |
293 | { x = v[0]; y = v[1]; z = v[2]; } | 293 | { x = v[0]; y = v[1]; z = v[2]; } |
294 | 294 | ||
295 | vec3 cross( const vec3 &rhs ) const | 295 | vec3 cross( const vec3 &rhs ) const |
296 | { | 296 | { |
297 | vec3 rt; | 297 | vec3 rt; |
298 | rt.v[0] = v[1]*rhs.v[2]-v[2]*rhs.v[1]; | 298 | rt.v[0] = v[1]*rhs.v[2]-v[2]*rhs.v[1]; |
299 | rt.v[1] = v[2]*rhs.v[0]-v[0]*rhs.v[2]; | 299 | rt.v[1] = v[2]*rhs.v[0]-v[0]*rhs.v[2]; |
300 | rt.v[2] = v[0]*rhs.v[1]-v[1]*rhs.v[0]; | 300 | rt.v[2] = v[0]*rhs.v[1]-v[1]*rhs.v[0]; |
301 | return rt; | 301 | return rt; |
302 | } | 302 | } |
303 | 303 | ||
304 | vec3 & set_value( const real & x, const real & y, const real & z) | 304 | vec3 & set_value( const real & x, const real & y, const real & z) |
305 | { v[0] = x; v[1] = y; v[2] = z; return *this; } | 305 | { v[0] = x; v[1] = y; v[2] = z; return *this; } |
306 | 306 | ||
307 | }; | 307 | }; |
308 | 308 | ||
309 | 309 | ||
310 | class vec4 : public vec<4,real> | 310 | class vec4 : public vec<4,real> |
311 | { | 311 | { |
312 | public: | 312 | public: |
313 | vec4(const real & t = real()) : vec<4,real>(t) | 313 | vec4(const real & t = real()) : vec<4,real>(t) |
314 | {} | 314 | {} |
315 | vec4(const vec<4,real> & t) : vec<4,real>(t) | 315 | vec4(const vec<4,real> & t) : vec<4,real>(t) |
316 | {} | 316 | {} |
317 | 317 | ||
318 | vec4(const vec<3,real> & t, real fourth) | 318 | vec4(const vec<3,real> & t, real fourth) |
319 | 319 | ||
320 | { v[0] = t.v[0]; v[1] = t.v[1]; v[2] = t.v[2]; v[3] = fourth; } | 320 | { v[0] = t.v[0]; v[1] = t.v[1]; v[2] = t.v[2]; v[3] = fourth; } |
321 | vec4(const real * tp) : vec<4,real>(tp) | 321 | vec4(const real * tp) : vec<4,real>(tp) |
322 | {} | 322 | {} |
323 | vec4(real x, real y, real z, real w) | 323 | vec4(real x, real y, real z, real w) |
324 | { v[0] = x; v[1] = y; v[2] = z; v[3] = w; } | 324 | { v[0] = x; v[1] = y; v[2] = z; v[3] = w; } |
325 | 325 | ||
326 | void get_value(real & x, real & y, real & z, real & w) const | 326 | void get_value(real & x, real & y, real & z, real & w) const |
327 | { x = v[0]; y = v[1]; z = v[2]; w = v[3]; } | 327 | { x = v[0]; y = v[1]; z = v[2]; w = v[3]; } |
328 | 328 | ||
329 | vec4 & set_value( const real & x, const real & y, const real & z, const real & w) | 329 | vec4 & set_value( const real & x, const real & y, const real & z, const real & w) |
330 | { v[0] = x; v[1] = y; v[2] = z; v[3] = w; return *this; } | 330 | { v[0] = x; v[1] = y; v[2] = z; v[3] = w; return *this; } |
331 | }; | 331 | }; |
332 | 332 | ||
333 | inline | 333 | inline |
334 | vec3 homogenize(const vec4 & v) | 334 | vec3 homogenize(const vec4 & v) |
335 | { | 335 | { |
336 | vec3 rt; | 336 | vec3 rt; |
337 | assert(v.v[3] != GLH_ZERO); | 337 | assert(v.v[3] != GLH_ZERO); |
338 | rt.v[0] = v.v[0]/v.v[3]; | 338 | rt.v[0] = v.v[0]/v.v[3]; |
339 | rt.v[1] = v.v[1]/v.v[3]; | 339 | rt.v[1] = v.v[1]/v.v[3]; |
340 | rt.v[2] = v.v[2]/v.v[3]; | 340 | rt.v[2] = v.v[2]/v.v[3]; |
341 | return rt; | 341 | return rt; |
342 | } | 342 | } |
343 | 343 | ||
344 | 344 | ||
345 | 345 | ||
346 | class line | 346 | class line |
347 | { | 347 | { |
348 | public: | 348 | public: |
349 | 349 | ||
350 | line() | 350 | line() |
351 | { set_value(vec3(0,0,0),vec3(0,0,1)); } | 351 | { set_value(vec3(0,0,0),vec3(0,0,1)); } |
352 | 352 | ||
353 | line( const vec3 & p0, const vec3 &p1) | 353 | line( const vec3 & p0, const vec3 &p1) |
354 | { set_value(p0,p1); } | 354 | { set_value(p0,p1); } |
355 | 355 | ||
356 | void set_value( const vec3 &p0, const vec3 &p1) | 356 | void set_value( const vec3 &p0, const vec3 &p1) |
357 | { | 357 | { |
358 | position = p0; | 358 | position = p0; |
359 | direction = p1-p0; | 359 | direction = p1-p0; |
360 | direction.normalize(); | 360 | direction.normalize(); |
361 | } | 361 | } |
362 | 362 | ||
363 | bool get_closest_points(const line &line2, | 363 | bool get_closest_points(const line &line2, |
364 | vec3 &pointOnThis, | 364 | vec3 &pointOnThis, |
365 | vec3 &pointOnThat) | 365 | vec3 &pointOnThat) |
366 | { | 366 | { |
367 | 367 | ||
368 | // quick check to see if parallel -- if so, quit. | 368 | // quick check to see if parallel -- if so, quit. |
369 | if(fabs(direction.dot(line2.direction)) == 1.0) | 369 | if(fabs(direction.dot(line2.direction)) == 1.0) |
370 | return 0; | 370 | return 0; |
371 | line l2 = line2; | 371 | line l2 = line2; |
372 | 372 | ||
373 | // Algorithm: Brian Jean | 373 | // Algorithm: Brian Jean |
374 | // | 374 | // |
375 | register real u; | 375 | register real u; |
376 | register real v; | 376 | register real v; |
377 | vec3 Vr = direction; | 377 | vec3 Vr = direction; |
378 | vec3 Vs = l2.direction; | 378 | vec3 Vs = l2.direction; |
379 | register real Vr_Dot_Vs = Vr.dot(Vs); | 379 | register real Vr_Dot_Vs = Vr.dot(Vs); |
380 | register real detA = real(1.0 - (Vr_Dot_Vs * Vr_Dot_Vs)); | 380 | register real detA = real(1.0 - (Vr_Dot_Vs * Vr_Dot_Vs)); |
381 | vec3 C = l2.position - position; | 381 | vec3 C = l2.position - position; |
382 | register real C_Dot_Vr = C.dot(Vr); | 382 | register real C_Dot_Vr = C.dot(Vr); |
383 | register real C_Dot_Vs = C.dot(Vs); | 383 | register real C_Dot_Vs = C.dot(Vs); |
384 | 384 | ||
385 | u = (C_Dot_Vr - Vr_Dot_Vs * C_Dot_Vs)/detA; | 385 | u = (C_Dot_Vr - Vr_Dot_Vs * C_Dot_Vs)/detA; |
386 | v = (C_Dot_Vr * Vr_Dot_Vs - C_Dot_Vs)/detA; | 386 | v = (C_Dot_Vr * Vr_Dot_Vs - C_Dot_Vs)/detA; |
387 | 387 | ||
388 | pointOnThis = position; | 388 | pointOnThis = position; |
389 | pointOnThis += direction * u; | 389 | pointOnThis += direction * u; |
390 | pointOnThat = l2.position; | 390 | pointOnThat = l2.position; |
391 | pointOnThat += l2.direction * v; | 391 | pointOnThat += l2.direction * v; |
392 | 392 | ||
393 | return 1; | 393 | return 1; |
394 | } | 394 | } |
395 | 395 | ||
396 | vec3 get_closest_point(const vec3 &point) | 396 | vec3 get_closest_point(const vec3 &point) |
397 | { | 397 | { |
398 | vec3 np = point - position; | 398 | vec3 np = point - position; |
399 | vec3 rp = direction*direction.dot(np)+position; | 399 | vec3 rp = direction*direction.dot(np)+position; |
400 | return rp; | 400 | return rp; |
401 | } | 401 | } |
402 | 402 | ||
403 | const vec3 & get_position() const {return position;} | 403 | const vec3 & get_position() const {return position;} |
404 | 404 | ||
405 | const vec3 & get_direction() const {return direction;} | 405 | const vec3 & get_direction() const {return direction;} |
406 | 406 | ||
407 | //protected: | 407 | //protected: |
408 | vec3 position; | 408 | vec3 position; |
409 | vec3 direction; | 409 | vec3 direction; |
410 | }; | 410 | }; |
411 | 411 | ||
412 | 412 | ||
413 | 413 | ||
414 | 414 | ||
415 | 415 | ||
416 | 416 | ||
417 | 417 | ||
418 | 418 | ||
419 | 419 | ||
420 | 420 | ||
421 | 421 | ||
422 | 422 | ||
423 | 423 | ||
424 | 424 | ||
425 | 425 | ||
426 | 426 | ||
427 | 427 | ||
428 | 428 | ||
429 | 429 | ||
430 | 430 | ||
431 | 431 | ||
432 | 432 | ||
433 | 433 | ||
434 | 434 | ||
435 | 435 | ||
436 | 436 | ||
437 | 437 | ||
438 | 438 | ||
439 | 439 | ||
440 | // matrix | 440 | // matrix |
441 | 441 | ||
442 | 442 | ||
443 | class matrix4 | 443 | class matrix4 |
444 | { | 444 | { |
445 | 445 | ||
446 | public: | 446 | public: |
447 | 447 | ||
448 | matrix4() { make_identity(); } | 448 | matrix4() { make_identity(); } |
449 | 449 | ||
450 | matrix4( real r ) | 450 | matrix4( real r ) |
451 | { set_value(r); } | 451 | { set_value(r); } |
452 | 452 | ||
453 | matrix4( real * m ) | 453 | matrix4( real * m ) |
454 | { set_value(m); } | 454 | { set_value(m); } |
455 | 455 | ||
456 | matrix4( real a00, real a01, real a02, real a03, | 456 | matrix4( real a00, real a01, real a02, real a03, |
457 | real a10, real a11, real a12, real a13, | 457 | real a10, real a11, real a12, real a13, |
458 | real a20, real a21, real a22, real a23, | 458 | real a20, real a21, real a22, real a23, |
459 | real a30, real a31, real a32, real a33 ) | 459 | real a30, real a31, real a32, real a33 ) |
460 | { | 460 | { |
461 | element(0,0) = a00; | 461 | element(0,0) = a00; |
462 | element(0,1) = a01; | 462 | element(0,1) = a01; |
463 | element(0,2) = a02; | 463 | element(0,2) = a02; |
464 | element(0,3) = a03; | 464 | element(0,3) = a03; |
465 | 465 | ||
466 | element(1,0) = a10; | 466 | element(1,0) = a10; |
467 | element(1,1) = a11; | 467 | element(1,1) = a11; |
468 | element(1,2) = a12; | 468 | element(1,2) = a12; |
469 | element(1,3) = a13; | 469 | element(1,3) = a13; |
470 | 470 | ||
471 | element(2,0) = a20; | 471 | element(2,0) = a20; |
472 | element(2,1) = a21; | 472 | element(2,1) = a21; |
473 | element(2,2) = a22; | 473 | element(2,2) = a22; |
474 | element(2,3) = a23; | 474 | element(2,3) = a23; |
475 | 475 | ||
476 | element(3,0) = a30; | 476 | element(3,0) = a30; |
477 | element(3,1) = a31; | 477 | element(3,1) = a31; |
478 | element(3,2) = a32; | 478 | element(3,2) = a32; |
479 | element(3,3) = a33; | 479 | element(3,3) = a33; |
480 | } | 480 | } |
481 | 481 | ||
482 | 482 | ||
483 | void get_value( real * mp ) const | 483 | void get_value( real * mp ) const |
484 | { | 484 | { |
485 | int c = 0; | 485 | int c = 0; |
486 | for(int j=0; j < 4; j++) | 486 | for(int j=0; j < 4; j++) |
487 | for(int i=0; i < 4; i++) | 487 | for(int i=0; i < 4; i++) |
488 | mp[c++] = element(i,j); | 488 | mp[c++] = element(i,j); |
489 | } | 489 | } |
490 | 490 | ||
491 | 491 | ||
492 | const real * get_value() const | 492 | const real * get_value() const |
493 | { return m; } | 493 | { return m; } |
494 | 494 | ||
495 | void set_value( real * mp) | 495 | void set_value( real * mp) |
496 | { | 496 | { |
497 | int c = 0; | 497 | int c = 0; |
498 | for(int j=0; j < 4; j++) | 498 | for(int j=0; j < 4; j++) |
499 | for(int i=0; i < 4; i++) | 499 | for(int i=0; i < 4; i++) |
500 | element(i,j) = mp[c++]; | 500 | element(i,j) = mp[c++]; |
501 | } | 501 | } |
502 | 502 | ||
503 | void set_value( real r ) | 503 | void set_value( real r ) |
504 | { | 504 | { |
505 | for(int i=0; i < 4; i++) | 505 | for(int i=0; i < 4; i++) |
506 | for(int j=0; j < 4; j++) | 506 | for(int j=0; j < 4; j++) |
507 | element(i,j) = r; | 507 | element(i,j) = r; |
508 | } | 508 | } |
509 | 509 | ||
510 | void make_identity() | 510 | void make_identity() |
511 | { | 511 | { |
512 | element(0,0) = 1.0; | 512 | element(0,0) = 1.0; |
513 | element(0,1) = 0.0; | 513 | element(0,1) = 0.0; |
514 | element(0,2) = 0.0; | 514 | element(0,2) = 0.0; |
515 | element(0,3) = 0.0; | 515 | element(0,3) = 0.0; |
516 | 516 | ||
517 | element(1,0) = 0.0; | 517 | element(1,0) = 0.0; |
518 | element(1,1) = 1.0; | 518 | element(1,1) = 1.0; |
519 | element(1,2) = 0.0; | 519 | element(1,2) = 0.0; |
520 | element(1,3) = 0.0; | 520 | element(1,3) = 0.0; |
521 | 521 | ||
522 | element(2,0) = 0.0; | 522 | element(2,0) = 0.0; |
523 | element(2,1) = 0.0; | 523 | element(2,1) = 0.0; |
524 | element(2,2) = 1.0; | 524 | element(2,2) = 1.0; |
525 | element(2,3) = 0.0; | 525 | element(2,3) = 0.0; |
526 | 526 | ||
527 | element(3,0) = 0.0; | 527 | element(3,0) = 0.0; |
528 | element(3,1) = 0.0; | 528 | element(3,1) = 0.0; |
529 | element(3,2) = 0.0; | 529 | element(3,2) = 0.0; |
530 | element(3,3) = 1.0; | 530 | element(3,3) = 1.0; |
531 | } | 531 | } |
532 | 532 | ||
533 | 533 | ||
534 | static matrix4 identity() | 534 | static matrix4 identity() |
535 | { | 535 | { |
536 | static matrix4 mident ( | 536 | static matrix4 mident ( |
537 | 1.0, 0.0, 0.0, 0.0, | 537 | 1.0, 0.0, 0.0, 0.0, |
538 | 0.0, 1.0, 0.0, 0.0, | 538 | 0.0, 1.0, 0.0, 0.0, |
539 | 0.0, 0.0, 1.0, 0.0, | 539 | 0.0, 0.0, 1.0, 0.0, |
540 | 0.0, 0.0, 0.0, 1.0 ); | 540 | 0.0, 0.0, 0.0, 1.0 ); |
541 | return mident; | 541 | return mident; |
542 | } | 542 | } |
543 | 543 | ||
544 | 544 | ||
545 | void set_scale( real s ) | 545 | void set_scale( real s ) |
546 | { | 546 | { |
547 | element(0,0) = s; | 547 | element(0,0) = s; |
548 | element(1,1) = s; | 548 | element(1,1) = s; |
549 | element(2,2) = s; | 549 | element(2,2) = s; |
550 | } | 550 | } |
551 | 551 | ||
552 | void set_scale( const vec3 & s ) | 552 | void set_scale( const vec3 & s ) |
553 | { | 553 | { |
554 | element(0,0) = s.v[0]; | 554 | element(0,0) = s.v[0]; |
555 | element(1,1) = s.v[1]; | 555 | element(1,1) = s.v[1]; |
556 | element(2,2) = s.v[2]; | 556 | element(2,2) = s.v[2]; |
557 | } | 557 | } |
558 | 558 | ||
559 | 559 | ||
560 | void set_translate( const vec3 & t ) | 560 | void set_translate( const vec3 & t ) |
561 | { | 561 | { |
562 | element(0,3) = t.v[0]; | 562 | element(0,3) = t.v[0]; |
563 | element(1,3) = t.v[1]; | 563 | element(1,3) = t.v[1]; |
564 | element(2,3) = t.v[2]; | 564 | element(2,3) = t.v[2]; |
565 | } | 565 | } |
566 | 566 | ||
567 | void set_row(int r, const vec4 & t) | 567 | void set_row(int r, const vec4 & t) |
568 | { | 568 | { |
569 | element(r,0) = t.v[0]; | 569 | element(r,0) = t.v[0]; |
570 | element(r,1) = t.v[1]; | 570 | element(r,1) = t.v[1]; |
571 | element(r,2) = t.v[2]; | 571 | element(r,2) = t.v[2]; |
572 | element(r,3) = t.v[3]; | 572 | element(r,3) = t.v[3]; |
573 | } | 573 | } |
574 | 574 | ||
575 | void set_column(int c, const vec4 & t) | 575 | void set_column(int c, const vec4 & t) |
576 | { | 576 | { |
577 | element(0,c) = t.v[0]; | 577 | element(0,c) = t.v[0]; |
578 | element(1,c) = t.v[1]; | 578 | element(1,c) = t.v[1]; |
579 | element(2,c) = t.v[2]; | 579 | element(2,c) = t.v[2]; |
580 | element(3,c) = t.v[3]; | 580 | element(3,c) = t.v[3]; |
581 | } | 581 | } |
582 | 582 | ||
583 | 583 | ||
584 | void get_row(int r, vec4 & t) const | 584 | void get_row(int r, vec4 & t) const |
585 | { | 585 | { |
586 | t.v[0] = element(r,0); | 586 | t.v[0] = element(r,0); |
587 | t.v[1] = element(r,1); | 587 | t.v[1] = element(r,1); |
588 | t.v[2] = element(r,2); | 588 | t.v[2] = element(r,2); |
589 | t.v[3] = element(r,3); | 589 | t.v[3] = element(r,3); |
590 | } | 590 | } |
591 | 591 | ||
592 | vec4 get_row(int r) const | 592 | vec4 get_row(int r) const |
593 | { | 593 | { |
594 | vec4 v; get_row(r, v); | 594 | vec4 v; get_row(r, v); |
595 | return v; | 595 | return v; |
596 | } | 596 | } |
597 | 597 | ||
598 | void get_column(int c, vec4 & t) const | 598 | void get_column(int c, vec4 & t) const |
599 | { | 599 | { |
600 | t.v[0] = element(0,c); | 600 | t.v[0] = element(0,c); |
601 | t.v[1] = element(1,c); | 601 | t.v[1] = element(1,c); |
602 | t.v[2] = element(2,c); | 602 | t.v[2] = element(2,c); |
603 | t.v[3] = element(3,c); | 603 | t.v[3] = element(3,c); |
604 | } | 604 | } |
605 | 605 | ||
606 | vec4 get_column(int c) const | 606 | vec4 get_column(int c) const |
607 | { | 607 | { |
608 | vec4 v; get_column(c, v); | 608 | vec4 v; get_column(c, v); |
609 | return v; | 609 | return v; |
610 | } | 610 | } |
611 | 611 | ||
612 | matrix4 inverse() const | 612 | matrix4 inverse() const |
613 | { | 613 | { |
614 | matrix4 minv; | 614 | matrix4 minv; |
615 | 615 | ||
616 | real r1[8], r2[8], r3[8], r4[8]; | 616 | real r1[8], r2[8], r3[8], r4[8]; |
617 | real *s[4], *tmprow; | 617 | real *s[4], *tmprow; |
618 | 618 | ||
619 | s[0] = &r1[0]; | 619 | s[0] = &r1[0]; |
620 | s[1] = &r2[0]; | 620 | s[1] = &r2[0]; |
621 | s[2] = &r3[0]; | 621 | s[2] = &r3[0]; |
622 | s[3] = &r4[0]; | 622 | s[3] = &r4[0]; |
623 | 623 | ||
624 | register int i,j,p,jj; | 624 | register int i,j,p,jj; |
625 | for(i=0;i<4;i++) | 625 | for(i=0;i<4;i++) |
626 | { | 626 | { |
627 | for(j=0;j<4;j++) | 627 | for(j=0;j<4;j++) |
628 | { | 628 | { |
629 | s[i][j] = element(i,j); | 629 | s[i][j] = element(i,j); |
630 | if(i==j) s[i][j+4] = 1.0; | 630 | if(i==j) s[i][j+4] = 1.0; |
631 | else s[i][j+4] = 0.0; | 631 | else s[i][j+4] = 0.0; |
632 | } | 632 | } |
633 | } | 633 | } |
634 | real scp[4]; | 634 | real scp[4]; |
635 | for(i=0;i<4;i++) | 635 | for(i=0;i<4;i++) |
636 | { | 636 | { |
637 | scp[i] = real(fabs(s[i][0])); | 637 | scp[i] = real(fabs(s[i][0])); |
638 | for(j=1;j<4;j++) | 638 | for(j=1;j<4;j++) |
639 | if(real(fabs(s[i][j])) > scp[i]) scp[i] = real(fabs(s[i][j])); | 639 | if(real(fabs(s[i][j])) > scp[i]) scp[i] = real(fabs(s[i][j])); |
640 | if(scp[i] == 0.0) return minv; // singular matrix! | 640 | if(scp[i] == 0.0) return minv; // singular matrix! |
641 | } | 641 | } |
642 | 642 | ||
643 | int pivot_to; | 643 | int pivot_to; |
644 | real scp_max; | 644 | real scp_max; |
645 | for(i=0;i<4;i++) | 645 | for(i=0;i<4;i++) |
646 | { | 646 | { |
647 | // select pivot row | 647 | // select pivot row |
648 | pivot_to = i; | 648 | pivot_to = i; |
649 | scp_max = real(fabs(s[i][i]/scp[i])); | 649 | scp_max = real(fabs(s[i][i]/scp[i])); |
650 | // find out which row should be on top | 650 | // find out which row should be on top |
651 | for(p=i+1;p<4;p++) | 651 | for(p=i+1;p<4;p++) |
652 | if(real(fabs(s[p][i]/scp[p])) > scp_max) | 652 | if(real(fabs(s[p][i]/scp[p])) > scp_max) |
653 | { scp_max = real(fabs(s[p][i]/scp[p])); pivot_to = p; } | 653 | { scp_max = real(fabs(s[p][i]/scp[p])); pivot_to = p; } |
654 | // Pivot if necessary | 654 | // Pivot if necessary |
655 | if(pivot_to != i) | 655 | if(pivot_to != i) |
656 | { | 656 | { |
657 | tmprow = s[i]; | 657 | tmprow = s[i]; |
658 | s[i] = s[pivot_to]; | 658 | s[i] = s[pivot_to]; |
659 | s[pivot_to] = tmprow; | 659 | s[pivot_to] = tmprow; |
660 | real tmpscp; | 660 | real tmpscp; |
661 | tmpscp = scp[i]; | 661 | tmpscp = scp[i]; |
662 | scp[i] = scp[pivot_to]; | 662 | scp[i] = scp[pivot_to]; |
663 | scp[pivot_to] = tmpscp; | 663 | scp[pivot_to] = tmpscp; |
664 | } | 664 | } |
665 | 665 | ||
666 | real mji; | 666 | real mji; |
667 | // perform gaussian elimination | 667 | // perform gaussian elimination |
668 | for(j=i+1;j<4;j++) | 668 | for(j=i+1;j<4;j++) |
669 | { | 669 | { |
670 | mji = s[j][i]/s[i][i]; | 670 | mji = s[j][i]/s[i][i]; |
671 | s[j][i] = 0.0; | 671 | s[j][i] = 0.0; |
672 | for(jj=i+1;jj<8;jj++) | 672 | for(jj=i+1;jj<8;jj++) |
673 | s[j][jj] -= mji*s[i][jj]; | 673 | s[j][jj] -= mji*s[i][jj]; |
674 | } | 674 | } |
675 | } | 675 | } |
676 | if(s[3][3] == 0.0) return minv; // singular matrix! | 676 | if(s[3][3] == 0.0) return minv; // singular matrix! |
677 | 677 | ||
678 | // | 678 | // |
679 | // Now we have an upper triangular matrix. | 679 | // Now we have an upper triangular matrix. |
680 | // | 680 | // |
681 | // x x x x | y y y y | 681 | // x x x x | y y y y |
682 | // 0 x x x | y y y y | 682 | // 0 x x x | y y y y |
683 | // 0 0 x x | y y y y | 683 | // 0 0 x x | y y y y |
684 | // 0 0 0 x | y y y y | 684 | // 0 0 0 x | y y y y |
685 | // | 685 | // |
686 | // we'll back substitute to get the inverse | 686 | // we'll back substitute to get the inverse |
687 | // | 687 | // |
688 | // 1 0 0 0 | z z z z | 688 | // 1 0 0 0 | z z z z |
689 | // 0 1 0 0 | z z z z | 689 | // 0 1 0 0 | z z z z |
690 | // 0 0 1 0 | z z z z | 690 | // 0 0 1 0 | z z z z |
691 | // 0 0 0 1 | z z z z | 691 | // 0 0 0 1 | z z z z |
692 | // | 692 | // |
693 | 693 | ||
694 | real mij; | 694 | real mij; |
695 | for(i=3;i>0;i--) | 695 | for(i=3;i>0;i--) |
696 | { | 696 | { |
697 | for(j=i-1;j > -1; j--) | 697 | for(j=i-1;j > -1; j--) |
698 | { | 698 | { |
699 | mij = s[j][i]/s[i][i]; | 699 | mij = s[j][i]/s[i][i]; |
700 | for(jj=j+1;jj<8;jj++) | 700 | for(jj=j+1;jj<8;jj++) |
701 | s[j][jj] -= mij*s[i][jj]; | 701 | s[j][jj] -= mij*s[i][jj]; |
702 | } | 702 | } |
703 | } | 703 | } |
704 | 704 | ||
705 | for(i=0;i<4;i++) | 705 | for(i=0;i<4;i++) |
706 | for(j=0;j<4;j++) | 706 | for(j=0;j<4;j++) |
707 | minv(i,j) = s[i][j+4] / s[i][i]; | 707 | minv(i,j) = s[i][j+4] / s[i][i]; |
708 | 708 | ||
709 | return minv; | 709 | return minv; |
710 | } | 710 | } |
711 | 711 | ||
712 | 712 | ||
713 | matrix4 transpose() const | 713 | matrix4 transpose() const |
714 | { | 714 | { |
715 | matrix4 mtrans; | 715 | matrix4 mtrans; |
716 | 716 | ||
717 | for(int i=0;i<4;i++) | 717 | for(int i=0;i<4;i++) |
718 | for(int j=0;j<4;j++) | 718 | for(int j=0;j<4;j++) |
719 | mtrans(i,j) = element(j,i); | 719 | mtrans(i,j) = element(j,i); |
720 | return mtrans; | 720 | return mtrans; |
721 | } | 721 | } |
722 | 722 | ||
723 | matrix4 & mult_right( const matrix4 & b ) | 723 | matrix4 & mult_right( const matrix4 & b ) |
724 | { | 724 | { |
725 | matrix4 mt(*this); | 725 | matrix4 mt(*this); |
726 | set_value(real(0)); | 726 | set_value(real(0)); |
727 | 727 | ||
728 | for(int i=0; i < 4; i++) | 728 | for(int i=0; i < 4; i++) |
729 | for(int j=0; j < 4; j++) | 729 | for(int j=0; j < 4; j++) |
730 | for(int c=0; c < 4; c++) | 730 | for(int c=0; c < 4; c++) |
731 | element(i,j) += mt(i,c) * b(c,j); | 731 | element(i,j) += mt(i,c) * b(c,j); |
732 | return *this; | 732 | return *this; |
733 | } | 733 | } |
734 | 734 | ||
735 | matrix4 & mult_left( const matrix4 & b ) | 735 | matrix4 & mult_left( const matrix4 & b ) |
736 | { | 736 | { |
737 | matrix4 mt(*this); | 737 | matrix4 mt(*this); |
738 | set_value(real(0)); | 738 | set_value(real(0)); |
739 | 739 | ||
740 | for(int i=0; i < 4; i++) | 740 | for(int i=0; i < 4; i++) |
741 | for(int j=0; j < 4; j++) | 741 | for(int j=0; j < 4; j++) |
742 | for(int c=0; c < 4; c++) | 742 | for(int c=0; c < 4; c++) |
743 | element(i,j) += b(i,c) * mt(c,j); | 743 | element(i,j) += b(i,c) * mt(c,j); |
744 | return *this; | 744 | return *this; |
745 | } | 745 | } |
746 | 746 | ||
747 | // dst = M * src | 747 | // dst = M * src |
748 | void mult_matrix_vec( const vec3 &src, vec3 &dst ) const | 748 | void mult_matrix_vec( const vec3 &src, vec3 &dst ) const |
749 | { | 749 | { |
750 | real w = ( | 750 | real w = ( |
751 | src.v[0] * element(3,0) + | 751 | src.v[0] * element(3,0) + |
752 | src.v[1] * element(3,1) + | 752 | src.v[1] * element(3,1) + |
753 | src.v[2] * element(3,2) + | 753 | src.v[2] * element(3,2) + |
754 | element(3,3) ); | 754 | element(3,3) ); |
755 | 755 | ||
756 | assert(w != GLH_ZERO); | 756 | assert(w != GLH_ZERO); |
757 | 757 | ||
758 | dst.v[0] = ( | 758 | dst.v[0] = ( |
759 | src.v[0] * element(0,0) + | 759 | src.v[0] * element(0,0) + |
760 | src.v[1] * element(0,1) + | 760 | src.v[1] * element(0,1) + |
761 | src.v[2] * element(0,2) + | 761 | src.v[2] * element(0,2) + |
762 | element(0,3) ) / w; | 762 | element(0,3) ) / w; |
763 | dst.v[1] = ( | 763 | dst.v[1] = ( |
764 | src.v[0] * element(1,0) + | 764 | src.v[0] * element(1,0) + |
765 | src.v[1] * element(1,1) + | 765 | src.v[1] * element(1,1) + |
766 | src.v[2] * element(1,2) + | 766 | src.v[2] * element(1,2) + |
767 | element(1,3) ) / w; | 767 | element(1,3) ) / w; |
768 | dst.v[2] = ( | 768 | dst.v[2] = ( |
769 | src.v[0] * element(2,0) + | 769 | src.v[0] * element(2,0) + |
770 | src.v[1] * element(2,1) + | 770 | src.v[1] * element(2,1) + |
771 | src.v[2] * element(2,2) + | 771 | src.v[2] * element(2,2) + |
772 | element(2,3) ) / w; | 772 | element(2,3) ) / w; |
773 | } | 773 | } |
774 | 774 | ||
775 | void mult_matrix_vec( vec3 & src_and_dst) const | 775 | void mult_matrix_vec( vec3 & src_and_dst) const |
776 | { mult_matrix_vec(vec3(src_and_dst), src_and_dst); } | 776 | { mult_matrix_vec(vec3(src_and_dst), src_and_dst); } |
777 | 777 | ||
778 | 778 | ||
779 | // dst = src * M | 779 | // dst = src * M |
780 | void mult_vec_matrix( const vec3 &src, vec3 &dst ) const | 780 | void mult_vec_matrix( const vec3 &src, vec3 &dst ) const |
781 | { | 781 | { |
782 | real w = ( | 782 | real w = ( |
783 | src.v[0] * element(0,3) + | 783 | src.v[0] * element(0,3) + |
784 | src.v[1] * element(1,3) + | 784 | src.v[1] * element(1,3) + |
785 | src.v[2] * element(2,3) + | 785 | src.v[2] * element(2,3) + |
786 | element(3,3) ); | 786 | element(3,3) ); |
787 | 787 | ||
788 | assert(w != GLH_ZERO); | 788 | assert(w != GLH_ZERO); |
789 | 789 | ||
790 | dst.v[0] = ( | 790 | dst.v[0] = ( |
791 | src.v[0] * element(0,0) + | 791 | src.v[0] * element(0,0) + |
792 | src.v[1] * element(1,0) + | 792 | src.v[1] * element(1,0) + |
793 | src.v[2] * element(2,0) + | 793 | src.v[2] * element(2,0) + |
794 | element(3,0) ) / w; | 794 | element(3,0) ) / w; |
795 | dst.v[1] = ( | 795 | dst.v[1] = ( |
796 | src.v[0] * element(0,1) + | 796 | src.v[0] * element(0,1) + |
797 | src.v[1] * element(1,1) + | 797 | src.v[1] * element(1,1) + |
798 | src.v[2] * element(2,1) + | 798 | src.v[2] * element(2,1) + |
799 | element(3,1) ) / w; | 799 | element(3,1) ) / w; |
800 | dst.v[2] = ( | 800 | dst.v[2] = ( |
801 | src.v[0] * element(0,2) + | 801 | src.v[0] * element(0,2) + |
802 | src.v[1] * element(1,2) + | 802 | src.v[1] * element(1,2) + |
803 | src.v[2] * element(2,2) + | 803 | src.v[2] * element(2,2) + |
804 | element(3,2) ) / w; | 804 | element(3,2) ) / w; |
805 | } | 805 | } |
806 | 806 | ||
807 | 807 | ||
808 | void mult_vec_matrix( vec3 & src_and_dst) const | 808 | void mult_vec_matrix( vec3 & src_and_dst) const |
809 | { mult_vec_matrix(vec3(src_and_dst), src_and_dst); } | 809 | { mult_vec_matrix(vec3(src_and_dst), src_and_dst); } |
810 | 810 | ||
811 | // dst = M * src | 811 | // dst = M * src |
812 | void mult_matrix_vec( const vec4 &src, vec4 &dst ) const | 812 | void mult_matrix_vec( const vec4 &src, vec4 &dst ) const |
813 | { | 813 | { |
814 | dst.v[0] = ( | 814 | dst.v[0] = ( |
815 | src.v[0] * element(0,0) + | 815 | src.v[0] * element(0,0) + |
816 | src.v[1] * element(0,1) + | 816 | src.v[1] * element(0,1) + |
817 | src.v[2] * element(0,2) + | 817 | src.v[2] * element(0,2) + |
818 | src.v[3] * element(0,3)); | 818 | src.v[3] * element(0,3)); |
819 | dst.v[1] = ( | 819 | dst.v[1] = ( |
820 | src.v[0] * element(1,0) + | 820 | src.v[0] * element(1,0) + |
821 | src.v[1] * element(1,1) + | 821 | src.v[1] * element(1,1) + |
822 | src.v[2] * element(1,2) + | 822 | src.v[2] * element(1,2) + |
823 | src.v[3] * element(1,3)); | 823 | src.v[3] * element(1,3)); |
824 | dst.v[2] = ( | 824 | dst.v[2] = ( |
825 | src.v[0] * element(2,0) + | 825 | src.v[0] * element(2,0) + |
826 | src.v[1] * element(2,1) + | 826 | src.v[1] * element(2,1) + |
827 | src.v[2] * element(2,2) + | 827 | src.v[2] * element(2,2) + |
828 | src.v[3] * element(2,3)); | 828 | src.v[3] * element(2,3)); |
829 | dst.v[3] = ( | 829 | dst.v[3] = ( |
830 | src.v[0] * element(3,0) + | 830 | src.v[0] * element(3,0) + |
831 | src.v[1] * element(3,1) + | 831 | src.v[1] * element(3,1) + |
832 | src.v[2] * element(3,2) + | 832 | src.v[2] * element(3,2) + |
833 | src.v[3] * element(3,3)); | 833 | src.v[3] * element(3,3)); |
834 | } | 834 | } |
835 | 835 | ||
836 | void mult_matrix_vec( vec4 & src_and_dst) const | 836 | void mult_matrix_vec( vec4 & src_and_dst) const |
837 | { mult_matrix_vec(vec4(src_and_dst), src_and_dst); } | 837 | { mult_matrix_vec(vec4(src_and_dst), src_and_dst); } |
838 | 838 | ||
839 | 839 | ||
840 | // dst = src * M | 840 | // dst = src * M |
841 | void mult_vec_matrix( const vec4 &src, vec4 &dst ) const | 841 | void mult_vec_matrix( const vec4 &src, vec4 &dst ) const |
842 | { | 842 | { |
843 | dst.v[0] = ( | 843 | dst.v[0] = ( |
844 | src.v[0] * element(0,0) + | 844 | src.v[0] * element(0,0) + |
845 | src.v[1] * element(1,0) + | 845 | src.v[1] * element(1,0) + |
846 | src.v[2] * element(2,0) + | 846 | src.v[2] * element(2,0) + |
847 | src.v[3] * element(3,0)); | 847 | src.v[3] * element(3,0)); |
848 | dst.v[1] = ( | 848 | dst.v[1] = ( |
849 | src.v[0] * element(0,1) + | 849 | src.v[0] * element(0,1) + |
850 | src.v[1] * element(1,1) + | 850 | src.v[1] * element(1,1) + |
851 | src.v[2] * element(2,1) + | 851 | src.v[2] * element(2,1) + |
852 | src.v[3] * element(3,1)); | 852 | src.v[3] * element(3,1)); |
853 | dst.v[2] = ( | 853 | dst.v[2] = ( |
854 | src.v[0] * element(0,2) + | 854 | src.v[0] * element(0,2) + |
855 | src.v[1] * element(1,2) + | 855 | src.v[1] * element(1,2) + |
856 | src.v[2] * element(2,2) + | 856 | src.v[2] * element(2,2) + |
857 | src.v[3] * element(3,2)); | 857 | src.v[3] * element(3,2)); |
858 | dst.v[3] = ( | 858 | dst.v[3] = ( |
859 | src.v[0] * element(0,3) + | 859 | src.v[0] * element(0,3) + |
860 | src.v[1] * element(1,3) + | 860 | src.v[1] * element(1,3) + |
861 | src.v[2] * element(2,3) + | 861 | src.v[2] * element(2,3) + |
862 | src.v[3] * element(3,3)); | 862 | src.v[3] * element(3,3)); |
863 | } | 863 | } |
864 | 864 | ||
865 | 865 | ||
866 | void mult_vec_matrix( vec4 & src_and_dst) const | 866 | void mult_vec_matrix( vec4 & src_and_dst) const |
867 | { mult_vec_matrix(vec4(src_and_dst), src_and_dst); } | 867 | { mult_vec_matrix(vec4(src_and_dst), src_and_dst); } |
868 | 868 | ||
869 | 869 | ||
870 | // dst = M * src | 870 | // dst = M * src |
871 | void mult_matrix_dir( const vec3 &src, vec3 &dst ) const | 871 | void mult_matrix_dir( const vec3 &src, vec3 &dst ) const |
872 | { | 872 | { |
873 | dst.v[0] = ( | 873 | dst.v[0] = ( |
874 | src.v[0] * element(0,0) + | 874 | src.v[0] * element(0,0) + |
875 | src.v[1] * element(0,1) + | 875 | src.v[1] * element(0,1) + |
876 | src.v[2] * element(0,2) ) ; | 876 | src.v[2] * element(0,2) ) ; |
877 | dst.v[1] = ( | 877 | dst.v[1] = ( |
878 | src.v[0] * element(1,0) + | 878 | src.v[0] * element(1,0) + |
879 | src.v[1] * element(1,1) + | 879 | src.v[1] * element(1,1) + |
880 | src.v[2] * element(1,2) ) ; | 880 | src.v[2] * element(1,2) ) ; |
881 | dst.v[2] = ( | 881 | dst.v[2] = ( |
882 | src.v[0] * element(2,0) + | 882 | src.v[0] * element(2,0) + |
883 | src.v[1] * element(2,1) + | 883 | src.v[1] * element(2,1) + |
884 | src.v[2] * element(2,2) ) ; | 884 | src.v[2] * element(2,2) ) ; |
885 | } | 885 | } |
886 | 886 | ||
887 | 887 | ||
888 | void mult_matrix_dir( vec3 & src_and_dst) const | 888 | void mult_matrix_dir( vec3 & src_and_dst) const |
889 | { mult_matrix_dir(vec3(src_and_dst), src_and_dst); } | 889 | { mult_matrix_dir(vec3(src_and_dst), src_and_dst); } |
890 | 890 | ||
891 | 891 | ||
892 | // dst = src * M | 892 | // dst = src * M |
893 | void mult_dir_matrix( const vec3 &src, vec3 &dst ) const | 893 | void mult_dir_matrix( const vec3 &src, vec3 &dst ) const |
894 | { | 894 | { |
895 | dst.v[0] = ( | 895 | dst.v[0] = ( |
896 | src.v[0] * element(0,0) + | 896 | src.v[0] * element(0,0) + |
897 | src.v[1] * element(1,0) + | 897 | src.v[1] * element(1,0) + |
898 | src.v[2] * element(2,0) ) ; | 898 | src.v[2] * element(2,0) ) ; |
899 | dst.v[1] = ( | 899 | dst.v[1] = ( |
900 | src.v[0] * element(0,1) + | 900 | src.v[0] * element(0,1) + |
901 | src.v[1] * element(1,1) + | 901 | src.v[1] * element(1,1) + |
902 | src.v[2] * element(2,1) ) ; | 902 | src.v[2] * element(2,1) ) ; |
903 | dst.v[2] = ( | 903 | dst.v[2] = ( |
904 | src.v[0] * element(0,2) + | 904 | src.v[0] * element(0,2) + |
905 | src.v[1] * element(1,2) + | 905 | src.v[1] * element(1,2) + |
906 | src.v[2] * element(2,2) ) ; | 906 | src.v[2] * element(2,2) ) ; |
907 | } | 907 | } |
908 | 908 | ||
909 | 909 | ||
910 | void mult_dir_matrix( vec3 & src_and_dst) const | 910 | void mult_dir_matrix( vec3 & src_and_dst) const |
911 | { mult_dir_matrix(vec3(src_and_dst), src_and_dst); } | 911 | { mult_dir_matrix(vec3(src_and_dst), src_and_dst); } |
912 | 912 | ||
913 | 913 | ||
914 | real & operator () (int row, int col) | 914 | real & operator () (int row, int col) |
915 | { return element(row,col); } | 915 | { return element(row,col); } |
916 | 916 | ||
917 | const real & operator () (int row, int col) const | 917 | const real & operator () (int row, int col) const |
918 | { return element(row,col); } | 918 | { return element(row,col); } |
919 | 919 | ||
920 | real & element (int row, int col) | 920 | real & element (int row, int col) |
921 | { return m[row | (col<<2)]; } | 921 | { return m[row | (col<<2)]; } |
922 | 922 | ||
923 | const real & element (int row, int col) const | 923 | const real & element (int row, int col) const |
924 | { return m[row | (col<<2)]; } | 924 | { return m[row | (col<<2)]; } |
925 | 925 | ||
926 | matrix4 & operator *= ( const matrix4 & mat ) | 926 | matrix4 & operator *= ( const matrix4 & mat ) |
927 | { | 927 | { |
928 | mult_right( mat ); | 928 | mult_right( mat ); |
929 | return *this; | 929 | return *this; |
930 | } | 930 | } |
931 | 931 | ||
932 | matrix4 & operator *= ( const real & r ) | 932 | matrix4 & operator *= ( const real & r ) |
933 | { | 933 | { |
934 | for (int i = 0; i < 4; ++i) | 934 | for (int i = 0; i < 4; ++i) |
935 | { | 935 | { |
936 | element(0,i) *= r; | 936 | element(0,i) *= r; |
937 | element(1,i) *= r; | 937 | element(1,i) *= r; |
938 | element(2,i) *= r; | 938 | element(2,i) *= r; |
939 | element(3,i) *= r; | 939 | element(3,i) *= r; |
940 | } | 940 | } |
941 | return *this; | 941 | return *this; |
942 | } | 942 | } |
943 | 943 | ||
944 | matrix4 & operator += ( const matrix4 & mat ) | 944 | matrix4 & operator += ( const matrix4 & mat ) |
945 | { | 945 | { |
946 | for (int i = 0; i < 4; ++i) | 946 | for (int i = 0; i < 4; ++i) |
947 | { | 947 | { |
948 | element(0,i) += mat.element(0,i); | 948 | element(0,i) += mat.element(0,i); |
949 | element(1,i) += mat.element(1,i); | 949 | element(1,i) += mat.element(1,i); |
950 | element(2,i) += mat.element(2,i); | 950 | element(2,i) += mat.element(2,i); |
951 | element(3,i) += mat.element(3,i); | 951 | element(3,i) += mat.element(3,i); |
952 | } | 952 | } |
953 | return *this; | 953 | return *this; |
954 | } | 954 | } |
955 | 955 | ||
956 | friend matrix4 operator * ( const matrix4 & m1, const matrix4 & m2 ); | 956 | friend matrix4 operator * ( const matrix4 & m1, const matrix4 & m2 ); |
957 | friend bool operator == ( const matrix4 & m1, const matrix4 & m2 ); | 957 | friend bool operator == ( const matrix4 & m1, const matrix4 & m2 ); |
958 | friend bool operator != ( const matrix4 & m1, const matrix4 & m2 ); | 958 | friend bool operator != ( const matrix4 & m1, const matrix4 & m2 ); |
959 | 959 | ||
960 | //protected: | 960 | //protected: |
961 | real m[16]; | 961 | real m[16]; |
962 | }; | 962 | }; |
963 | 963 | ||
964 | inline | 964 | inline |
965 | matrix4 operator * ( const matrix4 & m1, const matrix4 & m2 ) | 965 | matrix4 operator * ( const matrix4 & m1, const matrix4 & m2 ) |
966 | { | 966 | { |
967 | matrix4 product; | 967 | matrix4 product; |
968 | 968 | ||
969 | product = m1; | 969 | product = m1; |
970 | product.mult_right(m2); | 970 | product.mult_right(m2); |
971 | 971 | ||
972 | return product; | 972 | return product; |
973 | } | 973 | } |
974 | 974 | ||
975 | inline | 975 | inline |
976 | bool operator ==( const matrix4 &m1, const matrix4 &m2 ) | 976 | bool operator ==( const matrix4 &m1, const matrix4 &m2 ) |
977 | { | 977 | { |
978 | return ( | 978 | return ( |
979 | m1(0,0) == m2(0,0) && | 979 | m1(0,0) == m2(0,0) && |
980 | m1(0,1) == m2(0,1) && | 980 | m1(0,1) == m2(0,1) && |
981 | m1(0,2) == m2(0,2) && | 981 | m1(0,2) == m2(0,2) && |
982 | m1(0,3) == m2(0,3) && | 982 | m1(0,3) == m2(0,3) && |
983 | m1(1,0) == m2(1,0) && | 983 | m1(1,0) == m2(1,0) && |
984 | m1(1,1) == m2(1,1) && | 984 | m1(1,1) == m2(1,1) && |
985 | m1(1,2) == m2(1,2) && | 985 | m1(1,2) == m2(1,2) && |
986 | m1(1,3) == m2(1,3) && | 986 | m1(1,3) == m2(1,3) && |
987 | m1(2,0) == m2(2,0) && | 987 | m1(2,0) == m2(2,0) && |
988 | m1(2,1) == m2(2,1) && | 988 | m1(2,1) == m2(2,1) && |
989 | m1(2,2) == m2(2,2) && | 989 | m1(2,2) == m2(2,2) && |
990 | m1(2,3) == m2(2,3) && | 990 | m1(2,3) == m2(2,3) && |
991 | m1(3,0) == m2(3,0) && | 991 | m1(3,0) == m2(3,0) && |
992 | m1(3,1) == m2(3,1) && | 992 | m1(3,1) == m2(3,1) && |
993 | m1(3,2) == m2(3,2) && | 993 | m1(3,2) == m2(3,2) && |
994 | m1(3,3) == m2(3,3) ); | 994 | m1(3,3) == m2(3,3) ); |
995 | } | 995 | } |
996 | 996 | ||
997 | inline | 997 | inline |
998 | bool operator != ( const matrix4 & m1, const matrix4 & m2 ) | 998 | bool operator != ( const matrix4 & m1, const matrix4 & m2 ) |
999 | { return !( m1 == m2 ); } | 999 | { return !( m1 == m2 ); } |
1000 | 1000 | ||
1001 | 1001 | ||
1002 | 1002 | ||
1003 | 1003 | ||
1004 | 1004 | ||
1005 | 1005 | ||
1006 | 1006 | ||
1007 | 1007 | ||
1008 | 1008 | ||
1009 | 1009 | ||
1010 | 1010 | ||
1011 | 1011 | ||
1012 | 1012 | ||
1013 | class quaternion | 1013 | class quaternion |
1014 | { | 1014 | { |
1015 | public: | 1015 | public: |
1016 | 1016 | ||
1017 | quaternion() | 1017 | quaternion() |
1018 | { | 1018 | { |
1019 | *this = identity(); | 1019 | *this = identity(); |
1020 | } | 1020 | } |
1021 | 1021 | ||
1022 | quaternion( const real v[4] ) | 1022 | quaternion( const real v[4] ) |
1023 | { | 1023 | { |
1024 | set_value( v ); | 1024 | set_value( v ); |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | 1027 | ||
1028 | quaternion( real q0, real q1, real q2, real q3 ) | 1028 | quaternion( real q0, real q1, real q2, real q3 ) |
1029 | { | 1029 | { |
1030 | set_value( q0, q1, q2, q3 ); | 1030 | set_value( q0, q1, q2, q3 ); |
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | 1033 | ||
1034 | quaternion( const matrix4 & m ) | 1034 | quaternion( const matrix4 & m ) |
1035 | { | 1035 | { |
1036 | set_value( m ); | 1036 | set_value( m ); |
1037 | } | 1037 | } |
1038 | 1038 | ||
1039 | 1039 | ||
1040 | quaternion( const vec3 &axis, real radians ) | 1040 | quaternion( const vec3 &axis, real radians ) |
1041 | { | 1041 | { |
1042 | set_value( axis, radians ); | 1042 | set_value( axis, radians ); |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | 1045 | ||
1046 | quaternion( const vec3 &rotateFrom, const vec3 &rotateTo ) | 1046 | quaternion( const vec3 &rotateFrom, const vec3 &rotateTo ) |
1047 | { | 1047 | { |
1048 | set_value( rotateFrom, rotateTo ); | 1048 | set_value( rotateFrom, rotateTo ); |
1049 | } | 1049 | } |
1050 | 1050 | ||
1051 | quaternion( const vec3 & from_look, const vec3 & from_up, | 1051 | quaternion( const vec3 & from_look, const vec3 & from_up, |
1052 | const vec3 & to_look, const vec3& to_up) | 1052 | const vec3 & to_look, const vec3& to_up) |
1053 | { | 1053 | { |
1054 | set_value(from_look, from_up, to_look, to_up); | 1054 | set_value(from_look, from_up, to_look, to_up); |
1055 | } | 1055 | } |
1056 | 1056 | ||
1057 | const real * get_value() const | 1057 | const real * get_value() const |
1058 | { | 1058 | { |
1059 | return &q[0]; | 1059 | return &q[0]; |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | void get_value( real &q0, real &q1, real &q2, real &q3 ) const | 1062 | void get_value( real &q0, real &q1, real &q2, real &q3 ) const |
1063 | { | 1063 | { |
1064 | q0 = q[0]; | 1064 | q0 = q[0]; |
1065 | q1 = q[1]; | 1065 | q1 = q[1]; |
1066 | q2 = q[2]; | 1066 | q2 = q[2]; |
1067 | q3 = q[3]; | 1067 | q3 = q[3]; |
1068 | } | 1068 | } |
1069 | 1069 | ||
1070 | quaternion & set_value( real q0, real q1, real q2, real q3 ) | 1070 | quaternion & set_value( real q0, real q1, real q2, real q3 ) |
1071 | { | 1071 | { |
1072 | q[0] = q0; | 1072 | q[0] = q0; |
1073 | q[1] = q1; | 1073 | q[1] = q1; |
1074 | q[2] = q2; | 1074 | q[2] = q2; |
1075 | q[3] = q3; | 1075 | q[3] = q3; |
1076 | counter = 0; | 1076 | counter = 0; |
1077 | return *this; | 1077 | return *this; |
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | void get_value( vec3 &axis, real &radians ) const | 1080 | void get_value( vec3 &axis, real &radians ) const |
1081 | { | 1081 | { |
1082 | radians = real(acos( q[3] ) * GLH_TWO); | 1082 | radians = real(acos( q[3] ) * GLH_TWO); |
1083 | if ( radians == GLH_ZERO ) | 1083 | if ( radians == GLH_ZERO ) |
1084 | axis = vec3( 0.0, 0.0, 1.0 ); | 1084 | axis = vec3( 0.0, 0.0, 1.0 ); |
1085 | else | 1085 | else |
1086 | { | 1086 | { |
1087 | axis.v[0] = q[0]; | 1087 | axis.v[0] = q[0]; |
1088 | axis.v[1] = q[1]; | 1088 | axis.v[1] = q[1]; |
1089 | axis.v[2] = q[2]; | 1089 | axis.v[2] = q[2]; |
1090 | axis.normalize(); | 1090 | axis.normalize(); |
1091 | } | 1091 | } |
1092 | } | 1092 | } |
1093 | 1093 | ||
1094 | void get_value( matrix4 & m ) const | 1094 | void get_value( matrix4 & m ) const |
1095 | { | 1095 | { |
1096 | real s, xs, ys, zs, wx, wy, wz, xx, xy, xz, yy, yz, zz; | 1096 | real s, xs, ys, zs, wx, wy, wz, xx, xy, xz, yy, yz, zz; |
1097 | 1097 | ||
1098 | real norm = q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3]; | 1098 | real norm = q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3]; |
1099 | 1099 | ||
1100 | s = (equivalent(norm,GLH_ZERO)) ? GLH_ZERO : ( GLH_TWO / norm ); | 1100 | s = (equivalent(norm,GLH_ZERO)) ? GLH_ZERO : ( GLH_TWO / norm ); |
1101 | 1101 | ||
1102 | xs = q[0] * s; | 1102 | xs = q[0] * s; |
1103 | ys = q[1] * s; | 1103 | ys = q[1] * s; |
1104 | zs = q[2] * s; | 1104 | zs = q[2] * s; |
1105 | 1105 | ||
1106 | wx = q[3] * xs; | 1106 | wx = q[3] * xs; |
1107 | wy = q[3] * ys; | 1107 | wy = q[3] * ys; |
1108 | wz = q[3] * zs; | 1108 | wz = q[3] * zs; |
1109 | 1109 | ||
1110 | xx = q[0] * xs; | 1110 | xx = q[0] * xs; |
1111 | xy = q[0] * ys; | 1111 | xy = q[0] * ys; |
1112 | xz = q[0] * zs; | 1112 | xz = q[0] * zs; |
1113 | 1113 | ||
1114 | yy = q[1] * ys; | 1114 | yy = q[1] * ys; |
1115 | yz = q[1] * zs; | 1115 | yz = q[1] * zs; |
1116 | zz = q[2] * zs; | 1116 | zz = q[2] * zs; |
1117 | 1117 | ||
1118 | m(0,0) = real( GLH_ONE - ( yy + zz )); | 1118 | m(0,0) = real( GLH_ONE - ( yy + zz )); |
1119 | m(1,0) = real ( xy + wz ); | 1119 | m(1,0) = real ( xy + wz ); |
1120 | m(2,0) = real ( xz - wy ); | 1120 | m(2,0) = real ( xz - wy ); |
1121 | 1121 | ||
1122 | m(0,1) = real ( xy - wz ); | 1122 | m(0,1) = real ( xy - wz ); |
1123 | m(1,1) = real ( GLH_ONE - ( xx + zz )); | 1123 | m(1,1) = real ( GLH_ONE - ( xx + zz )); |
1124 | m(2,1) = real ( yz + wx ); | 1124 | m(2,1) = real ( yz + wx ); |
1125 | 1125 | ||
1126 | m(0,2) = real ( xz + wy ); | 1126 | m(0,2) = real ( xz + wy ); |
1127 | m(1,2) = real ( yz - wx ); | 1127 | m(1,2) = real ( yz - wx ); |
1128 | m(2,2) = real ( GLH_ONE - ( xx + yy )); | 1128 | m(2,2) = real ( GLH_ONE - ( xx + yy )); |
1129 | 1129 | ||
1130 | m(3,0) = m(3,1) = m(3,2) = m(0,3) = m(1,3) = m(2,3) = GLH_ZERO; | 1130 | m(3,0) = m(3,1) = m(3,2) = m(0,3) = m(1,3) = m(2,3) = GLH_ZERO; |
1131 | m(3,3) = GLH_ONE; | 1131 | m(3,3) = GLH_ONE; |
1132 | } | 1132 | } |
1133 | 1133 | ||
1134 | quaternion & set_value( const real * qp ) | 1134 | quaternion & set_value( const real * qp ) |
1135 | { | 1135 | { |
1136 | memcpy(q,qp,sizeof(real) * 4); | 1136 | memcpy(q,qp,sizeof(real) * 4); |
1137 | 1137 | ||
1138 | counter = 0; | 1138 | counter = 0; |
1139 | return *this; | 1139 | return *this; |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | quaternion & set_value( const matrix4 & m ) | 1142 | quaternion & set_value( const matrix4 & m ) |
1143 | { | 1143 | { |
1144 | real tr, s; | 1144 | real tr, s; |
1145 | int i, j, k; | 1145 | int i, j, k; |
1146 | const int nxt[3] = { 1, 2, 0 }; | 1146 | const int nxt[3] = { 1, 2, 0 }; |
1147 | 1147 | ||
1148 | tr = m(0,0) + m(1,1) + m(2,2); | 1148 | tr = m(0,0) + m(1,1) + m(2,2); |
1149 | 1149 | ||
1150 | if ( tr > GLH_ZERO ) | 1150 | if ( tr > GLH_ZERO ) |
1151 | { | 1151 | { |
1152 | s = real(sqrt( tr + m(3,3) )); | 1152 | s = real(sqrt( tr + m(3,3) )); |
1153 | q[3] = real ( s * 0.5 ); | 1153 | q[3] = real ( s * 0.5 ); |
1154 | s = real(0.5) / s; | 1154 | s = real(0.5) / s; |
1155 | 1155 | ||
1156 | q[0] = real ( ( m(1,2) - m(2,1) ) * s ); | 1156 | q[0] = real ( ( m(1,2) - m(2,1) ) * s ); |
1157 | q[1] = real ( ( m(2,0) - m(0,2) ) * s ); | 1157 | q[1] = real ( ( m(2,0) - m(0,2) ) * s ); |
1158 | q[2] = real ( ( m(0,1) - m(1,0) ) * s ); | 1158 | q[2] = real ( ( m(0,1) - m(1,0) ) * s ); |
1159 | } | 1159 | } |
1160 | else | 1160 | else |
1161 | { | 1161 | { |
1162 | i = 0; | 1162 | i = 0; |
1163 | if ( m(1,1) > m(0,0) ) | 1163 | if ( m(1,1) > m(0,0) ) |
1164 | i = 1; | 1164 | i = 1; |
1165 | 1165 | ||
1166 | if ( m(2,2) > m(i,i) ) | 1166 | if ( m(2,2) > m(i,i) ) |
1167 | i = 2; | 1167 | i = 2; |
1168 | 1168 | ||
1169 | j = nxt[i]; | 1169 | j = nxt[i]; |
1170 | k = nxt[j]; | 1170 | k = nxt[j]; |
1171 | 1171 | ||
1172 | s = real(sqrt( ( m(i,j) - ( m(j,j) + m(k,k) )) + GLH_ONE )); | 1172 | s = real(sqrt( ( m(i,j) - ( m(j,j) + m(k,k) )) + GLH_ONE )); |
1173 | 1173 | ||
1174 | q[i] = real ( s * 0.5 ); | 1174 | q[i] = real ( s * 0.5 ); |
1175 | s = real(0.5 / s); | 1175 | s = real(0.5 / s); |
1176 | 1176 | ||
1177 | q[3] = real ( ( m(j,k) - m(k,j) ) * s ); | 1177 | q[3] = real ( ( m(j,k) - m(k,j) ) * s ); |
1178 | q[j] = real ( ( m(i,j) + m(j,i) ) * s ); | 1178 | q[j] = real ( ( m(i,j) + m(j,i) ) * s ); |
1179 | q[k] = real ( ( m(i,k) + m(k,i) ) * s ); | 1179 | q[k] = real ( ( m(i,k) + m(k,i) ) * s ); |
1180 | } | 1180 | } |
1181 | 1181 | ||
1182 | counter = 0; | 1182 | counter = 0; |
1183 | return *this; | 1183 | return *this; |
1184 | } | 1184 | } |
1185 | 1185 | ||
1186 | quaternion & set_value( const vec3 &axis, real theta ) | 1186 | quaternion & set_value( const vec3 &axis, real theta ) |
1187 | { | 1187 | { |
1188 | real sqnorm = axis.square_norm(); | 1188 | real sqnorm = axis.square_norm(); |
1189 | 1189 | ||
1190 | if (sqnorm <= GLH_EPSILON) | 1190 | if (sqnorm <= GLH_EPSILON) |
1191 | { | 1191 | { |
1192 | // axis too small. | 1192 | // axis too small. |
1193 | x = y = z = 0.0; | 1193 | x = y = z = 0.0; |
1194 | w = 1.0; | 1194 | w = 1.0; |
1195 | } | 1195 | } |
1196 | else | 1196 | else |
1197 | { | 1197 | { |
1198 | theta *= real(0.5); | 1198 | theta *= real(0.5); |
1199 | real sin_theta = real(sin(theta)); | 1199 | real sin_theta = real(sin(theta)); |
1200 | 1200 | ||
1201 | if (!equivalent(sqnorm,GLH_ONE)) | 1201 | if (!equivalent(sqnorm,GLH_ONE)) |
1202 | sin_theta /= real(sqrt(sqnorm)); | 1202 | sin_theta /= real(sqrt(sqnorm)); |
1203 | x = sin_theta * axis.v[0]; | 1203 | x = sin_theta * axis.v[0]; |
1204 | y = sin_theta * axis.v[1]; | 1204 | y = sin_theta * axis.v[1]; |
1205 | z = sin_theta * axis.v[2]; | 1205 | z = sin_theta * axis.v[2]; |
1206 | w = real(cos(theta)); | 1206 | w = real(cos(theta)); |
1207 | } | 1207 | } |
1208 | return *this; | 1208 | return *this; |
1209 | } | 1209 | } |
1210 | 1210 | ||
1211 | quaternion & set_value( const vec3 & rotateFrom, const vec3 & rotateTo ) | 1211 | quaternion & set_value( const vec3 & rotateFrom, const vec3 & rotateTo ) |
1212 | { | 1212 | { |
1213 | vec3 p1, p2; | 1213 | vec3 p1, p2; |
1214 | real alpha; | 1214 | real alpha; |
1215 | 1215 | ||
1216 | p1 = rotateFrom; | 1216 | p1 = rotateFrom; |
1217 | p1.normalize(); | 1217 | p1.normalize(); |
1218 | p2 = rotateTo; | 1218 | p2 = rotateTo; |
1219 | p2.normalize(); | 1219 | p2.normalize(); |
1220 | 1220 | ||
1221 | alpha = p1.dot(p2); | 1221 | alpha = p1.dot(p2); |
1222 | 1222 | ||
1223 | if(equivalent(alpha,GLH_ONE)) | 1223 | if(equivalent(alpha,GLH_ONE)) |
1224 | { | 1224 | { |
1225 | *this = identity(); | 1225 | *this = identity(); |
1226 | return *this; | 1226 | return *this; |
1227 | } | 1227 | } |
1228 | 1228 | ||
1229 | // ensures that the anti-parallel case leads to a positive dot | 1229 | // ensures that the anti-parallel case leads to a positive dot |
1230 | if(equivalent(alpha,-GLH_ONE)) | 1230 | if(equivalent(alpha,-GLH_ONE)) |
1231 | { | 1231 | { |
1232 | vec3 v; | 1232 | vec3 v; |
1233 | 1233 | ||
1234 | if(p1.v[0] != p1.v[1] || p1.v[0] != p1.v[2]) | 1234 | if(p1.v[0] != p1.v[1] || p1.v[0] != p1.v[2]) |
1235 | v = vec3(p1.v[1], p1.v[2], p1.v[0]); | 1235 | v = vec3(p1.v[1], p1.v[2], p1.v[0]); |
1236 | else | 1236 | else |
1237 | v = vec3(-p1.v[0], p1.v[1], p1.v[2]); | 1237 | v = vec3(-p1.v[0], p1.v[1], p1.v[2]); |
1238 | 1238 | ||
1239 | v -= p1 * p1.dot(v); | 1239 | v -= p1 * p1.dot(v); |
1240 | v.normalize(); | 1240 | v.normalize(); |
1241 | 1241 | ||
1242 | set_value(v, GLH_PI); | 1242 | set_value(v, GLH_PI); |
1243 | return *this; | 1243 | return *this; |
1244 | } | 1244 | } |
1245 | 1245 | ||
1246 | p1 = p1.cross(p2); | 1246 | p1 = p1.cross(p2); |
1247 | p1.normalize(); | 1247 | p1.normalize(); |
1248 | set_value(p1,real(acos(alpha))); | 1248 | set_value(p1,real(acos(alpha))); |
1249 | 1249 | ||
1250 | counter = 0; | 1250 | counter = 0; |
1251 | return *this; | 1251 | return *this; |
1252 | } | 1252 | } |
1253 | 1253 | ||
1254 | quaternion & set_value( const vec3 & from_look, const vec3 & from_up, | 1254 | quaternion & set_value( const vec3 & from_look, const vec3 & from_up, |
1255 | const vec3 & to_look, const vec3 & to_up) | 1255 | const vec3 & to_look, const vec3 & to_up) |
1256 | { | 1256 | { |
1257 | quaternion r_look = quaternion(from_look, to_look); | 1257 | quaternion r_look = quaternion(from_look, to_look); |
1258 | 1258 | ||
1259 | vec3 rotated_from_up(from_up); | 1259 | vec3 rotated_from_up(from_up); |
1260 | r_look.mult_vec(rotated_from_up); | 1260 | r_look.mult_vec(rotated_from_up); |
1261 | 1261 | ||
1262 | quaternion r_twist = quaternion(rotated_from_up, to_up); | 1262 | quaternion r_twist = quaternion(rotated_from_up, to_up); |
1263 | 1263 | ||
1264 | *this = r_twist; | 1264 | *this = r_twist; |
1265 | *this *= r_look; | 1265 | *this *= r_look; |
1266 | return *this; | 1266 | return *this; |
1267 | } | 1267 | } |
1268 | 1268 | ||
1269 | quaternion & operator *= ( const quaternion & qr ) | 1269 | quaternion & operator *= ( const quaternion & qr ) |
1270 | { | 1270 | { |
1271 | quaternion ql(*this); | 1271 | quaternion ql(*this); |
1272 | 1272 | ||
1273 | w = ql.w * qr.w - ql.x * qr.x - ql.y * qr.y - ql.z * qr.z; | 1273 | w = ql.w * qr.w - ql.x * qr.x - ql.y * qr.y - ql.z * qr.z; |
1274 | x = ql.w * qr.x + ql.x * qr.w + ql.y * qr.z - ql.z * qr.y; | 1274 | x = ql.w * qr.x + ql.x * qr.w + ql.y * qr.z - ql.z * qr.y; |
1275 | y = ql.w * qr.y + ql.y * qr.w + ql.z * qr.x - ql.x * qr.z; | 1275 | y = ql.w * qr.y + ql.y * qr.w + ql.z * qr.x - ql.x * qr.z; |
1276 | z = ql.w * qr.z + ql.z * qr.w + ql.x * qr.y - ql.y * qr.x; | 1276 | z = ql.w * qr.z + ql.z * qr.w + ql.x * qr.y - ql.y * qr.x; |
1277 | 1277 | ||
1278 | counter += qr.counter; | 1278 | counter += qr.counter; |
1279 | counter++; | 1279 | counter++; |
1280 | counter_normalize(); | 1280 | counter_normalize(); |
1281 | return *this; | 1281 | return *this; |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | void normalize() | 1284 | void normalize() |
1285 | { | 1285 | { |
1286 | real rnorm = GLH_ONE / real(sqrt(w * w + x * x + y * y + z * z)); | 1286 | real rnorm = GLH_ONE / real(sqrt(w * w + x * x + y * y + z * z)); |
1287 | if (equivalent(rnorm, GLH_ZERO)) | 1287 | if (equivalent(rnorm, GLH_ZERO)) |
1288 | return; | 1288 | return; |
1289 | x *= rnorm; | 1289 | x *= rnorm; |
1290 | y *= rnorm; | 1290 | y *= rnorm; |
1291 | z *= rnorm; | 1291 | z *= rnorm; |
1292 | w *= rnorm; | 1292 | w *= rnorm; |
1293 | counter = 0; | 1293 | counter = 0; |
1294 | } | 1294 | } |
1295 | 1295 | ||
1296 | friend bool operator == ( const quaternion & q1, const quaternion & q2 ); | 1296 | friend bool operator == ( const quaternion & q1, const quaternion & q2 ); |
1297 | 1297 | ||
1298 | friend bool operator != ( const quaternion & q1, const quaternion & q2 ); | 1298 | friend bool operator != ( const quaternion & q1, const quaternion & q2 ); |
1299 | 1299 | ||
1300 | friend quaternion operator * ( const quaternion & q1, const quaternion & q2 ); | 1300 | friend quaternion operator * ( const quaternion & q1, const quaternion & q2 ); |
1301 | 1301 | ||
1302 | bool equals( const quaternion & r, real tolerance ) const | 1302 | bool equals( const quaternion & r, real tolerance ) const |
1303 | { | 1303 | { |
1304 | real t; | 1304 | real t; |
1305 | 1305 | ||
1306 | t = ( | 1306 | t = ( |
1307 | (q[0]-r.q[0])*(q[0]-r.q[0]) + | 1307 | (q[0]-r.q[0])*(q[0]-r.q[0]) + |
1308 | (q[1]-r.q[1])*(q[1]-r.q[1]) + | 1308 | (q[1]-r.q[1])*(q[1]-r.q[1]) + |
1309 | (q[2]-r.q[2])*(q[2]-r.q[2]) + | 1309 | (q[2]-r.q[2])*(q[2]-r.q[2]) + |
1310 | (q[3]-r.q[3])*(q[3]-r.q[3]) ); | 1310 | (q[3]-r.q[3])*(q[3]-r.q[3]) ); |
1311 | if(t > GLH_EPSILON) | 1311 | if(t > GLH_EPSILON) |
1312 | return false; | 1312 | return false; |
1313 | return 1; | 1313 | return 1; |
1314 | } | 1314 | } |
1315 | 1315 | ||
1316 | quaternion & conjugate() | 1316 | quaternion & conjugate() |
1317 | { | 1317 | { |
1318 | q[0] *= -GLH_ONE; | 1318 | q[0] *= -GLH_ONE; |
1319 | q[1] *= -GLH_ONE; | 1319 | q[1] *= -GLH_ONE; |
1320 | q[2] *= -GLH_ONE; | 1320 | q[2] *= -GLH_ONE; |
1321 | return *this; | 1321 | return *this; |
1322 | } | 1322 | } |
1323 | 1323 | ||
1324 | quaternion & invert() | 1324 | quaternion & invert() |
1325 | { | 1325 | { |
1326 | return conjugate(); | 1326 | return conjugate(); |
1327 | } | 1327 | } |
1328 | 1328 | ||
1329 | quaternion inverse() const | 1329 | quaternion inverse() const |
1330 | { | 1330 | { |
1331 | quaternion r = *this; | 1331 | quaternion r = *this; |
1332 | return r.invert(); | 1332 | return r.invert(); |
1333 | } | 1333 | } |
1334 | 1334 | ||
1335 | // | 1335 | // |
1336 | // Quaternion multiplication with cartesian vector | 1336 | // Quaternion multiplication with cartesian vector |
1337 | // v' = q*v*q(star) | 1337 | // v' = q*v*q(star) |
1338 | // | 1338 | // |
1339 | void mult_vec( const vec3 &src, vec3 &dst ) const | 1339 | void mult_vec( const vec3 &src, vec3 &dst ) const |
1340 | { | 1340 | { |
1341 | real v_coef = w * w - x * x - y * y - z * z; | 1341 | real v_coef = w * w - x * x - y * y - z * z; |
1342 | real u_coef = GLH_TWO * (src.v[0] * x + src.v[1] * y + src.v[2] * z); | 1342 | real u_coef = GLH_TWO * (src.v[0] * x + src.v[1] * y + src.v[2] * z); |
1343 | real c_coef = GLH_TWO * w; | 1343 | real c_coef = GLH_TWO * w; |
1344 | 1344 | ||
1345 | dst.v[0] = v_coef * src.v[0] + u_coef * x + c_coef * (y * src.v[2] - z * src.v[1]); | 1345 | dst.v[0] = v_coef * src.v[0] + u_coef * x + c_coef * (y * src.v[2] - z * src.v[1]); |
1346 | dst.v[1] = v_coef * src.v[1] + u_coef * y + c_coef * (z * src.v[0] - x * src.v[2]); | 1346 | dst.v[1] = v_coef * src.v[1] + u_coef * y + c_coef * (z * src.v[0] - x * src.v[2]); |
1347 | dst.v[2] = v_coef * src.v[2] + u_coef * z + c_coef * (x * src.v[1] - y * src.v[0]); | 1347 | dst.v[2] = v_coef * src.v[2] + u_coef * z + c_coef * (x * src.v[1] - y * src.v[0]); |
1348 | } | 1348 | } |
1349 | 1349 | ||
1350 | void mult_vec( vec3 & src_and_dst) const | 1350 | void mult_vec( vec3 & src_and_dst) const |
1351 | { | 1351 | { |
1352 | mult_vec(vec3(src_and_dst), src_and_dst); | 1352 | mult_vec(vec3(src_and_dst), src_and_dst); |
1353 | } | 1353 | } |
1354 | 1354 | ||
1355 | void scale_angle( real scaleFactor ) | 1355 | void scale_angle( real scaleFactor ) |
1356 | { | 1356 | { |
1357 | vec3 axis; | 1357 | vec3 axis; |
1358 | real radians; | 1358 | real radians; |
1359 | 1359 | ||
1360 | get_value(axis, radians); | 1360 | get_value(axis, radians); |
1361 | radians *= scaleFactor; | 1361 | radians *= scaleFactor; |
1362 | set_value(axis, radians); | 1362 | set_value(axis, radians); |
1363 | } | 1363 | } |
1364 | 1364 | ||
1365 | static quaternion slerp( const quaternion & p, const quaternion & q, real alpha ) | 1365 | static quaternion slerp( const quaternion & p, const quaternion & q, real alpha ) |
1366 | { | 1366 | { |
1367 | quaternion r; | 1367 | quaternion r; |
1368 | 1368 | ||
1369 | real cos_omega = p.x * q.x + p.y * q.y + p.z * q.z + p.w * q.w; | 1369 | real cos_omega = p.x * q.x + p.y * q.y + p.z * q.z + p.w * q.w; |
1370 | // if B is on opposite hemisphere from A, use -B instead | 1370 | // if B is on opposite hemisphere from A, use -B instead |
1371 | 1371 | ||
1372 | int bflip; | 1372 | int bflip; |
1373 | if ( ( bflip = (cos_omega < GLH_ZERO)) ) | 1373 | if ( ( bflip = (cos_omega < GLH_ZERO)) ) |
1374 | cos_omega = -cos_omega; | 1374 | cos_omega = -cos_omega; |
1375 | 1375 | ||
1376 | // complementary interpolation parameter | 1376 | // complementary interpolation parameter |
1377 | real beta = GLH_ONE - alpha; | 1377 | real beta = GLH_ONE - alpha; |
1378 | 1378 | ||
1379 | if(cos_omega <= GLH_ONE - GLH_EPSILON) | 1379 | if(cos_omega <= GLH_ONE - GLH_EPSILON) |
1380 | return p; | 1380 | return p; |
1381 | 1381 | ||
1382 | real omega = real(acos(cos_omega)); | 1382 | real omega = real(acos(cos_omega)); |
1383 | real one_over_sin_omega = GLH_ONE / real(sin(omega)); | 1383 | real one_over_sin_omega = GLH_ONE / real(sin(omega)); |
1384 | 1384 | ||
1385 | beta = real(sin(omega*beta) * one_over_sin_omega); | 1385 | beta = real(sin(omega*beta) * one_over_sin_omega); |
1386 | alpha = real(sin(omega*alpha) * one_over_sin_omega); | 1386 | alpha = real(sin(omega*alpha) * one_over_sin_omega); |
1387 | 1387 | ||
1388 | if (bflip) | 1388 | if (bflip) |
1389 | alpha = -alpha; | 1389 | alpha = -alpha; |
1390 | 1390 | ||
1391 | r.x = beta * p.q[0]+ alpha * q.q[0]; | 1391 | r.x = beta * p.q[0]+ alpha * q.q[0]; |
1392 | r.y = beta * p.q[1]+ alpha * q.q[1]; | 1392 | r.y = beta * p.q[1]+ alpha * q.q[1]; |
1393 | r.z = beta * p.q[2]+ alpha * q.q[2]; | 1393 | r.z = beta * p.q[2]+ alpha * q.q[2]; |
1394 | r.w = beta * p.q[3]+ alpha * q.q[3]; | 1394 | r.w = beta * p.q[3]+ alpha * q.q[3]; |
1395 | return r; | 1395 | return r; |
1396 | } | 1396 | } |
1397 | 1397 | ||
1398 | static quaternion identity() | 1398 | static quaternion identity() |
1399 | { | 1399 | { |
1400 | static quaternion ident( vec3( 0.0, 0.0, 0.0 ), GLH_ONE ); | 1400 | static quaternion ident( vec3( 0.0, 0.0, 0.0 ), GLH_ONE ); |
1401 | return ident; | 1401 | return ident; |
1402 | } | 1402 | } |
1403 | 1403 | ||
1404 | real & operator []( int i ) | 1404 | real & operator []( int i ) |
1405 | { | 1405 | { |
1406 | assert(i < 4); | 1406 | assert(i < 4); |
1407 | return q[i]; | 1407 | return q[i]; |
1408 | } | 1408 | } |
1409 | 1409 | ||
1410 | const real & operator []( int i ) const | 1410 | const real & operator []( int i ) const |
1411 | { | 1411 | { |
1412 | assert(i < 4); | 1412 | assert(i < 4); |
1413 | return q[i]; | 1413 | return q[i]; |
1414 | } | 1414 | } |
1415 | 1415 | ||
1416 | protected: | 1416 | protected: |
1417 | 1417 | ||
1418 | void counter_normalize() | 1418 | void counter_normalize() |
1419 | { | 1419 | { |
1420 | if (counter > GLH_QUATERNION_NORMALIZATION_THRESHOLD) | 1420 | if (counter > GLH_QUATERNION_NORMALIZATION_THRESHOLD) |
1421 | normalize(); | 1421 | normalize(); |
1422 | } | 1422 | } |
1423 | 1423 | ||
1424 | union | 1424 | union |
1425 | { | 1425 | { |
1426 | struct | 1426 | struct |
1427 | { | 1427 | { |
1428 | real q[4]; | 1428 | real q[4]; |
1429 | }; | 1429 | }; |
1430 | struct | 1430 | struct |
1431 | { | 1431 | { |
1432 | real x; | 1432 | real x; |
1433 | real y; | 1433 | real y; |
1434 | real z; | 1434 | real z; |
1435 | real w; | 1435 | real w; |
1436 | }; | 1436 | }; |
1437 | }; | 1437 | }; |
1438 | 1438 | ||
1439 | // renormalization counter | 1439 | // renormalization counter |
1440 | unsigned char counter; | 1440 | unsigned char counter; |
1441 | }; | 1441 | }; |
1442 | 1442 | ||
1443 | inline | 1443 | inline |
1444 | bool operator == ( const quaternion & q1, const quaternion & q2 ) | 1444 | bool operator == ( const quaternion & q1, const quaternion & q2 ) |
1445 | { | 1445 | { |
1446 | return (equivalent(q1.x, q2.x) && | 1446 | return (equivalent(q1.x, q2.x) && |
1447 | equivalent(q1.y, q2.y) && | 1447 | equivalent(q1.y, q2.y) && |
1448 | equivalent(q1.z, q2.z) && | 1448 | equivalent(q1.z, q2.z) && |
1449 | equivalent(q1.w, q2.w) ); | 1449 | equivalent(q1.w, q2.w) ); |
1450 | } | 1450 | } |
1451 | 1451 | ||
1452 | inline | 1452 | inline |
1453 | bool operator != ( const quaternion & q1, const quaternion & q2 ) | 1453 | bool operator != ( const quaternion & q1, const quaternion & q2 ) |
1454 | { | 1454 | { |
1455 | return ! ( q1 == q2 ); | 1455 | return ! ( q1 == q2 ); |
1456 | } | 1456 | } |
1457 | 1457 | ||
1458 | inline | 1458 | inline |
1459 | quaternion operator * ( const quaternion & q1, const quaternion & q2 ) | 1459 | quaternion operator * ( const quaternion & q1, const quaternion & q2 ) |
1460 | { | 1460 | { |
1461 | quaternion r(q1); | 1461 | quaternion r(q1); |
1462 | r *= q2; | 1462 | r *= q2; |
1463 | return r; | 1463 | return r; |
1464 | } | 1464 | } |
1465 | 1465 | ||
1466 | 1466 | ||
1467 | 1467 | ||
1468 | 1468 | ||
1469 | 1469 | ||
1470 | 1470 | ||
1471 | 1471 | ||
1472 | 1472 | ||
1473 | 1473 | ||
1474 | 1474 | ||
1475 | class plane | 1475 | class plane |
1476 | { | 1476 | { |
1477 | public: | 1477 | public: |
1478 | 1478 | ||
1479 | plane() | 1479 | plane() |
1480 | { | 1480 | { |
1481 | planedistance = 0.0; | 1481 | planedistance = 0.0; |
1482 | planenormal.set_value( 0.0, 0.0, 1.0 ); | 1482 | planenormal.set_value( 0.0, 0.0, 1.0 ); |
1483 | } | 1483 | } |
1484 | 1484 | ||
1485 | 1485 | ||
1486 | plane( const vec3 &p0, const vec3 &p1, const vec3 &p2 ) | 1486 | plane( const vec3 &p0, const vec3 &p1, const vec3 &p2 ) |
1487 | { | 1487 | { |
1488 | vec3 v0 = p1 - p0; | 1488 | vec3 v0 = p1 - p0; |
1489 | vec3 v1 = p2 - p0; | 1489 | vec3 v1 = p2 - p0; |
1490 | planenormal = v0.cross(v1); | 1490 | planenormal = v0.cross(v1); |
1491 | planenormal.normalize(); | 1491 | planenormal.normalize(); |
1492 | planedistance = p0.dot(planenormal); | 1492 | planedistance = p0.dot(planenormal); |
1493 | } | 1493 | } |
1494 | 1494 | ||
1495 | plane( const vec3 &normal, real distance ) | 1495 | plane( const vec3 &normal, real distance ) |
1496 | { | 1496 | { |
1497 | planedistance = distance; | 1497 | planedistance = distance; |
1498 | planenormal = normal; | 1498 | planenormal = normal; |
1499 | planenormal.normalize(); | 1499 | planenormal.normalize(); |
1500 | } | 1500 | } |
1501 | 1501 | ||
1502 | plane( const vec3 &normal, const vec3 &point ) | 1502 | plane( const vec3 &normal, const vec3 &point ) |
1503 | { | 1503 | { |
1504 | planenormal = normal; | 1504 | planenormal = normal; |
1505 | planenormal.normalize(); | 1505 | planenormal.normalize(); |
1506 | planedistance = point.dot(planenormal); | 1506 | planedistance = point.dot(planenormal); |
1507 | } | 1507 | } |
1508 | 1508 | ||
1509 | void offset( real d ) | 1509 | void offset( real d ) |
1510 | { | 1510 | { |
1511 | planedistance += d; | 1511 | planedistance += d; |
1512 | } | 1512 | } |
1513 | 1513 | ||
1514 | bool intersect( const line &l, vec3 &intersection ) const | 1514 | bool intersect( const line &l, vec3 &intersection ) const |
1515 | { | 1515 | { |
1516 | vec3 pos, dir; | 1516 | vec3 pos, dir; |
1517 | vec3 pn = planenormal; | 1517 | vec3 pn = planenormal; |
1518 | real pd = planedistance; | 1518 | real pd = planedistance; |
1519 | 1519 | ||
1520 | pos = l.get_position(); | 1520 | pos = l.get_position(); |
1521 | dir = l.get_direction(); | 1521 | dir = l.get_direction(); |
1522 | 1522 | ||
1523 | if(dir.dot(pn) == 0.0) return 0; | 1523 | if(dir.dot(pn) == 0.0) return 0; |
1524 | pos -= pn*pd; | 1524 | pos -= pn*pd; |
1525 | // now we're talking about a plane passing through the origin | 1525 | // now we're talking about a plane passing through the origin |
1526 | if(pos.dot(pn) < 0.0) pn.negate(); | 1526 | if(pos.dot(pn) < 0.0) pn.negate(); |
1527 | if(dir.dot(pn) > 0.0) dir.negate(); | 1527 | if(dir.dot(pn) > 0.0) dir.negate(); |
1528 | vec3 ppos = pn * pos.dot(pn); | 1528 | vec3 ppos = pn * pos.dot(pn); |
1529 | pos = (ppos.length()/dir.dot(-pn))*dir; | 1529 | pos = (ppos.length()/dir.dot(-pn))*dir; |
1530 | intersection = l.get_position(); | 1530 | intersection = l.get_position(); |
1531 | intersection += pos; | 1531 | intersection += pos; |
1532 | return 1; | 1532 | return 1; |
1533 | } | 1533 | } |
1534 | void transform( const matrix4 &matrix ) | 1534 | void transform( const matrix4 &matrix ) |
1535 | { | 1535 | { |
1536 | matrix4 invtr = matrix.inverse(); | 1536 | matrix4 invtr = matrix.inverse(); |
1537 | invtr = invtr.transpose(); | 1537 | invtr = invtr.transpose(); |
1538 | 1538 | ||
1539 | vec3 pntOnplane = planenormal * planedistance; | 1539 | vec3 pntOnplane = planenormal * planedistance; |
1540 | vec3 newPntOnplane; | 1540 | vec3 newPntOnplane; |
1541 | vec3 newnormal; | 1541 | vec3 newnormal; |
1542 | 1542 | ||
1543 | invtr.mult_dir_matrix(planenormal, newnormal); | 1543 | invtr.mult_dir_matrix(planenormal, newnormal); |
1544 | matrix.mult_vec_matrix(pntOnplane, newPntOnplane); | 1544 | matrix.mult_vec_matrix(pntOnplane, newPntOnplane); |
1545 | 1545 | ||
1546 | newnormal.normalize(); | 1546 | newnormal.normalize(); |
1547 | planenormal = newnormal; | 1547 | planenormal = newnormal; |
1548 | planedistance = newPntOnplane.dot(planenormal); | 1548 | planedistance = newPntOnplane.dot(planenormal); |
1549 | } | 1549 | } |
1550 | 1550 | ||
1551 | bool is_in_half_space( const vec3 &point ) const | 1551 | bool is_in_half_space( const vec3 &point ) const |
1552 | { | 1552 | { |
1553 | 1553 | ||
1554 | if(( point.dot(planenormal) - planedistance) < 0.0) | 1554 | if(( point.dot(planenormal) - planedistance) < 0.0) |
1555 | return 0; | 1555 | return 0; |
1556 | return 1; | 1556 | return 1; |
1557 | } | 1557 | } |
1558 | 1558 | ||
1559 | 1559 | ||
1560 | real distance( const vec3 & point ) const | 1560 | real distance( const vec3 & point ) const |
1561 | { | 1561 | { |
1562 | return planenormal.dot(point - planenormal*planedistance); | 1562 | return planenormal.dot(point - planenormal*planedistance); |
1563 | } | 1563 | } |
1564 | 1564 | ||
1565 | const vec3 &get_normal() const | 1565 | const vec3 &get_normal() const |
1566 | { | 1566 | { |
1567 | return planenormal; | 1567 | return planenormal; |
1568 | } | 1568 | } |
1569 | 1569 | ||
1570 | 1570 | ||
1571 | real get_distance_from_origin() const | 1571 | real get_distance_from_origin() const |
1572 | { | 1572 | { |
1573 | return planedistance; | 1573 | return planedistance; |
1574 | } | 1574 | } |
1575 | 1575 | ||
1576 | 1576 | ||
1577 | friend bool operator == ( const plane & p1, const plane & p2 ); | 1577 | friend bool operator == ( const plane & p1, const plane & p2 ); |
1578 | 1578 | ||
1579 | 1579 | ||
1580 | friend bool operator != ( const plane & p1, const plane & p2 ); | 1580 | friend bool operator != ( const plane & p1, const plane & p2 ); |
1581 | 1581 | ||
1582 | //protected: | 1582 | //protected: |
1583 | vec3 planenormal; | 1583 | vec3 planenormal; |
1584 | real planedistance; | 1584 | real planedistance; |
1585 | }; | 1585 | }; |
1586 | 1586 | ||
1587 | inline | 1587 | inline |
1588 | bool operator == (const plane & p1, const plane & p2 ) | 1588 | bool operator == (const plane & p1, const plane & p2 ) |
1589 | { | 1589 | { |
1590 | return ( p1.planedistance == p2.planedistance && p1.planenormal == p2.planenormal); | 1590 | return ( p1.planedistance == p2.planedistance && p1.planenormal == p2.planenormal); |
1591 | } | 1591 | } |
1592 | 1592 | ||
1593 | inline | 1593 | inline |
1594 | bool operator != ( const plane & p1, const plane & p2 ) | 1594 | bool operator != ( const plane & p1, const plane & p2 ) |
1595 | { return ! (p1 == p2); } | 1595 | { return ! (p1 == p2); } |
1596 | 1596 | ||
1597 | 1597 | ||
1598 | 1598 | ||
1599 | } // "ns_##GLH_REAL" | 1599 | } // "ns_##GLH_REAL" |
1600 | 1600 | ||
1601 | // make common typedefs... | 1601 | // make common typedefs... |
1602 | #ifdef GLH_REAL_IS_FLOAT | 1602 | #ifdef GLH_REAL_IS_FLOAT |
1603 | typedef GLH_REAL_NAMESPACE::vec2 vec2f; | 1603 | typedef GLH_REAL_NAMESPACE::vec2 vec2f; |
1604 | typedef GLH_REAL_NAMESPACE::vec3 vec3f; | 1604 | typedef GLH_REAL_NAMESPACE::vec3 vec3f; |
1605 | typedef GLH_REAL_NAMESPACE::vec4 vec4f; | 1605 | typedef GLH_REAL_NAMESPACE::vec4 vec4f; |
1606 | typedef GLH_REAL_NAMESPACE::quaternion quaternionf; | 1606 | typedef GLH_REAL_NAMESPACE::quaternion quaternionf; |
1607 | typedef GLH_REAL_NAMESPACE::quaternion rotationf; | 1607 | typedef GLH_REAL_NAMESPACE::quaternion rotationf; |
1608 | typedef GLH_REAL_NAMESPACE::line linef; | 1608 | typedef GLH_REAL_NAMESPACE::line linef; |
1609 | typedef GLH_REAL_NAMESPACE::plane planef; | 1609 | typedef GLH_REAL_NAMESPACE::plane planef; |
1610 | typedef GLH_REAL_NAMESPACE::matrix4 matrix4f; | 1610 | typedef GLH_REAL_NAMESPACE::matrix4 matrix4f; |
1611 | #endif | 1611 | #endif |
1612 | 1612 | ||
1613 | 1613 | ||
1614 | 1614 | ||
1615 | 1615 | ||
1616 | } // namespace glh | 1616 | } // namespace glh |
1617 | 1617 | ||
1618 | 1618 | ||
1619 | 1619 | ||
1620 | #endif | 1620 | #endif |
1621 | 1621 | ||
diff --git a/linden/indra/newview/llfloaterregioninfo.cpp b/linden/indra/newview/llfloaterregioninfo.cpp index 4880308..3c3625b 100644 --- a/linden/indra/newview/llfloaterregioninfo.cpp +++ b/linden/indra/newview/llfloaterregioninfo.cpp | |||
@@ -1,3446 +1,3446 @@ | |||
1 | /** | 1 | /** |
2 | * @file llfloaterregioninfo.cpp | 2 | * @file llfloaterregioninfo.cpp |
3 | * @author Aaron Brashears | 3 | * @author Aaron Brashears |
4 | * @brief Implementation of the region info and controls floater and panels. | 4 | * @brief Implementation of the region info and controls floater and panels. |
5 | * | 5 | * |
6 | * $LicenseInfo:firstyear=2004&license=viewergpl$ | 6 | * $LicenseInfo:firstyear=2004&license=viewergpl$ |
7 | * | 7 | * |
8 | * Copyright (c) 2004-2009, Linden Research, Inc. | 8 | * Copyright (c) 2004-2009, Linden Research, Inc. |
9 | * | 9 | * |
10 | * Second Life Viewer Source Code | 10 | * Second Life Viewer Source Code |
11 | * The source code in this file ("Source Code") is provided by Linden Lab | 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 | 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 | 13 | * ("GPL"), unless you have obtained a separate licensing agreement |
14 | * ("Other License"), formally executed by you and Linden Lab. Terms of | 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 | 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 | 16 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 |
17 | * | 17 | * |
18 | * There are special exceptions to the terms and conditions of the GPL as | 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 | 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 | 20 | * in the file doc/FLOSS-exception.txt in this software distribution, or |
21 | * online at | 21 | * online at |
22 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | 22 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception |
23 | * | 23 | * |
24 | * By copying, modifying or distributing this software, you acknowledge | 24 | * By copying, modifying or distributing this software, you acknowledge |
25 | * that you have read and understood your obligations described above, | 25 | * that you have read and understood your obligations described above, |
26 | * and agree to abide by those obligations. | 26 | * and agree to abide by those obligations. |
27 | * | 27 | * |
28 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | 28 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO |
29 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | 29 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, |
30 | * COMPLETENESS OR PERFORMANCE. | 30 | * COMPLETENESS OR PERFORMANCE. |
31 | * $/LicenseInfo$ | 31 | * $/LicenseInfo$ |
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include "llviewerprecompiledheaders.h" | 34 | #include "llviewerprecompiledheaders.h" |
35 | #include "llfloaterregioninfo.h" | 35 | #include "llfloaterregioninfo.h" |
36 | 36 | ||
37 | #include <algorithm> | 37 | #include <algorithm> |
38 | #include <functional> | 38 | #include <functional> |
39 | 39 | ||
40 | #include "llcachename.h" | 40 | #include "llcachename.h" |
41 | #include "lldir.h" | 41 | #include "lldir.h" |
42 | #include "lldispatcher.h" | 42 | #include "lldispatcher.h" |
43 | #include "llglheaders.h" | 43 | #include "llglheaders.h" |
44 | #include "llregionflags.h" | 44 | #include "llregionflags.h" |
45 | #include "llstl.h" | 45 | #include "llstl.h" |
46 | #include "indra_constants.h" | 46 | #include "indra_constants.h" |
47 | #include "message.h" | 47 | #include "message.h" |
48 | 48 | ||
49 | #include "llagent.h" | 49 | #include "llagent.h" |
50 | #include "llalertdialog.h" | 50 | #include "llalertdialog.h" |
51 | #include "llappviewer.h" | 51 | #include "llappviewer.h" |
52 | #include "llfloateravatarpicker.h" | 52 | #include "llfloateravatarpicker.h" |
53 | #include "llbutton.h" | 53 | #include "llbutton.h" |
54 | #include "llcheckboxctrl.h" | 54 | #include "llcheckboxctrl.h" |
55 | #include "llcombobox.h" | 55 | #include "llcombobox.h" |
56 | #include "llfilepicker.h" | 56 | #include "llfilepicker.h" |
57 | #include "llfloaterdaycycle.h" | 57 | #include "llfloaterdaycycle.h" |
58 | #include "llfloatergodtools.h" // for send_sim_wide_deletes() | 58 | #include "llfloatergodtools.h" // for send_sim_wide_deletes() |
59 | #include "llfloatertopobjects.h" // added to fix SL-32336 | 59 | #include "llfloatertopobjects.h" // added to fix SL-32336 |
60 | #include "llfloatergroups.h" | 60 | #include "llfloatergroups.h" |
61 | #include "llfloatertelehub.h" | 61 | #include "llfloatertelehub.h" |
62 | #include "llfloaterwindlight.h" | 62 | #include "llfloaterwindlight.h" |
63 | #include "llinventorymodel.h" | 63 | #include "llinventorymodel.h" |
64 | #include "lllineeditor.h" | 64 | #include "lllineeditor.h" |
65 | #include "llalertdialog.h" | 65 | #include "llalertdialog.h" |
66 | #include "llnamelistctrl.h" | 66 | #include "llnamelistctrl.h" |
67 | #include "llsliderctrl.h" | 67 | #include "llsliderctrl.h" |
68 | #include "llspinctrl.h" | 68 | #include "llspinctrl.h" |
69 | #include "lltabcontainer.h" | 69 | #include "lltabcontainer.h" |
70 | #include "lltextbox.h" | 70 | #include "lltextbox.h" |
71 | #include "llinventory.h" | 71 | #include "llinventory.h" |
72 | #include "lltexturectrl.h" | 72 | #include "lltexturectrl.h" |
73 | #include "lltrans.h" | 73 | #include "lltrans.h" |
74 | #include "llviewercontrol.h" | 74 | #include "llviewercontrol.h" |
75 | #include "lluictrlfactory.h" | 75 | #include "lluictrlfactory.h" |
76 | #include "llviewerimage.h" | 76 | #include "llviewerimage.h" |
77 | #include "llviewerimagelist.h" | 77 | #include "llviewerimagelist.h" |
78 | #include "llviewerregion.h" | 78 | #include "llviewerregion.h" |
79 | #include "llviewerstats.h" | 79 | #include "llviewerstats.h" |
80 | #include "llviewertexteditor.h" | 80 | #include "llviewertexteditor.h" |
81 | #include "llviewerwindow.h" | 81 | #include "llviewerwindow.h" |
82 | #include "llvlcomposition.h" | 82 | #include "llvlcomposition.h" |
83 | #include "hippolimits.h" | 83 | #include "hippolimits.h" |
84 | 84 | ||
85 | // [RLVa:KB] | 85 | // [RLVa:KB] |
86 | #include "rlvhandler.h" | 86 | #include "rlvhandler.h" |
87 | // [/RLVa:KB] | 87 | // [/RLVa:KB] |
88 | 88 | ||
89 | #define ELAR_ENABLED 0 // Enable when server support is implemented | 89 | #define ELAR_ENABLED 0 // Enable when server support is implemented |
90 | 90 | ||
91 | const S32 TERRAIN_TEXTURE_COUNT = 4; | 91 | const S32 TERRAIN_TEXTURE_COUNT = 4; |
92 | const S32 CORNER_COUNT = 4; | 92 | const S32 CORNER_COUNT = 4; |
93 | 93 | ||
94 | ///---------------------------------------------------------------------------- | 94 | ///---------------------------------------------------------------------------- |
95 | /// Local class declaration | 95 | /// Local class declaration |
96 | ///---------------------------------------------------------------------------- | 96 | ///---------------------------------------------------------------------------- |
97 | 97 | ||
98 | class LLDispatchEstateUpdateInfo : public LLDispatchHandler | 98 | class LLDispatchEstateUpdateInfo : public LLDispatchHandler |
99 | { | 99 | { |
100 | public: | 100 | public: |
101 | LLDispatchEstateUpdateInfo() {} | 101 | LLDispatchEstateUpdateInfo() {} |
102 | virtual ~LLDispatchEstateUpdateInfo() {} | 102 | virtual ~LLDispatchEstateUpdateInfo() {} |
103 | virtual bool operator()( | 103 | virtual bool operator()( |
104 | const LLDispatcher* dispatcher, | 104 | const LLDispatcher* dispatcher, |
105 | const std::string& key, | 105 | const std::string& key, |
106 | const LLUUID& invoice, | 106 | const LLUUID& invoice, |
107 | const sparam_t& strings); | 107 | const sparam_t& strings); |
108 | }; | 108 | }; |
109 | 109 | ||
110 | class LLDispatchSetEstateAccess : public LLDispatchHandler | 110 | class LLDispatchSetEstateAccess : public LLDispatchHandler |
111 | { | 111 | { |
112 | public: | 112 | public: |
113 | LLDispatchSetEstateAccess() {} | 113 | LLDispatchSetEstateAccess() {} |
114 | virtual ~LLDispatchSetEstateAccess() {} | 114 | virtual ~LLDispatchSetEstateAccess() {} |
115 | virtual bool operator()( | 115 | virtual bool operator()( |
116 | const LLDispatcher* dispatcher, | 116 | const LLDispatcher* dispatcher, |
117 | const std::string& key, | 117 | const std::string& key, |
118 | const LLUUID& invoice, | 118 | const LLUUID& invoice, |
119 | const sparam_t& strings); | 119 | const sparam_t& strings); |
120 | }; | 120 | }; |
121 | 121 | ||
122 | 122 | ||
123 | /* | 123 | /* |
124 | void unpack_request_params( | 124 | void unpack_request_params( |
125 | LLMessageSystem* msg, | 125 | LLMessageSystem* msg, |
126 | LLDispatcher::sparam_t& strings, | 126 | LLDispatcher::sparam_t& strings, |
127 | LLDispatcher::iparam_t& integers) | 127 | LLDispatcher::iparam_t& integers) |
128 | { | 128 | { |
129 | char str_buf[MAX_STRING]; | 129 | char str_buf[MAX_STRING]; |
130 | S32 str_count = msg->getNumberOfBlocksFast(_PREHASH_StringData); | 130 | S32 str_count = msg->getNumberOfBlocksFast(_PREHASH_StringData); |
131 | S32 i; | 131 | S32 i; |
132 | for (i = 0; i < str_count; ++i) | 132 | for (i = 0; i < str_count; ++i) |
133 | { | 133 | { |
134 | // we treat the SParam as binary data (since it might be an | 134 | // we treat the SParam as binary data (since it might be an |
135 | // LLUUID in compressed form which may have embedded \0's,) | 135 | // LLUUID in compressed form which may have embedded \0's,) |
136 | str_buf[0] = '\0'; | 136 | str_buf[0] = '\0'; |
137 | S32 data_size = msg->getSizeFast(_PREHASH_StringData, i, _PREHASH_SParam); | 137 | S32 data_size = msg->getSizeFast(_PREHASH_StringData, i, _PREHASH_SParam); |
138 | if (data_size >= 0) | 138 | if (data_size >= 0) |
139 | { | 139 | { |
140 | msg->getBinaryDataFast(_PREHASH_StringData, _PREHASH_SParam, | 140 | msg->getBinaryDataFast(_PREHASH_StringData, _PREHASH_SParam, |
141 | str_buf, data_size, i, MAX_STRING - 1); | 141 | str_buf, data_size, i, MAX_STRING - 1); |
142 | strings.push_back(std::string(str_buf, data_size)); | 142 | strings.push_back(std::string(str_buf, data_size)); |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | U32 int_buf; | 146 | U32 int_buf; |
147 | S32 int_count = msg->getNumberOfBlocksFast(_PREHASH_IntegerData); | 147 | S32 int_count = msg->getNumberOfBlocksFast(_PREHASH_IntegerData); |
148 | for (i = 0; i < int_count; ++i) | 148 | for (i = 0; i < int_count; ++i) |
149 | { | 149 | { |
150 | msg->getU32("IntegerData", "IParam", int_buf, i); | 150 | msg->getU32("IntegerData", "IParam", int_buf, i); |
151 | integers.push_back(int_buf); | 151 | integers.push_back(int_buf); |
152 | } | 152 | } |
153 | } | 153 | } |
154 | */ | 154 | */ |
155 | 155 | ||
156 | 156 | ||
157 | 157 | ||
158 | bool estate_dispatch_initialized = false; | 158 | bool estate_dispatch_initialized = false; |
159 | 159 | ||
160 | 160 | ||
161 | ///---------------------------------------------------------------------------- | 161 | ///---------------------------------------------------------------------------- |
162 | /// LLFloaterRegionInfo | 162 | /// LLFloaterRegionInfo |
163 | ///---------------------------------------------------------------------------- | 163 | ///---------------------------------------------------------------------------- |
164 | 164 | ||
165 | //S32 LLFloaterRegionInfo::sRequestSerial = 0; | 165 | //S32 LLFloaterRegionInfo::sRequestSerial = 0; |
166 | LLUUID LLFloaterRegionInfo::sRequestInvoice; | 166 | LLUUID LLFloaterRegionInfo::sRequestInvoice; |
167 | 167 | ||
168 | LLFloaterRegionInfo::LLFloaterRegionInfo(const LLSD& seed) | 168 | LLFloaterRegionInfo::LLFloaterRegionInfo(const LLSD& seed) |
169 | { | 169 | { |
170 | LLUICtrlFactory::getInstance()->buildFloater(this, "floater_region_info.xml", NULL, FALSE); | 170 | LLUICtrlFactory::getInstance()->buildFloater(this, "floater_region_info.xml", NULL, FALSE); |
171 | } | 171 | } |
172 | 172 | ||
173 | BOOL LLFloaterRegionInfo::postBuild() | 173 | BOOL LLFloaterRegionInfo::postBuild() |
174 | { | 174 | { |
175 | mTab = getChild<LLTabContainer>("region_panels"); | 175 | mTab = getChild<LLTabContainer>("region_panels"); |
176 | 176 | ||
177 | // contruct the panels | 177 | // contruct the panels |
178 | LLPanelRegionInfo* panel; | 178 | LLPanelRegionInfo* panel; |
179 | 179 | ||
180 | panel = new LLPanelRegionGeneralInfo; | 180 | panel = new LLPanelRegionGeneralInfo; |
181 | mInfoPanels.push_back(panel); | 181 | mInfoPanels.push_back(panel); |
182 | LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_general.xml"); | 182 | LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_general.xml"); |
183 | mTab->addTabPanel(panel, panel->getLabel(), TRUE); | 183 | mTab->addTabPanel(panel, panel->getLabel(), TRUE); |
184 | 184 | ||
185 | // We only use this panel on Aurora-based sims -- MC | 185 | // We only use this panel on Aurora-based sims -- MC |
186 | std::string url = gAgent.getRegion()->getCapability("DispatchOpenRegionSettings"); | 186 | std::string url = gAgent.getRegion()->getCapability("DispatchOpenRegionSettings"); |
187 | if (!url.empty()) | 187 | if (!url.empty()) |
188 | { | 188 | { |
189 | panel = new LLPanelRegionOpenSettingsInfo; | 189 | panel = new LLPanelRegionOpenSettingsInfo; |
190 | mInfoPanels.push_back(panel); | 190 | mInfoPanels.push_back(panel); |
191 | LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_open_region_settings.xml"); | 191 | LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_open_region_settings.xml"); |
192 | mTab->addTabPanel(panel, panel->getLabel(), FALSE); | 192 | mTab->addTabPanel(panel, panel->getLabel(), FALSE); |
193 | } | 193 | } |
194 | 194 | ||
195 | panel = new LLPanelRegionDebugInfo; | 195 | panel = new LLPanelRegionDebugInfo; |
196 | mInfoPanels.push_back(panel); | 196 | mInfoPanels.push_back(panel); |
197 | LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_debug.xml"); | 197 | LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_debug.xml"); |
198 | mTab->addTabPanel(panel, panel->getLabel(), FALSE); | 198 | mTab->addTabPanel(panel, panel->getLabel(), FALSE); |
199 | 199 | ||
200 | panel = new LLPanelRegionTextureInfo; | 200 | panel = new LLPanelRegionTextureInfo; |
201 | mInfoPanels.push_back(panel); | 201 | mInfoPanels.push_back(panel); |
202 | LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_texture.xml"); | 202 | LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_texture.xml"); |
203 | mTab->addTabPanel(panel, panel->getLabel(), FALSE); | 203 | mTab->addTabPanel(panel, panel->getLabel(), FALSE); |
204 | 204 | ||
205 | panel = new LLPanelRegionTerrainInfo; | 205 | panel = new LLPanelRegionTerrainInfo; |
206 | mInfoPanels.push_back(panel); | 206 | mInfoPanels.push_back(panel); |
207 | LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_terrain.xml"); | 207 | LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_terrain.xml"); |
208 | mTab->addTabPanel(panel, panel->getLabel(), FALSE); | 208 | mTab->addTabPanel(panel, panel->getLabel(), FALSE); |
209 | 209 | ||
210 | panel = new LLPanelEstateInfo; | 210 | panel = new LLPanelEstateInfo; |
211 | mInfoPanels.push_back(panel); | 211 | mInfoPanels.push_back(panel); |
212 | LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_estate.xml"); | 212 | LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_estate.xml"); |
213 | mTab->addTabPanel(panel, panel->getLabel(), FALSE); | 213 | mTab->addTabPanel(panel, panel->getLabel(), FALSE); |
214 | 214 | ||
215 | panel = new LLPanelEstateCovenant; | 215 | panel = new LLPanelEstateCovenant; |
216 | mInfoPanels.push_back(panel); | 216 | mInfoPanels.push_back(panel); |
217 | LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_covenant.xml"); | 217 | LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_covenant.xml"); |
218 | mTab->addTabPanel(panel, panel->getLabel(), FALSE); | 218 | mTab->addTabPanel(panel, panel->getLabel(), FALSE); |
219 | 219 | ||
220 | gMessageSystem->setHandlerFunc( | 220 | gMessageSystem->setHandlerFunc( |
221 | "EstateOwnerMessage", | 221 | "EstateOwnerMessage", |
222 | &processEstateOwnerRequest); | 222 | &processEstateOwnerRequest); |
223 | 223 | ||
224 | return TRUE; | 224 | return TRUE; |
225 | } | 225 | } |
226 | 226 | ||
227 | LLFloaterRegionInfo::~LLFloaterRegionInfo() | 227 | LLFloaterRegionInfo::~LLFloaterRegionInfo() |
228 | { | 228 | { |
229 | } | 229 | } |
230 | 230 | ||
231 | void LLFloaterRegionInfo::onOpen() | 231 | void LLFloaterRegionInfo::onOpen() |
232 | { | 232 | { |
233 | LLRect rect = gSavedSettings.getRect("FloaterRegionInfo"); | 233 | LLRect rect = gSavedSettings.getRect("FloaterRegionInfo"); |
234 | S32 left, top; | 234 | S32 left, top; |
235 | gFloaterView->getNewFloaterPosition(&left, &top); | 235 | gFloaterView->getNewFloaterPosition(&left, &top); |
236 | rect.translate(left,top); | 236 | rect.translate(left,top); |
237 | 237 | ||
238 | refreshFromRegion(gAgent.getRegion()); | 238 | refreshFromRegion(gAgent.getRegion()); |
239 | requestRegionInfo(); | 239 | requestRegionInfo(); |
240 | LLFloater::onOpen(); | 240 | LLFloater::onOpen(); |
241 | } | 241 | } |
242 | 242 | ||
243 | // static | 243 | // static |
244 | void LLFloaterRegionInfo::requestRegionInfo() | 244 | void LLFloaterRegionInfo::requestRegionInfo() |
245 | { | 245 | { |
246 | LLTabContainer* tab = findInstance()->getChild<LLTabContainer>("region_panels"); | 246 | LLTabContainer* tab = findInstance()->getChild<LLTabContainer>("region_panels"); |
247 | 247 | ||
248 | tab->getChild<LLPanel>("General")->setCtrlsEnabled(FALSE); | 248 | tab->getChild<LLPanel>("General")->setCtrlsEnabled(FALSE); |
249 | tab->getChild<LLPanel>("Debug")->setCtrlsEnabled(FALSE); | 249 | tab->getChild<LLPanel>("Debug")->setCtrlsEnabled(FALSE); |
250 | tab->getChild<LLPanel>("Terrain")->setCtrlsEnabled(FALSE); | 250 | tab->getChild<LLPanel>("Terrain")->setCtrlsEnabled(FALSE); |
251 | tab->getChild<LLPanel>("Estate")->setCtrlsEnabled(FALSE); | 251 | tab->getChild<LLPanel>("Estate")->setCtrlsEnabled(FALSE); |
252 | tab->getChild<LLPanel>("RegionSettings")->setCtrlsEnabled(FALSE); | 252 | tab->getChild<LLPanel>("RegionSettings")->setCtrlsEnabled(FALSE); |
253 | 253 | ||
254 | // Must allow anyone to request the RegionInfo data | 254 | // Must allow anyone to request the RegionInfo data |
255 | // so non-owners/non-gods can see the values. | 255 | // so non-owners/non-gods can see the values. |
256 | // Therefore can't use an EstateOwnerMessage JC | 256 | // Therefore can't use an EstateOwnerMessage JC |
257 | LLMessageSystem* msg = gMessageSystem; | 257 | LLMessageSystem* msg = gMessageSystem; |
258 | msg->newMessage("RequestRegionInfo"); | 258 | msg->newMessage("RequestRegionInfo"); |
259 | msg->nextBlock("AgentData"); | 259 | msg->nextBlock("AgentData"); |
260 | msg->addUUID("AgentID", gAgent.getID()); | 260 | msg->addUUID("AgentID", gAgent.getID()); |
261 | msg->addUUID("SessionID", gAgent.getSessionID()); | 261 | msg->addUUID("SessionID", gAgent.getSessionID()); |
262 | gAgent.sendReliableMessage(); | 262 | gAgent.sendReliableMessage(); |
263 | } | 263 | } |
264 | 264 | ||
265 | // static | 265 | // static |
266 | void LLFloaterRegionInfo::processEstateOwnerRequest(LLMessageSystem* msg,void**) | 266 | void LLFloaterRegionInfo::processEstateOwnerRequest(LLMessageSystem* msg,void**) |
267 | { | 267 | { |
268 | static LLDispatcher dispatch; | 268 | static LLDispatcher dispatch; |
269 | if(!findInstance()) | 269 | if(!findInstance()) |
270 | { | 270 | { |
271 | return; | 271 | return; |
272 | } | 272 | } |
273 | 273 | ||
274 | if (!estate_dispatch_initialized) | 274 | if (!estate_dispatch_initialized) |
275 | { | 275 | { |
276 | LLPanelEstateInfo::initDispatch(dispatch); | 276 | LLPanelEstateInfo::initDispatch(dispatch); |
277 | } | 277 | } |
278 | 278 | ||
279 | LLTabContainer* tab = findInstance()->getChild<LLTabContainer>("region_panels"); | 279 | LLTabContainer* tab = findInstance()->getChild<LLTabContainer>("region_panels"); |
280 | LLPanelEstateInfo* panel = (LLPanelEstateInfo*)tab->getChild<LLPanel>("Estate"); | 280 | LLPanelEstateInfo* panel = (LLPanelEstateInfo*)tab->getChild<LLPanel>("Estate"); |
281 | 281 | ||
282 | // unpack the message | 282 | // unpack the message |
283 | std::string request; | 283 | std::string request; |
284 | LLUUID invoice; | 284 | LLUUID invoice; |
285 | LLDispatcher::sparam_t strings; | 285 | LLDispatcher::sparam_t strings; |
286 | LLDispatcher::unpackMessage(msg, request, invoice, strings); | 286 | LLDispatcher::unpackMessage(msg, request, invoice, strings); |
287 | if(invoice != getLastInvoice()) | 287 | if(invoice != getLastInvoice()) |
288 | { | 288 | { |
289 | llwarns << "Mismatched Estate message: " << request << llendl; | 289 | llwarns << "Mismatched Estate message: " << request << llendl; |
290 | return; | 290 | return; |
291 | } | 291 | } |
292 | 292 | ||
293 | //dispatch the message | 293 | //dispatch the message |
294 | dispatch.dispatch(request, invoice, strings); | 294 | dispatch.dispatch(request, invoice, strings); |
295 | 295 | ||
296 | LLViewerRegion* region = gAgent.getRegion(); | 296 | LLViewerRegion* region = gAgent.getRegion(); |
297 | panel->updateControls(region); | 297 | panel->updateControls(region); |
298 | } | 298 | } |
299 | 299 | ||
300 | 300 | ||
301 | // static | 301 | // static |
302 | void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) | 302 | void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) |
303 | { | 303 | { |
304 | LLPanel* panel; | 304 | LLPanel* panel; |
305 | 305 | ||
306 | llinfos << "LLFloaterRegionInfo::processRegionInfo" << llendl; | 306 | llinfos << "LLFloaterRegionInfo::processRegionInfo" << llendl; |
307 | if(!findInstance()) | 307 | if(!findInstance()) |
308 | { | 308 | { |
309 | return; | 309 | return; |
310 | } | 310 | } |
311 | 311 | ||
312 | LLTabContainer* tab = findInstance()->getChild<LLTabContainer>("region_panels"); | 312 | LLTabContainer* tab = findInstance()->getChild<LLTabContainer>("region_panels"); |
313 | 313 | ||
314 | LLViewerRegion* region = gAgent.getRegion(); | 314 | LLViewerRegion* region = gAgent.getRegion(); |
315 | BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate()); | 315 | BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate()); |
316 | 316 | ||
317 | // extract message | 317 | // extract message |
318 | std::string sim_name; | 318 | std::string sim_name; |
319 | std::string sim_type = LLTrans::getString("land_type_unknown"); | 319 | std::string sim_type = LLTrans::getString("land_type_unknown"); |
320 | U32 region_flags; | 320 | U32 region_flags; |
321 | U8 agent_limit; | 321 | U8 agent_limit; |
322 | F32 object_bonus_factor; | 322 | F32 object_bonus_factor; |
323 | U8 sim_access; | 323 | U8 sim_access; |
324 | F32 water_height; | 324 | F32 water_height; |
325 | F32 terrain_raise_limit; | 325 | F32 terrain_raise_limit; |
326 | F32 terrain_lower_limit; | 326 | F32 terrain_lower_limit; |
327 | BOOL use_estate_sun; | 327 | BOOL use_estate_sun; |
328 | F32 sun_hour; | 328 | F32 sun_hour; |
329 | msg->getString("RegionInfo", "SimName", sim_name); | 329 | msg->getString("RegionInfo", "SimName", sim_name); |
330 | msg->getU32("RegionInfo", "RegionFlags", region_flags); | 330 | msg->getU32("RegionInfo", "RegionFlags", region_flags); |
331 | msg->getU8("RegionInfo", "MaxAgents", agent_limit); | 331 | msg->getU8("RegionInfo", "MaxAgents", agent_limit); |
332 | msg->getF32("RegionInfo", "ObjectBonusFactor", object_bonus_factor); | 332 | msg->getF32("RegionInfo", "ObjectBonusFactor", object_bonus_factor); |
333 | msg->getU8("RegionInfo", "SimAccess", sim_access); | 333 | msg->getU8("RegionInfo", "SimAccess", sim_access); |
334 | msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_WaterHeight, water_height); | 334 | msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_WaterHeight, water_height); |
335 | msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_TerrainRaiseLimit, terrain_raise_limit); | 335 | msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_TerrainRaiseLimit, terrain_raise_limit); |
336 | msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_TerrainLowerLimit, terrain_lower_limit); | 336 | msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_TerrainLowerLimit, terrain_lower_limit); |
337 | msg->getBOOL("RegionInfo", "UseEstateSun", use_estate_sun); | 337 | msg->getBOOL("RegionInfo", "UseEstateSun", use_estate_sun); |
338 | // actually the "last set" sun hour, not the current sun hour. JC | 338 | // actually the "last set" sun hour, not the current sun hour. JC |
339 | msg->getF32("RegionInfo", "SunHour", sun_hour); | 339 | msg->getF32("RegionInfo", "SunHour", sun_hour); |
340 | // the only reasonable way to decide if we actually have any data is to | 340 | // the only reasonable way to decide if we actually have any data is to |
341 | // check to see if any of these fields have nonzero sizes | 341 | // check to see if any of these fields have nonzero sizes |
342 | if (msg->getSize("RegionInfo2", "ProductSKU") > 0 || | 342 | if (msg->getSize("RegionInfo2", "ProductSKU") > 0 || |
343 | msg->getSize("RegionInfo2", "ProductName") > 0) | 343 | msg->getSize("RegionInfo2", "ProductName") > 0) |
344 | { | 344 | { |
345 | msg->getString("RegionInfo2", "ProductName", sim_type); | 345 | msg->getString("RegionInfo2", "ProductName", sim_type); |
346 | } | 346 | } |
347 | 347 | ||
348 | // GENERAL PANEL | 348 | // GENERAL PANEL |
349 | panel = tab->getChild<LLPanel>("General"); | 349 | panel = tab->getChild<LLPanel>("General"); |
350 | panel->childSetValue("region_text", LLSD(sim_name)); | 350 | panel->childSetValue("region_text", LLSD(sim_name)); |
351 | panel->childSetValue("region_type", LLSD(sim_type)); | 351 | panel->childSetValue("region_type", LLSD(sim_type)); |
352 | panel->childSetValue("version_channel_text", gLastVersionChannel); | 352 | panel->childSetValue("version_channel_text", gLastVersionChannel); |
353 | 353 | ||
354 | panel->childSetValue("block_terraform_check", (region_flags & REGION_FLAGS_BLOCK_TERRAFORM) ? TRUE : FALSE ); | 354 | panel->childSetValue("block_terraform_check", (region_flags & REGION_FLAGS_BLOCK_TERRAFORM) ? TRUE : FALSE ); |
355 | panel->childSetValue("block_fly_check", (region_flags & REGION_FLAGS_BLOCK_FLY) ? TRUE : FALSE ); | 355 | panel->childSetValue("block_fly_check", (region_flags & REGION_FLAGS_BLOCK_FLY) ? TRUE : FALSE ); |
356 | panel->childSetValue("allow_damage_check", (region_flags & REGION_FLAGS_ALLOW_DAMAGE) ? TRUE : FALSE ); | 356 | panel->childSetValue("allow_damage_check", (region_flags & REGION_FLAGS_ALLOW_DAMAGE) ? TRUE : FALSE ); |
357 | panel->childSetValue("restrict_pushobject", (region_flags & REGION_FLAGS_RESTRICT_PUSHOBJECT) ? TRUE : FALSE ); | 357 | panel->childSetValue("restrict_pushobject", (region_flags & REGION_FLAGS_RESTRICT_PUSHOBJECT) ? TRUE : FALSE ); |
358 | panel->childSetValue("allow_land_resell_check", (region_flags & REGION_FLAGS_BLOCK_LAND_RESELL) ? FALSE : TRUE ); | 358 | panel->childSetValue("allow_land_resell_check", (region_flags & REGION_FLAGS_BLOCK_LAND_RESELL) ? FALSE : TRUE ); |
359 | panel->childSetValue("allow_parcel_changes_check", (region_flags & REGION_FLAGS_ALLOW_PARCEL_CHANGES) ? TRUE : FALSE ); | 359 | panel->childSetValue("allow_parcel_changes_check", (region_flags & REGION_FLAGS_ALLOW_PARCEL_CHANGES) ? TRUE : FALSE ); |
360 | panel->childSetValue("block_parcel_search_check", (region_flags & REGION_FLAGS_BLOCK_PARCEL_SEARCH) ? TRUE : FALSE ); | 360 | panel->childSetValue("block_parcel_search_check", (region_flags & REGION_FLAGS_BLOCK_PARCEL_SEARCH) ? TRUE : FALSE ); |
361 | panel->childSetValue("agent_limit_spin", LLSD((F32)agent_limit) ); | 361 | panel->childSetValue("agent_limit_spin", LLSD((F32)agent_limit) ); |
362 | panel->childSetValue("object_bonus_spin", LLSD(object_bonus_factor) ); | 362 | panel->childSetValue("object_bonus_spin", LLSD(object_bonus_factor) ); |
363 | panel->childSetValue("access_combo", LLSD(sim_access) ); | 363 | panel->childSetValue("access_combo", LLSD(sim_access) ); |
364 | 364 | ||
365 | 365 | ||
366 | // detect teen grid for maturity | 366 | // detect teen grid for maturity |
367 | 367 | ||
368 | U32 parent_estate_id; | 368 | U32 parent_estate_id; |
369 | msg->getU32("RegionInfo", "ParentEstateID", parent_estate_id); | 369 | msg->getU32("RegionInfo", "ParentEstateID", parent_estate_id); |
370 | BOOL teen_grid = (parent_estate_id == 5); // *TODO add field to estate table and test that | 370 | BOOL teen_grid = (parent_estate_id == 5); // *TODO add field to estate table and test that |
371 | panel->childSetEnabled("access_combo", gAgent.isGodlike() || (region && region->canManageEstate() && !teen_grid)); | 371 | panel->childSetEnabled("access_combo", gAgent.isGodlike() || (region && region->canManageEstate() && !teen_grid)); |
372 | panel->setCtrlsEnabled(allow_modify); | 372 | panel->setCtrlsEnabled(allow_modify); |
373 | 373 | ||
374 | // RegionSettings PANEL | 374 | // RegionSettings PANEL |
375 | panel = tab->getChild<LLPanel>("RegionSettings"); | 375 | panel = tab->getChild<LLPanel>("RegionSettings"); |
376 | panel->setCtrlsEnabled(allow_modify); | 376 | panel->setCtrlsEnabled(allow_modify); |
377 | 377 | ||
378 | // DEBUG PANEL | 378 | // DEBUG PANEL |
379 | panel = tab->getChild<LLPanel>("Debug"); | 379 | panel = tab->getChild<LLPanel>("Debug"); |
380 | 380 | ||
381 | panel->childSetValue("region_text", LLSD(sim_name) ); | 381 | panel->childSetValue("region_text", LLSD(sim_name) ); |
382 | panel->childSetValue("disable_scripts_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_SCRIPTS)) ); | 382 | panel->childSetValue("disable_scripts_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_SCRIPTS)) ); |
383 | panel->childSetValue("disable_collisions_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_COLLISIONS)) ); | 383 | panel->childSetValue("disable_collisions_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_COLLISIONS)) ); |
384 | panel->childSetValue("disable_physics_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_PHYSICS)) ); | 384 | panel->childSetValue("disable_physics_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_PHYSICS)) ); |
385 | panel->setCtrlsEnabled(allow_modify); | 385 | panel->setCtrlsEnabled(allow_modify); |
386 | 386 | ||
387 | // TERRAIN PANEL | 387 | // TERRAIN PANEL |
388 | panel = tab->getChild<LLPanel>("Terrain"); | 388 | panel = tab->getChild<LLPanel>("Terrain"); |
389 | 389 | ||
390 | panel->childSetValue("region_text", LLSD(sim_name)); | 390 | panel->childSetValue("region_text", LLSD(sim_name)); |
391 | panel->childSetValue("water_height_spin", LLSD(water_height)); | 391 | panel->childSetValue("water_height_spin", LLSD(water_height)); |
392 | panel->childSetValue("terrain_raise_spin", LLSD(terrain_raise_limit)); | 392 | panel->childSetValue("terrain_raise_spin", LLSD(terrain_raise_limit)); |
393 | panel->childSetValue("terrain_lower_spin", LLSD(terrain_lower_limit)); | 393 | panel->childSetValue("terrain_lower_spin", LLSD(terrain_lower_limit)); |
394 | panel->childSetValue("use_estate_sun_check", LLSD(use_estate_sun)); | 394 | panel->childSetValue("use_estate_sun_check", LLSD(use_estate_sun)); |
395 | 395 | ||
396 | panel->childSetValue("fixed_sun_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SUN_FIXED))); | 396 | panel->childSetValue("fixed_sun_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SUN_FIXED))); |
397 | panel->childSetEnabled("fixed_sun_check", allow_modify && !use_estate_sun); | 397 | panel->childSetEnabled("fixed_sun_check", allow_modify && !use_estate_sun); |
398 | panel->childSetValue("sun_hour_slider", LLSD(sun_hour)); | 398 | panel->childSetValue("sun_hour_slider", LLSD(sun_hour)); |
399 | panel->childSetEnabled("sun_hour_slider", allow_modify && !use_estate_sun); | 399 | panel->childSetEnabled("sun_hour_slider", allow_modify && !use_estate_sun); |
400 | panel->setCtrlsEnabled(allow_modify); | 400 | panel->setCtrlsEnabled(allow_modify); |
401 | 401 | ||
402 | getInstance()->refreshFromRegion( gAgent.getRegion() ); | 402 | getInstance()->refreshFromRegion( gAgent.getRegion() ); |
403 | } | 403 | } |
404 | 404 | ||
405 | // static | 405 | // static |
406 | LLPanelEstateInfo* LLFloaterRegionInfo::getPanelEstate() | 406 | LLPanelEstateInfo* LLFloaterRegionInfo::getPanelEstate() |
407 | { | 407 | { |
408 | LLFloaterRegionInfo* floater = LLFloaterRegionInfo::getInstance(); | 408 | LLFloaterRegionInfo* floater = LLFloaterRegionInfo::getInstance(); |
409 | if (!floater) return NULL; | 409 | if (!floater) return NULL; |
410 | LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels"); | 410 | LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels"); |
411 | LLPanelEstateInfo* panel = (LLPanelEstateInfo*)tab->getChild<LLPanel>("Estate"); | 411 | LLPanelEstateInfo* panel = (LLPanelEstateInfo*)tab->getChild<LLPanel>("Estate"); |
412 | return panel; | 412 | return panel; |
413 | } | 413 | } |
414 | 414 | ||
415 | // static | 415 | // static |
416 | LLPanelEstateCovenant* LLFloaterRegionInfo::getPanelCovenant() | 416 | LLPanelEstateCovenant* LLFloaterRegionInfo::getPanelCovenant() |
417 | { | 417 | { |
418 | LLFloaterRegionInfo* floater = LLFloaterRegionInfo::getInstance(); | 418 | LLFloaterRegionInfo* floater = LLFloaterRegionInfo::getInstance(); |
419 | if (!floater) return NULL; | 419 | if (!floater) return NULL; |
420 | LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels"); | 420 | LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels"); |
421 | LLPanelEstateCovenant* panel = (LLPanelEstateCovenant*)tab->getChild<LLPanel>("Covenant"); | 421 | LLPanelEstateCovenant* panel = (LLPanelEstateCovenant*)tab->getChild<LLPanel>("Covenant"); |
422 | return panel; | 422 | return panel; |
423 | } | 423 | } |
424 | 424 | ||
425 | // static | 425 | // static |
426 | LLPanelRegionOpenSettingsInfo* LLFloaterRegionInfo::getPanelOpenSettings() | 426 | LLPanelRegionOpenSettingsInfo* LLFloaterRegionInfo::getPanelOpenSettings() |
427 | { | 427 | { |
428 | LLFloaterRegionInfo* floater = LLFloaterRegionInfo::getInstance(); | 428 | LLFloaterRegionInfo* floater = LLFloaterRegionInfo::getInstance(); |
429 | if (floater) | 429 | if (floater) |
430 | { | 430 | { |
431 | LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels"); | 431 | LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels"); |
432 | LLPanelRegionOpenSettingsInfo* panel = (LLPanelRegionOpenSettingsInfo*)tab->getChild<LLPanel>("RegionSettings", FALSE, FALSE); | 432 | LLPanelRegionOpenSettingsInfo* panel = (LLPanelRegionOpenSettingsInfo*)tab->getChild<LLPanel>("RegionSettings", FALSE, FALSE); |
433 | if (panel) | 433 | if (panel) |
434 | { | 434 | { |
435 | return panel; | 435 | return panel; |
436 | } | 436 | } |
437 | } | 437 | } |
438 | return NULL; | 438 | return NULL; |
439 | } | 439 | } |
440 | 440 | ||
441 | void LLFloaterRegionInfo::refreshFromRegion(LLViewerRegion* region) | 441 | void LLFloaterRegionInfo::refreshFromRegion(LLViewerRegion* region) |
442 | { | 442 | { |
443 | // call refresh from region on all panels | 443 | // call refresh from region on all panels |
444 | std::for_each( | 444 | std::for_each( |
445 | mInfoPanels.begin(), | 445 | mInfoPanels.begin(), |
446 | mInfoPanels.end(), | 446 | mInfoPanels.end(), |
447 | llbind2nd( | 447 | llbind2nd( |
448 | #if LL_WINDOWS | 448 | #if LL_WINDOWS |
449 | std::mem_fun1(&LLPanelRegionInfo::refreshFromRegion), | 449 | std::mem_fun1(&LLPanelRegionInfo::refreshFromRegion), |
450 | #else | 450 | #else |
451 | std::mem_fun(&LLPanelRegionInfo::refreshFromRegion), | 451 | std::mem_fun(&LLPanelRegionInfo::refreshFromRegion), |
452 | #endif | 452 | #endif |
453 | region)); | 453 | region)); |
454 | } | 454 | } |
455 | 455 | ||
456 | // public | 456 | // public |
457 | void LLFloaterRegionInfo::refresh() | 457 | void LLFloaterRegionInfo::refresh() |
458 | { | 458 | { |
459 | for(info_panels_t::iterator iter = mInfoPanels.begin(); | 459 | for(info_panels_t::iterator iter = mInfoPanels.begin(); |
460 | iter != mInfoPanels.end(); ++iter) | 460 | iter != mInfoPanels.end(); ++iter) |
461 | { | 461 | { |
462 | (*iter)->refresh(); | 462 | (*iter)->refresh(); |
463 | } | 463 | } |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | ///---------------------------------------------------------------------------- | 467 | ///---------------------------------------------------------------------------- |
468 | /// Local class implementation | 468 | /// Local class implementation |
469 | ///---------------------------------------------------------------------------- | 469 | ///---------------------------------------------------------------------------- |
470 | 470 | ||
471 | // | 471 | // |
472 | // LLPanelRegionInfo | 472 | // LLPanelRegionInfo |
473 | // | 473 | // |
474 | 474 | ||
475 | // static | 475 | // static |
476 | void LLPanelRegionInfo::onBtnSet(void* user_data) | 476 | void LLPanelRegionInfo::onBtnSet(void* user_data) |
477 | { | 477 | { |
478 | LLPanelRegionInfo* panel = (LLPanelRegionInfo*)user_data; | 478 | LLPanelRegionInfo* panel = (LLPanelRegionInfo*)user_data; |
479 | if(!panel) return; | 479 | if(!panel) return; |
480 | if (panel->sendUpdate()) | 480 | if (panel->sendUpdate()) |
481 | { | 481 | { |
482 | panel->disableButton("apply_btn"); | 482 | panel->disableButton("apply_btn"); |
483 | } | 483 | } |
484 | } | 484 | } |
485 | 485 | ||
486 | //static | 486 | //static |
487 | void LLPanelRegionInfo::onChangeChildCtrl(LLUICtrl* ctrl, void* user_data) | 487 | void LLPanelRegionInfo::onChangeChildCtrl(LLUICtrl* ctrl, void* user_data) |
488 | { | 488 | { |
489 | if (ctrl) | 489 | if (ctrl) |
490 | { | 490 | { |
491 | LLPanelRegionInfo* panel = (LLPanelRegionInfo*) ctrl->getParent(); | 491 | LLPanelRegionInfo* panel = (LLPanelRegionInfo*) ctrl->getParent(); |
492 | panel->updateChild(ctrl); | 492 | panel->updateChild(ctrl); |
493 | } | 493 | } |
494 | } | 494 | } |
495 | 495 | ||
496 | // static | 496 | // static |
497 | // Enables the "set" button if it is not already enabled | 497 | // Enables the "set" button if it is not already enabled |
498 | void LLPanelRegionInfo::onChangeAnything(LLUICtrl* ctrl, void* user_data) | 498 | void LLPanelRegionInfo::onChangeAnything(LLUICtrl* ctrl, void* user_data) |
499 | { | 499 | { |
500 | LLPanelRegionInfo* panel = (LLPanelRegionInfo*)user_data; | 500 | LLPanelRegionInfo* panel = (LLPanelRegionInfo*)user_data; |
501 | if(panel) | 501 | if(panel) |
502 | { | 502 | { |
503 | panel->enableButton("apply_btn"); | 503 | panel->enableButton("apply_btn"); |
504 | panel->refresh(); | 504 | panel->refresh(); |
505 | } | 505 | } |
506 | } | 506 | } |
507 | 507 | ||
508 | // static | 508 | // static |
509 | // Enables set button on change to line editor | 509 | // Enables set button on change to line editor |
510 | void LLPanelRegionInfo::onChangeText(LLLineEditor* caller, void* user_data) | 510 | void LLPanelRegionInfo::onChangeText(LLLineEditor* caller, void* user_data) |
511 | { | 511 | { |
512 | // reuse the previous method | 512 | // reuse the previous method |
513 | onChangeAnything(0, user_data); | 513 | onChangeAnything(0, user_data); |
514 | } | 514 | } |
515 | 515 | ||
516 | 516 | ||
517 | // virtual | 517 | // virtual |
518 | BOOL LLPanelRegionInfo::postBuild() | 518 | BOOL LLPanelRegionInfo::postBuild() |
519 | { | 519 | { |
520 | childSetAction("apply_btn", onBtnSet, this); | 520 | childSetAction("apply_btn", onBtnSet, this); |
521 | childDisable("apply_btn"); | 521 | childDisable("apply_btn"); |
522 | refresh(); | 522 | refresh(); |
523 | return TRUE; | 523 | return TRUE; |
524 | } | 524 | } |
525 | 525 | ||
526 | // virtual | 526 | // virtual |
527 | void LLPanelRegionInfo::updateChild(LLUICtrl* child_ctr) | 527 | void LLPanelRegionInfo::updateChild(LLUICtrl* child_ctr) |
528 | { | 528 | { |
529 | } | 529 | } |
530 | 530 | ||
531 | // virtual | 531 | // virtual |
532 | bool LLPanelRegionInfo::refreshFromRegion(LLViewerRegion* region) | 532 | bool LLPanelRegionInfo::refreshFromRegion(LLViewerRegion* region) |
533 | { | 533 | { |
534 | if (region) mHost = region->getHost(); | 534 | if (region) mHost = region->getHost(); |
535 | return true; | 535 | return true; |
536 | } | 536 | } |
537 | 537 | ||
538 | void LLPanelRegionInfo::sendEstateOwnerMessage( | 538 | void LLPanelRegionInfo::sendEstateOwnerMessage( |
539 | LLMessageSystem* msg, | 539 | LLMessageSystem* msg, |
540 | const std::string& request, | 540 | const std::string& request, |
541 | const LLUUID& invoice, | 541 | const LLUUID& invoice, |
542 | const strings_t& strings) | 542 | const strings_t& strings) |
543 | { | 543 | { |
544 | llinfos << "Sending estate request '" << request << "'" << llendl; | 544 | llinfos << "Sending estate request '" << request << "'" << llendl; |
545 | msg->newMessage("EstateOwnerMessage"); | 545 | msg->newMessage("EstateOwnerMessage"); |
546 | msg->nextBlockFast(_PREHASH_AgentData); | 546 | msg->nextBlockFast(_PREHASH_AgentData); |
547 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | 547 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); |
548 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | 548 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); |
549 | msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used | 549 | msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used |
550 | msg->nextBlock("MethodData"); | 550 | msg->nextBlock("MethodData"); |
551 | msg->addString("Method", request); | 551 | msg->addString("Method", request); |
552 | msg->addUUID("Invoice", invoice); | 552 | msg->addUUID("Invoice", invoice); |
553 | if(strings.empty()) | 553 | if(strings.empty()) |
554 | { | 554 | { |
555 | msg->nextBlock("ParamList"); | 555 | msg->nextBlock("ParamList"); |
556 | msg->addString("Parameter", NULL); | 556 | msg->addString("Parameter", NULL); |
557 | } | 557 | } |
558 | else | 558 | else |
559 | { | 559 | { |
560 | strings_t::const_iterator it = strings.begin(); | 560 | strings_t::const_iterator it = strings.begin(); |
561 | strings_t::const_iterator end = strings.end(); | 561 | strings_t::const_iterator end = strings.end(); |
562 | for(; it != end; ++it) | 562 | for(; it != end; ++it) |
563 | { | 563 | { |
564 | msg->nextBlock("ParamList"); | 564 | msg->nextBlock("ParamList"); |
565 | msg->addString("Parameter", *it); | 565 | msg->addString("Parameter", *it); |
566 | } | 566 | } |
567 | } | 567 | } |
568 | msg->sendReliable(mHost); | 568 | msg->sendReliable(mHost); |
569 | } | 569 | } |
570 | 570 | ||
571 | void LLPanelRegionInfo::enableButton(const std::string& btn_name, BOOL enable) | 571 | void LLPanelRegionInfo::enableButton(const std::string& btn_name, BOOL enable) |
572 | { | 572 | { |
573 | childSetEnabled(btn_name, enable); | 573 | childSetEnabled(btn_name, enable); |
574 | } | 574 | } |
575 | 575 | ||
576 | void LLPanelRegionInfo::disableButton(const std::string& btn_name) | 576 | void LLPanelRegionInfo::disableButton(const std::string& btn_name) |
577 | { | 577 | { |
578 | childDisable(btn_name); | 578 | childDisable(btn_name); |
579 | } | 579 | } |
580 | 580 | ||
581 | void LLPanelRegionInfo::initCtrl(const std::string& name) | 581 | void LLPanelRegionInfo::initCtrl(const std::string& name) |
582 | { | 582 | { |
583 | childSetCommitCallback(name, onChangeAnything, this); | 583 | childSetCommitCallback(name, onChangeAnything, this); |
584 | } | 584 | } |
585 | 585 | ||
586 | void LLPanelRegionInfo::initHelpBtn(const std::string& name, const std::string& xml_alert) | 586 | void LLPanelRegionInfo::initHelpBtn(const std::string& name, const std::string& xml_alert) |
587 | { | 587 | { |
588 | childSetAction(name, onClickHelp, new std::string(xml_alert)); | 588 | childSetAction(name, onClickHelp, new std::string(xml_alert)); |
589 | } | 589 | } |
590 | 590 | ||
591 | // static | 591 | // static |
592 | void LLPanelRegionInfo::onClickHelp(void* data) | 592 | void LLPanelRegionInfo::onClickHelp(void* data) |
593 | { | 593 | { |
594 | std::string* xml_alert = (std::string*)data; | 594 | std::string* xml_alert = (std::string*)data; |
595 | LLNotifications::instance().add(*xml_alert); | 595 | LLNotifications::instance().add(*xml_alert); |
596 | } | 596 | } |
597 | 597 | ||
598 | ///////////////////////////////////////////////////////////////////////////// | 598 | ///////////////////////////////////////////////////////////////////////////// |
599 | // LLPanelRegionGeneralInfo | 599 | // LLPanelRegionGeneralInfo |
600 | // | 600 | // |
601 | bool LLPanelRegionGeneralInfo::refreshFromRegion(LLViewerRegion* region) | 601 | bool LLPanelRegionGeneralInfo::refreshFromRegion(LLViewerRegion* region) |
602 | { | 602 | { |
603 | BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate()); | 603 | BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate()); |
604 | setCtrlsEnabled(allow_modify); | 604 | setCtrlsEnabled(allow_modify); |
605 | childDisable("apply_btn"); | 605 | childDisable("apply_btn"); |
606 | childSetEnabled("access_text", allow_modify); | 606 | childSetEnabled("access_text", allow_modify); |
607 | // childSetEnabled("access_combo", allow_modify); | 607 | // childSetEnabled("access_combo", allow_modify); |
608 | // now set in processRegionInfo for teen grid detection | 608 | // now set in processRegionInfo for teen grid detection |
609 | childSetEnabled("kick_btn", allow_modify); | 609 | childSetEnabled("kick_btn", allow_modify); |
610 | childSetEnabled("kick_all_btn", allow_modify); | 610 | childSetEnabled("kick_all_btn", allow_modify); |
611 | childSetEnabled("im_btn", allow_modify); | 611 | childSetEnabled("im_btn", allow_modify); |
612 | childSetEnabled("manage_telehub_btn", allow_modify); | 612 | childSetEnabled("manage_telehub_btn", allow_modify); |
613 | 613 | ||
614 | // Data gets filled in by processRegionInfo | 614 | // Data gets filled in by processRegionInfo |
615 | 615 | ||
616 | return LLPanelRegionInfo::refreshFromRegion(region); | 616 | return LLPanelRegionInfo::refreshFromRegion(region); |
617 | } | 617 | } |
618 | 618 | ||
619 | BOOL LLPanelRegionGeneralInfo::postBuild() | 619 | BOOL LLPanelRegionGeneralInfo::postBuild() |
620 | { | 620 | { |
621 | // Enable the "Apply" button if something is changed. JC | 621 | // Enable the "Apply" button if something is changed. JC |
622 | initCtrl("block_terraform_check"); | 622 | initCtrl("block_terraform_check"); |
623 | initCtrl("block_fly_check"); | 623 | initCtrl("block_fly_check"); |
624 | initCtrl("allow_damage_check"); | 624 | initCtrl("allow_damage_check"); |
625 | initCtrl("allow_land_resell_check"); | 625 | initCtrl("allow_land_resell_check"); |
626 | initCtrl("allow_parcel_changes_check"); | 626 | initCtrl("allow_parcel_changes_check"); |
627 | initCtrl("agent_limit_spin"); | 627 | initCtrl("agent_limit_spin"); |
628 | initCtrl("object_bonus_spin"); | 628 | initCtrl("object_bonus_spin"); |
629 | initCtrl("access_combo"); | 629 | initCtrl("access_combo"); |
630 | initCtrl("restrict_pushobject"); | 630 | initCtrl("restrict_pushobject"); |
631 | initCtrl("block_parcel_search_check"); | 631 | initCtrl("block_parcel_search_check"); |
632 | initCtrl("minimum_agent_age"); | 632 | initCtrl("minimum_agent_age"); |
633 | 633 | ||
634 | initHelpBtn("terraform_help", "HelpRegionBlockTerraform"); | 634 | initHelpBtn("terraform_help", "HelpRegionBlockTerraform"); |
635 | initHelpBtn("fly_help", "HelpRegionBlockFly"); | 635 | initHelpBtn("fly_help", "HelpRegionBlockFly"); |
636 | initHelpBtn("damage_help", "HelpRegionAllowDamage"); | 636 | initHelpBtn("damage_help", "HelpRegionAllowDamage"); |
637 | initHelpBtn("agent_limit_help", "HelpRegionAgentLimit"); | 637 | initHelpBtn("agent_limit_help", "HelpRegionAgentLimit"); |
638 | initHelpBtn("object_bonus_help", "HelpRegionObjectBonus"); | 638 | initHelpBtn("object_bonus_help", "HelpRegionObjectBonus"); |
639 | initHelpBtn("access_help", "HelpRegionMaturity"); | 639 | initHelpBtn("access_help", "HelpRegionMaturity"); |
640 | initHelpBtn("restrict_pushobject_help", "HelpRegionRestrictPushObject"); | 640 | initHelpBtn("restrict_pushobject_help", "HelpRegionRestrictPushObject"); |
641 | initHelpBtn("land_resell_help", "HelpRegionLandResell"); | 641 | initHelpBtn("land_resell_help", "HelpRegionLandResell"); |
642 | initHelpBtn("parcel_changes_help", "HelpParcelChanges"); | 642 | initHelpBtn("parcel_changes_help", "HelpParcelChanges"); |
643 | initHelpBtn("parcel_search_help", "HelpRegionSearch"); | 643 | initHelpBtn("parcel_search_help", "HelpRegionSearch"); |
644 | 644 | ||
645 | childSetAction("kick_btn", onClickKick, this); | 645 | childSetAction("kick_btn", onClickKick, this); |
646 | childSetAction("kick_all_btn", onClickKickAll, this); | 646 | childSetAction("kick_all_btn", onClickKickAll, this); |
647 | childSetAction("im_btn", onClickMessage, this); | 647 | childSetAction("im_btn", onClickMessage, this); |
648 | childSetAction("manage_telehub_btn", onClickManageTelehub, this); | 648 | childSetAction("manage_telehub_btn", onClickManageTelehub, this); |
649 | 649 | ||
650 | return LLPanelRegionInfo::postBuild(); | 650 | return LLPanelRegionInfo::postBuild(); |
651 | } | 651 | } |
652 | 652 | ||
653 | // static | 653 | // static |
654 | void LLPanelRegionGeneralInfo::onClickKick(void* userdata) | 654 | void LLPanelRegionGeneralInfo::onClickKick(void* userdata) |
655 | { | 655 | { |
656 | llinfos << "LLPanelRegionGeneralInfo::onClickKick" << llendl; | 656 | llinfos << "LLPanelRegionGeneralInfo::onClickKick" << llendl; |
657 | LLPanelRegionGeneralInfo* panelp = (LLPanelRegionGeneralInfo*)userdata; | 657 | LLPanelRegionGeneralInfo* panelp = (LLPanelRegionGeneralInfo*)userdata; |
658 | 658 | ||
659 | // this depends on the grandparent view being a floater | 659 | // this depends on the grandparent view being a floater |
660 | // in order to set up floater dependency | 660 | // in order to set up floater dependency |
661 | LLFloater* parent_floater = gFloaterView->getParentFloater(panelp); | 661 | LLFloater* parent_floater = gFloaterView->getParentFloater(panelp); |
662 | LLFloater* child_floater = LLFloaterAvatarPicker::show(onKickCommit, userdata, FALSE, TRUE); | 662 | LLFloater* child_floater = LLFloaterAvatarPicker::show(onKickCommit, userdata, FALSE, TRUE); |
663 | parent_floater->addDependentFloater(child_floater); | 663 | parent_floater->addDependentFloater(child_floater); |
664 | } | 664 | } |
665 | 665 | ||
666 | // static | 666 | // static |
667 | void LLPanelRegionGeneralInfo::onKickCommit(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* userdata) | 667 | void LLPanelRegionGeneralInfo::onKickCommit(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* userdata) |
668 | { | 668 | { |
669 | if (names.empty() || ids.empty()) return; | 669 | if (names.empty() || ids.empty()) return; |
670 | if(ids[0].notNull()) | 670 | if(ids[0].notNull()) |
671 | { | 671 | { |
672 | LLPanelRegionGeneralInfo* self = (LLPanelRegionGeneralInfo*)userdata; | 672 | LLPanelRegionGeneralInfo* self = (LLPanelRegionGeneralInfo*)userdata; |
673 | if(!self) return; | 673 | if(!self) return; |
674 | strings_t strings; | 674 | strings_t strings; |
675 | // [0] = our agent id | 675 | // [0] = our agent id |
676 | // [1] = target agent id | 676 | // [1] = target agent id |
677 | std::string buffer; | 677 | std::string buffer; |
678 | gAgent.getID().toString(buffer); | 678 | gAgent.getID().toString(buffer); |
679 | strings.push_back(buffer); | 679 | strings.push_back(buffer); |
680 | 680 | ||
681 | ids[0].toString(buffer); | 681 | ids[0].toString(buffer); |
682 | strings.push_back(strings_t::value_type(buffer)); | 682 | strings.push_back(strings_t::value_type(buffer)); |
683 | 683 | ||
684 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); | 684 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); |
685 | self->sendEstateOwnerMessage(gMessageSystem, "teleporthomeuser", invoice, strings); | 685 | self->sendEstateOwnerMessage(gMessageSystem, "teleporthomeuser", invoice, strings); |
686 | } | 686 | } |
687 | } | 687 | } |
688 | 688 | ||
689 | // static | 689 | // static |
690 | void LLPanelRegionGeneralInfo::onClickKickAll(void* userdata) | 690 | void LLPanelRegionGeneralInfo::onClickKickAll(void* userdata) |
691 | { | 691 | { |
692 | llinfos << "LLPanelRegionGeneralInfo::onClickKickAll" << llendl; | 692 | llinfos << "LLPanelRegionGeneralInfo::onClickKickAll" << llendl; |
693 | LLNotifications::instance().add("KickUsersFromRegion", | 693 | LLNotifications::instance().add("KickUsersFromRegion", |
694 | LLSD(), | 694 | LLSD(), |
695 | LLSD(), | 695 | LLSD(), |
696 | boost::bind(&LLPanelRegionGeneralInfo::onKickAllCommit, (LLPanelRegionGeneralInfo*)userdata, _1, _2)); | 696 | boost::bind(&LLPanelRegionGeneralInfo::onKickAllCommit, (LLPanelRegionGeneralInfo*)userdata, _1, _2)); |
697 | } | 697 | } |
698 | 698 | ||
699 | bool LLPanelRegionGeneralInfo::onKickAllCommit(const LLSD& notification, const LLSD& response) | 699 | bool LLPanelRegionGeneralInfo::onKickAllCommit(const LLSD& notification, const LLSD& response) |
700 | { | 700 | { |
701 | S32 option = LLNotification::getSelectedOption(notification, response); | 701 | S32 option = LLNotification::getSelectedOption(notification, response); |
702 | if (option == 0) | 702 | if (option == 0) |
703 | { | 703 | { |
704 | strings_t strings; | 704 | strings_t strings; |
705 | // [0] = our agent id | 705 | // [0] = our agent id |
706 | std::string buffer; | 706 | std::string buffer; |
707 | gAgent.getID().toString(buffer); | 707 | gAgent.getID().toString(buffer); |
708 | strings.push_back(buffer); | 708 | strings.push_back(buffer); |
709 | 709 | ||
710 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); | 710 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); |
711 | // historical message name | 711 | // historical message name |
712 | sendEstateOwnerMessage(gMessageSystem, "teleporthomeallusers", invoice, strings); | 712 | sendEstateOwnerMessage(gMessageSystem, "teleporthomeallusers", invoice, strings); |
713 | } | 713 | } |
714 | return false; | 714 | return false; |
715 | } | 715 | } |
716 | 716 | ||
717 | // static | 717 | // static |
718 | void LLPanelRegionGeneralInfo::onClickMessage(void* userdata) | 718 | void LLPanelRegionGeneralInfo::onClickMessage(void* userdata) |
719 | { | 719 | { |
720 | llinfos << "LLPanelRegionGeneralInfo::onClickMessage" << llendl; | 720 | llinfos << "LLPanelRegionGeneralInfo::onClickMessage" << llendl; |
721 | LLNotifications::instance().add("MessageRegion", | 721 | LLNotifications::instance().add("MessageRegion", |
722 | LLSD(), | 722 | LLSD(), |
723 | LLSD(), | 723 | LLSD(), |
724 | boost::bind(&LLPanelRegionGeneralInfo::onMessageCommit, (LLPanelRegionGeneralInfo*)userdata, _1, _2)); | 724 | boost::bind(&LLPanelRegionGeneralInfo::onMessageCommit, (LLPanelRegionGeneralInfo*)userdata, _1, _2)); |
725 | } | 725 | } |
726 | 726 | ||
727 | // static | 727 | // static |
728 | bool LLPanelRegionGeneralInfo::onMessageCommit(const LLSD& notification, const LLSD& response) | 728 | bool LLPanelRegionGeneralInfo::onMessageCommit(const LLSD& notification, const LLSD& response) |
729 | { | 729 | { |
730 | if(LLNotification::getSelectedOption(notification, response) != 0) return false; | 730 | if(LLNotification::getSelectedOption(notification, response) != 0) return false; |
731 | 731 | ||
732 | std::string text = response["message"].asString(); | 732 | std::string text = response["message"].asString(); |
733 | if (text.empty()) return false; | 733 | if (text.empty()) return false; |
734 | 734 | ||
735 | llinfos << "Message to everyone: " << text << llendl; | 735 | llinfos << "Message to everyone: " << text << llendl; |
736 | strings_t strings; | 736 | strings_t strings; |
737 | // [0] grid_x, unused here | 737 | // [0] grid_x, unused here |
738 | // [1] grid_y, unused here | 738 | // [1] grid_y, unused here |
739 | // [2] agent_id of sender | 739 | // [2] agent_id of sender |
740 | // [3] sender name | 740 | // [3] sender name |
741 | // [4] message | 741 | // [4] message |
742 | strings.push_back("-1"); | 742 | strings.push_back("-1"); |
743 | strings.push_back("-1"); | 743 | strings.push_back("-1"); |
744 | std::string buffer; | 744 | std::string buffer; |
745 | gAgent.getID().toString(buffer); | 745 | gAgent.getID().toString(buffer); |
746 | strings.push_back(buffer); | 746 | strings.push_back(buffer); |
747 | std::string name; | 747 | std::string name; |
748 | gAgent.buildFullname(name); | 748 | gAgent.buildFullname(name); |
749 | strings.push_back(strings_t::value_type(name)); | 749 | strings.push_back(strings_t::value_type(name)); |
750 | strings.push_back(strings_t::value_type(text)); | 750 | strings.push_back(strings_t::value_type(text)); |
751 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); | 751 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); |
752 | sendEstateOwnerMessage(gMessageSystem, "simulatormessage", invoice, strings); | 752 | sendEstateOwnerMessage(gMessageSystem, "simulatormessage", invoice, strings); |
753 | return false; | 753 | return false; |
754 | } | 754 | } |
755 | 755 | ||
756 | // static | 756 | // static |
757 | void LLPanelRegionGeneralInfo::onClickManageTelehub(void* data) | 757 | void LLPanelRegionGeneralInfo::onClickManageTelehub(void* data) |
758 | { | 758 | { |
759 | LLFloaterRegionInfo::getInstance()->close(); | 759 | LLFloaterRegionInfo::getInstance()->close(); |
760 | 760 | ||
761 | LLFloaterTelehub::show(); | 761 | LLFloaterTelehub::show(); |
762 | } | 762 | } |
763 | 763 | ||
764 | // setregioninfo | 764 | // setregioninfo |
765 | // strings[0] = 'Y' - block terraform, 'N' - not | 765 | // strings[0] = 'Y' - block terraform, 'N' - not |
766 | // strings[1] = 'Y' - block fly, 'N' - not | 766 | // strings[1] = 'Y' - block fly, 'N' - not |
767 | // strings[2] = 'Y' - allow damage, 'N' - not | 767 | // strings[2] = 'Y' - allow damage, 'N' - not |
768 | // strings[3] = 'Y' - allow land sale, 'N' - not | 768 | // strings[3] = 'Y' - allow land sale, 'N' - not |
769 | // strings[4] = agent limit | 769 | // strings[4] = agent limit |
770 | // strings[5] = object bonus | 770 | // strings[5] = object bonus |
771 | // strings[6] = sim access (0 = unknown, 13 = PG, 21 = Mature, 42 = Adult) | 771 | // strings[6] = sim access (0 = unknown, 13 = PG, 21 = Mature, 42 = Adult) |
772 | // strings[7] = restrict pushobject | 772 | // strings[7] = restrict pushobject |
773 | // strings[8] = 'Y' - allow parcel subdivide, 'N' - not | 773 | // strings[8] = 'Y' - allow parcel subdivide, 'N' - not |
774 | // strings[9] = 'Y' - block parcel search, 'N' - allow | 774 | // strings[9] = 'Y' - block parcel search, 'N' - allow |
775 | BOOL LLPanelRegionGeneralInfo::sendUpdate() | 775 | BOOL LLPanelRegionGeneralInfo::sendUpdate() |
776 | { | 776 | { |
777 | llinfos << "LLPanelRegionGeneralInfo::sendUpdate()" << llendl; | 777 | llinfos << "LLPanelRegionGeneralInfo::sendUpdate()" << llendl; |
778 | 778 | ||
779 | // First try using a Cap. If that fails use the old method. | 779 | // First try using a Cap. If that fails use the old method. |
780 | LLSD body; | 780 | LLSD body; |
781 | std::string url = gAgent.getRegion()->getCapability("DispatchRegionInfo"); | 781 | std::string url = gAgent.getRegion()->getCapability("DispatchRegionInfo"); |
782 | if (!url.empty()) | 782 | if (!url.empty()) |
783 | { | 783 | { |
784 | body["block_terraform"] = childGetValue("block_terraform_check"); | 784 | body["block_terraform"] = childGetValue("block_terraform_check"); |
785 | body["block_fly"] = childGetValue("block_fly_check"); | 785 | body["block_fly"] = childGetValue("block_fly_check"); |
786 | body["allow_damage"] = childGetValue("allow_damage_check"); | 786 | body["allow_damage"] = childGetValue("allow_damage_check"); |
787 | body["allow_land_resell"] = childGetValue("allow_land_resell_check"); | 787 | body["allow_land_resell"] = childGetValue("allow_land_resell_check"); |
788 | body["agent_limit"] = childGetValue("agent_limit_spin"); | 788 | body["agent_limit"] = childGetValue("agent_limit_spin"); |
789 | body["prim_bonus"] = childGetValue("object_bonus_spin"); | 789 | body["prim_bonus"] = childGetValue("object_bonus_spin"); |
790 | body["sim_access"] = childGetValue("access_combo"); | 790 | body["sim_access"] = childGetValue("access_combo"); |
791 | body["restrict_pushobject"] = childGetValue("restrict_pushobject"); | 791 | body["restrict_pushobject"] = childGetValue("restrict_pushobject"); |
792 | body["allow_parcel_changes"] = childGetValue("allow_parcel_changes_check"); | 792 | body["allow_parcel_changes"] = childGetValue("allow_parcel_changes_check"); |
793 | body["block_parcel_search"] = childGetValue("block_parcel_search_check"); | 793 | body["block_parcel_search"] = childGetValue("block_parcel_search_check"); |
794 | body["minimum_agent_age"] = childGetValue("minimum_agent_age"); | 794 | body["minimum_agent_age"] = childGetValue("minimum_agent_age"); |
795 | 795 | ||
796 | LLHTTPClient::post(url, body, new LLHTTPClient::Responder()); | 796 | LLHTTPClient::post(url, body, new LLHTTPClient::Responder()); |
797 | } | 797 | } |
798 | else | 798 | else |
799 | { | 799 | { |
800 | strings_t strings; | 800 | strings_t strings; |
801 | std::string buffer; | 801 | std::string buffer; |
802 | 802 | ||
803 | buffer = llformat("%s", (childGetValue("block_terraform_check").asBoolean() ? "Y" : "N")); | 803 | buffer = llformat("%s", (childGetValue("block_terraform_check").asBoolean() ? "Y" : "N")); |
804 | strings.push_back(strings_t::value_type(buffer)); | 804 | strings.push_back(strings_t::value_type(buffer)); |
805 | 805 | ||
806 | buffer = llformat("%s", (childGetValue("block_fly_check").asBoolean() ? "Y" : "N")); | 806 | buffer = llformat("%s", (childGetValue("block_fly_check").asBoolean() ? "Y" : "N")); |
807 | strings.push_back(strings_t::value_type(buffer)); | 807 | strings.push_back(strings_t::value_type(buffer)); |
808 | 808 | ||
809 | buffer = llformat("%s", (childGetValue("allow_damage_check").asBoolean() ? "Y" : "N")); | 809 | buffer = llformat("%s", (childGetValue("allow_damage_check").asBoolean() ? "Y" : "N")); |
810 | strings.push_back(strings_t::value_type(buffer)); | 810 | strings.push_back(strings_t::value_type(buffer)); |
811 | 811 | ||
812 | buffer = llformat("%s", (childGetValue("allow_land_resell_check").asBoolean() ? "Y" : "N")); | 812 | buffer = llformat("%s", (childGetValue("allow_land_resell_check").asBoolean() ? "Y" : "N")); |
813 | strings.push_back(strings_t::value_type(buffer)); | 813 | strings.push_back(strings_t::value_type(buffer)); |
814 | 814 | ||
815 | F32 value = (F32)childGetValue("agent_limit_spin").asReal(); | 815 | F32 value = (F32)childGetValue("agent_limit_spin").asReal(); |
816 | buffer = llformat("%f", value); | 816 | buffer = llformat("%f", value); |
817 | strings.push_back(strings_t::value_type(buffer)); | 817 | strings.push_back(strings_t::value_type(buffer)); |
818 | 818 | ||
819 | value = (F32)childGetValue("object_bonus_spin").asReal(); | 819 | value = (F32)childGetValue("object_bonus_spin").asReal(); |
820 | buffer = llformat("%f", value); | 820 | buffer = llformat("%f", value); |
821 | strings.push_back(strings_t::value_type(buffer)); | 821 | strings.push_back(strings_t::value_type(buffer)); |
822 | 822 | ||
823 | buffer = llformat("%d", childGetValue("access_combo").asInteger()); | 823 | buffer = llformat("%d", childGetValue("access_combo").asInteger()); |
824 | strings.push_back(strings_t::value_type(buffer)); | 824 | strings.push_back(strings_t::value_type(buffer)); |
825 | 825 | ||
826 | buffer = llformat("%s", (childGetValue("restrict_pushobject").asBoolean() ? "Y" : "N")); | 826 | buffer = llformat("%s", (childGetValue("restrict_pushobject").asBoolean() ? "Y" : "N")); |
827 | strings.push_back(strings_t::value_type(buffer)); | 827 | strings.push_back(strings_t::value_type(buffer)); |
828 | 828 | ||
829 | buffer = llformat("%s", (childGetValue("allow_parcel_changes_check").asBoolean() ? "Y" : "N")); | 829 | buffer = llformat("%s", (childGetValue("allow_parcel_changes_check").asBoolean() ? "Y" : "N")); |
830 | strings.push_back(strings_t::value_type(buffer)); | 830 | strings.push_back(strings_t::value_type(buffer)); |
831 | 831 | ||
832 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); | 832 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); |
833 | sendEstateOwnerMessage(gMessageSystem, "setregioninfo", invoice, strings); | 833 | sendEstateOwnerMessage(gMessageSystem, "setregioninfo", invoice, strings); |
834 | } | 834 | } |
835 | 835 | ||
836 | // if we changed access levels, tell user about it | 836 | // if we changed access levels, tell user about it |
837 | LLViewerRegion* region = gAgent.getRegion(); | 837 | LLViewerRegion* region = gAgent.getRegion(); |
838 | if (region && (childGetValue("access_combo").asInteger() != region->getSimAccess()) ) | 838 | if (region && (childGetValue("access_combo").asInteger() != region->getSimAccess()) ) |
839 | { | 839 | { |
840 | LLNotifications::instance().add("RegionMaturityChange"); | 840 | LLNotifications::instance().add("RegionMaturityChange"); |
841 | } | 841 | } |
842 | 842 | ||
843 | return TRUE; | 843 | return TRUE; |
844 | } | 844 | } |
845 | 845 | ||
846 | ///////////////////////////////////////////////////////////////////////////// | 846 | ///////////////////////////////////////////////////////////////////////////// |
847 | // LLPanelRegionOpenSettingsInfo | 847 | // LLPanelRegionOpenSettingsInfo |
848 | // | 848 | // |
849 | bool LLPanelRegionOpenSettingsInfo::refreshFromRegion(LLViewerRegion* region) | 849 | bool LLPanelRegionOpenSettingsInfo::refreshFromRegion(LLViewerRegion* region) |
850 | { | 850 | { |
851 | // Data gets filled in by hippo manager | 851 | // Data gets filled in by hippo manager |
852 | BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate()); | 852 | BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate()); |
853 | 853 | ||
854 | childSetValue("draw_distance", gAgent.mDrawDistance); | 854 | childSetValue("draw_distance", gAgent.mDrawDistance); |
855 | childSetValue("force_draw_distance", gAgent.mLockedDrawDistance); | 855 | childSetValue("force_draw_distance", gAgent.mLockedDrawDistance); |
856 | childSetValue("allow_minimap", LLSD(gHippoLimits->mAllowMinimap)); | 856 | childSetValue("allow_minimap", LLSD(gHippoLimits->mAllowMinimap)); |
857 | childSetValue("allow_physical_prims", (gHippoLimits->mAllowPhysicalPrims == 1 ? TRUE : FALSE)); | 857 | childSetValue("allow_physical_prims", (gHippoLimits->mAllowPhysicalPrims == 1 ? TRUE : FALSE)); |
858 | childSetValue("max_drag_distance", LLSD(gHippoLimits->mMaxDragDistance)); | 858 | childSetValue("max_drag_distance", LLSD(gHippoLimits->mMaxDragDistance)); |
859 | childSetValue("min_hole_size", LLSD(gHippoLimits->mMinHoleSize)); | 859 | childSetValue("min_hole_size", LLSD(gHippoLimits->mMinHoleSize)); |
860 | childSetValue("max_hollow_size", LLSD(gHippoLimits->mMaxHollow)); | 860 | childSetValue("max_hollow_size", LLSD(gHippoLimits->mMaxHollow)); |
861 | childSetValue("max_inventory_items_transfer", LLSD(gHippoLimits->mMaxInventoryItemsTransfer)); | 861 | childSetValue("max_inventory_items_transfer", LLSD(gHippoLimits->mMaxInventoryItemsTransfer)); |
862 | childSetValue("max_link_count", LLSD(gHippoLimits->mMaxLinkedPrims)); | 862 | childSetValue("max_link_count", LLSD(gHippoLimits->mMaxLinkedPrims)); |
863 | childSetValue("max_link_count_phys", LLSD(gHippoLimits->mMaxPhysLinkedPrims)); | 863 | childSetValue("max_link_count_phys", LLSD(gHippoLimits->mMaxPhysLinkedPrims)); |
864 | childSetValue("max_phys_prim_scale", LLSD(gHippoLimits->mMaxPrimScale));//Todo:Fix | 864 | childSetValue("max_phys_prim_scale", LLSD(gHippoLimits->mMaxPrimScale));//Todo:Fix |
865 | childSetValue("max_prim_scale", LLSD(gHippoLimits->mMaxPrimScale)); | 865 | childSetValue("max_prim_scale", LLSD(gHippoLimits->mMaxPrimScale)); |
866 | childSetValue("min_prim_scale", LLSD(gHippoLimits->mMinPrimScale)); | 866 | childSetValue("min_prim_scale", LLSD(gHippoLimits->mMinPrimScale)); |
867 | childSetValue("render_water", LLSD(gHippoLimits->mRenderWater)); | 867 | childSetValue("render_water", LLSD(gHippoLimits->mRenderWater)); |
868 | childSetValue("show_tags", LLSD(gHippoLimits->mRenderName)); | 868 | childSetValue("show_tags", LLSD(gHippoLimits->mRenderName)); |
869 | childSetValue("max_groups", LLSD(gHippoLimits->mMaxAgentGroups)); | 869 | childSetValue("max_groups", LLSD(gHippoLimits->mMaxAgentGroups)); |
870 | childSetValue("allow_parcel_windlight", LLSD(gHippoLimits->mAllowParcelWindLight)); | 870 | childSetValue("allow_parcel_windlight", LLSD(gHippoLimits->mAllowParcelWindLight)); |
871 | childSetValue("enable_teen_mode", LLSD(gHippoLimits->mEnableTeenMode)); | 871 | childSetValue("enable_teen_mode", LLSD(gHippoLimits->mEnableTeenMode)); |
872 | childSetValue("enforce_max_build", LLSD(gHippoLimits->mEnforceMaxBuild)); | 872 | childSetValue("enforce_max_build", LLSD(gHippoLimits->mEnforceMaxBuild)); |
873 | 873 | ||
874 | setCtrlsEnabled(allow_modify); | 874 | setCtrlsEnabled(allow_modify); |
875 | 875 | ||
876 | return LLPanelRegionInfo::refreshFromRegion(region); | 876 | return LLPanelRegionInfo::refreshFromRegion(region); |
877 | } | 877 | } |
878 | 878 | ||
879 | BOOL LLPanelRegionOpenSettingsInfo::postBuild() | 879 | BOOL LLPanelRegionOpenSettingsInfo::postBuild() |
880 | { | 880 | { |
881 | // Enable the "Apply" button if something is changed. JC | 881 | // Enable the "Apply" button if something is changed. JC |
882 | initCtrl("draw_distance"); | 882 | initCtrl("draw_distance"); |
883 | initCtrl("force_draw_distance"); | 883 | initCtrl("force_draw_distance"); |
884 | initCtrl("max_drag_distance"); | 884 | initCtrl("max_drag_distance"); |
885 | initCtrl("max_prim_scale"); | 885 | initCtrl("max_prim_scale"); |
886 | initCtrl("min_prim_scale"); | 886 | initCtrl("min_prim_scale"); |
887 | initCtrl("max_phys_prim_scale"); | 887 | initCtrl("max_phys_prim_scale"); |
888 | initCtrl("max_hollow_size"); | 888 | initCtrl("max_hollow_size"); |
889 | initCtrl("min_hole_size"); | 889 | initCtrl("min_hole_size"); |
890 | initCtrl("max_link_count"); | 890 | initCtrl("max_link_count"); |
891 | initCtrl("max_link_count_phys"); | 891 | initCtrl("max_link_count_phys"); |
892 | initCtrl("max_inventory_items_transfer"); | 892 | initCtrl("max_inventory_items_transfer"); |
893 | initCtrl("max_groups"); | 893 | initCtrl("max_groups"); |
894 | initCtrl("render_water"); | 894 | initCtrl("render_water"); |
895 | initCtrl("allow_minimap"); | 895 | initCtrl("allow_minimap"); |
896 | initCtrl("allow_physical_prims"); | 896 | initCtrl("allow_physical_prims"); |
897 | initCtrl("enable_teen_mode"); | 897 | initCtrl("enable_teen_mode"); |
898 | initCtrl("show_tags"); | 898 | initCtrl("show_tags"); |
899 | initCtrl("allow_parcel_windlight"); | 899 | initCtrl("allow_parcel_windlight"); |
900 | 900 | ||
901 | initHelpBtn("force_draw_distance_help", "HelpForceDrawDistance"); | 901 | initHelpBtn("force_draw_distance_help", "HelpForceDrawDistance"); |
902 | initHelpBtn("max_inventory_items_transfer_help", "HelpMaxInventoryItemsTransfer"); | 902 | initHelpBtn("max_inventory_items_transfer_help", "HelpMaxInventoryItemsTransfer"); |
903 | initHelpBtn("max_groups_help", "HelpMaxGroups"); | 903 | initHelpBtn("max_groups_help", "HelpMaxGroups"); |
904 | initHelpBtn("render_water_help", "HelpRenderWater"); | 904 | initHelpBtn("render_water_help", "HelpRenderWater"); |
905 | initHelpBtn("allow_minimap_help", "HelpAllowMinimap"); | 905 | initHelpBtn("allow_minimap_help", "HelpAllowMinimap"); |
906 | initHelpBtn("allow_physical_prims_help", "HelpAllowPhysicalPrims"); | 906 | initHelpBtn("allow_physical_prims_help", "HelpAllowPhysicalPrims"); |
907 | initHelpBtn("enable_teen_mode_help", "HelpEnableTeenMode"); | 907 | initHelpBtn("enable_teen_mode_help", "HelpEnableTeenMode"); |
908 | initHelpBtn("show_tags_help", "HelpShowTags"); | 908 | initHelpBtn("show_tags_help", "HelpShowTags"); |
909 | initHelpBtn("allow_parcel_windlight_help", "HelpAllowParcelWindLight"); | 909 | initHelpBtn("allow_parcel_windlight_help", "HelpAllowParcelWindLight"); |
910 | 910 | ||
911 | childSetAction("apply_ors_btn", onClickOrs, this); | 911 | childSetAction("apply_ors_btn", onClickOrs, this); |
912 | 912 | ||
913 | refreshFromRegion(gAgent.getRegion()); | 913 | refreshFromRegion(gAgent.getRegion()); |
914 | 914 | ||
915 | return LLPanelRegionInfo::postBuild(); | 915 | return LLPanelRegionInfo::postBuild(); |
916 | } | 916 | } |
917 | 917 | ||
918 | // setregioninfo | 918 | // setregioninfo |
919 | // strings[0] = 'Y' - block terraform, 'N' - not | 919 | // strings[0] = 'Y' - block terraform, 'N' - not |
920 | // strings[1] = 'Y' - block fly, 'N' - not | 920 | // strings[1] = 'Y' - block fly, 'N' - not |
921 | // strings[2] = 'Y' - allow damage, 'N' - not | 921 | // strings[2] = 'Y' - allow damage, 'N' - not |
922 | // strings[3] = 'Y' - allow land sale, 'N' - not | 922 | // strings[3] = 'Y' - allow land sale, 'N' - not |
923 | // strings[4] = agent limit | 923 | // strings[4] = agent limit |
924 | // strings[5] = object bonus | 924 | // strings[5] = object bonus |
925 | // strings[6] = sim access (0 = unknown, 13 = PG, 21 = Mature, 42 = Adult) | 925 | // strings[6] = sim access (0 = unknown, 13 = PG, 21 = Mature, 42 = Adult) |
926 | // strings[7] = restrict pushobject | 926 | // strings[7] = restrict pushobject |
927 | // strings[8] = 'Y' - allow parcel subdivide, 'N' - not | 927 | // strings[8] = 'Y' - allow parcel subdivide, 'N' - not |
928 | // strings[9] = 'Y' - block parcel search, 'N' - allow | 928 | // strings[9] = 'Y' - block parcel search, 'N' - allow |
929 | void LLPanelRegionOpenSettingsInfo::onClickOrs(void* userdata) | 929 | void LLPanelRegionOpenSettingsInfo::onClickOrs(void* userdata) |
930 | { | 930 | { |
931 | LLPanelRegionOpenSettingsInfo* self; | 931 | LLPanelRegionOpenSettingsInfo* self; |
932 | self = (LLPanelRegionOpenSettingsInfo*)userdata; | 932 | self = (LLPanelRegionOpenSettingsInfo*)userdata; |
933 | 933 | ||
934 | llinfos << "LLPanelRegionOpenSettingsInfo::onClickOrs()" << llendl; | 934 | llinfos << "LLPanelRegionOpenSettingsInfo::onClickOrs()" << llendl; |
935 | 935 | ||
936 | LLSD body; | 936 | LLSD body; |
937 | std::string url = gAgent.getRegion()->getCapability("DispatchOpenRegionSettings"); | 937 | std::string url = gAgent.getRegion()->getCapability("DispatchOpenRegionSettings"); |
938 | if (!url.empty()) | 938 | if (!url.empty()) |
939 | { | 939 | { |
940 | body["draw_distance"] = self->childGetValue("draw_distance"); | 940 | body["draw_distance"] = self->childGetValue("draw_distance"); |
941 | body["force_draw_distance"] = self->childGetValue("force_draw_distance"); | 941 | body["force_draw_distance"] = self->childGetValue("force_draw_distance"); |
942 | body["allow_minimap"] = self->childGetValue("allow_minimap"); | 942 | body["allow_minimap"] = self->childGetValue("allow_minimap"); |
943 | body["allow_physical_prims"] = self->childGetValue("allow_physical_prims"); | 943 | body["allow_physical_prims"] = self->childGetValue("allow_physical_prims"); |
944 | body["max_drag_distance"] = self->childGetValue("max_drag_distance"); | 944 | body["max_drag_distance"] = self->childGetValue("max_drag_distance"); |
945 | body["min_hole_size"] = self->childGetValue("min_hole_size"); | 945 | body["min_hole_size"] = self->childGetValue("min_hole_size"); |
946 | body["max_hollow_size"] = self->childGetValue("max_hollow_size"); | 946 | body["max_hollow_size"] = self->childGetValue("max_hollow_size"); |
947 | body["max_inventory_items_transfer"] = self->childGetValue("max_inventory_items_transfer"); | 947 | body["max_inventory_items_transfer"] = self->childGetValue("max_inventory_items_transfer"); |
948 | body["max_link_count"] = self->childGetValue("max_link_count"); | 948 | body["max_link_count"] = self->childGetValue("max_link_count"); |
949 | body["max_link_count_phys"] = self->childGetValue("max_link_count_phys"); | 949 | body["max_link_count_phys"] = self->childGetValue("max_link_count_phys"); |
950 | body["max_phys_prim_scale"] = self->childGetValue("max_phys_prim_scale"); | 950 | body["max_phys_prim_scale"] = self->childGetValue("max_phys_prim_scale"); |
951 | body["max_prim_scale"] = self->childGetValue("max_prim_scale"); | 951 | body["max_prim_scale"] = self->childGetValue("max_prim_scale"); |
952 | body["min_prim_scale"] = self->childGetValue("min_prim_scale"); | 952 | body["min_prim_scale"] = self->childGetValue("min_prim_scale"); |
953 | body["render_water"] = self->childGetValue("render_water"); | 953 | body["render_water"] = self->childGetValue("render_water"); |
954 | body["show_tags"] = self->childGetValue("show_tags"); | 954 | body["show_tags"] = self->childGetValue("show_tags"); |
955 | body["max_groups"] = self->childGetValue("max_groups"); | 955 | body["max_groups"] = self->childGetValue("max_groups"); |
956 | body["allow_parcel_windlight"] = self->childGetValue("allow_parcel_windlight"); | 956 | body["allow_parcel_windlight"] = self->childGetValue("allow_parcel_windlight"); |
957 | body["enable_teen_mode"] = self->childGetValue("enable_teen_mode"); | 957 | body["enable_teen_mode"] = self->childGetValue("enable_teen_mode"); |
958 | body["enforce_max_build"] = self->childGetValue("enforce_max_build"); | 958 | body["enforce_max_build"] = self->childGetValue("enforce_max_build"); |
959 | 959 | ||
960 | LLHTTPClient::post(url, body, new LLHTTPClient::Responder()); | 960 | LLHTTPClient::post(url, body, new LLHTTPClient::Responder()); |
961 | } | 961 | } |
962 | } | 962 | } |
963 | 963 | ||
964 | ///////////////////////////////////////////////////////////////////////////// | 964 | ///////////////////////////////////////////////////////////////////////////// |
965 | // LLPanelRegionDebugInfo | 965 | // LLPanelRegionDebugInfo |
966 | ///////////////////////////////////////////////////////////////////////////// | 966 | ///////////////////////////////////////////////////////////////////////////// |
967 | BOOL LLPanelRegionDebugInfo::postBuild() | 967 | BOOL LLPanelRegionDebugInfo::postBuild() |
968 | { | 968 | { |
969 | LLPanelRegionInfo::postBuild(); | 969 | LLPanelRegionInfo::postBuild(); |
970 | initCtrl("disable_scripts_check"); | 970 | initCtrl("disable_scripts_check"); |
971 | initCtrl("disable_collisions_check"); | 971 | initCtrl("disable_collisions_check"); |
972 | initCtrl("disable_physics_check"); | 972 | initCtrl("disable_physics_check"); |
973 | 973 | ||
974 | initHelpBtn("disable_scripts_help", "HelpRegionDisableScripts"); | 974 | initHelpBtn("disable_scripts_help", "HelpRegionDisableScripts"); |
975 | initHelpBtn("disable_collisions_help", "HelpRegionDisableCollisions"); | 975 | initHelpBtn("disable_collisions_help", "HelpRegionDisableCollisions"); |
976 | initHelpBtn("disable_physics_help", "HelpRegionDisablePhysics"); | 976 | initHelpBtn("disable_physics_help", "HelpRegionDisablePhysics"); |
977 | initHelpBtn("top_colliders_help", "HelpRegionTopColliders"); | 977 | initHelpBtn("top_colliders_help", "HelpRegionTopColliders"); |
978 | initHelpBtn("top_scripts_help", "HelpRegionTopScripts"); | 978 | initHelpBtn("top_scripts_help", "HelpRegionTopScripts"); |
979 | initHelpBtn("restart_help", "HelpRegionRestart"); | 979 | initHelpBtn("restart_help", "HelpRegionRestart"); |
980 | initHelpBtn("minimum_agent_age_help", "HelpRegionMinimumAge"); | 980 | initHelpBtn("minimum_agent_age_help", "HelpRegionMinimumAge"); |
981 | 981 | ||
982 | 982 | ||
983 | childSetAction("choose_avatar_btn", onClickChooseAvatar, this); | 983 | childSetAction("choose_avatar_btn", onClickChooseAvatar, this); |
984 | childSetAction("return_btn", onClickReturn, this); | 984 | childSetAction("return_btn", onClickReturn, this); |
985 | childSetAction("top_colliders_btn", onClickTopColliders, this); | 985 | childSetAction("top_colliders_btn", onClickTopColliders, this); |
986 | childSetAction("top_scripts_btn", onClickTopScripts, this); | 986 | childSetAction("top_scripts_btn", onClickTopScripts, this); |
987 | childSetAction("restart_btn", onClickRestart, this); | 987 | childSetAction("restart_btn", onClickRestart, this); |
988 | childSetAction("cancel_restart_btn", onClickCancelRestart, this); | 988 | childSetAction("cancel_restart_btn", onClickCancelRestart, this); |
989 | 989 | ||
990 | return TRUE; | 990 | return TRUE; |
991 | } | 991 | } |
992 | 992 | ||
993 | // virtual | 993 | // virtual |
994 | bool LLPanelRegionDebugInfo::refreshFromRegion(LLViewerRegion* region) | 994 | bool LLPanelRegionDebugInfo::refreshFromRegion(LLViewerRegion* region) |
995 | { | 995 | { |
996 | BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate()); | 996 | BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate()); |
997 | setCtrlsEnabled(allow_modify); | 997 | setCtrlsEnabled(allow_modify); |
998 | childDisable("apply_btn"); | 998 | childDisable("apply_btn"); |
999 | childDisable("target_avatar_name"); | 999 | childDisable("target_avatar_name"); |
1000 | 1000 | ||
1001 | childSetEnabled("choose_avatar_btn", allow_modify); | 1001 | childSetEnabled("choose_avatar_btn", allow_modify); |
1002 | childSetEnabled("return_scripts", allow_modify && !mTargetAvatar.isNull()); | 1002 | childSetEnabled("return_scripts", allow_modify && !mTargetAvatar.isNull()); |
1003 | childSetEnabled("return_other_land", allow_modify && !mTargetAvatar.isNull()); | 1003 | childSetEnabled("return_other_land", allow_modify && !mTargetAvatar.isNull()); |
1004 | childSetEnabled("return_estate_wide", allow_modify && !mTargetAvatar.isNull()); | 1004 | childSetEnabled("return_estate_wide", allow_modify && !mTargetAvatar.isNull()); |
1005 | childSetEnabled("return_btn", allow_modify && !mTargetAvatar.isNull()); | 1005 | childSetEnabled("return_btn", allow_modify && !mTargetAvatar.isNull()); |
1006 | childSetEnabled("top_colliders_btn", allow_modify); | 1006 | childSetEnabled("top_colliders_btn", allow_modify); |
1007 | childSetEnabled("top_scripts_btn", allow_modify); | 1007 | childSetEnabled("top_scripts_btn", allow_modify); |
1008 | childSetEnabled("restart_btn", allow_modify); | 1008 | childSetEnabled("restart_btn", allow_modify); |
1009 | childSetEnabled("cancel_restart_btn", allow_modify); | 1009 | childSetEnabled("cancel_restart_btn", allow_modify); |
1010 | 1010 | ||
1011 | return LLPanelRegionInfo::refreshFromRegion(region); | 1011 | return LLPanelRegionInfo::refreshFromRegion(region); |
1012 | } | 1012 | } |
1013 | 1013 | ||
1014 | // virtual | 1014 | // virtual |
1015 | BOOL LLPanelRegionDebugInfo::sendUpdate() | 1015 | BOOL LLPanelRegionDebugInfo::sendUpdate() |
1016 | { | 1016 | { |
1017 | llinfos << "LLPanelRegionDebugInfo::sendUpdate" << llendl; | 1017 | llinfos << "LLPanelRegionDebugInfo::sendUpdate" << llendl; |
1018 | strings_t strings; | 1018 | strings_t strings; |
1019 | std::string buffer; | 1019 | std::string buffer; |
1020 | 1020 | ||
1021 | buffer = llformat("%s", (childGetValue("disable_scripts_check").asBoolean() ? "Y" : "N")); | 1021 | buffer = llformat("%s", (childGetValue("disable_scripts_check").asBoolean() ? "Y" : "N")); |
1022 | strings.push_back(buffer); | 1022 | strings.push_back(buffer); |
1023 | 1023 | ||
1024 | buffer = llformat("%s", (childGetValue("disable_collisions_check").asBoolean() ? "Y" : "N")); | 1024 | buffer = llformat("%s", (childGetValue("disable_collisions_check").asBoolean() ? "Y" : "N")); |
1025 | strings.push_back(buffer); | 1025 | strings.push_back(buffer); |
1026 | 1026 | ||
1027 | buffer = llformat("%s", (childGetValue("disable_physics_check").asBoolean() ? "Y" : "N")); | 1027 | buffer = llformat("%s", (childGetValue("disable_physics_check").asBoolean() ? "Y" : "N")); |
1028 | strings.push_back(buffer); | 1028 | strings.push_back(buffer); |
1029 | 1029 | ||
1030 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); | 1030 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); |
1031 | sendEstateOwnerMessage(gMessageSystem, "setregiondebug", invoice, strings); | 1031 | sendEstateOwnerMessage(gMessageSystem, "setregiondebug", invoice, strings); |
1032 | return TRUE; | 1032 | return TRUE; |
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | void LLPanelRegionDebugInfo::onClickChooseAvatar(void* data) | 1035 | void LLPanelRegionDebugInfo::onClickChooseAvatar(void* data) |
1036 | { | 1036 | { |
1037 | LLFloaterAvatarPicker::show(callbackAvatarID, data, FALSE, TRUE); | 1037 | LLFloaterAvatarPicker::show(callbackAvatarID, data, FALSE, TRUE); |
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | // static | 1040 | // static |
1041 | void LLPanelRegionDebugInfo::callbackAvatarID(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data) | 1041 | void LLPanelRegionDebugInfo::callbackAvatarID(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data) |
1042 | { | 1042 | { |
1043 | LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*) data; | 1043 | LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*) data; |
1044 | if (ids.empty() || names.empty()) return; | 1044 | if (ids.empty() || names.empty()) return; |
1045 | self->mTargetAvatar = ids[0]; | 1045 | self->mTargetAvatar = ids[0]; |
1046 | self->childSetValue("target_avatar_name", LLSD(names[0])); | 1046 | self->childSetValue("target_avatar_name", LLSD(names[0])); |
1047 | self->refreshFromRegion( gAgent.getRegion() ); | 1047 | self->refreshFromRegion( gAgent.getRegion() ); |
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | // static | 1050 | // static |
1051 | void LLPanelRegionDebugInfo::onClickReturn(void* data) | 1051 | void LLPanelRegionDebugInfo::onClickReturn(void* data) |
1052 | { | 1052 | { |
1053 | LLPanelRegionDebugInfo* panelp = (LLPanelRegionDebugInfo*) data; | 1053 | LLPanelRegionDebugInfo* panelp = (LLPanelRegionDebugInfo*) data; |
1054 | if (panelp->mTargetAvatar.isNull()) return; | 1054 | if (panelp->mTargetAvatar.isNull()) return; |
1055 | 1055 | ||
1056 | LLSD args; | 1056 | LLSD args; |
1057 | args["USER_NAME"] = panelp->childGetValue("target_avatar_name").asString(); | 1057 | args["USER_NAME"] = panelp->childGetValue("target_avatar_name").asString(); |
1058 | LLSD payload; | 1058 | LLSD payload; |
1059 | payload["avatar_id"] = panelp->mTargetAvatar; | 1059 | payload["avatar_id"] = panelp->mTargetAvatar; |
1060 | 1060 | ||
1061 | U32 flags = SWD_ALWAYS_RETURN_OBJECTS; | 1061 | U32 flags = SWD_ALWAYS_RETURN_OBJECTS; |
1062 | 1062 | ||
1063 | if (panelp->childGetValue("return_scripts").asBoolean()) | 1063 | if (panelp->childGetValue("return_scripts").asBoolean()) |
1064 | { | 1064 | { |
1065 | flags |= SWD_SCRIPTED_ONLY; | 1065 | flags |= SWD_SCRIPTED_ONLY; |
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | if (panelp->childGetValue("return_other_land").asBoolean()) | 1068 | if (panelp->childGetValue("return_other_land").asBoolean()) |
1069 | { | 1069 | { |
1070 | flags |= SWD_OTHERS_LAND_ONLY; | 1070 | flags |= SWD_OTHERS_LAND_ONLY; |
1071 | } | 1071 | } |
1072 | payload["flags"] = int(flags); | 1072 | payload["flags"] = int(flags); |
1073 | payload["return_estate_wide"] = panelp->childGetValue("return_estate_wide").asBoolean(); | 1073 | payload["return_estate_wide"] = panelp->childGetValue("return_estate_wide").asBoolean(); |
1074 | LLNotifications::instance().add("EstateObjectReturn", args, payload, | 1074 | LLNotifications::instance().add("EstateObjectReturn", args, payload, |
1075 | boost::bind(&LLPanelRegionDebugInfo::callbackReturn, panelp, _1, _2)); | 1075 | boost::bind(&LLPanelRegionDebugInfo::callbackReturn, panelp, _1, _2)); |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | bool LLPanelRegionDebugInfo::callbackReturn(const LLSD& notification, const LLSD& response) | 1078 | bool LLPanelRegionDebugInfo::callbackReturn(const LLSD& notification, const LLSD& response) |
1079 | { | 1079 | { |
1080 | S32 option = LLNotification::getSelectedOption(notification, response); | 1080 | S32 option = LLNotification::getSelectedOption(notification, response); |
1081 | if (option != 0) return false; | 1081 | if (option != 0) return false; |
1082 | 1082 | ||
1083 | LLUUID target_avatar = notification["payload"]["avatar_id"].asUUID(); | 1083 | LLUUID target_avatar = notification["payload"]["avatar_id"].asUUID(); |
1084 | if (!target_avatar.isNull()) | 1084 | if (!target_avatar.isNull()) |
1085 | { | 1085 | { |
1086 | U32 flags = notification["payload"]["flags"].asInteger(); | 1086 | U32 flags = notification["payload"]["flags"].asInteger(); |
1087 | bool return_estate_wide = notification["payload"]["return_estate_wide"]; | 1087 | bool return_estate_wide = notification["payload"]["return_estate_wide"]; |
1088 | if (return_estate_wide) | 1088 | if (return_estate_wide) |
1089 | { | 1089 | { |
1090 | // send as estate message - routed by spaceserver to all regions in estate | 1090 | // send as estate message - routed by spaceserver to all regions in estate |
1091 | strings_t strings; | 1091 | strings_t strings; |
1092 | strings.push_back(llformat("%d", flags)); | 1092 | strings.push_back(llformat("%d", flags)); |
1093 | strings.push_back(target_avatar.asString()); | 1093 | strings.push_back(target_avatar.asString()); |
1094 | 1094 | ||
1095 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); | 1095 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); |
1096 | 1096 | ||
1097 | sendEstateOwnerMessage(gMessageSystem, "estateobjectreturn", invoice, strings); | 1097 | sendEstateOwnerMessage(gMessageSystem, "estateobjectreturn", invoice, strings); |
1098 | } | 1098 | } |
1099 | else | 1099 | else |
1100 | { | 1100 | { |
1101 | // send to this simulator only | 1101 | // send to this simulator only |
1102 | send_sim_wide_deletes(target_avatar, flags); | 1102 | send_sim_wide_deletes(target_avatar, flags); |
1103 | } | 1103 | } |
1104 | } | 1104 | } |
1105 | return false; | 1105 | return false; |
1106 | } | 1106 | } |
1107 | 1107 | ||
1108 | 1108 | ||
1109 | // static | 1109 | // static |
1110 | void LLPanelRegionDebugInfo::onClickTopColliders(void* data) | 1110 | void LLPanelRegionDebugInfo::onClickTopColliders(void* data) |
1111 | { | 1111 | { |
1112 | LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data; | 1112 | LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data; |
1113 | strings_t strings; | 1113 | strings_t strings; |
1114 | strings.push_back("1"); // one physics step | 1114 | strings.push_back("1"); // one physics step |
1115 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); | 1115 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); |
1116 | LLFloaterTopObjects::show(); | 1116 | LLFloaterTopObjects::show(); |
1117 | LLFloaterTopObjects::clearList(); | 1117 | LLFloaterTopObjects::clearList(); |
1118 | self->sendEstateOwnerMessage(gMessageSystem, "colliders", invoice, strings); | 1118 | self->sendEstateOwnerMessage(gMessageSystem, "colliders", invoice, strings); |
1119 | } | 1119 | } |
1120 | 1120 | ||
1121 | // static | 1121 | // static |
1122 | void LLPanelRegionDebugInfo::onClickTopScripts(void* data) | 1122 | void LLPanelRegionDebugInfo::onClickTopScripts(void* data) |
1123 | { | 1123 | { |
1124 | LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data; | 1124 | LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data; |
1125 | strings_t strings; | 1125 | strings_t strings; |
1126 | strings.push_back("6"); // top 5 scripts | 1126 | strings.push_back("6"); // top 5 scripts |
1127 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); | 1127 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); |
1128 | LLFloaterTopObjects::show(); | 1128 | LLFloaterTopObjects::show(); |
1129 | LLFloaterTopObjects::clearList(); | 1129 | LLFloaterTopObjects::clearList(); |
1130 | self->sendEstateOwnerMessage(gMessageSystem, "scripts", invoice, strings); | 1130 | self->sendEstateOwnerMessage(gMessageSystem, "scripts", invoice, strings); |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | // static | 1133 | // static |
1134 | void LLPanelRegionDebugInfo::onClickRestart(void* data) | 1134 | void LLPanelRegionDebugInfo::onClickRestart(void* data) |
1135 | { | 1135 | { |
1136 | LLNotifications::instance().add("ConfirmRestart", LLSD(), LLSD(), | 1136 | LLNotifications::instance().add("ConfirmRestart", LLSD(), LLSD(), |
1137 | boost::bind(&LLPanelRegionDebugInfo::callbackRestart, (LLPanelRegionDebugInfo*)data, _1, _2)); | 1137 | boost::bind(&LLPanelRegionDebugInfo::callbackRestart, (LLPanelRegionDebugInfo*)data, _1, _2)); |
1138 | } | 1138 | } |
1139 | 1139 | ||
1140 | bool LLPanelRegionDebugInfo::callbackRestart(const LLSD& notification, const LLSD& response) | 1140 | bool LLPanelRegionDebugInfo::callbackRestart(const LLSD& notification, const LLSD& response) |
1141 | { | 1141 | { |
1142 | S32 option = LLNotification::getSelectedOption(notification, response); | 1142 | S32 option = LLNotification::getSelectedOption(notification, response); |
1143 | if (option != 0) return false; | 1143 | if (option != 0) return false; |
1144 | 1144 | ||
1145 | strings_t strings; | 1145 | strings_t strings; |
1146 | strings.push_back("120"); | 1146 | strings.push_back("120"); |
1147 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); | 1147 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); |
1148 | sendEstateOwnerMessage(gMessageSystem, "restart", invoice, strings); | 1148 | sendEstateOwnerMessage(gMessageSystem, "restart", invoice, strings); |
1149 | return false; | 1149 | return false; |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | // static | 1152 | // static |
1153 | void LLPanelRegionDebugInfo::onClickCancelRestart(void* data) | 1153 | void LLPanelRegionDebugInfo::onClickCancelRestart(void* data) |
1154 | { | 1154 | { |
1155 | LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data; | 1155 | LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data; |
1156 | strings_t strings; | 1156 | strings_t strings; |
1157 | strings.push_back("-1"); | 1157 | strings.push_back("-1"); |
1158 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); | 1158 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); |
1159 | self->sendEstateOwnerMessage(gMessageSystem, "restart", invoice, strings); | 1159 | self->sendEstateOwnerMessage(gMessageSystem, "restart", invoice, strings); |
1160 | } | 1160 | } |
1161 | 1161 | ||
1162 | 1162 | ||
1163 | ///////////////////////////////////////////////////////////////////////////// | 1163 | ///////////////////////////////////////////////////////////////////////////// |
1164 | // LLPanelRegionTextureInfo | 1164 | // LLPanelRegionTextureInfo |
1165 | // | 1165 | // |
1166 | LLPanelRegionTextureInfo::LLPanelRegionTextureInfo() : LLPanelRegionInfo() | 1166 | LLPanelRegionTextureInfo::LLPanelRegionTextureInfo() : LLPanelRegionInfo() |
1167 | { | 1167 | { |
1168 | // nothing. | 1168 | // nothing. |
1169 | } | 1169 | } |
1170 | 1170 | ||
1171 | bool LLPanelRegionTextureInfo::refreshFromRegion(LLViewerRegion* region) | 1171 | bool LLPanelRegionTextureInfo::refreshFromRegion(LLViewerRegion* region) |
1172 | { | 1172 | { |
1173 | BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate()); | 1173 | BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate()); |
1174 | setCtrlsEnabled(allow_modify); | 1174 | setCtrlsEnabled(allow_modify); |
1175 | childDisable("apply_btn"); | 1175 | childDisable("apply_btn"); |
1176 | 1176 | ||
1177 | if (region) | 1177 | if (region) |
1178 | { | 1178 | { |
1179 | childSetValue("region_text", LLSD(region->getName())); | 1179 | childSetValue("region_text", LLSD(region->getName())); |
1180 | } | 1180 | } |
1181 | else | 1181 | else |
1182 | { | 1182 | { |
1183 | childSetValue("region_text", LLSD("")); | 1183 | childSetValue("region_text", LLSD("")); |
1184 | } | 1184 | } |
1185 | 1185 | ||
1186 | if (!region) return LLPanelRegionInfo::refreshFromRegion(region); | 1186 | if (!region) return LLPanelRegionInfo::refreshFromRegion(region); |
1187 | 1187 | ||
1188 | LLVLComposition* compp = region->getComposition(); | 1188 | LLVLComposition* compp = region->getComposition(); |
1189 | LLTextureCtrl* texture_ctrl; | 1189 | LLTextureCtrl* texture_ctrl; |
1190 | std::string buffer; | 1190 | std::string buffer; |
1191 | for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) | 1191 | for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) |
1192 | { | 1192 | { |
1193 | buffer = llformat("texture_detail_%d", i); | 1193 | buffer = llformat("texture_detail_%d", i); |
1194 | texture_ctrl = getChild<LLTextureCtrl>(buffer); | 1194 | texture_ctrl = getChild<LLTextureCtrl>(buffer); |
1195 | if(texture_ctrl) | 1195 | if(texture_ctrl) |
1196 | { | 1196 | { |
1197 | lldebugs << "Detail Texture " << i << ": " | 1197 | lldebugs << "Detail Texture " << i << ": " |
1198 | << compp->getDetailTextureID(i) << llendl; | 1198 | << compp->getDetailTextureID(i) << llendl; |
1199 | LLUUID tmp_id(compp->getDetailTextureID(i)); | 1199 | LLUUID tmp_id(compp->getDetailTextureID(i)); |
1200 | texture_ctrl->setImageAssetID(tmp_id); | 1200 | texture_ctrl->setImageAssetID(tmp_id); |
1201 | } | 1201 | } |
1202 | } | 1202 | } |
1203 | 1203 | ||
1204 | for(S32 i = 0; i < CORNER_COUNT; ++i) | 1204 | for(S32 i = 0; i < CORNER_COUNT; ++i) |
1205 | { | 1205 | { |
1206 | buffer = llformat("height_start_spin_%d", i); | 1206 | buffer = llformat("height_start_spin_%d", i); |
1207 | childSetValue(buffer, LLSD(compp->getStartHeight(i))); | 1207 | childSetValue(buffer, LLSD(compp->getStartHeight(i))); |
1208 | buffer = llformat("height_range_spin_%d", i); | 1208 | buffer = llformat("height_range_spin_%d", i); |
1209 | childSetValue(buffer, LLSD(compp->getHeightRange(i))); | 1209 | childSetValue(buffer, LLSD(compp->getHeightRange(i))); |
1210 | } | 1210 | } |
1211 | 1211 | ||
1212 | // Call the parent for common book-keeping | 1212 | // Call the parent for common book-keeping |
1213 | return LLPanelRegionInfo::refreshFromRegion(region); | 1213 | return LLPanelRegionInfo::refreshFromRegion(region); |
1214 | } | 1214 | } |
1215 | 1215 | ||
1216 | 1216 | ||
1217 | BOOL LLPanelRegionTextureInfo::postBuild() | 1217 | BOOL LLPanelRegionTextureInfo::postBuild() |
1218 | { | 1218 | { |
1219 | LLPanelRegionInfo::postBuild(); | 1219 | LLPanelRegionInfo::postBuild(); |
1220 | std::string buffer; | 1220 | std::string buffer; |
1221 | for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) | 1221 | for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) |
1222 | { | 1222 | { |
1223 | buffer = llformat("texture_detail_%d", i); | 1223 | buffer = llformat("texture_detail_%d", i); |
1224 | initCtrl(buffer); | 1224 | initCtrl(buffer); |
1225 | } | 1225 | } |
1226 | 1226 | ||
1227 | for(S32 i = 0; i < CORNER_COUNT; ++i) | 1227 | for(S32 i = 0; i < CORNER_COUNT; ++i) |
1228 | { | 1228 | { |
1229 | buffer = llformat("height_start_spin_%d", i); | 1229 | buffer = llformat("height_start_spin_%d", i); |
1230 | initCtrl(buffer); | 1230 | initCtrl(buffer); |
1231 | buffer = llformat("height_range_spin_%d", i); | 1231 | buffer = llformat("height_range_spin_%d", i); |
1232 | initCtrl(buffer); | 1232 | initCtrl(buffer); |
1233 | } | 1233 | } |
1234 | 1234 | ||
1235 | // LLButton* btn = new LLButton("dump", LLRect(0, 20, 100, 0), "", onClickDump, this); | 1235 | // LLButton* btn = new LLButton("dump", LLRect(0, 20, 100, 0), "", onClickDump, this); |
1236 | // btn->setFollows(FOLLOWS_TOP|FOLLOWS_LEFT); | 1236 | // btn->setFollows(FOLLOWS_TOP|FOLLOWS_LEFT); |
1237 | // addChild(btn); | 1237 | // addChild(btn); |
1238 | 1238 | ||
1239 | return LLPanelRegionInfo::postBuild(); | 1239 | return LLPanelRegionInfo::postBuild(); |
1240 | } | 1240 | } |
1241 | 1241 | ||
1242 | BOOL LLPanelRegionTextureInfo::sendUpdate() | 1242 | BOOL LLPanelRegionTextureInfo::sendUpdate() |
1243 | { | 1243 | { |
1244 | llinfos << "LLPanelRegionTextureInfo::sendUpdate()" << llendl; | 1244 | llinfos << "LLPanelRegionTextureInfo::sendUpdate()" << llendl; |
1245 | 1245 | ||
1246 | // Make sure user hasn't chosen wacky textures. | 1246 | // Make sure user hasn't chosen wacky textures. |
1247 | //if (!validateTextureSizes()) | 1247 | //if (!validateTextureSizes()) |
1248 | //{ | 1248 | //{ |
1249 | // return FALSE; | 1249 | // return FALSE; |
1250 | //} | 1250 | //} |
1251 | 1251 | ||
1252 | LLTextureCtrl* texture_ctrl; | 1252 | LLTextureCtrl* texture_ctrl; |
1253 | std::string buffer; | 1253 | std::string buffer; |
1254 | std::string id_str; | 1254 | std::string id_str; |
1255 | LLMessageSystem* msg = gMessageSystem; | 1255 | LLMessageSystem* msg = gMessageSystem; |
1256 | strings_t strings; | 1256 | strings_t strings; |
1257 | 1257 | ||
1258 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); | 1258 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); |
1259 | 1259 | ||
1260 | for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) | 1260 | for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) |
1261 | { | 1261 | { |
1262 | buffer = llformat("texture_detail_%d", i); | 1262 | buffer = llformat("texture_detail_%d", i); |
1263 | texture_ctrl = getChild<LLTextureCtrl>(buffer); | 1263 | texture_ctrl = getChild<LLTextureCtrl>(buffer); |
1264 | if(texture_ctrl) | 1264 | if(texture_ctrl) |
1265 | { | 1265 | { |
1266 | LLUUID tmp_id(texture_ctrl->getImageAssetID()); | 1266 | LLUUID tmp_id(texture_ctrl->getImageAssetID()); |
1267 | tmp_id.toString(id_str); | 1267 | tmp_id.toString(id_str); |
1268 | buffer = llformat("%d %s", i, id_str.c_str()); | 1268 | buffer = llformat("%d %s", i, id_str.c_str()); |
1269 | strings.push_back(buffer); | 1269 | strings.push_back(buffer); |
1270 | } | 1270 | } |
1271 | } | 1271 | } |
1272 | sendEstateOwnerMessage(msg, "texturedetail", invoice, strings); | 1272 | sendEstateOwnerMessage(msg, "texturedetail", invoice, strings); |
1273 | strings.clear(); | 1273 | strings.clear(); |
1274 | for(S32 i = 0; i < CORNER_COUNT; ++i) | 1274 | for(S32 i = 0; i < CORNER_COUNT; ++i) |
1275 | { | 1275 | { |
1276 | buffer = llformat("height_start_spin_%d", i); | 1276 | buffer = llformat("height_start_spin_%d", i); |
1277 | std::string buffer2 = llformat("height_range_spin_%d", i); | 1277 | std::string buffer2 = llformat("height_range_spin_%d", i); |
1278 | std::string buffer3 = llformat("%d %f %f", i, (F32)childGetValue(buffer).asReal(), (F32)childGetValue(buffer2).asReal()); | 1278 | std::string buffer3 = llformat("%d %f %f", i, (F32)childGetValue(buffer).asReal(), (F32)childGetValue(buffer2).asReal()); |
1279 | strings.push_back(buffer3); | 1279 | strings.push_back(buffer3); |
1280 | } | 1280 | } |
1281 | sendEstateOwnerMessage(msg, "textureheights", invoice, strings); | 1281 | sendEstateOwnerMessage(msg, "textureheights", invoice, strings); |
1282 | strings.clear(); | 1282 | strings.clear(); |
1283 | sendEstateOwnerMessage(msg, "texturecommit", invoice, strings); | 1283 | sendEstateOwnerMessage(msg, "texturecommit", invoice, strings); |
1284 | return TRUE; | 1284 | return TRUE; |
1285 | } | 1285 | } |
1286 | 1286 | ||
1287 | BOOL LLPanelRegionTextureInfo::validateTextureSizes() | 1287 | BOOL LLPanelRegionTextureInfo::validateTextureSizes() |
1288 | { | 1288 | { |
1289 | for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) | 1289 | for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) |
1290 | { | 1290 | { |
1291 | std::string buffer; | 1291 | std::string buffer; |
1292 | buffer = llformat("texture_detail_%d", i); | 1292 | buffer = llformat("texture_detail_%d", i); |
1293 | LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>(buffer); | 1293 | LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>(buffer); |
1294 | if (!texture_ctrl) continue; | 1294 | if (!texture_ctrl) continue; |
1295 | 1295 | ||
1296 | LLUUID image_asset_id = texture_ctrl->getImageAssetID(); | 1296 | LLUUID image_asset_id = texture_ctrl->getImageAssetID(); |
1297 | LLViewerImage* img = gImageList.getImage(image_asset_id); | 1297 | LLViewerImage* img = gImageList.getImage(image_asset_id); |
1298 | S32 components = img->getComponents(); | 1298 | S32 components = img->getComponents(); |
1299 | // Must ask for highest resolution version's width. JC | 1299 | // Must ask for highest resolution version's width. JC |
1300 | S32 width = img->getWidth(0); | 1300 | S32 width = img->getWidth(0); |
1301 | S32 height = img->getHeight(0); | 1301 | S32 height = img->getHeight(0); |
1302 | 1302 | ||
1303 | //llinfos << "texture detail " << i << " is " << width << "x" << height << "x" << components << llendl; | 1303 | //llinfos << "texture detail " << i << " is " << width << "x" << height << "x" << components << llendl; |
1304 | 1304 | ||
1305 | if (components != 3) | 1305 | if (components != 3) |
1306 | { | 1306 | { |
1307 | LLSD args; | 1307 | LLSD args; |
1308 | args["TEXTURE_NUM"] = i+1; | 1308 | args["TEXTURE_NUM"] = i+1; |
1309 | args["TEXTURE_BIT_DEPTH"] = llformat("%d",components * 8); | 1309 | args["TEXTURE_BIT_DEPTH"] = llformat("%d",components * 8); |
1310 | LLNotifications::instance().add("InvalidTerrainBitDepth", args); | 1310 | LLNotifications::instance().add("InvalidTerrainBitDepth", args); |
1311 | return FALSE; | 1311 | return FALSE; |
1312 | } | 1312 | } |
1313 | 1313 | ||
1314 | if (width > 512 || height > 512) | 1314 | if (width > 512 || height > 512) |
1315 | { | 1315 | { |
1316 | 1316 | ||
1317 | LLSD args; | 1317 | LLSD args; |
1318 | args["TEXTURE_NUM"] = i+1; | 1318 | args["TEXTURE_NUM"] = i+1; |
1319 | args["TEXTURE_SIZE_X"] = width; | 1319 | args["TEXTURE_SIZE_X"] = width; |
1320 | args["TEXTURE_SIZE_Y"] = height; | 1320 | args["TEXTURE_SIZE_Y"] = height; |
1321 | LLNotifications::instance().add("InvalidTerrainSize", args); | 1321 | LLNotifications::instance().add("InvalidTerrainSize", args); |
1322 | return FALSE; | 1322 | return FALSE; |
1323 | 1323 | ||
1324 | } | 1324 | } |
1325 | } | 1325 | } |
1326 | 1326 | ||
1327 | return TRUE; | 1327 | return TRUE; |
1328 | } | 1328 | } |
1329 | 1329 | ||
1330 | 1330 | ||
1331 | // static | 1331 | // static |
1332 | void LLPanelRegionTextureInfo::onClickDump(void* data) | 1332 | void LLPanelRegionTextureInfo::onClickDump(void* data) |
1333 | { | 1333 | { |
1334 | llinfos << "LLPanelRegionTextureInfo::onClickDump()" << llendl; | 1334 | llinfos << "LLPanelRegionTextureInfo::onClickDump()" << llendl; |
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | 1337 | ||
1338 | ///////////////////////////////////////////////////////////////////////////// | 1338 | ///////////////////////////////////////////////////////////////////////////// |
1339 | // LLPanelRegionTerrainInfo | 1339 | // LLPanelRegionTerrainInfo |
1340 | ///////////////////////////////////////////////////////////////////////////// | 1340 | ///////////////////////////////////////////////////////////////////////////// |
1341 | BOOL LLPanelRegionTerrainInfo::postBuild() | 1341 | BOOL LLPanelRegionTerrainInfo::postBuild() |
1342 | { | 1342 | { |
1343 | LLPanelRegionInfo::postBuild(); | 1343 | LLPanelRegionInfo::postBuild(); |
1344 | 1344 | ||
1345 | initHelpBtn("water_height_help", "HelpRegionWaterHeight"); | 1345 | initHelpBtn("water_height_help", "HelpRegionWaterHeight"); |
1346 | initHelpBtn("terrain_raise_help", "HelpRegionTerrainRaise"); | 1346 | initHelpBtn("terrain_raise_help", "HelpRegionTerrainRaise"); |
1347 | initHelpBtn("terrain_lower_help", "HelpRegionTerrainLower"); | 1347 | initHelpBtn("terrain_lower_help", "HelpRegionTerrainLower"); |
1348 | initHelpBtn("upload_raw_help", "HelpRegionUploadRaw"); | 1348 | initHelpBtn("upload_raw_help", "HelpRegionUploadRaw"); |
1349 | initHelpBtn("download_raw_help", "HelpRegionDownloadRaw"); | 1349 | initHelpBtn("download_raw_help", "HelpRegionDownloadRaw"); |
1350 | initHelpBtn("use_estate_sun_help", "HelpRegionUseEstateSun"); | 1350 | initHelpBtn("use_estate_sun_help", "HelpRegionUseEstateSun"); |
1351 | initHelpBtn("fixed_sun_help", "HelpRegionFixedSun"); | 1351 | initHelpBtn("fixed_sun_help", "HelpRegionFixedSun"); |
1352 | initHelpBtn("bake_terrain_help", "HelpRegionBakeTerrain"); | 1352 | initHelpBtn("bake_terrain_help", "HelpRegionBakeTerrain"); |
1353 | 1353 | ||
1354 | initCtrl("water_height_spin"); | 1354 | initCtrl("water_height_spin"); |
1355 | initCtrl("terrain_raise_spin"); | 1355 | initCtrl("terrain_raise_spin"); |
1356 | initCtrl("terrain_lower_spin"); | 1356 | initCtrl("terrain_lower_spin"); |
1357 | 1357 | ||
1358 | initCtrl("fixed_sun_check"); | 1358 | initCtrl("fixed_sun_check"); |
1359 | childSetCommitCallback("fixed_sun_check", onChangeFixedSun, this); | 1359 | childSetCommitCallback("fixed_sun_check", onChangeFixedSun, this); |
1360 | childSetCommitCallback("use_estate_sun_check", onChangeUseEstateTime, this); | 1360 | childSetCommitCallback("use_estate_sun_check", onChangeUseEstateTime, this); |
1361 | childSetCommitCallback("sun_hour_slider", onChangeSunHour, this); | 1361 | childSetCommitCallback("sun_hour_slider", onChangeSunHour, this); |
1362 | 1362 | ||
1363 | childSetAction("download_raw_btn", onClickDownloadRaw, this); | 1363 | childSetAction("download_raw_btn", onClickDownloadRaw, this); |
1364 | childSetAction("upload_raw_btn", onClickUploadRaw, this); | 1364 | childSetAction("upload_raw_btn", onClickUploadRaw, this); |
1365 | childSetAction("bake_terrain_btn", onClickBakeTerrain, this); | 1365 | childSetAction("bake_terrain_btn", onClickBakeTerrain, this); |
1366 | 1366 | ||
1367 | return TRUE; | 1367 | return TRUE; |
1368 | } | 1368 | } |
1369 | 1369 | ||
1370 | // virtual | 1370 | // virtual |
1371 | bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) | 1371 | bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) |
1372 | { | 1372 | { |
1373 | llinfos << "LLPanelRegionTerrainInfo::refreshFromRegion" << llendl; | 1373 | llinfos << "LLPanelRegionTerrainInfo::refreshFromRegion" << llendl; |
1374 | 1374 | ||
1375 | BOOL owner_or_god = gAgent.isGodlike() | 1375 | BOOL owner_or_god = gAgent.isGodlike() |
1376 | || (region && (region->getOwner() == gAgent.getID())); | 1376 | || (region && (region->getOwner() == gAgent.getID())); |
1377 | BOOL owner_or_god_or_manager = owner_or_god | 1377 | BOOL owner_or_god_or_manager = owner_or_god |
1378 | || (region && region->isEstateManager()); | 1378 | || (region && region->isEstateManager()); |
1379 | setCtrlsEnabled(owner_or_god_or_manager); | 1379 | setCtrlsEnabled(owner_or_god_or_manager); |
1380 | childDisable("apply_btn"); | 1380 | childDisable("apply_btn"); |
1381 | 1381 | ||
1382 | childSetEnabled("download_raw_btn", owner_or_god); | 1382 | childSetEnabled("download_raw_btn", owner_or_god); |
1383 | childSetEnabled("upload_raw_btn", owner_or_god); | 1383 | childSetEnabled("upload_raw_btn", owner_or_god); |
1384 | childSetEnabled("bake_terrain_btn", owner_or_god); | 1384 | childSetEnabled("bake_terrain_btn", owner_or_god); |
1385 | 1385 | ||
1386 | return LLPanelRegionInfo::refreshFromRegion(region); | 1386 | return LLPanelRegionInfo::refreshFromRegion(region); |
1387 | } | 1387 | } |
1388 | 1388 | ||
1389 | // virtual | 1389 | // virtual |
1390 | BOOL LLPanelRegionTerrainInfo::sendUpdate() | 1390 | BOOL LLPanelRegionTerrainInfo::sendUpdate() |
1391 | { | 1391 | { |
1392 | llinfos << "LLPanelRegionTerrainInfo::sendUpdate" << llendl; | 1392 | llinfos << "LLPanelRegionTerrainInfo::sendUpdate" << llendl; |
1393 | std::string buffer; | 1393 | std::string buffer; |
1394 | strings_t strings; | 1394 | strings_t strings; |
1395 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); | 1395 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); |
1396 | 1396 | ||
1397 | buffer = llformat("%f", (F32)childGetValue("water_height_spin").asReal()); | 1397 | buffer = llformat("%f", (F32)childGetValue("water_height_spin").asReal()); |
1398 | strings.push_back(buffer); | 1398 | strings.push_back(buffer); |
1399 | buffer = llformat("%f", (F32)childGetValue("terrain_raise_spin").asReal()); | 1399 | buffer = llformat("%f", (F32)childGetValue("terrain_raise_spin").asReal()); |
1400 | strings.push_back(buffer); | 1400 | strings.push_back(buffer); |
1401 | buffer = llformat("%f", (F32)childGetValue("terrain_lower_spin").asReal()); | 1401 | buffer = llformat("%f", (F32)childGetValue("terrain_lower_spin").asReal()); |
1402 | strings.push_back(buffer); | 1402 | strings.push_back(buffer); |
1403 | buffer = llformat("%s", (childGetValue("use_estate_sun_check").asBoolean() ? "Y" : "N")); | 1403 | buffer = llformat("%s", (childGetValue("use_estate_sun_check").asBoolean() ? "Y" : "N")); |
1404 | strings.push_back(buffer); | 1404 | strings.push_back(buffer); |
1405 | buffer = llformat("%s", (childGetValue("fixed_sun_check").asBoolean() ? "Y" : "N")); | 1405 | buffer = llformat("%s", (childGetValue("fixed_sun_check").asBoolean() ? "Y" : "N")); |
1406 | strings.push_back(buffer); | 1406 | strings.push_back(buffer); |
1407 | buffer = llformat("%f", (F32)childGetValue("sun_hour_slider").asReal() ); | 1407 | buffer = llformat("%f", (F32)childGetValue("sun_hour_slider").asReal() ); |
1408 | strings.push_back(buffer); | 1408 | strings.push_back(buffer); |
1409 | 1409 | ||
1410 | // Grab estate information in case the user decided to set the | 1410 | // Grab estate information in case the user decided to set the |
1411 | // region back to estate time. JC | 1411 | // region back to estate time. JC |
1412 | LLFloaterRegionInfo* floater = LLFloaterRegionInfo::getInstance(); | 1412 | LLFloaterRegionInfo* floater = LLFloaterRegionInfo::getInstance(); |
1413 | if (!floater) return true; | 1413 | if (!floater) return true; |
1414 | 1414 | ||
1415 | LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels"); | 1415 | LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels"); |
1416 | if (!tab) return true; | 1416 | if (!tab) return true; |
1417 | 1417 | ||
1418 | LLPanelEstateInfo* panel = (LLPanelEstateInfo*)tab->getChild<LLPanel>("Estate"); | 1418 | LLPanelEstateInfo* panel = (LLPanelEstateInfo*)tab->getChild<LLPanel>("Estate"); |
1419 | if (!panel) return true; | 1419 | if (!panel) return true; |
1420 | 1420 | ||
1421 | BOOL estate_global_time = panel->getGlobalTime(); | 1421 | BOOL estate_global_time = panel->getGlobalTime(); |
1422 | BOOL estate_fixed_sun = panel->getFixedSun(); | 1422 | BOOL estate_fixed_sun = panel->getFixedSun(); |
1423 | F32 estate_sun_hour; | 1423 | F32 estate_sun_hour; |
1424 | if (estate_global_time) | 1424 | if (estate_global_time) |
1425 | { | 1425 | { |
1426 | estate_sun_hour = 0.f; | 1426 | estate_sun_hour = 0.f; |
1427 | } | 1427 | } |
1428 | else | 1428 | else |
1429 | { | 1429 | { |
1430 | estate_sun_hour = panel->getSunHour(); | 1430 | estate_sun_hour = panel->getSunHour(); |
1431 | } | 1431 | } |
1432 | 1432 | ||
1433 | buffer = llformat("%s", (estate_global_time ? "Y" : "N") ); | 1433 | buffer = llformat("%s", (estate_global_time ? "Y" : "N") ); |
1434 | strings.push_back(buffer); | 1434 | strings.push_back(buffer); |
1435 | buffer = llformat("%s", (estate_fixed_sun ? "Y" : "N") ); | 1435 | buffer = llformat("%s", (estate_fixed_sun ? "Y" : "N") ); |
1436 | strings.push_back(buffer); | 1436 | strings.push_back(buffer); |
1437 | buffer = llformat("%f", estate_sun_hour); | 1437 | buffer = llformat("%f", estate_sun_hour); |
1438 | strings.push_back(buffer); | 1438 | strings.push_back(buffer); |
1439 | 1439 | ||
1440 | sendEstateOwnerMessage(gMessageSystem, "setregionterrain", invoice, strings); | 1440 | sendEstateOwnerMessage(gMessageSystem, "setregionterrain", invoice, strings); |
1441 | return TRUE; | 1441 | return TRUE; |
1442 | } | 1442 | } |
1443 | 1443 | ||
1444 | // static | 1444 | // static |
1445 | void LLPanelRegionTerrainInfo::onChangeUseEstateTime(LLUICtrl* ctrl, void* user_data) | 1445 | void LLPanelRegionTerrainInfo::onChangeUseEstateTime(LLUICtrl* ctrl, void* user_data) |
1446 | { | 1446 | { |
1447 | LLPanelRegionTerrainInfo* panel = (LLPanelRegionTerrainInfo*) user_data; | 1447 | LLPanelRegionTerrainInfo* panel = (LLPanelRegionTerrainInfo*) user_data; |
1448 | if (!panel) return; | 1448 | if (!panel) return; |
1449 | BOOL use_estate_sun = panel->childGetValue("use_estate_sun_check").asBoolean(); | 1449 | BOOL use_estate_sun = panel->childGetValue("use_estate_sun_check").asBoolean(); |
1450 | panel->childSetEnabled("fixed_sun_check", !use_estate_sun); | 1450 | panel->childSetEnabled("fixed_sun_check", !use_estate_sun); |
1451 | panel->childSetEnabled("sun_hour_slider", !use_estate_sun); | 1451 | panel->childSetEnabled("sun_hour_slider", !use_estate_sun); |
1452 | if (use_estate_sun) | 1452 | if (use_estate_sun) |
1453 | { | 1453 | { |
1454 | panel->childSetValue("fixed_sun_check", LLSD(FALSE)); | 1454 | panel->childSetValue("fixed_sun_check", LLSD(FALSE)); |
1455 | panel->childSetValue("sun_hour_slider", LLSD(0.f)); | 1455 | panel->childSetValue("sun_hour_slider", LLSD(0.f)); |
1456 | } | 1456 | } |
1457 | panel->childEnable("apply_btn"); | 1457 | panel->childEnable("apply_btn"); |
1458 | } | 1458 | } |
1459 | 1459 | ||
1460 | // static | 1460 | // static |
1461 | void LLPanelRegionTerrainInfo::onChangeFixedSun(LLUICtrl* ctrl, void* user_data) | 1461 | void LLPanelRegionTerrainInfo::onChangeFixedSun(LLUICtrl* ctrl, void* user_data) |
1462 | { | 1462 | { |
1463 | LLPanelRegionTerrainInfo* panel = (LLPanelRegionTerrainInfo*) user_data; | 1463 | LLPanelRegionTerrainInfo* panel = (LLPanelRegionTerrainInfo*) user_data; |
1464 | if (!panel) return; | 1464 | if (!panel) return; |
1465 | // Just enable the apply button. We let the sun-hour slider be enabled | 1465 | // Just enable the apply button. We let the sun-hour slider be enabled |
1466 | // for both fixed-sun and non-fixed-sun. JC | 1466 | // for both fixed-sun and non-fixed-sun. JC |
1467 | panel->childEnable("apply_btn"); | 1467 | panel->childEnable("apply_btn"); |
1468 | } | 1468 | } |
1469 | 1469 | ||
1470 | // static | 1470 | // static |
1471 | void LLPanelRegionTerrainInfo::onChangeSunHour(LLUICtrl* ctrl, void*) | 1471 | void LLPanelRegionTerrainInfo::onChangeSunHour(LLUICtrl* ctrl, void*) |
1472 | { | 1472 | { |
1473 | // can't use userdata to get panel, slider uses it internally | 1473 | // can't use userdata to get panel, slider uses it internally |
1474 | LLPanelRegionTerrainInfo* panel = (LLPanelRegionTerrainInfo*) ctrl->getParent(); | 1474 | LLPanelRegionTerrainInfo* panel = (LLPanelRegionTerrainInfo*) ctrl->getParent(); |
1475 | if (!panel) return; | 1475 | if (!panel) return; |
1476 | panel->childEnable("apply_btn"); | 1476 | panel->childEnable("apply_btn"); |
1477 | } | 1477 | } |
1478 | 1478 | ||
1479 | // static | 1479 | // static |
1480 | void LLPanelRegionTerrainInfo::onClickDownloadRaw(void* data) | 1480 | void LLPanelRegionTerrainInfo::onClickDownloadRaw(void* data) |
1481 | { | 1481 | { |
1482 | LLFilePicker& picker = LLFilePicker::instance(); | 1482 | LLFilePicker& picker = LLFilePicker::instance(); |
1483 | if (!picker.getSaveFile(LLFilePicker::FFSAVE_RAW, "terrain.raw")) | 1483 | if (!picker.getSaveFile(LLFilePicker::FFSAVE_RAW, "terrain.raw")) |
1484 | { | 1484 | { |
1485 | llwarns << "No file" << llendl; | 1485 | llwarns << "No file" << llendl; |
1486 | return; | 1486 | return; |
1487 | } | 1487 | } |
1488 | std::string filepath = picker.getFirstFile(); | 1488 | std::string filepath = picker.getFirstFile(); |
1489 | gXferManager->expectFileForRequest(filepath); | 1489 | gXferManager->expectFileForRequest(filepath); |
1490 | 1490 | ||
1491 | LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data; | 1491 | LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data; |
1492 | strings_t strings; | 1492 | strings_t strings; |
1493 | strings.push_back("download filename"); | 1493 | strings.push_back("download filename"); |
1494 | strings.push_back(filepath); | 1494 | strings.push_back(filepath); |
1495 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); | 1495 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); |
1496 | self->sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); | 1496 | self->sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); |
1497 | } | 1497 | } |
1498 | 1498 | ||
1499 | // static | 1499 | // static |
1500 | void LLPanelRegionTerrainInfo::onClickUploadRaw(void* data) | 1500 | void LLPanelRegionTerrainInfo::onClickUploadRaw(void* data) |
1501 | { | 1501 | { |
1502 | LLFilePicker& picker = LLFilePicker::instance(); | 1502 | LLFilePicker& picker = LLFilePicker::instance(); |
1503 | if (!picker.getOpenFile(LLFilePicker::FFLOAD_RAW)) | 1503 | if (!picker.getOpenFile(LLFilePicker::FFLOAD_RAW)) |
1504 | { | 1504 | { |
1505 | llwarns << "No file" << llendl; | 1505 | llwarns << "No file" << llendl; |
1506 | return; | 1506 | return; |
1507 | } | 1507 | } |
1508 | std::string filepath = picker.getFirstFile(); | 1508 | std::string filepath = picker.getFirstFile(); |
1509 | gXferManager->expectFileForTransfer(filepath); | 1509 | gXferManager->expectFileForTransfer(filepath); |
1510 | 1510 | ||
1511 | LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data; | 1511 | LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data; |
1512 | strings_t strings; | 1512 | strings_t strings; |
1513 | strings.push_back("upload filename"); | 1513 | strings.push_back("upload filename"); |
1514 | strings.push_back(filepath); | 1514 | strings.push_back(filepath); |
1515 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); | 1515 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); |
1516 | self->sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); | 1516 | self->sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); |
1517 | 1517 | ||
1518 | LLNotifications::instance().add("RawUploadStarted"); | 1518 | LLNotifications::instance().add("RawUploadStarted"); |
1519 | } | 1519 | } |
1520 | 1520 | ||
1521 | // static | 1521 | // static |
1522 | void LLPanelRegionTerrainInfo::onClickBakeTerrain(void* data) | 1522 | void LLPanelRegionTerrainInfo::onClickBakeTerrain(void* data) |
1523 | { | 1523 | { |
1524 | LLNotifications::instance().add( | 1524 | LLNotifications::instance().add( |
1525 | LLNotification::Params("ConfirmBakeTerrain") | 1525 | LLNotification::Params("ConfirmBakeTerrain") |
1526 | .functor(boost::bind(&LLPanelRegionTerrainInfo::callbackBakeTerrain, (LLPanelRegionTerrainInfo*)data, _1, _2))); | 1526 | .functor(boost::bind(&LLPanelRegionTerrainInfo::callbackBakeTerrain, (LLPanelRegionTerrainInfo*)data, _1, _2))); |
1527 | } | 1527 | } |
1528 | 1528 | ||
1529 | bool LLPanelRegionTerrainInfo::callbackBakeTerrain(const LLSD& notification, const LLSD& response) | 1529 | bool LLPanelRegionTerrainInfo::callbackBakeTerrain(const LLSD& notification, const LLSD& response) |
1530 | { | 1530 | { |
1531 | S32 option = LLNotification::getSelectedOption(notification, response); | 1531 | S32 option = LLNotification::getSelectedOption(notification, response); |
1532 | if (option != 0) return false; | 1532 | if (option != 0) return false; |
1533 | 1533 | ||
1534 | strings_t strings; | 1534 | strings_t strings; |
1535 | strings.push_back("bake"); | 1535 | strings.push_back("bake"); |
1536 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); | 1536 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); |
1537 | sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); | 1537 | sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); |
1538 | return false; | 1538 | return false; |
1539 | } | 1539 | } |
1540 | 1540 | ||
1541 | ///////////////////////////////////////////////////////////////////////////// | 1541 | ///////////////////////////////////////////////////////////////////////////// |
1542 | // LLPanelEstateInfo | 1542 | // LLPanelEstateInfo |
1543 | // | 1543 | // |
1544 | 1544 | ||
1545 | LLPanelEstateInfo::LLPanelEstateInfo() | 1545 | LLPanelEstateInfo::LLPanelEstateInfo() |
1546 | : LLPanelRegionInfo(), | 1546 | : LLPanelRegionInfo(), |
1547 | mEstateID(0) // invalid | 1547 | mEstateID(0) // invalid |
1548 | { | 1548 | { |
1549 | } | 1549 | } |
1550 | 1550 | ||
1551 | // static | 1551 | // static |
1552 | void LLPanelEstateInfo::initDispatch(LLDispatcher& dispatch) | 1552 | void LLPanelEstateInfo::initDispatch(LLDispatcher& dispatch) |
1553 | { | 1553 | { |
1554 | std::string name; | 1554 | std::string name; |
1555 | 1555 | ||
1556 | // name.assign("setowner"); | 1556 | // name.assign("setowner"); |
1557 | // static LLDispatchSetEstateOwner set_owner; | 1557 | // static LLDispatchSetEstateOwner set_owner; |
1558 | // dispatch.addHandler(name, &set_owner); | 1558 | // dispatch.addHandler(name, &set_owner); |
1559 | 1559 | ||
1560 | name.assign("estateupdateinfo"); | 1560 | name.assign("estateupdateinfo"); |
1561 | static LLDispatchEstateUpdateInfo estate_update_info; | 1561 | static LLDispatchEstateUpdateInfo estate_update_info; |
1562 | dispatch.addHandler(name, &estate_update_info); | 1562 | dispatch.addHandler(name, &estate_update_info); |
1563 | 1563 | ||
1564 | name.assign("setaccess"); | 1564 | name.assign("setaccess"); |
1565 | static LLDispatchSetEstateAccess set_access; | 1565 | static LLDispatchSetEstateAccess set_access; |
1566 | dispatch.addHandler(name, &set_access); | 1566 | dispatch.addHandler(name, &set_access); |
1567 | 1567 | ||
1568 | estate_dispatch_initialized = true; | 1568 | estate_dispatch_initialized = true; |
1569 | } | 1569 | } |
1570 | 1570 | ||
1571 | // static | 1571 | // static |
1572 | // Disables the sun-hour slider and the use fixed time check if the use global time is check | 1572 | // Disables the sun-hour slider and the use fixed time check if the use global time is check |
1573 | void LLPanelEstateInfo::onChangeUseGlobalTime(LLUICtrl* ctrl, void* user_data) | 1573 | void LLPanelEstateInfo::onChangeUseGlobalTime(LLUICtrl* ctrl, void* user_data) |
1574 | { | 1574 | { |
1575 | LLPanelEstateInfo* panel = (LLPanelEstateInfo*) user_data; | 1575 | LLPanelEstateInfo* panel = (LLPanelEstateInfo*) user_data; |
1576 | if (panel) | 1576 | if (panel) |
1577 | { | 1577 | { |
1578 | bool enabled = !panel->childGetValue("use_global_time_check").asBoolean(); | 1578 | bool enabled = !panel->childGetValue("use_global_time_check").asBoolean(); |
1579 | panel->childSetEnabled("sun_hour_slider", enabled); | 1579 | panel->childSetEnabled("sun_hour_slider", enabled); |
1580 | panel->childSetEnabled("fixed_sun_check", enabled); | 1580 | panel->childSetEnabled("fixed_sun_check", enabled); |
1581 | panel->childSetValue("fixed_sun_check", LLSD(FALSE)); | 1581 | panel->childSetValue("fixed_sun_check", LLSD(FALSE)); |
1582 | panel->enableButton("apply_btn"); | 1582 | panel->enableButton("apply_btn"); |
1583 | } | 1583 | } |
1584 | } | 1584 | } |
1585 | 1585 | ||
1586 | // Enables the sun-hour slider if the fixed-sun checkbox is set | 1586 | // Enables the sun-hour slider if the fixed-sun checkbox is set |
1587 | void LLPanelEstateInfo::onChangeFixedSun(LLUICtrl* ctrl, void* user_data) | 1587 | void LLPanelEstateInfo::onChangeFixedSun(LLUICtrl* ctrl, void* user_data) |
1588 | { | 1588 | { |
1589 | LLPanelEstateInfo* panel = (LLPanelEstateInfo*) user_data; | 1589 | LLPanelEstateInfo* panel = (LLPanelEstateInfo*) user_data; |
1590 | if (panel) | 1590 | if (panel) |
1591 | { | 1591 | { |
1592 | bool enabled = !panel->childGetValue("fixed_sun_check").asBoolean(); | 1592 | bool enabled = !panel->childGetValue("fixed_sun_check").asBoolean(); |
1593 | panel->childSetEnabled("use_global_time_check", enabled); | 1593 | panel->childSetEnabled("use_global_time_check", enabled); |
1594 | panel->childSetValue("use_global_time_check", LLSD(FALSE)); | 1594 | panel->childSetValue("use_global_time_check", LLSD(FALSE)); |
1595 | panel->enableButton("apply_btn"); | 1595 | panel->enableButton("apply_btn"); |
1596 | } | 1596 | } |
1597 | } | 1597 | } |
1598 | 1598 | ||
1599 | 1599 | ||
1600 | 1600 | ||
1601 | 1601 | ||
1602 | //--------------------------------------------------------------------------- | 1602 | //--------------------------------------------------------------------------- |
1603 | // Add/Remove estate access button callbacks | 1603 | // Add/Remove estate access button callbacks |
1604 | //--------------------------------------------------------------------------- | 1604 | //--------------------------------------------------------------------------- |
1605 | void LLPanelEstateInfo::onClickEditSky(void* user_data) | 1605 | void LLPanelEstateInfo::onClickEditSky(void* user_data) |
1606 | { | 1606 | { |
1607 | LLFloaterWindLight::show(); | 1607 | LLFloaterWindLight::show(); |
1608 | } | 1608 | } |
1609 | 1609 | ||
1610 | void LLPanelEstateInfo::onClickEditDayCycle(void* user_data) | 1610 | void LLPanelEstateInfo::onClickEditDayCycle(void* user_data) |
1611 | { | 1611 | { |
1612 | LLFloaterDayCycle::show(); | 1612 | LLFloaterDayCycle::show(); |
1613 | } | 1613 | } |
1614 | 1614 | ||
1615 | // static | 1615 | // static |
1616 | void LLPanelEstateInfo::onClickAddAllowedAgent(void* user_data) | 1616 | void LLPanelEstateInfo::onClickAddAllowedAgent(void* user_data) |
1617 | { | 1617 | { |
1618 | LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data; | 1618 | LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data; |
1619 | LLCtrlListInterface *list = self->childGetListInterface("allowed_avatar_name_list"); | 1619 | LLCtrlListInterface *list = self->childGetListInterface("allowed_avatar_name_list"); |
1620 | if (!list) return; | 1620 | if (!list) return; |
1621 | if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS) | 1621 | if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS) |
1622 | { | 1622 | { |
1623 | //args | 1623 | //args |
1624 | 1624 | ||
1625 | LLSD args; | 1625 | LLSD args; |
1626 | args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); | 1626 | args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); |
1627 | LLNotifications::instance().add("MaxAllowedAgentOnRegion", args); | 1627 | LLNotifications::instance().add("MaxAllowedAgentOnRegion", args); |
1628 | return; | 1628 | return; |
1629 | } | 1629 | } |
1630 | accessAddCore(ESTATE_ACCESS_ALLOWED_AGENT_ADD, "EstateAllowedAgentAdd"); | 1630 | accessAddCore(ESTATE_ACCESS_ALLOWED_AGENT_ADD, "EstateAllowedAgentAdd"); |
1631 | } | 1631 | } |
1632 | 1632 | ||
1633 | // static | 1633 | // static |
1634 | void LLPanelEstateInfo::onClickRemoveAllowedAgent(void* user_data) | 1634 | void LLPanelEstateInfo::onClickRemoveAllowedAgent(void* user_data) |
1635 | { | 1635 | { |
1636 | accessRemoveCore(ESTATE_ACCESS_ALLOWED_AGENT_REMOVE, "EstateAllowedAgentRemove", "allowed_avatar_name_list"); | 1636 | accessRemoveCore(ESTATE_ACCESS_ALLOWED_AGENT_REMOVE, "EstateAllowedAgentRemove", "allowed_avatar_name_list"); |
1637 | } | 1637 | } |
1638 | 1638 | ||
1639 | // static | 1639 | // static |
1640 | void LLPanelEstateInfo::onClickAddAllowedGroup(void* user_data) | 1640 | void LLPanelEstateInfo::onClickAddAllowedGroup(void* user_data) |
1641 | { | 1641 | { |
1642 | LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data; | 1642 | LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data; |
1643 | LLCtrlListInterface *list = self->childGetListInterface("allowed_group_name_list"); | 1643 | LLCtrlListInterface *list = self->childGetListInterface("allowed_group_name_list"); |
1644 | if (!list) return; | 1644 | if (!list) return; |
1645 | if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS) | 1645 | if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS) |
1646 | { | 1646 | { |
1647 | LLSD args; | 1647 | LLSD args; |
1648 | args["MAX_GROUPS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); | 1648 | args["MAX_GROUPS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); |
1649 | LLNotifications::instance().add("MaxAllowedGroupsOnRegion", args); | 1649 | LLNotifications::instance().add("MaxAllowedGroupsOnRegion", args); |
1650 | return; | 1650 | return; |
1651 | } | 1651 | } |
1652 | 1652 | ||
1653 | LLNotification::Params params("ChangeLindenAccess"); | 1653 | LLNotification::Params params("ChangeLindenAccess"); |
1654 | params.functor(boost::bind(&LLPanelEstateInfo::addAllowedGroup, self, _1, _2)); | 1654 | params.functor(boost::bind(&LLPanelEstateInfo::addAllowedGroup, self, _1, _2)); |
1655 | if (isLindenEstate()) | 1655 | if (isLindenEstate()) |
1656 | { | 1656 | { |
1657 | LLNotifications::instance().add(params); | 1657 | LLNotifications::instance().add(params); |
1658 | } | 1658 | } |
1659 | else | 1659 | else |
1660 | { | 1660 | { |
1661 | LLNotifications::instance().forceResponse(params, 0); | 1661 | LLNotifications::instance().forceResponse(params, 0); |
1662 | } | 1662 | } |
1663 | } | 1663 | } |
1664 | 1664 | ||
1665 | bool LLPanelEstateInfo::addAllowedGroup(const LLSD& notification, const LLSD& response) | 1665 | bool LLPanelEstateInfo::addAllowedGroup(const LLSD& notification, const LLSD& response) |
1666 | { | 1666 | { |
1667 | S32 option = LLNotification::getSelectedOption(notification, response); | 1667 | S32 option = LLNotification::getSelectedOption(notification, response); |
1668 | if (option != 0) return false; | 1668 | if (option != 0) return false; |
1669 | 1669 | ||
1670 | LLFloater* parent_floater = gFloaterView->getParentFloater(this); | 1670 | LLFloater* parent_floater = gFloaterView->getParentFloater(this); |
1671 | 1671 | ||
1672 | LLFloaterGroupPicker* widget; | 1672 | LLFloaterGroupPicker* widget; |
1673 | widget = LLFloaterGroupPicker::showInstance(LLSD(gAgent.getID())); | 1673 | widget = LLFloaterGroupPicker::showInstance(LLSD(gAgent.getID())); |
1674 | if (widget) | 1674 | if (widget) |
1675 | { | 1675 | { |
1676 | widget->setSelectCallback(addAllowedGroup2, NULL); | 1676 | widget->setSelectCallback(addAllowedGroup2, NULL); |
1677 | if (parent_floater) | 1677 | if (parent_floater) |
1678 | { | 1678 | { |
1679 | LLRect new_rect = gFloaterView->findNeighboringPosition(parent_floater, widget); | 1679 | LLRect new_rect = gFloaterView->findNeighboringPosition(parent_floater, widget); |
1680 | widget->setOrigin(new_rect.mLeft, new_rect.mBottom); | 1680 | widget->setOrigin(new_rect.mLeft, new_rect.mBottom); |
1681 | parent_floater->addDependentFloater(widget); | 1681 | parent_floater->addDependentFloater(widget); |
1682 | } | 1682 | } |
1683 | } | 1683 | } |
1684 | 1684 | ||
1685 | return false; | 1685 | return false; |
1686 | } | 1686 | } |
1687 | 1687 | ||
1688 | // static | 1688 | // static |
1689 | void LLPanelEstateInfo::onClickRemoveAllowedGroup(void* user_data) | 1689 | void LLPanelEstateInfo::onClickRemoveAllowedGroup(void* user_data) |
1690 | { | 1690 | { |
1691 | accessRemoveCore(ESTATE_ACCESS_ALLOWED_GROUP_REMOVE, "EstateAllowedGroupRemove", "allowed_group_name_list"); | 1691 | accessRemoveCore(ESTATE_ACCESS_ALLOWED_GROUP_REMOVE, "EstateAllowedGroupRemove", "allowed_group_name_list"); |
1692 | } | 1692 | } |
1693 | 1693 | ||
1694 | // static | 1694 | // static |
1695 | void LLPanelEstateInfo::onClickAddBannedAgent(void* user_data) | 1695 | void LLPanelEstateInfo::onClickAddBannedAgent(void* user_data) |
1696 | { | 1696 | { |
1697 | LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data; | 1697 | LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data; |
1698 | LLCtrlListInterface *list = self->childGetListInterface("banned_avatar_name_list"); | 1698 | LLCtrlListInterface *list = self->childGetListInterface("banned_avatar_name_list"); |
1699 | if (!list) return; | 1699 | if (!list) return; |
1700 | if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS) | 1700 | if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS) |
1701 | { | 1701 | { |
1702 | LLSD args; | 1702 | LLSD args; |
1703 | args["MAX_BANNED"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); | 1703 | args["MAX_BANNED"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); |
1704 | LLNotifications::instance().add("MaxBannedAgentsOnRegion", args); | 1704 | LLNotifications::instance().add("MaxBannedAgentsOnRegion", args); |
1705 | return; | 1705 | return; |
1706 | } | 1706 | } |
1707 | accessAddCore(ESTATE_ACCESS_BANNED_AGENT_ADD, "EstateBannedAgentAdd"); | 1707 | accessAddCore(ESTATE_ACCESS_BANNED_AGENT_ADD, "EstateBannedAgentAdd"); |
1708 | } | 1708 | } |
1709 | 1709 | ||
1710 | // static | 1710 | // static |
1711 | void LLPanelEstateInfo::onClickRemoveBannedAgent(void* user_data) | 1711 | void LLPanelEstateInfo::onClickRemoveBannedAgent(void* user_data) |
1712 | { | 1712 | { |
1713 | accessRemoveCore(ESTATE_ACCESS_BANNED_AGENT_REMOVE, "EstateBannedAgentRemove", "banned_avatar_name_list"); | 1713 | accessRemoveCore(ESTATE_ACCESS_BANNED_AGENT_REMOVE, "EstateBannedAgentRemove", "banned_avatar_name_list"); |
1714 | } | 1714 | } |
1715 | 1715 | ||
1716 | // static | 1716 | // static |
1717 | void LLPanelEstateInfo::onClickAddEstateManager(void* user_data) | 1717 | void LLPanelEstateInfo::onClickAddEstateManager(void* user_data) |
1718 | { | 1718 | { |
1719 | LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data; | 1719 | LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data; |
1720 | LLCtrlListInterface *list = self->childGetListInterface("estate_manager_name_list"); | 1720 | LLCtrlListInterface *list = self->childGetListInterface("estate_manager_name_list"); |
1721 | if (!list) return; | 1721 | if (!list) return; |
1722 | if (list->getItemCount() >= ESTATE_MAX_MANAGERS) | 1722 | if (list->getItemCount() >= ESTATE_MAX_MANAGERS) |
1723 | { // Tell user they can't add more managers | 1723 | { // Tell user they can't add more managers |
1724 | LLSD args; | 1724 | LLSD args; |
1725 | args["MAX_MANAGER"] = llformat("%d",ESTATE_MAX_MANAGERS); | 1725 | args["MAX_MANAGER"] = llformat("%d",ESTATE_MAX_MANAGERS); |
1726 | LLNotifications::instance().add("MaxManagersOnRegion", args); | 1726 | LLNotifications::instance().add("MaxManagersOnRegion", args); |
1727 | } | 1727 | } |
1728 | else | 1728 | else |
1729 | { // Go pick managers to add | 1729 | { // Go pick managers to add |
1730 | accessAddCore(ESTATE_ACCESS_MANAGER_ADD, "EstateManagerAdd"); | 1730 | accessAddCore(ESTATE_ACCESS_MANAGER_ADD, "EstateManagerAdd"); |
1731 | } | 1731 | } |
1732 | } | 1732 | } |
1733 | 1733 | ||
1734 | // static | 1734 | // static |
1735 | void LLPanelEstateInfo::onClickRemoveEstateManager(void* user_data) | 1735 | void LLPanelEstateInfo::onClickRemoveEstateManager(void* user_data) |
1736 | { | 1736 | { |
1737 | accessRemoveCore(ESTATE_ACCESS_MANAGER_REMOVE, "EstateManagerRemove", "estate_manager_name_list"); | 1737 | accessRemoveCore(ESTATE_ACCESS_MANAGER_REMOVE, "EstateManagerRemove", "estate_manager_name_list"); |
1738 | } | 1738 | } |
1739 | 1739 | ||
1740 | //--------------------------------------------------------------------------- | 1740 | //--------------------------------------------------------------------------- |
1741 | // Kick from estate methods | 1741 | // Kick from estate methods |
1742 | //--------------------------------------------------------------------------- | 1742 | //--------------------------------------------------------------------------- |
1743 | struct LLKickFromEstateInfo | 1743 | struct LLKickFromEstateInfo |
1744 | { | 1744 | { |
1745 | LLPanelEstateInfo *mEstatePanelp; | 1745 | LLPanelEstateInfo *mEstatePanelp; |
1746 | LLUUID mAgentID; | 1746 | LLUUID mAgentID; |
1747 | }; | 1747 | }; |
1748 | 1748 | ||
1749 | void LLPanelEstateInfo::onClickKickUser(void *user_data) | 1749 | void LLPanelEstateInfo::onClickKickUser(void *user_data) |
1750 | { | 1750 | { |
1751 | LLPanelEstateInfo* panelp = (LLPanelEstateInfo*)user_data; | 1751 | LLPanelEstateInfo* panelp = (LLPanelEstateInfo*)user_data; |
1752 | 1752 | ||
1753 | // this depends on the grandparent view being a floater | 1753 | // this depends on the grandparent view being a floater |
1754 | // in order to set up floater dependency | 1754 | // in order to set up floater dependency |
1755 | LLFloater* parent_floater = gFloaterView->getParentFloater(panelp); | 1755 | LLFloater* parent_floater = gFloaterView->getParentFloater(panelp); |
1756 | LLFloater* child_floater = LLFloaterAvatarPicker::show(LLPanelEstateInfo::onKickUserCommit, user_data, FALSE, TRUE); | 1756 | LLFloater* child_floater = LLFloaterAvatarPicker::show(LLPanelEstateInfo::onKickUserCommit, user_data, FALSE, TRUE); |
1757 | parent_floater->addDependentFloater(child_floater); | 1757 | parent_floater->addDependentFloater(child_floater); |
1758 | } | 1758 | } |
1759 | 1759 | ||
1760 | void LLPanelEstateInfo::onKickUserCommit(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* userdata) | 1760 | void LLPanelEstateInfo::onKickUserCommit(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* userdata) |
1761 | { | 1761 | { |
1762 | if (names.empty() || ids.empty()) return; | 1762 | if (names.empty() || ids.empty()) return; |
1763 | 1763 | ||
1764 | //check to make sure there is one valid user and id | 1764 | //check to make sure there is one valid user and id |
1765 | if( (ids[0].isNull()) || | 1765 | if( (ids[0].isNull()) || |
1766 | (names[0].length() == 0) ) | 1766 | (names[0].length() == 0) ) |
1767 | { | 1767 | { |
1768 | return; | 1768 | return; |
1769 | } | 1769 | } |
1770 | 1770 | ||
1771 | LLPanelEstateInfo* self = (LLPanelEstateInfo*)userdata; | 1771 | LLPanelEstateInfo* self = (LLPanelEstateInfo*)userdata; |
1772 | if(!self) return; | 1772 | if(!self) return; |
1773 | 1773 | ||
1774 | //keep track of what user they want to kick and other misc info | 1774 | //keep track of what user they want to kick and other misc info |
1775 | LLKickFromEstateInfo *kick_info = new LLKickFromEstateInfo(); | 1775 | LLKickFromEstateInfo *kick_info = new LLKickFromEstateInfo(); |
1776 | kick_info->mEstatePanelp = self; | 1776 | kick_info->mEstatePanelp = self; |
1777 | kick_info->mAgentID = ids[0]; | 1777 | kick_info->mAgentID = ids[0]; |
1778 | 1778 | ||
1779 | //Bring up a confirmation dialog | 1779 | //Bring up a confirmation dialog |
1780 | LLSD args; | 1780 | LLSD args; |
1781 | args["EVIL_USER"] = names[0]; | 1781 | args["EVIL_USER"] = names[0]; |
1782 | LLSD payload; | 1782 | LLSD payload; |
1783 | payload["agent_id"] = ids[0]; | 1783 | payload["agent_id"] = ids[0]; |
1784 | LLNotifications::instance().add("EstateKickUser", args, payload, boost::bind(&LLPanelEstateInfo::kickUserConfirm, self, _1, _2)); | 1784 | LLNotifications::instance().add("EstateKickUser", args, payload, boost::bind(&LLPanelEstateInfo::kickUserConfirm, self, _1, _2)); |
1785 | 1785 | ||
1786 | } | 1786 | } |
1787 | 1787 | ||
1788 | bool LLPanelEstateInfo::kickUserConfirm(const LLSD& notification, const LLSD& response) | 1788 | bool LLPanelEstateInfo::kickUserConfirm(const LLSD& notification, const LLSD& response) |
1789 | { | 1789 | { |
1790 | S32 option = LLNotification::getSelectedOption(notification, response); | 1790 | S32 option = LLNotification::getSelectedOption(notification, response); |
1791 | switch(option) | 1791 | switch(option) |
1792 | { | 1792 | { |
1793 | case 0: | 1793 | case 0: |
1794 | { | 1794 | { |
1795 | //Kick User | 1795 | //Kick User |
1796 | strings_t strings; | 1796 | strings_t strings; |
1797 | strings.push_back(notification["payload"]["agent_id"].asString()); | 1797 | strings.push_back(notification["payload"]["agent_id"].asString()); |
1798 | 1798 | ||
1799 | sendEstateOwnerMessage(gMessageSystem, "kickestate", LLFloaterRegionInfo::getLastInvoice(), strings); | 1799 | sendEstateOwnerMessage(gMessageSystem, "kickestate", LLFloaterRegionInfo::getLastInvoice(), strings); |
1800 | break; | 1800 | break; |
1801 | } | 1801 | } |
1802 | default: | 1802 | default: |
1803 | break; | 1803 | break; |
1804 | } | 1804 | } |
1805 | return false; | 1805 | return false; |
1806 | } | 1806 | } |
1807 | 1807 | ||
1808 | //--------------------------------------------------------------------------- | 1808 | //--------------------------------------------------------------------------- |
1809 | // Core Add/Remove estate access methods | 1809 | // Core Add/Remove estate access methods |
1810 | // TODO: INTERNATIONAL: don't build message text here; | 1810 | // TODO: INTERNATIONAL: don't build message text here; |
1811 | // instead, create multiple translatable messages and choose | 1811 | // instead, create multiple translatable messages and choose |
1812 | // one based on the status. | 1812 | // one based on the status. |
1813 | //--------------------------------------------------------------------------- | 1813 | //--------------------------------------------------------------------------- |
1814 | std::string all_estates_text() | 1814 | std::string all_estates_text() |
1815 | { | 1815 | { |
1816 | LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); | 1816 | LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); |
1817 | if (!panel) return "(error)"; | 1817 | if (!panel) return "(error)"; |
1818 | 1818 | ||
1819 | std::string owner = panel->getOwnerName(); | 1819 | std::string owner = panel->getOwnerName(); |
1820 | 1820 | ||
1821 | LLViewerRegion* region = gAgent.getRegion(); | 1821 | LLViewerRegion* region = gAgent.getRegion(); |
1822 | if (gAgent.isGodlike()) | 1822 | if (gAgent.isGodlike()) |
1823 | { | 1823 | { |
1824 | return llformat("all estates\nowned by %s", owner.c_str()); | 1824 | return llformat("all estates\nowned by %s", owner.c_str()); |
1825 | } | 1825 | } |
1826 | else if (region && region->getOwner() == gAgent.getID()) | 1826 | else if (region && region->getOwner() == gAgent.getID()) |
1827 | { | 1827 | { |
1828 | return "all estates you own"; | 1828 | return "all estates you own"; |
1829 | } | 1829 | } |
1830 | else if (region && region->isEstateManager()) | 1830 | else if (region && region->isEstateManager()) |
1831 | { | 1831 | { |
1832 | return llformat("all estates that\nyou manage for %s", owner.c_str()); | 1832 | return llformat("all estates that\nyou manage for %s", owner.c_str()); |
1833 | } | 1833 | } |
1834 | else | 1834 | else |
1835 | { | 1835 | { |
1836 | return "(error)"; | 1836 | return "(error)"; |
1837 | } | 1837 | } |
1838 | } | 1838 | } |
1839 | 1839 | ||
1840 | // static | 1840 | // static |
1841 | bool LLPanelEstateInfo::isLindenEstate() | 1841 | bool LLPanelEstateInfo::isLindenEstate() |
1842 | { | 1842 | { |
1843 | LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); | 1843 | LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); |
1844 | if (!panel) return false; | 1844 | if (!panel) return false; |
1845 | 1845 | ||
1846 | U32 estate_id = panel->getEstateID(); | 1846 | U32 estate_id = panel->getEstateID(); |
1847 | return (estate_id <= ESTATE_LAST_LINDEN); | 1847 | return (estate_id <= ESTATE_LAST_LINDEN); |
1848 | } | 1848 | } |
1849 | 1849 | ||
1850 | typedef std::vector<LLUUID> AgentOrGroupIDsVector; | 1850 | typedef std::vector<LLUUID> AgentOrGroupIDsVector; |
1851 | struct LLEstateAccessChangeInfo | 1851 | struct LLEstateAccessChangeInfo |
1852 | { | 1852 | { |
1853 | LLEstateAccessChangeInfo(const LLSD& sd) | 1853 | LLEstateAccessChangeInfo(const LLSD& sd) |
1854 | { | 1854 | { |
1855 | mDialogName = sd["dialog_name"].asString(); | 1855 | mDialogName = sd["dialog_name"].asString(); |
1856 | mOperationFlag = (U32)sd["operation"].asInteger(); | 1856 | mOperationFlag = (U32)sd["operation"].asInteger(); |
1857 | LLSD::array_const_iterator end_it = sd["allowed_ids"].endArray(); | 1857 | LLSD::array_const_iterator end_it = sd["allowed_ids"].endArray(); |
1858 | for (LLSD::array_const_iterator id_it = sd["allowed_ids"].beginArray(); | 1858 | for (LLSD::array_const_iterator id_it = sd["allowed_ids"].beginArray(); |
1859 | id_it != end_it; | 1859 | id_it != end_it; |
1860 | ++id_it) | 1860 | ++id_it) |
1861 | { | 1861 | { |
1862 | mAgentOrGroupIDs.push_back(id_it->asUUID()); | 1862 | mAgentOrGroupIDs.push_back(id_it->asUUID()); |
1863 | } | 1863 | } |
1864 | } | 1864 | } |
1865 | 1865 | ||
1866 | const LLSD asLLSD() const | 1866 | const LLSD asLLSD() const |
1867 | { | 1867 | { |
1868 | LLSD sd; | 1868 | LLSD sd; |
1869 | sd["name"] = mDialogName; | 1869 | sd["name"] = mDialogName; |
1870 | sd["operation"] = (S32)mOperationFlag; | 1870 | sd["operation"] = (S32)mOperationFlag; |
1871 | for (AgentOrGroupIDsVector::const_iterator it = mAgentOrGroupIDs.begin(); | 1871 | for (AgentOrGroupIDsVector::const_iterator it = mAgentOrGroupIDs.begin(); |
1872 | it != mAgentOrGroupIDs.end(); | 1872 | it != mAgentOrGroupIDs.end(); |
1873 | ++it) | 1873 | ++it) |
1874 | { | 1874 | { |
1875 | sd["allowed_ids"].append(*it); | 1875 | sd["allowed_ids"].append(*it); |
1876 | } | 1876 | } |
1877 | return sd; | 1877 | return sd; |
1878 | } | 1878 | } |
1879 | 1879 | ||
1880 | U32 mOperationFlag; // ESTATE_ACCESS_BANNED_AGENT_ADD, _REMOVE, etc. | 1880 | U32 mOperationFlag; // ESTATE_ACCESS_BANNED_AGENT_ADD, _REMOVE, etc. |
1881 | std::string mDialogName; | 1881 | std::string mDialogName; |
1882 | AgentOrGroupIDsVector mAgentOrGroupIDs; // List of agent IDs to apply to this change | 1882 | AgentOrGroupIDsVector mAgentOrGroupIDs; // List of agent IDs to apply to this change |
1883 | }; | 1883 | }; |
1884 | 1884 | ||
1885 | // Special case callback for groups, since it has different callback format than names | 1885 | // Special case callback for groups, since it has different callback format than names |
1886 | // static | 1886 | // static |
1887 | void LLPanelEstateInfo::addAllowedGroup2(LLUUID id, void* user_data) | 1887 | void LLPanelEstateInfo::addAllowedGroup2(LLUUID id, void* user_data) |
1888 | { | 1888 | { |
1889 | LLSD payload; | 1889 | LLSD payload; |
1890 | payload["operation"] = (S32)ESTATE_ACCESS_ALLOWED_GROUP_ADD; | 1890 | payload["operation"] = (S32)ESTATE_ACCESS_ALLOWED_GROUP_ADD; |
1891 | payload["dialog_name"] = "EstateAllowedGroupAdd"; | 1891 | payload["dialog_name"] = "EstateAllowedGroupAdd"; |
1892 | payload["allowed_ids"].append(id); | 1892 | payload["allowed_ids"].append(id); |
1893 | 1893 | ||
1894 | LLSD args; | 1894 | LLSD args; |
1895 | args["ALL_ESTATES"] = all_estates_text(); | 1895 | args["ALL_ESTATES"] = all_estates_text(); |
1896 | 1896 | ||
1897 | LLNotification::Params params("EstateAllowedGroupAdd"); | 1897 | LLNotification::Params params("EstateAllowedGroupAdd"); |
1898 | params.payload(payload) | 1898 | params.payload(payload) |
1899 | .substitutions(args) | 1899 | .substitutions(args) |
1900 | .functor(accessCoreConfirm); | 1900 | .functor(accessCoreConfirm); |
1901 | if (isLindenEstate()) | 1901 | if (isLindenEstate()) |
1902 | { | 1902 | { |
1903 | LLNotifications::instance().forceResponse(params, 0); | 1903 | LLNotifications::instance().forceResponse(params, 0); |
1904 | } | 1904 | } |
1905 | else | 1905 | else |
1906 | { | 1906 | { |
1907 | LLNotifications::instance().add(params); | 1907 | LLNotifications::instance().add(params); |
1908 | } | 1908 | } |
1909 | } | 1909 | } |
1910 | 1910 | ||
1911 | // static | 1911 | // static |
1912 | void LLPanelEstateInfo::accessAddCore(U32 operation_flag, const std::string& dialog_name) | 1912 | void LLPanelEstateInfo::accessAddCore(U32 operation_flag, const std::string& dialog_name) |
1913 | { | 1913 | { |
1914 | LLSD payload; | 1914 | LLSD payload; |
1915 | payload["operation"] = (S32)operation_flag; | 1915 | payload["operation"] = (S32)operation_flag; |
1916 | payload["dialog_name"] = dialog_name; | 1916 | payload["dialog_name"] = dialog_name; |
1917 | // agent id filled in after avatar picker | 1917 | // agent id filled in after avatar picker |
1918 | 1918 | ||
1919 | LLNotification::Params params("ChangeLindenAccess"); | 1919 | LLNotification::Params params("ChangeLindenAccess"); |
1920 | params.payload(payload) | 1920 | params.payload(payload) |
1921 | .functor(accessAddCore2); | 1921 | .functor(accessAddCore2); |
1922 | 1922 | ||
1923 | if (isLindenEstate()) | 1923 | if (isLindenEstate()) |
1924 | { | 1924 | { |
1925 | LLNotifications::instance().add(params); | 1925 | LLNotifications::instance().add(params); |
1926 | } | 1926 | } |
1927 | else | 1927 | else |
1928 | { | 1928 | { |
1929 | // same as clicking "OK" | 1929 | // same as clicking "OK" |
1930 | LLNotifications::instance().forceResponse(params, 0); | 1930 | LLNotifications::instance().forceResponse(params, 0); |
1931 | } | 1931 | } |
1932 | } | 1932 | } |
1933 | 1933 | ||
1934 | // static | 1934 | // static |
1935 | bool LLPanelEstateInfo::accessAddCore2(const LLSD& notification, const LLSD& response) | 1935 | bool LLPanelEstateInfo::accessAddCore2(const LLSD& notification, const LLSD& response) |
1936 | { | 1936 | { |
1937 | S32 option = LLNotification::getSelectedOption(notification, response); | 1937 | S32 option = LLNotification::getSelectedOption(notification, response); |
1938 | if (option != 0) | 1938 | if (option != 0) |
1939 | { | 1939 | { |
1940 | // abort change | 1940 | // abort change |
1941 | return false; | 1941 | return false; |
1942 | } | 1942 | } |
1943 | 1943 | ||
1944 | LLEstateAccessChangeInfo* change_info = new LLEstateAccessChangeInfo(notification["payload"]); | 1944 | LLEstateAccessChangeInfo* change_info = new LLEstateAccessChangeInfo(notification["payload"]); |
1945 | // avatar picker yes multi-select, yes close-on-select | 1945 | // avatar picker yes multi-select, yes close-on-select |
1946 | LLFloaterAvatarPicker::show(accessAddCore3, (void*)change_info, TRUE, TRUE); | 1946 | LLFloaterAvatarPicker::show(accessAddCore3, (void*)change_info, TRUE, TRUE); |
1947 | return false; | 1947 | return false; |
1948 | } | 1948 | } |
1949 | 1949 | ||
1950 | // static | 1950 | // static |
1951 | void LLPanelEstateInfo::accessAddCore3(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data) | 1951 | void LLPanelEstateInfo::accessAddCore3(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data) |
1952 | { | 1952 | { |
1953 | LLEstateAccessChangeInfo* change_info = (LLEstateAccessChangeInfo*)data; | 1953 | LLEstateAccessChangeInfo* change_info = (LLEstateAccessChangeInfo*)data; |
1954 | if (!change_info) return; | 1954 | if (!change_info) return; |
1955 | if (ids.empty()) | 1955 | if (ids.empty()) |
1956 | { | 1956 | { |
1957 | // User didn't select a name. | 1957 | // User didn't select a name. |
1958 | delete change_info; | 1958 | delete change_info; |
1959 | change_info = NULL; | 1959 | change_info = NULL; |
1960 | return; | 1960 | return; |
1961 | } | 1961 | } |
1962 | // User did select a name. | 1962 | // User did select a name. |
1963 | change_info->mAgentOrGroupIDs = ids; | 1963 | change_info->mAgentOrGroupIDs = ids; |
1964 | // Can't put estate owner on ban list | 1964 | // Can't put estate owner on ban list |
1965 | LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); | 1965 | LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); |
1966 | if (!panel) return; | 1966 | if (!panel) return; |
1967 | LLViewerRegion* region = gAgent.getRegion(); | 1967 | LLViewerRegion* region = gAgent.getRegion(); |
1968 | if (!region) return; | 1968 | if (!region) return; |
1969 | 1969 | ||
1970 | if (change_info->mOperationFlag & ESTATE_ACCESS_ALLOWED_AGENT_ADD) | 1970 | if (change_info->mOperationFlag & ESTATE_ACCESS_ALLOWED_AGENT_ADD) |
1971 | { | 1971 | { |
1972 | LLCtrlListInterface *list = panel->childGetListInterface("allowed_avatar_name_list"); | 1972 | LLCtrlListInterface *list = panel->childGetListInterface("allowed_avatar_name_list"); |
1973 | int currentCount = (list ? list->getItemCount() : 0); | 1973 | int currentCount = (list ? list->getItemCount() : 0); |
1974 | if (ids.size() + currentCount > ESTATE_MAX_ACCESS_IDS) | 1974 | if (ids.size() + currentCount > ESTATE_MAX_ACCESS_IDS) |
1975 | { | 1975 | { |
1976 | LLSD args; | 1976 | LLSD args; |
1977 | args["NUM_ADDED"] = llformat("%d",ids.size()); | 1977 | args["NUM_ADDED"] = llformat("%d",ids.size()); |
1978 | args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); | 1978 | args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); |
1979 | args["LIST_TYPE"] = "Allowed Residents"; | 1979 | args["LIST_TYPE"] = "Allowed Residents"; |
1980 | args["NUM_EXCESS"] = llformat("%d",(ids.size()+currentCount)-ESTATE_MAX_ACCESS_IDS); | 1980 | args["NUM_EXCESS"] = llformat("%d",(ids.size()+currentCount)-ESTATE_MAX_ACCESS_IDS); |
1981 | LLNotifications::instance().add("MaxAgentOnRegionBatch", args); | 1981 | LLNotifications::instance().add("MaxAgentOnRegionBatch", args); |
1982 | delete change_info; | 1982 | delete change_info; |
1983 | return; | 1983 | return; |
1984 | } | 1984 | } |
1985 | } | 1985 | } |
1986 | if (change_info->mOperationFlag & ESTATE_ACCESS_BANNED_AGENT_ADD) | 1986 | if (change_info->mOperationFlag & ESTATE_ACCESS_BANNED_AGENT_ADD) |
1987 | { | 1987 | { |
1988 | LLCtrlListInterface *list = panel->childGetListInterface("banned_avatar_name_list"); | 1988 | LLCtrlListInterface *list = panel->childGetListInterface("banned_avatar_name_list"); |
1989 | int currentCount = (list ? list->getItemCount() : 0); | 1989 | int currentCount = (list ? list->getItemCount() : 0); |
1990 | if (ids.size() + currentCount > ESTATE_MAX_ACCESS_IDS) | 1990 | if (ids.size() + currentCount > ESTATE_MAX_ACCESS_IDS) |
1991 | { | 1991 | { |
1992 | LLSD args; | 1992 | LLSD args; |
1993 | args["NUM_ADDED"] = llformat("%d",ids.size()); | 1993 | args["NUM_ADDED"] = llformat("%d",ids.size()); |
1994 | args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); | 1994 | args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); |
1995 | args["LIST_TYPE"] = "Banned Residents"; | 1995 | args["LIST_TYPE"] = "Banned Residents"; |
1996 | args["NUM_EXCESS"] = llformat("%d",(ids.size()+currentCount)-ESTATE_MAX_ACCESS_IDS); | 1996 | args["NUM_EXCESS"] = llformat("%d",(ids.size()+currentCount)-ESTATE_MAX_ACCESS_IDS); |
1997 | LLNotifications::instance().add("MaxAgentOnRegionBatch", args); | 1997 | LLNotifications::instance().add("MaxAgentOnRegionBatch", args); |
1998 | delete change_info; | 1998 | delete change_info; |
1999 | return; | 1999 | return; |
2000 | } | 2000 | } |
2001 | } | 2001 | } |
2002 | 2002 | ||
2003 | LLSD args; | 2003 | LLSD args; |
2004 | args["ALL_ESTATES"] = all_estates_text(); | 2004 | args["ALL_ESTATES"] = all_estates_text(); |
2005 | 2005 | ||
2006 | LLNotification::Params params(change_info->mDialogName); | 2006 | LLNotification::Params params(change_info->mDialogName); |
2007 | params.substitutions(args) | 2007 | params.substitutions(args) |
2008 | .payload(change_info->asLLSD()) | 2008 | .payload(change_info->asLLSD()) |
2009 | .functor(accessCoreConfirm); | 2009 | .functor(accessCoreConfirm); |
2010 | 2010 | ||
2011 | if (isLindenEstate()) | 2011 | if (isLindenEstate()) |
2012 | { | 2012 | { |
2013 | // just apply to this estate | 2013 | // just apply to this estate |
2014 | LLNotifications::instance().forceResponse(params, 0); | 2014 | LLNotifications::instance().forceResponse(params, 0); |
2015 | } | 2015 | } |
2016 | else | 2016 | else |
2017 | { | 2017 | { |
2018 | // ask if this estate or all estates with this owner | 2018 | // ask if this estate or all estates with this owner |
2019 | LLNotifications::instance().add(params); | 2019 | LLNotifications::instance().add(params); |
2020 | } | 2020 | } |
2021 | } | 2021 | } |
2022 | 2022 | ||
2023 | // static | 2023 | // static |
2024 | void LLPanelEstateInfo::accessRemoveCore(U32 operation_flag, const std::string& dialog_name, const std::string& list_ctrl_name) | 2024 | void LLPanelEstateInfo::accessRemoveCore(U32 operation_flag, const std::string& dialog_name, const std::string& list_ctrl_name) |
2025 | { | 2025 | { |
2026 | LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); | 2026 | LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); |
2027 | if (!panel) return; | 2027 | if (!panel) return; |
2028 | LLNameListCtrl* name_list = panel->getChild<LLNameListCtrl>(list_ctrl_name); | 2028 | LLNameListCtrl* name_list = panel->getChild<LLNameListCtrl>(list_ctrl_name); |
2029 | if (!name_list) return; | 2029 | if (!name_list) return; |
2030 | 2030 | ||
2031 | std::vector<LLScrollListItem*> list_vector = name_list->getAllSelected(); | 2031 | std::vector<LLScrollListItem*> list_vector = name_list->getAllSelected(); |
2032 | if (list_vector.size() == 0) | 2032 | if (list_vector.size() == 0) |
2033 | return; | 2033 | return; |
2034 | 2034 | ||
2035 | LLSD payload; | 2035 | LLSD payload; |
2036 | payload["operation"] = (S32)operation_flag; | 2036 | payload["operation"] = (S32)operation_flag; |
2037 | payload["dialog_name"] = dialog_name; | 2037 | payload["dialog_name"] = dialog_name; |
2038 | 2038 | ||
2039 | for (std::vector<LLScrollListItem*>::const_iterator iter = list_vector.begin(); | 2039 | for (std::vector<LLScrollListItem*>::const_iterator iter = list_vector.begin(); |
2040 | iter != list_vector.end(); | 2040 | iter != list_vector.end(); |
2041 | iter++) | 2041 | iter++) |
2042 | { | 2042 | { |
2043 | LLScrollListItem *item = (*iter); | 2043 | LLScrollListItem *item = (*iter); |
2044 | payload["allowed_ids"].append(item->getUUID()); | 2044 | payload["allowed_ids"].append(item->getUUID()); |
2045 | } | 2045 | } |
2046 | 2046 | ||
2047 | LLNotification::Params params("ChangeLindenAccess"); | 2047 | LLNotification::Params params("ChangeLindenAccess"); |
2048 | params.payload(payload) | 2048 | params.payload(payload) |
2049 | .functor(accessRemoveCore2); | 2049 | .functor(accessRemoveCore2); |
2050 | 2050 | ||
2051 | if (isLindenEstate()) | 2051 | if (isLindenEstate()) |
2052 | { | 2052 | { |
2053 | // warn on change linden estate | 2053 | // warn on change linden estate |
2054 | LLNotifications::instance().add(params); | 2054 | LLNotifications::instance().add(params); |
2055 | } | 2055 | } |
2056 | else | 2056 | else |
2057 | { | 2057 | { |
2058 | // just proceed, as if clicking OK | 2058 | // just proceed, as if clicking OK |
2059 | LLNotifications::instance().forceResponse(params, 0); | 2059 | LLNotifications::instance().forceResponse(params, 0); |
2060 | } | 2060 | } |
2061 | } | 2061 | } |
2062 | 2062 | ||
2063 | // static | 2063 | // static |
2064 | bool LLPanelEstateInfo::accessRemoveCore2(const LLSD& notification, const LLSD& response) | 2064 | bool LLPanelEstateInfo::accessRemoveCore2(const LLSD& notification, const LLSD& response) |
2065 | { | 2065 | { |
2066 | S32 option = LLNotification::getSelectedOption(notification, response); | 2066 | S32 option = LLNotification::getSelectedOption(notification, response); |
2067 | if (option != 0) | 2067 | if (option != 0) |
2068 | { | 2068 | { |
2069 | // abort | 2069 | // abort |
2070 | return false; | 2070 | return false; |
2071 | } | 2071 | } |
2072 | 2072 | ||
2073 | // If Linden estate, can only apply to "this" estate, not all estates | 2073 | // If Linden estate, can only apply to "this" estate, not all estates |
2074 | // owned by NULL. | 2074 | // owned by NULL. |
2075 | if (isLindenEstate()) | 2075 | if (isLindenEstate()) |
2076 | { | 2076 | { |
2077 | accessCoreConfirm(notification, response); | 2077 | accessCoreConfirm(notification, response); |
2078 | } | 2078 | } |
2079 | else | 2079 | else |
2080 | { | 2080 | { |
2081 | LLSD args; | 2081 | LLSD args; |
2082 | args["ALL_ESTATES"] = all_estates_text(); | 2082 | args["ALL_ESTATES"] = all_estates_text(); |
2083 | LLNotifications::instance().add(notification["payload"]["dialog_name"], | 2083 | LLNotifications::instance().add(notification["payload"]["dialog_name"], |
2084 | args, | 2084 | args, |
2085 | notification["payload"], | 2085 | notification["payload"], |
2086 | accessCoreConfirm); | 2086 | accessCoreConfirm); |
2087 | } | 2087 | } |
2088 | return false; | 2088 | return false; |
2089 | } | 2089 | } |
2090 | 2090 | ||
2091 | // Used for both access add and remove operations, depending on the mOperationFlag | 2091 | // Used for both access add and remove operations, depending on the mOperationFlag |
2092 | // passed in (ESTATE_ACCESS_BANNED_AGENT_ADD, ESTATE_ACCESS_ALLOWED_AGENT_REMOVE, etc.) | 2092 | // passed in (ESTATE_ACCESS_BANNED_AGENT_ADD, ESTATE_ACCESS_ALLOWED_AGENT_REMOVE, etc.) |
2093 | // static | 2093 | // static |
2094 | bool LLPanelEstateInfo::accessCoreConfirm(const LLSD& notification, const LLSD& response) | 2094 | bool LLPanelEstateInfo::accessCoreConfirm(const LLSD& notification, const LLSD& response) |
2095 | { | 2095 | { |
2096 | S32 option = LLNotification::getSelectedOption(notification, response); | 2096 | S32 option = LLNotification::getSelectedOption(notification, response); |
2097 | const U32 originalFlags = (U32)notification["payload"]["operation"].asInteger(); | 2097 | const U32 originalFlags = (U32)notification["payload"]["operation"].asInteger(); |
2098 | 2098 | ||
2099 | LLViewerRegion* region = gAgent.getRegion(); | 2099 | LLViewerRegion* region = gAgent.getRegion(); |
2100 | 2100 | ||
2101 | LLSD::array_const_iterator end_it = notification["payload"]["allowed_ids"].endArray(); | 2101 | LLSD::array_const_iterator end_it = notification["payload"]["allowed_ids"].endArray(); |
2102 | 2102 | ||
2103 | for (LLSD::array_const_iterator iter = notification["payload"]["allowed_ids"].beginArray(); | 2103 | for (LLSD::array_const_iterator iter = notification["payload"]["allowed_ids"].beginArray(); |
2104 | iter != end_it; | 2104 | iter != end_it; |
2105 | iter++) | 2105 | iter++) |
2106 | { | 2106 | { |
2107 | U32 flags = originalFlags; | 2107 | U32 flags = originalFlags; |
2108 | if (iter + 1 != end_it) | 2108 | if (iter + 1 != end_it) |
2109 | flags |= ESTATE_ACCESS_NO_REPLY; | 2109 | flags |= ESTATE_ACCESS_NO_REPLY; |
2110 | 2110 | ||
2111 | const LLUUID id = iter->asUUID(); | 2111 | const LLUUID id = iter->asUUID(); |
2112 | if (((U32)notification["payload"]["operation"].asInteger() & ESTATE_ACCESS_BANNED_AGENT_ADD) | 2112 | if (((U32)notification["payload"]["operation"].asInteger() & ESTATE_ACCESS_BANNED_AGENT_ADD) |
2113 | && region && (region->getOwner() == id)) | 2113 | && region && (region->getOwner() == id)) |
2114 | { | 2114 | { |
2115 | LLNotifications::instance().add("OwnerCanNotBeDenied"); | 2115 | LLNotifications::instance().add("OwnerCanNotBeDenied"); |
2116 | break; | 2116 | break; |
2117 | } | 2117 | } |
2118 | switch(option) | 2118 | switch(option) |
2119 | { | 2119 | { |
2120 | case 0: | 2120 | case 0: |
2121 | // This estate | 2121 | // This estate |
2122 | sendEstateAccessDelta(flags, id); | 2122 | sendEstateAccessDelta(flags, id); |
2123 | break; | 2123 | break; |
2124 | case 1: | 2124 | case 1: |
2125 | { | 2125 | { |
2126 | // All estates, either than I own or manage for this owner. | 2126 | // All estates, either than I own or manage for this owner. |
2127 | // This will be verified on simulator. JC | 2127 | // This will be verified on simulator. JC |
2128 | if (!region) break; | 2128 | if (!region) break; |
2129 | if (region->getOwner() == gAgent.getID() | 2129 | if (region->getOwner() == gAgent.getID() |
2130 | || gAgent.isGodlike()) | 2130 | || gAgent.isGodlike()) |
2131 | { | 2131 | { |
2132 | flags |= ESTATE_ACCESS_APPLY_TO_ALL_ESTATES; | 2132 | flags |= ESTATE_ACCESS_APPLY_TO_ALL_ESTATES; |
2133 | sendEstateAccessDelta(flags, id); | 2133 | sendEstateAccessDelta(flags, id); |
2134 | } | 2134 | } |
2135 | else if (region->isEstateManager()) | 2135 | else if (region->isEstateManager()) |
2136 | { | 2136 | { |
2137 | flags |= ESTATE_ACCESS_APPLY_TO_MANAGED_ESTATES; | 2137 | flags |= ESTATE_ACCESS_APPLY_TO_MANAGED_ESTATES; |
2138 | sendEstateAccessDelta(flags, id); | 2138 | sendEstateAccessDelta(flags, id); |
2139 | } | 2139 | } |
2140 | break; | 2140 | break; |
2141 | } | 2141 | } |
2142 | case 2: | 2142 | case 2: |
2143 | default: | 2143 | default: |
2144 | break; | 2144 | break; |
2145 | } | 2145 | } |
2146 | } | 2146 | } |
2147 | return false; | 2147 | return false; |
2148 | } | 2148 | } |
2149 | 2149 | ||
2150 | // key = "estateaccessdelta" | 2150 | // key = "estateaccessdelta" |
2151 | // str(estate_id) will be added to front of list by forward_EstateOwnerRequest_to_dataserver | 2151 | // str(estate_id) will be added to front of list by forward_EstateOwnerRequest_to_dataserver |
2152 | // str[0] = str(agent_id) requesting the change | 2152 | // str[0] = str(agent_id) requesting the change |
2153 | // str[1] = str(flags) (ESTATE_ACCESS_DELTA_*) | 2153 | // str[1] = str(flags) (ESTATE_ACCESS_DELTA_*) |
2154 | // str[2] = str(agent_id) to add or remove | 2154 | // str[2] = str(agent_id) to add or remove |
2155 | // static | 2155 | // static |
2156 | void LLPanelEstateInfo::sendEstateAccessDelta(U32 flags, const LLUUID& agent_or_group_id) | 2156 | void LLPanelEstateInfo::sendEstateAccessDelta(U32 flags, const LLUUID& agent_or_group_id) |
2157 | { | 2157 | { |
2158 | LLMessageSystem* msg = gMessageSystem; | 2158 | LLMessageSystem* msg = gMessageSystem; |
2159 | msg->newMessage("EstateOwnerMessage"); | 2159 | msg->newMessage("EstateOwnerMessage"); |
2160 | msg->nextBlockFast(_PREHASH_AgentData); | 2160 | msg->nextBlockFast(_PREHASH_AgentData); |
2161 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | 2161 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); |
2162 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | 2162 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); |
2163 | msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used | 2163 | msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used |
2164 | 2164 | ||
2165 | msg->nextBlock("MethodData"); | 2165 | msg->nextBlock("MethodData"); |
2166 | msg->addString("Method", "estateaccessdelta"); | 2166 | msg->addString("Method", "estateaccessdelta"); |
2167 | msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice()); | 2167 | msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice()); |
2168 | 2168 | ||
2169 | std::string buf; | 2169 | std::string buf; |
2170 | gAgent.getID().toString(buf); | 2170 | gAgent.getID().toString(buf); |
2171 | msg->nextBlock("ParamList"); | 2171 | msg->nextBlock("ParamList"); |
2172 | msg->addString("Parameter", buf); | 2172 | msg->addString("Parameter", buf); |
2173 | 2173 | ||
2174 | buf = llformat("%u", flags); | 2174 | buf = llformat("%u", flags); |
2175 | msg->nextBlock("ParamList"); | 2175 | msg->nextBlock("ParamList"); |
2176 | msg->addString("Parameter", buf); | 2176 | msg->addString("Parameter", buf); |
2177 | 2177 | ||
2178 | agent_or_group_id.toString(buf); | 2178 | agent_or_group_id.toString(buf); |
2179 | msg->nextBlock("ParamList"); | 2179 | msg->nextBlock("ParamList"); |
2180 | msg->addString("Parameter", buf); | 2180 | msg->addString("Parameter", buf); |
2181 | 2181 | ||
2182 | 2182 | ||
2183 | LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); | 2183 | LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); |
2184 | 2184 | ||
2185 | if (flags & (ESTATE_ACCESS_ALLOWED_AGENT_ADD | ESTATE_ACCESS_ALLOWED_AGENT_REMOVE | | 2185 | if (flags & (ESTATE_ACCESS_ALLOWED_AGENT_ADD | ESTATE_ACCESS_ALLOWED_AGENT_REMOVE | |
2186 | ESTATE_ACCESS_BANNED_AGENT_ADD | ESTATE_ACCESS_BANNED_AGENT_REMOVE)) | 2186 | ESTATE_ACCESS_BANNED_AGENT_ADD | ESTATE_ACCESS_BANNED_AGENT_REMOVE)) |
2187 | { | 2187 | { |
2188 | 2188 | ||
2189 | panel->clearAccessLists(); | 2189 | panel->clearAccessLists(); |
2190 | } | 2190 | } |
2191 | 2191 | ||
2192 | gAgent.sendReliableMessage(); | 2192 | gAgent.sendReliableMessage(); |
2193 | } | 2193 | } |
2194 | 2194 | ||
2195 | void LLPanelEstateInfo::updateControls(LLViewerRegion* region) | 2195 | void LLPanelEstateInfo::updateControls(LLViewerRegion* region) |
2196 | { | 2196 | { |
2197 | BOOL god = gAgent.isGodlike(); | 2197 | BOOL god = gAgent.isGodlike(); |
2198 | BOOL owner = (region && (region->getOwner() == gAgent.getID())); | 2198 | BOOL owner = (region && (region->getOwner() == gAgent.getID())); |
2199 | BOOL manager = (region && region->isEstateManager()); | 2199 | BOOL manager = (region && region->isEstateManager()); |
2200 | setCtrlsEnabled(god || owner || manager); | 2200 | setCtrlsEnabled(god || owner || manager); |
2201 | 2201 | ||
2202 | childDisable("apply_btn"); | 2202 | childDisable("apply_btn"); |
2203 | childSetEnabled("add_allowed_avatar_btn", god || owner || manager); | 2203 | childSetEnabled("add_allowed_avatar_btn", god || owner || manager); |
2204 | childSetEnabled("remove_allowed_avatar_btn", god || owner || manager); | 2204 | childSetEnabled("remove_allowed_avatar_btn", god || owner || manager); |
2205 | childSetEnabled("add_allowed_group_btn", god || owner || manager); | 2205 | childSetEnabled("add_allowed_group_btn", god || owner || manager); |
2206 | childSetEnabled("remove_allowed_group_btn", god || owner || manager); | 2206 | childSetEnabled("remove_allowed_group_btn", god || owner || manager); |
2207 | childSetEnabled("add_banned_avatar_btn", god || owner || manager); | 2207 | childSetEnabled("add_banned_avatar_btn", god || owner || manager); |
2208 | childSetEnabled("remove_banned_avatar_btn", god || owner || manager); | 2208 | childSetEnabled("remove_banned_avatar_btn", god || owner || manager); |
2209 | childSetEnabled("message_estate_btn", god || owner || manager); | 2209 | childSetEnabled("message_estate_btn", god || owner || manager); |
2210 | childSetEnabled("kick_user_from_estate_btn", god || owner || manager); | 2210 | childSetEnabled("kick_user_from_estate_btn", god || owner || manager); |
2211 | childSetEnabled("abuse_email_address", god || owner || manager); | 2211 | childSetEnabled("abuse_email_address", god || owner || manager); |
2212 | 2212 | ||
2213 | // estate managers can't add estate managers | 2213 | // estate managers can't add estate managers |
2214 | childSetEnabled("add_estate_manager_btn", god || owner); | 2214 | childSetEnabled("add_estate_manager_btn", god || owner); |
2215 | childSetEnabled("remove_estate_manager_btn", god || owner); | 2215 | childSetEnabled("remove_estate_manager_btn", god || owner); |
2216 | childSetEnabled("estate_manager_name_list", god || owner); | 2216 | childSetEnabled("estate_manager_name_list", god || owner); |
2217 | } | 2217 | } |
2218 | 2218 | ||
2219 | bool LLPanelEstateInfo::refreshFromRegion(LLViewerRegion* region) | 2219 | bool LLPanelEstateInfo::refreshFromRegion(LLViewerRegion* region) |
2220 | { | 2220 | { |
2221 | updateControls(region); | 2221 | updateControls(region); |
2222 | 2222 | ||
2223 | // let the parent class handle the general data collection. | 2223 | // let the parent class handle the general data collection. |
2224 | bool rv = LLPanelRegionInfo::refreshFromRegion(region); | 2224 | bool rv = LLPanelRegionInfo::refreshFromRegion(region); |
2225 | 2225 | ||
2226 | // We want estate info. To make sure it works across region | 2226 | // We want estate info. To make sure it works across region |
2227 | // boundaries and multiple packets, we add a serial number to the | 2227 | // boundaries and multiple packets, we add a serial number to the |
2228 | // integers and track against that on update. | 2228 | // integers and track against that on update. |
2229 | strings_t strings; | 2229 | strings_t strings; |
2230 | //integers_t integers; | 2230 | //integers_t integers; |
2231 | //LLFloaterRegionInfo::incrementSerial(); | 2231 | //LLFloaterRegionInfo::incrementSerial(); |
2232 | LLFloaterRegionInfo::nextInvoice(); | 2232 | LLFloaterRegionInfo::nextInvoice(); |
2233 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); | 2233 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); |
2234 | //integers.push_back(LLFloaterRegionInfo::());::getPanelEstate(); | 2234 | //integers.push_back(LLFloaterRegionInfo::());::getPanelEstate(); |
2235 | 2235 | ||
2236 | 2236 | ||
2237 | LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); | 2237 | LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); |
2238 | panel->clearAccessLists(); | 2238 | panel->clearAccessLists(); |
2239 | 2239 | ||
2240 | 2240 | ||
2241 | sendEstateOwnerMessage(gMessageSystem, "getinfo", invoice, strings); | 2241 | sendEstateOwnerMessage(gMessageSystem, "getinfo", invoice, strings); |
2242 | 2242 | ||
2243 | refresh(); | 2243 | refresh(); |
2244 | 2244 | ||
2245 | return rv; | 2245 | return rv; |
2246 | } | 2246 | } |
2247 | 2247 | ||
2248 | void LLPanelEstateInfo::updateChild(LLUICtrl* child_ctrl) | 2248 | void LLPanelEstateInfo::updateChild(LLUICtrl* child_ctrl) |
2249 | { | 2249 | { |
2250 | if (checkRemovalButton(child_ctrl->getName())) | 2250 | if (checkRemovalButton(child_ctrl->getName())) |
2251 | { | 2251 | { |
2252 | // do nothing | 2252 | // do nothing |
2253 | } | 2253 | } |
2254 | else if (checkSunHourSlider(child_ctrl)) | 2254 | else if (checkSunHourSlider(child_ctrl)) |
2255 | { | 2255 | { |
2256 | // do nothing | 2256 | // do nothing |
2257 | } | 2257 | } |
2258 | } | 2258 | } |
2259 | 2259 | ||
2260 | bool LLPanelEstateInfo::estateUpdate(LLMessageSystem* msg) | 2260 | bool LLPanelEstateInfo::estateUpdate(LLMessageSystem* msg) |
2261 | { | 2261 | { |
2262 | llinfos << "LLPanelEstateInfo::estateUpdate()" << llendl; | 2262 | llinfos << "LLPanelEstateInfo::estateUpdate()" << llendl; |
2263 | return false; | 2263 | return false; |
2264 | } | 2264 | } |
2265 | 2265 | ||
2266 | 2266 | ||
2267 | BOOL LLPanelEstateInfo::postBuild() | 2267 | BOOL LLPanelEstateInfo::postBuild() |
2268 | { | 2268 | { |
2269 | // set up the callbacks for the generic controls | 2269 | // set up the callbacks for the generic controls |
2270 | initCtrl("externally_visible_check"); | 2270 | initCtrl("externally_visible_check"); |
2271 | initCtrl("use_global_time_check"); | 2271 | initCtrl("use_global_time_check"); |
2272 | initCtrl("fixed_sun_check"); | 2272 | initCtrl("fixed_sun_check"); |
2273 | initCtrl("allow_direct_teleport"); | 2273 | initCtrl("allow_direct_teleport"); |
2274 | initCtrl("limit_payment"); | 2274 | initCtrl("limit_payment"); |
2275 | initCtrl("limit_age_verified"); | 2275 | initCtrl("limit_age_verified"); |
2276 | initCtrl("voice_chat_check"); | 2276 | initCtrl("voice_chat_check"); |
2277 | childSetCommitCallback("abuse_email_address", onChangeAnything, this); | 2277 | childSetCommitCallback("abuse_email_address", onChangeAnything, this); |
2278 | childSetKeystrokeCallback("abuse_email_address", onChangeText, this); | 2278 | childSetKeystrokeCallback("abuse_email_address", onChangeText, this); |
2279 | 2279 | ||
2280 | initHelpBtn("estate_manager_help", "HelpEstateEstateManager"); | 2280 | initHelpBtn("estate_manager_help", "HelpEstateEstateManager"); |
2281 | initHelpBtn("use_global_time_help", "HelpEstateUseGlobalTime"); | 2281 | initHelpBtn("use_global_time_help", "HelpEstateUseGlobalTime"); |
2282 | initHelpBtn("fixed_sun_help", "HelpEstateFixedSun"); | 2282 | initHelpBtn("fixed_sun_help", "HelpEstateFixedSun"); |
2283 | initHelpBtn("WLEditSkyHelp", "HelpEditSky"); | 2283 | initHelpBtn("WLEditSkyHelp", "HelpEditSky"); |
2284 | initHelpBtn("WLEditDayCycleHelp", "HelpEditDayCycle"); | 2284 | initHelpBtn("WLEditDayCycleHelp", "HelpEditDayCycle"); |
2285 | 2285 | ||
2286 | initHelpBtn("externally_visible_help", "HelpEstateExternallyVisible"); | 2286 | initHelpBtn("externally_visible_help", "HelpEstateExternallyVisible"); |
2287 | initHelpBtn("allow_direct_teleport_help", "HelpEstateAllowDirectTeleport"); | 2287 | initHelpBtn("allow_direct_teleport_help", "HelpEstateAllowDirectTeleport"); |
2288 | initHelpBtn("allow_resident_help", "HelpEstateAllowResident"); | 2288 | initHelpBtn("allow_resident_help", "HelpEstateAllowResident"); |
2289 | initHelpBtn("allow_group_help", "HelpEstateAllowGroup"); | 2289 | initHelpBtn("allow_group_help", "HelpEstateAllowGroup"); |
2290 | initHelpBtn("ban_resident_help", "HelpEstateBanResident"); | 2290 | initHelpBtn("ban_resident_help", "HelpEstateBanResident"); |
2291 | initHelpBtn("abuse_email_address_help", "HelpEstateAbuseEmailAddress"); | 2291 | initHelpBtn("abuse_email_address_help", "HelpEstateAbuseEmailAddress"); |
2292 | initHelpBtn("voice_chat_help", "HelpEstateVoiceChat"); | 2292 | initHelpBtn("voice_chat_help", "HelpEstateVoiceChat"); |
2293 | 2293 | ||
2294 | // set up the use global time checkbox | 2294 | // set up the use global time checkbox |
2295 | childSetCommitCallback("use_global_time_check", onChangeUseGlobalTime, this); | 2295 | childSetCommitCallback("use_global_time_check", onChangeUseGlobalTime, this); |
2296 | childSetCommitCallback("fixed_sun_check", onChangeFixedSun, this); | 2296 | childSetCommitCallback("fixed_sun_check", onChangeFixedSun, this); |
2297 | childSetCommitCallback("sun_hour_slider", onChangeChildCtrl, this); | 2297 | childSetCommitCallback("sun_hour_slider", onChangeChildCtrl, this); |
2298 | 2298 | ||
2299 | childSetCommitCallback("allowed_avatar_name_list", onChangeChildCtrl, this); | 2299 | childSetCommitCallback("allowed_avatar_name_list", onChangeChildCtrl, this); |
2300 | LLNameListCtrl *avatar_name_list = getChild<LLNameListCtrl>("allowed_avatar_name_list"); | 2300 | LLNameListCtrl *avatar_name_list = getChild<LLNameListCtrl>("allowed_avatar_name_list"); |
2301 | if (avatar_name_list) | 2301 | if (avatar_name_list) |
2302 | { | 2302 | { |
2303 | avatar_name_list->setCommitOnSelectionChange(TRUE); | 2303 | avatar_name_list->setCommitOnSelectionChange(TRUE); |
2304 | avatar_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS); | 2304 | avatar_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS); |
2305 | } | 2305 | } |
2306 | 2306 | ||
2307 | childSetAction("add_allowed_avatar_btn", onClickAddAllowedAgent, this); | 2307 | childSetAction("add_allowed_avatar_btn", onClickAddAllowedAgent, this); |
2308 | childSetAction("remove_allowed_avatar_btn", onClickRemoveAllowedAgent, this); | 2308 | childSetAction("remove_allowed_avatar_btn", onClickRemoveAllowedAgent, this); |
2309 | 2309 | ||
2310 | childSetCommitCallback("allowed_group_name_list", onChangeChildCtrl, this); | 2310 | childSetCommitCallback("allowed_group_name_list", onChangeChildCtrl, this); |
2311 | LLNameListCtrl* group_name_list = getChild<LLNameListCtrl>("allowed_group_name_list"); | 2311 | LLNameListCtrl* group_name_list = getChild<LLNameListCtrl>("allowed_group_name_list"); |
2312 | if (group_name_list) | 2312 | if (group_name_list) |
2313 | { | 2313 | { |
2314 | group_name_list->setCommitOnSelectionChange(TRUE); | 2314 | group_name_list->setCommitOnSelectionChange(TRUE); |
2315 | group_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS); | 2315 | group_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS); |
2316 | } | 2316 | } |
2317 | 2317 | ||
2318 | childSetAction("add_allowed_group_btn", onClickAddAllowedGroup, this); | 2318 | childSetAction("add_allowed_group_btn", onClickAddAllowedGroup, this); |
2319 | childSetAction("remove_allowed_group_btn", onClickRemoveAllowedGroup, this); | 2319 | childSetAction("remove_allowed_group_btn", onClickRemoveAllowedGroup, this); |
2320 | 2320 | ||
2321 | childSetCommitCallback("banned_avatar_name_list", onChangeChildCtrl, this); | 2321 | childSetCommitCallback("banned_avatar_name_list", onChangeChildCtrl, this); |
2322 | LLNameListCtrl* banned_name_list = getChild<LLNameListCtrl>("banned_avatar_name_list"); | 2322 | LLNameListCtrl* banned_name_list = getChild<LLNameListCtrl>("banned_avatar_name_list"); |
2323 | if (banned_name_list) | 2323 | if (banned_name_list) |
2324 | { | 2324 | { |
2325 | banned_name_list->setCommitOnSelectionChange(TRUE); | 2325 | banned_name_list->setCommitOnSelectionChange(TRUE); |
2326 | banned_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS); | 2326 | banned_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS); |
2327 | } | 2327 | } |
2328 | 2328 | ||
2329 | childSetAction("add_banned_avatar_btn", onClickAddBannedAgent, this); | 2329 | childSetAction("add_banned_avatar_btn", onClickAddBannedAgent, this); |
2330 | childSetAction("remove_banned_avatar_btn", onClickRemoveBannedAgent, this); | 2330 | childSetAction("remove_banned_avatar_btn", onClickRemoveBannedAgent, this); |
2331 | 2331 | ||
2332 | childSetCommitCallback("estate_manager_name_list", onChangeChildCtrl, this); | 2332 | childSetCommitCallback("estate_manager_name_list", onChangeChildCtrl, this); |
2333 | LLNameListCtrl* manager_name_list = getChild<LLNameListCtrl>("estate_manager_name_list"); | 2333 | LLNameListCtrl* manager_name_list = getChild<LLNameListCtrl>("estate_manager_name_list"); |
2334 | if (manager_name_list) | 2334 | if (manager_name_list) |
2335 | { | 2335 | { |
2336 | manager_name_list->setCommitOnSelectionChange(TRUE); | 2336 | manager_name_list->setCommitOnSelectionChange(TRUE); |
2337 | manager_name_list->setMaxItemCount(ESTATE_MAX_MANAGERS * 4); // Allow extras for dupe issue | 2337 | manager_name_list->setMaxItemCount(ESTATE_MAX_MANAGERS * 4); // Allow extras for dupe issue |
2338 | } | 2338 | } |
2339 | 2339 | ||
2340 | childSetAction("add_estate_manager_btn", onClickAddEstateManager, this); | 2340 | childSetAction("add_estate_manager_btn", onClickAddEstateManager, this); |
2341 | childSetAction("remove_estate_manager_btn", onClickRemoveEstateManager, this); | 2341 | childSetAction("remove_estate_manager_btn", onClickRemoveEstateManager, this); |
2342 | childSetAction("message_estate_btn", onClickMessageEstate, this); | 2342 | childSetAction("message_estate_btn", onClickMessageEstate, this); |
2343 | childSetAction("kick_user_from_estate_btn", onClickKickUser, this); | 2343 | childSetAction("kick_user_from_estate_btn", onClickKickUser, this); |
2344 | 2344 | ||
2345 | childSetAction("WLEditSky", onClickEditSky, this); | 2345 | childSetAction("WLEditSky", onClickEditSky, this); |
2346 | childSetAction("WLEditDayCycle", onClickEditDayCycle, this); | 2346 | childSetAction("WLEditDayCycle", onClickEditDayCycle, this); |
2347 | 2347 | ||
2348 | return LLPanelRegionInfo::postBuild(); | 2348 | return LLPanelRegionInfo::postBuild(); |
2349 | } | 2349 | } |
2350 | 2350 | ||
2351 | void LLPanelEstateInfo::refresh() | 2351 | void LLPanelEstateInfo::refresh() |
2352 | { | 2352 | { |
2353 | bool public_access = childGetValue("externally_visible_check").asBoolean(); | 2353 | bool public_access = childGetValue("externally_visible_check").asBoolean(); |
2354 | childSetEnabled("Only Allow", public_access); | 2354 | childSetEnabled("Only Allow", public_access); |
2355 | childSetEnabled("limit_payment", public_access); | 2355 | childSetEnabled("limit_payment", public_access); |
2356 | childSetEnabled("limit_age_verified", public_access); | 2356 | childSetEnabled("limit_age_verified", public_access); |
2357 | // if this is set to false, then the limit fields are meaningless and should be turned off | 2357 | // if this is set to false, then the limit fields are meaningless and should be turned off |
2358 | if (public_access == false) | 2358 | if (public_access == false) |
2359 | { | 2359 | { |
2360 | childSetValue("limit_payment", false); | 2360 | childSetValue("limit_payment", false); |
2361 | childSetValue("limit_age_verified", false); | 2361 | childSetValue("limit_age_verified", false); |
2362 | } | 2362 | } |
2363 | } | 2363 | } |
2364 | 2364 | ||
2365 | BOOL LLPanelEstateInfo::sendUpdate() | 2365 | BOOL LLPanelEstateInfo::sendUpdate() |
2366 | { | 2366 | { |
2367 | llinfos << "LLPanelEsateInfo::sendUpdate()" << llendl; | 2367 | llinfos << "LLPanelEsateInfo::sendUpdate()" << llendl; |
2368 | 2368 | ||
2369 | LLNotification::Params params("ChangeLindenEstate"); | 2369 | LLNotification::Params params("ChangeLindenEstate"); |
2370 | params.functor(boost::bind(&LLPanelEstateInfo::callbackChangeLindenEstate, this, _1, _2)); | 2370 | params.functor(boost::bind(&LLPanelEstateInfo::callbackChangeLindenEstate, this, _1, _2)); |
2371 | 2371 | ||
2372 | if (getEstateID() <= ESTATE_LAST_LINDEN) | 2372 | if (getEstateID() <= ESTATE_LAST_LINDEN) |
2373 | { | 2373 | { |
2374 | // trying to change reserved estate, warn | 2374 | // trying to change reserved estate, warn |
2375 | LLNotifications::instance().add(params); | 2375 | LLNotifications::instance().add(params); |
2376 | } | 2376 | } |
2377 | else | 2377 | else |
2378 | { | 2378 | { |
2379 | // for normal estates, just make the change | 2379 | // for normal estates, just make the change |
2380 | LLNotifications::instance().forceResponse(params, 0); | 2380 | LLNotifications::instance().forceResponse(params, 0); |
2381 | } | 2381 | } |
2382 | return TRUE; | 2382 | return TRUE; |
2383 | } | 2383 | } |
2384 | 2384 | ||
2385 | bool LLPanelEstateInfo::callbackChangeLindenEstate(const LLSD& notification, const LLSD& response) | 2385 | bool LLPanelEstateInfo::callbackChangeLindenEstate(const LLSD& notification, const LLSD& response) |
2386 | { | 2386 | { |
2387 | S32 option = LLNotification::getSelectedOption(notification, response); | 2387 | S32 option = LLNotification::getSelectedOption(notification, response); |
2388 | switch(option) | 2388 | switch(option) |
2389 | { | 2389 | { |
2390 | case 0: | 2390 | case 0: |
2391 | // send the update | 2391 | // send the update |
2392 | if (!commitEstateInfoCaps()) | 2392 | if (!commitEstateInfoCaps()) |
2393 | { | 2393 | { |
2394 | // the caps method failed, try the old way | 2394 | // the caps method failed, try the old way |
2395 | LLFloaterRegionInfo::nextInvoice(); | 2395 | LLFloaterRegionInfo::nextInvoice(); |
2396 | commitEstateInfoDataserver(); | 2396 | commitEstateInfoDataserver(); |
2397 | } | 2397 | } |
2398 | // we don't want to do this because we'll get it automatically from the sim | 2398 | // we don't want to do this because we'll get it automatically from the sim |
2399 | // after the spaceserver processes it | 2399 | // after the spaceserver processes it |
2400 | // else | 2400 | // else |
2401 | // { | 2401 | // { |
2402 | // // caps method does not automatically send this info | 2402 | // // caps method does not automatically send this info |
2403 | // LLFloaterRegionInfo::requestRegionInfo(); | 2403 | // LLFloaterRegionInfo::requestRegionInfo(); |
2404 | // } | 2404 | // } |
2405 | break; | 2405 | break; |
2406 | case 1: | 2406 | case 1: |
2407 | default: | 2407 | default: |
2408 | // do nothing | 2408 | // do nothing |
2409 | break; | 2409 | break; |
2410 | } | 2410 | } |
2411 | return false; | 2411 | return false; |
2412 | } | 2412 | } |
2413 | 2413 | ||
2414 | 2414 | ||
2415 | /* | 2415 | /* |
2416 | // Request = "getowner" | 2416 | // Request = "getowner" |
2417 | // SParam[0] = "" (empty string) | 2417 | // SParam[0] = "" (empty string) |
2418 | // IParam[0] = serial | 2418 | // IParam[0] = serial |
2419 | void LLPanelEstateInfo::getEstateOwner() | 2419 | void LLPanelEstateInfo::getEstateOwner() |
2420 | { | 2420 | { |
2421 | // TODO -- disable the panel | 2421 | // TODO -- disable the panel |
2422 | // and call this function whenever we cross a region boundary | 2422 | // and call this function whenever we cross a region boundary |
2423 | // re-enable when owner matches, and get new estate info | 2423 | // re-enable when owner matches, and get new estate info |
2424 | LLMessageSystem* msg = gMessageSystem; | 2424 | LLMessageSystem* msg = gMessageSystem; |
2425 | msg->newMessageFast(_PREHASH_EstateOwnerRequest); | 2425 | msg->newMessageFast(_PREHASH_EstateOwnerRequest); |
2426 | msg->nextBlockFast(_PREHASH_AgentData); | 2426 | msg->nextBlockFast(_PREHASH_AgentData); |
2427 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | 2427 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); |
2428 | 2428 | ||
2429 | msg->nextBlockFast(_PREHASH_RequestData); | 2429 | msg->nextBlockFast(_PREHASH_RequestData); |
2430 | msg->addStringFast(_PREHASH_Request, "getowner"); | 2430 | msg->addStringFast(_PREHASH_Request, "getowner"); |
2431 | 2431 | ||
2432 | // we send an empty string so that the variable block is not empty | 2432 | // we send an empty string so that the variable block is not empty |
2433 | msg->nextBlockFast(_PREHASH_StringData); | 2433 | msg->nextBlockFast(_PREHASH_StringData); |
2434 | msg->addStringFast(_PREHASH_SParam, ""); | 2434 | msg->addStringFast(_PREHASH_SParam, ""); |
2435 | 2435 | ||
2436 | msg->nextBlockFast(_PREHASH_IntegerData); | 2436 | msg->nextBlockFast(_PREHASH_IntegerData); |
2437 | msg->addS32Fast(_PREHASH_IParam, LLFloaterRegionInfo::getSerial()); | 2437 | msg->addS32Fast(_PREHASH_IParam, LLFloaterRegionInfo::getSerial()); |
2438 | 2438 | ||
2439 | gAgent.sendMessage(); | 2439 | gAgent.sendMessage(); |
2440 | } | 2440 | } |
2441 | */ | 2441 | */ |
2442 | 2442 | ||
2443 | class LLEstateChangeInfoResponder : public LLHTTPClient::Responder | 2443 | class LLEstateChangeInfoResponder : public LLHTTPClient::Responder |
2444 | { | 2444 | { |
2445 | public: | 2445 | public: |
2446 | LLEstateChangeInfoResponder(void* userdata) : mpPanel((LLPanelEstateInfo*)userdata) {}; | 2446 | LLEstateChangeInfoResponder(void* userdata) : mpPanel((LLPanelEstateInfo*)userdata) {}; |
2447 | 2447 | ||
2448 | // if we get a normal response, handle it here | 2448 | // if we get a normal response, handle it here |
2449 | virtual void result(const LLSD& content) | 2449 | virtual void result(const LLSD& content) |
2450 | { | 2450 | { |
2451 | // refresh the panel from the database | 2451 | // refresh the panel from the database |
2452 | mpPanel->refresh(); | 2452 | mpPanel->refresh(); |
2453 | } | 2453 | } |
2454 | 2454 | ||
2455 | // if we get an error response | 2455 | // if we get an error response |
2456 | virtual void error(U32 status, const std::string& reason) | 2456 | virtual void error(U32 status, const std::string& reason) |
2457 | { | 2457 | { |
2458 | llinfos << "LLEstateChangeInfoResponder::error " | 2458 | llinfos << "LLEstateChangeInfoResponder::error " |
2459 | << status << ": " << reason << llendl; | 2459 | << status << ": " << reason << llendl; |
2460 | } | 2460 | } |
2461 | private: | 2461 | private: |
2462 | LLPanelEstateInfo* mpPanel; | 2462 | LLPanelEstateInfo* mpPanel; |
2463 | }; | 2463 | }; |
2464 | 2464 | ||
2465 | // tries to send estate info using a cap; returns true if it succeeded | 2465 | // tries to send estate info using a cap; returns true if it succeeded |
2466 | bool LLPanelEstateInfo::commitEstateInfoCaps() | 2466 | bool LLPanelEstateInfo::commitEstateInfoCaps() |
2467 | { | 2467 | { |
2468 | std::string url = gAgent.getRegion()->getCapability("EstateChangeInfo"); | 2468 | std::string url = gAgent.getRegion()->getCapability("EstateChangeInfo"); |
2469 | 2469 | ||
2470 | if (url.empty()) | 2470 | if (url.empty()) |
2471 | { | 2471 | { |
2472 | // whoops, couldn't find the cap, so bail out | 2472 | // whoops, couldn't find the cap, so bail out |
2473 | return false; | 2473 | return false; |
2474 | } | 2474 | } |
2475 | 2475 | ||
2476 | LLSD body; | 2476 | LLSD body; |
2477 | body["estate_name"] = getEstateName(); | 2477 | body["estate_name"] = getEstateName(); |
2478 | 2478 | ||
2479 | body["is_externally_visible"] = childGetValue("externally_visible_check").asBoolean(); | 2479 | body["is_externally_visible"] = childGetValue("externally_visible_check").asBoolean(); |
2480 | body["allow_direct_teleport"] = childGetValue("allow_direct_teleport").asBoolean(); | 2480 | body["allow_direct_teleport"] = childGetValue("allow_direct_teleport").asBoolean(); |
2481 | body["is_sun_fixed" ] = childGetValue("fixed_sun_check").asBoolean(); | 2481 | body["is_sun_fixed" ] = childGetValue("fixed_sun_check").asBoolean(); |
2482 | body["deny_anonymous" ] = childGetValue("limit_payment").asBoolean(); | 2482 | body["deny_anonymous" ] = childGetValue("limit_payment").asBoolean(); |
2483 | body["deny_age_unverified" ] = childGetValue("limit_age_verified").asBoolean(); | 2483 | body["deny_age_unverified" ] = childGetValue("limit_age_verified").asBoolean(); |
2484 | body["allow_voice_chat" ] = childGetValue("voice_chat_check").asBoolean(); | 2484 | body["allow_voice_chat" ] = childGetValue("voice_chat_check").asBoolean(); |
2485 | body["invoice" ] = LLFloaterRegionInfo::getLastInvoice(); | 2485 | body["invoice" ] = LLFloaterRegionInfo::getLastInvoice(); |
2486 | 2486 | ||
2487 | // block fly is in estate database but not in estate UI, so we're not supporting it | 2487 | // block fly is in estate database but not in estate UI, so we're not supporting it |
2488 | //body["block_fly" ] = childGetValue("").asBoolean(); | 2488 | //body["block_fly" ] = childGetValue("").asBoolean(); |
2489 | 2489 | ||
2490 | F32 sun_hour = getSunHour(); | 2490 | F32 sun_hour = getSunHour(); |
2491 | if (childGetValue("use_global_time_check").asBoolean()) | 2491 | if (childGetValue("use_global_time_check").asBoolean()) |
2492 | { | 2492 | { |
2493 | sun_hour = 0.f; // 0 = global time | 2493 | sun_hour = 0.f; // 0 = global time |
2494 | } | 2494 | } |
2495 | body["sun_hour"] = sun_hour; | 2495 | body["sun_hour"] = sun_hour; |
2496 | 2496 | ||
2497 | body["owner_abuse_email"] = childGetValue("abuse_email_address").asString(); | 2497 | body["owner_abuse_email"] = childGetValue("abuse_email_address").asString(); |
2498 | 2498 | ||
2499 | // we use a responder so that we can re-get the data after committing to the database | 2499 | // we use a responder so that we can re-get the data after committing to the database |
2500 | LLHTTPClient::post(url, body, new LLEstateChangeInfoResponder((void*)this)); | 2500 | LLHTTPClient::post(url, body, new LLEstateChangeInfoResponder((void*)this)); |
2501 | return true; | 2501 | return true; |
2502 | } | 2502 | } |
2503 | 2503 | ||
2504 | /* This is the old way of doing things, is deprecated, and should be | 2504 | /* This is the old way of doing things, is deprecated, and should be |
2505 | deleted when the dataserver model can be removed */ | 2505 | deleted when the dataserver model can be removed */ |
2506 | // key = "estatechangeinfo" | 2506 | // key = "estatechangeinfo" |
2507 | // strings[0] = str(estate_id) (added by simulator before relay - not here) | 2507 | // strings[0] = str(estate_id) (added by simulator before relay - not here) |
2508 | // strings[1] = estate_name | 2508 | // strings[1] = estate_name |
2509 | // strings[2] = str(estate_flags) | 2509 | // strings[2] = str(estate_flags) |
2510 | // strings[3] = str((S32)(sun_hour * 1024.f)) | 2510 | // strings[3] = str((S32)(sun_hour * 1024.f)) |
2511 | void LLPanelEstateInfo::commitEstateInfoDataserver() | 2511 | void LLPanelEstateInfo::commitEstateInfoDataserver() |
2512 | { | 2512 | { |
2513 | LLMessageSystem* msg = gMessageSystem; | 2513 | LLMessageSystem* msg = gMessageSystem; |
2514 | msg->newMessage("EstateOwnerMessage"); | 2514 | msg->newMessage("EstateOwnerMessage"); |
2515 | msg->nextBlockFast(_PREHASH_AgentData); | 2515 | msg->nextBlockFast(_PREHASH_AgentData); |
2516 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | 2516 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); |
2517 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | 2517 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); |
2518 | msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used | 2518 | msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used |
2519 | 2519 | ||
2520 | msg->nextBlock("MethodData"); | 2520 | msg->nextBlock("MethodData"); |
2521 | msg->addString("Method", "estatechangeinfo"); | 2521 | msg->addString("Method", "estatechangeinfo"); |
2522 | msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice()); | 2522 | msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice()); |
2523 | 2523 | ||
2524 | msg->nextBlock("ParamList"); | 2524 | msg->nextBlock("ParamList"); |
2525 | msg->addString("Parameter", getEstateName()); | 2525 | msg->addString("Parameter", getEstateName()); |
2526 | 2526 | ||
2527 | std::string buffer; | 2527 | std::string buffer; |
2528 | buffer = llformat("%u", computeEstateFlags()); | 2528 | buffer = llformat("%u", computeEstateFlags()); |
2529 | msg->nextBlock("ParamList"); | 2529 | msg->nextBlock("ParamList"); |
2530 | msg->addString("Parameter", buffer); | 2530 | msg->addString("Parameter", buffer); |
2531 | 2531 | ||
2532 | F32 sun_hour = getSunHour(); | 2532 | F32 sun_hour = getSunHour(); |
2533 | if (childGetValue("use_global_time_check").asBoolean()) | 2533 | if (childGetValue("use_global_time_check").asBoolean()) |
2534 | { | 2534 | { |
2535 | sun_hour = 0.f; // 0 = global time | 2535 | sun_hour = 0.f; // 0 = global time |
2536 | } | 2536 | } |
2537 | 2537 | ||
2538 | buffer = llformat("%d", (S32)(sun_hour*1024.0f)); | 2538 | buffer = llformat("%d", (S32)(sun_hour*1024.0f)); |
2539 | msg->nextBlock("ParamList"); | 2539 | msg->nextBlock("ParamList"); |
2540 | msg->addString("Parameter", buffer); | 2540 | msg->addString("Parameter", buffer); |
2541 | 2541 | ||
2542 | gAgent.sendMessage(); | 2542 | gAgent.sendMessage(); |
2543 | } | 2543 | } |
2544 | 2544 | ||
2545 | void LLPanelEstateInfo::setEstateFlags(U32 flags) | 2545 | void LLPanelEstateInfo::setEstateFlags(U32 flags) |
2546 | { | 2546 | { |
2547 | childSetValue("externally_visible_check", LLSD(flags & REGION_FLAGS_EXTERNALLY_VISIBLE ? TRUE : FALSE) ); | 2547 | childSetValue("externally_visible_check", LLSD(flags & REGION_FLAGS_EXTERNALLY_VISIBLE ? TRUE : FALSE) ); |
2548 | childSetValue("fixed_sun_check", LLSD(flags & REGION_FLAGS_SUN_FIXED ? TRUE : FALSE) ); | 2548 | childSetValue("fixed_sun_check", LLSD(flags & REGION_FLAGS_SUN_FIXED ? TRUE : FALSE) ); |
2549 | childSetValue( | 2549 | childSetValue( |
2550 | "voice_chat_check", | 2550 | "voice_chat_check", |
2551 | LLSD(flags & REGION_FLAGS_ALLOW_VOICE ? TRUE : FALSE)); | 2551 | LLSD(flags & REGION_FLAGS_ALLOW_VOICE ? TRUE : FALSE)); |
2552 | childSetValue("allow_direct_teleport", LLSD(flags & REGION_FLAGS_ALLOW_DIRECT_TELEPORT ? TRUE : FALSE) ); | 2552 | childSetValue("allow_direct_teleport", LLSD(flags & REGION_FLAGS_ALLOW_DIRECT_TELEPORT ? TRUE : FALSE) ); |
2553 | childSetValue("limit_payment", LLSD(flags & REGION_FLAGS_DENY_ANONYMOUS ? TRUE : FALSE) ); | 2553 | childSetValue("limit_payment", LLSD(flags & REGION_FLAGS_DENY_ANONYMOUS ? TRUE : FALSE) ); |
2554 | childSetValue("limit_age_verified", LLSD(flags & REGION_FLAGS_DENY_AGEUNVERIFIED ? TRUE : FALSE) ); | 2554 | childSetValue("limit_age_verified", LLSD(flags & REGION_FLAGS_DENY_AGEUNVERIFIED ? TRUE : FALSE) ); |
2555 | 2555 | ||
2556 | refresh(); | 2556 | refresh(); |
2557 | } | 2557 | } |
2558 | 2558 | ||
2559 | U32 LLPanelEstateInfo::computeEstateFlags() | 2559 | U32 LLPanelEstateInfo::computeEstateFlags() |
2560 | { | 2560 | { |
2561 | U32 flags = 0; | 2561 | U32 flags = 0; |
2562 | 2562 | ||
2563 | if (childGetValue("externally_visible_check").asBoolean()) | 2563 | if (childGetValue("externally_visible_check").asBoolean()) |
2564 | { | 2564 | { |
2565 | flags |= REGION_FLAGS_EXTERNALLY_VISIBLE; | 2565 | flags |= REGION_FLAGS_EXTERNALLY_VISIBLE; |
2566 | } | 2566 | } |
2567 | 2567 | ||
2568 | if ( childGetValue("voice_chat_check").asBoolean() ) | 2568 | if ( childGetValue("voice_chat_check").asBoolean() ) |
2569 | { | 2569 | { |
2570 | flags |= REGION_FLAGS_ALLOW_VOICE; | 2570 | flags |= REGION_FLAGS_ALLOW_VOICE; |
2571 | } | 2571 | } |
2572 | 2572 | ||
2573 | if (childGetValue("allow_direct_teleport").asBoolean()) | 2573 | if (childGetValue("allow_direct_teleport").asBoolean()) |
2574 | { | 2574 | { |
2575 | flags |= REGION_FLAGS_ALLOW_DIRECT_TELEPORT; | 2575 | flags |= REGION_FLAGS_ALLOW_DIRECT_TELEPORT; |
2576 | } | 2576 | } |
2577 | 2577 | ||
2578 | if (childGetValue("fixed_sun_check").asBoolean()) | 2578 | if (childGetValue("fixed_sun_check").asBoolean()) |
2579 | { | 2579 | { |
2580 | flags |= REGION_FLAGS_SUN_FIXED; | 2580 | flags |= REGION_FLAGS_SUN_FIXED; |
2581 | } | 2581 | } |
2582 | 2582 | ||
2583 | if (childGetValue("limit_payment").asBoolean()) | 2583 | if (childGetValue("limit_payment").asBoolean()) |
2584 | { | 2584 | { |
2585 | flags |= REGION_FLAGS_DENY_ANONYMOUS; | 2585 | flags |= REGION_FLAGS_DENY_ANONYMOUS; |
2586 | } | 2586 | } |
2587 | 2587 | ||
2588 | if (childGetValue("limit_age_verified").asBoolean()) | 2588 | if (childGetValue("limit_age_verified").asBoolean()) |
2589 | { | 2589 | { |
2590 | flags |= REGION_FLAGS_DENY_AGEUNVERIFIED; | 2590 | flags |= REGION_FLAGS_DENY_AGEUNVERIFIED; |
2591 | } | 2591 | } |
2592 | 2592 | ||
2593 | 2593 | ||
2594 | return flags; | 2594 | return flags; |
2595 | } | 2595 | } |
2596 | 2596 | ||
2597 | BOOL LLPanelEstateInfo::getGlobalTime() | 2597 | BOOL LLPanelEstateInfo::getGlobalTime() |
2598 | { | 2598 | { |
2599 | return childGetValue("use_global_time_check").asBoolean(); | 2599 | return childGetValue("use_global_time_check").asBoolean(); |
2600 | } | 2600 | } |
2601 | 2601 | ||
2602 | void LLPanelEstateInfo::setGlobalTime(bool b) | 2602 | void LLPanelEstateInfo::setGlobalTime(bool b) |
2603 | { | 2603 | { |
2604 | childSetValue("use_global_time_check", LLSD(b)); | 2604 | childSetValue("use_global_time_check", LLSD(b)); |
2605 | childSetEnabled("fixed_sun_check", LLSD(!b)); | 2605 | childSetEnabled("fixed_sun_check", LLSD(!b)); |
2606 | childSetEnabled("sun_hour_slider", LLSD(!b)); | 2606 | childSetEnabled("sun_hour_slider", LLSD(!b)); |
2607 | if (b) | 2607 | if (b) |
2608 | { | 2608 | { |
2609 | childSetValue("sun_hour_slider", LLSD(0.f)); | 2609 | childSetValue("sun_hour_slider", LLSD(0.f)); |
2610 | } | 2610 | } |
2611 | } | 2611 | } |
2612 | 2612 | ||
2613 | 2613 | ||
2614 | BOOL LLPanelEstateInfo::getFixedSun() | 2614 | BOOL LLPanelEstateInfo::getFixedSun() |
2615 | { | 2615 | { |
2616 | return childGetValue("fixed_sun_check").asBoolean(); | 2616 | return childGetValue("fixed_sun_check").asBoolean(); |
2617 | } | 2617 | } |
2618 | 2618 | ||
2619 | void LLPanelEstateInfo::setSunHour(F32 sun_hour) | 2619 | void LLPanelEstateInfo::setSunHour(F32 sun_hour) |
2620 | { | 2620 | { |
2621 | if(sun_hour < 6.0f) | 2621 | if(sun_hour < 6.0f) |
2622 | { | 2622 | { |
2623 | sun_hour = 24.0f + sun_hour; | 2623 | sun_hour = 24.0f + sun_hour; |
2624 | } | 2624 | } |
2625 | childSetValue("sun_hour_slider", LLSD(sun_hour)); | 2625 | childSetValue("sun_hour_slider", LLSD(sun_hour)); |
2626 | } | 2626 | } |
2627 | 2627 | ||
2628 | F32 LLPanelEstateInfo::getSunHour() | 2628 | F32 LLPanelEstateInfo::getSunHour() |
2629 | { | 2629 | { |
2630 | if (childIsEnabled("sun_hour_slider")) | 2630 | if (childIsEnabled("sun_hour_slider")) |
2631 | { | 2631 | { |
2632 | return (F32)childGetValue("sun_hour_slider").asReal(); | 2632 | return (F32)childGetValue("sun_hour_slider").asReal(); |
2633 | } | 2633 | } |
2634 | return 0.f; | 2634 | return 0.f; |
2635 | } | 2635 | } |
2636 | 2636 | ||
2637 | const std::string LLPanelEstateInfo::getEstateName() const | 2637 | const std::string LLPanelEstateInfo::getEstateName() const |
2638 | { | 2638 | { |
2639 | return childGetValue("estate_name").asString(); | 2639 | return childGetValue("estate_name").asString(); |
2640 | } | 2640 | } |
2641 | 2641 | ||
2642 | void LLPanelEstateInfo::setEstateName(const std::string& name) | 2642 | void LLPanelEstateInfo::setEstateName(const std::string& name) |
2643 | { | 2643 | { |
2644 | childSetValue("estate_name", LLSD(name)); | 2644 | childSetValue("estate_name", LLSD(name)); |
2645 | } | 2645 | } |
2646 | 2646 | ||
2647 | const std::string LLPanelEstateInfo::getOwnerName() const | 2647 | const std::string LLPanelEstateInfo::getOwnerName() const |
2648 | { | 2648 | { |
2649 | return childGetValue("estate_owner").asString(); | 2649 | return childGetValue("estate_owner").asString(); |
2650 | } | 2650 | } |
2651 | 2651 | ||
2652 | void LLPanelEstateInfo::setOwnerName(const std::string& name) | 2652 | void LLPanelEstateInfo::setOwnerName(const std::string& name) |
2653 | { | 2653 | { |
2654 | childSetValue("estate_owner", LLSD(name)); | 2654 | childSetValue("estate_owner", LLSD(name)); |
2655 | } | 2655 | } |
2656 | 2656 | ||
2657 | const std::string LLPanelEstateInfo::getAbuseEmailAddress() const | 2657 | const std::string LLPanelEstateInfo::getAbuseEmailAddress() const |
2658 | { | 2658 | { |
2659 | return childGetValue("abuse_email_address").asString(); | 2659 | return childGetValue("abuse_email_address").asString(); |
2660 | } | 2660 | } |
2661 | 2661 | ||
2662 | void LLPanelEstateInfo::setAbuseEmailAddress(const std::string& address) | 2662 | void LLPanelEstateInfo::setAbuseEmailAddress(const std::string& address) |
2663 | { | 2663 | { |
2664 | childSetValue("abuse_email_address", LLSD(address)); | 2664 | childSetValue("abuse_email_address", LLSD(address)); |
2665 | } | 2665 | } |
2666 | 2666 | ||
2667 | void LLPanelEstateInfo::setAccessAllowedEnabled(bool enable_agent, | 2667 | void LLPanelEstateInfo::setAccessAllowedEnabled(bool enable_agent, |
2668 | bool enable_group, | 2668 | bool enable_group, |
2669 | bool enable_ban) | 2669 | bool enable_ban) |
2670 | { | 2670 | { |
2671 | childSetEnabled("allow_resident_label", enable_agent); | 2671 | childSetEnabled("allow_resident_label", enable_agent); |
2672 | childSetEnabled("allowed_avatar_name_list", enable_agent); | 2672 | childSetEnabled("allowed_avatar_name_list", enable_agent); |
2673 | childSetVisible("allowed_avatar_name_list", enable_agent); | 2673 | childSetVisible("allowed_avatar_name_list", enable_agent); |
2674 | childSetEnabled("add_allowed_avatar_btn", enable_agent); | 2674 | childSetEnabled("add_allowed_avatar_btn", enable_agent); |
2675 | childSetEnabled("remove_allowed_avatar_btn", enable_agent); | 2675 | childSetEnabled("remove_allowed_avatar_btn", enable_agent); |
2676 | 2676 | ||
2677 | // Groups | 2677 | // Groups |
2678 | childSetEnabled("allow_group_label", enable_group); | 2678 | childSetEnabled("allow_group_label", enable_group); |
2679 | childSetEnabled("allowed_group_name_list", enable_group); | 2679 | childSetEnabled("allowed_group_name_list", enable_group); |
2680 | childSetVisible("allowed_group_name_list", enable_group); | 2680 | childSetVisible("allowed_group_name_list", enable_group); |
2681 | childSetEnabled("add_allowed_group_btn", enable_group); | 2681 | childSetEnabled("add_allowed_group_btn", enable_group); |
2682 | childSetEnabled("remove_allowed_group_btn", enable_group); | 2682 | childSetEnabled("remove_allowed_group_btn", enable_group); |
2683 | 2683 | ||
2684 | // Ban | 2684 | // Ban |
2685 | childSetEnabled("ban_resident_label", enable_ban); | 2685 | childSetEnabled("ban_resident_label", enable_ban); |
2686 | childSetEnabled("banned_avatar_name_list", enable_ban); | 2686 | childSetEnabled("banned_avatar_name_list", enable_ban); |
2687 | childSetVisible("banned_avatar_name_list", enable_ban); | 2687 | childSetVisible("banned_avatar_name_list", enable_ban); |
2688 | childSetEnabled("add_banned_avatar_btn", enable_ban); | 2688 | childSetEnabled("add_banned_avatar_btn", enable_ban); |
2689 | childSetEnabled("remove_banned_avatar_btn", enable_ban); | 2689 | childSetEnabled("remove_banned_avatar_btn", enable_ban); |
2690 | 2690 | ||
2691 | // Update removal buttons if needed | 2691 | // Update removal buttons if needed |
2692 | if (enable_agent) | 2692 | if (enable_agent) |
2693 | { | 2693 | { |
2694 | checkRemovalButton("allowed_avatar_name_list"); | 2694 | checkRemovalButton("allowed_avatar_name_list"); |
2695 | } | 2695 | } |
2696 | 2696 | ||
2697 | if (enable_group) | 2697 | if (enable_group) |
2698 | { | 2698 | { |
2699 | checkRemovalButton("allowed_group_name_list"); | 2699 | checkRemovalButton("allowed_group_name_list"); |
2700 | } | 2700 | } |
2701 | 2701 | ||
2702 | if (enable_ban) | 2702 | if (enable_ban) |
2703 | { | 2703 | { |
2704 | checkRemovalButton("banned_avatar_name_list"); | 2704 | checkRemovalButton("banned_avatar_name_list"); |
2705 | } | 2705 | } |
2706 | } | 2706 | } |
2707 | 2707 | ||
2708 | // static | 2708 | // static |
2709 | void LLPanelEstateInfo::callbackCacheName( | 2709 | void LLPanelEstateInfo::callbackCacheName( |
2710 | const LLUUID& id, | 2710 | const LLUUID& id, |
2711 | const std::string& first, | 2711 | const std::string& first, |
2712 | const std::string& last, | 2712 | const std::string& last, |
2713 | BOOL is_group, | 2713 | BOOL is_group, |
2714 | void*) | 2714 | void*) |
2715 | { | 2715 | { |
2716 | LLPanelEstateInfo* self = LLFloaterRegionInfo::getPanelEstate(); | 2716 | LLPanelEstateInfo* self = LLFloaterRegionInfo::getPanelEstate(); |
2717 | if (!self) return; | 2717 | if (!self) return; |
2718 | 2718 | ||
2719 | std::string name; | 2719 | std::string name; |
2720 | 2720 | ||
2721 | if (id.isNull()) | 2721 | if (id.isNull()) |
2722 | { | 2722 | { |
2723 | name = "(none)"; | 2723 | name = "(none)"; |
2724 | } | 2724 | } |
2725 | else | 2725 | else |
2726 | { | 2726 | { |
2727 | name = first + " " + last; | 2727 | name = first + " " + last; |
2728 | } | 2728 | } |
2729 | 2729 | ||
2730 | self->setOwnerName(name); | 2730 | self->setOwnerName(name); |
2731 | } | 2731 | } |
2732 | 2732 | ||
2733 | void LLPanelEstateInfo::clearAccessLists() | 2733 | void LLPanelEstateInfo::clearAccessLists() |
2734 | { | 2734 | { |
2735 | LLNameListCtrl* name_list = getChild<LLNameListCtrl>("allowed_avatar_name_list"); | 2735 | LLNameListCtrl* name_list = getChild<LLNameListCtrl>("allowed_avatar_name_list"); |
2736 | if (name_list) | 2736 | if (name_list) |
2737 | { | 2737 | { |
2738 | name_list->deleteAllItems(); | 2738 | name_list->deleteAllItems(); |
2739 | } | 2739 | } |
2740 | 2740 | ||
2741 | name_list = getChild<LLNameListCtrl>("banned_avatar_name_list"); | 2741 | name_list = getChild<LLNameListCtrl>("banned_avatar_name_list"); |
2742 | if (name_list) | 2742 | if (name_list) |
2743 | { | 2743 | { |
2744 | name_list->deleteAllItems(); | 2744 | name_list->deleteAllItems(); |
2745 | } | 2745 | } |
2746 | } | 2746 | } |
2747 | 2747 | ||
2748 | // enables/disables the "remove" button for the various allow/ban lists | 2748 | // enables/disables the "remove" button for the various allow/ban lists |
2749 | BOOL LLPanelEstateInfo::checkRemovalButton(std::string name) | 2749 | BOOL LLPanelEstateInfo::checkRemovalButton(std::string name) |
2750 | { | 2750 | { |
2751 | std::string btn_name = ""; | 2751 | std::string btn_name = ""; |
2752 | if (name == "allowed_avatar_name_list") | 2752 | if (name == "allowed_avatar_name_list") |
2753 | { | 2753 | { |
2754 | btn_name = "remove_allowed_avatar_btn"; | 2754 | btn_name = "remove_allowed_avatar_btn"; |
2755 | } | 2755 | } |
2756 | else if (name == "allowed_group_name_list") | 2756 | else if (name == "allowed_group_name_list") |
2757 | { | 2757 | { |
2758 | btn_name = "remove_allowed_group_btn"; | 2758 | btn_name = "remove_allowed_group_btn"; |
2759 | } | 2759 | } |
2760 | else if (name == "banned_avatar_name_list") | 2760 | else if (name == "banned_avatar_name_list") |
2761 | { | 2761 | { |
2762 | btn_name = "remove_banned_avatar_btn"; | 2762 | btn_name = "remove_banned_avatar_btn"; |
2763 | } | 2763 | } |
2764 | else if (name == "estate_manager_name_list") | 2764 | else if (name == "estate_manager_name_list") |
2765 | { | 2765 | { |
2766 | //ONLY OWNER CAN ADD /DELET ESTATE MANAGER | 2766 | //ONLY OWNER CAN ADD /DELET ESTATE MANAGER |
2767 | LLViewerRegion* region = gAgent.getRegion(); | 2767 | LLViewerRegion* region = gAgent.getRegion(); |
2768 | if (region && (region->getOwner() == gAgent.getID())) | 2768 | if (region && (region->getOwner() == gAgent.getID())) |
2769 | { | 2769 | { |
2770 | btn_name = "remove_estate_manager_btn"; | 2770 | btn_name = "remove_estate_manager_btn"; |
2771 | } | 2771 | } |
2772 | } | 2772 | } |
2773 | 2773 | ||
2774 | // enable the remove button if something is selected | 2774 | // enable the remove button if something is selected |
2775 | LLNameListCtrl* name_list = getChild<LLNameListCtrl>(name); | 2775 | LLNameListCtrl* name_list = getChild<LLNameListCtrl>(name); |
2776 | childSetEnabled(btn_name, name_list && name_list->getFirstSelected() ? TRUE : FALSE); | 2776 | childSetEnabled(btn_name, name_list && name_list->getFirstSelected() ? TRUE : FALSE); |
2777 | 2777 | ||
2778 | return (btn_name != ""); | 2778 | return (btn_name != ""); |
2779 | } | 2779 | } |
2780 | 2780 | ||
2781 | BOOL LLPanelEstateInfo::checkSunHourSlider(LLUICtrl* child_ctrl) | 2781 | BOOL LLPanelEstateInfo::checkSunHourSlider(LLUICtrl* child_ctrl) |
2782 | { | 2782 | { |
2783 | BOOL found_child_ctrl = FALSE; | 2783 | BOOL found_child_ctrl = FALSE; |
2784 | if (child_ctrl->getName() == "sun_hour_slider") | 2784 | if (child_ctrl->getName() == "sun_hour_slider") |
2785 | { | 2785 | { |
2786 | enableButton("apply_btn"); | 2786 | enableButton("apply_btn"); |
2787 | found_child_ctrl = TRUE; | 2787 | found_child_ctrl = TRUE; |
2788 | } | 2788 | } |
2789 | return found_child_ctrl; | 2789 | return found_child_ctrl; |
2790 | } | 2790 | } |
2791 | 2791 | ||
2792 | // static | 2792 | // static |
2793 | void LLPanelEstateInfo::onClickMessageEstate(void* userdata) | 2793 | void LLPanelEstateInfo::onClickMessageEstate(void* userdata) |
2794 | { | 2794 | { |
2795 | llinfos << "LLPanelEstateInfo::onClickMessageEstate" << llendl; | 2795 | llinfos << "LLPanelEstateInfo::onClickMessageEstate" << llendl; |
2796 | LLNotifications::instance().add("MessageEstate", LLSD(), LLSD(), boost::bind(&LLPanelEstateInfo::onMessageCommit, (LLPanelEstateInfo*)userdata, _1, _2)); | 2796 | LLNotifications::instance().add("MessageEstate", LLSD(), LLSD(), boost::bind(&LLPanelEstateInfo::onMessageCommit, (LLPanelEstateInfo*)userdata, _1, _2)); |
2797 | } | 2797 | } |
2798 | 2798 | ||
2799 | bool LLPanelEstateInfo::onMessageCommit(const LLSD& notification, const LLSD& response) | 2799 | bool LLPanelEstateInfo::onMessageCommit(const LLSD& notification, const LLSD& response) |
2800 | { | 2800 | { |
2801 | S32 option = LLNotification::getSelectedOption(notification, response); | 2801 | S32 option = LLNotification::getSelectedOption(notification, response); |
2802 | std::string text = response["message"].asString(); | 2802 | std::string text = response["message"].asString(); |
2803 | if(option != 0) return false; | 2803 | if(option != 0) return false; |
2804 | if(text.empty()) return false; | 2804 | if(text.empty()) return false; |
2805 | llinfos << "Message to everyone: " << text << llendl; | 2805 | llinfos << "Message to everyone: " << text << llendl; |
2806 | strings_t strings; | 2806 | strings_t strings; |
2807 | //integers_t integers; | 2807 | //integers_t integers; |
2808 | std::string name; | 2808 | std::string name; |
2809 | gAgent.buildFullname(name); | 2809 | gAgent.buildFullname(name); |
2810 | strings.push_back(strings_t::value_type(name)); | 2810 | strings.push_back(strings_t::value_type(name)); |
2811 | strings.push_back(strings_t::value_type(text)); | 2811 | strings.push_back(strings_t::value_type(text)); |
2812 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); | 2812 | LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); |
2813 | sendEstateOwnerMessage(gMessageSystem, "instantmessage", invoice, strings); | 2813 | sendEstateOwnerMessage(gMessageSystem, "instantmessage", invoice, strings); |
2814 | return false; | 2814 | return false; |
2815 | } | 2815 | } |
2816 | 2816 | ||
2817 | LLPanelEstateCovenant::LLPanelEstateCovenant() | 2817 | LLPanelEstateCovenant::LLPanelEstateCovenant() |
2818 | : mCovenantID(LLUUID::null) | 2818 | : mCovenantID(LLUUID::null) |
2819 | { | 2819 | { |
2820 | } | 2820 | } |
2821 | 2821 | ||
2822 | // virtual | 2822 | // virtual |
2823 | bool LLPanelEstateCovenant::refreshFromRegion(LLViewerRegion* region) | 2823 | bool LLPanelEstateCovenant::refreshFromRegion(LLViewerRegion* region) |
2824 | { | 2824 | { |
2825 | LLTextBox* region_name = getChild<LLTextBox>("region_name_text"); | 2825 | LLTextBox* region_name = getChild<LLTextBox>("region_name_text"); |
2826 | if (region_name) | 2826 | if (region_name) |
2827 | { | 2827 | { |
2828 | region_name->setText(region->getName()); | 2828 | region_name->setText(region->getName()); |
2829 | } | 2829 | } |
2830 | 2830 | ||
2831 | LLTextBox* resellable_clause = getChild<LLTextBox>("resellable_clause"); | 2831 | LLTextBox* resellable_clause = getChild<LLTextBox>("resellable_clause"); |
2832 | if (resellable_clause) | 2832 | if (resellable_clause) |
2833 | { | 2833 | { |
2834 | if (region->getRegionFlags() & REGION_FLAGS_BLOCK_LAND_RESELL) | 2834 | if (region->getRegionFlags() & REGION_FLAGS_BLOCK_LAND_RESELL) |
2835 | { | 2835 | { |
2836 | resellable_clause->setText(getString("can_not_resell")); | 2836 | resellable_clause->setText(getString("can_not_resell")); |
2837 | } | 2837 | } |
2838 | else | 2838 | else |
2839 | { | 2839 | { |
2840 | resellable_clause->setText(getString("can_resell")); | 2840 | resellable_clause->setText(getString("can_resell")); |
2841 | } | 2841 | } |
2842 | } | 2842 | } |
2843 | 2843 | ||
2844 | LLTextBox* changeable_clause = getChild<LLTextBox>("changeable_clause"); | 2844 | LLTextBox* changeable_clause = getChild<LLTextBox>("changeable_clause"); |
2845 | if (changeable_clause) | 2845 | if (changeable_clause) |
2846 | { | 2846 | { |
2847 | if (region->getRegionFlags() & REGION_FLAGS_ALLOW_PARCEL_CHANGES) | 2847 | if (region->getRegionFlags() & REGION_FLAGS_ALLOW_PARCEL_CHANGES) |
2848 | { | 2848 | { |
2849 | changeable_clause->setText(getString("can_change")); | 2849 | changeable_clause->setText(getString("can_change")); |
2850 | } | 2850 | } |
2851 | else | 2851 | else |
2852 | { | 2852 | { |
2853 | changeable_clause->setText(getString("can_not_change")); | 2853 | changeable_clause->setText(getString("can_not_change")); |
2854 | } | 2854 | } |
2855 | } | 2855 | } |
2856 | 2856 | ||
2857 | LLTextBox* region_maturity = getChild<LLTextBox>("region_maturity_text"); | 2857 | LLTextBox* region_maturity = getChild<LLTextBox>("region_maturity_text"); |
2858 | if (region_maturity) | 2858 | if (region_maturity) |
2859 | { | 2859 | { |
2860 | region_maturity->setText(region->getSimAccessString()); | 2860 | region_maturity->setText(region->getSimAccessString()); |
2861 | } | 2861 | } |
2862 | 2862 | ||
2863 | LLTextBox* region_landtype = getChild<LLTextBox>("region_landtype_text"); | 2863 | LLTextBox* region_landtype = getChild<LLTextBox>("region_landtype_text"); |
2864 | if (region_landtype) | 2864 | if (region_landtype) |
2865 | { | 2865 | { |
2866 | region_landtype->setText(region->getSimProductName()); | 2866 | region_landtype->setText(region->getSimProductName()); |
2867 | } | 2867 | } |
2868 | 2868 | ||
2869 | 2869 | ||
2870 | // let the parent class handle the general data collection. | 2870 | // let the parent class handle the general data collection. |
2871 | bool rv = LLPanelRegionInfo::refreshFromRegion(region); | 2871 | bool rv = LLPanelRegionInfo::refreshFromRegion(region); |
2872 | LLMessageSystem *msg = gMessageSystem; | 2872 | LLMessageSystem *msg = gMessageSystem; |
2873 | msg->newMessage("EstateCovenantRequest"); | 2873 | msg->newMessage("EstateCovenantRequest"); |
2874 | msg->nextBlockFast(_PREHASH_AgentData); | 2874 | msg->nextBlockFast(_PREHASH_AgentData); |
2875 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | 2875 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); |
2876 | msg->addUUIDFast(_PREHASH_SessionID,gAgent.getSessionID()); | 2876 | msg->addUUIDFast(_PREHASH_SessionID,gAgent.getSessionID()); |
2877 | msg->sendReliable(region->getHost()); | 2877 | msg->sendReliable(region->getHost()); |
2878 | return rv; | 2878 | return rv; |
2879 | } | 2879 | } |
2880 | 2880 | ||
2881 | // virtual | 2881 | // virtual |
2882 | bool LLPanelEstateCovenant::estateUpdate(LLMessageSystem* msg) | 2882 | bool LLPanelEstateCovenant::estateUpdate(LLMessageSystem* msg) |
2883 | { | 2883 | { |
2884 | llinfos << "LLPanelEstateCovenant::estateUpdate()" << llendl; | 2884 | llinfos << "LLPanelEstateCovenant::estateUpdate()" << llendl; |
2885 | return true; | 2885 | return true; |
2886 | } | 2886 | } |
2887 | 2887 | ||
2888 | // virtual | 2888 | // virtual |
2889 | BOOL LLPanelEstateCovenant::postBuild() | 2889 | BOOL LLPanelEstateCovenant::postBuild() |
2890 | { | 2890 | { |
2891 | initHelpBtn("covenant_help", "HelpEstateCovenant"); | 2891 | initHelpBtn("covenant_help", "HelpEstateCovenant"); |
2892 | mEstateNameText = getChild<LLTextBox>("estate_name_text"); | 2892 | mEstateNameText = getChild<LLTextBox>("estate_name_text"); |
2893 | mEstateOwnerText = getChild<LLTextBox>("estate_owner_text"); | 2893 | mEstateOwnerText = getChild<LLTextBox>("estate_owner_text"); |
2894 | mLastModifiedText = getChild<LLTextBox>("covenant_timestamp_text"); | 2894 | mLastModifiedText = getChild<LLTextBox>("covenant_timestamp_text"); |
2895 | mEditor = getChild<LLViewerTextEditor>("covenant_editor"); | 2895 | mEditor = getChild<LLViewerTextEditor>("covenant_editor"); |
2896 | if (mEditor) mEditor->setHandleEditKeysDirectly(TRUE); | 2896 | if (mEditor) mEditor->setHandleEditKeysDirectly(TRUE); |
2897 | LLButton* reset_button = getChild<LLButton>("reset_covenant"); | 2897 | LLButton* reset_button = getChild<LLButton>("reset_covenant"); |
2898 | reset_button->setEnabled(gAgent.canManageEstate()); | 2898 | reset_button->setEnabled(gAgent.canManageEstate()); |
2899 | reset_button->setClickedCallback(LLPanelEstateCovenant::resetCovenantID, NULL); | 2899 | reset_button->setClickedCallback(LLPanelEstateCovenant::resetCovenantID, NULL); |
2900 | 2900 | ||
2901 | return LLPanelRegionInfo::postBuild(); | 2901 | return LLPanelRegionInfo::postBuild(); |
2902 | } | 2902 | } |
2903 | 2903 | ||
2904 | // virtual | 2904 | // virtual |
2905 | void LLPanelEstateCovenant::updateChild(LLUICtrl* child_ctrl) | 2905 | void LLPanelEstateCovenant::updateChild(LLUICtrl* child_ctrl) |
2906 | { | 2906 | { |
2907 | } | 2907 | } |
2908 | 2908 | ||
2909 | // virtual | 2909 | // virtual |
2910 | BOOL LLPanelEstateCovenant::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, | 2910 | BOOL LLPanelEstateCovenant::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, |
2911 | EDragAndDropType cargo_type, | 2911 | EDragAndDropType cargo_type, |
2912 | void* cargo_data, | 2912 | void* cargo_data, |
2913 | EAcceptance* accept, | 2913 | EAcceptance* accept, |
2914 | std::string& tooltip_msg) | 2914 | std::string& tooltip_msg) |
2915 | { | 2915 | { |
2916 | LLInventoryItem* item = (LLInventoryItem*)cargo_data; | 2916 | LLInventoryItem* item = (LLInventoryItem*)cargo_data; |
2917 | 2917 | ||
2918 | if (!gAgent.canManageEstate()) | 2918 | if (!gAgent.canManageEstate()) |
2919 | { | 2919 | { |
2920 | *accept = ACCEPT_NO; | 2920 | *accept = ACCEPT_NO; |
2921 | return TRUE; | 2921 | return TRUE; |
2922 | } | 2922 | } |
2923 | 2923 | ||
2924 | switch(cargo_type) | 2924 | switch(cargo_type) |
2925 | { | 2925 | { |
2926 | case DAD_NOTECARD: | 2926 | case DAD_NOTECARD: |
2927 | *accept = ACCEPT_YES_COPY_SINGLE; | 2927 | *accept = ACCEPT_YES_COPY_SINGLE; |
2928 | if (item && drop) | 2928 | if (item && drop) |
2929 | { | 2929 | { |
2930 | LLSD payload; | 2930 | LLSD payload; |
2931 | payload["item_id"] = item->getUUID(); | 2931 | payload["item_id"] = item->getUUID(); |
2932 | LLNotifications::instance().add("EstateChangeCovenant", LLSD(), payload, | 2932 | LLNotifications::instance().add("EstateChangeCovenant", LLSD(), payload, |
2933 | LLPanelEstateCovenant::confirmChangeCovenantCallback); | 2933 | LLPanelEstateCovenant::confirmChangeCovenantCallback); |
2934 | } | 2934 | } |
2935 | break; | 2935 | break; |
2936 | default: | 2936 | default: |
2937 | *accept = ACCEPT_NO; | 2937 | *accept = ACCEPT_NO; |
2938 | break; | 2938 | break; |
2939 | } | 2939 | } |
2940 | 2940 | ||
2941 | return TRUE; | 2941 | return TRUE; |
2942 | } | 2942 | } |
2943 | 2943 | ||
2944 | // static | 2944 | // static |
2945 | bool LLPanelEstateCovenant::confirmChangeCovenantCallback(const LLSD& notification, const LLSD& response) | 2945 | bool LLPanelEstateCovenant::confirmChangeCovenantCallback(const LLSD& notification, const LLSD& response) |
2946 | { | 2946 | { |
2947 | S32 option = LLNotification::getSelectedOption(notification, response); | 2947 | S32 option = LLNotification::getSelectedOption(notification, response); |
2948 | LLInventoryItem* item = gInventory.getItem(notification["payload"]["item_id"].asUUID()); | 2948 | LLInventoryItem* item = gInventory.getItem(notification["payload"]["item_id"].asUUID()); |
2949 | LLPanelEstateCovenant* self = LLFloaterRegionInfo::getPanelCovenant(); | 2949 | LLPanelEstateCovenant* self = LLFloaterRegionInfo::getPanelCovenant(); |
2950 | 2950 | ||
2951 | if (!item || !self) return false; | 2951 | if (!item || !self) return false; |
2952 | 2952 | ||
2953 | switch(option) | 2953 | switch(option) |
2954 | { | 2954 | { |
2955 | case 0: | 2955 | case 0: |
2956 | self->loadInvItem(item); | 2956 | self->loadInvItem(item); |
2957 | break; | 2957 | break; |
2958 | default: | 2958 | default: |
2959 | break; | 2959 | break; |
2960 | } | 2960 | } |
2961 | return false; | 2961 | return false; |
2962 | } | 2962 | } |
2963 | 2963 | ||
2964 | // static | 2964 | // static |
2965 | void LLPanelEstateCovenant::resetCovenantID(void* userdata) | 2965 | void LLPanelEstateCovenant::resetCovenantID(void* userdata) |
2966 | { | 2966 | { |
2967 | LLNotifications::instance().add("EstateChangeCovenant", LLSD(), LLSD(), confirmResetCovenantCallback); | 2967 | LLNotifications::instance().add("EstateChangeCovenant", LLSD(), LLSD(), confirmResetCovenantCallback); |
2968 | } | 2968 | } |
2969 | 2969 | ||
2970 | // static | 2970 | // static |
2971 | bool LLPanelEstateCovenant::confirmResetCovenantCallback(const LLSD& notification, const LLSD& response) | 2971 | bool LLPanelEstateCovenant::confirmResetCovenantCallback(const LLSD& notification, const LLSD& response) |
2972 | { | 2972 | { |
2973 | LLPanelEstateCovenant* self = LLFloaterRegionInfo::getPanelCovenant(); | 2973 | LLPanelEstateCovenant* self = LLFloaterRegionInfo::getPanelCovenant(); |
2974 | if (!self) return false; | 2974 | if (!self) return false; |
2975 | 2975 | ||
2976 | S32 option = LLNotification::getSelectedOption(notification, response); | 2976 | S32 option = LLNotification::getSelectedOption(notification, response); |
2977 | switch(option) | 2977 | switch(option) |
2978 | { | 2978 | { |
2979 | case 0: | 2979 | case 0: |
2980 | self->loadInvItem(NULL); | 2980 | self->loadInvItem(NULL); |
2981 | break; | 2981 | break; |
2982 | default: | 2982 | default: |
2983 | break; | 2983 | break; |
2984 | } | 2984 | } |
2985 | return false; | 2985 | return false; |
2986 | } | 2986 | } |
2987 | 2987 | ||
2988 | void LLPanelEstateCovenant::loadInvItem(LLInventoryItem *itemp) | 2988 | void LLPanelEstateCovenant::loadInvItem(LLInventoryItem *itemp) |
2989 | { | 2989 | { |
2990 | const BOOL high_priority = TRUE; | 2990 | const BOOL high_priority = TRUE; |
2991 | if (itemp) | 2991 | if (itemp) |
2992 | { | 2992 | { |
2993 | gAssetStorage->getInvItemAsset(gAgent.getRegionHost(), | 2993 | gAssetStorage->getInvItemAsset(gAgent.getRegionHost(), |
2994 | gAgent.getID(), | 2994 | gAgent.getID(), |
2995 | gAgent.getSessionID(), | 2995 | gAgent.getSessionID(), |
2996 | itemp->getPermissions().getOwner(), | 2996 | itemp->getPermissions().getOwner(), |
2997 | LLUUID::null, | 2997 | LLUUID::null, |
2998 | itemp->getUUID(), | 2998 | itemp->getUUID(), |
2999 | itemp->getAssetUUID(), | 2999 | itemp->getAssetUUID(), |
3000 | itemp->getType(), | 3000 | itemp->getType(), |
3001 | onLoadComplete, | 3001 | onLoadComplete, |
3002 | (void*)this, | 3002 | (void*)this, |
3003 | high_priority); | 3003 | high_priority); |
3004 | mAssetStatus = ASSET_LOADING; | 3004 | mAssetStatus = ASSET_LOADING; |
3005 | } | 3005 | } |
3006 | else | 3006 | else |
3007 | { | 3007 | { |
3008 | mAssetStatus = ASSET_LOADED; | 3008 | mAssetStatus = ASSET_LOADED; |
3009 | setCovenantTextEditor("There is no Covenant provided for this Estate."); | 3009 | setCovenantTextEditor("There is no Covenant provided for this Estate."); |
3010 | sendChangeCovenantID(LLUUID::null); | 3010 | sendChangeCovenantID(LLUUID::null); |
3011 | } | 3011 | } |
3012 | } | 3012 | } |
3013 | 3013 | ||
3014 | // static | 3014 | // static |
3015 | void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs, | 3015 | void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs, |
3016 | const LLUUID& asset_uuid, | 3016 | const LLUUID& asset_uuid, |
3017 | LLAssetType::EType type, | 3017 | LLAssetType::EType type, |
3018 | void* user_data, S32 status, LLExtStat ext_status) | 3018 | void* user_data, S32 status, LLExtStat ext_status) |
3019 | { | 3019 | { |
3020 | llinfos << "LLPanelEstateCovenant::onLoadComplete()" << llendl; | 3020 | llinfos << "LLPanelEstateCovenant::onLoadComplete()" << llendl; |
3021 | LLPanelEstateCovenant* panelp = (LLPanelEstateCovenant*)user_data; | 3021 | LLPanelEstateCovenant* panelp = (LLPanelEstateCovenant*)user_data; |
3022 | if( panelp ) | 3022 | if( panelp ) |
3023 | { | 3023 | { |
3024 | if(0 == status) | 3024 | if(0 == status) |
3025 | { | 3025 | { |
3026 | LLVFile file(vfs, asset_uuid, type, LLVFile::READ); | 3026 | LLVFile file(vfs, asset_uuid, type, LLVFile::READ); |
3027 | 3027 | ||
3028 | S32 file_length = file.getSize(); | 3028 | S32 file_length = file.getSize(); |
3029 | 3029 | ||
3030 | char* buffer = new char[file_length+1]; | 3030 | char* buffer = new char[file_length+1]; |
3031 | if (buffer == NULL) | 3031 | if (buffer == NULL) |
3032 | { | 3032 | { |
3033 | llerrs << "Memory Allocation Failed" << llendl; | 3033 | llerrs << "Memory Allocation Failed" << llendl; |
3034 | return; | 3034 | return; |
3035 | } | 3035 | } |
3036 | 3036 | ||
3037 | file.read((U8*)buffer, file_length); /* Flawfinder: ignore */ | 3037 | file.read((U8*)buffer, file_length); /* Flawfinder: ignore */ |
3038 | // put a EOS at the end | 3038 | // put a EOS at the end |
3039 | buffer[file_length] = 0; | 3039 | buffer[file_length] = 0; |
3040 | 3040 | ||
3041 | if( (file_length > 19) && !strncmp( buffer, "Linden text version", 19 ) ) | 3041 | if( (file_length > 19) && !strncmp( buffer, "Linden text version", 19 ) ) |
3042 | { | 3042 | { |
3043 | if( !panelp->mEditor->importBuffer( buffer, file_length+1 ) ) | 3043 | if( !panelp->mEditor->importBuffer( buffer, file_length+1 ) ) |
3044 | { | 3044 | { |
3045 | llwarns << "Problem importing estate covenant." << llendl; | 3045 | llwarns << "Problem importing estate covenant." << llendl; |
3046 | LLNotifications::instance().add("ProblemImportingEstateCovenant"); | 3046 | LLNotifications::instance().add("ProblemImportingEstateCovenant"); |
3047 | } | 3047 | } |
3048 | else | 3048 | else |
3049 | { | 3049 | { |
3050 | panelp->sendChangeCovenantID(asset_uuid); | 3050 | panelp->sendChangeCovenantID(asset_uuid); |
3051 | } | 3051 | } |
3052 | } | 3052 | } |
3053 | else | 3053 | else |
3054 | { | 3054 | { |
3055 | // Version 0 (just text, doesn't include version number) | 3055 | // Version 0 (just text, doesn't include version number) |
3056 | panelp->sendChangeCovenantID(asset_uuid); | 3056 | panelp->sendChangeCovenantID(asset_uuid); |
3057 | } | 3057 | } |
3058 | delete[] buffer; | 3058 | delete[] buffer; |
3059 | } | 3059 | } |
3060 | else | 3060 | else |
3061 | { | 3061 | { |
3062 | LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); | 3062 | LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); |
3063 | 3063 | ||
3064 | if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || | 3064 | if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || |
3065 | LL_ERR_FILE_EMPTY == status) | 3065 | LL_ERR_FILE_EMPTY == status) |
3066 | { | 3066 | { |
3067 | LLNotifications::instance().add("MissingNotecardAssetID"); | 3067 | LLNotifications::instance().add("MissingNotecardAssetID"); |
3068 | } | 3068 | } |
3069 | else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status) | 3069 | else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status) |
3070 | { | 3070 | { |
3071 | LLNotifications::instance().add("NotAllowedToViewNotecard"); | 3071 | LLNotifications::instance().add("NotAllowedToViewNotecard"); |
3072 | } | 3072 | } |
3073 | else | 3073 | else |
3074 | { | 3074 | { |
3075 | LLNotifications::instance().add("UnableToLoadNotecardAsset"); | 3075 | LLNotifications::instance().add("UnableToLoadNotecardAsset"); |
3076 | } | 3076 | } |
3077 | 3077 | ||
3078 | llwarns << "Problem loading notecard: " << status << llendl; | 3078 | llwarns << "Problem loading notecard: " << status << llendl; |
3079 | } | 3079 | } |
3080 | panelp->mAssetStatus = ASSET_LOADED; | 3080 | panelp->mAssetStatus = ASSET_LOADED; |
3081 | panelp->setCovenantID(asset_uuid); | 3081 | panelp->setCovenantID(asset_uuid); |
3082 | } | 3082 | } |
3083 | } | 3083 | } |
3084 | 3084 | ||
3085 | // key = "estatechangecovenantid" | 3085 | // key = "estatechangecovenantid" |
3086 | // strings[0] = str(estate_id) (added by simulator before relay - not here) | 3086 | // strings[0] = str(estate_id) (added by simulator before relay - not here) |
3087 | // strings[1] = str(covenant_id) | 3087 | // strings[1] = str(covenant_id) |
3088 | void LLPanelEstateCovenant::sendChangeCovenantID(const LLUUID &asset_id) | 3088 | void LLPanelEstateCovenant::sendChangeCovenantID(const LLUUID &asset_id) |
3089 | { | 3089 | { |
3090 | if (asset_id != getCovenantID()) | 3090 | if (asset_id != getCovenantID()) |
3091 | { | 3091 | { |
3092 | setCovenantID(asset_id); | 3092 | setCovenantID(asset_id); |
3093 | 3093 | ||
3094 | LLMessageSystem* msg = gMessageSystem; | 3094 | LLMessageSystem* msg = gMessageSystem; |
3095 | msg->newMessage("EstateOwnerMessage"); | 3095 | msg->newMessage("EstateOwnerMessage"); |
3096 | msg->nextBlockFast(_PREHASH_AgentData); | 3096 | msg->nextBlockFast(_PREHASH_AgentData); |
3097 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | 3097 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); |
3098 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | 3098 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); |
3099 | msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used | 3099 | msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used |
3100 | 3100 | ||
3101 | msg->nextBlock("MethodData"); | 3101 | msg->nextBlock("MethodData"); |
3102 | msg->addString("Method", "estatechangecovenantid"); | 3102 | msg->addString("Method", "estatechangecovenantid"); |
3103 | msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice()); | 3103 | msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice()); |
3104 | 3104 | ||
3105 | msg->nextBlock("ParamList"); | 3105 | msg->nextBlock("ParamList"); |
3106 | msg->addString("Parameter", getCovenantID().asString()); | 3106 | msg->addString("Parameter", getCovenantID().asString()); |
3107 | gAgent.sendReliableMessage(); | 3107 | gAgent.sendReliableMessage(); |
3108 | } | 3108 | } |
3109 | } | 3109 | } |
3110 | 3110 | ||
3111 | // virtual | 3111 | // virtual |
3112 | BOOL LLPanelEstateCovenant::sendUpdate() | 3112 | BOOL LLPanelEstateCovenant::sendUpdate() |
3113 | { | 3113 | { |
3114 | return TRUE; | 3114 | return TRUE; |
3115 | } | 3115 | } |
3116 | 3116 | ||
3117 | const std::string& LLPanelEstateCovenant::getEstateName() const | 3117 | const std::string& LLPanelEstateCovenant::getEstateName() const |
3118 | { | 3118 | { |
3119 | return mEstateNameText->getText(); | 3119 | return mEstateNameText->getText(); |
3120 | } | 3120 | } |
3121 | 3121 | ||
3122 | void LLPanelEstateCovenant::setEstateName(const std::string& name) | 3122 | void LLPanelEstateCovenant::setEstateName(const std::string& name) |
3123 | { | 3123 | { |
3124 | mEstateNameText->setText(name); | 3124 | mEstateNameText->setText(name); |
3125 | } | 3125 | } |
3126 | 3126 | ||
3127 | // static | 3127 | // static |
3128 | void LLPanelEstateCovenant::updateCovenantText(const std::string& string, const LLUUID& asset_id) | 3128 | void LLPanelEstateCovenant::updateCovenantText(const std::string& string, const LLUUID& asset_id) |
3129 | { | 3129 | { |
3130 | LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant(); | 3130 | LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant(); |
3131 | if( panelp ) | 3131 | if( panelp ) |
3132 | { | 3132 | { |
3133 | panelp->mEditor->setText(string); | 3133 | panelp->mEditor->setText(string); |
3134 | panelp->setCovenantID(asset_id); | 3134 | panelp->setCovenantID(asset_id); |
3135 | } | 3135 | } |
3136 | } | 3136 | } |
3137 | 3137 | ||
3138 | // static | 3138 | // static |
3139 | void LLPanelEstateCovenant::updateEstateName(const std::string& name) | 3139 | void LLPanelEstateCovenant::updateEstateName(const std::string& name) |
3140 | { | 3140 | { |
3141 | LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant(); | 3141 | LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant(); |
3142 | if( panelp ) | 3142 | if( panelp ) |
3143 | { | 3143 | { |
3144 | panelp->mEstateNameText->setText(name); | 3144 | panelp->mEstateNameText->setText(name); |
3145 | } | 3145 | } |
3146 | } | 3146 | } |
3147 | 3147 | ||
3148 | // static | 3148 | // static |
3149 | void LLPanelEstateCovenant::updateLastModified(const std::string& text) | 3149 | void LLPanelEstateCovenant::updateLastModified(const std::string& text) |
3150 | { | 3150 | { |
3151 | LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant(); | 3151 | LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant(); |
3152 | if( panelp ) | 3152 | if( panelp ) |
3153 | { | 3153 | { |
3154 | panelp->mLastModifiedText->setText(text); | 3154 | panelp->mLastModifiedText->setText(text); |
3155 | } | 3155 | } |
3156 | } | 3156 | } |
3157 | 3157 | ||
3158 | // static | 3158 | // static |
3159 | void LLPanelEstateCovenant::updateEstateOwnerName(const std::string& name) | 3159 | void LLPanelEstateCovenant::updateEstateOwnerName(const std::string& name) |
3160 | { | 3160 | { |
3161 | LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant(); | 3161 | LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant(); |
3162 | if( panelp ) | 3162 | if( panelp ) |
3163 | { | 3163 | { |
3164 | panelp->mEstateOwnerText->setText(name); | 3164 | panelp->mEstateOwnerText->setText(name); |
3165 | } | 3165 | } |
3166 | } | 3166 | } |
3167 | 3167 | ||
3168 | const std::string& LLPanelEstateCovenant::getOwnerName() const | 3168 | const std::string& LLPanelEstateCovenant::getOwnerName() const |
3169 | { | 3169 | { |
3170 | return mEstateOwnerText->getText(); | 3170 | return mEstateOwnerText->getText(); |
3171 | } | 3171 | } |
3172 | 3172 | ||
3173 | void LLPanelEstateCovenant::setOwnerName(const std::string& name) | 3173 | void LLPanelEstateCovenant::setOwnerName(const std::string& name) |
3174 | { | 3174 | { |
3175 | mEstateOwnerText->setText(name); | 3175 | mEstateOwnerText->setText(name); |
3176 | } | 3176 | } |
3177 | 3177 | ||
3178 | void LLPanelEstateCovenant::setCovenantTextEditor(const std::string& text) | 3178 | void LLPanelEstateCovenant::setCovenantTextEditor(const std::string& text) |
3179 | { | 3179 | { |
3180 | mEditor->setText(text); | 3180 | mEditor->setText(text); |
3181 | } | 3181 | } |
3182 | 3182 | ||
3183 | // key = "estateupdateinfo" | 3183 | // key = "estateupdateinfo" |
3184 | // strings[0] = estate name | 3184 | // strings[0] = estate name |
3185 | // strings[1] = str(owner_id) | 3185 | // strings[1] = str(owner_id) |
3186 | // strings[2] = str(estate_id) | 3186 | // strings[2] = str(estate_id) |
3187 | // strings[3] = str(estate_flags) | 3187 | // strings[3] = str(estate_flags) |
3188 | // strings[4] = str((S32)(sun_hour * 1024)) | 3188 | // strings[4] = str((S32)(sun_hour * 1024)) |
3189 | // strings[5] = str(parent_estate_id) | 3189 | // strings[5] = str(parent_estate_id) |
3190 | // strings[6] = str(covenant_id) | 3190 | // strings[6] = str(covenant_id) |
3191 | // strings[7] = str(covenant_timestamp) | 3191 | // strings[7] = str(covenant_timestamp) |
3192 | // strings[8] = str(send_to_agent_only) | 3192 | // strings[8] = str(send_to_agent_only) |
3193 | // strings[9] = str(abuse_email_addr) | 3193 | // strings[9] = str(abuse_email_addr) |
3194 | bool LLDispatchEstateUpdateInfo::operator()( | 3194 | bool LLDispatchEstateUpdateInfo::operator()( |
3195 | const LLDispatcher* dispatcher, | 3195 | const LLDispatcher* dispatcher, |
3196 | const std::string& key, | 3196 | const std::string& key, |
3197 | const LLUUID& invoice, | 3197 | const LLUUID& invoice, |
3198 | const sparam_t& strings) | 3198 | const sparam_t& strings) |
3199 | { | 3199 | { |
3200 | LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); | 3200 | LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); |
3201 | if (!panel) return true; | 3201 | if (!panel) return true; |
3202 | 3202 | ||
3203 | // NOTE: LLDispatcher extracts strings with an extra \0 at the | 3203 | // NOTE: LLDispatcher extracts strings with an extra \0 at the |
3204 | // end. If we pass the std::string direct to the UI/renderer | 3204 | // end. If we pass the std::string direct to the UI/renderer |
3205 | // it draws with a weird character at the end of the string. | 3205 | // it draws with a weird character at the end of the string. |
3206 | std::string estate_name = strings[0].c_str(); // preserve c_str() call! | 3206 | std::string estate_name = strings[0].c_str(); // preserve c_str() call! |
3207 | panel->setEstateName(estate_name); | 3207 | panel->setEstateName(estate_name); |
3208 | 3208 | ||
3209 | if (strings.size() > 3) | 3209 | if (strings.size() > 3) |
3210 | { | 3210 | { |
3211 | std::string abuse_email = strings[9].c_str(); // preserve c_str() call! | 3211 | std::string abuse_email = strings[9].c_str(); // preserve c_str() call! |
3212 | panel->setAbuseEmailAddress(abuse_email); | 3212 | panel->setAbuseEmailAddress(abuse_email); |
3213 | } | 3213 | } |
3214 | else | 3214 | else |
3215 | { | 3215 | { |
3216 | panel->setAbuseEmailAddress(panel->getString("email_unsupported")); | 3216 | panel->setAbuseEmailAddress(panel->getString("email_unsupported")); |
3217 | } | 3217 | } |
3218 | 3218 | ||
3219 | LLViewerRegion* regionp = gAgent.getRegion(); | 3219 | LLViewerRegion* regionp = gAgent.getRegion(); |
3220 | 3220 | ||
3221 | LLUUID owner_id(strings[1]); | 3221 | LLUUID owner_id(strings[1]); |
3222 | regionp->setOwner(owner_id); | 3222 | regionp->setOwner(owner_id); |
3223 | // Update estate owner name in UI | 3223 | // Update estate owner name in UI |
3224 | const BOOL is_group = FALSE; | 3224 | const BOOL is_group = FALSE; |
3225 | gCacheName->get(owner_id, is_group, LLPanelEstateInfo::callbackCacheName); | 3225 | gCacheName->get(owner_id, is_group, LLPanelEstateInfo::callbackCacheName); |
3226 | 3226 | ||
3227 | U32 estate_id = strtoul(strings[2].c_str(), NULL, 10); | 3227 | U32 estate_id = strtoul(strings[2].c_str(), NULL, 10); |
3228 | panel->setEstateID(estate_id); | 3228 | panel->setEstateID(estate_id); |
3229 | 3229 | ||
3230 | U32 flags = strtoul(strings[3].c_str(), NULL, 10); | 3230 | U32 flags = strtoul(strings[3].c_str(), NULL, 10); |
3231 | panel->setEstateFlags(flags); | 3231 | panel->setEstateFlags(flags); |
3232 | 3232 | ||
3233 | F32 sun_hour = ((F32)(strtod(strings[4].c_str(), NULL)))/1024.0f; | 3233 | F32 sun_hour = ((F32)(strtod(strings[4].c_str(), NULL)))/1024.0f; |
3234 | if(sun_hour == 0 && (flags & REGION_FLAGS_SUN_FIXED ? FALSE : TRUE)) | 3234 | if(sun_hour == 0 && (flags & REGION_FLAGS_SUN_FIXED ? FALSE : TRUE)) |
3235 | { | 3235 | { |
3236 | panel->setGlobalTime(TRUE); | 3236 | panel->setGlobalTime(TRUE); |
3237 | } | 3237 | } |
3238 | else | 3238 | else |
3239 | { | 3239 | { |
3240 | panel->setGlobalTime(FALSE); | 3240 | panel->setGlobalTime(FALSE); |
3241 | panel->setSunHour(sun_hour); | 3241 | panel->setSunHour(sun_hour); |
3242 | } | 3242 | } |
3243 | 3243 | ||
3244 | bool visible_from_mainland = (bool)(flags & REGION_FLAGS_EXTERNALLY_VISIBLE); | 3244 | bool visible_from_mainland = (bool)(flags & REGION_FLAGS_EXTERNALLY_VISIBLE); |
3245 | bool god = gAgent.isGodlike(); | 3245 | bool god = gAgent.isGodlike(); |
3246 | bool linden_estate = (estate_id <= ESTATE_LAST_LINDEN); | 3246 | bool linden_estate = (estate_id <= ESTATE_LAST_LINDEN); |
3247 | 3247 | ||
3248 | // If visible from mainland, disable the access allowed | 3248 | // If visible from mainland, disable the access allowed |
3249 | // UI, as anyone can teleport there. | 3249 | // UI, as anyone can teleport there. |
3250 | // However, gods need to be able to edit the access list for | 3250 | // However, gods need to be able to edit the access list for |
3251 | // linden estates, regardless of visibility, to allow object | 3251 | // linden estates, regardless of visibility, to allow object |
3252 | // and L$ transfers. | 3252 | // and L$ transfers. |
3253 | bool enable_agent = (!visible_from_mainland || (god && linden_estate)); | 3253 | bool enable_agent = (!visible_from_mainland || (god && linden_estate)); |
3254 | bool enable_group = enable_agent; | 3254 | bool enable_group = enable_agent; |
3255 | bool enable_ban = !linden_estate; | 3255 | bool enable_ban = !linden_estate; |
3256 | panel->setAccessAllowedEnabled(enable_agent, enable_group, enable_ban); | 3256 | panel->setAccessAllowedEnabled(enable_agent, enable_group, enable_ban); |
3257 | 3257 | ||
3258 | return true; | 3258 | return true; |
3259 | } | 3259 | } |
3260 | 3260 | ||
3261 | 3261 | ||
3262 | // key = "setaccess" | 3262 | // key = "setaccess" |
3263 | // strings[0] = str(estate_id) | 3263 | // strings[0] = str(estate_id) |
3264 | // strings[1] = str(packed_access_lists) | 3264 | // strings[1] = str(packed_access_lists) |
3265 | // strings[2] = str(num allowed agent ids) | 3265 | // strings[2] = str(num allowed agent ids) |
3266 | // strings[3] = str(num allowed group ids) | 3266 | // strings[3] = str(num allowed group ids) |
3267 | // strings[4] = str(num banned agent ids) | 3267 | // strings[4] = str(num banned agent ids) |
3268 | // strings[5] = str(num estate manager agent ids) | 3268 | // strings[5] = str(num estate manager agent ids) |
3269 | // strings[6] = bin(uuid) | 3269 | // strings[6] = bin(uuid) |
3270 | // strings[7] = bin(uuid) | 3270 | // strings[7] = bin(uuid) |
3271 | // strings[8] = bin(uuid) | 3271 | // strings[8] = bin(uuid) |
3272 | // ... | 3272 | // ... |
3273 | bool LLDispatchSetEstateAccess::operator()( | 3273 | bool LLDispatchSetEstateAccess::operator()( |
3274 | const LLDispatcher* dispatcher, | 3274 | const LLDispatcher* dispatcher, |
3275 | const std::string& key, | 3275 | const std::string& key, |
3276 | const LLUUID& invoice, | 3276 | const LLUUID& invoice, |
3277 | const sparam_t& strings) | 3277 | const sparam_t& strings) |
3278 | { | 3278 | { |
3279 | LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); | 3279 | LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); |
3280 | if (!panel) return true; | 3280 | if (!panel) return true; |
3281 | 3281 | ||
3282 | S32 index = 1; // skip estate_id | 3282 | S32 index = 1; // skip estate_id |
3283 | U32 access_flags = strtoul(strings[index++].c_str(), NULL,10); | 3283 | U32 access_flags = strtoul(strings[index++].c_str(), NULL,10); |
3284 | S32 num_allowed_agents = strtol(strings[index++].c_str(), NULL, 10); | 3284 | S32 num_allowed_agents = strtol(strings[index++].c_str(), NULL, 10); |
3285 | S32 num_allowed_groups = strtol(strings[index++].c_str(), NULL, 10); | 3285 | S32 num_allowed_groups = strtol(strings[index++].c_str(), NULL, 10); |
3286 | S32 num_banned_agents = strtol(strings[index++].c_str(), NULL, 10); | 3286 | S32 num_banned_agents = strtol(strings[index++].c_str(), NULL, 10); |
3287 | S32 num_estate_managers = strtol(strings[index++].c_str(), NULL, 10); | 3287 | S32 num_estate_managers = strtol(strings[index++].c_str(), NULL, 10); |
3288 | 3288 | ||
3289 | // sanity ckecks | 3289 | // sanity ckecks |
3290 | if (num_allowed_agents > 0 | 3290 | if (num_allowed_agents > 0 |
3291 | && !(access_flags & ESTATE_ACCESS_ALLOWED_AGENTS)) | 3291 | && !(access_flags & ESTATE_ACCESS_ALLOWED_AGENTS)) |
3292 | { | 3292 | { |
3293 | llwarns << "non-zero count for allowed agents, but no corresponding flag" << llendl; | 3293 | llwarns << "non-zero count for allowed agents, but no corresponding flag" << llendl; |
3294 | } | 3294 | } |
3295 | if (num_allowed_groups > 0 | 3295 | if (num_allowed_groups > 0 |
3296 | && !(access_flags & ESTATE_ACCESS_ALLOWED_GROUPS)) | 3296 | && !(access_flags & ESTATE_ACCESS_ALLOWED_GROUPS)) |
3297 | { | 3297 | { |
3298 | llwarns << "non-zero count for allowed groups, but no corresponding flag" << llendl; | 3298 | llwarns << "non-zero count for allowed groups, but no corresponding flag" << llendl; |
3299 | } | 3299 | } |
3300 | if (num_banned_agents > 0 | 3300 | if (num_banned_agents > 0 |
3301 | && !(access_flags & ESTATE_ACCESS_BANNED_AGENTS)) | 3301 | && !(access_flags & ESTATE_ACCESS_BANNED_AGENTS)) |
3302 | { | 3302 | { |
3303 | llwarns << "non-zero count for banned agents, but no corresponding flag" << llendl; | 3303 | llwarns << "non-zero count for banned agents, but no corresponding flag" << llendl; |
3304 | } | 3304 | } |
3305 | if (num_estate_managers > 0 | 3305 | if (num_estate_managers > 0 |
3306 | && !(access_flags & ESTATE_ACCESS_MANAGERS)) | 3306 | && !(access_flags & ESTATE_ACCESS_MANAGERS)) |
3307 | { | 3307 | { |
3308 | llwarns << "non-zero count for managers, but no corresponding flag" << llendl; | 3308 | llwarns << "non-zero count for managers, but no corresponding flag" << llendl; |
3309 | } | 3309 | } |
3310 | 3310 | ||
3311 | // grab the UUID's out of the string fields | 3311 | // grab the UUID's out of the string fields |
3312 | if (access_flags & ESTATE_ACCESS_ALLOWED_AGENTS) | 3312 | if (access_flags & ESTATE_ACCESS_ALLOWED_AGENTS) |
3313 | { | 3313 | { |
3314 | LLNameListCtrl* allowed_agent_name_list; | 3314 | LLNameListCtrl* allowed_agent_name_list; |
3315 | allowed_agent_name_list = panel->getChild<LLNameListCtrl>("allowed_avatar_name_list"); | 3315 | allowed_agent_name_list = panel->getChild<LLNameListCtrl>("allowed_avatar_name_list"); |
3316 | 3316 | ||
3317 | int totalAllowedAgents = num_allowed_agents; | 3317 | int totalAllowedAgents = num_allowed_agents; |
3318 | 3318 | ||
3319 | if (allowed_agent_name_list) | 3319 | if (allowed_agent_name_list) |
3320 | { | 3320 | { |
3321 | totalAllowedAgents += allowed_agent_name_list->getItemCount(); | 3321 | totalAllowedAgents += allowed_agent_name_list->getItemCount(); |
3322 | } | 3322 | } |
3323 | 3323 | ||
3324 | std::string msg = llformat("Allowed residents: (%d, max %d)", | 3324 | std::string msg = llformat("Allowed residents: (%d, max %d)", |
3325 | totalAllowedAgents, | 3325 | totalAllowedAgents, |
3326 | ESTATE_MAX_ACCESS_IDS); | 3326 | ESTATE_MAX_ACCESS_IDS); |
3327 | panel->childSetValue("allow_resident_label", LLSD(msg)); | 3327 | panel->childSetValue("allow_resident_label", LLSD(msg)); |
3328 | 3328 | ||
3329 | if (allowed_agent_name_list) | 3329 | if (allowed_agent_name_list) |
3330 | { | 3330 | { |
3331 | //allowed_agent_name_list->deleteAllItems(); | 3331 | //allowed_agent_name_list->deleteAllItems(); |
3332 | for (S32 i = 0; i < num_allowed_agents && i < ESTATE_MAX_ACCESS_IDS; i++) | 3332 | for (S32 i = 0; i < num_allowed_agents && i < ESTATE_MAX_ACCESS_IDS; i++) |
3333 | { | 3333 | { |
3334 | LLUUID id; | 3334 | LLUUID id; |
3335 | memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ | 3335 | memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ |
3336 | allowed_agent_name_list->addNameItem(id); | 3336 | allowed_agent_name_list->addNameItem(id); |
3337 | } | 3337 | } |
3338 | panel->childSetEnabled("remove_allowed_avatar_btn", allowed_agent_name_list->getFirstSelected() ? TRUE : FALSE); | 3338 | panel->childSetEnabled("remove_allowed_avatar_btn", allowed_agent_name_list->getFirstSelected() ? TRUE : FALSE); |
3339 | allowed_agent_name_list->sortByColumnIndex(0, TRUE); | 3339 | allowed_agent_name_list->sortByColumnIndex(0, TRUE); |
3340 | } | 3340 | } |
3341 | } | 3341 | } |
3342 | 3342 | ||
3343 | if (access_flags & ESTATE_ACCESS_ALLOWED_GROUPS) | 3343 | if (access_flags & ESTATE_ACCESS_ALLOWED_GROUPS) |
3344 | { | 3344 | { |
3345 | LLNameListCtrl* allowed_group_name_list; | 3345 | LLNameListCtrl* allowed_group_name_list; |
3346 | allowed_group_name_list = panel->getChild<LLNameListCtrl>("allowed_group_name_list"); | 3346 | allowed_group_name_list = panel->getChild<LLNameListCtrl>("allowed_group_name_list"); |
3347 | 3347 | ||
3348 | std::string msg = llformat("Allowed groups: (%d, max %d)", | 3348 | std::string msg = llformat("Allowed groups: (%d, max %d)", |
3349 | num_allowed_groups, | 3349 | num_allowed_groups, |
3350 | (S32) ESTATE_MAX_GROUP_IDS); | 3350 | (S32) ESTATE_MAX_GROUP_IDS); |
3351 | panel->childSetValue("allow_group_label", LLSD(msg)); | 3351 | panel->childSetValue("allow_group_label", LLSD(msg)); |
3352 | 3352 | ||
3353 | if (allowed_group_name_list) | 3353 | if (allowed_group_name_list) |
3354 | { | 3354 | { |
3355 | allowed_group_name_list->deleteAllItems(); | 3355 | allowed_group_name_list->deleteAllItems(); |
3356 | for (S32 i = 0; i < num_allowed_groups && i < ESTATE_MAX_GROUP_IDS; i++) | 3356 | for (S32 i = 0; i < num_allowed_groups && i < ESTATE_MAX_GROUP_IDS; i++) |
3357 | { | 3357 | { |
3358 | LLUUID id; | 3358 | LLUUID id; |
3359 | memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ | 3359 | memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ |
3360 | allowed_group_name_list->addGroupNameItem(id); | 3360 | allowed_group_name_list->addGroupNameItem(id); |
3361 | } | 3361 | } |
3362 | panel->childSetEnabled("remove_allowed_group_btn", allowed_group_name_list->getFirstSelected() ? TRUE : FALSE); | 3362 | panel->childSetEnabled("remove_allowed_group_btn", allowed_group_name_list->getFirstSelected() ? TRUE : FALSE); |
3363 | allowed_group_name_list->sortByColumnIndex(0, TRUE); | 3363 | allowed_group_name_list->sortByColumnIndex(0, TRUE); |
3364 | } | 3364 | } |
3365 | } | 3365 | } |
3366 | 3366 | ||
3367 | if (access_flags & ESTATE_ACCESS_BANNED_AGENTS) | 3367 | if (access_flags & ESTATE_ACCESS_BANNED_AGENTS) |
3368 | { | 3368 | { |
3369 | LLNameListCtrl* banned_agent_name_list; | 3369 | LLNameListCtrl* banned_agent_name_list; |
3370 | banned_agent_name_list = panel->getChild<LLNameListCtrl>("banned_avatar_name_list"); | 3370 | banned_agent_name_list = panel->getChild<LLNameListCtrl>("banned_avatar_name_list"); |
3371 | 3371 | ||
3372 | int totalBannedAgents = num_banned_agents; | 3372 | int totalBannedAgents = num_banned_agents; |
3373 | 3373 | ||
3374 | if (banned_agent_name_list) | 3374 | if (banned_agent_name_list) |
3375 | { | 3375 | { |
3376 | totalBannedAgents += banned_agent_name_list->getItemCount(); | 3376 | totalBannedAgents += banned_agent_name_list->getItemCount(); |
3377 | } | 3377 | } |
3378 | 3378 | ||
3379 | 3379 | ||
3380 | std::string msg = llformat("Banned residents: (%d, max %d)", | 3380 | std::string msg = llformat("Banned residents: (%d, max %d)", |
3381 | totalBannedAgents, | 3381 | totalBannedAgents, |
3382 | ESTATE_MAX_ACCESS_IDS); | 3382 | ESTATE_MAX_ACCESS_IDS); |
3383 | panel->childSetValue("ban_resident_label", LLSD(msg)); | 3383 | panel->childSetValue("ban_resident_label", LLSD(msg)); |
3384 | 3384 | ||
3385 | if (banned_agent_name_list) | 3385 | if (banned_agent_name_list) |
3386 | { | 3386 | { |
3387 | //banned_agent_name_list->deleteAllItems(); | 3387 | //banned_agent_name_list->deleteAllItems(); |
3388 | for (S32 i = 0; i < num_banned_agents && i < ESTATE_MAX_ACCESS_IDS; i++) | 3388 | for (S32 i = 0; i < num_banned_agents && i < ESTATE_MAX_ACCESS_IDS; i++) |
3389 | { | 3389 | { |
3390 | LLUUID id; | 3390 | LLUUID id; |
3391 | memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ | 3391 | memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ |
3392 | banned_agent_name_list->addNameItem(id); | 3392 | banned_agent_name_list->addNameItem(id); |
3393 | } | 3393 | } |
3394 | panel->childSetEnabled("remove_banned_avatar_btn", banned_agent_name_list->getFirstSelected() ? TRUE : FALSE); | 3394 | panel->childSetEnabled("remove_banned_avatar_btn", banned_agent_name_list->getFirstSelected() ? TRUE : FALSE); |
3395 | banned_agent_name_list->sortByColumnIndex(0, TRUE); | 3395 | banned_agent_name_list->sortByColumnIndex(0, TRUE); |
3396 | } | 3396 | } |
3397 | } | 3397 | } |
3398 | 3398 | ||
3399 | if (access_flags & ESTATE_ACCESS_MANAGERS) | 3399 | if (access_flags & ESTATE_ACCESS_MANAGERS) |
3400 | { | 3400 | { |
3401 | std::string msg = llformat("Estate Managers: (%d, max %d)", | 3401 | std::string msg = llformat("Estate Managers: (%d, max %d)", |
3402 | num_estate_managers, | 3402 | num_estate_managers, |
3403 | ESTATE_MAX_MANAGERS); | 3403 | ESTATE_MAX_MANAGERS); |
3404 | panel->childSetValue("estate_manager_label", LLSD(msg)); | 3404 | panel->childSetValue("estate_manager_label", LLSD(msg)); |
3405 | 3405 | ||
3406 | LLNameListCtrl* estate_manager_name_list = | 3406 | LLNameListCtrl* estate_manager_name_list = |
3407 | panel->getChild<LLNameListCtrl>("estate_manager_name_list"); | 3407 | panel->getChild<LLNameListCtrl>("estate_manager_name_list"); |
3408 | if (estate_manager_name_list) | 3408 | if (estate_manager_name_list) |
3409 | { | 3409 | { |
3410 | estate_manager_name_list->deleteAllItems(); // Clear existing entries | 3410 | estate_manager_name_list->deleteAllItems(); // Clear existing entries |
3411 | 3411 | ||
3412 | // There should be only ESTATE_MAX_MANAGERS people in the list, but if the database gets more (SL-46107) don't | 3412 | // There should be only ESTATE_MAX_MANAGERS people in the list, but if the database gets more (SL-46107) don't |
3413 | // truncate the list unless it's really big. Go ahead and show the extras so the user doesn't get confused, | 3413 | // truncate the list unless it's really big. Go ahead and show the extras so the user doesn't get confused, |
3414 | // and they can still remove them. | 3414 | // and they can still remove them. |
3415 | for (S32 i = 0; i < num_estate_managers && i < (ESTATE_MAX_MANAGERS * 4); i++) | 3415 | for (S32 i = 0; i < num_estate_managers && i < (ESTATE_MAX_MANAGERS * 4); i++) |
3416 | { | 3416 | { |
3417 | LLUUID id; | 3417 | LLUUID id; |
3418 | memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ | 3418 | memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ |
3419 | estate_manager_name_list->addNameItem(id); | 3419 | estate_manager_name_list->addNameItem(id); |
3420 | } | 3420 | } |
3421 | panel->childSetEnabled("remove_estate_manager_btn", estate_manager_name_list->getFirstSelected() ? TRUE : FALSE); | 3421 | panel->childSetEnabled("remove_estate_manager_btn", estate_manager_name_list->getFirstSelected() ? TRUE : FALSE); |
3422 | estate_manager_name_list->sortByColumnIndex(0, TRUE); | 3422 | estate_manager_name_list->sortByColumnIndex(0, TRUE); |
3423 | } | 3423 | } |
3424 | } | 3424 | } |
3425 | 3425 | ||
3426 | return true; | 3426 | return true; |
3427 | } | 3427 | } |
3428 | 3428 | ||
3429 | // [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a) | 3429 | // [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a) |
3430 | void LLFloaterRegionInfo::open() | 3430 | void LLFloaterRegionInfo::open() |
3431 | { | 3431 | { |
3432 | // We'll allow access to the estate tools for estate managers (and for the sim owner) | 3432 | // We'll allow access to the estate tools for estate managers (and for the sim owner) |
3433 | if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) | 3433 | if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) |
3434 | { | 3434 | { |
3435 | LLViewerRegion* pRegion = gAgent.getRegion(); | 3435 | LLViewerRegion* pRegion = gAgent.getRegion(); |
3436 | if (!pRegion) | 3436 | if (!pRegion) |
3437 | return; | 3437 | return; |
3438 | 3438 | ||
3439 | // Should be able to call LLRegion::canManageEstate() but then we can fake god like | 3439 | // Should be able to call LLRegion::canManageEstate() but then we can fake god like |
3440 | if ( (!pRegion->isEstateManager()) && (pRegion->getOwner() != gAgent.getID()) ) | 3440 | if ( (!pRegion->isEstateManager()) && (pRegion->getOwner() != gAgent.getID()) ) |
3441 | return; | 3441 | return; |
3442 | } | 3442 | } |
3443 | 3443 | ||
3444 | LLFloater::open(); | 3444 | LLFloater::open(); |
3445 | } | 3445 | } |
3446 | // [/RLVa:KB] | 3446 | // [/RLVa:KB] |
diff --git a/linden/indra/newview/llfloatertos.cpp b/linden/indra/newview/llfloatertos.cpp index ac4a06b..efc8bd6 100644 --- a/linden/indra/newview/llfloatertos.cpp +++ b/linden/indra/newview/llfloatertos.cpp | |||
@@ -1,305 +1,305 @@ | |||
1 | /** | 1 | /** |
2 | * @file llfloatertos.cpp | 2 | * @file llfloatertos.cpp |
3 | * @brief Terms of Service Agreement dialog | 3 | * @brief Terms of Service Agreement dialog |
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2003&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2003&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2003-2009, Linden Research, Inc. | 7 | * Copyright (c) 2003-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 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 | 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 | 12 | * ("GPL"), unless you have obtained a separate licensing agreement |
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | 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 | 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 | 15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 |
16 | * | 16 | * |
17 | * There are special exceptions to the terms and conditions of the GPL as | 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 | 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 | 19 | * in the file doc/FLOSS-exception.txt in this software distribution, or |
20 | * online at | 20 | * online at |
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | 21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception |
22 | * | 22 | * |
23 | * By copying, modifying or distributing this software, you acknowledge | 23 | * By copying, modifying or distributing this software, you acknowledge |
24 | * that you have read and understood your obligations described above, | 24 | * that you have read and understood your obligations described above, |
25 | * and agree to abide by those obligations. | 25 | * and agree to abide by those obligations. |
26 | * | 26 | * |
27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | 27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO |
28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | 28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, |
29 | * COMPLETENESS OR PERFORMANCE. | 29 | * COMPLETENESS OR PERFORMANCE. |
30 | * $/LicenseInfo$ | 30 | * $/LicenseInfo$ |
31 | */ | 31 | */ |
32 | 32 | ||
33 | #include "llviewerprecompiledheaders.h" | 33 | #include "llviewerprecompiledheaders.h" |
34 | 34 | ||
35 | #include "llfloatertos.h" | 35 | #include "llfloatertos.h" |
36 | 36 | ||
37 | // viewer includes | 37 | // viewer includes |
38 | #include "llagent.h" | 38 | #include "llagent.h" |
39 | #include "llappviewer.h" | 39 | #include "llappviewer.h" |
40 | #include "llstartup.h" | 40 | #include "llstartup.h" |
41 | #include "llviewerstats.h" | 41 | #include "llviewerstats.h" |
42 | #include "llviewertexteditor.h" | 42 | #include "llviewertexteditor.h" |
43 | #include "llviewerwindow.h" | 43 | #include "llviewerwindow.h" |
44 | 44 | ||
45 | // linden library includes | 45 | // linden library includes |
46 | #include "llbutton.h" | 46 | #include "llbutton.h" |
47 | #include "llhttpclient.h" | 47 | #include "llhttpclient.h" |
48 | #include "llhttpstatuscodes.h" // for HTTP_FOUND | 48 | #include "llhttpstatuscodes.h" // for HTTP_FOUND |
49 | #include "llradiogroup.h" | 49 | #include "llradiogroup.h" |
50 | #include "lltextbox.h" | 50 | #include "lltextbox.h" |
51 | #include "llui.h" | 51 | #include "llui.h" |
52 | #include "lluictrlfactory.h" | 52 | #include "lluictrlfactory.h" |
53 | #include "llvfile.h" | 53 | #include "llvfile.h" |
54 | #include "message.h" | 54 | #include "message.h" |
55 | #include "hippogridmanager.h" | 55 | #include "hippogridmanager.h" |
56 | 56 | ||
57 | 57 | ||
58 | // static | 58 | // static |
59 | LLFloaterTOS* LLFloaterTOS::sInstance = NULL; | 59 | LLFloaterTOS* LLFloaterTOS::sInstance = NULL; |
60 | 60 | ||
61 | // static | 61 | // static |
62 | LLFloaterTOS* LLFloaterTOS::show(ETOSType type, const std::string & message) | 62 | LLFloaterTOS* LLFloaterTOS::show(ETOSType type, const std::string & message) |
63 | { | 63 | { |
64 | if( !LLFloaterTOS::sInstance ) | 64 | if( !LLFloaterTOS::sInstance ) |
65 | { | 65 | { |
66 | LLFloaterTOS::sInstance = new LLFloaterTOS(type, message); | 66 | LLFloaterTOS::sInstance = new LLFloaterTOS(type, message); |
67 | } | 67 | } |
68 | 68 | ||
69 | if (type == TOS_TOS) | 69 | if (type == TOS_TOS) |
70 | { | 70 | { |
71 | LLUICtrlFactory::getInstance()->buildFloater(LLFloaterTOS::sInstance, "floater_tos.xml"); | 71 | LLUICtrlFactory::getInstance()->buildFloater(LLFloaterTOS::sInstance, "floater_tos.xml"); |
72 | } | 72 | } |
73 | else | 73 | else |
74 | { | 74 | { |
75 | LLUICtrlFactory::getInstance()->buildFloater(LLFloaterTOS::sInstance, "floater_critical.xml"); | 75 | LLUICtrlFactory::getInstance()->buildFloater(LLFloaterTOS::sInstance, "floater_critical.xml"); |
76 | } | 76 | } |
77 | 77 | ||
78 | return LLFloaterTOS::sInstance; | 78 | return LLFloaterTOS::sInstance; |
79 | } | 79 | } |
80 | 80 | ||
81 | 81 | ||
82 | LLFloaterTOS::LLFloaterTOS(ETOSType type, const std::string & message) | 82 | LLFloaterTOS::LLFloaterTOS(ETOSType type, const std::string & message) |
83 | : LLModalDialog( std::string(" "), 100, 100 ), | 83 | : LLModalDialog( std::string(" "), 100, 100 ), |
84 | mType(type), | 84 | mType(type), |
85 | mMessage(message), | 85 | mMessage(message), |
86 | mWebBrowserWindowId( 0 ), | 86 | mWebBrowserWindowId( 0 ), |
87 | mLoadCompleteCount( 0 ) | 87 | mLoadCompleteCount( 0 ) |
88 | { | 88 | { |
89 | } | 89 | } |
90 | 90 | ||
91 | // helper class that trys to download a URL from a web site and calls a method | 91 | // helper class that trys to download a URL from a web site and calls a method |
92 | // on parent class indicating if the web server is working or not | 92 | // on parent class indicating if the web server is working or not |
93 | class LLIamHereTOS : public LLHTTPClient::Responder | 93 | class LLIamHereTOS : public LLHTTPClient::Responder |
94 | { | 94 | { |
95 | private: | 95 | private: |
96 | LLIamHereTOS( LLFloaterTOS* parent ) : | 96 | LLIamHereTOS( LLFloaterTOS* parent ) : |
97 | mParent( parent ) | 97 | mParent( parent ) |
98 | {} | 98 | {} |
99 | 99 | ||
100 | LLFloaterTOS* mParent; | 100 | LLFloaterTOS* mParent; |
101 | 101 | ||
102 | public: | 102 | public: |
103 | 103 | ||
104 | static boost::intrusive_ptr< LLIamHereTOS > build( LLFloaterTOS* parent ) | 104 | static boost::intrusive_ptr< LLIamHereTOS > build( LLFloaterTOS* parent ) |
105 | { | 105 | { |
106 | return boost::intrusive_ptr< LLIamHereTOS >( new LLIamHereTOS( parent ) ); | 106 | return boost::intrusive_ptr< LLIamHereTOS >( new LLIamHereTOS( parent ) ); |
107 | }; | 107 | }; |
108 | 108 | ||
109 | virtual void setParent( LLFloaterTOS* parentIn ) | 109 | virtual void setParent( LLFloaterTOS* parentIn ) |
110 | { | 110 | { |
111 | mParent = parentIn; | 111 | mParent = parentIn; |
112 | }; | 112 | }; |
113 | 113 | ||
114 | virtual void result( const LLSD& content ) | 114 | virtual void result( const LLSD& content ) |
115 | { | 115 | { |
116 | if ( mParent ) | 116 | if ( mParent ) |
117 | mParent->setSiteIsAlive( true ); | 117 | mParent->setSiteIsAlive( true ); |
118 | }; | 118 | }; |
119 | 119 | ||
120 | virtual void error( U32 status, const std::string& reason ) | 120 | virtual void error( U32 status, const std::string& reason ) |
121 | { | 121 | { |
122 | if ( mParent ) | 122 | if ( mParent ) |
123 | { | 123 | { |
124 | // *HACK: For purposes of this alive check, 302 Found | 124 | // *HACK: For purposes of this alive check, 302 Found |
125 | // (aka Moved Temporarily) is considered alive. The web site | 125 | // (aka Moved Temporarily) is considered alive. The web site |
126 | // redirects this link to a "cache busting" temporary URL. JC | 126 | // redirects this link to a "cache busting" temporary URL. JC |
127 | bool alive = (status == HTTP_FOUND); | 127 | bool alive = (status == HTTP_FOUND); |
128 | mParent->setSiteIsAlive( alive ); | 128 | mParent->setSiteIsAlive( alive ); |
129 | } | 129 | } |
130 | }; | 130 | }; |
131 | }; | 131 | }; |
132 | 132 | ||
133 | // this is global and not a class member to keep crud out of the header file | 133 | // this is global and not a class member to keep crud out of the header file |
134 | namespace { | 134 | namespace { |
135 | boost::intrusive_ptr< LLIamHereTOS > gResponsePtr = 0; | 135 | boost::intrusive_ptr< LLIamHereTOS > gResponsePtr = 0; |
136 | }; | 136 | }; |
137 | 137 | ||
138 | BOOL LLFloaterTOS::postBuild() | 138 | BOOL LLFloaterTOS::postBuild() |
139 | { | 139 | { |
140 | childSetAction("Continue", onContinue, this); | 140 | childSetAction("Continue", onContinue, this); |
141 | childSetAction("Cancel", onCancel, this); | 141 | childSetAction("Cancel", onCancel, this); |
142 | childSetCommitCallback("agree_chk", updateAgree, this); | 142 | childSetCommitCallback("agree_chk", updateAgree, this); |
143 | 143 | ||
144 | LLCheckBoxCtrl* tos_agreement = getChild<LLCheckBoxCtrl>("agree_chk"); | 144 | LLCheckBoxCtrl* tos_agreement = getChild<LLCheckBoxCtrl>("agree_chk"); |
145 | tos_agreement->setEnabled( true ); | 145 | tos_agreement->setEnabled( true ); |
146 | 146 | ||
147 | //Always set this so that the TOS is displayed whether the web browser pops up or not. | 147 | //Always set this so that the TOS is displayed whether the web browser pops up or not. |
148 | LLTextEditor *editor = getChild<LLTextEditor>("tos_text"); | 148 | LLTextEditor *editor = getChild<LLTextEditor>("tos_text"); |
149 | editor->setHandleEditKeysDirectly( TRUE ); | 149 | editor->setHandleEditKeysDirectly( TRUE ); |
150 | editor->setEnabled( FALSE ); | 150 | editor->setEnabled( FALSE ); |
151 | editor->setWordWrap(TRUE); | 151 | editor->setWordWrap(TRUE); |
152 | editor->setFocus(TRUE); | 152 | editor->setFocus(TRUE); |
153 | editor->setValue(LLSD(mMessage)); | 153 | editor->setValue(LLSD(mMessage)); |
154 | LLMediaCtrl* web_browser = getChild<LLMediaCtrl>("tos_html"); | 154 | LLMediaCtrl* web_browser = getChild<LLMediaCtrl>("tos_html"); |
155 | if (web_browser) | 155 | if (web_browser) |
156 | { | 156 | { |
157 | //Disable for critical messages and text messages, it is reenabled later | 157 | //Disable for critical messages and text messages, it is reenabled later |
158 | web_browser->setVisible( FALSE ); | 158 | web_browser->setVisible( FALSE ); |
159 | } | 159 | } |
160 | 160 | ||
161 | if ( mType != TOS_TOS ) | 161 | if ( mType != TOS_TOS ) |
162 | { | 162 | { |
163 | // this displays the critical message only | 163 | // this displays the critical message only |
164 | return TRUE; | 164 | return TRUE; |
165 | } | 165 | } |
166 | bool use_web_browser = false; | 166 | bool use_web_browser = false; |
167 | 167 | ||
168 | //Check to see if the message is a link to display | 168 | //Check to see if the message is a link to display |
169 | std::string token = "http://"; | 169 | std::string token = "http://"; |
170 | std::string::size_type iIndex = mMessage.rfind(token); | 170 | std::string::size_type iIndex = mMessage.rfind(token); |
171 | //IF it has http:// in it, we use the web browser | 171 | //IF it has http:// in it, we use the web browser |
172 | if(iIndex != std::string::npos && mMessage.length() >= 2) | 172 | if(iIndex != std::string::npos && mMessage.length() >= 2) |
173 | { | 173 | { |
174 | // it exists | 174 | // it exists |
175 | use_web_browser = true; | 175 | use_web_browser = true; |
176 | } | 176 | } |
177 | else if (gHippoGridManager->getConnectedGrid()->isSecondLife()) | 177 | else if (gHippoGridManager->getConnectedGrid()->isSecondLife()) |
178 | { | 178 | { |
179 | //Its SL, use the browser for it as thats what it should do | 179 | //Its SL, use the browser for it as thats what it should do |
180 | use_web_browser = true; | 180 | use_web_browser = true; |
181 | } | 181 | } |
182 | 182 | ||
183 | if ( web_browser && use_web_browser) | 183 | if ( web_browser && use_web_browser) |
184 | { | 184 | { |
185 | // hide the SL text widget if we're displaying TOS with using a browser widget. | 185 | // hide the SL text widget if we're displaying TOS with using a browser widget. |
186 | LLTextEditor *editor = getChild<LLTextEditor>("tos_text"); | 186 | LLTextEditor *editor = getChild<LLTextEditor>("tos_text"); |
187 | editor->setVisible( FALSE ); | 187 | editor->setVisible( FALSE ); |
188 | 188 | ||
189 | // disable Agree to TOS radio button until the page has fully loaded | 189 | // disable Agree to TOS radio button until the page has fully loaded |
190 | tos_agreement->setEnabled( false ); | 190 | tos_agreement->setEnabled( false ); |
191 | 191 | ||
192 | // Reenable the web browser | 192 | // Reenable the web browser |
193 | web_browser->setVisible( TRUE ); | 193 | web_browser->setVisible( TRUE ); |
194 | 194 | ||
195 | web_browser->addObserver(this); | 195 | web_browser->addObserver(this); |
196 | gResponsePtr = LLIamHereTOS::build( this ); | 196 | gResponsePtr = LLIamHereTOS::build( this ); |
197 | LLHTTPClient::head( getString( "real_url" ), gResponsePtr ); | 197 | LLHTTPClient::head( getString( "real_url" ), gResponsePtr ); |
198 | } | 198 | } |
199 | 199 | ||
200 | return TRUE; | 200 | return TRUE; |
201 | } | 201 | } |
202 | 202 | ||
203 | void LLFloaterTOS::setSiteIsAlive( bool alive ) | 203 | void LLFloaterTOS::setSiteIsAlive( bool alive ) |
204 | { | 204 | { |
205 | // only do this for TOS pages | 205 | // only do this for TOS pages |
206 | if ( mType == TOS_TOS ) | 206 | if ( mType == TOS_TOS ) |
207 | { | 207 | { |
208 | LLMediaCtrl* web_browser = getChild<LLMediaCtrl>("tos_html"); | 208 | LLMediaCtrl* web_browser = getChild<LLMediaCtrl>("tos_html"); |
209 | // if the contents of the site was retrieved | 209 | // if the contents of the site was retrieved |
210 | if ( alive ) | 210 | if ( alive ) |
211 | { | 211 | { |
212 | if ( web_browser ) | 212 | if ( web_browser ) |
213 | { | 213 | { |
214 | // navigate to the "real" page | 214 | // navigate to the "real" page |
215 | web_browser->navigateTo( getString( "real_url" ) ); | 215 | web_browser->navigateTo( getString( "real_url" ) ); |
216 | }; | 216 | }; |
217 | } | 217 | } |
218 | else | 218 | else |
219 | { | 219 | { |
220 | // normally this is set when navigation to TOS page navigation completes (so you can't accept before TOS loads) | 220 | // normally this is set when navigation to TOS page navigation completes (so you can't accept before TOS loads) |
221 | // but if the page is unavailable, we need to do this now | 221 | // but if the page is unavailable, we need to do this now |
222 | LLCheckBoxCtrl* tos_agreement = getChild<LLCheckBoxCtrl>("agree_chk"); | 222 | LLCheckBoxCtrl* tos_agreement = getChild<LLCheckBoxCtrl>("agree_chk"); |
223 | tos_agreement->setEnabled( true ); | 223 | tos_agreement->setEnabled( true ); |
224 | }; | 224 | }; |
225 | }; | 225 | }; |
226 | } | 226 | } |
227 | 227 | ||
228 | LLFloaterTOS::~LLFloaterTOS() | 228 | LLFloaterTOS::~LLFloaterTOS() |
229 | { | 229 | { |
230 | 230 | ||
231 | // tell the responder we're not here anymore | 231 | // tell the responder we're not here anymore |
232 | if ( gResponsePtr ) | 232 | if ( gResponsePtr ) |
233 | gResponsePtr->setParent( 0 ); | 233 | gResponsePtr->setParent( 0 ); |
234 | 234 | ||
235 | LLFloaterTOS::sInstance = NULL; | 235 | LLFloaterTOS::sInstance = NULL; |
236 | } | 236 | } |
237 | 237 | ||
238 | // virtual | 238 | // virtual |
239 | void LLFloaterTOS::draw() | 239 | void LLFloaterTOS::draw() |
240 | { | 240 | { |
241 | // draw children | 241 | // draw children |
242 | LLModalDialog::draw(); | 242 | LLModalDialog::draw(); |
243 | } | 243 | } |
244 | 244 | ||
245 | // static | 245 | // static |
246 | void LLFloaterTOS::updateAgree(LLUICtrl*, void* userdata ) | 246 | void LLFloaterTOS::updateAgree(LLUICtrl*, void* userdata ) |
247 | { | 247 | { |
248 | LLFloaterTOS* self = (LLFloaterTOS*) userdata; | 248 | LLFloaterTOS* self = (LLFloaterTOS*) userdata; |
249 | bool agree = self->childGetValue("agree_chk").asBoolean(); | 249 | bool agree = self->childGetValue("agree_chk").asBoolean(); |
250 | self->childSetEnabled("Continue", agree); | 250 | self->childSetEnabled("Continue", agree); |
251 | } | 251 | } |
252 | 252 | ||
253 | // static | 253 | // static |
254 | void LLFloaterTOS::onContinue( void* userdata ) | 254 | void LLFloaterTOS::onContinue( void* userdata ) |
255 | { | 255 | { |
256 | LLFloaterTOS* self = (LLFloaterTOS*) userdata; | 256 | LLFloaterTOS* self = (LLFloaterTOS*) userdata; |
257 | llinfos << "User agrees with TOS." << llendl; | 257 | llinfos << "User agrees with TOS." << llendl; |
258 | if (self->mType == TOS_TOS) | 258 | if (self->mType == TOS_TOS) |
259 | { | 259 | { |
260 | gAcceptTOS = TRUE; | 260 | gAcceptTOS = TRUE; |
261 | } | 261 | } |
262 | else | 262 | else |
263 | { | 263 | { |
264 | gAcceptCriticalMessage = TRUE; | 264 | gAcceptCriticalMessage = TRUE; |
265 | } | 265 | } |
266 | 266 | ||
267 | // Testing TOS dialog | 267 | // Testing TOS dialog |
268 | #if ! LL_RELEASE_FOR_DOWNLOAD | 268 | #if ! LL_RELEASE_FOR_DOWNLOAD |
269 | if ( LLStartUp::getStartupState() == STATE_LOGIN_WAIT ) | 269 | if ( LLStartUp::getStartupState() == STATE_LOGIN_WAIT ) |
270 | { | 270 | { |
271 | LLStartUp::setStartupState( STATE_LOGIN_SHOW ); | 271 | LLStartUp::setStartupState( STATE_LOGIN_SHOW ); |
272 | } | 272 | } |
273 | else | 273 | else |
274 | #endif | 274 | #endif |
275 | 275 | ||
276 | LLStartUp::setStartupState( STATE_LOGIN_AUTH_INIT ); // Go back and finish authentication | 276 | LLStartUp::setStartupState( STATE_LOGIN_AUTH_INIT ); // Go back and finish authentication |
277 | self->close(); // destroys this object | 277 | self->close(); // destroys this object |
278 | } | 278 | } |
279 | 279 | ||
280 | // static | 280 | // static |
281 | void LLFloaterTOS::onCancel( void* userdata ) | 281 | void LLFloaterTOS::onCancel( void* userdata ) |
282 | { | 282 | { |
283 | LLFloaterTOS* self = (LLFloaterTOS*) userdata; | 283 | LLFloaterTOS* self = (LLFloaterTOS*) userdata; |
284 | llinfos << "User disagrees with TOS." << llendl; | 284 | llinfos << "User disagrees with TOS." << llendl; |
285 | LLNotifications::instance().add("MustAgreeToLogIn", LLSD(), LLSD(), login_alert_done); | 285 | LLNotifications::instance().add("MustAgreeToLogIn", LLSD(), LLSD(), login_alert_done); |
286 | LLStartUp::setStartupState( STATE_LOGIN_SHOW ); | 286 | LLStartUp::setStartupState( STATE_LOGIN_SHOW ); |
287 | self->mLoadCompleteCount = 0; // reset counter for next time we come to TOS | 287 | self->mLoadCompleteCount = 0; // reset counter for next time we come to TOS |
288 | self->close(); // destroys this object | 288 | self->close(); // destroys this object |
289 | } | 289 | } |
290 | 290 | ||
291 | //virtual | 291 | //virtual |
292 | void LLFloaterTOS::handleMediaEvent(LLPluginClassMedia* /*self*/, EMediaEvent event) | 292 | void LLFloaterTOS::handleMediaEvent(LLPluginClassMedia* /*self*/, EMediaEvent event) |
293 | { | 293 | { |
294 | if(event == MEDIA_EVENT_NAVIGATE_COMPLETE) | 294 | if(event == MEDIA_EVENT_NAVIGATE_COMPLETE) |
295 | { | 295 | { |
296 | // skip past the loading screen navigate complete | 296 | // skip past the loading screen navigate complete |
297 | if ( ++mLoadCompleteCount == 2 ) | 297 | if ( ++mLoadCompleteCount == 2 ) |
298 | { | 298 | { |
299 | llinfos << "NAVIGATE COMPLETE" << llendl; | 299 | llinfos << "NAVIGATE COMPLETE" << llendl; |
300 | // enable Agree to TOS radio button now that page has loaded | 300 | // enable Agree to TOS radio button now that page has loaded |
301 | LLCheckBoxCtrl * tos_agreement = getChild<LLCheckBoxCtrl>("agree_chk"); | 301 | LLCheckBoxCtrl * tos_agreement = getChild<LLCheckBoxCtrl>("agree_chk"); |
302 | tos_agreement->setEnabled( true ); | 302 | tos_agreement->setEnabled( true ); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | } | 305 | } |
diff --git a/linden/indra/newview/llmaniptranslate.cpp b/linden/indra/newview/llmaniptranslate.cpp index 8484c4e..3b78553 100644 --- a/linden/indra/newview/llmaniptranslate.cpp +++ b/linden/indra/newview/llmaniptranslate.cpp | |||
@@ -531,7 +531,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask) | |||
531 | // You can't move more than some distance from your original mousedown point. | 531 | // You can't move more than some distance from your original mousedown point. |
532 | F32 max_drag_distance = gHippoLimits->getMaxDragDistance(); | 532 | F32 max_drag_distance = gHippoLimits->getMaxDragDistance(); |
533 | 533 | ||
534 | if (max_drag_distance != FLT_MAX && relative_move.magVecSquared() > max_drag_distance * max_drag_distance) | 534 | if (max_drag_distance != FLT_MAX && relative_move.magVecSquared() > max_drag_distance * max_drag_distance) |
535 | { | 535 | { |
536 | lldebugst(LLERR_USER_INPUT) << "hover handled by LLManipTranslate (too far)" << llendl; | 536 | lldebugst(LLERR_USER_INPUT) << "hover handled by LLManipTranslate (too far)" << llendl; |
537 | gViewerWindow->setCursor(UI_CURSOR_NOLOCKED); | 537 | gViewerWindow->setCursor(UI_CURSOR_NOLOCKED); |
diff --git a/linden/indra/newview/llmapresponders.cpp b/linden/indra/newview/llmapresponders.cpp index b6b5c8a..31c04a3 100644 --- a/linden/indra/newview/llmapresponders.cpp +++ b/linden/indra/newview/llmapresponders.cpp | |||
@@ -120,8 +120,8 @@ void LLMapLayerResponder::result(const LLSD& result) | |||
120 | 120 | ||
121 | S32 x_regions = map_block["X"]; | 121 | S32 x_regions = map_block["X"]; |
122 | S32 y_regions = map_block["Y"]; | 122 | S32 y_regions = map_block["Y"]; |
123 | S32 size_x_regions = map_block["SizeX"]; | 123 | S32 size_x_regions = map_block["SizeX"]; |
124 | S32 size_y_regions = map_block["SizeY"]; | 124 | S32 size_y_regions = map_block["SizeY"]; |
125 | std::string name = map_block["Name"]; | 125 | std::string name = map_block["Name"]; |
126 | S32 access = map_block["Access"]; | 126 | S32 access = map_block["Access"]; |
127 | S32 region_flags = map_block["RegionFlags"]; | 127 | S32 region_flags = map_block["RegionFlags"]; |
@@ -170,8 +170,8 @@ void LLMapLayerResponder::result(const LLSD& result) | |||
170 | LLWorldMap::getInstance()->mSimInfoMap[handle] = siminfo; | 170 | LLWorldMap::getInstance()->mSimInfoMap[handle] = siminfo; |
171 | 171 | ||
172 | siminfo->mHandle = handle; | 172 | siminfo->mHandle = handle; |
173 | siminfo->msizeX = size_x_regions; | 173 | siminfo->msizeX = size_x_regions; |
174 | siminfo->msizeY = size_y_regions; | 174 | siminfo->msizeY = size_y_regions; |
175 | siminfo->mName.assign( name ); | 175 | siminfo->mName.assign( name ); |
176 | siminfo->mAccess = access; /*Flawfinder: ignore*/ | 176 | siminfo->mAccess = access; /*Flawfinder: ignore*/ |
177 | siminfo->mRegionFlags = region_flags; | 177 | siminfo->mRegionFlags = region_flags; |
diff --git a/linden/indra/newview/llstartup.cpp b/linden/indra/newview/llstartup.cpp index 0b6d75f..164e038 100644 --- a/linden/indra/newview/llstartup.cpp +++ b/linden/indra/newview/llstartup.cpp | |||
@@ -368,7 +368,7 @@ bool idle_startup() | |||
368 | static U64 first_sim_handle = 0; | 368 | static U64 first_sim_handle = 0; |
369 | static LLHost first_sim; | 369 | static LLHost first_sim; |
370 | static std::string first_sim_seed_cap; | 370 | static std::string first_sim_seed_cap; |
371 | static U32 first_sim_size_x = 256; | 371 | static U32 first_sim_size_x = 256; |
372 | static U32 first_sim_size_y = 256; | 372 | static U32 first_sim_size_y = 256; |
373 | 373 | ||
374 | static LLVector3 initial_sun_direction(1.f, 0.f, 0.f); | 374 | static LLVector3 initial_sun_direction(1.f, 0.f, 0.f); |
@@ -1622,16 +1622,16 @@ bool idle_startup() | |||
1622 | first_sim_handle = to_region_handle(region_x, region_y); | 1622 | first_sim_handle = to_region_handle(region_x, region_y); |
1623 | } | 1623 | } |
1624 | 1624 | ||
1625 | text = LLUserAuth::getInstance()->getResponse("region_size_x"); | 1625 | text = LLUserAuth::getInstance()->getResponse("region_size_x"); |
1626 | if(!text.empty()) { | 1626 | if(!text.empty()) { |
1627 | first_sim_size_x = strtoul(text.c_str(), NULL, 10); | 1627 | first_sim_size_x = strtoul(text.c_str(), NULL, 10); |
1628 | LLViewerParcelMgr::getInstance()->init(first_sim_size_x); | 1628 | LLViewerParcelMgr::getInstance()->init(first_sim_size_x); |
1629 | } | 1629 | } |
1630 | 1630 | ||
1631 | //region Y size is currently unused, major refactoring required. - Patrick Sapinski (2/10/2011) | 1631 | //region Y size is currently unused, major refactoring required. - Patrick Sapinski (2/10/2011) |
1632 | text = LLUserAuth::getInstance()->getResponse("region_size_y"); | 1632 | text = LLUserAuth::getInstance()->getResponse("region_size_y"); |
1633 | if(!text.empty()) first_sim_size_y = strtoul(text.c_str(), NULL, 10); | 1633 | if(!text.empty()) first_sim_size_y = strtoul(text.c_str(), NULL, 10); |
1634 | 1634 | ||
1635 | const std::string look_at_str = LLUserAuth::getInstance()->getResponse("look_at"); | 1635 | const std::string look_at_str = LLUserAuth::getInstance()->getResponse("look_at"); |
1636 | if (!look_at_str.empty()) | 1636 | if (!look_at_str.empty()) |
1637 | { | 1637 | { |
diff --git a/linden/indra/newview/llsurface.cpp b/linden/indra/newview/llsurface.cpp index 66f8076..5a99e66 100644 --- a/linden/indra/newview/llsurface.cpp +++ b/linden/indra/newview/llsurface.cpp | |||
@@ -713,15 +713,15 @@ void LLSurface::decompressDCTPatch(LLBitPack &bitpack, LLGroupHeader *gopp, BOOL | |||
713 | break; | 713 | break; |
714 | } | 714 | } |
715 | 715 | ||
716 | if (b_large_patch) | 716 | if (b_large_patch) |
717 | { | 717 | { |
718 | i = ph.patchids >> 16; //x | 718 | i = ph.patchids >> 16; //x |
719 | j = ph.patchids & 0xFFFF; //y | 719 | j = ph.patchids & 0xFFFF; //y |
720 | } | 720 | } |
721 | else | 721 | else |
722 | { | 722 | { |
723 | i = ph.patchids >> 5; //x | 723 | i = ph.patchids >> 5; //x |
724 | j = ph.patchids & 0x1F; //y | 724 | j = ph.patchids & 0x1F; //y |
725 | } | 725 | } |
726 | 726 | ||
727 | if ((i >= mPatchesPerEdge) || (j >= mPatchesPerEdge)) | 727 | if ((i >= mPatchesPerEdge) || (j >= mPatchesPerEdge)) |
diff --git a/linden/indra/newview/llviewermessage.cpp b/linden/indra/newview/llviewermessage.cpp index 4de4768..f67f0dc 100755 --- a/linden/indra/newview/llviewermessage.cpp +++ b/linden/indra/newview/llviewermessage.cpp | |||
@@ -3531,16 +3531,16 @@ void process_teleport_finish(LLMessageSystem* msg, void**) | |||
3531 | U32 teleport_flags; | 3531 | U32 teleport_flags; |
3532 | msg->getU32Fast(_PREHASH_Info, _PREHASH_TeleportFlags, teleport_flags); | 3532 | msg->getU32Fast(_PREHASH_Info, _PREHASH_TeleportFlags, teleport_flags); |
3533 | 3533 | ||
3534 | U32 region_size_x = 256; | 3534 | U32 region_size_x = 256; |
3535 | msg->getU32Fast(_PREHASH_Info, _PREHASH_RegionSizeX, region_size_x); | 3535 | msg->getU32Fast(_PREHASH_Info, _PREHASH_RegionSizeX, region_size_x); |
3536 | U32 region_size_y = 256; | 3536 | U32 region_size_y = 256; |
3537 | msg->getU32Fast(_PREHASH_Info, _PREHASH_RegionSizeY, region_size_y); | 3537 | msg->getU32Fast(_PREHASH_Info, _PREHASH_RegionSizeY, region_size_y); |
3538 | 3538 | ||
3539 | //and a little hack for Second Life compatibility | 3539 | //and a little hack for Second Life compatibility |
3540 | if (region_size_y == 0 || region_size_x == 0) | 3540 | if (region_size_y == 0 || region_size_x == 0) |
3541 | { | 3541 | { |
3542 | region_size_x = 256; | 3542 | region_size_x = 256; |
3543 | region_size_y = 256; | 3543 | region_size_y = 256; |
3544 | } | 3544 | } |
3545 | 3545 | ||
3546 | std::string seedCap; | 3546 | std::string seedCap; |
@@ -3877,16 +3877,16 @@ void process_crossed_region(LLMessageSystem* msg, void**) | |||
3877 | std::string seedCap; | 3877 | std::string seedCap; |
3878 | msg->getStringFast(_PREHASH_RegionData, _PREHASH_SeedCapability, seedCap); | 3878 | msg->getStringFast(_PREHASH_RegionData, _PREHASH_SeedCapability, seedCap); |
3879 | 3879 | ||
3880 | U32 region_size_x = 256; | 3880 | U32 region_size_x = 256; |
3881 | msg->getU32(_PREHASH_RegionData, _PREHASH_RegionSizeX, region_size_x); | 3881 | msg->getU32(_PREHASH_RegionData, _PREHASH_RegionSizeX, region_size_x); |
3882 | U32 region_size_y = 256; | 3882 | U32 region_size_y = 256; |
3883 | msg->getU32(_PREHASH_RegionData, _PREHASH_RegionSizeY, region_size_y); | 3883 | msg->getU32(_PREHASH_RegionData, _PREHASH_RegionSizeY, region_size_y); |
3884 | 3884 | ||
3885 | //and a little hack for Second Life compatibility | 3885 | //and a little hack for Second Life compatibility |
3886 | if (region_size_y == 0 || region_size_x == 0) | 3886 | if (region_size_y == 0 || region_size_x == 0) |
3887 | { | 3887 | { |
3888 | region_size_x = 256; | 3888 | region_size_x = 256; |
3889 | region_size_y = 256; | 3889 | region_size_y = 256; |
3890 | } | 3890 | } |
3891 | 3891 | ||
3892 | send_complete_agent_movement(sim_host); | 3892 | send_complete_agent_movement(sim_host); |
diff --git a/linden/indra/newview/llviewerparcelmgr.cpp b/linden/indra/newview/llviewerparcelmgr.cpp index 7373c3f..b99b0c0 100644 --- a/linden/indra/newview/llviewerparcelmgr.cpp +++ b/linden/indra/newview/llviewerparcelmgr.cpp | |||
@@ -140,24 +140,24 @@ LLViewerParcelMgr::LLViewerParcelMgr() | |||
140 | mBlockedImage = gImageList.getImageFromFile("noentrylines.j2c"); | 140 | mBlockedImage = gImageList.getImageFromFile("noentrylines.j2c"); |
141 | mPassImage = gImageList.getImageFromFile("noentrypasslines.j2c"); | 141 | mPassImage = gImageList.getImageFromFile("noentrypasslines.j2c"); |
142 | 142 | ||
143 | init(256); | 143 | init(256); |
144 | } | 144 | } |
145 | 145 | ||
146 | //moved this stuff out of the constructor and into a function that we can call again after we get the region size. | 146 | //moved this stuff out of the constructor and into a function that we can call again after we get the region size. |
147 | //LLViewerParcelMgr needs to be changed so we either get an instance per region, or it handles various region sizes | 147 | //LLViewerParcelMgr needs to be changed so we either get an instance per region, or it handles various region sizes |
148 | //on a single grid properly - Patrick Sapinski (2/10/2011) | 148 | //on a single grid properly - Patrick Sapinski (2/10/2011) |
149 | void LLViewerParcelMgr::init(F32 region_size) | 149 | void LLViewerParcelMgr::init(F32 region_size) |
150 | { | 150 | { |
151 | mParcelsPerEdge = S32( region_size / PARCEL_GRID_STEP_METERS ); | 151 | mParcelsPerEdge = S32( region_size / PARCEL_GRID_STEP_METERS ); |
152 | mHighlightSegments = new U8[(mParcelsPerEdge+1)*(mParcelsPerEdge+1)]; | 152 | mHighlightSegments = new U8[(mParcelsPerEdge+1)*(mParcelsPerEdge+1)]; |
153 | resetSegments(mHighlightSegments); | 153 | resetSegments(mHighlightSegments); |
154 | 154 | ||
155 | mCollisionSegments = new U8[(mParcelsPerEdge+1)*(mParcelsPerEdge+1)]; | 155 | mCollisionSegments = new U8[(mParcelsPerEdge+1)*(mParcelsPerEdge+1)]; |
156 | resetSegments(mCollisionSegments); | 156 | resetSegments(mCollisionSegments); |
157 | 157 | ||
158 | S32 mParcelOverLayChunks = region_size * region_size / (128 * 128); | 158 | S32 mParcelOverLayChunks = region_size * region_size / (128 * 128); |
159 | 159 | ||
160 | S32 overlay_size = mParcelsPerEdge * mParcelsPerEdge / mParcelOverLayChunks; | 160 | S32 overlay_size = mParcelsPerEdge * mParcelsPerEdge / mParcelOverLayChunks; |
161 | sPackedOverlay = new U8[overlay_size]; | 161 | sPackedOverlay = new U8[overlay_size]; |
162 | 162 | ||
163 | mAgentParcelOverlay = new U8[mParcelsPerEdge * mParcelsPerEdge]; | 163 | mAgentParcelOverlay = new U8[mParcelsPerEdge * mParcelsPerEdge]; |
@@ -1361,7 +1361,7 @@ void LLViewerParcelMgr::processParcelOverlay(LLMessageSystem *msg, void **user) | |||
1361 | return; | 1361 | return; |
1362 | } | 1362 | } |
1363 | 1363 | ||
1364 | S32 expected_size = 1024; //parcels_per_edge * parcels_per_edge / PARCEL_OVERLAY_CHUNKS; | 1364 | S32 expected_size = 1024; //parcels_per_edge * parcels_per_edge / PARCEL_OVERLAY_CHUNKS; |
1365 | if (packed_overlay_size != expected_size) | 1365 | if (packed_overlay_size != expected_size) |
1366 | { | 1366 | { |
1367 | llwarns << "Got parcel overlay size " << packed_overlay_size | 1367 | llwarns << "Got parcel overlay size " << packed_overlay_size |
diff --git a/linden/indra/newview/llviewerparcelmgr.h b/linden/indra/newview/llviewerparcelmgr.h index dcdea3c..59e6186 100644 --- a/linden/indra/newview/llviewerparcelmgr.h +++ b/linden/indra/newview/llviewerparcelmgr.h | |||
@@ -82,8 +82,8 @@ public: | |||
82 | LLViewerParcelMgr(); | 82 | LLViewerParcelMgr(); |
83 | ~LLViewerParcelMgr(); | 83 | ~LLViewerParcelMgr(); |
84 | 84 | ||
85 | void init(F32 region_size); | 85 | void init(F32 region_size); |
86 | 86 | ||
87 | static void cleanupGlobals(); | 87 | static void cleanupGlobals(); |
88 | 88 | ||
89 | BOOL selectionEmpty() const; | 89 | BOOL selectionEmpty() const; |
diff --git a/linden/indra/newview/llviewerparceloverlay.cpp b/linden/indra/newview/llviewerparceloverlay.cpp index a31f153..4ae3253 100644 --- a/linden/indra/newview/llviewerparceloverlay.cpp +++ b/linden/indra/newview/llviewerparceloverlay.cpp | |||
@@ -58,7 +58,7 @@ const U8 OVERLAY_IMG_COMPONENTS = 4; | |||
58 | LLViewerParcelOverlay::LLViewerParcelOverlay(LLViewerRegion* region, F32 region_width_meters) | 58 | LLViewerParcelOverlay::LLViewerParcelOverlay(LLViewerRegion* region, F32 region_width_meters) |
59 | : mRegion( region ), | 59 | : mRegion( region ), |
60 | mParcelGridsPerEdge( S32( region_width_meters / PARCEL_GRID_STEP_METERS ) ), | 60 | mParcelGridsPerEdge( S32( region_width_meters / PARCEL_GRID_STEP_METERS ) ), |
61 | mRegionSize(S32(region_width_meters)), | 61 | mRegionSize(S32(region_width_meters)), |
62 | mDirty( FALSE ), | 62 | mDirty( FALSE ), |
63 | mTimeSinceLastUpdate(), | 63 | mTimeSinceLastUpdate(), |
64 | mOverlayTextureIdx(-1), | 64 | mOverlayTextureIdx(-1), |
@@ -300,8 +300,8 @@ void LLViewerParcelOverlay::uncompressLandOverlay(S32 chunk, U8 *packed_overlay) | |||
300 | { | 300 | { |
301 | // Unpack the message data into the ownership array | 301 | // Unpack the message data into the ownership array |
302 | S32 size = mParcelGridsPerEdge * mParcelGridsPerEdge; | 302 | S32 size = mParcelGridsPerEdge * mParcelGridsPerEdge; |
303 | S32 mParcelOverLayChunks = mRegionSize * mRegionSize / (128 * 128); | 303 | S32 mParcelOverLayChunks = mRegionSize * mRegionSize / (128 * 128); |
304 | S32 chunk_size = size / mParcelOverLayChunks; | 304 | S32 chunk_size = size / mParcelOverLayChunks; |
305 | 305 | ||
306 | memcpy(mOwnership + chunk*chunk_size, packed_overlay, chunk_size); /*Flawfinder: ignore*/ | 306 | memcpy(mOwnership + chunk*chunk_size, packed_overlay, chunk_size); /*Flawfinder: ignore*/ |
307 | 307 | ||
diff --git a/linden/indra/newview/llviewerparceloverlay.h b/linden/indra/newview/llviewerparceloverlay.h index d3b5980..fc0db0a 100644 --- a/linden/indra/newview/llviewerparceloverlay.h +++ b/linden/indra/newview/llviewerparceloverlay.h | |||
@@ -98,7 +98,7 @@ private: | |||
98 | LLViewerRegion* mRegion; | 98 | LLViewerRegion* mRegion; |
99 | 99 | ||
100 | S32 mParcelGridsPerEdge; | 100 | S32 mParcelGridsPerEdge; |
101 | S32 mRegionSize; | 101 | S32 mRegionSize; |
102 | 102 | ||
103 | LLPointer<LLImageGL> mTexture; | 103 | LLPointer<LLImageGL> mTexture; |
104 | LLPointer<LLImageRaw> mImageRaw; | 104 | LLPointer<LLImageRaw> mImageRaw; |
diff --git a/linden/indra/newview/llviewerregion.cpp b/linden/indra/newview/llviewerregion.cpp index 4186362..eba0db7 100644 --- a/linden/indra/newview/llviewerregion.cpp +++ b/linden/indra/newview/llviewerregion.cpp | |||
@@ -200,7 +200,7 @@ LLViewerRegion::LLViewerRegion(const U64 &handle, | |||
200 | if (!gNoRender) | 200 | if (!gNoRender) |
201 | { | 201 | { |
202 | mParcelOverlay = new LLViewerParcelOverlay(this, region_width_meters); | 202 | mParcelOverlay = new LLViewerParcelOverlay(this, region_width_meters); |
203 | //Re-init the parcel mgr for this sim | 203 | //Re-init the parcel mgr for this sim |
204 | LLViewerParcelMgr::getInstance()->init(region_width_meters); | 204 | LLViewerParcelMgr::getInstance()->init(region_width_meters); |
205 | } | 205 | } |
206 | else | 206 | else |
diff --git a/linden/indra/newview/llvlmanager.cpp b/linden/indra/newview/llvlmanager.cpp index 68b4d7b..7f483ca 100644 --- a/linden/indra/newview/llvlmanager.cpp +++ b/linden/indra/newview/llvlmanager.cpp | |||
@@ -57,23 +57,23 @@ LLVLManager::~LLVLManager() | |||
57 | 57 | ||
58 | void LLVLManager::addLayerData(LLVLData *vl_datap, const S32 mesg_size) | 58 | void LLVLManager::addLayerData(LLVLData *vl_datap, const S32 mesg_size) |
59 | { | 59 | { |
60 | if (LAND_LAYER_CODE == vl_datap->mType || | 60 | if (LAND_LAYER_CODE == vl_datap->mType || |
61 | AURORA_LAND_LAYER_CODE == vl_datap->mType) | 61 | AURORA_LAND_LAYER_CODE == vl_datap->mType) |
62 | { | 62 | { |
63 | mLandBits += mesg_size * 8; | 63 | mLandBits += mesg_size * 8; |
64 | } | 64 | } |
65 | else if (WIND_LAYER_CODE == vl_datap->mType || | 65 | else if (WIND_LAYER_CODE == vl_datap->mType || |
66 | AURORA_WIND_LAYER_CODE == vl_datap->mType) | 66 | AURORA_WIND_LAYER_CODE == vl_datap->mType) |
67 | { | 67 | { |
68 | mWindBits += mesg_size * 8; | 68 | mWindBits += mesg_size * 8; |
69 | } | 69 | } |
70 | else if (CLOUD_LAYER_CODE == vl_datap->mType) | 70 | else if (CLOUD_LAYER_CODE == vl_datap->mType) |
71 | { | 71 | { |
72 | mCloudBits += mesg_size * 8; | 72 | mCloudBits += mesg_size * 8; |
73 | } | 73 | } |
74 | else | 74 | else |
75 | { | 75 | { |
76 | llerrs << "Unknown layer type!" << (S32)vl_datap->mType << llendl; | 76 | llerrs << "Unknown layer type!" << (S32)vl_datap->mType << llendl; |
77 | } | 77 | } |
78 | 78 | ||
79 | mPacketData.put(vl_datap); | 79 | mPacketData.put(vl_datap); |
@@ -92,23 +92,23 @@ void LLVLManager::unpackData(const S32 num_packets) | |||
92 | LLGroupHeader goph; | 92 | LLGroupHeader goph; |
93 | 93 | ||
94 | decode_patch_group_header(bit_pack, &goph); | 94 | decode_patch_group_header(bit_pack, &goph); |
95 | if (LAND_LAYER_CODE == datap->mType) | 95 | if (LAND_LAYER_CODE == datap->mType) |
96 | { | 96 | { |
97 | datap->mRegionp->getLand().decompressDCTPatch(bit_pack, &goph, FALSE); | 97 | datap->mRegionp->getLand().decompressDCTPatch(bit_pack, &goph, FALSE); |
98 | } | 98 | } |
99 | else if (AURORA_LAND_LAYER_CODE == datap->mType) | 99 | else if (AURORA_LAND_LAYER_CODE == datap->mType) |
100 | { | 100 | { |
101 | datap->mRegionp->getLand().decompressDCTPatch(bit_pack, &goph, TRUE); | 101 | datap->mRegionp->getLand().decompressDCTPatch(bit_pack, &goph, TRUE); |
102 | } | 102 | } |
103 | else if (WIND_LAYER_CODE == datap->mType || | 103 | else if (WIND_LAYER_CODE == datap->mType || |
104 | AURORA_WIND_LAYER_CODE == datap->mType) | 104 | AURORA_WIND_LAYER_CODE == datap->mType) |
105 | { | 105 | { |
106 | datap->mRegionp->mWind.decompress(bit_pack, &goph); | 106 | datap->mRegionp->mWind.decompress(bit_pack, &goph); |
107 | } | 107 | } |
108 | else if (CLOUD_LAYER_CODE == datap->mType || | 108 | else if (CLOUD_LAYER_CODE == datap->mType || |
109 | AURORA_CLOUD_LAYER_CODE == datap->mType) | 109 | AURORA_CLOUD_LAYER_CODE == datap->mType) |
110 | { | 110 | { |
111 | datap->mRegionp->mCloudLayer.decompress(bit_pack, &goph); | 111 | datap->mRegionp->mCloudLayer.decompress(bit_pack, &goph); |
112 | } | 112 | } |
113 | } | 113 | } |
114 | 114 | ||
diff --git a/linden/indra/newview/llvowater.cpp b/linden/indra/newview/llvowater.cpp index 8af9e4a..eb74520 100644 --- a/linden/indra/newview/llvowater.cpp +++ b/linden/indra/newview/llvowater.cpp | |||
@@ -74,7 +74,7 @@ LLVOWater::LLVOWater(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regi | |||
74 | { | 74 | { |
75 | // Terrain must draw during selection passes so it can block objects behind it. | 75 | // Terrain must draw during selection passes so it can block objects behind it. |
76 | mbCanSelect = FALSE; | 76 | mbCanSelect = FALSE; |
77 | setScale(LLVector3(mRegionp->getWidth(), mRegionp->getWidth(), 0.f)); // Hack for setting scale for bounding boxes/visibility. | 77 | setScale(LLVector3(mRegionp->getWidth(), mRegionp->getWidth(), 0.f)); // Hack for setting scale for bounding boxes/visibility. |
78 | 78 | ||
79 | mUseTexture = TRUE; | 79 | mUseTexture = TRUE; |
80 | mIsEdgePatch = FALSE; | 80 | mIsEdgePatch = FALSE; |
diff --git a/linden/indra/newview/llworld.cpp b/linden/indra/newview/llworld.cpp index 525195d..13fc91c 100644 --- a/linden/indra/newview/llworld.cpp +++ b/linden/indra/newview/llworld.cpp | |||
@@ -172,11 +172,11 @@ LLViewerRegion* LLWorld::addRegion(const U64 ®ion_handle, const LLHost &host, | |||
172 | 172 | ||
173 | U32 iindex = 0; | 173 | U32 iindex = 0; |
174 | U32 jindex = 0; | 174 | U32 jindex = 0; |
175 | mWidth = region_size_x; | 175 | mWidth = region_size_x; |
176 | mWidthInMeters = mWidth * mScale; | 176 | mWidthInMeters = mWidth * mScale; |
177 | from_region_handle(region_handle, &iindex, &jindex); | 177 | from_region_handle(region_handle, &iindex, &jindex); |
178 | S32 x = (S32)(iindex/256); | 178 | S32 x = (S32)(iindex/256); |
179 | S32 y = (S32)(jindex/256); | 179 | S32 y = (S32)(jindex/256); |
180 | llinfos << "Adding new region (" << x << ":" << y << ")" << llendl; | 180 | llinfos << "Adding new region (" << x << ":" << y << ")" << llendl; |
181 | llinfos << "Host: " << host << llendl; | 181 | llinfos << "Host: " << host << llendl; |
182 | 182 | ||
@@ -1258,15 +1258,15 @@ void process_enable_simulator(LLMessageSystem *msg, void **user_data) | |||
1258 | // which simulator should we modify? | 1258 | // which simulator should we modify? |
1259 | LLHost sim(ip_u32, port); | 1259 | LLHost sim(ip_u32, port); |
1260 | 1260 | ||
1261 | U32 region_size_x = 256; | 1261 | U32 region_size_x = 256; |
1262 | msg->getU32Fast(_PREHASH_SimulatorInfo, _PREHASH_RegionSizeX, region_size_x); | 1262 | msg->getU32Fast(_PREHASH_SimulatorInfo, _PREHASH_RegionSizeX, region_size_x); |
1263 | U32 region_size_y = 256; | 1263 | U32 region_size_y = 256; |
1264 | msg->getU32Fast(_PREHASH_SimulatorInfo, _PREHASH_RegionSizeY, region_size_y); | 1264 | msg->getU32Fast(_PREHASH_SimulatorInfo, _PREHASH_RegionSizeY, region_size_y); |
1265 | 1265 | ||
1266 | if (region_size_y == 0 || region_size_x == 0) | 1266 | if (region_size_y == 0 || region_size_x == 0) |
1267 | { | 1267 | { |
1268 | region_size_x = 256; | 1268 | region_size_x = 256; |
1269 | region_size_y = 256; | 1269 | region_size_y = 256; |
1270 | } | 1270 | } |
1271 | 1271 | ||
1272 | // Viewer trusts the simulator. | 1272 | // Viewer trusts the simulator. |
diff --git a/linden/indra/newview/llworldmap.cpp b/linden/indra/newview/llworldmap.cpp index ead72fa..bd3996d 100644 --- a/linden/indra/newview/llworldmap.cpp +++ b/linden/indra/newview/llworldmap.cpp | |||
@@ -239,25 +239,25 @@ LLSimInfo* LLWorldMap::simInfoFromPosGlobal(const LLVector3d& pos_global) | |||
239 | 239 | ||
240 | LLSimInfo* LLWorldMap::simInfoFromHandle(const U64 findhandle) | 240 | LLSimInfo* LLWorldMap::simInfoFromHandle(const U64 findhandle) |
241 | { | 241 | { |
242 | std::map<U64, LLSimInfo*>::const_iterator it; | 242 | std::map<U64, LLSimInfo*>::const_iterator it; |
243 | for (it = LLWorldMap::getInstance()->mSimInfoMap.begin(); it != LLWorldMap::getInstance()->mSimInfoMap.end(); ++it) | 243 | for (it = LLWorldMap::getInstance()->mSimInfoMap.begin(); it != LLWorldMap::getInstance()->mSimInfoMap.end(); ++it) |
244 | { | 244 | { |
245 | const U64 handle = (*it).first; | 245 | const U64 handle = (*it).first; |
246 | LLSimInfo* info = (*it).second; | 246 | LLSimInfo* info = (*it).second; |
247 | if(handle == findhandle) | 247 | if(handle == findhandle) |
248 | { | 248 | { |
249 | return info; | 249 | return info; |
250 | } | 250 | } |
251 | U32 x = 0, y = 0; | 251 | U32 x = 0, y = 0; |
252 | from_region_handle(findhandle, &x, &y); | 252 | from_region_handle(findhandle, &x, &y); |
253 | U32 checkRegionX, checkRegionY; | 253 | U32 checkRegionX, checkRegionY; |
254 | from_region_handle(handle, &checkRegionX, &checkRegionY); | 254 | from_region_handle(handle, &checkRegionX, &checkRegionY); |
255 | 255 | ||
256 | if(x > checkRegionX && x < (checkRegionX + info->msizeX) && | 256 | if(x > checkRegionX && x < (checkRegionX + info->msizeX) && |
257 | y > checkRegionY && y < (checkRegionY + info->msizeY)) | 257 | y > checkRegionY && y < (checkRegionY + info->msizeY)) |
258 | { | 258 | { |
259 | return info; | 259 | return info; |
260 | } | 260 | } |
261 | } | 261 | } |
262 | return NULL; | 262 | return NULL; |
263 | } | 263 | } |
diff --git a/linden/indra/newview/llworldmap.h b/linden/indra/newview/llworldmap.h index 6725f91..56b32a2 100644 --- a/linden/indra/newview/llworldmap.h +++ b/linden/indra/newview/llworldmap.h | |||
@@ -81,8 +81,8 @@ public: | |||
81 | 81 | ||
82 | public: | 82 | public: |
83 | U64 mHandle; | 83 | U64 mHandle; |
84 | S32 msizeX; | 84 | S32 msizeX; |
85 | S32 msizeY; | 85 | S32 msizeY; |
86 | std::string mName; | 86 | std::string mName; |
87 | 87 | ||
88 | F64 mAgentsUpdateTime; | 88 | F64 mAgentsUpdateTime; |
diff --git a/linden/indra/newview/llworldmapview.cpp b/linden/indra/newview/llworldmapview.cpp index 51de598..8d9ed1b 100644 --- a/linden/indra/newview/llworldmapview.cpp +++ b/linden/indra/newview/llworldmapview.cpp | |||
@@ -471,8 +471,8 @@ void LLWorldMapView::draw() | |||
471 | // When the view isn't panned, 0,0 = center of rectangle | 471 | // When the view isn't panned, 0,0 = center of rectangle |
472 | F32 bottom = sPanY + half_height + relative_y; | 472 | F32 bottom = sPanY + half_height + relative_y; |
473 | F32 left = sPanX + half_width + relative_x; | 473 | F32 left = sPanX + half_width + relative_x; |
474 | F32 top = bottom+ (sMapScale * info->msizeY / REGION_WIDTH_METERS); | 474 | F32 top = bottom+ (sMapScale * info->msizeY / REGION_WIDTH_METERS); |
475 | F32 right = left + (sMapScale * info->msizeY / REGION_WIDTH_METERS); | 475 | F32 right = left + (sMapScale * info->msizeY / REGION_WIDTH_METERS); |
476 | 476 | ||
477 | // Switch to world map texture (if available for this region) if either: | 477 | // Switch to world map texture (if available for this region) if either: |
478 | // 1. Tiles are zoomed out small enough, or | 478 | // 1. Tiles are zoomed out small enough, or |
@@ -567,11 +567,11 @@ void LLWorldMapView::draw() | |||
567 | center_global.mdV[VX] += 128.0; | 567 | center_global.mdV[VX] += 128.0; |
568 | center_global.mdV[VY] += 128.0; | 568 | center_global.mdV[VY] += 128.0; |
569 | 569 | ||
570 | S32 x_draw_size = llround(sMapScale); | 570 | S32 x_draw_size = llround(sMapScale); |
571 | S32 y_draw_size = llround(sMapScale); | 571 | S32 y_draw_size = llround(sMapScale); |
572 | x_draw_size *= info->msizeX / REGION_WIDTH_METERS; | 572 | x_draw_size *= info->msizeX / REGION_WIDTH_METERS; |
573 | y_draw_size *= info->msizeY / REGION_WIDTH_METERS; | 573 | y_draw_size *= info->msizeY / REGION_WIDTH_METERS; |
574 | 574 | ||
575 | if (simimage != NULL) | 575 | if (simimage != NULL) |
576 | { | 576 | { |
577 | simimage->setBoostLevel(LLViewerImageBoostLevel::BOOST_MAP); | 577 | simimage->setBoostLevel(LLViewerImageBoostLevel::BOOST_MAP); |
diff --git a/linden/indra/newview/viewertime.cpp b/linden/indra/newview/viewertime.cpp index 8a65a23..5ed9465 100644 --- a/linden/indra/newview/viewertime.cpp +++ b/linden/indra/newview/viewertime.cpp | |||
@@ -27,7 +27,7 @@ | |||
27 | * COMPLETENESS OR PERFORMANCE. | 27 | * COMPLETENESS OR PERFORMANCE. |
28 | * $/LicenseInfo$ | 28 | * $/LicenseInfo$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <sstream> | 31 | #include <sstream> |
32 | #include "llviewerprecompiledheaders.h" | 32 | #include "llviewerprecompiledheaders.h" |
33 | 33 | ||