From f73c666f0e405cade458d82e07a4b53c15b9642b Mon Sep 17 00:00:00 2001 From: Shyotl Date: Fri, 25 Mar 2011 17:50:06 -0500 Subject: [PATCH 1/8] Added isAgentAvatarValid() helper function from v2 Nullchecks Flight-state tweaks --- indra/llrender/llglstates.h | 1 + indra/newview/llagent.cpp | 189 +++++++++++++++------------ indra/newview/llagent.h | 3 + indra/newview/llappviewer.cpp | 15 ++- indra/newview/llsurface.cpp | 1 + indra/newview/llviewerobject.cpp | 5 +- indra/newview/llviewerobjectlist.cpp | 3 +- 7 files changed, 119 insertions(+), 98 deletions(-) diff --git a/indra/llrender/llglstates.h b/indra/llrender/llglstates.h index 4a51cac43..92bf79a7e 100644 --- a/indra/llrender/llglstates.h +++ b/indra/llrender/llglstates.h @@ -46,6 +46,7 @@ public: ~LLGLDepthTest(); + void checkState(); GLboolean mPrevDepthEnabled; GLenum mPrevDepthFunc; GLboolean mPrevWriteEnabled; diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index f3dc53305..25debb3b0 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -258,6 +258,13 @@ const F32 LLAgent::TYPING_TIMEOUT_SECS = 5.f; std::map LLAgent::sTeleportErrorMessages; std::map LLAgent::sTeleportProgressMessages; +BOOL isAgentAvatarValid() +{ + return (gAgent.getAvatarObject() && + (gAgent.getAvatarObject()->getRegion() != NULL) && + (!gAgent.getAvatarObject()->isDead())); +} + class LLAgentFriendObserver : public LLFriendObserver { public: @@ -546,8 +553,11 @@ void LLAgent::resetView(BOOL reset_camera, BOOL change_camera) LLSelectMgr::getInstance()->deselectAll(); } - // Hide all popup menus - gMenuHolder->hideMenus(); + if (gMenuHolder != NULL) + { + // Hide all popup menus + gMenuHolder->hideMenus(); + } } static const LLCachedControl freeze_time("FreezeTime",false); @@ -586,6 +596,8 @@ void LLAgent::resetView(BOOL reset_camera, BOOL change_camera) } setFocusOnAvatar(TRUE, ANIMATE); + + mCameraFOVZoomFactor = 0.f; } mHUDTargetZoom = 1.f; @@ -608,7 +620,7 @@ void LLAgent::onAppFocusGained() void LLAgent::ageChat() { - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { // get amount of time since I last chatted F64 elapsed_time = (F64)mAvatarObject->mChatTimer.getElapsedTimeF32(); @@ -625,7 +637,7 @@ void LLAgent::unlockView() { if (getFocusOnAvatar()) { - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { setFocusGlobal( LLVector3d::zero, mAvatarObject->mID ); } @@ -842,7 +854,7 @@ void LLAgent::resetClientTag() //----------------------------------------------------------------------------- void LLAgent::setFlying(BOOL fly) { - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { if(mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_STANDUP) != mAvatarObject->mSignaledAnimations.end()) { @@ -879,13 +891,15 @@ void LLAgent::setFlying(BOOL fly) LLViewerStats::getInstance()->incStat(LLViewerStats::ST_FLY_COUNT); } setControlFlags(AGENT_CONTROL_FLY); - gSavedSettings.setBOOL("FlyBtnState", TRUE); } else { clearControlFlags(AGENT_CONTROL_FLY); - gSavedSettings.setBOOL("FlyBtnState", FALSE); } + + + gSavedSettings.setBOOL("FlyBtnState",fly); + mbFlagsDirty = TRUE; } @@ -1064,6 +1078,7 @@ void LLAgent::sendMessage() if (!mRegionp) { llerrs << "No region for agent yet!" << llendl; + return; } gMessageSystem->sendMessage(mRegionp->getHost()); } @@ -1092,7 +1107,7 @@ void LLAgent::sendReliableMessage() //----------------------------------------------------------------------------- LLVector3 LLAgent::getVelocity() const { - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { return mAvatarObject->getVelocity(); } @@ -1113,7 +1128,7 @@ void LLAgent::setPositionAgent(const LLVector3 &pos_agent) llerrs << "setPositionAgent is not a number" << llendl; } - if (mAvatarObject.notNull() && mAvatarObject->getParent()) + if (isAgentAvatarValid() && mAvatarObject->getParent()) { LLVector3 pos_agent_sitting; LLVector3d pos_agent_d; @@ -1151,7 +1166,7 @@ void LLAgent::slamLookAt(const LLVector3 &look_at) //----------------------------------------------------------------------------- const LLVector3d &LLAgent::getPositionGlobal() const { - if (mAvatarObject.notNull() && !mAvatarObject->mDrawable.isNull()) + if (isAgentAvatarValid() && !mAvatarObject->mDrawable.isNull()) { mPositionGlobal = getPosGlobalFromAgent(mAvatarObject->getRenderPosition()); } @@ -1296,7 +1311,7 @@ LLVector3 LLAgent::getReferenceUpVector() { // this vector is in the coordinate frame of the avatar's parent object, or the world if none LLVector3 up_vector = LLVector3::z_axis; - if (mAvatarObject.notNull() && + if (isAgentAvatarValid() && mAvatarObject->getParent() && mAvatarObject->mDrawable.notNull()) { @@ -1346,7 +1361,7 @@ F32 LLAgent::clampPitchToLimits(F32 angle) F32 angle_from_skyward = acos( mFrameAgent.getAtAxis() * skyward ); - if (mAvatarObject.notNull() && mAvatarObject->mIsSitting) + if (isAgentAvatarValid() && mAvatarObject->mIsSitting) { look_down_limit = 130.f * DEG_TO_RAD; } @@ -2238,10 +2253,9 @@ void LLAgent::clearAFK() // Gods can sometimes get into away state (via gestures) // without setting the appropriate control flag. JC - LLVOAvatar* av = mAvatarObject; if (mControlFlags & AGENT_CONTROL_AWAY - || (av - && (av->mSignaledAnimations.find(ANIM_AGENT_AWAY) != av->mSignaledAnimations.end()))) + || (isAgentAvatarValid() + && (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_AWAY) != mAvatarObject->mSignaledAnimations.end()))) { sendAnimationRequest(ANIM_AGENT_AWAY, ANIM_REQUEST_STOP); clearControlFlags(AGENT_CONTROL_AWAY); @@ -2305,7 +2319,7 @@ BOOL LLAgent::getBusy() const //----------------------------------------------------------------------------- void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::string& behavior_name, const LLQuaternion *target_rotation, void (*finish_callback)(BOOL, void *), void *callback_data, F32 stop_distance, F32 rot_threshold) { - if (!gAgent.getAvatarObject()) + if (!isAgentAvatarValid()) { return; } @@ -2351,7 +2365,10 @@ void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::s if ( distance > 1.f && heightDelta > (sqrtf(mAutoPilotStopDistance) + 1.f)) { setFlying(TRUE); - mAutoPilotFlyOnStop = TRUE; + // Do not force flying for "Sit" behavior to prevent flying after pressing "Stand" + // from an object. See EXT-1655. + if ("Sit" != mAutoPilotBehaviorName) + mAutoPilotFlyOnStop = TRUE; } mAutoPilot = TRUE; @@ -2420,6 +2437,13 @@ void LLAgent::stopAutoPilot(BOOL user_cancel) { resetAxes(mAutoPilotTargetFacing); } + // Restore previous flying state before invoking mAutoPilotFinishedCallback to allow + // callback function to change the flying state (like in near_sit_down_point()). + // If the user cancelled, don't change the fly state + if (!user_cancel) + { + setFlying(mAutoPilotFlyOnStop); + } //NB: auto pilot can terminate for a reason other than reaching the destination if (mAutoPilotFinishedCallback) { @@ -2427,11 +2451,6 @@ void LLAgent::stopAutoPilot(BOOL user_cancel) } mLeaderID = LLUUID::null; - // If the user cancelled, don't change the fly state - if (!user_cancel) - { - setFlying(mAutoPilotFlyOnStop); - } setControlFlags(AGENT_CONTROL_STOP); if (user_cancel && !mAutoPilotBehaviorName.empty()) @@ -2466,10 +2485,7 @@ void LLAgent::autoPilot(F32 *delta_yaw) mAutoPilotTargetGlobal = object->getPositionGlobal(); } - if (mAvatarObject.isNull()) - { - return; - } + if (!isAgentAvatarValid()) return; if (mAvatarObject->mInAir) { @@ -2547,7 +2563,7 @@ void LLAgent::autoPilot(F32 *delta_yaw) // If we're flying, handle autopilot points above or below you. if (getFlying() && xy_distance < AUTOPILOT_HEIGHT_ADJUST_DISTANCE) { - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { F64 current_height = mAvatarObject->getPositionGlobal().mdV[VZ]; F32 delta_z = (F32)(mAutoPilotTargetGlobal.mdV[VZ] - current_height); @@ -2682,11 +2698,7 @@ void LLAgent::updateLookAt(const S32 mouse_x, const S32 mouse_y) { static LLVector3 last_at_axis; - - if (mAvatarObject.isNull()) - { - return; - } + if (!isAgentAvatarValid()) return; LLQuaternion av_inv_rot = ~mAvatarObject->mRoot.getWorldRotation(); LLVector3 root_at = LLVector3::x_axis * mAvatarObject->mRoot.getWorldRotation(); @@ -2958,7 +2970,7 @@ void LLAgent::endAnimationUpdateUI() } // Disable mouselook-specific animations - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { if( mAvatarObject->isAnyAnimationSignaled(AGENT_GUN_AIM_ANIMS, NUM_AGENT_GUN_AIM_ANIMS) ) { @@ -3004,7 +3016,7 @@ void LLAgent::endAnimationUpdateUI() gMorphView->setVisible( FALSE ); } - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { if(mCustomAnim) { @@ -3046,7 +3058,7 @@ void LLAgent::endAnimationUpdateUI() gConsole->setVisible( TRUE ); - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { // Trigger mouselook-specific animations if( mAvatarObject->isAnyAnimationSignaled(AGENT_GUN_HOLD_ANIMS, NUM_AGENT_GUN_HOLD_ANIMS) ) @@ -3107,7 +3119,7 @@ void LLAgent::endAnimationUpdateUI() } // freeze avatar - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { // //mPauseRequest = mAvatarObject->requestPause(); @@ -3115,9 +3127,9 @@ void LLAgent::endAnimationUpdateUI() } } - if (getAvatarObject()) + if (isAgentAvatarValid()) { - getAvatarObject()->updateAttachmentVisibility(mCameraMode); + mAvatarObject->updateAttachmentVisibility(mCameraMode); } gFloaterTools->dirty(); @@ -3143,7 +3155,7 @@ void LLAgent::updateCamera() validateFocusObject(); - if (mAvatarObject.notNull() && + if (isAgentAvatarValid() && mAvatarObject->mIsSitting && camera_mode == CAMERA_MODE_MOUSELOOK) { @@ -3257,7 +3269,7 @@ void LLAgent::updateCamera() //Ventrella if ( mCameraMode == CAMERA_MODE_FOLLOW ) { - if ( mAvatarObject.notNull() ) + if (isAgentAvatarValid()) { //-------------------------------------------------------------------------------- // this is where the avatar's position and rotation are given to followCam, and @@ -3273,6 +3285,7 @@ void LLAgent::updateCamera() mFollowCam.copyParams(*current_cam); mFollowCam.setSubjectPositionAndRotation( mAvatarObject->getRenderPosition(), avatarRotationForFollowCam ); mFollowCam.update(); + LLViewerJoystick::getInstance()->setCameraNeedsUpdate(true); } else { @@ -3502,6 +3515,11 @@ void LLAgent::updateCamera() } } +void LLAgent::updateLastCamera() +{ + mLastCameraMode = mCameraMode; +} + void LLAgent::updateFocusOffset() { validateFocusObject(); @@ -3652,7 +3670,7 @@ LLVector3d LLAgent::calcThirdPersonFocusOffset() focus_offset.setVec(gSavedSettings.getVector3("FocusOffsetDefault")); LLQuaternion agent_rot = mFrameAgent.getQuaternion(); - if (!mAvatarObject.isNull() && mAvatarObject->getParent()) + if (isAgentAvatarValid() && mAvatarObject->getParent()) { agent_rot *= ((LLViewerObject*)(mAvatarObject->getParent()))->getRenderRotation(); } @@ -3664,7 +3682,7 @@ LLVector3d LLAgent::calcThirdPersonFocusOffset() void LLAgent::setupSitCamera() { // agent frame entering this function is in world coordinates - if (mAvatarObject.notNull() && mAvatarObject->getParent()) + if (isAgentAvatarValid() && mAvatarObject->getParent()) { LLQuaternion parent_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); // slam agent coordinate frame to proper parent local version @@ -3732,7 +3750,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit) { // Compute base camera position and look-at points. //F32 camera_land_height; - LLVector3d frame_center_global = mAvatarObject.isNull() ? getPositionGlobal() + LLVector3d frame_center_global = !isAgentAvatarValid() ? getPositionGlobal() : getPosGlobalFromAgent(mAvatarObject->mRoot.getWorldPosition()); LLVector3 upAxis = getUpAxis(); @@ -3749,7 +3767,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit) }// End Ventrella else if (mCameraMode == CAMERA_MODE_MOUSELOOK) { - if (mAvatarObject.isNull() || mAvatarObject->mDrawable.isNull()) + if (!isAgentAvatarValid() || mAvatarObject->mDrawable.isNull()) { llwarns << "Null avatar drawable!" << llendl; return LLVector3d::zero; @@ -3784,7 +3802,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit) F32 camera_distance = 0.f; if (mSitCameraEnabled - && mAvatarObject.notNull() + && isAgentAvatarValid() && mAvatarObject->mIsSitting && mSitCameraReferenceObject.notNull()) { @@ -3801,7 +3819,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit) local_camera_offset = mCameraZoomFraction * mCameraOffsetDefault * gSavedSettings.getF32("CameraOffsetScale"); // are we sitting down? - if (mAvatarObject.notNull() && mAvatarObject->getParent()) + if (isAgentAvatarValid() && mAvatarObject->getParent()) { LLQuaternion parent_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); // slam agent coordinate frame to proper parent local version @@ -3817,7 +3835,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit) local_camera_offset = mFrameAgent.rotateToAbsolute( local_camera_offset ); } - if (!mCameraCollidePlane.isExactlyZero() && (mAvatarObject.isNull() || !mAvatarObject->mIsSitting)) + if (!mCameraCollidePlane.isExactlyZero() && (!isAgentAvatarValid() || !mAvatarObject->mIsSitting)) { LLVector3 plane_normal; plane_normal.setVec(mCameraCollidePlane.mV); @@ -3870,11 +3888,11 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit) // set the global camera position LLVector3d camera_offset; - LLVector3 av_pos = mAvatarObject.isNull() ? LLVector3::zero : mAvatarObject->getRenderPosition(); + LLVector3 av_pos = !isAgentAvatarValid() ? LLVector3::zero : mAvatarObject->getRenderPosition(); camera_offset.setVec( local_camera_offset ); camera_position_global = frame_center_global + head_offset + camera_offset; - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { LLVector3d camera_lag_d; F32 lag_interp = LLCriticalDamp::getInterpolant(CAMERA_LAG_HALF_LIFE); @@ -4075,7 +4093,7 @@ void LLAgent::changeCameraToMouselook(BOOL animate) gFocusMgr.setKeyboardFocus( NULL ); if (gSavedSettings.getBOOL("AONoStandsInMouselook")) LLFloaterAO::stopMotion(LLFloaterAO::getCurrentStandId(), FALSE,TRUE); - mLastCameraMode = mCameraMode; + updateLastCamera(); mCameraMode = CAMERA_MODE_MOUSELOOK; U32 old_flags = mControlFlags; setControlFlags(AGENT_CONTROL_MOUSELOOK); @@ -4137,7 +4155,7 @@ void LLAgent::changeCameraToFollow(BOOL animate) } startCameraAnimation(); - mLastCameraMode = mCameraMode; + updateLastCamera(); mCameraMode = CAMERA_MODE_FOLLOW; // bang-in the current focus, position, and up vector of the follow cam @@ -4148,7 +4166,7 @@ void LLAgent::changeCameraToFollow(BOOL animate) LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); } - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { mAvatarObject->mPelvisp->setPosition(LLVector3::zero); mAvatarObject->startMotion( ANIM_AGENT_BODY_NOISE ); @@ -4206,7 +4224,7 @@ void LLAgent::changeCameraToThirdPerson(BOOL animate) mCameraZoomFraction = INITIAL_ZOOM_FRACTION; - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { if (!mAvatarObject->mIsSitting) { @@ -4240,7 +4258,7 @@ void LLAgent::changeCameraToThirdPerson(BOOL animate) mTargetCameraDistance = MIN_CAMERA_DISTANCE; animate = FALSE; } - mLastCameraMode = mCameraMode; + updateLastCamera(); mCameraMode = CAMERA_MODE_THIRD_PERSON; U32 old_flags = mControlFlags; clearControlFlags(AGENT_CONTROL_MOUSELOOK); @@ -4252,7 +4270,7 @@ void LLAgent::changeCameraToThirdPerson(BOOL animate) } // Remove any pitch from the avatar - if (mAvatarObject.notNull() && mAvatarObject->getParent()) + if (isAgentAvatarValid() && mAvatarObject->getParent()) { LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); at_axis = LLViewerCamera::getInstance()->getAtAxis(); @@ -4336,7 +4354,7 @@ void LLAgent::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL camera_ani LLVOAvatar::onCustomizeStart(); } - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { if(avatar_animate) { @@ -4456,7 +4474,7 @@ void LLAgent::setFocusGlobal(const LLVector3d& focus, const LLUUID &object_id) { if (focus.isExactlyZero()) { - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { mFocusTargetGlobal = getPosGlobalFromAgent(mAvatarObject->mHeadp->getWorldPosition()); } @@ -4501,7 +4519,7 @@ void LLAgent::setFocusGlobal(const LLVector3d& focus, const LLUUID &object_id) { if (focus.isExactlyZero()) { - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { mFocusTargetGlobal = getPosGlobalFromAgent(mAvatarObject->mHeadp->getWorldPosition()); } @@ -4639,7 +4657,7 @@ void LLAgent::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate) if (mCameraMode == CAMERA_MODE_THIRD_PERSON) { LLVector3 at_axis; - if (mAvatarObject.notNull() && mAvatarObject->getParent()) + if (isAgentAvatarValid() && mAvatarObject->getParent()) { LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); at_axis = LLViewerCamera::getInstance()->getAtAxis(); @@ -4706,7 +4724,7 @@ void LLAgent::lookAtLastChat() if (chatter->isAvatar()) { LLVOAvatar *chatter_av = (LLVOAvatar*)chatter; - if (mAvatarObject.notNull() && chatter_av->mHeadp) + if (isAgentAvatarValid() && chatter_av->mHeadp) { delta_pos = chatter_av->mHeadp->getWorldPosition() - mAvatarObject->mHeadp->getWorldPosition(); } @@ -4895,13 +4913,13 @@ void LLAgent::setStartPosition( U32 location_id ) const F32 REGION_WIDTH = LLWorld::getInstance()->getRegionWidthInMeters(); LLVector3 agent_pos = getPositionAgent(); - LLVector3 agent_look_at = mFrameAgent.getAtAxis(); + LLVector3 agent_look_at = mFrameAgent.getAtAxis(); - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { - // the z height is at the agent's feet - agent_pos.mV[VZ] -= 0.5f * mAvatarObject->mBodySize.mV[VZ]; - } + // the z height is at the agent's feet + agent_pos.mV[VZ] -= 0.5f * mAvatarObject->mBodySize.mV[VZ]; + } agent_pos.mV[VX] = llclamp( agent_pos.mV[VX], INSET, REGION_WIDTH - INSET ); agent_pos.mV[VY] = llclamp( agent_pos.mV[VY], INSET, REGION_WIDTH - INSET ); @@ -5018,7 +5036,7 @@ void LLAgent::onAnimStop(const LLUUID& id) setControlFlags(AGENT_CONTROL_FINISH_ANIM); // now trigger dusting self off animation - if (mAvatarObject.notNull() && !mAvatarObject->mBelowWater && rand() % 3 == 0) + if (isAgentAvatarValid() && !mAvatarObject->mBelowWater && rand() % 3 == 0) sendAnimationRequest( ANIM_AGENT_BRUSH, ANIM_REQUEST_START ); } else if (id == ANIM_AGENT_PRE_JUMP || id == ANIM_AGENT_LAND || id == ANIM_AGENT_MEDIUM_LAND) @@ -5125,6 +5143,9 @@ int LLAgent::convertTextToMaturity(char text) bool LLAgent::sendMaturityPreferenceToServer(int preferredMaturity) { + if (!getRegion()) + return false; + // Update agent access preference on the server std::string url = getRegion()->getCapability("UpdateAgentInformation"); if (!url.empty()) @@ -5187,7 +5208,7 @@ const LLAgentAccess& LLAgent::getAgentAccess() void LLAgent::buildFullname(std::string& name) const { - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { name = mAvatarObject->getFullname(); } @@ -5205,7 +5226,7 @@ void LLAgent::buildFullnameAndTitle(std::string& name) const name.erase(0, name.length()); } - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { name += mAvatarObject->getFullname(); } @@ -5404,7 +5425,7 @@ void LLAgent::buildLocationString(std::string& str) LLQuaternion LLAgent::getHeadRotation() { - if (mAvatarObject.isNull() || !mAvatarObject->mPelvisp || !mAvatarObject->mHeadp) + if (!isAgentAvatarValid() || !mAvatarObject->mPelvisp || !mAvatarObject->mHeadp) { return LLQuaternion::DEFAULT; } @@ -6049,8 +6070,7 @@ void LLAgent::processAgentCachedTextureResponse(LLMessageSystem *mesgsys, void * { gAgent.mNumPendingQueries--; - LLVOAvatar* avatarp = gAgent.getAvatarObject(); - if (!avatarp || avatarp->isDead()) + if (!isAgentAvatarValid()) { llwarns << "No avatar for user in cached texture update!" << llendl; return; @@ -6082,7 +6102,7 @@ void LLAgent::processAgentCachedTextureResponse(LLMessageSystem *mesgsys, void * && gAgent.mActiveCacheQueries[ texture_index ] == query_id) { //llinfos << "Received cached texture " << (U32)texture_index << ": " << texture_id << llendl; - avatarp->setCachedBakedTexture(getTextureIndex((EBakedTextureIndex)texture_index), texture_id); + gAgent.getAvatarObject()->setCachedBakedTexture(getTextureIndex((EBakedTextureIndex)texture_index), texture_id); //avatarp->setTETexture( LLVOAvatar::sBakedTextureIndices[texture_index], texture_id ); gAgent.mActiveCacheQueries[ texture_index ] = 0; num_results++; @@ -6091,20 +6111,19 @@ void LLAgent::processAgentCachedTextureResponse(LLMessageSystem *mesgsys, void * llinfos << "Received cached texture response for " << num_results << " textures." << llendl; - avatarp->updateMeshTextures(); + gAgent.getAvatarObject()->updateMeshTextures(); if (gAgent.mNumPendingQueries == 0) { // RN: not sure why composites are disabled at this point - avatarp->setCompositeUpdatesEnabled(TRUE); + gAgent.getAvatarObject()->setCompositeUpdatesEnabled(TRUE); gAgent.sendAgentSetAppearance(); } } BOOL LLAgent::anyControlGrabbed() const { - U32 i; - for (i = 0; i < TOTAL_CONTROLS; i++) + for (U32 i = 0; i < TOTAL_CONTROLS; i++) { if (gAgent.mControlsTakenCount[i] > 0) return TRUE; @@ -6150,11 +6169,10 @@ BOOL LLAgent::getHomePosGlobal( LLVector3d* pos_global ) void LLAgent::clearVisualParams(void *data) { - LLVOAvatar* avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { - avatarp->clearVisualParamWeights(); - avatarp->updateVisualParams(); + gAgent.getAvatarObject()->clearVisualParamWeights(); + gAgent.getAvatarObject()->updateVisualParams(); } } @@ -6181,9 +6199,9 @@ bool LLAgent::teleportCore(bool is_local) // sync with other viewers. Discuss in DEV-14145/VWR-6744 before reenabling. // Stop all animation before actual teleporting - LLVOAvatar* avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { + LLVOAvatar* avatarp = gAgent.getAvatarObject(); for ( LLVOAvatar::AnimIterator anim_it= avatarp->mPlayingAnimations.begin(); anim_it != avatarp->mPlayingAnimations.end(); ++anim_it) @@ -6475,10 +6493,9 @@ void LLAgent::stopCurrentAnimations() { // This function stops all current overriding animations on this // avatar, propagating this change back to the server. - - LLVOAvatar* avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { + LLVOAvatar* avatarp = gAgent.getAvatarObject(); for ( LLVOAvatar::AnimIterator anim_it = avatarp->mPlayingAnimations.begin(); anim_it != avatarp->mPlayingAnimations.end(); @@ -7575,7 +7592,7 @@ void LLAgent::addWearableToAgentInventory( //----------------------------------------------------------------------------- void LLAgent::sendAgentSetAppearance() { - if (mAvatarObject.isNull()) return; + if (!isAgentAvatarValid()) return; if (mNumPendingQueries > 0 && !gAgent.cameraCustomizeAvatar()) { diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 71363c28c..7fed1db85 100644 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -123,6 +123,8 @@ inline bool operator==(const LLGroupData &a, const LLGroupData &b) return (a.mID == b.mID); } +BOOL isAgentAvatarValid(); + // forward declarations // @@ -449,6 +451,7 @@ public: void cameraPanLeft(const F32 meters); void cameraPanUp(const F32 meters); + void updateLastCamera(); void updateFocusOffset(); void validateFocusObject(); diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index e465f338b..52c8dfd00 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -372,7 +372,7 @@ void request_initial_instant_messages() if (!requested && gMessageSystem && LLMuteList::getInstance()->isLoaded() - && gAgent.getAvatarObject()) + && isAgentAvatarValid()) { // Auto-accepted inventory items may require the avatar object // to build a correct name. Likewise, inventory offers from @@ -2635,26 +2635,27 @@ void LLAppViewer::initMarkerFile() if(LLAPRFile::isExist(logout_marker_file, LL_APR_RB)) { - LL_INFOS("MarkerFile") << "Last exec LLError crashed, setting LastExecEvent to " << LAST_EXEC_LLERROR_CRASH << LL_ENDL; gLastExecEvent = LAST_EXEC_LOGOUT_FROZE; + LL_INFOS("MarkerFile") << "Last exec LLError crashed, setting LastExecEvent to " << gLastExecEvent << LL_ENDL; + LLAPRFile::remove(logout_marker_file); } if(LLAPRFile::isExist(llerror_marker_file, LL_APR_RB)) { llinfos << "Last exec LLError crashed, setting LastExecEvent to " << LAST_EXEC_LLERROR_CRASH << llendl; if(gLastExecEvent == LAST_EXEC_LOGOUT_FROZE) gLastExecEvent = LAST_EXEC_LOGOUT_CRASH; else gLastExecEvent = LAST_EXEC_LLERROR_CRASH; + LL_INFOS("MarkerFile") << "Last exec LLError crashed, setting LastExecEvent to " << gLastExecEvent << LL_ENDL; + LLAPRFile::remove(llerror_marker_file); } if(LLAPRFile::isExist(error_marker_file, LL_APR_RB)) { LL_INFOS("MarkerFile") << "Last exec crashed, setting LastExecEvent to " << LAST_EXEC_OTHER_CRASH << LL_ENDL; if(gLastExecEvent == LAST_EXEC_LOGOUT_FROZE) gLastExecEvent = LAST_EXEC_LOGOUT_CRASH; else gLastExecEvent = LAST_EXEC_OTHER_CRASH; + LL_INFOS("MarkerFile") << "Last exec crashed, setting LastExecEvent to " << gLastExecEvent << LL_ENDL; + LLAPRFile::remove(error_marker_file); } - LLAPRFile::remove(logout_marker_file); - LLAPRFile::remove(llerror_marker_file); - LLAPRFile::remove(error_marker_file); - // No new markers if another instance is running. if(anotherInstanceRunning()) { @@ -3990,7 +3991,7 @@ void LLAppViewer::idleNetwork() // Check that the circuit between the viewer and the agent's current // region is still alive LLViewerRegion *agent_region = gAgent.getRegion(); - if (agent_region) + if (agent_region && (LLStartUp::getStartupState()==STATE_STARTED)) { LLUUID this_region_id = agent_region->getRegionID(); bool this_region_alive = agent_region->isAlive(); diff --git a/indra/newview/llsurface.cpp b/indra/newview/llsurface.cpp index f8cf9e57e..f75c8e314 100644 --- a/indra/newview/llsurface.cpp +++ b/indra/newview/llsurface.cpp @@ -960,6 +960,7 @@ LLSurfacePatch *LLSurface::resolvePatchRegion(const LLVector3 &pos_region) const LLSurfacePatch *LLSurface::resolvePatchGlobal(const LLVector3d &pos_global) const { + llassert(mRegionp); LLVector3 pos_region = mRegionp->getPosRegionFromGlobal(pos_global); return resolvePatchRegion(pos_region); } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 1b33b6515..c5ae4b44c 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -369,11 +369,10 @@ void LLViewerObject::markDead() if (flagAnimSource()) { - LLVOAvatar* avatarp = gAgent.getAvatarObject(); - if (avatarp && !avatarp->isDead()) + if (isAgentAvatarValid()) { // stop motions associated with this object - avatarp->stopMotionFromSource(mID); + gAgent.getAvatarObject()->stopMotionFromSource(mID); } } diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index e07b39374..bf50be20e 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -1235,8 +1235,7 @@ void LLViewerObjectList::generatePickList(LLCamera &camera) } // add all hud objects to pick list - LLVOAvatar* avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { LLVOAvatar* avatarp = gAgent.getAvatarObject(); for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); From 459deb428861e82b60bb13c9668e5969fabbfca6 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Fri, 25 Mar 2011 17:51:18 -0500 Subject: [PATCH 2/8] Media stream cleared when entering parcel with invalid media url --- indra/newview/llviewerparcelmgr.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index 7d40cae4a..40928c7be 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -763,13 +763,17 @@ BOOL LLViewerParcelMgr::canHearSound(const LLVector3d &pos_global) const BOOL LLViewerParcelMgr::inAgentParcel(const LLVector3d &pos_global) const { LLViewerRegion* region = LLWorld::getInstance()->getRegionFromPosGlobal(pos_global); - if (region != gAgent.getRegion()) + LLViewerRegion* agent_region = gAgent.getRegion(); + if (!region || !agent_region) + return FALSE; + + if (region != agent_region) { // Can't be in the agent parcel if you're not in the same region. return FALSE; } - LLVector3 pos_region = gAgent.getRegion()->getPosRegionFromGlobal(pos_global); + LLVector3 pos_region = agent_region->getPosRegionFromGlobal(pos_global); S32 row = S32(pos_region.mV[VY] / PARCEL_GRID_STEP_METERS); S32 column = S32(pos_region.mV[VX] / PARCEL_GRID_STEP_METERS); @@ -838,8 +842,11 @@ void LLViewerParcelMgr::renderParcelCollision() if (mRenderCollision && gSavedSettings.getBOOL("ShowBanLines")) { LLViewerRegion* regionp = gAgent.getRegion(); - BOOL use_pass = mCollisionParcel->getParcelFlag(PF_USE_PASS_LIST); - renderCollisionSegments(mCollisionSegments, use_pass, regionp); + if (regionp) + { + BOOL use_pass = mCollisionParcel->getParcelFlag(PF_USE_PASS_LIST); + renderCollisionSegments(mCollisionSegments, use_pass, regionp); + } } } @@ -1684,10 +1691,16 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use { optionally_start_music(music_url); } + else + { + llinfos << "Stopping parcel music (invalid audio stream URL)" << llendl; + // clears the URL + gAudiop->startInternetStream(LLStringUtil::null); + } } else if (!gAudiop->getInternetStreamURL().empty()) { - llinfos << "Stopping parcel music" << llendl; + llinfos << "Stopping parcel music (parcel stream URL is empty)" << llendl; gAudiop->startInternetStream(LLStringUtil::null); } } From 8323a701e81633d6a1834e01b90cc703728be092 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sun, 27 Mar 2011 16:53:17 -0500 Subject: [PATCH 3/8] Fixed some 'RenderDelayCreation' related crashes --- indra/newview/llselectmgr.cpp | 28 ++++++++++++++-------------- indra/newview/llviewerobject.cpp | 19 ++++++++++--------- indra/newview/llviewerobject.h | 5 ++--- indra/newview/llvoavatar.cpp | 6 +++--- indra/newview/llvovolume.cpp | 2 +- indra/newview/pipeline.cpp | 3 ++- 6 files changed, 32 insertions(+), 31 deletions(-) diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 3e22474a7..0622b579c 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -405,7 +405,7 @@ LLObjectSelectionHandle LLSelectMgr::selectObjectAndFamily(LLViewerObject* obj, } // Collect all of the objects - LLDynamicArray objects; + std::vector objects; root->addThisAndNonJointChildren(objects); addAsFamily(objects, add_to_end); @@ -451,7 +451,7 @@ LLObjectSelectionHandle LLSelectMgr::selectObjectAndFamily(const std::vector objects; + std::vector objects; //clear primary object (no primary object) mSelectedObjects->mPrimaryObject = NULL; @@ -575,7 +575,7 @@ void LLSelectMgr::deselectObjectAndFamily(LLViewerObject* object, BOOL send_to_s if(!object->isSelected()) return; // Collect all of the objects, and remove them - LLDynamicArray objects; + std::vector objects; if (include_entire_object) { @@ -821,7 +821,7 @@ LLObjectSelectionHandle LLSelectMgr::setHoverObject(LLViewerObject *objectp, S32 { // Collect all of the objects - LLDynamicArray objects; + std::vector objects; objectp = objectp->getRootEdit(); objectp->addThisAndNonJointChildren(objects); @@ -1310,7 +1310,7 @@ void LLSelectMgr::promoteSelectionToRoot() //----------------------------------------------------------------------------- void LLSelectMgr::demoteSelectionToIndividuals() { - LLDynamicArray objects; + std::vector objects; for (LLObjectSelection::root_iterator iter = getSelection()->root_begin(); iter != getSelection()->root_end(); iter++) @@ -1319,7 +1319,7 @@ void LLSelectMgr::demoteSelectionToIndividuals() object->addThisAndNonJointChildren(objects); } - if (objects.getLength()) + if (!objects.empty()) { deselectAll(); for (std::vector::iterator iter = objects.begin(); @@ -3602,7 +3602,7 @@ void LLSelectMgr::sendAttach(U8 attachment_point) { LLViewerObject* attach_object = mSelectedObjects->getFirstRootObject(); - if (!attach_object || !gAgent.getAvatarObject() || mSelectedObjects->mSelectType != SELECT_TYPE_WORLD) + if (!attach_object || !isAgentAvatarValid() || mSelectedObjects->mSelectType != SELECT_TYPE_WORLD) { return; } @@ -4886,7 +4886,7 @@ void LLSelectMgr::updateSelectionSilhouette(LLObjectSelectionHandle object_handl generateSilhouette(node, LLViewerCamera::getInstance()->getOrigin()); changed_objects.push_back(objectp); } - else if (objectp->isAttachment()) + else if (objectp->isAttachment() && objectp->getRootEdit() && objectp->getRootEdit()->mDrawable.notNull()) { //RN: hack for orthogonal projection of HUD attachments LLViewerJointAttachment* attachment_pt = (LLViewerJointAttachment*)objectp->getRootEdit()->mDrawable->getParent(); @@ -4914,9 +4914,9 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud) LLGLEnable blend(GL_BLEND); LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); - LLVOAvatar* avatar = gAgent.getAvatarObject(); - if (for_hud && avatar) + if (isAgentAvatarValid() && for_hud) { + LLVOAvatar* avatar = gAgent.getAvatarObject(); LLBBox hud_bbox = avatar->getHUDBBox(); F32 cur_zoom = gAgent.mHUDCurZoom; @@ -5010,7 +5010,7 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud) } } - if (for_hud && avatar) + if (isAgentAvatarValid() && for_hud) { glMatrixMode(GL_PROJECTION); glPopMatrix(); @@ -5372,7 +5372,7 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color) if (volume) { F32 silhouette_thickness; - if (is_hud_object && gAgent.getAvatarObject()) + if (isAgentAvatarValid() && is_hud_object) { silhouette_thickness = LLSelectMgr::sHighlightThickness / gAgent.mHUDCurZoom; } @@ -5567,7 +5567,7 @@ void LLSelectMgr::updateSelectionCenter() { mSelectedObjects->mSelectType = getSelectTypeForObject(object); - if (mSelectedObjects->mSelectType == SELECT_TYPE_ATTACHMENT && gAgent.getAvatarObject()) + if (mSelectedObjects->mSelectType == SELECT_TYPE_ATTACHMENT && isAgentAvatarValid()) { mPauseRequest = gAgent.getAvatarObject()->requestPause(); } @@ -5576,7 +5576,7 @@ void LLSelectMgr::updateSelectionCenter() mPauseRequest = NULL; } - if (mSelectedObjects->mSelectType != SELECT_TYPE_HUD && gAgent.getAvatarObject()) + if (mSelectedObjects->mSelectType != SELECT_TYPE_HUD && isAgentAvatarValid()) { // reset hud ZOOM gAgent.mHUDTargetZoom = 1.f; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 64e4f8cce..0aabf8269 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -578,11 +578,11 @@ void LLViewerObject::removeChild(LLViewerObject *childp) } } -void LLViewerObject::addThisAndAllChildren(LLDynamicArray& objects) +void LLViewerObject::addThisAndAllChildren(std::vector& objects) { - objects.put(this); + objects.push_back(this); for (child_list_t::iterator iter = mChildList.begin(); - iter != mChildList.end(); iter++) + iter != mChildList.end(); ++iter) { LLViewerObject* child = *iter; if (!child->isAvatar()) @@ -592,16 +592,16 @@ void LLViewerObject::addThisAndAllChildren(LLDynamicArray& obje } } -void LLViewerObject::addThisAndNonJointChildren(LLDynamicArray& objects) +void LLViewerObject::addThisAndNonJointChildren(std::vector& objects) { - objects.put(this); + objects.push_back(this); // don't add any attachments when temporarily selecting avatar if (isAvatar()) { return; } for (child_list_t::iterator iter = mChildList.begin(); - iter != mChildList.end(); iter++) + iter != mChildList.end(); ++iter) { LLViewerObject* child = *iter; if ( (!child->isAvatar()) && (!child->isJointChild())) @@ -614,7 +614,7 @@ void LLViewerObject::addThisAndNonJointChildren(LLDynamicArray& BOOL LLViewerObject::isChild(LLViewerObject *childp) const { for (child_list_t::const_iterator iter = mChildList.begin(); - iter != mChildList.end(); iter++) + iter != mChildList.end(); ++iter) { LLViewerObject* testchild = *iter; if (testchild == childp) @@ -628,7 +628,7 @@ BOOL LLViewerObject::isChild(LLViewerObject *childp) const BOOL LLViewerObject::isSeat() const { for (child_list_t::const_iterator iter = mChildList.begin(); - iter != mChildList.end(); iter++) + iter != mChildList.end(); ++iter) { LLViewerObject* child = *iter; if (child->isAvatar()) @@ -2914,7 +2914,8 @@ void LLViewerObject::updateSpatialExtents(LLVector3& newMin, LLVector3 &newMax) LLVector3 size = getScale(); newMin.setVec(center-size); newMax.setVec(center+size); - mDrawable->setPositionGroup((newMin + newMax) * 0.5f); + if(mDrawable.notNull()) + mDrawable->setPositionGroup((newMin + newMax) * 0.5f); } F32 LLViewerObject::getBinRadius() diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 1341367d0..0dc36c6c2 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -36,7 +36,6 @@ #include #include "llassetstorage.h" -#include "lldarrayptr.h" #include "llhudtext.h" #include "llhudicon.h" #include "llinventory.h" @@ -243,8 +242,8 @@ public: virtual void removeChild(LLViewerObject *childp); const_child_list_t& getChildren() const { return mChildList; } S32 numChildren() const { return mChildList.size(); } - void addThisAndAllChildren(LLDynamicArray& objects); - void addThisAndNonJointChildren(LLDynamicArray& objects); + void addThisAndAllChildren(std::vector& objects); + void addThisAndNonJointChildren(std::vector& objects); BOOL isChild(LLViewerObject *childp) const; BOOL isSeat() const; diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 8965cc08f..bf819e186 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -1585,7 +1585,7 @@ const LLVector3 LLVOAvatar::getRenderPosition() const { return getPositionAgent(); } - else if (isRoot()) + else if (isRoot() || !mDrawable->getParent()) { return mDrawable->getPositionAgent(); } @@ -3029,7 +3029,7 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update) mDrawable->movePartition(); //force a move if sitting on an active object - if (getParent() && ((LLViewerObject*) getParent())->mDrawable->isActive()) + if (getParent() && ((LLViewerObject*)getParent())->mDrawable.notNull() && ((LLViewerObject*) getParent())->mDrawable->isActive()) { gPipeline.markMoved(mDrawable, TRUE); } @@ -7358,7 +7358,7 @@ BOOL LLVOAvatar::detachObject(LLViewerObject *viewer_object) //----------------------------------------------------------------------------- void LLVOAvatar::sitOnObject(LLViewerObject *sit_object) { - if (!mDrawable || mDrawable.isNull()) + if (!mDrawable || mDrawable.isNull() || sit_object->mDrawable.isNull()) { return; } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index bfe218d4c..ade4a343b 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -471,7 +471,7 @@ void LLVOVolume::updateTextureVirtualSize() { // Update the pixel area of all faces - if(!isVisible()) + if(!isVisible() || mDrawable.isNull()) { return; } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 21ab8e598..13a4e1cef 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1037,13 +1037,14 @@ void LLPipeline::unlinkDrawable(LLDrawable *drawable) U32 LLPipeline::addObject(LLViewerObject *vobj) { + llassert_always(vobj); if (gNoRender) { return 0; } static const LLCachedControl render_delay_creation("RenderDelayCreation",false); - if (render_delay_creation) + if (!vobj->isAvatar() && render_delay_creation) { mCreateQ.push_back(vobj); } From 18af6baeddc09b5c31212edc1e6a4c534519529f Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sun, 27 Mar 2011 18:50:04 -0500 Subject: [PATCH 4/8] Cleaned up a few minor things --- indra/llcommon/llchat.h | 3 +-- indra/llcommon/llerror.cpp | 3 --- indra/llcommon/llsdserialize.h | 5 +++-- indra/llvfs/lllfsthread.cpp | 3 +-- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/indra/llcommon/llchat.h b/indra/llcommon/llchat.h index 62b5091a9..323b3b3c0 100644 --- a/indra/llcommon/llchat.h +++ b/indra/llcommon/llchat.h @@ -34,7 +34,6 @@ #ifndef LL_LLCHAT_H #define LL_LLCHAT_H -#include "llstring.h" #include "lluuid.h" #include "v3math.h" @@ -71,7 +70,7 @@ typedef enum e_chat_audible_level class LLChat { public: - LLChat(const std::string& text = LLStringUtil::null) + LLChat(const std::string& text = std::string()) : mText(text), mFromName(), mFromID(), diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index e61ed721e..e549979f0 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -45,9 +45,6 @@ # include # include #endif // !LL_WINDOWS -#if LL_WINDOWS -# include -#endif // LL_WINDOWS #include #include "llapp.h" diff --git a/indra/llcommon/llsdserialize.h b/indra/llcommon/llsdserialize.h index a01b6dcd3..7dd2603eb 100644 --- a/indra/llcommon/llsdserialize.h +++ b/indra/llcommon/llsdserialize.h @@ -639,7 +639,7 @@ protected: * */ template -class LLSDOStreamer : public Formatter +class LLSDOStreamer { public: /** @@ -660,7 +660,8 @@ public: std::ostream& str, const LLSDOStreamer& formatter) { - formatter.format(formatter.mSD, str, formatter.mOptions); + LLPointer f = new Formatter; + f->format(formatter.mSD, str, formatter.mOptions); return str; } diff --git a/indra/llvfs/lllfsthread.cpp b/indra/llvfs/lllfsthread.cpp index cd9122060..69c7eb6d6 100644 --- a/indra/llvfs/lllfsthread.cpp +++ b/indra/llvfs/lllfsthread.cpp @@ -184,7 +184,7 @@ bool LLLFSThread::Request::processRequest() if (mOperation == FILE_READ) { llassert(mOffset >= 0); - LLAPRFile infile ; + LLAPRFile infile ; // auto-closes infile.open(mFileName, LL_APR_RB, LLAPRFile::local); if (!infile.getFileHandle()) { @@ -200,7 +200,6 @@ bool LLLFSThread::Request::processRequest() llassert_always(off >= 0); mBytesRead = infile.read(mBuffer, mBytes ); complete = true; - infile.close() ; // llinfos << "LLLFSThread::READ:" << mFileName << " Bytes: " << mBytesRead << llendl; } else if (mOperation == FILE_WRITE) From dc62c29af0d55678b0e645fa27a3177508dadaf6 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sun, 27 Mar 2011 18:56:30 -0500 Subject: [PATCH 5/8] Extended win OS detection to include vista and win7 --- indra/llcommon/llsys.cpp | 170 +++++++++++++++++++++++++++-- indra/llcommon/llsys.h | 7 +- indra/newview/llappviewer.cpp | 4 +- indra/newview/llfeaturemanager.cpp | 4 +- indra/newview/llviewerjoystick.cpp | 2 +- 5 files changed, 168 insertions(+), 19 deletions(-) diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index 2e93b2a3a..d729d9883 100644 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -76,6 +76,75 @@ extern int errno; static const S32 CPUINFO_BUFFER_SIZE = 16383; LLCPUInfo gSysCPU; +#if LL_WINDOWS +#ifndef DLLVERSIONINFO +typedef struct _DllVersionInfo +{ + DWORD cbSize; + DWORD dwMajorVersion; + DWORD dwMinorVersion; + DWORD dwBuildNumber; + DWORD dwPlatformID; +}DLLVERSIONINFO; +#endif + +#ifndef DLLGETVERSIONPROC +typedef int (FAR WINAPI *DLLGETVERSIONPROC) (DLLVERSIONINFO *); +#endif + +bool get_shell32_dll_version(DWORD& major, DWORD& minor, DWORD& build_number) +{ + bool result = false; + const U32 BUFF_SIZE = 32767; + WCHAR tempBuf[BUFF_SIZE]; + if(GetSystemDirectory((LPWSTR)&tempBuf, BUFF_SIZE)) + { + + std::basic_string shell32_path(tempBuf); + + // Shell32.dll contains the DLLGetVersion function. + // according to msdn its not part of the API + // so you have to go in and get it. + // http://msdn.microsoft.com/en-us/library/bb776404(VS.85).aspx + shell32_path += TEXT("\\shell32.dll"); + + HMODULE hDllInst = LoadLibrary(shell32_path.c_str()); //load the DLL + if(hDllInst) + { // Could successfully load the DLL + DLLGETVERSIONPROC pDllGetVersion; + /* + You must get this function explicitly because earlier versions of the DLL + don't implement this function. That makes the lack of implementation of the + function a version marker in itself. + */ + pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hDllInst, + "DllGetVersion"); + + if(pDllGetVersion) + { + // DLL supports version retrieval function + DLLVERSIONINFO dvi; + + ZeroMemory(&dvi, sizeof(dvi)); + dvi.cbSize = sizeof(dvi); + HRESULT hr = (*pDllGetVersion)(&dvi); + + if(SUCCEEDED(hr)) + { // Finally, the version is at our hands + major = dvi.dwMajorVersion; + minor = dvi.dwMinorVersion; + build_number = dvi.dwBuildNumber; + result = true; + } + } + + FreeLibrary(hDllInst); // Release DLL + } + } + return result; +} +#endif // LL_WINDOWS + LLOSInfo::LLOSInfo() : mMajorVer(0), mMinorVer(0), mBuild(0) { @@ -98,6 +167,11 @@ LLOSInfo::LLOSInfo() : mMinorVer = osvi.dwMinorVersion; mBuild = osvi.dwBuildNumber; + DWORD shell32_major, shell32_minor, shell32_build; + bool got_shell32_version = get_shell32_dll_version(shell32_major, + shell32_minor, + shell32_build); + switch(osvi.dwPlatformId) { case VER_PLATFORM_WIN32_NT: @@ -122,14 +196,50 @@ LLOSInfo::LLOSInfo() : else mOSStringSimple = "Microsoft Windows Server 2003 "; } - else if(osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0) + else if(osvi.dwMajorVersion == 6 && osvi.dwMinorVersion <= 1) { - if(osvi.wProductType == VER_NT_WORKSTATION) + if(osvi.dwMinorVersion == 0) + { mOSStringSimple = "Microsoft Windows Vista "; - else mOSStringSimple = "Microsoft Windows Vista Server "; + } + else if(osvi.dwMinorVersion == 1) + { + mOSStringSimple = "Microsoft Windows 7 "; + } + + if(osvi.wProductType != VER_NT_WORKSTATION) + { + mOSStringSimple += "Server "; + } + + ///get native system info if available.. + typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); ///function pointer for loading GetNativeSystemInfo + SYSTEM_INFO si; //System Info object file contains architecture info + PGNSI pGNSI; //pointer object + ZeroMemory(&si, sizeof(SYSTEM_INFO)); //zero out the memory in information + pGNSI = (PGNSI) GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo"); //load kernel32 get function + if(NULL != pGNSI) //check if it has failed + pGNSI(&si); //success + else + GetSystemInfo(&si); //if it fails get regular system info + //(Warning: If GetSystemInfo it may result in incorrect information in a WOW64 machine, if the kernel fails to load) + + //msdn microsoft finds 32 bit and 64 bit flavors this way.. + //http://msdn.microsoft.com/en-us/library/ms724429(VS.85).aspx (example code that contains quite a few more flavors + //of windows than this code does (in case it is needed for the future) + if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 ) //check for 64 bit + { + mOSStringSimple += "64-bit "; + } + else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_INTEL ) + { + mOSStringSimple += "32-bit "; + } } else // Use the registry on early versions of Windows NT. { + mOSStringSimple = "Microsoft Windows (unrecognized) "; + HKEY hKey; WCHAR szProductType[80]; DWORD dwBufLen; @@ -170,6 +280,7 @@ LLOSInfo::LLOSInfo() : csdversion.c_str(), (osvi.dwBuildNumber & 0xffff)); } + mOSString = mOSStringSimple + tmpstr; } break; @@ -199,6 +310,21 @@ LLOSInfo::LLOSInfo() : mOSString = mOSStringSimple; break; } + + std::string compatibility_mode; + if(got_shell32_version) + { + if(osvi.dwMajorVersion != shell32_major + || osvi.dwMinorVersion != shell32_minor) + { + compatibility_mode = llformat(" compatibility mode. real ver: %d.%d (Build %d)", + shell32_major, + shell32_minor, + shell32_build); + } + } + mOSString += compatibility_mode; + #else struct utsname un; if(uname(&un) != -1) @@ -226,8 +352,8 @@ LLOSInfo::LLOSInfo() : else if (ostype == "Linux") { // Only care about major and minor Linux versions, truncate at second '.' - S32 idx1 = mOSStringSimple.find_first_of(".", 0); - S32 idx2 = (idx1 != std::string::npos) ? mOSStringSimple.find_first_of(".", idx1+1) : std::string::npos; + std::string::size_type idx1 = mOSStringSimple.find_first_of(".", 0); + std::string::size_type idx2 = (idx1 != std::string::npos) ? mOSStringSimple.find_first_of(".", idx1+1) : std::string::npos; std::string simple = mOSStringSimple.substr(0, idx2); if (simple.length() > 0) mOSStringSimple = simple; @@ -393,15 +519,15 @@ LLCPUInfo::LLCPUInfo() mHasSSE = info->_Ext.SSE_StreamingSIMD_Extensions; mHasSSE2 = info->_Ext.SSE2_StreamingSIMD2_Extensions; mHasAltivec = info->_Ext.Altivec_Extensions; - mCPUMhz = (S32)(proc.GetCPUFrequency(50)/1000000.0); + mCPUMHz = (F64)(proc.GetCPUFrequency(50)/1000000.0); mFamily.assign( info->strFamily ); mCPUString = "Unknown"; #if LL_WINDOWS || LL_DARWIN || LL_SOLARIS out << proc.strCPUName; - if (200 < mCPUMhz && mCPUMhz < 10000) // *NOTE: cpu speed is often way wrong, do a sanity check + if (200 < mCPUMHz && mCPUMHz < 10000) // *NOTE: cpu speed is often way wrong, do a sanity check { - out << " (" << mCPUMhz << " MHz)"; + out << " (" << mCPUMHz << " MHz)"; } mCPUString = out.str(); @@ -446,7 +572,7 @@ LLCPUInfo::LLCPUInfo() if (LLStringUtil::convertToF64(cpuinfo["cpu mhz"], mhz) && 200.0 < mhz && mhz < 10000.0) { - mCPUMhz = (S32)llrint(mhz); + mCPUMHz = (F64)llrint(mhz); } if (!cpuinfo["model name"].empty()) mCPUString = cpuinfo["model name"]; @@ -469,9 +595,9 @@ bool LLCPUInfo::hasSSE2() const return mHasSSE2; } -S32 LLCPUInfo::getMhz() const +F64 LLCPUInfo::getMHz() const { - return mCPUMhz; + return mCPUMHz; } std::string LLCPUInfo::getCPUString() const @@ -518,7 +644,7 @@ void LLCPUInfo::stream(std::ostream& s) const s << "->mHasSSE: " << (U32)mHasSSE << std::endl; s << "->mHasSSE2: " << (U32)mHasSSE2 << std::endl; s << "->mHasAltivec: " << (U32)mHasAltivec << std::endl; - s << "->mCPUMhz: " << mCPUMhz << std::endl; + s << "->mCPUMHz: " << mCPUMHz << std::endl; s << "->mCPUString: " << mCPUString << std::endl; } @@ -595,6 +721,26 @@ U32 LLMemoryInfo::getPhysicalMemoryClamped() const } } +//static +void LLMemoryInfo::getAvailableMemoryKB(U32& avail_physical_mem_kb, U32& avail_virtual_mem_kb) +{ +#if LL_WINDOWS + MEMORYSTATUSEX state; + state.dwLength = sizeof(state); + GlobalMemoryStatusEx(&state); + + avail_physical_mem_kb = (U32)(state.ullAvailPhys/1024) ; + avail_virtual_mem_kb = (U32)(state.ullAvailVirtual/1024) ; + +#else + //do not know how to collect available memory info for other systems. + //leave it blank here for now. + + avail_physical_mem_kb = -1 ; + avail_virtual_mem_kb = -1 ; +#endif +} + void LLMemoryInfo::stream(std::ostream& s) const { #if LL_WINDOWS diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h index d5575b2e1..e481c8838 100644 --- a/indra/llcommon/llsys.h +++ b/indra/llcommon/llsys.h @@ -81,7 +81,7 @@ public: bool hasAltivec() const; bool hasSSE() const; bool hasSSE2() const; - S32 getMhz() const; + F64 getMHz() const; // Family is "AMD Duron" or "Intel Pentium Pro" const std::string& getFamily() const { return mFamily; } @@ -90,7 +90,7 @@ private: bool mHasSSE; bool mHasSSE2; bool mHasAltivec; - S32 mCPUMhz; + F64 mCPUMHz; std::string mFamily; std::string mCPUString; }; @@ -120,6 +120,9 @@ public: ** be returned. */ U32 getPhysicalMemoryClamped() const; ///< Memory size in clamped bytes + + //get the available memory infomation in KiloBytes. + static void getAvailableMemoryKB(U32& avail_physical_mem_kb, U32& avail_virtual_mem_kb); }; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 6ccecb38b..5a582678e 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -800,7 +800,7 @@ bool LLAppViewer::init() minSpecs += "\n"; unsupported = true; } - if(gSysCPU.getMhz() < minCPU) + if(gSysCPU.getMHz() < minCPU) { minSpecs += LLNotifications::instance().getGlobalString("UnsupportedCPU"); minSpecs += "\n"; @@ -2358,7 +2358,7 @@ void LLAppViewer::writeSystemInfo() //need to put in something to lie about this stuff gDebugInfo["CPUInfo"]["CPUString"] = gSysCPU.getCPUString(); gDebugInfo["CPUInfo"]["CPUFamily"] = gSysCPU.getFamily(); - gDebugInfo["CPUInfo"]["CPUMhz"] = gSysCPU.getMhz(); + gDebugInfo["CPUInfo"]["CPUMhz"] = gSysCPU.getMHz(); gDebugInfo["CPUInfo"]["CPUAltivec"] = gSysCPU.hasAltivec(); gDebugInfo["CPUInfo"]["CPUSSE"] = gSysCPU.hasSSE(); gDebugInfo["CPUInfo"]["CPUSSE2"] = gSysCPU.hasSSE2(); diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index 136ddde75..338e2ae51 100644 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -627,9 +627,9 @@ void LLFeatureManager::applyBaseMasks() #if LL_SOLARIS && defined(__sparc) // even low MHz SPARCs are fast #error The 800 is hinky. Would something like a LL_MIN_MHZ make more sense here? - if (gSysCPU.getMhz() < 800) + if (gSysCPU.getMHz() < 800) #else - if (gSysCPU.getMhz() < 1100) + if (gSysCPU.getMHz() < 1100) #endif { maskFeatures("CPUSlow"); diff --git a/indra/newview/llviewerjoystick.cpp b/indra/newview/llviewerjoystick.cpp index 652e50e20..9058bdc13 100644 --- a/indra/newview/llviewerjoystick.cpp +++ b/indra/newview/llviewerjoystick.cpp @@ -162,7 +162,7 @@ LLViewerJoystick::LLViewerJoystick() memset(mBtn, 0, sizeof(mBtn)); // factor in bandwidth? bandwidth = gViewerStats->mKBitStat - mPerfScale = 4000.f / gSysCPU.getMhz(); + mPerfScale = 4000.f / gSysCPU.getMHz(); } // ----------------------------------------------------------------------------- From 74659e6121489381c8369641f6c7a3637f3f4bfa Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sun, 27 Mar 2011 18:59:41 -0500 Subject: [PATCH 6/8] LLImage update. Nothing big. Allocation checks and utility functions. --- indra/llimage/llimage.cpp | 76 +++++++++++++++++++++++++++++++++++++++ indra/llimage/llimage.h | 3 ++ 2 files changed, 79 insertions(+) diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 3834dde1f..8974f3eee 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -314,6 +314,21 @@ void LLImageRaw::deleteData() LLImageBase::deleteData(); } +void LLImageRaw::setDataAndSize(U8 *data, S32 width, S32 height, S8 components) +{ + if(data == getData()) + { + return ; + } + + deleteData(); + + LLImageBase::setSize(width, height, components) ; + LLImageBase::setDataAndSize(data, width * height * components) ; + + sGlobalRawMemory += getDataSize(); +} + BOOL LLImageRaw::resize(U16 width, U16 height, S8 components) { if ((getWidth() == width) && (getHeight() == height) && (getComponents() == components)) @@ -561,6 +576,11 @@ void LLImageRaw::compositeScaled4onto3(LLImageRaw* src) // Vertical: scale but no composite S32 temp_data_size = src->getWidth() * dst->getHeight() * src->getComponents(); U8* temp_buffer = new U8[ temp_data_size ]; + if (!temp_buffer ) + { + llerrs << "Out of memory in LLImageRaw::compositeScaled4onto3()" << llendl; + return; + } for( S32 col = 0; col < src->getWidth(); col++ ) { copyLineScaled( src->getData() + (src->getComponents() * col), temp_buffer + (src->getComponents() * col), src->getHeight(), dst->getHeight(), src->getWidth(), src->getWidth() ); @@ -813,6 +833,11 @@ void LLImageRaw::copyScaled( LLImageRaw* src ) S32 temp_data_size = src->getWidth() * dst->getHeight() * getComponents(); llassert_always(temp_data_size > 0); U8* temp_buffer = new U8[ temp_data_size ]; + if (!temp_buffer ) + { + llerrs << "Out of memory in LLImageRaw::copyScaled()" << llendl; + return; + } for( S32 col = 0; col < src->getWidth(); col++ ) { copyLineScaled( src->getData() + (getComponents() * col), temp_buffer + (getComponents() * col), src->getHeight(), dst->getHeight(), src->getWidth(), src->getWidth() ); @@ -829,6 +854,52 @@ void LLImageRaw::copyScaled( LLImageRaw* src ) } +//scale down image by not blending a pixel with its neighbors. +BOOL LLImageRaw::scaleDownWithoutBlending( S32 new_width, S32 new_height) +{ + LLMemType mt1((LLMemType::EMemType)mMemType); + + S8 c = getComponents() ; + llassert((1 == c) || (3 == c) || (4 == c) ); + + S32 old_width = getWidth(); + S32 old_height = getHeight(); + + S32 new_data_size = old_width * new_height * c ; + llassert_always(new_data_size > 0); + + F32 ratio_x = (F32)old_width / new_width ; + F32 ratio_y = (F32)old_height / new_height ; + if( ratio_x < 1.0f || ratio_y < 1.0f ) + { + return TRUE; // Nothing to do. + } + ratio_x -= 1.0f ; + ratio_y -= 1.0f ; + + U8* new_data = new U8[new_data_size] ; + llassert_always(new_data != NULL) ; + + U8* old_data = getData() ; + S32 i, j, k, s, t; + for(i = 0, s = 0, t = 0 ; i < new_height ; i++) + { + for(j = 0 ; j < new_width ; j++) + { + for(k = 0 ; k < c ; k++) + { + new_data[s++] = old_data[t++] ; + } + t += (S32)(ratio_x * c + 0.1f) ; + } + t += (S32)(ratio_y * old_width * c + 0.1f) ; + } + + setDataAndSize(new_data, new_width, new_height, c) ; + + return TRUE ; +} + BOOL LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data ) { LLMemType mt1((LLMemType::EMemType)mMemType); @@ -850,6 +921,11 @@ BOOL LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data ) S32 temp_data_size = old_width * new_height * getComponents(); llassert_always(temp_data_size > 0); U8* temp_buffer = new U8[ temp_data_size ]; + if (!temp_buffer ) + { + llerrs << "Out of memory in LLImageRaw::scale()" << llendl; + return FALSE; + } for( S32 col = 0; col < old_width; col++ ) { copyLineScaled( getData() + (getComponents() * col), temp_buffer + (getComponents() * col), old_height, new_height, old_width, old_width ); diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index 7d45911bd..f74c5901d 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -189,6 +189,7 @@ public: void contractToPowerOfTwo(S32 max_dim = MAX_IMAGE_SIZE, BOOL scale_image = TRUE); void biasedScaleToPowerOfTwo(S32 max_dim = MAX_IMAGE_SIZE); BOOL scale( S32 new_width, S32 new_height, BOOL scale_image = TRUE ); + BOOL scaleDownWithoutBlending( S32 new_width, S32 new_height) ; // Fill the buffer with a constant color void fill( const LLColor4U& color ); @@ -237,6 +238,8 @@ protected: U8 fastFractionalMult(U8 a,U8 b); + void setDataAndSize(U8 *data, S32 width, S32 height, S8 components) ; + public: static S32 sGlobalRawMemory; static S32 sRawImageCount; From acf31bb8856b0ea21ddfd419390a7b9b6648fb1e Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sun, 27 Mar 2011 19:00:36 -0500 Subject: [PATCH 7/8] U32 LLImageJ2C::mAreaUsedForDataSizeCalcs now initialized to 0 --- indra/llimage/llimagej2c.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 4c1b7ec89..08bcde633 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -179,8 +179,8 @@ LLImageJ2C::LLImageJ2C() : LLImageFormatted(IMG_CODEC_J2C), mMaxBytes(0), mRawDiscardLevel(-1), mRate(0.0f), - mReversible(FALSE) - + mReversible(FALSE), + mAreaUsedForDataSizeCalcs(0) { //We assume here that if we wanted to create via //a dynamic library that the approriate open calls were made From de109f9f97ee3068ef82240bfd0006e1dcba22f4 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sun, 27 Mar 2011 19:06:15 -0500 Subject: [PATCH 8/8] LLSD update. LLSD::insert no longer returns self. Use LLSD::with if return value is required. --- indra/llcommon/llsd.cpp | 64 +++++++++++++++++----------------- indra/llcommon/llsd.h | 6 ++-- indra/llui/llnotifications.cpp | 10 +++--- indra/newview/llstartup.cpp | 6 ++-- 4 files changed, 44 insertions(+), 42 deletions(-) diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp index ebc0dc621..ba7901cdb 100644 --- a/indra/llcommon/llsd.cpp +++ b/indra/llcommon/llsd.cpp @@ -349,13 +349,13 @@ namespace virtual LLSD::Boolean asBoolean() const { return !mData.empty(); } + virtual bool has(const LLSD::String&) const; + using LLSD::Impl::get; // Unhiding get(LLSD::Integer) using LLSD::Impl::erase; // Unhiding erase(LLSD::Integer) using LLSD::Impl::ref; // Unhiding ref(LLSD::Integer) - - virtual bool has(const LLSD::String&) const; virtual LLSD get(const LLSD::String&) const; - LLSD& insert(const LLSD::String& k, const LLSD& v); + void insert(const LLSD::String& k, const LLSD& v); virtual void erase(const LLSD::String&); LLSD& ref(const LLSD::String&); virtual const LLSD& ref(const LLSD::String&) const; @@ -394,14 +394,9 @@ namespace return (i != mData.end()) ? i->second : LLSD(); } - LLSD& ImplMap::insert(const LLSD::String& k, const LLSD& v) + void ImplMap::insert(const LLSD::String& k, const LLSD& v) { mData.insert(DataMap::value_type(k, v)); - #ifdef LL_MSVC7 - return *((LLSD*)this); - #else - return *dynamic_cast(this); - #endif } void ImplMap::erase(const LLSD::String& k) @@ -444,15 +439,13 @@ namespace virtual LLSD::Boolean asBoolean() const { return !mData.empty(); } + using LLSD::Impl::get; // Unhiding get(LLSD::String) + using LLSD::Impl::erase; // Unhiding erase(LLSD::String) + using LLSD::Impl::ref; // Unhiding ref(LLSD::String) virtual int size() const; - - using LLSD::Impl::get; // Unhiding get(LLSD::Integer) - using LLSD::Impl::erase; // Unhiding erase(LLSD::Integer) - using LLSD::Impl::ref; // Unhiding ref(LLSD::Integer) - virtual LLSD get(LLSD::Integer) const; void set(LLSD::Integer, const LLSD&); - LLSD& insert(LLSD::Integer, const LLSD&); + void insert(LLSD::Integer, const LLSD&); void append(const LLSD&); virtual void erase(LLSD::Integer); LLSD& ref(LLSD::Integer); @@ -501,14 +494,10 @@ namespace mData[index] = v; } - LLSD& ImplArray::insert(LLSD::Integer i, const LLSD& v) + void ImplArray::insert(LLSD::Integer i, const LLSD& v) { if (i < 0) { - #ifdef LL_MSVC7 - return *((LLSD*)this); - #else - return *dynamic_cast(this); - #endif + return; } DataVector::size_type index = i; @@ -518,11 +507,6 @@ namespace } mData.insert(mData.begin() + index, v); - #ifdef LL_MSVC7 - return *((LLSD*)this); - #else - return *dynamic_cast(this); - #endif } void ImplArray::append(const LLSD& v) @@ -765,11 +749,16 @@ LLSD LLSD::emptyMap() bool LLSD::has(const String& k) const { return safe(impl).has(k); } LLSD LLSD::get(const String& k) const { return safe(impl).get(k); } +void LLSD::insert(const String& k, const LLSD& v) { makeMap(impl).insert(k, v); } -LLSD& LLSD::insert(const String& k, const LLSD& v) +LLSD& LLSD::with(const String& k, const LLSD& v) { makeMap(impl).insert(k, v); - return *dynamic_cast(this); + #ifdef LL_MSVC7 + return *dynamic_cast(this); + #else + return *this; + #endif } void LLSD::erase(const String& k) { makeMap(impl).erase(k); } @@ -790,11 +779,16 @@ int LLSD::size() const { return safe(impl).size(); } LLSD LLSD::get(Integer i) const { return safe(impl).get(i); } void LLSD::set(Integer i, const LLSD& v){ makeArray(impl).set(i, v); } +void LLSD::insert(Integer i, const LLSD& v) { makeArray(impl).insert(i, v); } -LLSD& LLSD::insert(Integer i, const LLSD& v) +LLSD& LLSD::with(Integer i, const LLSD& v) { makeArray(impl).insert(i, v); - return *this; + #ifdef LL_MSVC7 + return *dynamic_cast(this); + #else + return *this; + #endif } void LLSD::append(const LLSD& v) { makeArray(impl).append(v); } void LLSD::erase(Integer i) { makeArray(impl).erase(i); } @@ -821,9 +815,15 @@ static const char *llsd_dump(const LLSD &llsd, bool useXMLFormat) { std::ostringstream out; if (useXMLFormat) - out << LLSDXMLStreamer(llsd); + { + LLSDXMLStreamer xml_streamer(llsd); + out << xml_streamer; + } else - out << LLSDNotationStreamer(llsd); + { + LLSDNotationStreamer notation_streamer(llsd); + out << notation_streamer; + } out_string = out.str(); } int len = out_string.length(); diff --git a/indra/llcommon/llsd.h b/indra/llcommon/llsd.h index 07a755567..5cfca77f8 100644 --- a/indra/llcommon/llsd.h +++ b/indra/llcommon/llsd.h @@ -226,8 +226,9 @@ public: bool has(const String&) const; LLSD get(const String&) const; - LLSD& insert(const String&, const LLSD&); + void insert(const String&, const LLSD&); void erase(const String&); + LLSD& with(const String&, const LLSD&); LLSD& operator[](const String&); LLSD& operator[](const char* c) { return (*this)[String(c)]; } @@ -241,9 +242,10 @@ public: LLSD get(Integer) const; void set(Integer, const LLSD&); - LLSD& insert(Integer, const LLSD&); + void insert(Integer, const LLSD&); void append(const LLSD&); void erase(Integer); + LLSD& with(Integer, const LLSD&); const LLSD& operator[](Integer) const; LLSD& operator[](Integer); diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index dbae679ff..7748df84f 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -734,7 +734,7 @@ void LLNotificationChannelBase::connectChanged(const LLStandardSignal::slot_type // only about new notifications for (LLNotificationSet::iterator it = mItems.begin(); it != mItems.end(); ++it) { - slot.get_slot_function()(LLSD().insert("sigtype", "load").insert("id", (*it)->id())); + slot.get_slot_function()(LLSD().with("sigtype", "load").with("id", (*it)->id())); } // and then connect the signal so that all future notifications will also be // forwarded. @@ -922,7 +922,7 @@ void LLNotificationChannel::setComparator(LLNotificationComparator comparator) mItems.swap(s2); // notify clients that we've been resorted - mChanged(LLSD().insert("sigtype", "sort")); + mChanged(LLSD().with("sigtype", "sort")); } bool LLNotificationChannel::isEmpty() const @@ -1432,7 +1432,7 @@ void LLNotifications::add(const LLNotificationPtr pNotif) llerrs << "Notification added a second time to the master notification channel." << llendl; } - updateItem(LLSD().insert("sigtype", "add").insert("id", pNotif->id()), pNotif); + updateItem(LLSD().with("sigtype", "add").with("id", pNotif->id()), pNotif); } void LLNotifications::cancel(LLNotificationPtr pNotif) @@ -1442,7 +1442,7 @@ void LLNotifications::cancel(LLNotificationPtr pNotif) { llerrs << "Attempted to delete nonexistent notification " << pNotif->getName() << llendl; } - updateItem(LLSD().insert("sigtype", "delete").insert("id", pNotif->id()), pNotif); + updateItem(LLSD().with("sigtype", "delete").with("id", pNotif->id()), pNotif); pNotif->cancel(); } @@ -1451,7 +1451,7 @@ void LLNotifications::update(const LLNotificationPtr pNotif) LLNotificationSet::iterator it=mItems.find(pNotif); if (it != mItems.end()) { - updateItem(LLSD().insert("sigtype", "change").insert("id", pNotif->id()), pNotif); + updateItem(LLSD().with("sigtype", "change").with("id", pNotif->id()), pNotif); } } diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 7df058e40..1090faf56 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -476,7 +476,7 @@ bool idle_startup() { std::string diagnostic = "Could not start address resolution system"; LL_WARNS("AppInit") << diagnostic << LL_ENDL; - LLAppViewer::instance()->earlyExit("LoginFailedNoNetwork", LLSD().insert("DIAGNOSTIC", diagnostic)); + LLAppViewer::instance()->earlyExit("LoginFailedNoNetwork", LLSD().with("DIAGNOSTIC", diagnostic)); } // @@ -536,7 +536,7 @@ bool idle_startup() { std::string diagnostic = llformat(" Error: %d", gMessageSystem->getErrorCode()); LL_WARNS("AppInit") << diagnostic << LL_ENDL; - LLAppViewer::instance()->earlyExit("LoginFailedNoNetwork", LLSD().insert("DIAGNOSTIC", diagnostic)); + LLAppViewer::instance()->earlyExit("LoginFailedNoNetwork", LLSD().with("DIAGNOSTIC", diagnostic)); } #if LL_WINDOWS @@ -559,7 +559,7 @@ bool idle_startup() } else { - LLAppViewer::instance()->earlyExit("MessageTemplateNotFound", LLSD().insert("PATH", message_template_path)); + LLAppViewer::instance()->earlyExit("MessageTemplateNotFound", LLSD().with("PATH", message_template_path)); } if(gMessageSystem && gMessageSystem->isOK())