diff options
Diffstat (limited to 'linden/indra/newview/llwearable.cpp')
-rw-r--r-- | linden/indra/newview/llwearable.cpp | 69 |
1 files changed, 58 insertions, 11 deletions
diff --git a/linden/indra/newview/llwearable.cpp b/linden/indra/newview/llwearable.cpp index 6bdc50f..884cda5 100644 --- a/linden/indra/newview/llwearable.cpp +++ b/linden/indra/newview/llwearable.cpp | |||
@@ -150,41 +150,87 @@ EWearableType LLWearable::typeNameToType( const std::string& type_name ) | |||
150 | return WT_INVALID; | 150 | return WT_INVALID; |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | const char* terse_F32_to_string( F32 f, char s[MAX_STRING] ) /* Flawfinder: ignore */ | |
154 | std::string terse_F32_to_string( F32 f ) | ||
155 | { | 154 | { |
156 | std::string r = llformat( "%.2f", f ); | 155 | char* r = s; |
156 | S32 len = snprintf( s, MAX_STRING, "%.2f", f ); /* Flawfinder: ignore */ | ||
157 | 157 | ||
158 | // "1.20" -> "1.2" | 158 | // "1.20" -> "1.2" |
159 | // "24.00" -> "24." | 159 | // "24.00" -> "24." |
160 | S32 len = r.length(); | 160 | while( '0' == r[len - 1] ) |
161 | while( len > 0 && '0' == r[len - 1] ) | ||
162 | { | 161 | { |
163 | r.erase(len-1, 1); | 162 | len--; |
164 | len--; | 163 | r[len] = '\0'; |
165 | } | 164 | } |
166 | 165 | ||
167 | if( '.' == r[len - 1] ) | 166 | if( '.' == r[len - 1] ) |
168 | { | 167 | { |
169 | // "24." -> "24" | 168 | // "24." -> "24" |
170 | r.erase(len-1, 1); | 169 | len--; |
170 | r[len] = '\0'; | ||
171 | } | 171 | } |
172 | else | 172 | else |
173 | if( ('-' == r[0]) && ('0' == r[1]) ) | 173 | if( ('-' == r[0]) && ('0' == r[1]) ) |
174 | { | 174 | { |
175 | // "-0.59" -> "-.59" | 175 | // "-0.59" -> "-.59" |
176 | r.erase(1, 1); | 176 | r++; |
177 | r[0] = '-'; | ||
177 | } | 178 | } |
178 | else | 179 | else |
179 | if( '0' == r[0] ) | 180 | if( '0' == r[0] ) |
180 | { | 181 | { |
181 | // "0.59" -> ".59" | 182 | // "0.59" -> ".59" |
182 | r.erase(0, 1); | 183 | r++; |
183 | } | 184 | } |
184 | 185 | ||
185 | return r; | 186 | return r; |
186 | } | 187 | } |
187 | 188 | ||
189 | // reX: new function | ||
190 | BOOL LLWearable::FileExportParams( FILE* file ) | ||
191 | { | ||
192 | // wearable type | ||
193 | S32 type = (S32)mType; | ||
194 | fprintf( file, "type %d\n", type ); | ||
195 | |||
196 | // parameters | ||
197 | S32 num_parameters = mVisualParamMap.size(); | ||
198 | fprintf( file, "parameters %d\n", num_parameters ); | ||
199 | |||
200 | char s[ MAX_STRING ]; /* Flawfinder: ignore */ | ||
201 | for (param_map_t::iterator iter = mVisualParamMap.begin(); | ||
202 | iter != mVisualParamMap.end(); ++iter) | ||
203 | { | ||
204 | S32 param_id = iter->first; | ||
205 | F32 param_weight = iter->second; | ||
206 | fprintf( file, "%d %s\n", param_id, terse_F32_to_string( param_weight, s ) ); | ||
207 | } | ||
208 | |||
209 | return TRUE; | ||
210 | } | ||
211 | |||
212 | // reX: new function | ||
213 | BOOL LLWearable::FileExportTextures( FILE* file ) | ||
214 | { | ||
215 | // wearable type | ||
216 | S32 type = (S32)mType; | ||
217 | fprintf( file, "type %d\n", type ); | ||
218 | |||
219 | // texture entries | ||
220 | S32 num_textures = mTEMap.size(); | ||
221 | fprintf( file, "textures %d\n", num_textures ); | ||
222 | |||
223 | for (te_map_t::iterator iter = mTEMap.begin(); | ||
224 | iter != mTEMap.end(); ++iter) | ||
225 | { | ||
226 | S32 te = iter->first; | ||
227 | LLUUID& image_id = iter->second; | ||
228 | fprintf( file, "%d %s\n", te, image_id.asString().c_str() ); | ||
229 | } | ||
230 | |||
231 | return TRUE; | ||
232 | } | ||
233 | |||
188 | BOOL LLWearable::exportFile( LLFILE* file ) | 234 | BOOL LLWearable::exportFile( LLFILE* file ) |
189 | { | 235 | { |
190 | // header and version | 236 | // header and version |
@@ -231,12 +277,13 @@ BOOL LLWearable::exportFile( LLFILE* file ) | |||
231 | return FALSE; | 277 | return FALSE; |
232 | } | 278 | } |
233 | 279 | ||
280 | char s[ MAX_STRING ]; /* Flawfinder: ignore */ | ||
234 | for (param_map_t::iterator iter = mVisualParamMap.begin(); | 281 | for (param_map_t::iterator iter = mVisualParamMap.begin(); |
235 | iter != mVisualParamMap.end(); ++iter) | 282 | iter != mVisualParamMap.end(); ++iter) |
236 | { | 283 | { |
237 | S32 param_id = iter->first; | 284 | S32 param_id = iter->first; |
238 | F32 param_weight = iter->second; | 285 | F32 param_weight = iter->second; |
239 | if( fprintf( file, "%d %s\n", param_id, terse_F32_to_string( param_weight ).c_str() ) < 0 ) | 286 | if( fprintf( file, "%d %s\n", param_id, terse_F32_to_string( param_weight, s ) ) < 0 ) |
240 | { | 287 | { |
241 | return FALSE; | 288 | return FALSE; |
242 | } | 289 | } |