/** * @file viewer.cpp * @brief A window into the virtual world. * * Copyright (c) 2000-2007, Linden Research, Inc. * * 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. */ #include "llviewerprecompiledheaders.h" #include "llparcel.h" #include "llviewerparcelmgr.h" // System library headers #include #include #include #include #include #if LL_WINDOWS # include #else # include # include #endif #include #include #include #include #include #include #include "curl/curl.h" #if LL_WINDOWS #include //_O_APPEND #include //_open_osfhandle() #include // for AddERExcludedApplicationA() #include // _spawnl() #include // For TCHAR support //#define LL_USE_SMARTHEAP 0 #if LL_WINDOWS && LL_RELEASE_FOR_DOWNLOAD && LL_USE_SMARTHEAP #include "smrtheap/smrtheap.h" #endif // LL_WINDOWS && LL_RELEASE_FOR_DOWNLOAD && LL_USE_SMARTHEAP #elif LL_DARWIN || LL_LINUX # include // # include // mkdir() # include # include // inet_ntoa() #if LL_LINUX # include // RTLD_LAZY # include // backtrace - glibc only #define LL_ELFBIN 1 # if LL_ELFBIN # include // for symbol demangling # include "ELFIO.h" // for better backtraces # endif // LL_ELFBIN #endif #if LL_DARWIN #include // Apple sucks! AssertMacros.h defines these COMMONLY used names. #ifdef check #undef check #endif #ifdef verify #undef verify #endif // verify #ifdef require #undef require #endif #endif #endif // !LL_WINDOWS // Support for sending crash reports from the viewer? //#define LL_SEND_CRASH_REPORTS 0 #include "viewer.h" // // Linden library headers // #include "llcommon.h" #include "llapr.h" #include "audioengine.h" #include "llcachename.h" #include "llviewercontrol.h" #include "llcriticaldamp.h" #include "lldir.h" #include "lleconomy.h" #include "llflexibleobject.h" #include "llfasttimer.h" #include "llfocusmgr.h" #include "llgroupmgr.h" #include "lllfsthread.h" #include "llmd5.h" #include "llsecondlifeurls.h" #include "llversion.h" #include "llvfile.h" #include "llvfs.h" #include "llwindow.h" // for shell_open #include "llworkerthread.h" #include "llvfsthread.h" #include "llxfermanager.h" #include "message.h" #include "text_out.h" #include "llvoavatar.h" // // Viewer headers // #include "llasynchostbyname.h" #include "llagent.h" #include "llagentpilot.h" #include "llbutton.h" // For constants #include "llcallbacklist.h" #include "llchatbar.h" #include "llcombobox.h" // For constants #include "llconsole.h" #include "llcontainerview.h" #include "lldebugview.h" #include "lldrawpoolbump.h" #include "lldrawpoolterrain.h" #include "lleventnotifier.h" #include "llfasttimerview.h" #include "llfeaturemanager.h" #include "llfirstuse.h" #include "llfloatertools.h" #include "llfloaterworldmap.h" #include "llfloaterhtmlhelp.h" #include "llfloatersaveavatar.h" #include "llfloatersnapshot.h" #include "llfolderview.h" #include "llframestats.h" #include "llgesturemgr.h" #include "llhoverview.h" #include "llhudeffecttrail.h" #include "llhudmanager.h" #include "llhttpclient.h" #include "llimview.h" #include "llinventorymodel.h" #include "llinventoryview.h" #include "llkeyboard.h" #include "llkeyframemotion.h" #include "llpanellogin.h" #include "llmutelist.h" #include "llmenugl.h" #include "llnamelistctrl.h" #include "llnamebox.h" #include "llnameeditor.h" #include "llpumpio.h" #include "llnotify.h" #include "llselectmgr.h" #include "llsky.h" #include "llstartup.h" #include "llstatusbar.h" #include "llsurface.h" #include "lltexlayer.h" #include "lltoolbar.h" #include "lltoolmgr.h" #include "lltracker.h" #include "llurlwhitelist.h" #include "llviewerbuild.h" #include "llviewercamera.h" #include "llviewerimagelist.h" #include "llviewerkeyboard.h" #include "llviewermenu.h" #include "llviewermessage.h" #include "llviewernetwork.h" #include "llviewerobjectlist.h" #include "llviewerparcelmgr.h" #include "llviewerregion.h" #include "llviewerstats.h" #include "llviewerthrottle.h" #include "llvieweruictrlfactory.h" #include "llviewerwindow.h" #include "llvlmanager.h" #include "llvoavatar.h" #include "llvograss.h" #include "llvotree.h" #include "llvotreenew.h" #include "llvovolume.h" // To set a static member. #include "llvowater.h" #include "llvolume.h" #include "llvolumemgr.h" #include "llvolumemessage.h" #include "llweb.h" #include "llworld.h" #include "llworldmap.h" #include "llworldmapview.h" #include "pipeline.h" #include "llface.h" #include "audiosettings.h" #include "res/resource.h" #if LL_WINDOWS #include "llwindebug.h" #include "lldxhardware.h" #include "llwindowwin32.h" #endif // LL_WINDOWS #if LL_QUICKTIME_ENABLED #if LL_DARWIN #include #else // quicktime specific includes #include "MacTypes.h" #include "QTML.h" #include "Movies.h" #include "FixMath.h" #endif #endif #include "llmediaengine.h" #include "llmozlib.h" extern LLErrorBuffer gErrorBuffer; // Support for crash handling. void errorCallback(const std::string &error_string); S32 gCrashBehavior = CRASH_BEHAVIOR_ASK; void (*gCrashCallback)(void) = NULL; BOOL gReportedCrash = FALSE; bool gVerifySSLCert = true; BOOL gHandleKeysAsync = FALSE; // Use DirectX 9 to probe for hardware BOOL gProbeHardware = TRUE; std::string gSerialNumber; // // Application constants // S32 gStartupState = STATE_FIRST; BOOL gHaveSavedSnapshot = FALSE; S32 gYieldMS = 0; BOOL gYieldTime = FALSE; const U32 COLLISION_LIST_DEPTH = 300; // only looks at the first so many collisionable objects const S32 MAX_CONSOLE_LINES = 500; const S32 NUM_SESSIONS_BEFORE_SHOW_PROFILE = 5; const F32 DEFAULT_AFK_TIMEOUT = 5.f * 60.f; // time with no input before user flagged as Away From Keyboard const char *VFS_DATA_FILE_BASE = "data.db2.x."; const char *VFS_INDEX_FILE_BASE = "index.db2.x."; const U32 VFS_SIZE_MAP[4] = {52428800, 209715200, 524288000, 1048576000}; const F32 MAX_USER_FOG_RATIO = 4.f; const F32 MIN_USER_FOG_RATIO = 0.5f; F32 gSimLastTime; F32 gSimFrames; const S32 MAX_USER_COMPOSITE_LIMIT = 100; const S32 MIN_USER_COMPOSITE_LIMIT = 0; //#define RENDER_CLOUD_DENSITY // uncomment to look at cloud density ///////////////////////////////////////////////////////////////////////////////// // Globals ///////////////////////////////////////////////////////////////////////////////// // // Core Application globals // LLString gSecondLife; LLString gWindowTitle; LLString gWindowName("Second Life"); LLString gDisabledMessage; BOOL gHideLinks = FALSE; // This is whether or not we are connect to a production grid. BOOL gInProductionGrid = FALSE; //#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 EUserServerDomain UserServerDefaultChoice = USERSERVER_AGNI; #else static EUserServerDomain UserServerDefaultChoice = USERSERVER_ADITI; #endif #else // Default userserver for development builds is dmz static EUserServerDomain UserServerDefaultChoice = USERSERVER_DMZ; #endif #ifdef TOGGLE_HACKED_GODLIKE_VIEWER BOOL gHackGodmode = FALSE; #endif LLUUID gTemplateToken; // Only used if not empty. Otherwise uses value from table above. static std::string gLoginURI; static std::string gHelperURI; LLAgent gAgent; LLPipeline gPipeline; // Set true when the viewer has been disconnected from the server, for example, // by the user being kicked. BOOL gDoDisconnect = FALSE; BOOL gDisconnected = FALSE; // Tells us to clean up the cache directory in the case of network corruption BOOL gPurgeOnExit = FALSE; // Allow multiple viewers in ReleaseForDownload #if LL_RELEASE_FOR_DOWNLOAD BOOL gMultipleViewersOK = FALSE; #else BOOL gMultipleViewersOK = TRUE; #endif LLString gArgs; // Setting this true will cause the app to exit cleanly at the end of the frame. BOOL gQuit = FALSE; // Set when user has indicated desire to quit, but may have modified documents open BOOL gQuitRequested = FALSE; LLString gLaunchFileOnQuit; BOOL gDoneLogout = FALSE; BOOL gInitializationComplete = FALSE; // used in windows handlers to determine if OK to call idle() BOOL gAutoLogin = FALSE; LLString gOldSettingsFileName; BOOL gPrintMessagesThisFrame = FALSE; const char* DEFAULT_SETTINGS_FILE = "settings.xml"; const char* LEGACY_DEFAULT_SETTINGS_FILE = "settings.ini"; BOOL gRenderLightGlows = FALSE; // off by default for speed BOOL gUseWireframe = FALSE; BOOL gRunLocal = FALSE; LLUUID gViewerDigest; // MD5 digest of the viewer's executable file. S32 gNumSessions = 0; BOOL gAllowAFK = TRUE; F32 gAFKTimeout = DEFAULT_AFK_TIMEOUT; F32 gMouseSensitivity = 3.f; BOOL gInvertMouse = FALSE; BOOL gLogoutRequestSent = FALSE; LLTimer gLogoutTimer; BOOL gShowObjectUpdates = FALSE; const F32 LOGOUT_REQUEST_TIME = 6.f; // this will be cut short by the LogoutReply msg. F32 gLogoutMaxTime = LOGOUT_REQUEST_TIME; // Map scale in pixels per region F32 gMapScale = 128.f; F32 gMiniMapScale = 128.f; // User interface/rendering globals extern LLPointer gStartImageGL; extern BOOL gDebugWindowProc; extern BOOL gAvatarBacklight; // Sky object, globals LLSky gSky; // HUD display lines in lower right BOOL gDisplayWindInfo = FALSE; BOOL gDisplayCameraPos = FALSE; BOOL gDisplayNearestWater = FALSE; BOOL gDoNearestWaterSearch = FALSE; BOOL gDisplayFOV = FALSE; // used to restore texture state after a mode switch LLFrameTimer gRestoreGLTimer; BOOL gRestoreGL = FALSE; LLGlobalEconomy *gGlobalEconomy = NULL; // VFS globals - see viewer.h LLVFS *gStaticVFS = NULL; // Debugging FILE *gDebugFile = NULL; // File pointer used by the function which writes debug data. BOOL gRandomizeFramerate = FALSE; BOOL gPeriodicSlowFrame = FALSE; //LLVector3 gCameraVelocitySmoothed; // // Timing/Performance/statistics globals // // Frame timing U64 gFrameTime = 0; F32 gFrameTimeSeconds = 0.f; F32 gFrameIntervalSeconds = 0.f; U32 gFrameCount = 0; U64 gStartTime = 0; // gStartTime is "private", used only to calculate gFrameTimeSeconds U64 gSpaceTime = 0; // gSpaceTime is the time, according to the spaceserver. // Timing Globals LLTimer gRenderStartTime; F32 gQuitAfterSeconds = 0.f; BOOL gRotateRight = FALSE; // Is the Pacific time zone (aka server time zone) // current in daylight savings time? BOOL gPacificDaylightTime = FALSE; // // Simulator/SpaceServer configuration information // U32 gSecondsPerDay = 0; U32 gSecondsPerYear = 0; // // Region/Object globals // LLVector3 gWindVec(3.0, 3.0, 0.0); LLVector3 gRelativeWindVec(0.0, 0.0, 0.0); // // Globals for controls... // BOOL gVelocityInterpolate = TRUE; // (These are written once/frame with the data from gSavedSettings) BOOL gPingInterpolate = TRUE; //static LLURLSimString LLURLSimString::sInstance; // // System info // LLMemoryInfo gSysMemory; LLOSInfo gSysOS; // file globals static const char USAGE[] = "\n" "usage:\tviewer [options]\n" "options:\n" " -login log in as a user\n" " -loginuri login server and CGI script to use\n" " -helperuri helper web CGI prefix to use\n" " -settings specify the filename of a\n" " configuration file\n" " default is settings.xml\n" " -setdefault specify the value of a particular\n" " configuration variable which can be\n" " overridden by settings.xml\n" " -set specify the value of a particular\n" " configuration variable that\n" " overrides all other settings\n" " -user specify userserver in dotted quad\n" #if !LL_RELEASE_FOR_DOWNLOAD " -sim specify the simulator ip address\n" " -local run without simulator\n" " -debugst debug mask |= 1< 32 bit bitmask for error type mask\n" " -logcontrol specify admin logging control\n" "