aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llstartup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llstartup.cpp')
-rw-r--r--linden/indra/newview/llstartup.cpp761
1 files changed, 438 insertions, 323 deletions
diff --git a/linden/indra/newview/llstartup.cpp b/linden/indra/newview/llstartup.cpp
index b5ab0ee..d018eaa 100644
--- a/linden/indra/newview/llstartup.cpp
+++ b/linden/indra/newview/llstartup.cpp
@@ -41,8 +41,8 @@
41 41
42#include "audioengine.h" 42#include "audioengine.h"
43 43
44#if LL_FMOD 44#ifdef LL_FMOD
45#include "audioengine_fmod.h" 45# include "audioengine_fmod.h"
46#endif 46#endif
47 47
48#include "llares.h" 48#include "llares.h"
@@ -174,6 +174,11 @@
174#include "llpostprocess.h" 174#include "llpostprocess.h"
175#include "llwlparammanager.h" 175#include "llwlparammanager.h"
176#include "llwaterparammanager.h" 176#include "llwaterparammanager.h"
177#include "llagentlanguage.h"
178
179#if LL_LIBXUL_ENABLED
180#include "llmozlib.h"
181#endif // LL_LIBXUL_ENABLED
177 182
178#if LL_WINDOWS 183#if LL_WINDOWS
179#include "llwindebug.h" 184#include "llwindebug.h"
@@ -183,10 +188,12 @@
183// 188//
184// exported globals 189// exported globals
185// 190//
186BOOL gAgentMovementCompleted = FALSE; 191bool gAgentMovementCompleted = false;
192std::string gInitialOutfit;
193std::string gInitialOutfitGender;
187 194
188const char* SCREEN_HOME_FILENAME = "screen_home.bmp"; 195std::string SCREEN_HOME_FILENAME = "screen_home.bmp";
189const char* SCREEN_LAST_FILENAME = "screen_last.bmp"; 196std::string SCREEN_LAST_FILENAME = "screen_last.bmp";
190 197
191// 198//
192// Imported globals 199// Imported globals
@@ -204,12 +211,12 @@ static LLHost gAgentSimHost;
204static BOOL gSkipOptionalUpdate = FALSE; 211static BOOL gSkipOptionalUpdate = FALSE;
205 212
206static bool gGotUseCircuitCodeAck = false; 213static bool gGotUseCircuitCodeAck = false;
207LLString gInitialOutfit; 214static std::string sInitialOutfit;
208LLString gInitialOutfitGender; // "male" or "female" 215static std::string sInitialOutfitGender; // "male" or "female"
209 216
210static bool gUseCircuitCallbackCalled = false; 217static bool gUseCircuitCallbackCalled = false;
211 218
212S32 LLStartUp::gStartupState = STATE_FIRST; 219EStartupState LLStartUp::gStartupState = STATE_FIRST;
213 220
214 221
215// 222//
@@ -218,12 +225,12 @@ S32 LLStartUp::gStartupState = STATE_FIRST;
218 225
219void login_show(); 226void login_show();
220void login_callback(S32 option, void* userdata); 227void login_callback(S32 option, void* userdata);
221LLString load_password_from_disk(); 228std::string load_password_from_disk();
222void save_password_to_disk(const char* hashed_password); 229void save_password_to_disk(const char* hashed_password);
223BOOL is_hex_string(U8* str, S32 len); 230bool is_hex_string(U8* str, S32 len);
224void show_first_run_dialog(); 231void show_first_run_dialog();
225void first_run_dialog_callback(S32 option, void* userdata); 232void first_run_dialog_callback(S32 option, void* userdata);
226void set_startup_status(const F32 frac, const char* string, const char* msg); 233void set_startup_status(const F32 frac, const std::string& string, const std::string& msg);
227void login_alert_status(S32 option, void* user_data); 234void login_alert_status(S32 option, void* user_data);
228void update_app(BOOL mandatory, const std::string& message); 235void update_app(BOOL mandatory, const std::string& message);
229void update_dialog_callback(S32 option, void *userdata); 236void update_dialog_callback(S32 option, void *userdata);
@@ -238,7 +245,7 @@ void init_start_screen(S32 location_id);
238void release_start_screen(); 245void release_start_screen();
239void reset_login(); 246void reset_login();
240 247
241void callback_cache_name(const LLUUID& id, const char* firstname, const char* lastname, BOOL is_group, void* data) 248void callback_cache_name(const LLUUID& id, const std::string& firstname, const std::string& lastname, BOOL is_group, void* data)
242{ 249{
243 LLNameListCtrl::refreshAll(id, firstname, lastname, is_group); 250 LLNameListCtrl::refreshAll(id, firstname, lastname, is_group);
244 LLNameBox::refreshAll(id, firstname, lastname, is_group); 251 LLNameBox::refreshAll(id, firstname, lastname, is_group);
@@ -262,7 +269,7 @@ namespace
262 class LLNullHTTPSender : public LLHTTPSender 269 class LLNullHTTPSender : public LLHTTPSender
263 { 270 {
264 virtual void send(const LLHost& host, 271 virtual void send(const LLHost& host,
265 const char* message, const LLSD& body, 272 const std::string& message, const LLSD& body,
266 LLHTTPClient::ResponderPtr response) const 273 LLHTTPClient::ResponderPtr response) const
267 { 274 {
268 LL_WARNS("AppInit") << " attemped to send " << message << " to " << host 275 LL_WARNS("AppInit") << " attemped to send " << message << " to " << host
@@ -296,9 +303,9 @@ void update_texture_fetch()
296static std::vector<std::string> sAuthUris; 303static std::vector<std::string> sAuthUris;
297static S32 sAuthUriNum = -1; 304static S32 sAuthUriNum = -1;
298 305
299// Returns FALSE to skip other idle processing. Should only return 306// Returns false to skip other idle processing. Should only return
300// TRUE when all initialization done. 307// true when all initialization done.
301BOOL idle_startup() 308bool idle_startup()
302{ 309{
303 LLMemType mt1(LLMemType::MTYPE_STARTUP); 310 LLMemType mt1(LLMemType::MTYPE_STARTUP);
304 311
@@ -317,10 +324,10 @@ BOOL idle_startup()
317 static std::string auth_method; 324 static std::string auth_method;
318 static std::string auth_desc; 325 static std::string auth_desc;
319 static std::string auth_message; 326 static std::string auth_message;
320 static LLString firstname; 327 static std::string firstname;
321 static LLString lastname; 328 static std::string lastname;
322 static LLUUID web_login_key; 329 static LLUUID web_login_key;
323 static LLString password; 330 static std::string password;
324 static std::vector<const char*> requested_options; 331 static std::vector<const char*> requested_options;
325 332
326 static U64 first_sim_handle = 0; 333 static U64 first_sim_handle = 0;
@@ -336,14 +343,12 @@ BOOL idle_startup()
336 static S32 agent_location_id = START_LOCATION_ID_LAST; 343 static S32 agent_location_id = START_LOCATION_ID_LAST;
337 static S32 location_which = START_LOCATION_ID_LAST; 344 static S32 location_which = START_LOCATION_ID_LAST;
338 345
339 static BOOL show_connect_box = TRUE; 346 static bool show_connect_box = true;
340 static BOOL remember_password = TRUE; 347 static BOOL remember_password = TRUE;
341 348
342 static BOOL stipend_since_login = FALSE; 349 static bool stipend_since_login = false;
343
344 static BOOL samename = FALSE;
345 350
346 BOOL do_normal_idle = FALSE; 351 static bool samename = false;
347 352
348 // HACK: These are things from the main loop that usually aren't done 353 // HACK: These are things from the main loop that usually aren't done
349 // until initialization is complete, but need to be done here for things 354 // until initialization is complete, but need to be done here for things
@@ -389,16 +394,16 @@ BOOL idle_startup()
389 394
390 gSavedSettings.setS32("LastFeatureVersion", LLFeatureManager::getInstance()->getVersion()); 395 gSavedSettings.setS32("LastFeatureVersion", LLFeatureManager::getInstance()->getVersion());
391 396
392 LLString xml_file = LLUI::locateSkin("xui_version.xml"); 397 std::string xml_file = LLUI::locateSkin("xui_version.xml");
393 LLXMLNodePtr root; 398 LLXMLNodePtr root;
394 bool xml_ok = false; 399 bool xml_ok = false;
395 if (LLXMLNode::parseFile(xml_file, root, NULL)) 400 if (LLXMLNode::parseFile(xml_file, root, NULL))
396 { 401 {
397 if( (root->hasName("xui_version") ) ) 402 if( (root->hasName("xui_version") ) )
398 { 403 {
399 LLString value = root->getValue(); 404 std::string value = root->getValue();
400 F32 version = 0.0f; 405 F32 version = 0.0f;
401 LLString::convertToF32(value, version); 406 LLStringUtil::convertToF32(value, version);
402 if (version >= 1.0f) 407 if (version >= 1.0f)
403 { 408 {
404 xml_ok = true; 409 xml_ok = true;
@@ -409,7 +414,7 @@ BOOL idle_startup()
409 { 414 {
410 // *TODO:translate (maybe - very unlikely error message) 415 // *TODO:translate (maybe - very unlikely error message)
411 // Note: alerts.xml may be invalid - if this gets translated it will need to be in the code 416 // Note: alerts.xml may be invalid - if this gets translated it will need to be in the code
412 LLString bad_xui_msg = "An error occured while updating Second Life. Please download the latest version from www.secondlife.com."; 417 std::string bad_xui_msg = "An error occured while updating Second Life. Please download the latest version from www.secondlife.com.";
413 LLAppViewer::instance()->earlyExit(bad_xui_msg); 418 LLAppViewer::instance()->earlyExit(bad_xui_msg);
414 } 419 }
415 // 420 //
@@ -417,7 +422,7 @@ BOOL idle_startup()
417 // 422 //
418 423
419 // Load autopilot and stats stuff 424 // Load autopilot and stats stuff
420 gAgentPilot.load(gSavedSettings.getString("StatsPilotFile").c_str()); 425 gAgentPilot.load(gSavedSettings.getString("StatsPilotFile"));
421 gFrameStats.setFilename(gSavedSettings.getString("StatsFile")); 426 gFrameStats.setFilename(gSavedSettings.getString("StatsFile"));
422 gFrameStats.setSummaryFilename(gSavedSettings.getString("StatsSummaryFile")); 427 gFrameStats.setSummaryFilename(gSavedSettings.getString("StatsSummaryFile"));
423 428
@@ -439,7 +444,19 @@ BOOL idle_startup()
439 std::string message_template_path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"message_template.msg"); 444 std::string message_template_path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"message_template.msg");
440 445
441 LLFILE* found_template = NULL; 446 LLFILE* found_template = NULL;
442 found_template = LLFile::fopen(message_template_path.c_str(), "r"); /* Flawfinder: ignore */ 447 found_template = LLFile::fopen(message_template_path, "r"); /* Flawfinder: ignore */
448
449 #if LL_WINDOWS
450 // On the windows dev builds, unpackaged, the message_template.msg
451 // file will be located in
452 // indra/build-vc**/newview/<config>/app_settings.
453 if (!found_template)
454 {
455 message_template_path = gDirUtilp->getExpandedFilename(LL_PATH_EXECUTABLE, "app_settings", "message_template.msg");
456 found_template = LLFile::fopen(message_template_path.c_str(), "r"); /* Flawfinder: ignore */
457 }
458 #endif
459
443 if (found_template) 460 if (found_template)
444 { 461 {
445 fclose(found_template); 462 fclose(found_template);
@@ -465,11 +482,28 @@ BOOL idle_startup()
465 std::string msg = llformat("Unable to start networking, error %d", gMessageSystem->getErrorCode()); 482 std::string msg = llformat("Unable to start networking, error %d", gMessageSystem->getErrorCode());
466 LLAppViewer::instance()->earlyExit(msg); 483 LLAppViewer::instance()->earlyExit(msg);
467 } 484 }
468 LLMessageConfig::initClass("viewer", gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "")); 485
486 #if LL_WINDOWS
487 // On the windows dev builds, unpackaged, the message.xml file will
488 // be located in indra/build-vc**/newview/<config>/app_settings.
489 std::string message_path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"message.xml");
490
491 if (!LLFile::isfile(message_path.c_str()))
492 {
493 LLMessageConfig::initClass("viewer", gDirUtilp->getExpandedFilename(LL_PATH_EXECUTABLE, "app_settings", ""));
494 }
495 else
496 {
497 LLMessageConfig::initClass("viewer", gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, ""));
498 }
499 #else
500 LLMessageConfig::initClass("viewer", gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, ""));
501 #endif
502
469 } 503 }
470 else 504 else
471 { 505 {
472 LLAppViewer::instance()->earlyExit("Unable to initialize communications."); 506 LLAppViewer::instance()->earlyExit("Message Template " + message_template_path + " not found.");
473 } 507 }
474 508
475 if(gMessageSystem && gMessageSystem->isOK()) 509 if(gMessageSystem && gMessageSystem->isOK())
@@ -540,7 +574,7 @@ BOOL idle_startup()
540 574
541 if (FALSE == gSavedSettings.getBOOL("NoAudio")) 575 if (FALSE == gSavedSettings.getBOOL("NoAudio"))
542 { 576 {
543#if LL_FMOD 577#ifdef LL_FMOD
544 gAudiop = (LLAudioEngine *) new LLAudioEngine_FMOD(); 578 gAudiop = (LLAudioEngine *) new LLAudioEngine_FMOD();
545#else 579#else
546 gAudiop = NULL; 580 gAudiop = NULL;
@@ -555,7 +589,7 @@ BOOL idle_startup()
555#else 589#else
556 void* window_handle = NULL; 590 void* window_handle = NULL;
557#endif 591#endif
558 BOOL init = gAudiop->init(kAUDIO_NUM_SOURCES, window_handle); 592 bool init = gAudiop->init(kAUDIO_NUM_SOURCES, window_handle);
559 if(!init) 593 if(!init)
560 { 594 {
561 LL_WARNS("AppInit") << "Unable to initialize audio engine" << LL_ENDL; 595 LL_WARNS("AppInit") << "Unable to initialize audio engine" << LL_ENDL;
@@ -581,7 +615,7 @@ BOOL idle_startup()
581 lastname = gLoginHandler.mLastName; 615 lastname = gLoginHandler.mLastName;
582 web_login_key = gLoginHandler.mWebLoginKey; 616 web_login_key = gLoginHandler.mWebLoginKey;
583 617
584 show_connect_box = FALSE; 618 show_connect_box = false;
585 } 619 }
586 else if(gSavedSettings.getLLSD("UserLoginInfo").size() == 3) 620 else if(gSavedSettings.getLLSD("UserLoginInfo").size() == 3)
587 { 621 {
@@ -596,9 +630,9 @@ BOOL idle_startup()
596 remember_password = gSavedSettings.getBOOL("RememberPassword"); 630 remember_password = gSavedSettings.getBOOL("RememberPassword");
597 631
598#ifdef USE_VIEWER_AUTH 632#ifdef USE_VIEWER_AUTH
599 show_connect_box = TRUE; 633 show_connect_box = true;
600#else 634#else
601 show_connect_box = FALSE; 635 show_connect_box = false;
602#endif 636#endif
603 gSavedSettings.setBOOL("AutoLogin", TRUE); 637 gSavedSettings.setBOOL("AutoLogin", TRUE);
604 } 638 }
@@ -611,9 +645,9 @@ BOOL idle_startup()
611 remember_password = TRUE; 645 remember_password = TRUE;
612 646
613#ifdef USE_VIEWER_AUTH 647#ifdef USE_VIEWER_AUTH
614 show_connect_box = TRUE; 648 show_connect_box = true;
615#else 649#else
616 show_connect_box = FALSE; 650 show_connect_box = false;
617#endif 651#endif
618 } 652 }
619 else 653 else
@@ -624,39 +658,31 @@ BOOL idle_startup()
624 lastname = gSavedSettings.getString("LastName"); 658 lastname = gSavedSettings.getString("LastName");
625 password = load_password_from_disk(); 659 password = load_password_from_disk();
626 remember_password = gSavedSettings.getBOOL("RememberPassword"); 660 remember_password = gSavedSettings.getBOOL("RememberPassword");
627 show_connect_box = TRUE; 661 show_connect_box = true;
628 } 662 }
629 663
630 664
631 // Go to the next startup state 665 // Go to the next startup state
632 LLStartUp::setStartupState( STATE_MEDIA_INIT ); 666 LLStartUp::setStartupState( STATE_BROWSER_INIT );
633 return do_normal_idle; 667 return FALSE;
634 } 668 }
635 669
636 670
637 //--------------------------------------------------------------------- 671 if (STATE_BROWSER_INIT == LLStartUp::getStartupState())
638 // LLMediaEngine Init
639 //---------------------------------------------------------------------
640 if (STATE_MEDIA_INIT == LLStartUp::getStartupState())
641 { 672 {
642 LL_DEBUGS("AppInit") << "Initializing Multimedia...." << LL_ENDL; 673 LL_DEBUGS("AppInit") << "STATE_BROWSER_INIT" << LL_ENDL;
643 set_startup_status(0.03f, "Initializing Multimedia...", gAgent.mMOTD.c_str()); 674 std::string msg = LLTrans::getString("LoginInitializingBrowser");
675 set_startup_status(0.03f, msg.c_str(), gAgent.mMOTD.c_str());
644 display_startup(); 676 display_startup();
645 LLViewerMedia::initClass(); 677 LLViewerMedia::initBrowser();
646 LLViewerParcelMedia::initClass();
647
648 if (gViewerWindow)
649 {
650 audio_update_volume(true);
651 }
652 678
653 LLStartUp::setStartupState( STATE_LOGIN_SHOW ); 679 LLStartUp::setStartupState( STATE_LOGIN_SHOW );
654 return do_normal_idle; 680 return FALSE;
655 } 681 }
656 682
657 if (STATE_LOGIN_SHOW == LLStartUp::getStartupState())
658 {
659 683
684 if (STATE_LOGIN_SHOW == LLStartUp::getStartupState())
685 {
660 LL_DEBUGS("AppInit") << "Initializing Window" << LL_ENDL; 686 LL_DEBUGS("AppInit") << "Initializing Window" << LL_ENDL;
661 687
662 gViewerWindow->getWindow()->setCursor(UI_CURSOR_ARROW); 688 gViewerWindow->getWindow()->setCursor(UI_CURSOR_ARROW);
@@ -718,7 +744,7 @@ BOOL idle_startup()
718 gLoginMenuBarView->setEnabled( TRUE ); 744 gLoginMenuBarView->setEnabled( TRUE );
719 745
720 timeout.reset(); 746 timeout.reset();
721 return do_normal_idle; 747 return FALSE;
722 } 748 }
723 749
724 if (STATE_LOGIN_WAIT == LLStartUp::getStartupState()) 750 if (STATE_LOGIN_WAIT == LLStartUp::getStartupState())
@@ -728,7 +754,7 @@ BOOL idle_startup()
728 754
729 // Sleep so we don't spin the CPU 755 // Sleep so we don't spin the CPU
730 ms_sleep(1); 756 ms_sleep(1);
731 return do_normal_idle; 757 return FALSE;
732 } 758 }
733 759
734 if (STATE_LOGIN_CLEANUP == LLStartUp::getStartupState()) 760 if (STATE_LOGIN_CLEANUP == LLStartUp::getStartupState())
@@ -773,8 +799,8 @@ BOOL idle_startup()
773 799
774 // create necessary directories 800 // create necessary directories
775 // *FIX: these mkdir's should error check 801 // *FIX: these mkdir's should error check
776 gDirUtilp->setLindenUserDir(firstname.c_str(), lastname.c_str()); 802 gDirUtilp->setLindenUserDir(firstname, lastname);
777 LLFile::mkdir(gDirUtilp->getLindenUserDir().c_str()); 803 LLFile::mkdir(gDirUtilp->getLindenUserDir());
778 804
779 // Set PerAccountSettingsFile to the default value. 805 // Set PerAccountSettingsFile to the default value.
780 gSavedSettings.setString("PerAccountSettingsFile", 806 gSavedSettings.setString("PerAccountSettingsFile",
@@ -804,10 +830,10 @@ BOOL idle_startup()
804 gDirUtilp->setChatLogsDir(gSavedPerAccountSettings.getString("InstantMessageLogPath")); 830 gDirUtilp->setChatLogsDir(gSavedPerAccountSettings.getString("InstantMessageLogPath"));
805 } 831 }
806 832
807 gDirUtilp->setPerAccountChatLogsDir(firstname.c_str(), lastname.c_str()); 833 gDirUtilp->setPerAccountChatLogsDir(firstname, lastname);
808 834
809 LLFile::mkdir(gDirUtilp->getChatLogsDir().c_str()); 835 LLFile::mkdir(gDirUtilp->getChatLogsDir());
810 LLFile::mkdir(gDirUtilp->getPerAccountChatLogsDir().c_str()); 836 LLFile::mkdir(gDirUtilp->getPerAccountChatLogsDir());
811 837
812 if (show_connect_box) 838 if (show_connect_box)
813 { 839 {
@@ -818,7 +844,7 @@ BOOL idle_startup()
818 sAuthUris.clear(); 844 sAuthUris.clear();
819 } 845 }
820 846
821 LLString location; 847 std::string location;
822 LLPanelLogin::getLocation( location ); 848 LLPanelLogin::getLocation( location );
823 LLURLSimString::setString( location ); 849 LLURLSimString::setString( location );
824 850
@@ -829,9 +855,6 @@ BOOL idle_startup()
829 855
830 //For HTML parsing in text boxes. 856 //For HTML parsing in text boxes.
831 LLTextEditor::setLinkColor( gSavedSettings.getColor4("HTMLLinkColor") ); 857 LLTextEditor::setLinkColor( gSavedSettings.getColor4("HTMLLinkColor") );
832 LLTextEditor::setURLCallbacks ( &LLWeb::loadURL,
833 &LLURLDispatcher::dispatchFromTextEditor,
834 &LLURLDispatcher::dispatchFromTextEditor );
835 858
836 // Load URL History File 859 // Load URL History File
837 LLURLHistory::loadFile("url_history.xml"); 860 LLURLHistory::loadFile("url_history.xml");
@@ -874,11 +897,11 @@ BOOL idle_startup()
874 897
875 // Display the startup progress bar. 898 // Display the startup progress bar.
876 gViewerWindow->setShowProgress(TRUE); 899 gViewerWindow->setShowProgress(TRUE);
877 gViewerWindow->setProgressCancelButtonVisible(TRUE, "Quit"); 900 gViewerWindow->setProgressCancelButtonVisible(TRUE, std::string("Quit")); // *TODO: Translate
878 901
879 // Poke the VFS, which could potentially block for a while if 902 // Poke the VFS, which could potentially block for a while if
880 // Windows XP is acting up 903 // Windows XP is acting up
881 set_startup_status(0.07f, LLTrans::getString("LoginVerifyingCache").c_str(), NULL); 904 set_startup_status(0.07f, LLTrans::getString("LoginVerifyingCache"), LLStringUtil::null);
882 display_startup(); 905 display_startup();
883 906
884 gVFS->pokeFiles(); 907 gVFS->pokeFiles();
@@ -889,13 +912,13 @@ BOOL idle_startup()
889 // skipping over STATE_UPDATE_CHECK because that just waits for input 912 // skipping over STATE_UPDATE_CHECK because that just waits for input
890 LLStartUp::setStartupState( STATE_LOGIN_AUTH_INIT ); 913 LLStartUp::setStartupState( STATE_LOGIN_AUTH_INIT );
891 914
892 return do_normal_idle; 915 return FALSE;
893 } 916 }
894 917
895 if (STATE_UPDATE_CHECK == LLStartUp::getStartupState()) 918 if (STATE_UPDATE_CHECK == LLStartUp::getStartupState())
896 { 919 {
897 // wait for user to give input via dialog box 920 // wait for user to give input via dialog box
898 return do_normal_idle; 921 return FALSE;
899 } 922 }
900 923
901 if(STATE_LOGIN_AUTH_INIT == LLStartUp::getStartupState()) 924 if(STATE_LOGIN_AUTH_INIT == LLStartUp::getStartupState())
@@ -948,16 +971,16 @@ BOOL idle_startup()
948 sAuthUriNum = 0; 971 sAuthUriNum = 0;
949 auth_method = "login_to_simulator"; 972 auth_method = "login_to_simulator";
950 973
951 LLString::format_map_t args; 974 LLStringUtil::format_map_t args;
952 args["[APP_NAME]"] = LLAppViewer::instance()->getSecondLifeTitle(); 975 args["[APP_NAME]"] = LLAppViewer::instance()->getSecondLifeTitle();
953 auth_desc = LLTrans::getString("LoginInProgress", args).c_str(); 976 auth_desc = LLTrans::getString("LoginInProgress", args);
954 LLStartUp::setStartupState( STATE_LOGIN_AUTHENTICATE ); 977 LLStartUp::setStartupState( STATE_LOGIN_AUTHENTICATE );
955 } 978 }
956 979
957 if (STATE_LOGIN_AUTHENTICATE == LLStartUp::getStartupState()) 980 if (STATE_LOGIN_AUTHENTICATE == LLStartUp::getStartupState())
958 { 981 {
959 LL_DEBUGS("AppInit") << "STATE_LOGIN_AUTHENTICATE" << LL_ENDL; 982 LL_DEBUGS("AppInit") << "STATE_LOGIN_AUTHENTICATE" << LL_ENDL;
960 set_startup_status(progress, auth_desc.c_str(), auth_message.c_str()); 983 set_startup_status(progress, auth_desc, auth_message);
961 progress += 0.02f; 984 progress += 0.02f;
962 display_startup(); 985 display_startup();
963 986
@@ -971,7 +994,7 @@ BOOL idle_startup()
971 << LLURLSimString::sInstance.mX << "&" 994 << LLURLSimString::sInstance.mX << "&"
972 << LLURLSimString::sInstance.mY << "&" 995 << LLURLSimString::sInstance.mY << "&"
973 << LLURLSimString::sInstance.mZ; 996 << LLURLSimString::sInstance.mZ;
974 start << xml_escape_string(unescaped_start.str().c_str()); 997 start << xml_escape_string(unescaped_start.str());
975 998
976 } 999 }
977 else if (gSavedSettings.getBOOL("LoginLastLocation")) 1000 else if (gSavedSettings.getBOOL("LoginLastLocation"))
@@ -992,13 +1015,12 @@ BOOL idle_startup()
992 // TODO if statement here to use web_login_key 1015 // TODO if statement here to use web_login_key
993 sAuthUriNum = llclamp(sAuthUriNum, 0, (S32)sAuthUris.size()-1); 1016 sAuthUriNum = llclamp(sAuthUriNum, 0, (S32)sAuthUris.size()-1);
994 LLUserAuth::getInstance()->authenticate( 1017 LLUserAuth::getInstance()->authenticate(
995 sAuthUris[sAuthUriNum].c_str(), 1018 sAuthUris[sAuthUriNum],
996 auth_method.c_str(), 1019 auth_method,
997 firstname.c_str(), 1020 firstname,
998 lastname.c_str(), 1021 lastname,
999 // web_login_key, 1022 password, // web_login_key,
1000 password.c_str(), 1023 start.str(),
1001 start.str().c_str(),
1002 gSkipOptionalUpdate, 1024 gSkipOptionalUpdate,
1003 gAcceptTOS, 1025 gAcceptTOS,
1004 gAcceptCriticalMessage, 1026 gAcceptCriticalMessage,
@@ -1011,7 +1033,7 @@ BOOL idle_startup()
1011 gAcceptTOS = FALSE; 1033 gAcceptTOS = FALSE;
1012 gAcceptCriticalMessage = FALSE; 1034 gAcceptCriticalMessage = FALSE;
1013 LLStartUp::setStartupState( STATE_LOGIN_NO_DATA_YET ); 1035 LLStartUp::setStartupState( STATE_LOGIN_NO_DATA_YET );
1014 return do_normal_idle; 1036 return FALSE;
1015 } 1037 }
1016 1038
1017 if(STATE_LOGIN_NO_DATA_YET == LLStartUp::getStartupState()) 1039 if(STATE_LOGIN_NO_DATA_YET == LLStartUp::getStartupState())
@@ -1020,7 +1042,7 @@ BOOL idle_startup()
1020 // If we get here we have gotten past the potential stall 1042 // If we get here we have gotten past the potential stall
1021 // in curl, so take "may appear frozen" out of progress bar. JC 1043 // in curl, so take "may appear frozen" out of progress bar. JC
1022 auth_desc = "Logging in..."; 1044 auth_desc = "Logging in...";
1023 set_startup_status(progress, auth_desc.c_str(), auth_message.c_str()); 1045 set_startup_status(progress, auth_desc, auth_message);
1024 // Process messages to keep from dropping circuit. 1046 // Process messages to keep from dropping circuit.
1025 LLMessageSystem* msg = gMessageSystem; 1047 LLMessageSystem* msg = gMessageSystem;
1026 while (msg->checkAllMessages(gFrameCount, gServicePump)) 1048 while (msg->checkAllMessages(gFrameCount, gServicePump))
@@ -1031,12 +1053,12 @@ BOOL idle_startup()
1031 if(LLUserAuth::E_NO_RESPONSE_YET == error) 1053 if(LLUserAuth::E_NO_RESPONSE_YET == error)
1032 { 1054 {
1033 LL_DEBUGS("AppInit") << "waiting..." << LL_ENDL; 1055 LL_DEBUGS("AppInit") << "waiting..." << LL_ENDL;
1034 return do_normal_idle; 1056 return FALSE;
1035 } 1057 }
1036 LLStartUp::setStartupState( STATE_LOGIN_DOWNLOADING ); 1058 LLStartUp::setStartupState( STATE_LOGIN_DOWNLOADING );
1037 progress += 0.01f; 1059 progress += 0.01f;
1038 set_startup_status(progress, auth_desc.c_str(), auth_message.c_str()); 1060 set_startup_status(progress, auth_desc, auth_message);
1039 return do_normal_idle; 1061 return FALSE;
1040 } 1062 }
1041 1063
1042 if(STATE_LOGIN_DOWNLOADING == LLStartUp::getStartupState()) 1064 if(STATE_LOGIN_DOWNLOADING == LLStartUp::getStartupState())
@@ -1052,23 +1074,23 @@ BOOL idle_startup()
1052 if(LLUserAuth::E_DOWNLOADING == error) 1074 if(LLUserAuth::E_DOWNLOADING == error)
1053 { 1075 {
1054 LL_DEBUGS("AppInit") << "downloading..." << LL_ENDL; 1076 LL_DEBUGS("AppInit") << "downloading..." << LL_ENDL;
1055 return do_normal_idle; 1077 return FALSE;
1056 } 1078 }
1057 LLStartUp::setStartupState( STATE_LOGIN_PROCESS_RESPONSE ); 1079 LLStartUp::setStartupState( STATE_LOGIN_PROCESS_RESPONSE );
1058 progress += 0.01f; 1080 progress += 0.01f;
1059 set_startup_status(progress, LLTrans::getString("LoginProcessingResponse").c_str(), auth_message.c_str()); 1081 set_startup_status(progress, LLTrans::getString("LoginProcessingResponse"), auth_message);
1060 return do_normal_idle; 1082 return FALSE;
1061 } 1083 }
1062 1084
1063 if(STATE_LOGIN_PROCESS_RESPONSE == LLStartUp::getStartupState()) 1085 if(STATE_LOGIN_PROCESS_RESPONSE == LLStartUp::getStartupState())
1064 { 1086 {
1065 LL_DEBUGS("AppInit") << "STATE_LOGIN_PROCESS_RESPONSE" << LL_ENDL; 1087 LL_DEBUGS("AppInit") << "STATE_LOGIN_PROCESS_RESPONSE" << LL_ENDL;
1066 std::ostringstream emsg; 1088 std::ostringstream emsg;
1067 BOOL quit = FALSE; 1089 bool quit = false;
1068 const char* login_response = NULL; 1090 std::string login_response;
1069 const char* reason_response = NULL; 1091 std::string reason_response;
1070 const char* message_response = NULL; 1092 std::string message_response;
1071 BOOL successful_login = FALSE; 1093 bool successful_login = false;
1072 LLUserAuth::UserAuthcode error = LLUserAuth::getInstance()->authResponse(); 1094 LLUserAuth::UserAuthcode error = LLUserAuth::getInstance()->authResponse();
1073 // reset globals 1095 // reset globals
1074 gAcceptTOS = FALSE; 1096 gAcceptTOS = FALSE;
@@ -1077,12 +1099,12 @@ BOOL idle_startup()
1077 { 1099 {
1078 case LLUserAuth::E_OK: 1100 case LLUserAuth::E_OK:
1079 login_response = LLUserAuth::getInstance()->getResponse("login"); 1101 login_response = LLUserAuth::getInstance()->getResponse("login");
1080 if(login_response && (0 == strcmp(login_response, "true"))) 1102 if(login_response == "true")
1081 { 1103 {
1082 // Yay, login! 1104 // Yay, login!
1083 successful_login = TRUE; 1105 successful_login = true;
1084 } 1106 }
1085 else if(login_response && (0 == strcmp(login_response, "indeterminate"))) 1107 else if(login_response == "indeterminate")
1086 { 1108 {
1087 LL_INFOS("AppInit") << "Indeterminate login..." << LL_ENDL; 1109 LL_INFOS("AppInit") << "Indeterminate login..." << LL_ENDL;
1088 sAuthUris = LLSRV::rewriteURI(LLUserAuth::getInstance()->getResponse("next_url")); 1110 sAuthUris = LLSRV::rewriteURI(LLUserAuth::getInstance()->getResponse("next_url"));
@@ -1091,16 +1113,16 @@ BOOL idle_startup()
1091 auth_message = LLUserAuth::getInstance()->getResponse("message"); 1113 auth_message = LLUserAuth::getInstance()->getResponse("message");
1092 if(auth_method.substr(0, 5) == "login") 1114 if(auth_method.substr(0, 5) == "login")
1093 { 1115 {
1094 auth_desc.assign(LLTrans::getString("LoginAuthenticating").c_str()); 1116 auth_desc.assign(LLTrans::getString("LoginAuthenticating"));
1095 } 1117 }
1096 else 1118 else
1097 { 1119 {
1098 auth_desc.assign(LLTrans::getString("LoginMaintenance").c_str()); 1120 auth_desc.assign(LLTrans::getString("LoginMaintenance"));
1099 } 1121 }
1100 // ignoring the duration & options array for now. 1122 // ignoring the duration & options array for now.
1101 // Go back to authenticate. 1123 // Go back to authenticate.
1102 LLStartUp::setStartupState( STATE_LOGIN_AUTHENTICATE ); 1124 LLStartUp::setStartupState( STATE_LOGIN_AUTHENTICATE );
1103 return do_normal_idle; 1125 return FALSE;
1104 } 1126 }
1105 else 1127 else
1106 { 1128 {
@@ -1108,15 +1130,15 @@ BOOL idle_startup()
1108 reason_response = LLUserAuth::getInstance()->getResponse("reason"); 1130 reason_response = LLUserAuth::getInstance()->getResponse("reason");
1109 message_response = LLUserAuth::getInstance()->getResponse("message"); 1131 message_response = LLUserAuth::getInstance()->getResponse("message");
1110 1132
1111 if (gHideLinks && reason_response && (0 == strcmp(reason_response, "disabled"))) 1133 if (gHideLinks && reason_response == "disabled")
1112 { 1134 {
1113 emsg << gDisabledMessage; 1135 emsg << gDisabledMessage;
1114 } 1136 }
1115 else if (message_response) 1137 else if (!message_response.empty())
1116 { 1138 {
1117 // XUI: fix translation for strings returned during login 1139 // XUI: fix translation for strings returned during login
1118 // We need a generic table for translations 1140 // We need a generic table for translations
1119 LLString big_reason = LLAgent::sTeleportErrorMessages[ message_response ]; 1141 std::string big_reason = LLAgent::sTeleportErrorMessages[ message_response ];
1120 if ( big_reason.size() == 0 ) 1142 if ( big_reason.size() == 0 )
1121 { 1143 {
1122 emsg << message_response; 1144 emsg << message_response;
@@ -1127,7 +1149,7 @@ BOOL idle_startup()
1127 } 1149 }
1128 } 1150 }
1129 1151
1130 if(reason_response && (0 == strcmp(reason_response, "tos"))) 1152 if(reason_response == "tos")
1131 { 1153 {
1132 if (show_connect_box) 1154 if (show_connect_box)
1133 { 1155 {
@@ -1137,14 +1159,14 @@ BOOL idle_startup()
1137 message_response); 1159 message_response);
1138 tos_dialog->startModal(); 1160 tos_dialog->startModal();
1139 // LLFloaterTOS deletes itself. 1161 // LLFloaterTOS deletes itself.
1140 return FALSE; 1162 return false;
1141 } 1163 }
1142 else 1164 else
1143 { 1165 {
1144 quit = TRUE; 1166 quit = true;
1145 } 1167 }
1146 } 1168 }
1147 if(reason_response && (0 == strcmp(reason_response, "critical"))) 1169 if(reason_response == "critical")
1148 { 1170 {
1149 if (show_connect_box) 1171 if (show_connect_box)
1150 { 1172 {
@@ -1154,34 +1176,34 @@ BOOL idle_startup()
1154 message_response); 1176 message_response);
1155 tos_dialog->startModal(); 1177 tos_dialog->startModal();
1156 // LLFloaterTOS deletes itself. 1178 // LLFloaterTOS deletes itself.
1157 return FALSE; 1179 return false;
1158 } 1180 }
1159 else 1181 else
1160 { 1182 {
1161 quit = TRUE; 1183 quit = true;
1162 } 1184 }
1163 } 1185 }
1164 if(reason_response && (0 == strcmp(reason_response, "key"))) 1186 if(reason_response == "key")
1165 { 1187 {
1166 // Couldn't login because user/password is wrong 1188 // Couldn't login because user/password is wrong
1167 // Clear the password 1189 // Clear the password
1168 password = ""; 1190 password = "";
1169 } 1191 }
1170 if(reason_response && (0 == strcmp(reason_response, "update"))) 1192 if(reason_response == "update")
1171 { 1193 {
1172 auth_message = LLUserAuth::getInstance()->getResponse("message"); 1194 auth_message = LLUserAuth::getInstance()->getResponse("message");
1173 if (show_connect_box) 1195 if (show_connect_box)
1174 { 1196 {
1175 update_app(TRUE, auth_message); 1197 update_app(TRUE, auth_message);
1176 LLStartUp::setStartupState( STATE_UPDATE_CHECK ); 1198 LLStartUp::setStartupState( STATE_UPDATE_CHECK );
1177 return FALSE; 1199 return false;
1178 } 1200 }
1179 else 1201 else
1180 { 1202 {
1181 quit = TRUE; 1203 quit = true;
1182 } 1204 }
1183 } 1205 }
1184 if(reason_response && (0 == strcmp(reason_response, "optional"))) 1206 if(reason_response == "optional")
1185 { 1207 {
1186 LL_DEBUGS("AppInit") << "Login got optional update" << LL_ENDL; 1208 LL_DEBUGS("AppInit") << "Login got optional update" << LL_ENDL;
1187 auth_message = LLUserAuth::getInstance()->getResponse("message"); 1209 auth_message = LLUserAuth::getInstance()->getResponse("message");
@@ -1190,7 +1212,7 @@ BOOL idle_startup()
1190 update_app(FALSE, auth_message); 1212 update_app(FALSE, auth_message);
1191 LLStartUp::setStartupState( STATE_UPDATE_CHECK ); 1213 LLStartUp::setStartupState( STATE_UPDATE_CHECK );
1192 gSkipOptionalUpdate = TRUE; 1214 gSkipOptionalUpdate = TRUE;
1193 return FALSE; 1215 return false;
1194 } 1216 }
1195 } 1217 }
1196 } 1218 }
@@ -1208,11 +1230,11 @@ BOOL idle_startup()
1208 } else { 1230 } else {
1209 sAuthUriNum++; 1231 sAuthUriNum++;
1210 std::ostringstream s; 1232 std::ostringstream s;
1211 LLString::format_map_t args; 1233 LLStringUtil::format_map_t args;
1212 args["[NUMBER]"] = llformat("%d", sAuthUriNum + 1); 1234 args["[NUMBER]"] = llformat("%d", sAuthUriNum + 1);
1213 auth_desc = LLTrans::getString("LoginAttempt", args).c_str(); 1235 auth_desc = LLTrans::getString("LoginAttempt", args);
1214 LLStartUp::setStartupState( STATE_LOGIN_AUTHENTICATE ); 1236 LLStartUp::setStartupState( STATE_LOGIN_AUTHENTICATE );
1215 return do_normal_idle; 1237 return FALSE;
1216 } 1238 }
1217 break; 1239 break;
1218 } 1240 }
@@ -1222,35 +1244,35 @@ BOOL idle_startup()
1222 { 1244 {
1223 LLUserAuth::getInstance()->reset(); 1245 LLUserAuth::getInstance()->reset();
1224 LLAppViewer::instance()->forceQuit(); 1246 LLAppViewer::instance()->forceQuit();
1225 return FALSE; 1247 return false;
1226 } 1248 }
1227 1249
1228 if(successful_login) 1250 if(successful_login)
1229 { 1251 {
1230 // unpack login data needed by the application 1252 // unpack login data needed by the application
1231 const char* text; 1253 std::string text;
1232 text = LLUserAuth::getInstance()->getResponse("agent_id"); 1254 text = LLUserAuth::getInstance()->getResponse("agent_id");
1233 if(text) gAgentID.set(text); 1255 if(!text.empty()) gAgentID.set(text);
1234 gDebugInfo["AgentID"] = text; 1256 gDebugInfo["AgentID"] = text;
1235 1257
1236 text = LLUserAuth::getInstance()->getResponse("session_id"); 1258 text = LLUserAuth::getInstance()->getResponse("session_id");
1237 if(text) gAgentSessionID.set(text); 1259 if(!text.empty()) gAgentSessionID.set(text);
1238 gDebugInfo["SessionID"] = text; 1260 gDebugInfo["SessionID"] = text;
1239 1261
1240 text = LLUserAuth::getInstance()->getResponse("secure_session_id"); 1262 text = LLUserAuth::getInstance()->getResponse("secure_session_id");
1241 if(text) gAgent.mSecureSessionID.set(text); 1263 if(!text.empty()) gAgent.mSecureSessionID.set(text);
1242 1264
1243 text = LLUserAuth::getInstance()->getResponse("first_name"); 1265 text = LLUserAuth::getInstance()->getResponse("first_name");
1244 if(text) 1266 if(!text.empty())
1245 { 1267 {
1246 // Remove quotes from string. Login.cgi sends these to force 1268 // Remove quotes from string. Login.cgi sends these to force
1247 // names that look like numbers into strings. 1269 // names that look like numbers into strings.
1248 firstname.assign(text); 1270 firstname.assign(text);
1249 LLString::replaceChar(firstname, '"', ' '); 1271 LLStringUtil::replaceChar(firstname, '"', ' ');
1250 LLString::trim(firstname); 1272 LLStringUtil::trim(firstname);
1251 } 1273 }
1252 text = LLUserAuth::getInstance()->getResponse("last_name"); 1274 text = LLUserAuth::getInstance()->getResponse("last_name");
1253 if(text) lastname.assign(text); 1275 if(!text.empty()) lastname.assign(text);
1254 gSavedSettings.setString("FirstName", firstname); 1276 gSavedSettings.setString("FirstName", firstname);
1255 gSavedSettings.setString("LastName", lastname); 1277 gSavedSettings.setString("LastName", lastname);
1256 1278
@@ -1265,7 +1287,7 @@ BOOL idle_startup()
1265 gSavedSettings.setBOOL("RememberPassword", remember_password); 1287 gSavedSettings.setBOOL("RememberPassword", remember_password);
1266 1288
1267 text = LLUserAuth::getInstance()->getResponse("agent_access"); 1289 text = LLUserAuth::getInstance()->getResponse("agent_access");
1268 if(text && (text[0] == 'M')) 1290 if(!text.empty() && (text[0] == 'M'))
1269 { 1291 {
1270 gAgent.setTeen(false); 1292 gAgent.setTeen(false);
1271 } 1293 }
@@ -1275,52 +1297,48 @@ BOOL idle_startup()
1275 } 1297 }
1276 1298
1277 text = LLUserAuth::getInstance()->getResponse("start_location"); 1299 text = LLUserAuth::getInstance()->getResponse("start_location");
1278 if(text) agent_start_location.assign(text); 1300 if(!text.empty()) agent_start_location.assign(text);
1279 text = LLUserAuth::getInstance()->getResponse("circuit_code"); 1301 text = LLUserAuth::getInstance()->getResponse("circuit_code");
1280 if(text) 1302 if(!text.empty())
1281 { 1303 {
1282 gMessageSystem->mOurCircuitCode = strtoul(text, NULL, 10); 1304 gMessageSystem->mOurCircuitCode = strtoul(text.c_str(), NULL, 10);
1283 } 1305 }
1284 const char* sim_ip_str = LLUserAuth::getInstance()->getResponse("sim_ip"); 1306 std::string sim_ip_str = LLUserAuth::getInstance()->getResponse("sim_ip");
1285 const char* sim_port_str = LLUserAuth::getInstance()->getResponse("sim_port"); 1307 std::string sim_port_str = LLUserAuth::getInstance()->getResponse("sim_port");
1286 if(sim_ip_str && sim_port_str) 1308 if(!sim_ip_str.empty() && !sim_port_str.empty())
1287 { 1309 {
1288 U32 sim_port = strtoul(sim_port_str, NULL, 10); 1310 U32 sim_port = strtoul(sim_port_str.c_str(), NULL, 10);
1289 first_sim.set(sim_ip_str, sim_port); 1311 first_sim.set(sim_ip_str, sim_port);
1290 if (first_sim.isOk()) 1312 if (first_sim.isOk())
1291 { 1313 {
1292 gMessageSystem->enableCircuit(first_sim, TRUE); 1314 gMessageSystem->enableCircuit(first_sim, TRUE);
1293 } 1315 }
1294 } 1316 }
1295 const char* region_x_str = LLUserAuth::getInstance()->getResponse("region_x"); 1317 std::string region_x_str = LLUserAuth::getInstance()->getResponse("region_x");
1296 const char* region_y_str = LLUserAuth::getInstance()->getResponse("region_y"); 1318 std::string region_y_str = LLUserAuth::getInstance()->getResponse("region_y");
1297 if(region_x_str && region_y_str) 1319 if(!region_x_str.empty() && !region_y_str.empty())
1298 { 1320 {
1299 U32 region_x = strtoul(region_x_str, NULL, 10); 1321 U32 region_x = strtoul(region_x_str.c_str(), NULL, 10);
1300 U32 region_y = strtoul(region_y_str, NULL, 10); 1322 U32 region_y = strtoul(region_y_str.c_str(), NULL, 10);
1301 first_sim_handle = to_region_handle(region_x, region_y); 1323 first_sim_handle = to_region_handle(region_x, region_y);
1302 } 1324 }
1303 1325
1304 const char* look_at_str = LLUserAuth::getInstance()->getResponse("look_at"); 1326 const std::string look_at_str = LLUserAuth::getInstance()->getResponse("look_at");
1305 if (look_at_str) 1327 if (!look_at_str.empty())
1306 { 1328 {
1307#if !LL_WINDOWS && !LL_DARWIN 1329 size_t len = look_at_str.size();
1308 size_t len = strnlen(look_at_str, MAX_STRING); 1330 LLMemoryStream mstr((U8*)look_at_str.c_str(), len);
1309#else
1310 size_t len = strlen(look_at_str);
1311#endif
1312 LLMemoryStream mstr((U8*)look_at_str, len);
1313 LLSD sd = LLSDSerialize::fromNotation(mstr, len); 1331 LLSD sd = LLSDSerialize::fromNotation(mstr, len);
1314 agent_start_look_at = ll_vector3_from_sd(sd); 1332 agent_start_look_at = ll_vector3_from_sd(sd);
1315 } 1333 }
1316 1334
1317 text = LLUserAuth::getInstance()->getResponse("seed_capability"); 1335 text = LLUserAuth::getInstance()->getResponse("seed_capability");
1318 if (text) first_sim_seed_cap = text; 1336 if (!text.empty()) first_sim_seed_cap = text;
1319 1337
1320 text = LLUserAuth::getInstance()->getResponse("seconds_since_epoch"); 1338 text = LLUserAuth::getInstance()->getResponse("seconds_since_epoch");
1321 if(text) 1339 if(!text.empty())
1322 { 1340 {
1323 U32 server_utc_time = strtoul(text, NULL, 10); 1341 U32 server_utc_time = strtoul(text.c_str(), NULL, 10);
1324 if(server_utc_time) 1342 if(server_utc_time)
1325 { 1343 {
1326 time_t now = time(NULL); 1344 time_t now = time(NULL);
@@ -1328,15 +1346,11 @@ BOOL idle_startup()
1328 } 1346 }
1329 } 1347 }
1330 1348
1331 const char* home_location = LLUserAuth::getInstance()->getResponse("home"); 1349 std::string home_location = LLUserAuth::getInstance()->getResponse("home");
1332 if(home_location) 1350 if(!home_location.empty())
1333 { 1351 {
1334#if !LL_WINDOWS && !LL_DARWIN 1352 size_t len = home_location.size();
1335 size_t len = strnlen(home_location, MAX_STRING); 1353 LLMemoryStream mstr((U8*)home_location.c_str(), len);
1336#else
1337 size_t len = strlen(home_location);
1338#endif
1339 LLMemoryStream mstr((U8*)home_location, len);
1340 LLSD sd = LLSDSerialize::fromNotation(mstr, len); 1354 LLSD sd = LLSDSerialize::fromNotation(mstr, len);
1341 S32 region_x = sd["region_handle"][0].asInteger(); 1355 S32 region_x = sd["region_handle"][0].asInteger();
1342 S32 region_y = sd["region_handle"][1].asInteger(); 1356 S32 region_y = sd["region_handle"][1].asInteger();
@@ -1353,7 +1367,7 @@ BOOL idle_startup()
1353 it = options[0].find("folder_id"); 1367 it = options[0].find("folder_id");
1354 if(it != options[0].end()) 1368 if(it != options[0].end())
1355 { 1369 {
1356 gAgent.mInventoryRootID.set((*it).second.c_str()); 1370 gAgent.mInventoryRootID.set((*it).second);
1357 //gInventory.mock(gAgent.getInventoryRootID()); 1371 //gInventory.mock(gAgent.getInventoryRootID());
1358 } 1372 }
1359 } 1373 }
@@ -1372,7 +1386,7 @@ BOOL idle_startup()
1372 it = options[0].find("stipend_since_login"); 1386 it = options[0].find("stipend_since_login");
1373 if(it != no_flag) 1387 if(it != no_flag)
1374 { 1388 {
1375 if((*it).second == "Y") stipend_since_login = TRUE; 1389 if((*it).second == "Y") stipend_since_login = true;
1376 } 1390 }
1377 it = options[0].find("gendered"); 1391 it = options[0].find("gendered");
1378 if(it != no_flag) 1392 if(it != no_flag)
@@ -1395,12 +1409,14 @@ BOOL idle_startup()
1395 it = options[0].find("folder_name"); 1409 it = options[0].find("folder_name");
1396 if(it != it_end) 1410 if(it != it_end)
1397 { 1411 {
1398 gInitialOutfit = (*it).second; 1412 // Initial outfit is a folder in your inventory,
1413 // must be an exact folder-name match.
1414 sInitialOutfit = (*it).second;
1399 } 1415 }
1400 it = options[0].find("gender"); 1416 it = options[0].find("gender");
1401 if (it != it_end) 1417 if (it != it_end)
1402 { 1418 {
1403 gInitialOutfitGender = (*it).second; 1419 sInitialOutfitGender = (*it).second;
1404 } 1420 }
1405 } 1421 }
1406 1422
@@ -1415,17 +1431,17 @@ BOOL idle_startup()
1415 it = options[0].find("sun_texture_id"); 1431 it = options[0].find("sun_texture_id");
1416 if(it != no_texture) 1432 if(it != no_texture)
1417 { 1433 {
1418 gSunTextureID.set((*it).second.c_str()); 1434 gSunTextureID.set((*it).second);
1419 } 1435 }
1420 it = options[0].find("moon_texture_id"); 1436 it = options[0].find("moon_texture_id");
1421 if(it != no_texture) 1437 if(it != no_texture)
1422 { 1438 {
1423 gMoonTextureID.set((*it).second.c_str()); 1439 gMoonTextureID.set((*it).second);
1424 } 1440 }
1425 it = options[0].find("cloud_texture_id"); 1441 it = options[0].find("cloud_texture_id");
1426 if(it != no_texture) 1442 if(it != no_texture)
1427 { 1443 {
1428 gCloudTextureID.set((*it).second.c_str()); 1444 gCloudTextureID.set((*it).second);
1429 } 1445 }
1430 } 1446 }
1431 1447
@@ -1450,12 +1466,12 @@ BOOL idle_startup()
1450 exit(0); 1466 exit(0);
1451 } 1467 }
1452 // Bounce back to the login screen. 1468 // Bounce back to the login screen.
1453 LLStringBase<char>::format_map_t args; 1469 LLStringUtil::format_map_t args;
1454 args["[ERROR_MESSAGE]"] = emsg.str(); 1470 args["[ERROR_MESSAGE]"] = emsg.str();
1455 gViewerWindow->alertXml("ErrorMessage", args, login_alert_done); 1471 gViewerWindow->alertXml("ErrorMessage", args, login_alert_done);
1456 reset_login(); 1472 reset_login();
1457 gSavedSettings.setBOOL("AutoLogin", FALSE); 1473 gSavedSettings.setBOOL("AutoLogin", FALSE);
1458 show_connect_box = TRUE; 1474 show_connect_box = true;
1459 } 1475 }
1460 1476
1461 // Pass the user information to the voice chat server interface. 1477 // Pass the user information to the voice chat server interface.
@@ -1470,16 +1486,16 @@ BOOL idle_startup()
1470 exit(0); 1486 exit(0);
1471 } 1487 }
1472 // Bounce back to the login screen. 1488 // Bounce back to the login screen.
1473 LLStringBase<char>::format_map_t args; 1489 LLStringUtil::format_map_t args;
1474 args["[ERROR_MESSAGE]"] = emsg.str(); 1490 args["[ERROR_MESSAGE]"] = emsg.str();
1475 gViewerWindow->alertXml("ErrorMessage", args, login_alert_done); 1491 gViewerWindow->alertXml("ErrorMessage", args, login_alert_done);
1476 reset_login(); 1492 reset_login();
1477 gSavedSettings.setBOOL("AutoLogin", FALSE); 1493 gSavedSettings.setBOOL("AutoLogin", FALSE);
1478 show_connect_box = TRUE; 1494 show_connect_box = true;
1479 // Don't save an incorrect password to disk. 1495 // Don't save an incorrect password to disk.
1480 save_password_to_disk(NULL); 1496 save_password_to_disk(NULL);
1481 } 1497 }
1482 return do_normal_idle; 1498 return FALSE;
1483 } 1499 }
1484 1500
1485 //--------------------------------------------------------------------- 1501 //---------------------------------------------------------------------
@@ -1487,7 +1503,7 @@ BOOL idle_startup()
1487 //--------------------------------------------------------------------- 1503 //---------------------------------------------------------------------
1488 if (STATE_WORLD_INIT == LLStartUp::getStartupState()) 1504 if (STATE_WORLD_INIT == LLStartUp::getStartupState())
1489 { 1505 {
1490 set_startup_status(0.40f, LLTrans::getString("LoginInitializingWorld").c_str(), gAgent.mMOTD.c_str()); 1506 set_startup_status(0.40f, LLTrans::getString("LoginInitializingWorld"), gAgent.mMOTD);
1491 display_startup(); 1507 display_startup();
1492 // We should have an agent id by this point. 1508 // We should have an agent id by this point.
1493 llassert(!(gAgentID == LLUUID::null)); 1509 llassert(!(gAgentID == LLUUID::null));
@@ -1537,7 +1553,6 @@ BOOL idle_startup()
1537 LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromHandle(first_sim_handle); 1553 LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromHandle(first_sim_handle);
1538 LL_INFOS("AppInit") << "Adding initial simulator " << regionp->getOriginGlobal() << LL_ENDL; 1554 LL_INFOS("AppInit") << "Adding initial simulator " << regionp->getOriginGlobal() << LL_ENDL;
1539 1555
1540 LLStartUp::setStartupState( STATE_SEED_GRANTED_WAIT );
1541 regionp->setSeedCapability(first_sim_seed_cap); 1556 regionp->setSeedCapability(first_sim_seed_cap);
1542 LL_DEBUGS("AppInit") << "Waiting for seed grant ...." << LL_ENDL; 1557 LL_DEBUGS("AppInit") << "Waiting for seed grant ...." << LL_ENDL;
1543 1558
@@ -1549,16 +1564,28 @@ BOOL idle_startup()
1549 gAgent.setPositionAgent(agent_start_position_region); 1564 gAgent.setPositionAgent(agent_start_position_region);
1550 1565
1551 display_startup(); 1566 display_startup();
1552 return do_normal_idle; 1567 LLStartUp::setStartupState( STATE_MULTIMEDIA_INIT );
1568 return FALSE;
1553 } 1569 }
1554 1570
1555 1571
1556 //--------------------------------------------------------------------- 1572 //---------------------------------------------------------------------
1573 // Load QuickTime/GStreamer and other multimedia engines, can be slow.
1574 // Do it while we're waiting on the network for our seed capability. JC
1575 //---------------------------------------------------------------------
1576 if (STATE_MULTIMEDIA_INIT == LLStartUp::getStartupState())
1577 {
1578 LLStartUp::multimediaInit();
1579 LLStartUp::setStartupState( STATE_SEED_GRANTED_WAIT );
1580 return FALSE;
1581 }
1582
1583 //---------------------------------------------------------------------
1557 // Wait for Seed Cap Grant 1584 // Wait for Seed Cap Grant
1558 //--------------------------------------------------------------------- 1585 //---------------------------------------------------------------------
1559 if(STATE_SEED_GRANTED_WAIT == LLStartUp::getStartupState()) 1586 if(STATE_SEED_GRANTED_WAIT == LLStartUp::getStartupState())
1560 { 1587 {
1561 return do_normal_idle; 1588 return FALSE;
1562 } 1589 }
1563 1590
1564 1591
@@ -1579,6 +1606,9 @@ BOOL idle_startup()
1579 1606
1580 gFloaterMap->setVisible( gSavedSettings.getBOOL("ShowMiniMap") ); 1607 gFloaterMap->setVisible( gSavedSettings.getBOOL("ShowMiniMap") );
1581 1608
1609 LLRect window(0, gViewerWindow->getWindowHeight(), gViewerWindow->getWindowWidth(), 0);
1610 gViewerWindow->adjustControlRectanglesForFirstUse(window);
1611
1582 if (gSavedSettings.getBOOL("ShowCameraControls")) 1612 if (gSavedSettings.getBOOL("ShowCameraControls"))
1583 { 1613 {
1584 LLFloaterCamera::showInstance(); 1614 LLFloaterCamera::showInstance();
@@ -1703,7 +1733,7 @@ BOOL idle_startup()
1703 for (int i = 0; i < DECODE_TIME_SEC; i++) 1733 for (int i = 0; i < DECODE_TIME_SEC; i++)
1704 { 1734 {
1705 F32 frac = (F32)i / (F32)DECODE_TIME_SEC; 1735 F32 frac = (F32)i / (F32)DECODE_TIME_SEC;
1706 set_startup_status(0.45f + frac*0.1f, LLTrans::getString("LoginDecodingImages").c_str(), gAgent.mMOTD.c_str()); 1736 set_startup_status(0.45f + frac*0.1f, LLTrans::getString("LoginDecodingImages"), gAgent.mMOTD);
1707 display_startup(); 1737 display_startup();
1708 gImageList.decodeAllImages(1.f); 1738 gImageList.decodeAllImages(1.f);
1709 } 1739 }
@@ -1737,18 +1767,16 @@ BOOL idle_startup()
1737 1767
1738 timeout.reset(); 1768 timeout.reset();
1739 1769
1740 return do_normal_idle; 1770 return FALSE;
1741 } 1771 }
1742 1772
1743 //--------------------------------------------------------------------- 1773 //---------------------------------------------------------------------
1744
1745
1746 // Agent Send 1774 // Agent Send
1747 //--------------------------------------------------------------------- 1775 //---------------------------------------------------------------------
1748 if(STATE_WORLD_WAIT == LLStartUp::getStartupState()) 1776 if(STATE_WORLD_WAIT == LLStartUp::getStartupState())
1749 { 1777 {
1750 LL_DEBUGS("AppInit") << "Waiting for simulator ack...." << LL_ENDL; 1778 LL_DEBUGS("AppInit") << "Waiting for simulator ack...." << LL_ENDL;
1751 set_startup_status(0.59f, LLTrans::getString("LoginWaitingForRegionHandshake").c_str(), gAgent.mMOTD.c_str()); 1779 set_startup_status(0.59f, LLTrans::getString("LoginWaitingForRegionHandshake"), gAgent.mMOTD);
1752 if(gGotUseCircuitCodeAck) 1780 if(gGotUseCircuitCodeAck)
1753 { 1781 {
1754 LLStartUp::setStartupState( STATE_AGENT_SEND ); 1782 LLStartUp::setStartupState( STATE_AGENT_SEND );
@@ -1758,7 +1786,7 @@ BOOL idle_startup()
1758 { 1786 {
1759 } 1787 }
1760 msg->processAcks(); 1788 msg->processAcks();
1761 return do_normal_idle; 1789 return FALSE;
1762 } 1790 }
1763 1791
1764 //--------------------------------------------------------------------- 1792 //---------------------------------------------------------------------
@@ -1767,7 +1795,7 @@ BOOL idle_startup()
1767 if (STATE_AGENT_SEND == LLStartUp::getStartupState()) 1795 if (STATE_AGENT_SEND == LLStartUp::getStartupState())
1768 { 1796 {
1769 LL_DEBUGS("AppInit") << "Connecting to region..." << LL_ENDL; 1797 LL_DEBUGS("AppInit") << "Connecting to region..." << LL_ENDL;
1770 set_startup_status(0.60f, LLTrans::getString("LoginConnectingToRegion").c_str(), gAgent.mMOTD.c_str()); 1798 set_startup_status(0.60f, LLTrans::getString("LoginConnectingToRegion"), gAgent.mMOTD);
1771 // register with the message system so it knows we're 1799 // register with the message system so it knows we're
1772 // expecting this message 1800 // expecting this message
1773 LLMessageSystem* msg = gMessageSystem; 1801 LLMessageSystem* msg = gMessageSystem;
@@ -1797,7 +1825,7 @@ BOOL idle_startup()
1797 LLStartUp::setStartupState( STATE_AGENT_WAIT ); // Go to STATE_AGENT_WAIT 1825 LLStartUp::setStartupState( STATE_AGENT_WAIT ); // Go to STATE_AGENT_WAIT
1798 1826
1799 timeout.reset(); 1827 timeout.reset();
1800 return do_normal_idle; 1828 return FALSE;
1801 } 1829 }
1802 1830
1803 //--------------------------------------------------------------------- 1831 //---------------------------------------------------------------------
@@ -1829,7 +1857,7 @@ BOOL idle_startup()
1829 LLStartUp::setStartupState( STATE_INVENTORY_SEND ); 1857 LLStartUp::setStartupState( STATE_INVENTORY_SEND );
1830 } 1858 }
1831 1859
1832 return do_normal_idle; 1860 return FALSE;
1833 } 1861 }
1834 1862
1835 //--------------------------------------------------------------------- 1863 //---------------------------------------------------------------------
@@ -1850,7 +1878,7 @@ BOOL idle_startup()
1850 it = options[0].find("folder_id"); 1878 it = options[0].find("folder_id");
1851 if(it != options[0].end()) 1879 if(it != options[0].end())
1852 { 1880 {
1853 gInventoryLibraryRoot.set((*it).second.c_str()); 1881 gInventoryLibraryRoot.set((*it).second);
1854 } 1882 }
1855 } 1883 }
1856 options.clear(); 1884 options.clear();
@@ -1862,7 +1890,7 @@ BOOL idle_startup()
1862 it = options[0].find("agent_id"); 1890 it = options[0].find("agent_id");
1863 if(it != options[0].end()) 1891 if(it != options[0].end())
1864 { 1892 {
1865 gInventoryLibraryOwner.set((*it).second.c_str()); 1893 gInventoryLibraryOwner.set((*it).second);
1866 } 1894 }
1867 } 1895 }
1868 options.clear(); 1896 options.clear();
@@ -1897,7 +1925,7 @@ BOOL idle_startup()
1897 option_it = (*it).find("buddy_id"); 1925 option_it = (*it).find("buddy_id");
1898 if(option_it != (*it).end()) 1926 if(option_it != (*it).end())
1899 { 1927 {
1900 agent_id.set((*option_it).second.c_str()); 1928 agent_id.set((*option_it).second);
1901 } 1929 }
1902 option_it = (*it).find("buddy_rights_has"); 1930 option_it = (*it).find("buddy_rights_has");
1903 if(option_it != (*it).end()) 1931 if(option_it != (*it).end())
@@ -1933,6 +1961,7 @@ BOOL idle_startup()
1933 } 1961 }
1934 } 1962 }
1935 options.clear(); 1963 options.clear();
1964 bool show_hud = false;
1936 if(LLUserAuth::getInstance()->getOptions("tutorial_setting", options)) 1965 if(LLUserAuth::getInstance()->getOptions("tutorial_setting", options))
1937 { 1966 {
1938 LLUserAuth::options_t::iterator it = options.begin(); 1967 LLUserAuth::options_t::iterator it = options.begin();
@@ -1951,11 +1980,19 @@ BOOL idle_startup()
1951 { 1980 {
1952 if (option_it->second == "true") 1981 if (option_it->second == "true")
1953 { 1982 {
1954 LLFloaterHUD::show(); 1983 show_hud = true;
1955 } 1984 }
1956 } 1985 }
1957 } 1986 }
1958 } 1987 }
1988 // Either we want to show tutorial because this is the first login
1989 // to a Linden Help Island or the user quit with the tutorial
1990 // visible. JC
1991 if (show_hud
1992 || gSavedSettings.getBOOL("ShowTutorial"))
1993 {
1994 LLFloaterHUD::showHUD();
1995 }
1959 1996
1960 options.clear(); 1997 options.clear();
1961 if(LLUserAuth::getInstance()->getOptions("event_categories", options)) 1998 if(LLUserAuth::getInstance()->getOptions("event_categories", options))
@@ -1972,19 +2009,27 @@ BOOL idle_startup()
1972 LLClassifiedInfo::loadCategories(options); 2009 LLClassifiedInfo::loadCategories(options);
1973 } 2010 }
1974 gInventory.buildParentChildMap(); 2011 gInventory.buildParentChildMap();
2012
2013 llinfos << "Setting Inventory changed mask and notifying observers" << llendl;
1975 gInventory.addChangedMask(LLInventoryObserver::ALL, LLUUID::null); 2014 gInventory.addChangedMask(LLInventoryObserver::ALL, LLUUID::null);
1976 gInventory.notifyObservers(); 2015 gInventory.notifyObservers();
1977 2016
1978 // set up callbacks 2017 // set up callbacks
2018 llinfos << "Registering Callbacks" << llendl;
1979 LLMessageSystem* msg = gMessageSystem; 2019 LLMessageSystem* msg = gMessageSystem;
2020 llinfos << " Inventory" << llendl;
1980 LLInventoryModel::registerCallbacks(msg); 2021 LLInventoryModel::registerCallbacks(msg);
2022 llinfos << " AvatarTracker" << llendl;
1981 LLAvatarTracker::instance().registerCallbacks(msg); 2023 LLAvatarTracker::instance().registerCallbacks(msg);
2024 llinfos << " Landmark" << llendl;
1982 LLLandmark::registerCallbacks(msg); 2025 LLLandmark::registerCallbacks(msg);
1983 2026
1984 // request mute list 2027 // request mute list
2028 llinfos << "Requesting Mute List" << llendl;
1985 LLMuteList::getInstance()->requestFromServer(gAgent.getID()); 2029 LLMuteList::getInstance()->requestFromServer(gAgent.getID());
1986 2030
1987 // Get L$ and ownership credit information 2031 // Get L$ and ownership credit information
2032 llinfos << "Requesting Money Balance" << llendl;
1988 msg->newMessageFast(_PREHASH_MoneyBalanceRequest); 2033 msg->newMessageFast(_PREHASH_MoneyBalanceRequest);
1989 msg->nextBlockFast(_PREHASH_AgentData); 2034 msg->nextBlockFast(_PREHASH_AgentData);
1990 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); 2035 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
@@ -1994,11 +2039,13 @@ BOOL idle_startup()
1994 gAgent.sendReliableMessage(); 2039 gAgent.sendReliableMessage();
1995 2040
1996 // request all group information 2041 // request all group information
2042 llinfos << "Requesting Agent Data" << llendl;
1997 gAgent.sendAgentDataUpdateRequest(); 2043 gAgent.sendAgentDataUpdateRequest();
1998 2044
1999 BOOL shown_at_exit = gSavedSettings.getBOOL("ShowInventory"); 2045 bool shown_at_exit = gSavedSettings.getBOOL("ShowInventory");
2000 2046
2001 // Create the inventory views 2047 // Create the inventory views
2048 llinfos << "Creating Inventory Views" << llendl;
2002 LLInventoryView::showAgentInventory(); 2049 LLInventoryView::showAgentInventory();
2003 2050
2004 // Hide the inventory if it wasn't shown at exit 2051 // Hide the inventory if it wasn't shown at exit
@@ -2008,7 +2055,7 @@ BOOL idle_startup()
2008 } 2055 }
2009 2056
2010 LLStartUp::setStartupState( STATE_MISC ); 2057 LLStartUp::setStartupState( STATE_MISC );
2011 return do_normal_idle; 2058 return FALSE;
2012 } 2059 }
2013 2060
2014 2061
@@ -2053,7 +2100,7 @@ BOOL idle_startup()
2053 2100
2054 // based on the comments, we've successfully logged in so we can delete the 'forced' 2101 // based on the comments, we've successfully logged in so we can delete the 'forced'
2055 // URL that the updater set in settings.ini (in a mostly paranoid fashion) 2102 // URL that the updater set in settings.ini (in a mostly paranoid fashion)
2056 LLString nextLoginLocation = gSavedSettings.getString( "NextLoginLocation" ); 2103 std::string nextLoginLocation = gSavedSettings.getString( "NextLoginLocation" );
2057 if ( nextLoginLocation.length() ) 2104 if ( nextLoginLocation.length() )
2058 { 2105 {
2059 // clear it 2106 // clear it
@@ -2091,13 +2138,13 @@ BOOL idle_startup()
2091 if (option_it != response.end()) 2138 if (option_it != response.end())
2092 { 2139 {
2093 const std::string& uuid_string = (*option_it).second; 2140 const std::string& uuid_string = (*option_it).second;
2094 item_id.set(uuid_string.c_str()); 2141 item_id.set(uuid_string);
2095 } 2142 }
2096 option_it = response.find("asset_id"); 2143 option_it = response.find("asset_id");
2097 if (option_it != response.end()) 2144 if (option_it != response.end())
2098 { 2145 {
2099 const std::string& uuid_string = (*option_it).second; 2146 const std::string& uuid_string = (*option_it).second;
2100 asset_id.set(uuid_string.c_str()); 2147 asset_id.set(uuid_string);
2101 } 2148 }
2102 2149
2103 if (item_id.notNull() && asset_id.notNull()) 2150 if (item_id.notNull() && asset_id.notNull())
@@ -2106,8 +2153,8 @@ BOOL idle_startup()
2106 const BOOL no_inform_server = FALSE; 2153 const BOOL no_inform_server = FALSE;
2107 const BOOL no_deactivate_similar = FALSE; 2154 const BOOL no_deactivate_similar = FALSE;
2108 gGestureManager.activateGestureWithAsset(item_id, asset_id, 2155 gGestureManager.activateGestureWithAsset(item_id, asset_id,
2109 no_inform_server, 2156 no_inform_server,
2110 no_deactivate_similar); 2157 no_deactivate_similar);
2111 // We need to fetch the inventory items for these gestures 2158 // We need to fetch the inventory items for these gestures
2112 // so we have the names to populate the UI. 2159 // so we have the names to populate the UI.
2113 item_ids.push_back(item_id); 2160 item_ids.push_back(item_id);
@@ -2139,6 +2186,10 @@ BOOL idle_startup()
2139 // JC - 7/20/2002 2186 // JC - 7/20/2002
2140 gViewerWindow->sendShapeToSim(); 2187 gViewerWindow->sendShapeToSim();
2141 2188
2189 // Inform simulator of our language preference
2190 LLAgentLanguage::update();
2191
2192
2142 // Ignore stipend information for now. Money history is on the web site. 2193 // Ignore stipend information for now. Money history is on the web site.
2143 // if needed, show the L$ history window 2194 // if needed, show the L$ history window
2144 //if (stipend_since_login && !gNoRender) 2195 //if (stipend_since_login && !gNoRender)
@@ -2157,7 +2208,7 @@ BOOL idle_startup()
2157 // location is not your expected location. So, if this is 2208 // location is not your expected location. So, if this is
2158 // your first login, then you do not have an expectation, 2209 // your first login, then you do not have an expectation,
2159 // thus, do not show this alert. 2210 // thus, do not show this alert.
2160 LLString::format_map_t args; 2211 LLStringUtil::format_map_t args;
2161 if (url_ok) 2212 if (url_ok)
2162 { 2213 {
2163 args["[TYPE]"] = "desired"; 2214 args["[TYPE]"] = "desired";
@@ -2195,26 +2246,42 @@ BOOL idle_startup()
2195 2246
2196 LLStartUp::setStartupState( STATE_PRECACHE ); 2247 LLStartUp::setStartupState( STATE_PRECACHE );
2197 timeout.reset(); 2248 timeout.reset();
2198 return do_normal_idle; 2249 return FALSE;
2199 } 2250 }
2200 2251
2201 if (STATE_PRECACHE == LLStartUp::getStartupState()) 2252 if (STATE_PRECACHE == LLStartUp::getStartupState())
2202 { 2253 {
2203 do_normal_idle = TRUE; 2254 F32 timeout_frac = timeout.getElapsedTimeF32()/PRECACHING_DELAY;
2204 2255
2205 // Avoid generic Ruth avatar in Orientation Island by starting 2256 // We now have an inventory skeleton, so if this is a user's first
2206 // our outfit load as soon as possible. This will be replaced 2257 // login, we can start setting up their clothing and avatar
2207 // with a more definitive patch from featurettes-4 later. JC 2258 // appearance. This helps to avoid the generic "Ruth" avatar in
2259 // the orientation island tutorial experience. JC
2208 if (gAgent.isFirstLogin() 2260 if (gAgent.isFirstLogin()
2209 && !gInitialOutfit.empty() // registration set up an outfit 2261 && !sInitialOutfit.empty() // registration set up an outfit
2210 && gAgent.getAvatarObject() // can't wear clothes until have obj 2262 && !sInitialOutfitGender.empty() // and a gender
2211 && !gAgent.isGenderChosen() ) // nothing already loaded 2263 && gAgent.getAvatarObject() // can't wear clothes without object
2264 && !gAgent.isGenderChosen() ) // nothing already loading
2212 { 2265 {
2213 llinfos << "Wearing initial outfit " << gInitialOutfit << llendl; 2266 // Start loading the wearables, textures, gestures
2214 callback_choose_gender(-1, NULL); 2267 LLStartUp::loadInitialOutfit( sInitialOutfit, sInitialOutfitGender );
2268 }
2269
2270
2271 // We now have an inventory skeleton, so if this is a user's first
2272 // login, we can start setting up their clothing and avatar
2273 // appearance. This helps to avoid the generic "Ruth" avatar in
2274 // the orientation island tutorial experience. JC
2275 if (gAgent.isFirstLogin()
2276 && !sInitialOutfit.empty() // registration set up an outfit
2277 && !sInitialOutfitGender.empty() // and a gender
2278 && gAgent.getAvatarObject() // can't wear clothes without object
2279 && !gAgent.isGenderChosen() ) // nothing already loading
2280 {
2281 // Start loading the wearables, textures, gestures
2282 LLStartUp::loadInitialOutfit( sInitialOutfit, sInitialOutfitGender );
2215 } 2283 }
2216 2284
2217 F32 timeout_frac = timeout.getElapsedTimeF32()/PRECACHING_DELAY;
2218 // wait precache-delay and for agent's avatar or a lot longer. 2285 // wait precache-delay and for agent's avatar or a lot longer.
2219 if(((timeout_frac > 1.f) && gAgent.getAvatarObject()) 2286 if(((timeout_frac > 1.f) && gAgent.getAvatarObject())
2220 || (timeout_frac > 3.f)) 2287 || (timeout_frac > 3.f))
@@ -2224,48 +2291,79 @@ BOOL idle_startup()
2224 else 2291 else
2225 { 2292 {
2226 update_texture_fetch(); 2293 update_texture_fetch();
2227 set_startup_status(0.60f + 0.20f * timeout_frac, 2294 set_startup_status(0.60f + 0.30f * timeout_frac,
2228 "Loading world...", 2295 "Loading world...",
2229 gAgent.mMOTD.c_str()); 2296 gAgent.mMOTD);
2230 } 2297 }
2231 2298
2232 return do_normal_idle; 2299 return TRUE;
2233 } 2300 }
2234 2301
2235 if (STATE_WEARABLES_WAIT == LLStartUp::getStartupState()) 2302 if (STATE_WEARABLES_WAIT == LLStartUp::getStartupState())
2236 { 2303 {
2237 do_normal_idle = TRUE;
2238
2239 static LLFrameTimer wearables_timer; 2304 static LLFrameTimer wearables_timer;
2240 2305
2241 const F32 wearables_time = wearables_timer.getElapsedTimeF32(); 2306 const F32 wearables_time = wearables_timer.getElapsedTimeF32();
2242 const F32 MAX_WEARABLES_TIME = 10.f; 2307 const F32 MAX_WEARABLES_TIME = 10.f;
2243 2308
2244 if(gAgent.getWearablesLoaded() || !gAgent.isGenderChosen()) 2309 if (!gAgent.isGenderChosen())
2245 { 2310 {
2311 // No point in waiting for clothing, we don't even
2312 // know what gender we are. Pop a dialog to ask and
2313 // proceed to draw the world. JC
2314 //
2315 // *NOTE: We might hit this case even if we have an
2316 // initial outfit, but if the load hasn't started
2317 // already then something is wrong so fall back
2318 // to generic outfits. JC
2319 gViewerWindow->alertXml("WelcomeChooseSex",
2320 callback_choose_gender, NULL);
2246 LLStartUp::setStartupState( STATE_CLEANUP ); 2321 LLStartUp::setStartupState( STATE_CLEANUP );
2322 return TRUE;
2247 } 2323 }
2248 else if (wearables_time > MAX_WEARABLES_TIME) 2324
2325 if (wearables_time > MAX_WEARABLES_TIME)
2249 { 2326 {
2327 // It's taken too long to load, show the world
2250 gViewerWindow->alertXml("ClothingLoading"); 2328 gViewerWindow->alertXml("ClothingLoading");
2251 LLViewerStats::getInstance()->incStat(LLViewerStats::ST_WEARABLES_TOO_LONG); 2329 LLViewerStats::getInstance()->incStat(LLViewerStats::ST_WEARABLES_TOO_LONG);
2252 LLStartUp::setStartupState( STATE_CLEANUP ); 2330 LLStartUp::setStartupState( STATE_CLEANUP );
2331 return TRUE;
2332 }
2333
2334 if (gAgent.isFirstLogin())
2335 {
2336 // wait for avatar to be completely loaded
2337 if (gAgent.getAvatarObject()
2338 && gAgent.getAvatarObject()->isFullyLoaded())
2339 {
2340 //llinfos << "avatar fully loaded" << llendl;
2341 LLStartUp::setStartupState( STATE_CLEANUP );
2342 return TRUE;
2343 }
2253 } 2344 }
2254 else 2345 else
2255 { 2346 {
2256 update_texture_fetch(); 2347 // OK to just get the wearables
2257 set_startup_status(0.80f + 0.20f * wearables_time / MAX_WEARABLES_TIME, 2348 if ( gAgent.getWearablesLoaded() )
2258 LLTrans::getString("LoginDownloadingClothing").c_str(), 2349 {
2259 gAgent.mMOTD.c_str()); 2350 // We have our clothing, proceed.
2351 //llinfos << "wearables loaded" << llendl;
2352 LLStartUp::setStartupState( STATE_CLEANUP );
2353 return TRUE;
2354 }
2260 } 2355 }
2261 return do_normal_idle; 2356
2357 update_texture_fetch();
2358 set_startup_status(0.9f + 0.1f * wearables_time / MAX_WEARABLES_TIME,
2359 LLTrans::getString("LoginDownloadingClothing").c_str(),
2360 gAgent.mMOTD.c_str());
2361 return TRUE;
2262 } 2362 }
2263 2363
2264 if (STATE_CLEANUP == LLStartUp::getStartupState()) 2364 if (STATE_CLEANUP == LLStartUp::getStartupState())
2265 { 2365 {
2266 set_startup_status(1.0, "", NULL); 2366 set_startup_status(1.0, "", "");
2267
2268 do_normal_idle = TRUE;
2269 2367
2270 // Let the map know about the inventory. 2368 // Let the map know about the inventory.
2271 if(gFloaterWorldMap) 2369 if(gFloaterWorldMap)
@@ -2279,7 +2377,7 @@ BOOL idle_startup()
2279 gViewerWindow->getWindow()->setCursor(UI_CURSOR_ARROW); 2377 gViewerWindow->getWindow()->setCursor(UI_CURSOR_ARROW);
2280 LL_DEBUGS("AppInit") << "Done releasing bitmap" << LL_ENDL; 2378 LL_DEBUGS("AppInit") << "Done releasing bitmap" << LL_ENDL;
2281 gViewerWindow->setShowProgress(FALSE); 2379 gViewerWindow->setShowProgress(FALSE);
2282 gViewerWindow->setProgressCancelButtonVisible(FALSE, ""); 2380 gViewerWindow->setProgressCancelButtonVisible(FALSE);
2283 2381
2284 // We're not away from keyboard, even though login might have taken 2382 // We're not away from keyboard, even though login might have taken
2285 // a while. JC 2383 // a while. JC
@@ -2292,9 +2390,6 @@ BOOL idle_startup()
2292 gAgent.requestEnterGodMode(); 2390 gAgent.requestEnterGodMode();
2293 } 2391 }
2294 2392
2295 // On first start, ask user for gender
2296 dialog_choose_gender_first_start();
2297
2298 // Start automatic replay if the flag is set. 2393 // Start automatic replay if the flag is set.
2299 if (gSavedSettings.getBOOL("StatsAutoRun")) 2394 if (gSavedSettings.getBOOL("StatsAutoRun"))
2300 { 2395 {
@@ -2328,11 +2423,11 @@ BOOL idle_startup()
2328 2423
2329 LLAppViewer::instance()->initMainloopTimeout("Mainloop Init"); 2424 LLAppViewer::instance()->initMainloopTimeout("Mainloop Init");
2330 2425
2331 return do_normal_idle; 2426 return TRUE;
2332 } 2427 }
2333 2428
2334 LL_WARNS("AppInit") << "Reached end of idle_startup for state " << LLStartUp::getStartupState() << LL_ENDL; 2429 LL_WARNS("AppInit") << "Reached end of idle_startup for state " << LLStartUp::getStartupState() << LL_ENDL;
2335 return do_normal_idle; 2430 return TRUE;
2336} 2431}
2337 2432
2338// 2433//
@@ -2357,12 +2452,12 @@ void login_show()
2357 2452
2358 LL_DEBUGS("AppInit") << "Setting Servers" << LL_ENDL; 2453 LL_DEBUGS("AppInit") << "Setting Servers" << LL_ENDL;
2359 2454
2360 LLPanelLogin::addServer(LLViewerLogin::getInstance()->getGridLabel().c_str(), LLViewerLogin::getInstance()->getGridChoice()); 2455 LLPanelLogin::addServer(LLViewerLogin::getInstance()->getGridLabel(), LLViewerLogin::getInstance()->getGridChoice());
2361 2456
2362 LLViewerLogin* vl = LLViewerLogin::getInstance(); 2457 LLViewerLogin* vl = LLViewerLogin::getInstance();
2363 for(int grid_index = GRID_INFO_ADITI; grid_index < GRID_INFO_OTHER; ++grid_index) 2458 for(int grid_index = GRID_INFO_ADITI; grid_index < GRID_INFO_OTHER; ++grid_index)
2364 { 2459 {
2365 LLPanelLogin::addServer(vl->getKnownGridLabel((EGridInfo)grid_index).c_str(), grid_index); 2460 LLPanelLogin::addServer(vl->getKnownGridLabel((EGridInfo)grid_index), grid_index);
2366 } 2461 }
2367} 2462}
2368 2463
@@ -2380,7 +2475,7 @@ void login_callback(S32 option, void *userdata)
2380 else if (QUIT_OPTION == option) 2475 else if (QUIT_OPTION == option)
2381 { 2476 {
2382 // Make sure we don't save the password if the user is trying to clear it. 2477 // Make sure we don't save the password if the user is trying to clear it.
2383 LLString first, last, password; 2478 std::string first, last, password;
2384 BOOL remember = TRUE; 2479 BOOL remember = TRUE;
2385 LLPanelLogin::getFields(first, last, password, remember); 2480 LLPanelLogin::getFields(first, last, password, remember);
2386 if (!remember) 2481 if (!remember)
@@ -2408,9 +2503,9 @@ void login_callback(S32 option, void *userdata)
2408 } 2503 }
2409} 2504}
2410 2505
2411LLString load_password_from_disk() 2506std::string load_password_from_disk()
2412{ 2507{
2413 LLString hashed_password(""); 2508 std::string hashed_password("");
2414 2509
2415 // Look for legacy "marker" password from settings.ini 2510 // Look for legacy "marker" password from settings.ini
2416 hashed_password = gSavedSettings.getString("Marker"); 2511 hashed_password = gSavedSettings.getString("Marker");
@@ -2425,7 +2520,7 @@ LLString load_password_from_disk()
2425 2520
2426 std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, 2521 std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS,
2427 "password.dat"); 2522 "password.dat");
2428 LLFILE* fp = LLFile::fopen(filepath.c_str(), "rb"); /* Flawfinder: ignore */ 2523 LLFILE* fp = LLFile::fopen(filepath, "rb"); /* Flawfinder: ignore */
2429 if (!fp) 2524 if (!fp)
2430 { 2525 {
2431 return hashed_password; 2526 return hashed_password;
@@ -2468,11 +2563,11 @@ void save_password_to_disk(const char* hashed_password)
2468 if (!hashed_password) 2563 if (!hashed_password)
2469 { 2564 {
2470 // No password, remove the file. 2565 // No password, remove the file.
2471 LLFile::remove(filepath.c_str()); 2566 LLFile::remove(filepath);
2472 } 2567 }
2473 else 2568 else
2474 { 2569 {
2475 LLFILE* fp = LLFile::fopen(filepath.c_str(), "wb"); /* Flawfinder: ignore */ 2570 LLFILE* fp = LLFile::fopen(filepath, "wb"); /* Flawfinder: ignore */
2476 if (!fp) 2571 if (!fp)
2477 { 2572 {
2478 return; 2573 return;
@@ -2482,7 +2577,7 @@ void save_password_to_disk(const char* hashed_password)
2482 const S32 HASHED_LENGTH = 32; 2577 const S32 HASHED_LENGTH = 32;
2483 U8 buffer[HASHED_LENGTH+1]; 2578 U8 buffer[HASHED_LENGTH+1];
2484 2579
2485 LLString::copy((char*)buffer, hashed_password, HASHED_LENGTH+1); 2580 LLStringUtil::copy((char*)buffer, hashed_password, HASHED_LENGTH+1);
2486 2581
2487 LLXORCipher cipher(gMACAddress, 6); 2582 LLXORCipher cipher(gMACAddress, 6);
2488 cipher.encrypt(buffer, HASHED_LENGTH); 2583 cipher.encrypt(buffer, HASHED_LENGTH);
@@ -2496,9 +2591,9 @@ void save_password_to_disk(const char* hashed_password)
2496 } 2591 }
2497} 2592}
2498 2593
2499BOOL is_hex_string(U8* str, S32 len) 2594bool is_hex_string(U8* str, S32 len)
2500{ 2595{
2501 BOOL rv = TRUE; 2596 bool rv = true;
2502 U8* c = str; 2597 U8* c = str;
2503 while(rv && len--) 2598 while(rv && len--)
2504 { 2599 {
@@ -2523,7 +2618,7 @@ BOOL is_hex_string(U8* str, S32 len)
2523 ++c; 2618 ++c;
2524 break; 2619 break;
2525 default: 2620 default:
2526 rv = FALSE; 2621 rv = false;
2527 break; 2622 break;
2528 } 2623 }
2529 } 2624 }
@@ -2548,7 +2643,7 @@ void first_run_dialog_callback(S32 option, void* userdata)
2548 2643
2549 2644
2550 2645
2551void set_startup_status(const F32 frac, const char *string, const char* msg) 2646void set_startup_status(const F32 frac, const std::string& string, const std::string& msg)
2552{ 2647{
2553 gViewerWindow->setProgressPercent(frac*100); 2648 gViewerWindow->setProgressPercent(frac*100);
2554 gViewerWindow->setProgressString(string); 2649 gViewerWindow->setProgressString(string);
@@ -2591,7 +2686,7 @@ void update_app(BOOL mandatory, const std::string& auth_msg)
2591 { 2686 {
2592 msg = "(" + auth_msg + ") \n"; 2687 msg = "(" + auth_msg + ") \n";
2593 } 2688 }
2594 LLStringBase<char>::format_map_t args; 2689 LLStringUtil::format_map_t args;
2595 args["[MESSAGE]"] = msg; 2690 args["[MESSAGE]"] = msg;
2596 2691
2597 // represent a bool as a null/non-null pointer 2692 // represent a bool as a null/non-null pointer
@@ -2643,7 +2738,7 @@ void update_app(BOOL mandatory, const std::string& auth_msg)
2643void update_dialog_callback(S32 option, void *userdata) 2738void update_dialog_callback(S32 option, void *userdata)
2644{ 2739{
2645 std::string update_exe_path; 2740 std::string update_exe_path;
2646 BOOL mandatory = userdata != NULL; 2741 bool mandatory = userdata != NULL;
2647 2742
2648#if !LL_RELEASE_FOR_DOWNLOAD 2743#if !LL_RELEASE_FOR_DOWNLOAD
2649 if (option == 2) 2744 if (option == 2)
@@ -2701,7 +2796,7 @@ void update_dialog_callback(S32 option, void *userdata)
2701 updater_source += gDirUtilp->getDirDelimiter(); 2796 updater_source += gDirUtilp->getDirDelimiter();
2702 updater_source += "updater.exe"; 2797 updater_source += "updater.exe";
2703 2798
2704 LL_DEBUGS("AppInit") << "Calling CopyFile source: " << updater_source.c_str() 2799 LL_DEBUGS("AppInit") << "Calling CopyFile source: " << updater_source
2705 << " dest: " << update_exe_path 2800 << " dest: " << update_exe_path
2706 << LL_ENDL; 2801 << LL_ENDL;
2707 2802
@@ -2725,9 +2820,9 @@ void update_dialog_callback(S32 option, void *userdata)
2725 if (gHideLinks) 2820 if (gHideLinks)
2726 { 2821 {
2727 // Figure out the program name. 2822 // Figure out the program name.
2728 const char* data_dir = gDirUtilp->getAppRODataDir().c_str(); 2823 const std::string& data_dir = gDirUtilp->getAppRODataDir();
2729 // Roll back from the end, stopping at the first '\' 2824 // Roll back from the end, stopping at the first '\'
2730 const char* program_name = data_dir + strlen(data_dir); /* Flawfinder: ignore */ 2825 const char* program_name = data_dir.c_str() + data_dir.size(); /* Flawfinder: ignore */
2731 while ( (data_dir != --program_name) && 2826 while ( (data_dir != --program_name) &&
2732 *(program_name) != '\\'); 2827 *(program_name) != '\\');
2733 2828
@@ -2765,7 +2860,7 @@ void update_dialog_callback(S32 option, void *userdata)
2765 2860
2766 update_exe_path = "'"; 2861 update_exe_path = "'";
2767 update_exe_path += gDirUtilp->getAppRODataDir(); 2862 update_exe_path += gDirUtilp->getAppRODataDir();
2768 update_exe_path += "/AutoUpdater.app/Contents/MacOS/AutoUpdater' -url \""; 2863 update_exe_path += "/mac-updater.app/Contents/MacOS/mac-updater' -url \"";
2769 update_exe_path += update_url.asString(); 2864 update_exe_path += update_url.asString();
2770 update_exe_path += "\" -name \""; 2865 update_exe_path += "\" -name \"";
2771 update_exe_path += LLAppViewer::instance()->getSecondLifeTitle(); 2866 update_exe_path += LLAppViewer::instance()->getSecondLifeTitle();
@@ -2779,7 +2874,7 @@ void update_dialog_callback(S32 option, void *userdata)
2779#elif LL_LINUX 2874#elif LL_LINUX
2780 OSMessageBox("Automatic updating is not yet implemented for Linux.\n" 2875 OSMessageBox("Automatic updating is not yet implemented for Linux.\n"
2781 "Please download the latest version from www.secondlife.com.", 2876 "Please download the latest version from www.secondlife.com.",
2782 NULL, OSMB_OK); 2877 LLStringUtil::null, OSMB_OK);
2783#endif 2878#endif
2784 LLAppViewer::instance()->forceQuit(); 2879 LLAppViewer::instance()->forceQuit();
2785} 2880}
@@ -3341,13 +3436,13 @@ void init_stat_view()
3341 stat_barp->mDisplayBar = FALSE; 3436 stat_barp->mDisplayBar = FALSE;
3342 stat_barp->mDisplayMean = FALSE; 3437 stat_barp->mDisplayMean = FALSE;
3343 3438
3344 stat_barp = sim_statviewp->addStat("Script Perf", &(LLViewerStats::getInstance()->mSimLSLIPS)); 3439 stat_barp = sim_statviewp->addStat("Script Events", &(LLViewerStats::getInstance()->mSimScriptEPS));
3345 stat_barp->setUnitLabel(" ips"); 3440 stat_barp->setUnitLabel(" eps");
3346 stat_barp->mPrecision = 0; 3441 stat_barp->mPrecision = 0;
3347 stat_barp->mMinBar = 0.f; 3442 stat_barp->mMinBar = 0.f;
3348 stat_barp->mMaxBar = 100000.f; 3443 stat_barp->mMaxBar = 20000.f;
3349 stat_barp->mTickSpacing = 25000.f; 3444 stat_barp->mTickSpacing = 2500.f;
3350 stat_barp->mLabelSpacing = 50000.f; 3445 stat_barp->mLabelSpacing = 5000.f;
3351 stat_barp->mPerSec = FALSE; 3446 stat_barp->mPerSec = FALSE;
3352 stat_barp->mDisplayBar = FALSE; 3447 stat_barp->mDisplayBar = FALSE;
3353 stat_barp->mDisplayMean = FALSE; 3448 stat_barp->mDisplayMean = FALSE;
@@ -3536,61 +3631,52 @@ void asset_callback_nothing(LLVFS*, const LLUUID&, LLAssetType::EType, void*, S3
3536} 3631}
3537 3632
3538// *HACK: Must match name in Library or agent inventory 3633// *HACK: Must match name in Library or agent inventory
3539const char* COMMON_GESTURES_FOLDER = "Common Gestures"; 3634const std::string COMMON_GESTURES_FOLDER = "Common Gestures";
3540const char* MALE_GESTURES_FOLDER = "Male Gestures"; 3635const std::string MALE_GESTURES_FOLDER = "Male Gestures";
3541const char* FEMALE_GESTURES_FOLDER = "Female Gestures"; 3636const std::string FEMALE_GESTURES_FOLDER = "Female Gestures";
3542const char* MALE_OUTFIT_FOLDER = "Male Shape & Outfit"; 3637const std::string MALE_OUTFIT_FOLDER = "Male Shape & Outfit";
3543const char* FEMALE_OUTFIT_FOLDER = "Female Shape & Outfit"; 3638const std::string FEMALE_OUTFIT_FOLDER = "Female Shape & Outfit";
3544const S32 OPT_USE_INITIAL_OUTFIT = -2;
3545const S32 OPT_CLOSED_WINDOW = -1; 3639const S32 OPT_CLOSED_WINDOW = -1;
3546const S32 OPT_MALE = 0; 3640const S32 OPT_MALE = 0;
3547const S32 OPT_FEMALE = 1; 3641const S32 OPT_FEMALE = 1;
3548 3642
3549void callback_choose_gender(S32 option, void* userdata) 3643void callback_choose_gender(S32 option, void* userdata)
3550{ 3644{
3551 S32 gender = OPT_FEMALE; 3645 switch(option)
3552 const char* outfit = FEMALE_OUTFIT_FOLDER;
3553 const char* gestures = FEMALE_GESTURES_FOLDER;
3554 const char* common_gestures = COMMON_GESTURES_FOLDER;
3555 if (!gInitialOutfit.empty())
3556 { 3646 {
3557 outfit = gInitialOutfit.c_str(); 3647 case OPT_MALE:
3558 if (gInitialOutfitGender == "male") 3648 LLStartUp::loadInitialOutfit( MALE_OUTFIT_FOLDER, "male" );
3559 { 3649 break;
3560 gender = OPT_MALE; 3650
3561 gestures = MALE_GESTURES_FOLDER; 3651 case OPT_FEMALE:
3562 } 3652 case OPT_CLOSED_WINDOW:
3563 else 3653 default:
3564 { 3654 LLStartUp::loadInitialOutfit( FEMALE_OUTFIT_FOLDER, "female" );
3565 gender = OPT_FEMALE; 3655 break;
3566 gestures = FEMALE_GESTURES_FOLDER; 3656 }
3567 } 3657}
3658
3659void LLStartUp::loadInitialOutfit( const std::string& outfit_folder_name,
3660 const std::string& gender_name )
3661{
3662 S32 gender = 0;
3663 std::string gestures;
3664 if (gender_name == "male")
3665 {
3666 gender = OPT_MALE;
3667 gestures = MALE_GESTURES_FOLDER;
3568 } 3668 }
3569 else 3669 else
3570 { 3670 {
3571 switch(option) 3671 gender = OPT_FEMALE;
3572 { 3672 gestures = FEMALE_GESTURES_FOLDER;
3573 case OPT_MALE:
3574 gender = OPT_MALE;
3575 outfit = MALE_OUTFIT_FOLDER;
3576 gestures = MALE_GESTURES_FOLDER;
3577 break;
3578
3579 case OPT_FEMALE:
3580 case OPT_CLOSED_WINDOW:
3581 default:
3582 gender = OPT_FEMALE;
3583 outfit = FEMALE_OUTFIT_FOLDER;
3584 gestures = FEMALE_GESTURES_FOLDER;
3585 break;
3586 }
3587 } 3673 }
3588 3674
3589 // try to find the outfit - if not there, create some default 3675 // try to find the outfit - if not there, create some default
3590 // wearables. 3676 // wearables.
3591 LLInventoryModel::cat_array_t cat_array; 3677 LLInventoryModel::cat_array_t cat_array;
3592 LLInventoryModel::item_array_t item_array; 3678 LLInventoryModel::item_array_t item_array;
3593 LLNameCategoryCollector has_name(outfit); 3679 LLNameCategoryCollector has_name(outfit_folder_name);
3594 gInventory.collectDescendentsIf(LLUUID::null, 3680 gInventory.collectDescendentsIf(LLUUID::null,
3595 cat_array, 3681 cat_array,
3596 item_array, 3682 item_array,
@@ -3602,36 +3688,16 @@ void callback_choose_gender(S32 option, void* userdata)
3602 } 3688 }
3603 else 3689 else
3604 { 3690 {
3605 wear_outfit_by_name(outfit); 3691 wear_outfit_by_name(outfit_folder_name);
3606 } 3692 }
3607 wear_outfit_by_name(gestures); 3693 wear_outfit_by_name(gestures);
3608 wear_outfit_by_name(common_gestures); 3694 wear_outfit_by_name(COMMON_GESTURES_FOLDER);
3609
3610 typedef std::map<LLUUID, LLMultiGesture*> item_map_t;
3611 item_map_t::iterator gestureIterator;
3612 3695
3613 // Must be here so they aren't invisible if they close the window. 3696 // This is really misnamed -- it means we have started loading
3697 // an outfit/shape that will give the avatar a gender eventually. JC
3614 gAgent.setGenderChosen(TRUE); 3698 gAgent.setGenderChosen(TRUE);
3615} 3699}
3616
3617void dialog_choose_gender_first_start()
3618{
3619 if (!gNoRender
3620 && (!gAgent.isGenderChosen()))
3621 {
3622 if (!gInitialOutfit.empty())
3623 {
3624 gViewerWindow->alertXml("WelcomeNoClothes",
3625 callback_choose_gender, NULL);
3626 }
3627 else
3628 {
3629 gViewerWindow->alertXml("WelcomeChooseSex",
3630 callback_choose_gender, NULL);
3631 3700
3632 }
3633 }
3634}
3635 3701
3636// Loads a bitmap to display during load 3702// Loads a bitmap to display during load
3637// location_id = 0 => last position 3703// location_id = 0 => last position
@@ -3646,7 +3712,7 @@ void init_start_screen(S32 location_id)
3646 3712
3647 LL_DEBUGS("AppInit") << "Loading startup bitmap..." << LL_ENDL; 3713 LL_DEBUGS("AppInit") << "Loading startup bitmap..." << LL_ENDL;
3648 3714
3649 LLString temp_str = gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter(); 3715 std::string temp_str = gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter();
3650 3716
3651 if ((S32)START_LOCATION_ID_LAST == location_id) 3717 if ((S32)START_LOCATION_ID_LAST == location_id)
3652 { 3718 {
@@ -3698,9 +3764,45 @@ void release_start_screen()
3698 3764
3699 3765
3700// static 3766// static
3701void LLStartUp::setStartupState( S32 state ) 3767std::string LLStartUp::startupStateToString(EStartupState state)
3768{
3769#define RTNENUM(E) case E: return #E
3770 switch(state){
3771 RTNENUM( STATE_FIRST );
3772 RTNENUM( STATE_LOGIN_SHOW );
3773 RTNENUM( STATE_LOGIN_WAIT );
3774 RTNENUM( STATE_LOGIN_CLEANUP );
3775 RTNENUM( STATE_UPDATE_CHECK );
3776 RTNENUM( STATE_LOGIN_AUTH_INIT );
3777 RTNENUM( STATE_LOGIN_AUTHENTICATE );
3778 RTNENUM( STATE_LOGIN_NO_DATA_YET );
3779 RTNENUM( STATE_LOGIN_DOWNLOADING );
3780 RTNENUM( STATE_LOGIN_PROCESS_RESPONSE );
3781 RTNENUM( STATE_WORLD_INIT );
3782 RTNENUM( STATE_SEED_GRANTED_WAIT );
3783 RTNENUM( STATE_SEED_CAP_GRANTED );
3784 RTNENUM( STATE_WORLD_WAIT );
3785 RTNENUM( STATE_AGENT_SEND );
3786 RTNENUM( STATE_AGENT_WAIT );
3787 RTNENUM( STATE_INVENTORY_SEND );
3788 RTNENUM( STATE_MISC );
3789 RTNENUM( STATE_PRECACHE );
3790 RTNENUM( STATE_WEARABLES_WAIT );
3791 RTNENUM( STATE_CLEANUP );
3792 RTNENUM( STATE_STARTED );
3793 default:
3794 return llformat("(state #%d)", state);
3795 }
3796#undef RTNENUM
3797}
3798
3799
3800// static
3801void LLStartUp::setStartupState( EStartupState state )
3702{ 3802{
3703 LL_INFOS("AppInit") << "Startup state changing from " << gStartupState << " to " << state << LL_ENDL; 3803 LL_INFOS("AppInit") << "Startup state changing from " <<
3804 startupStateToString(gStartupState) << " to " <<
3805 startupStateToString(state) << LL_ENDL;
3704 gStartupState = state; 3806 gStartupState = state;
3705} 3807}
3706 3808
@@ -3730,6 +3832,19 @@ bool LLStartUp::canGoFullscreen()
3730 return gStartupState >= STATE_WORLD_INIT; 3832 return gStartupState >= STATE_WORLD_INIT;
3731} 3833}
3732 3834
3835// Initialize all plug-ins except the web browser (which was initialized
3836// early, before the login screen). JC
3837void LLStartUp::multimediaInit()
3838{
3839 LL_DEBUGS("AppInit") << "Initializing Multimedia...." << LL_ENDL;
3840 std::string msg = LLTrans::getString("LoginInitializingMultimedia");
3841 set_startup_status(0.50f, msg.c_str(), gAgent.mMOTD.c_str());
3842 display_startup();
3843
3844 LLViewerMedia::initClass();
3845 LLViewerParcelMedia::initClass();
3846}
3847
3733bool LLStartUp::dispatchURL() 3848bool LLStartUp::dispatchURL()
3734{ 3849{
3735 // ok, if we've gotten this far and have a startup URL 3850 // ok, if we've gotten this far and have a startup URL