Newer
Older
Steven Bennetts
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* @file llappviewer.cpp
* @brief The LLAppViewer class definitions
*
* $LicenseInfo:firstyear=2007&license=viewergpl$
*
* Copyright (c) 2007, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlife.com/developers/opensource/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at http://secondlife.com/developers/opensource/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llappviewer.h"
#include "llversionviewer.h"
#include "llfeaturemanager.h"
#include "llvieweruictrlfactory.h"
#include "llalertdialog.h"
#include "llerrorcontrol.h"
#include "llviewerimagelist.h"
#include "llgroupmgr.h"
#include "llagent.h"
#include "llwindow.h"
#include "llviewerstats.h"
#include "llmd5.h"
#include "llpumpio.h"
#include "llfloateractivespeakers.h"
#include "llimpanel.h"
Steven Bennetts
committed
#include "llstartup.h"
#include "llfocusmgr.h"
#include "llviewerjoystick.h"
Steven Bennetts
committed
#include "llcurl.h"
#include "llfloatersnapshot.h"
#include "llviewerwindow.h"
#include "llviewerdisplay.h"
#include "llviewermessage.h"
#include "llviewerobjectlist.h"
#include "llworldmap.h"
#include "llmutelist.h"
#include "llurldispatcher.h"
#include "llfirstuse.h"
Steven Bennetts
committed
#include "llweb.h"
#include "llsecondlifeurls.h"
#include <boost/bind.hpp>
Steven Bennetts
committed
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#if LL_WINDOWS
#include "llwindebug.h"
#endif
#if LL_WINDOWS
# include <share.h> // For _SH_DENYWR in initMarkerFile
#else
# include <sys/file.h> // For initMarkerFile support
#endif
#include "llnotify.h"
#include "llviewerkeyboard.h"
#include "lllfsthread.h"
#include "llworkerthread.h"
#include "lltexturecache.h"
#include "lltexturefetch.h"
#include "llimageworker.h"
// The files below handle dependencies from cleanup.
#include "llkeyframemotion.h"
#include "llworldmap.h"
#include "llhudmanager.h"
#include "lltoolmgr.h"
#include "llassetstorage.h"
#include "llpolymesh.h"
#include "lleconomy.h"
#include "llcachename.h"
#include "audioengine.h"
#include "llviewermenu.h"
#include "llselectmgr.h"
#include "lltracker.h"
#include "llviewerparcelmgr.h"
#include "llworldmapview.h"
#include "llpostprocess.h"
#include "llwlparammanager.h"
#include "llwaterparammanager.h"
Steven Bennetts
committed
#include "lldebugview.h"
#include "llconsole.h"
#include "llcontainerview.h"
Josh Bell
committed
#include "llfloaterstats.h"
Steven Bennetts
committed
#include "llhoverview.h"
Kyle Machulis
committed
#include "llsdserialize.h"
Steven Bennetts
committed
#include "llworld.h"
#include "llhudeffecttrail.h"
#include "llvectorperfoptions.h"
#include "llurlsimstring.h"
// Included so that constants/settings might be initialized
// in save_settings_to_globals()
#include "llbutton.h"
#include "llcombobox.h"
#include "llstatusbar.h"
#include "llsurface.h"
#include "llvosky.h"
#include "llvotree.h"
#include "llvoavatar.h"
#include "llfolderview.h"
#include "lltoolbar.h"
#include "llframestats.h"
#include "llagentpilot.h"
#include "llsrv.h"
#include "llvovolume.h"
#include "llflexibleobject.h"
#include "llvosurfacepatch.h"
Steven Bennetts
committed
// includes for idle() idleShutdown()
#include "llviewercontrol.h"
#include "lleventnotifier.h"
#include "llcallbacklist.h"
#include "pipeline.h"
#include "llgesturemgr.h"
#include "llsky.h"
#include "llvlmanager.h"
#include "llviewercamera.h"
#include "lldrawpoolbump.h"
#include "llvieweraudio.h"
#include "llimview.h"
#include "llviewerthrottle.h"
//
#include "llinventoryview.h"
#include "llcommandlineparser.h"
Steven Bennetts
committed
// *FIX: These extern globals should be cleaned up.
// The globals either represent state/config/resource-storage of either
// this app, or another 'component' of the viewer. App globals should be
// moved into the app class, where as the other globals should be
// moved out of here.
// If a global symbol reference seems valid, it will be included
// via header files above.
//----------------------------------------------------------------------------
// llviewernetwork.h
#include "llviewernetwork.h"
////// Windows-specific includes to the bottom - nasty defines in these pollute the preprocessor
//
#if LL_WINDOWS && LL_LCD_COMPILE
#include "lllcd.h"
#endif
Steven Bennetts
committed
//----------------------------------------------------------------------------
// viewer.cpp - these are only used in viewer, should be easily moved.
extern void disable_win_error_reporting();
//#define APPLE_PREVIEW // Define this if you're doing a preview build on the Mac
#if LL_RELEASE_FOR_DOWNLOAD
// Default userserver for production builds is agni
#ifndef APPLE_PREVIEW
static EGridInfo GridDefaultChoice = GRID_INFO_AGNI;
#else
static EGridInfo GridDefaultChoice = GRID_INFO_ADITI;
#endif
#else
Josh Bell
committed
// Default userserver for development builds is none
static EGridInfo GridDefaultChoice = GRID_INFO_NONE;
Steven Bennetts
committed
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#endif
#if LL_WINDOWS
extern void create_console();
#endif
#if LL_DARWIN
#include <Carbon/Carbon.h>
extern void init_apple_menu(const char* product);
extern OSErr AEGURLHandler(const AppleEvent *messagein, AppleEvent *reply, long refIn);
extern OSErr AEQuitHandler(const AppleEvent *messagein, AppleEvent *reply, long refIn);
extern OSStatus simpleDialogHandler(EventHandlerCallRef handler, EventRef event, void *userdata);
extern OSStatus DisplayReleaseNotes(void);
#include <boost/tokenizer.hpp>
#endif // LL_DARWIN
extern BOOL gRandomizeFramerate;
extern BOOL gPeriodicSlowFrame;
////////////////////////////////////////////////////////////
// All from the last globals push...
BOOL gHandleKeysAsync = FALSE;
const F32 DEFAULT_AFK_TIMEOUT = 5.f * 60.f; // time with no input before user flagged as Away From Keyboard
F32 gSimLastTime; // Used in LLAppViewer::init and send_stats()
F32 gSimFrames;
LLString gDisabledMessage; // Set in LLAppViewer::initConfiguration used in idle_startup
BOOL gHideLinks = FALSE; // Set in LLAppViewer::initConfiguration, used externally
BOOL gAllowIdleAFK = TRUE;
BOOL gShowObjectUpdates = FALSE;
Steven Bennetts
committed
const char* DEFAULT_SETTINGS_FILE = "settings.xml";
BOOL gAcceptTOS = FALSE;
BOOL gAcceptCriticalMessage = FALSE;
eLastExecEvent gLastExecEvent = LAST_EXEC_NORMAL;
Steven Bennetts
committed
Kyle Machulis
committed
LLSD gDebugInfo;
Steven Bennetts
committed
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
U32 gFrameCount = 0;
U32 gForegroundFrameCount = 0; // number of frames that app window was in foreground
LLPumpIO* gServicePump = NULL;
BOOL gPacificDaylightTime = FALSE;
U64 gFrameTime = 0;
F32 gFrameTimeSeconds = 0.f;
F32 gFrameIntervalSeconds = 0.f;
F32 gFPSClamped = 10.f; // Pretend we start at target rate.
F32 gFrameDTClamped = 0.f; // Time between adjacent checks to network for packets
U64 gStartTime = 0; // gStartTime is "private", used only to calculate gFrameTimeSeconds
LLTimer gRenderStartTime;
LLFrameTimer gForegroundTime;
LLTimer gLogoutTimer;
static const F32 LOGOUT_REQUEST_TIME = 6.f; // this will be cut short by the LogoutReply msg.
F32 gLogoutMaxTime = LOGOUT_REQUEST_TIME;
LLUUID gInventoryLibraryOwner;
LLUUID gInventoryLibraryRoot;
BOOL gDisconnected = FALSE;
// Map scale in pixels per region
F32 gMapScale = 128.f;
F32 gMiniMapScale = 128.f;
// used to restore texture state after a mode switch
LLFrameTimer gRestoreGLTimer;
BOOL gRestoreGL = FALSE;
BOOL gUseWireframe = FALSE;
// VFS globals - see llappviewer.h
LLVFS* gStaticVFS = NULL;
LLMemoryInfo gSysMemory;
LLString gLastVersionChannel;
LLVector3 gWindVec(3.0, 3.0, 0.0);
LLVector3 gRelativeWindVec(0.0, 0.0, 0.0);
U32 gPacketsIn = 0;
BOOL gPrintMessagesThisFrame = FALSE;
BOOL gRandomizeFramerate = FALSE;
BOOL gPeriodicSlowFrame = FALSE;
BOOL gLLErrorActivated = FALSE;
Steven Bennetts
committed
////////////////////////////////////////////////////////////
// Internal globals... that should be removed.
static LLString gArgs;
const char* MARKER_FILE_NAME = "SecondLife.exec_marker";
const char* ERROR_MARKER_FILE_NAME = "SecondLife.error_marker";
const char* LLERROR_MARKER_FILE_NAME = "SecondLife.llerror_marker";
Steven Bennetts
committed
static BOOL gDoDisconnect = FALSE;
static LLString gLaunchFileOnQuit;
//----------------------------------------------------------------------------
// File scope definitons
const char *VFS_DATA_FILE_BASE = "data.db2.x.";
const char *VFS_INDEX_FILE_BASE = "index.db2.x.";
static LLString gSecondLife;
static LLString gWindowTitle;
#ifdef LL_WINDOWS
static char sWindowClass[] = "Second Life";
#endif
Steven Bennetts
committed
std::vector<std::string> gLoginURIs;
static std::string gHelperURI;
void idle_afk_check()
{
// check idle timers
if (gAllowIdleAFK && (gAwayTriggerTimer.getElapsedTimeF32() > gSavedSettings.getF32("AFKTimeout")))
Steven Bennetts
committed
{
gAgent.setAFK();
}
}
// A callback set in LLAppViewer::init()
static void ui_audio_callback(const LLUUID& uuid)
{
if (gAudiop)
{
F32 volume = gSavedSettings.getBOOL("MuteUI") ? 0.f : gSavedSettings.getF32("AudioLevelUI");
Steven Bennetts
committed
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
gAudiop->triggerSound(uuid, gAgent.getID(), volume);
}
}
void request_initial_instant_messages()
{
static BOOL requested = FALSE;
if (!requested
&& gMuteListp
&& gMuteListp->isLoaded()
&& gAgent.getAvatarObject())
{
// Auto-accepted inventory items may require the avatar object
// to build a correct name. Likewise, inventory offers from
// muted avatars require the mute list to properly mute.
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_RetrieveInstantMessages);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
gAgent.sendReliableMessage();
requested = TRUE;
}
}
// Use these strictly for things that are constructed at startup,
// or for things that are performance critical. JC
static void settings_to_globals()
Steven Bennetts
committed
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
{
LLBUTTON_H_PAD = gSavedSettings.getS32("ButtonHPad");
LLBUTTON_V_PAD = gSavedSettings.getS32("ButtonVPad");
BTN_HEIGHT_SMALL = gSavedSettings.getS32("ButtonHeightSmall");
BTN_HEIGHT = gSavedSettings.getS32("ButtonHeight");
MENU_BAR_HEIGHT = gSavedSettings.getS32("MenuBarHeight");
MENU_BAR_WIDTH = gSavedSettings.getS32("MenuBarWidth");
STATUS_BAR_HEIGHT = gSavedSettings.getS32("StatusBarHeight");
LLCOMBOBOX_HEIGHT = BTN_HEIGHT - 2;
LLCOMBOBOX_WIDTH = 128;
LLSurface::setTextureSize(gSavedSettings.getU32("RegionTextureSize"));
LLImageGL::sGlobalUseAnisotropic = gSavedSettings.getBOOL("RenderAnisotropic");
LLVOVolume::sLODFactor = gSavedSettings.getF32("RenderVolumeLODFactor");
LLVOVolume::sDistanceFactor = 1.f-LLVOVolume::sLODFactor * 0.1f;
LLVolumeImplFlexible::sUpdateFactor = gSavedSettings.getF32("RenderFlexTimeFactor");
LLVOTree::sTreeFactor = gSavedSettings.getF32("RenderTreeLODFactor");
LLVOAvatar::sLODFactor = gSavedSettings.getF32("RenderAvatarLODFactor");
LLVOAvatar::sMaxVisible = gSavedSettings.getS32("RenderAvatarMaxVisible");
LLVOAvatar::sVisibleInFirstPerson = gSavedSettings.getBOOL("FirstPersonAvatarVisible");
// clamp auto-open time to some minimum usable value
LLFolderView::sAutoOpenTime = llmax(0.25f, gSavedSettings.getF32("FolderAutoOpenDelay"));
LLToolBar::sInventoryAutoOpenTime = gSavedSettings.getF32("InventoryAutoOpenDelay");
LLSelectMgr::sRectSelectInclusive = gSavedSettings.getBOOL("RectangleSelectInclusive");
LLSelectMgr::sRenderHiddenSelections = gSavedSettings.getBOOL("RenderHiddenSelections");
LLSelectMgr::sRenderLightRadius = gSavedSettings.getBOOL("RenderLightRadius");
gFrameStats.setTrackStats(gSavedSettings.getBOOL("StatsSessionTrackFrameStats"));
gAgentPilot.mNumRuns = gSavedSettings.getS32("StatsNumRuns");
gAgentPilot.mQuitAfterRuns = gSavedSettings.getBOOL("StatsQuitAfterRuns");
gAgent.mHideGroupTitle = gSavedSettings.getBOOL("RenderHideGroupTitle");
gDebugWindowProc = gSavedSettings.getBOOL("DebugWindowProc");
gAllowIdleAFK = gSavedSettings.getBOOL("AllowIdleAFK");
gShowObjectUpdates = gSavedSettings.getBOOL("ShowObjectUpdates");
gMapScale = gSavedSettings.getF32("MapScale");
gMiniMapScale = gSavedSettings.getF32("MiniMapScale");
gHandleKeysAsync = gSavedSettings.getBOOL("AsyncKeyboard");
LLHoverView::sShowHoverTips = gSavedSettings.getBOOL("ShowHoverTips");
Steven Bennetts
committed
static void settings_modify()
{
LLRenderTarget::sUseFBO = gSavedSettings.getBOOL("RenderUseFBO");
LLVOAvatar::sUseImpostors = gSavedSettings.getBOOL("RenderUseImpostors");
LLVOSurfacePatch::sLODFactor = gSavedSettings.getF32("RenderTerrainLODFactor");
LLVOSurfacePatch::sLODFactor *= LLVOSurfacePatch::sLODFactor; //sqaure lod factor to get exponential range of [1,4]
Steven Bennetts
committed
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
#if LL_VECTORIZE
if (gSysCPU.hasAltivec())
{
gSavedSettings.setBOOL("VectorizeEnable", TRUE );
gSavedSettings.setU32("VectorizeProcessor", 0 );
}
else
if (gSysCPU.hasSSE2())
{
gSavedSettings.setBOOL("VectorizeEnable", TRUE );
gSavedSettings.setU32("VectorizeProcessor", 2 );
}
else
if (gSysCPU.hasSSE())
{
gSavedSettings.setBOOL("VectorizeEnable", TRUE );
gSavedSettings.setU32("VectorizeProcessor", 1 );
}
else
{
// Don't bother testing or running if CPU doesn't support it. JC
gSavedSettings.setBOOL("VectorizePerfTest", FALSE );
gSavedSettings.setBOOL("VectorizeEnable", FALSE );
gSavedSettings.setU32("VectorizeProcessor", 0 );
gSavedSettings.setBOOL("VectorizeSkin", FALSE);
}
#else
// This build target doesn't support SSE, don't test/run.
gSavedSettings.setBOOL("VectorizePerfTest", FALSE );
gSavedSettings.setBOOL("VectorizeEnable", FALSE );
gSavedSettings.setU32("VectorizeProcessor", 0 );
gSavedSettings.setBOOL("VectorizeSkin", FALSE);
#endif
// propagate push to talk preference to current status
gSavedSettings.setBOOL("PTTCurrentlyEnabled", gSavedSettings.getBOOL("EnablePushToTalk"));
}
void initGridChoice()
Steven Bennetts
committed
{
LLString gridChoice = gSavedSettings.getString("GridChoice");
if(!gridChoice.empty())
Josh Bell
committed
// Used to show first chunk of each argument passed in the
// window title.
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
{
// find the grid choice from the user setting.
int gridIndex = GRID_INFO_NONE;
for(;gridIndex < GRID_INFO_OTHER; ++gridIndex )
{
if(0 == LLString::compareInsensitive(gGridInfo[gridIndex].mLabel, gridChoice.c_str()))
{
gGridChoice = (EGridInfo)gridIndex;
if(GRID_INFO_LOCAL == gGridChoice)
{
gGridName = LOOPBACK_ADDRESS_STRING;
break;
}
else
{
gGridName = gGridInfo[gGridChoice].mName;
break;
}
}
}
if(GRID_INFO_OTHER == gridIndex)
{
// *FIX:MEP Can and should we validate that this is an IP address?
gGridChoice = (EGridInfo)gridIndex;
gGridName = llformat("%s", gSavedSettings.getString("GridChoice").c_str());
}
}
Steven Bennetts
committed
#if !LL_RELEASE_FOR_DOWNLOAD
if (gGridChoice == GRID_INFO_NONE)
{
// Development version: load last server choice by default (overridden by cmd line args)
S32 server = gSavedSettings.getS32("ServerChoice");
if (server != 0)
gGridChoice = (EGridInfo)llclamp(server, 0, (S32)GRID_INFO_COUNT - 1);
if (server == GRID_INFO_OTHER)
LLString custom_server = gSavedSettings.getString("CustomServer");
if (custom_server.empty())
gGridName = custom_server.c_str();
gSavedSettings.setString("GridChoice", gGridInfo[gGridChoice].mLabel);
}
Steven Bennetts
committed
#endif
if (gGridChoice == GRID_INFO_NONE)
{
gGridChoice = GridDefaultChoice;
gSavedSettings.setString("GridChoice", gGridInfo[gGridChoice].mLabel);
Steven Bennetts
committed
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
}
}
bool send_url_to_other_instance(const std::string& url)
{
#if LL_WINDOWS
wchar_t window_class[256]; /* Flawfinder: ignore */ // Assume max length < 255 chars.
mbstowcs(window_class, sWindowClass, 255);
window_class[255] = 0;
// Use the class instead of the window name.
HWND other_window = FindWindow(window_class, NULL);
if (other_window != NULL)
{
lldebugs << "Found other window with the name '" << gWindowTitle << "'" << llendl;
COPYDATASTRUCT cds;
const S32 SLURL_MESSAGE_TYPE = 0;
cds.dwData = SLURL_MESSAGE_TYPE;
cds.cbData = url.length() + 1;
cds.lpData = (void*)url.c_str();
LRESULT msg_result = SendMessage(other_window, WM_COPYDATA, NULL, (LPARAM)&cds);
lldebugs << "SendMessage(WM_COPYDATA) to other window '"
<< gWindowTitle << "' returned " << msg_result << llendl;
return true;
}
#endif
return false;
}
//----------------------------------------------------------------------------
// LLAppViewer definition
// Static members.
// The single viewer app.
LLAppViewer* LLAppViewer::sInstance = NULL;
LLTextureCache* LLAppViewer::sTextureCache = NULL;
LLWorkerThread* LLAppViewer::sImageDecodeThread = NULL;
LLTextureFetch* LLAppViewer::sTextureFetch = NULL;
LLAppViewer::LLAppViewer() :
mMarkerFile(NULL),
mCrashBehavior(CRASH_BEHAVIOR_ASK),
mReportedCrash(false),
mNumSessions(0),
mPurgeCache(false),
mPurgeOnExit(false),
mSecondInstance(false),
Steven Bennetts
committed
mSavedFinalSnapshot(false),
mQuitRequested(false),
mLogoutRequestSent(false),
mYieldTime(-1)
Steven Bennetts
committed
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
{
if(NULL != sInstance)
{
llerrs << "Oh no! An instance of LLAppViewer already exists! LLAppViewer is sort of like a singleton." << llendl;
}
sInstance = this;
}
LLAppViewer::~LLAppViewer()
{
// If we got to this destructor somehow, the app didn't hang.
removeMarkerFile();
}
bool LLAppViewer::init()
{
// *NOTE:Mani - LLCurl::initClass is not thread safe.
// Called before threads are created.
LLCurl::initClass();
initThreads();
//
// Start of the application
//
// IMPORTANT! Do NOT put anything that will write
// into the log files during normal startup until AFTER
// we run the "program crashed last time" error handler below.
//
// Need to do this initialization before we do anything else, since anything
// that touches files should really go through the lldir API
gDirUtilp->initAppDirs("SecondLife");
initLogging();
//
// OK to write stuff to logs now, we've now crash reported if necessary
//
if (!initConfiguration())
return false;
writeSystemInfo();
// Build a string representing the current version number.
gCurrentVersion = llformat("%s %d.%d.%d.%d",
gSavedSettings.getString("VersionChannelName").c_str(),
LL_VERSION_MAJOR,
LL_VERSION_MINOR,
LL_VERSION_PATCH,
LL_VERSION_BUILD );
Steven Bennetts
committed
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// *FIX: The following code isn't grouped into functions yet.
// Various introspection concerning the libs we're using.
//
llinfos << "J2C Engine is: " << LLImageJ2C::getEngineInfo() << llendl;
Steven Bennetts
committed
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
// Get the single value from the crash settings file, if it exists
std::string crash_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE);
gCrashSettings.loadFromFile(crash_settings_filename.c_str());
/////////////////////////////////////////////////
// OS-specific login dialogs
/////////////////////////////////////////////////
#if LL_WINDOWS
/*
// Display initial login screen, comes up quickly. JC
{
LLSplashScreen::hide();
INT_PTR result = DialogBox(hInstance, L"CONNECTBOX", NULL, login_dialog_func);
if (result < 0)
{
llwarns << "Connect dialog box failed, returned " << result << llendl;
return 1;
}
// success, result contains which button user clicked
llinfos << "Connect dialog box clicked " << result << llendl;
LLSplashScreen::show();
}
*/
#endif
// track number of times that app has run
mNumSessions = gSavedSettings.getS32("NumSessions");
mNumSessions++;
gSavedSettings.setS32("NumSessions", mNumSessions);
gSavedSettings.setString("HelpLastVisitedURL",gSavedSettings.getString("HelpHomeURL"));
if (gSavedSettings.getBOOL("VerboseLogs"))
{
LLError::setPrintLocation(true);
}
// Load art UUID information, don't require these strings to be declared in code.
LLString viewer_art_filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"viewerart.xml");
llinfos << "Loading art table from " << viewer_art_filename << llendl;
gViewerArt.loadFromFileLegacy(viewer_art_filename.c_str(), FALSE);
Steven Bennetts
committed
LLString textures_filename = gDirUtilp->getExpandedFilename(LL_PATH_SKINS, "textures", "textures.xml");
llinfos << "Loading art table from " << textures_filename << llendl;
gViewerArt.loadFromFileLegacy(textures_filename.c_str(), FALSE);
Steven Bennetts
committed
LLString colors_base_filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "colors_base.xml");
llinfos << "Loading base colors from " << colors_base_filename << llendl;
gColors.loadFromFileLegacy(colors_base_filename.c_str(), FALSE, TYPE_COL4U);
Steven Bennetts
committed
// Load overrides from user colors file
LLString user_colors_filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "colors.xml");
llinfos << "Loading user colors from " << user_colors_filename << llendl;
if (gColors.loadFromFileLegacy(user_colors_filename.c_str(), FALSE, TYPE_COL4U) == 0)
Steven Bennetts
committed
{
llinfos << "Cannot load user colors from " << user_colors_filename << llendl;
Steven Bennetts
committed
}
// Widget construction depends on LLUI being initialized
LLUI::initClass(&gSavedSettings,
&gColors,
&gViewerArt,
&gImageList,
ui_audio_callback,
&LLUI::sGLScaleFactor);
LLWeb::initClass(); // do this after LLUI
Steven Bennetts
committed
gUICtrlFactory->setupPaths(); // update paths with correct language set
/////////////////////////////////////////////////
//
// Load settings files
//
//
LLGroupMgr::parseRoleActions("role_actions.xml");
LLAgent::parseTeleportMessages("teleport_strings.xml");
LLViewerJointMesh::updateVectorize();
// load MIME type -> media impl mappings
LLMIMETypes::parseMIMETypes( "mime_types.xml" );
Steven Bennetts
committed
// Copy settings to globals. *TODO: Remove or move to appropriage class initializers
settings_to_globals();
// Setup settings listeners
settings_setup_listeners();
// Modify settings based on system configuration and compile options
settings_modify();
Steven Bennetts
committed
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
// Find partition serial number (Windows) or hardware serial (Mac)
mSerialNumber = generateSerialNumber();
if(false == initHardwareTest())
{
// Early out from user choice.
return false;
}
// Always fetch the Ethernet MAC address, needed both for login
// and password load.
LLUUID::getNodeID(gMACAddress);
// Prepare for out-of-memory situations, during which we will crash on
// purpose and save a dump.
#if LL_WINDOWS && LL_RELEASE_FOR_DOWNLOAD && LL_USE_SMARTHEAP
MemSetErrorHandler(first_mem_error_handler);
#endif // LL_WINDOWS && LL_RELEASE_FOR_DOWNLOAD && LL_USE_SMARTHEAP
gViewerStats = new LLViewerStats();
//
// Initialize the VFS, and gracefully handle initialization errors
//
if (!initCache())
{
std::ostringstream msg;
msg <<
gSecondLife << " is unable to access a file that it needs.\n"
"\n"
"This can be because you somehow have multiple copies running, "
"or your system incorrectly thinks a file is open. "
"If this message persists, restart your computer and try again. "
"If it continues to persist, you may need to completely uninstall " <<
gSecondLife << " and reinstall it.";
OSMessageBox(
msg.str().c_str(),
NULL,
OSMB_OK);
return 1;
}
#if LL_DARWIN
// Display the release notes for the current version
if(!gHideLinks && gCurrentVersion != gLastRunVersion)
{
// Current version and last run version don't match exactly. Display the release notes.
DisplayReleaseNotes();
}
#endif
//
// Initialize the window
//
initWindow();
#if LL_WINDOWS && LL_LCD_COMPILE
// start up an LCD window on a logitech keyboard, if there is one
HINSTANCE hInstance = GetModuleHandle(NULL);
Josh Bell
committed
gLcdScreen = new LLLCD(hInstance);
Steven Bennetts
committed
CreateLCDDebugWindows();
#endif
Kyle Machulis
committed
gGLManager.getGLInfo(gDebugInfo);
Steven Bennetts
committed
llinfos << gGLManager.getGLInfoString() << llendl;
//load key settings
bind_keyboard_functions();
// Load Default bindings
if (!gViewerKeyboard.loadBindings(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"keys.ini").c_str()))
{
llerrs << "Unable to open keys.ini" << llendl;
}
// Load Custom bindings (override defaults)
gViewerKeyboard.loadBindings(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"custom_keys.ini").c_str());
// If we don't have the right GL requirements, exit.
if (!gGLManager.mHasRequirements && !gNoRender)
{
// can't use an alert here since we're existing and
// all hell breaks lose.
Steven Bennetts
committed
OSMessageBox(
LLAlertDialog::getTemplateMessage("UnsupportedGLRequirements").c_str(),
Steven Bennetts
committed
NULL,
OSMB_OK);
return 0;
}
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
// alert the user if they are using unsupported hardware
if(!gSavedSettings.getBOOL("AlertedUnsupportedHardware"))
{
bool unsupported = false;
LLString::format_map_t args;
LLString minSpecs;
// get cpu data from xml
std::stringstream minCPUString(LLAlertDialog::getTemplateMessage("UnsupportedCPUAmount"));
S32 minCPU = 0;
minCPUString >> minCPU;
// get RAM data from XML
std::stringstream minRAMString(LLAlertDialog::getTemplateMessage("UnsupportedRAMAmount"));
U64 minRAM = 0;
minRAMString >> minRAM;
minRAM = minRAM * 1024 * 1024;
if(!gFeatureManagerp->isGPUSupported())
{
minSpecs += LLAlertDialog::getTemplateMessage("UnsupportedGPU");
minSpecs += "\n";
unsupported = true;
}
if(gSysCPU.getMhz() < minCPU)
{
minSpecs += LLAlertDialog::getTemplateMessage("UnsupportedCPU");
minSpecs += "\n";
unsupported = true;
}
if(gSysMemory.getPhysicalMemoryClamped() < minRAM)
{
minSpecs += LLAlertDialog::getTemplateMessage("UnsupportedRAM");
minSpecs += "\n";
unsupported = true;
}
if(unsupported)
{
args["MINSPECS"] = minSpecs;
gViewerWindow->alertXml("UnsupportedHardware", args );
// turn off flag
gSavedSettings.setBOOL("AlertedUnsupportedHardware", TRUE);
}
}
Steven Bennetts
committed
// Save the current version to the prefs file
gSavedSettings.setString("LastRunVersion", gCurrentVersion);
gSimLastTime = gRenderStartTime.getElapsedTimeF32();
gSimFrames = (F32)gFrameCount;
return true;
}
bool LLAppViewer::mainLoop()
{
//-------------------------------------------
// Run main loop until time to quit
//-------------------------------------------
// Create IO Pump to use for HTTP Requests.
gServicePump = new LLPumpIO(gAPRPoolp);
LLHTTPClient::setPump(*gServicePump);
Steven Bennetts
committed
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
// initialize voice stuff here
gLocalSpeakerMgr = new LLLocalSpeakerMgr();
gActiveChannelSpeakerMgr = new LLActiveSpeakerMgr();
LLVoiceChannel::initClass();
LLVoiceClient::init(gServicePump);
LLMemType mt1(LLMemType::MTYPE_MAIN);
LLTimer frameTimer,idleTimer;
LLTimer debugTime;
// Handle messages
while (!LLApp::isExiting())
{
LLFastTimer::reset(); // Should be outside of any timer instances
{
LLFastTimer t(LLFastTimer::FTM_FRAME);
{
LLFastTimer t2(LLFastTimer::FTM_MESSAGES);
#if LL_WINDOWS
if (!LLWinDebug::setupExceptionHandler())
{
llwarns << " Someone took over my exception handler (post messagehandling)!" << llendl;
}
#endif
gViewerWindow->mWindow->gatherInput();
}
Steven Bennetts
committed
// once per second debug info
if (debugTime.getElapsedTimeF32() > 1.f)
{
debugTime.reset();
}
#endif
Steven Bennetts
committed
if (!LLApp::isExiting())
{
// Scan keyboard for movement keys. Command keys and typing
// are handled by windows callbacks. Don't do this until we're
// done initializing. JC
if (gViewerWindow->mWindow->getVisible()
&& gViewerWindow->getActive()
&& !gViewerWindow->mWindow->getMinimized()
&& LLStartUp::getStartupState() == STATE_STARTED
&& !gViewerWindow->getShowProgress()
&& !gFocusMgr.focusLocked())
{
gKeyboard->scanKeyboard();
LLViewerJoystick::scanJoystick();
}
// Update state based on messages, user input, object idle.
{
LLFastTimer t3(LLFastTimer::FTM_IDLE);
idle();
{
LLFastTimer t4(LLFastTimer::FTM_PUMP);
gAres->process();
// this pump is necessary to make the login screen show up
gServicePump->pump();
gServicePump->callback();
}
Steven Bennetts
committed
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
}
if (gDoDisconnect && (LLStartUp::getStartupState() == STATE_STARTED))
{
saveFinalSnapshot();
disconnectViewer();
}
// Render scene.
if (!LLApp::isExiting())
{
display();
LLFloaterSnapshot::update(); // take snapshots
#if LL_WINDOWS && LL_LCD_COMPILE
// update LCD Screen
gLcdScreen->UpdateDisplay();
#endif
}
}
// Sleep and run background threads
{
LLFastTimer t2(LLFastTimer::FTM_SLEEP);
bool run_multiple_threads = gSavedSettings.getBOOL("RunMultipleThreads");
// yield some time to the os based on command line option
Steven Bennetts
committed
{
ms_sleep(mYieldTime);
Steven Bennetts
committed
}
// yield cooperatively when not running as foreground window
if ( gNoRender
|| !gViewerWindow->mWindow->getVisible()
|| !gFocusMgr.getAppHasFocus())
{
// Sleep if we're not rendering, or the window is minimized.
S32 milliseconds_to_sleep = llclamp(gSavedSettings.getS32("BackgroundYieldTime"), 0, 1000);
// don't sleep when BackgroundYieldTime set to 0, since this will still yield to other threads
// of equal priority on Windows
if (milliseconds_to_sleep > 0)
{
ms_sleep(milliseconds_to_sleep);
// also pause worker threads during this wait period
LLAppViewer::getTextureCache()->pause();
LLAppViewer::getImageDecodeThread()->pause();
}
}
if (gRandomizeFramerate)
{