llviewermessage.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:176k
- LLUUID agent_id;
- msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
- LLUUID session_id;
- msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_SessionID, session_id);
- if((gAgent.getID() != agent_id) || (gAgent.getSessionID() != session_id))
- {
- LL_WARNS("Messaging") << "Incorrect id in process_agent_movement_complete()"
- << LL_ENDL;
- return;
- }
- LL_DEBUGS("Messaging") << "process_agent_movement_complete()" << LL_ENDL;
- // *TODO: check timestamp to make sure the movement compleation
- // makes sense.
- LLVector3 agent_pos;
- msg->getVector3Fast(_PREHASH_Data, _PREHASH_Position, agent_pos);
- LLVector3 look_at;
- msg->getVector3Fast(_PREHASH_Data, _PREHASH_LookAt, look_at);
- U64 region_handle;
- msg->getU64Fast(_PREHASH_Data, _PREHASH_RegionHandle, region_handle);
-
- std::string version_channel;
- msg->getString("SimData", "ChannelVersion", version_channel);
- LLVOAvatar* avatarp = gAgent.getAvatarObject();
- if (!avatarp)
- {
- // Could happen if you were immediately god-teleported away on login,
- // maybe other cases. Continue, but warn.
- LL_WARNS("Messaging") << "agent_movement_complete() with NULL avatarp." << LL_ENDL;
- }
- F32 x, y;
- from_region_handle(region_handle, &x, &y);
- LLViewerRegion* regionp = LLWorld::getInstance()->getRegionFromHandle(region_handle);
- if (!regionp)
- {
- if (gAgent.getRegion())
- {
- LL_WARNS("Messaging") << "current region " << gAgent.getRegion()->getOriginGlobal() << LL_ENDL;
- }
- LL_WARNS("Messaging") << "Agent being sent to invalid home region: "
- << x << ":" << y
- << " current pos " << gAgent.getPositionGlobal()
- << LL_ENDL;
- LLAppViewer::instance()->forceDisconnect("You were sent to an invalid region.");
- return;
- }
- LL_INFOS("Messaging") << "Changing home region to " << x << ":" << y << LL_ENDL;
- // set our upstream host the new simulator and shuffle things as
- // appropriate.
- LLVector3 shift_vector = regionp->getPosRegionFromGlobal(
- gAgent.getRegion()->getOriginGlobal());
- gAgent.setRegion(regionp);
- gObjectList.shiftObjects(shift_vector);
- gAssetStorage->setUpstream(msg->getSender());
- gCacheName->setUpstream(msg->getSender());
- gViewerThrottle.sendToSim();
- gViewerWindow->sendShapeToSim();
- bool is_teleport = gAgent.getTeleportState() == LLAgent::TELEPORT_MOVING;
- if( is_teleport )
- {
- // Force the camera back onto the agent, don't animate.
- gAgent.setFocusOnAvatar(TRUE, FALSE);
- gAgent.slamLookAt(look_at);
- gAgent.updateCamera();
- gAgent.setTeleportState( LLAgent::TELEPORT_START_ARRIVAL );
- // set the appearance on teleport since the new sim does not
- // know what you look like.
- gAgent.sendAgentSetAppearance();
- if (avatarp)
- {
- // Chat the "back" SLURL. (DEV-4907)
- LLSD args;
- args["MESSAGE"] = "Teleport completed from " + gAgent.getTeleportSourceSLURL();
- LLNotificationsUtil::add("SystemMessageTip", args);
- // Set the new position
- avatarp->setPositionAgent(agent_pos);
- avatarp->clearChat();
- avatarp->slamPosition();
- }
- }
- else
- {
- // This is likely just the initial logging in phase.
- gAgent.setTeleportState( LLAgent::TELEPORT_NONE );
- }
- if ( LLTracker::isTracking(NULL) )
- {
- // Check distance to beacon, if < 5m, remove beacon
- LLVector3d beacon_pos = LLTracker::getTrackedPositionGlobal();
- LLVector3 beacon_dir(agent_pos.mV[VX] - (F32)fmod(beacon_pos.mdV[VX], 256.0), agent_pos.mV[VY] - (F32)fmod(beacon_pos.mdV[VY], 256.0), 0);
- if (beacon_dir.magVecSquared() < 25.f)
- {
- LLTracker::stopTracking(NULL);
- }
- else if ( is_teleport )
- {
- //look at the beacon
- LLVector3 global_agent_pos = agent_pos;
- global_agent_pos[0] += x;
- global_agent_pos[1] += y;
- look_at = (LLVector3)beacon_pos - global_agent_pos;
- look_at.normVec();
- gAgent.slamLookAt(look_at);
- }
- }
- // TODO: Put back a check for flying status! DK 12/19/05
- // Sim tells us whether the new position is off the ground
- /*
- if (teleport_flags & TELEPORT_FLAGS_IS_FLYING)
- {
- gAgent.setFlying(TRUE);
- }
- else
- {
- gAgent.setFlying(FALSE);
- }
- */
- send_agent_update(TRUE, TRUE);
- if (gAgent.getRegion()->getBlockFly())
- {
- gAgent.setFlying(gAgent.canFly());
- }
- // force simulator to recognize busy state
- if (gAgent.getBusy())
- {
- gAgent.setBusy();
- }
- else
- {
- gAgent.clearBusy();
- }
- if (avatarp)
- {
- avatarp->mFootPlane.clearVec();
- }
-
- // send walk-vs-run status
- gAgent.sendWalkRun(gAgent.getRunning() || gAgent.getAlwaysRun());
- // If the server version has changed, display an info box and offer
- // to display the release notes, unless this is the initial log in.
- if (gLastVersionChannel == version_channel)
- {
- return;
- }
- if (!gLastVersionChannel.empty())
- {
- // work out the URL for this server's Release Notes
- std::string url ="http://wiki.secondlife.com/wiki/Release_Notes/";
- std::string server_version = version_channel;
- std::vector<std::string> s_vect;
- boost::algorithm::split(s_vect, server_version, isspace);
- for(U32 i = 0; i < s_vect.size(); i++)
- {
- if (i != (s_vect.size() - 1))
- {
- if(i != (s_vect.size() - 2))
- {
- url += s_vect[i] + "_";
- }
- else
- {
- url += s_vect[i] + "/";
- }
- }
- else
- {
- url += s_vect[i].substr(0,4);
- }
- }
- LLSD args;
- args["URL"] = url;
- LLNotificationsUtil::add("ServerVersionChanged", args);
- }
- gLastVersionChannel = version_channel;
- }
- void process_crossed_region(LLMessageSystem* msg, void**)
- {
- LLUUID agent_id;
- msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
- LLUUID session_id;
- msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_SessionID, session_id);
- if((gAgent.getID() != agent_id) || (gAgent.getSessionID() != session_id))
- {
- LL_WARNS("Messaging") << "Incorrect id in process_crossed_region()"
- << LL_ENDL;
- return;
- }
- LL_INFOS("Messaging") << "process_crossed_region()" << LL_ENDL;
- U32 sim_ip;
- msg->getIPAddrFast(_PREHASH_RegionData, _PREHASH_SimIP, sim_ip);
- U16 sim_port;
- msg->getIPPortFast(_PREHASH_RegionData, _PREHASH_SimPort, sim_port);
- LLHost sim_host(sim_ip, sim_port);
- U64 region_handle;
- msg->getU64Fast(_PREHASH_RegionData, _PREHASH_RegionHandle, region_handle);
-
- std::string seedCap;
- msg->getStringFast(_PREHASH_RegionData, _PREHASH_SeedCapability, seedCap);
- send_complete_agent_movement(sim_host);
- LLViewerRegion* regionp = LLWorld::getInstance()->addRegion(region_handle, sim_host);
- regionp->setSeedCapability(seedCap);
- }
- // Sends avatar and camera information to simulator.
- // Sent roughly once per frame, or 20 times per second, whichever is less often
- const F32 THRESHOLD_HEAD_ROT_QDOT = 0.9997f; // ~= 2.5 degrees -- if its less than this we need to update head_rot
- const F32 MAX_HEAD_ROT_QDOT = 0.99999f; // ~= 0.5 degrees -- if its greater than this then no need to update head_rot
- // between these values we delay the updates (but no more than one second)
- void send_agent_update(BOOL force_send, BOOL send_reliable)
- {
- if (gAgent.getTeleportState() != LLAgent::TELEPORT_NONE)
- {
- // We don't care if they want to send an agent update, they're not allowed to until the simulator
- // that's the target is ready to receive them (after avatar_init_complete is received)
- return;
- }
- // We have already requested to log out. Don't send agent updates.
- if(LLAppViewer::instance()->logoutRequestSent())
- {
- return;
- }
- // no region to send update to
- if(gAgent.getRegion() == NULL)
- {
- return;
- }
- const F32 TRANSLATE_THRESHOLD = 0.01f;
- // NOTA BENE: This is (intentionally?) using the small angle sine approximation to test for rotation
- // Plus, there is an extra 0.5 in the mix since the perpendicular between last_camera_at and getAtAxis() bisects cam_rot_change
- // Thus, we're actually testing against 0.2 degrees
- const F32 ROTATION_THRESHOLD = 0.1f * 2.f*F_PI/360.f; // Rotation thresh 0.2 deg, see note above
- const U8 DUP_MSGS = 1; // HACK! number of times to repeat data on motionless agent
- // Store data on last sent update so that if no changes, no send
- static LLVector3 last_camera_pos_agent,
- last_camera_at,
- last_camera_left,
- last_camera_up;
-
- static LLVector3 cam_center_chg,
- cam_rot_chg;
- static LLQuaternion last_head_rot;
- static U32 last_control_flags = 0;
- static U8 last_render_state;
- static U8 duplicate_count = 0;
- static F32 head_rot_chg = 1.0;
- static U8 last_flags;
- LLMessageSystem *msg = gMessageSystem;
- LLVector3 camera_pos_agent; // local to avatar's region
- U8 render_state;
- LLQuaternion body_rotation = gAgent.getFrameAgent().getQuaternion();
- LLQuaternion head_rotation = gAgent.getHeadRotation();
- camera_pos_agent = gAgent.getCameraPositionAgent();
- render_state = gAgent.getRenderState();
- U32 control_flag_change = 0;
- U8 flag_change = 0;
- cam_center_chg = last_camera_pos_agent - camera_pos_agent;
- cam_rot_chg = last_camera_at - LLViewerCamera::getInstance()->getAtAxis();
- // If a modifier key is held down, turn off
- // LBUTTON and ML_LBUTTON so that using the camera (alt-key) doesn't
- // trigger a control event.
- U32 control_flags = gAgent.getControlFlags();
- MASK key_mask = gKeyboard->currentMask(TRUE);
- if (key_mask & MASK_ALT || key_mask & MASK_CONTROL)
- {
- control_flags &= ~( AGENT_CONTROL_LBUTTON_DOWN |
- AGENT_CONTROL_ML_LBUTTON_DOWN );
- control_flags |= AGENT_CONTROL_LBUTTON_UP |
- AGENT_CONTROL_ML_LBUTTON_UP ;
- }
- control_flag_change = last_control_flags ^ control_flags;
- U8 flags = AU_FLAGS_NONE;
- if (gAgent.isGroupTitleHidden())
- {
- flags |= AU_FLAGS_HIDETITLE;
- }
- if (gAgent.getAutoPilot())
- {
- flags |= AU_FLAGS_CLIENT_AUTOPILOT;
- }
- flag_change = last_flags ^ flags;
- head_rot_chg = dot(last_head_rot, head_rotation);
- if (force_send ||
- (cam_center_chg.magVec() > TRANSLATE_THRESHOLD) ||
- (head_rot_chg < THRESHOLD_HEAD_ROT_QDOT) ||
- (last_render_state != render_state) ||
- (cam_rot_chg.magVec() > ROTATION_THRESHOLD) ||
- control_flag_change != 0 ||
- flag_change != 0)
- {
- /*
- if (head_rot_chg < THRESHOLD_HEAD_ROT_QDOT)
- {
- //LL_INFOS("Messaging") << "head rot " << head_rotation << LL_ENDL;
- LL_INFOS("Messaging") << "head_rot_chg = " << head_rot_chg << LL_ENDL;
- }
- if (cam_rot_chg.magVec() > ROTATION_THRESHOLD)
- {
- LL_INFOS("Messaging") << "cam rot " << cam_rot_chg.magVec() << LL_ENDL;
- }
- if (cam_center_chg.magVec() > TRANSLATE_THRESHOLD)
- {
- LL_INFOS("Messaging") << "cam center " << cam_center_chg.magVec() << LL_ENDL;
- }
- // if (drag_delta_chg.magVec() > TRANSLATE_THRESHOLD)
- // {
- // LL_INFOS("Messaging") << "drag delta " << drag_delta_chg.magVec() << LL_ENDL;
- // }
- if (control_flag_change)
- {
- LL_INFOS("Messaging") << "dcf = " << control_flag_change << LL_ENDL;
- }
- */
- duplicate_count = 0;
- }
- else
- {
- duplicate_count++;
- if (head_rot_chg < MAX_HEAD_ROT_QDOT && duplicate_count < AGENT_UPDATES_PER_SECOND)
- {
- // The head_rotation is sent for updating things like attached guns.
- // We only trigger a new update when head_rotation deviates beyond
- // some threshold from the last update, however this can break fine
- // adjustments when trying to aim an attached gun, so what we do here
- // (where we would normally skip sending an update when nothing has changed)
- // is gradually reduce the threshold to allow a better update to
- // eventually get sent... should update to within 0.5 degrees in less
- // than a second.
- if (head_rot_chg < THRESHOLD_HEAD_ROT_QDOT + (MAX_HEAD_ROT_QDOT - THRESHOLD_HEAD_ROT_QDOT) * duplicate_count / AGENT_UPDATES_PER_SECOND)
- {
- duplicate_count = 0;
- }
- else
- {
- return;
- }
- }
- else
- {
- return;
- }
- }
- if (duplicate_count < DUP_MSGS && !gDisconnected)
- {
- // Build the message
- msg->newMessageFast(_PREHASH_AgentUpdate);
- msg->nextBlockFast(_PREHASH_AgentData);
- msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- msg->addQuatFast(_PREHASH_BodyRotation, body_rotation);
- msg->addQuatFast(_PREHASH_HeadRotation, head_rotation);
- msg->addU8Fast(_PREHASH_State, render_state);
- msg->addU8Fast(_PREHASH_Flags, flags);
- // if (camera_pos_agent.mV[VY] > 255.f)
- // {
- // LL_INFOS("Messaging") << "Sending camera center " << camera_pos_agent << LL_ENDL;
- // }
-
- msg->addVector3Fast(_PREHASH_CameraCenter, camera_pos_agent);
- msg->addVector3Fast(_PREHASH_CameraAtAxis, LLViewerCamera::getInstance()->getAtAxis());
- msg->addVector3Fast(_PREHASH_CameraLeftAxis, LLViewerCamera::getInstance()->getLeftAxis());
- msg->addVector3Fast(_PREHASH_CameraUpAxis, LLViewerCamera::getInstance()->getUpAxis());
- msg->addF32Fast(_PREHASH_Far, gAgent.mDrawDistance);
-
- msg->addU32Fast(_PREHASH_ControlFlags, control_flags);
- if (gDebugClicks)
- {
- if (control_flags & AGENT_CONTROL_LBUTTON_DOWN)
- {
- LL_INFOS("Messaging") << "AgentUpdate left button down" << LL_ENDL;
- }
- if (control_flags & AGENT_CONTROL_LBUTTON_UP)
- {
- LL_INFOS("Messaging") << "AgentUpdate left button up" << LL_ENDL;
- }
- }
- gAgent.enableControlFlagReset();
- if (!send_reliable)
- {
- gAgent.sendMessage();
- }
- else
- {
- gAgent.sendReliableMessage();
- }
- // LL_DEBUGS("Messaging") << "agent " << avatar_pos_agent << " cam " << camera_pos_agent << LL_ENDL;
- // Copy the old data
- last_head_rot = head_rotation;
- last_render_state = render_state;
- last_camera_pos_agent = camera_pos_agent;
- last_camera_at = LLViewerCamera::getInstance()->getAtAxis();
- last_camera_left = LLViewerCamera::getInstance()->getLeftAxis();
- last_camera_up = LLViewerCamera::getInstance()->getUpAxis();
- last_control_flags = control_flags;
- last_flags = flags;
- }
- }
- // *TODO: Remove this dependency, or figure out a better way to handle
- // this hack.
- extern U32 gObjectBits;
- void process_object_update(LLMessageSystem *mesgsys, void **user_data)
- {
- LLMemType mt(LLMemType::MTYPE_OBJECT);
- // Update the data counters
- if (mesgsys->getReceiveCompressedSize())
- {
- gObjectBits += mesgsys->getReceiveCompressedSize() * 8;
- }
- else
- {
- gObjectBits += mesgsys->getReceiveSize() * 8;
- }
- // Update the object...
- gObjectList.processObjectUpdate(mesgsys, user_data, OUT_FULL);
- }
- void process_compressed_object_update(LLMessageSystem *mesgsys, void **user_data)
- {
- LLMemType mt(LLMemType::MTYPE_OBJECT);
- // Update the data counters
- if (mesgsys->getReceiveCompressedSize())
- {
- gObjectBits += mesgsys->getReceiveCompressedSize() * 8;
- }
- else
- {
- gObjectBits += mesgsys->getReceiveSize() * 8;
- }
- // Update the object...
- gObjectList.processCompressedObjectUpdate(mesgsys, user_data, OUT_FULL_COMPRESSED);
- }
- void process_cached_object_update(LLMessageSystem *mesgsys, void **user_data)
- {
- LLMemType mt(LLMemType::MTYPE_OBJECT);
- // Update the data counters
- if (mesgsys->getReceiveCompressedSize())
- {
- gObjectBits += mesgsys->getReceiveCompressedSize() * 8;
- }
- else
- {
- gObjectBits += mesgsys->getReceiveSize() * 8;
- }
- // Update the object...
- gObjectList.processCachedObjectUpdate(mesgsys, user_data, OUT_FULL_CACHED);
- }
- void process_terse_object_update_improved(LLMessageSystem *mesgsys, void **user_data)
- {
- LLMemType mt(LLMemType::MTYPE_OBJECT);
- if (mesgsys->getReceiveCompressedSize())
- {
- gObjectBits += mesgsys->getReceiveCompressedSize() * 8;
- }
- else
- {
- gObjectBits += mesgsys->getReceiveSize() * 8;
- }
- gObjectList.processCompressedObjectUpdate(mesgsys, user_data, OUT_TERSE_IMPROVED);
- }
- static LLFastTimer::DeclareTimer FTM_PROCESS_OBJECTS("Process Objects");
- void process_kill_object(LLMessageSystem *mesgsys, void **user_data)
- {
- LLFastTimer t(FTM_PROCESS_OBJECTS);
- LLUUID id;
- U32 local_id;
- S32 i;
- S32 num_objects;
- num_objects = mesgsys->getNumberOfBlocksFast(_PREHASH_ObjectData);
- for (i = 0; i < num_objects; i++)
- {
- mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_ID, local_id, i);
- LLViewerObjectList::getUUIDFromLocal(id,
- local_id,
- gMessageSystem->getSenderIP(),
- gMessageSystem->getSenderPort());
- if (id == LLUUID::null)
- {
- LL_DEBUGS("Messaging") << "Unknown kill for local " << local_id << LL_ENDL;
- gObjectList.mNumUnknownKills++;
- continue;
- }
- else
- {
- LL_DEBUGS("Messaging") << "Kill message for local " << local_id << LL_ENDL;
- }
- LLSelectMgr::getInstance()->removeObjectFromSelections(id);
- // ...don't kill the avatar
- if (!(id == gAgentID))
- {
- LLViewerObject *objectp = gObjectList.findObject(id);
- if (objectp)
- {
- // Display green bubble on kill
- if ( gShowObjectUpdates )
- {
- LLViewerObject* newobject;
- newobject = gObjectList.createObjectViewer(LL_PCODE_LEGACY_TEXT_BUBBLE, objectp->getRegion());
- LLVOTextBubble* bubble = (LLVOTextBubble*) newobject;
- bubble->mColor.setVec(0.f, 1.f, 0.f, 1.f);
- bubble->setScale( 2.0f * bubble->getScale() );
- bubble->setPositionGlobal(objectp->getPositionGlobal());
- gPipeline.addObject(bubble);
- }
- // Do the kill
- gObjectList.killObject(objectp);
- }
- else
- {
- LL_WARNS("Messaging") << "Object in UUID lookup, but not on object list in kill!" << LL_ENDL;
- gObjectList.mNumUnknownKills++;
- }
- }
- }
- }
- void process_time_synch(LLMessageSystem *mesgsys, void **user_data)
- {
- LLVector3 sun_direction;
- LLVector3 sun_ang_velocity;
- F32 phase;
- U64 space_time_usec;
- U32 seconds_per_day;
- U32 seconds_per_year;
- // "SimulatorViewerTimeMessage"
- mesgsys->getU64Fast(_PREHASH_TimeInfo, _PREHASH_UsecSinceStart, space_time_usec);
- mesgsys->getU32Fast(_PREHASH_TimeInfo, _PREHASH_SecPerDay, seconds_per_day);
- mesgsys->getU32Fast(_PREHASH_TimeInfo, _PREHASH_SecPerYear, seconds_per_year);
- // This should eventually be moved to an "UpdateHeavenlyBodies" message
- mesgsys->getF32Fast(_PREHASH_TimeInfo, _PREHASH_SunPhase, phase);
- mesgsys->getVector3Fast(_PREHASH_TimeInfo, _PREHASH_SunDirection, sun_direction);
- mesgsys->getVector3Fast(_PREHASH_TimeInfo, _PREHASH_SunAngVelocity, sun_ang_velocity);
- LLWorld::getInstance()->setSpaceTimeUSec(space_time_usec);
- //LL_DEBUGS("Messaging") << "time_synch() - " << sun_direction << ", " << sun_ang_velocity
- // << ", " << phase << LL_ENDL;
- gSky.setSunPhase(phase);
- gSky.setSunTargetDirection(sun_direction, sun_ang_velocity);
- if (!gNoRender && !(gSavedSettings.getBOOL("SkyOverrideSimSunPosition") || gSky.getOverrideSun()))
- {
- gSky.setSunDirection(sun_direction, sun_ang_velocity);
- }
- }
- void process_sound_trigger(LLMessageSystem *msg, void **)
- {
- if (!gAudiop) return;
- U64 region_handle = 0;
- F32 gain = 0;
- LLUUID sound_id;
- LLUUID owner_id;
- LLUUID object_id;
- LLUUID parent_id;
- LLVector3 pos_local;
- msg->getUUIDFast(_PREHASH_SoundData, _PREHASH_SoundID, sound_id);
- msg->getUUIDFast(_PREHASH_SoundData, _PREHASH_OwnerID, owner_id);
- msg->getUUIDFast(_PREHASH_SoundData, _PREHASH_ObjectID, object_id);
- msg->getUUIDFast(_PREHASH_SoundData, _PREHASH_ParentID, parent_id);
- msg->getU64Fast(_PREHASH_SoundData, _PREHASH_Handle, region_handle);
- msg->getVector3Fast(_PREHASH_SoundData, _PREHASH_Position, pos_local);
- msg->getF32Fast(_PREHASH_SoundData, _PREHASH_Gain, gain);
- // adjust sound location to true global coords
- LLVector3d pos_global = from_region_handle(region_handle);
- pos_global.mdV[VX] += pos_local.mV[VX];
- pos_global.mdV[VY] += pos_local.mV[VY];
- pos_global.mdV[VZ] += pos_local.mV[VZ];
- // Don't play a trigger sound if you can't hear it due
- // to parcel "local audio only" settings.
- if (!LLViewerParcelMgr::getInstance()->canHearSound(pos_global)) return;
- // Don't play sounds triggered by someone you muted.
- if (LLMuteList::getInstance()->isMuted(owner_id, LLMute::flagObjectSounds)) return;
-
- // Don't play sounds from an object you muted
- if (LLMuteList::getInstance()->isMuted(object_id)) return;
- // Don't play sounds from an object whose parent you muted
- if (parent_id.notNull()
- && LLMuteList::getInstance()->isMuted(parent_id))
- {
- return;
- }
- // Don't play sounds from a region with maturity above current agent maturity
- if( !gAgent.canAccessMaturityInRegion( region_handle ) )
- {
- return;
- }
-
- gAudiop->triggerSound(sound_id, owner_id, gain, LLAudioEngine::AUDIO_TYPE_SFX, pos_global);
- }
- void process_preload_sound(LLMessageSystem *msg, void **user_data)
- {
- if (!gAudiop)
- {
- return;
- }
- LLUUID sound_id;
- LLUUID object_id;
- LLUUID owner_id;
- msg->getUUIDFast(_PREHASH_DataBlock, _PREHASH_SoundID, sound_id);
- msg->getUUIDFast(_PREHASH_DataBlock, _PREHASH_ObjectID, object_id);
- msg->getUUIDFast(_PREHASH_DataBlock, _PREHASH_OwnerID, owner_id);
- LLViewerObject *objectp = gObjectList.findObject(object_id);
- if (!objectp) return;
- if (LLMuteList::getInstance()->isMuted(object_id)) return;
- if (LLMuteList::getInstance()->isMuted(owner_id, LLMute::flagObjectSounds)) return;
-
- LLAudioSource *sourcep = objectp->getAudioSource(owner_id);
- if (!sourcep) return;
-
- LLAudioData *datap = gAudiop->getAudioData(sound_id);
- // Note that I don't actually do any loading of the
- // audio data into a buffer at this point, as it won't actually
- // help us out.
- // Don't play sounds from a region with maturity above current agent maturity
- LLVector3d pos_global = objectp->getPositionGlobal();
- if( !gAgent.canAccessMaturityAtGlobal( pos_global ) )
- {
- return;
- }
-
- // Add audioData starts a transfer internally.
- sourcep->addAudioData(datap, FALSE);
- }
- void process_attached_sound(LLMessageSystem *msg, void **user_data)
- {
- F32 gain = 0;
- LLUUID sound_id;
- LLUUID object_id;
- LLUUID owner_id;
- U8 flags;
- msg->getUUIDFast(_PREHASH_DataBlock, _PREHASH_SoundID, sound_id);
- msg->getUUIDFast(_PREHASH_DataBlock, _PREHASH_ObjectID, object_id);
- msg->getUUIDFast(_PREHASH_DataBlock, _PREHASH_OwnerID, owner_id);
- msg->getF32Fast(_PREHASH_DataBlock, _PREHASH_Gain, gain);
- msg->getU8Fast(_PREHASH_DataBlock, _PREHASH_Flags, flags);
- LLViewerObject *objectp = gObjectList.findObject(object_id);
- if (!objectp)
- {
- // we don't know about this object, just bail
- return;
- }
-
- if (LLMuteList::getInstance()->isMuted(object_id)) return;
-
- if (LLMuteList::getInstance()->isMuted(owner_id, LLMute::flagObjectSounds)) return;
-
- // Don't play sounds from a region with maturity above current agent maturity
- LLVector3d pos = objectp->getPositionGlobal();
- if( !gAgent.canAccessMaturityAtGlobal(pos) )
- {
- return;
- }
-
- objectp->setAttachedSound(sound_id, owner_id, gain, flags);
- }
- void process_attached_sound_gain_change(LLMessageSystem *mesgsys, void **user_data)
- {
- F32 gain = 0;
- LLUUID object_guid;
- LLViewerObject *objectp = NULL;
- mesgsys->getUUIDFast(_PREHASH_DataBlock, _PREHASH_ObjectID, object_guid);
- if (!((objectp = gObjectList.findObject(object_guid))))
- {
- // we don't know about this object, just bail
- return;
- }
- mesgsys->getF32Fast(_PREHASH_DataBlock, _PREHASH_Gain, gain);
- objectp->adjustAudioGain(gain);
- }
- void process_health_message(LLMessageSystem *mesgsys, void **user_data)
- {
- F32 health;
- mesgsys->getF32Fast(_PREHASH_HealthData, _PREHASH_Health, health);
- if (gStatusBar)
- {
- gStatusBar->setHealth((S32)health);
- }
- }
- void process_sim_stats(LLMessageSystem *msg, void **user_data)
- {
- S32 count = msg->getNumberOfBlocks("Stat");
- for (S32 i = 0; i < count; ++i)
- {
- U32 stat_id;
- F32 stat_value;
- msg->getU32("Stat", "StatID", stat_id, i);
- msg->getF32("Stat", "StatValue", stat_value, i);
- switch (stat_id)
- {
- case LL_SIM_STAT_TIME_DILATION:
- LLViewerStats::getInstance()->mSimTimeDilation.addValue(stat_value);
- break;
- case LL_SIM_STAT_FPS:
- LLViewerStats::getInstance()->mSimFPS.addValue(stat_value);
- break;
- case LL_SIM_STAT_PHYSFPS:
- LLViewerStats::getInstance()->mSimPhysicsFPS.addValue(stat_value);
- break;
- case LL_SIM_STAT_AGENTUPS:
- LLViewerStats::getInstance()->mSimAgentUPS.addValue(stat_value);
- break;
- case LL_SIM_STAT_FRAMEMS:
- LLViewerStats::getInstance()->mSimFrameMsec.addValue(stat_value);
- break;
- case LL_SIM_STAT_NETMS:
- LLViewerStats::getInstance()->mSimNetMsec.addValue(stat_value);
- break;
- case LL_SIM_STAT_SIMOTHERMS:
- LLViewerStats::getInstance()->mSimSimOtherMsec.addValue(stat_value);
- break;
- case LL_SIM_STAT_SIMPHYSICSMS:
- LLViewerStats::getInstance()->mSimSimPhysicsMsec.addValue(stat_value);
- break;
- case LL_SIM_STAT_AGENTMS:
- LLViewerStats::getInstance()->mSimAgentMsec.addValue(stat_value);
- break;
- case LL_SIM_STAT_IMAGESMS:
- LLViewerStats::getInstance()->mSimImagesMsec.addValue(stat_value);
- break;
- case LL_SIM_STAT_SCRIPTMS:
- LLViewerStats::getInstance()->mSimScriptMsec.addValue(stat_value);
- break;
- case LL_SIM_STAT_NUMTASKS:
- LLViewerStats::getInstance()->mSimObjects.addValue(stat_value);
- break;
- case LL_SIM_STAT_NUMTASKSACTIVE:
- LLViewerStats::getInstance()->mSimActiveObjects.addValue(stat_value);
- break;
- case LL_SIM_STAT_NUMAGENTMAIN:
- LLViewerStats::getInstance()->mSimMainAgents.addValue(stat_value);
- break;
- case LL_SIM_STAT_NUMAGENTCHILD:
- LLViewerStats::getInstance()->mSimChildAgents.addValue(stat_value);
- break;
- case LL_SIM_STAT_NUMSCRIPTSACTIVE:
- LLViewerStats::getInstance()->mSimActiveScripts.addValue(stat_value);
- break;
- case LL_SIM_STAT_SCRIPT_EPS:
- LLViewerStats::getInstance()->mSimScriptEPS.addValue(stat_value);
- break;
- case LL_SIM_STAT_INPPS:
- LLViewerStats::getInstance()->mSimInPPS.addValue(stat_value);
- break;
- case LL_SIM_STAT_OUTPPS:
- LLViewerStats::getInstance()->mSimOutPPS.addValue(stat_value);
- break;
- case LL_SIM_STAT_PENDING_DOWNLOADS:
- LLViewerStats::getInstance()->mSimPendingDownloads.addValue(stat_value);
- break;
- case LL_SIM_STAT_PENDING_UPLOADS:
- LLViewerStats::getInstance()->mSimPendingUploads.addValue(stat_value);
- break;
- case LL_SIM_STAT_PENDING_LOCAL_UPLOADS:
- LLViewerStats::getInstance()->mSimPendingLocalUploads.addValue(stat_value);
- break;
- case LL_SIM_STAT_TOTAL_UNACKED_BYTES:
- LLViewerStats::getInstance()->mSimTotalUnackedBytes.addValue(stat_value / 1024.f);
- break;
- case LL_SIM_STAT_PHYSICS_PINNED_TASKS:
- LLViewerStats::getInstance()->mPhysicsPinnedTasks.addValue(stat_value);
- break;
- case LL_SIM_STAT_PHYSICS_LOD_TASKS:
- LLViewerStats::getInstance()->mPhysicsLODTasks.addValue(stat_value);
- break;
- case LL_SIM_STAT_SIMPHYSICSSTEPMS:
- LLViewerStats::getInstance()->mSimSimPhysicsStepMsec.addValue(stat_value);
- break;
- case LL_SIM_STAT_SIMPHYSICSSHAPEMS:
- LLViewerStats::getInstance()->mSimSimPhysicsShapeUpdateMsec.addValue(stat_value);
- break;
- case LL_SIM_STAT_SIMPHYSICSOTHERMS:
- LLViewerStats::getInstance()->mSimSimPhysicsOtherMsec.addValue(stat_value);
- break;
- case LL_SIM_STAT_SIMPHYSICSMEMORY:
- LLViewerStats::getInstance()->mPhysicsMemoryAllocated.addValue(stat_value);
- break;
- case LL_SIM_STAT_SIMSPARETIME:
- LLViewerStats::getInstance()->mSimSpareMsec.addValue(stat_value);
- break;
- case LL_SIM_STAT_SIMSLEEPTIME:
- LLViewerStats::getInstance()->mSimSleepMsec.addValue(stat_value);
- break;
- case LL_SIM_STAT_IOPUMPTIME:
- LLViewerStats::getInstance()->mSimPumpIOMsec.addValue(stat_value);
- break;
- default:
- // Used to be a commented out warning.
- LL_DEBUGS("Messaging") << "Unknown stat id" << stat_id << LL_ENDL;
- break;
- }
- }
- /*
- msg->getF32Fast(_PREHASH_Statistics, _PREHASH_PhysicsTimeDilation, time_dilation);
- LLViewerStats::getInstance()->mSimTDStat.addValue(time_dilation);
- // Process information
- // { CpuUsage F32 }
- // { SimMemTotal F32 }
- // { SimMemRSS F32 }
- // { ProcessUptime F32 }
- F32 cpu_usage;
- F32 sim_mem_total;
- F32 sim_mem_rss;
- F32 process_uptime;
- msg->getF32Fast(_PREHASH_Statistics, _PREHASH_CpuUsage, cpu_usage);
- msg->getF32Fast(_PREHASH_Statistics, _PREHASH_SimMemTotal, sim_mem_total);
- msg->getF32Fast(_PREHASH_Statistics, _PREHASH_SimMemRSS, sim_mem_rss);
- msg->getF32Fast(_PREHASH_Statistics, _PREHASH_ProcessUptime, process_uptime);
- LLViewerStats::getInstance()->mSimCPUUsageStat.addValue(cpu_usage);
- LLViewerStats::getInstance()->mSimMemTotalStat.addValue(sim_mem_total);
- LLViewerStats::getInstance()->mSimMemRSSStat.addValue(sim_mem_rss);
- */
- //
- // Various hacks that aren't statistics, but are being handled here.
- //
- U32 max_tasks_per_region;
- U32 region_flags;
- msg->getU32("Region", "ObjectCapacity", max_tasks_per_region);
- msg->getU32("Region", "RegionFlags", region_flags);
- LLViewerRegion* regionp = gAgent.getRegion();
- if (regionp)
- {
- BOOL was_flying = gAgent.getFlying();
- regionp->setRegionFlags(region_flags);
- regionp->setMaxTasks(max_tasks_per_region);
- // HACK: This makes agents drop from the sky if the region is
- // set to no fly while people are still in the sim.
- if (was_flying && regionp->getBlockFly())
- {
- gAgent.setFlying(gAgent.canFly());
- }
- }
- }
- void process_avatar_animation(LLMessageSystem *mesgsys, void **user_data)
- {
- LLUUID animation_id;
- LLUUID uuid;
- S32 anim_sequence_id;
- LLVOAvatar *avatarp;
-
- mesgsys->getUUIDFast(_PREHASH_Sender, _PREHASH_ID, uuid);
- //clear animation flags
- avatarp = (LLVOAvatar *)gObjectList.findObject(uuid);
- if (!avatarp)
- {
- // no agent by this ID...error?
- LL_WARNS("Messaging") << "Received animation state for unknown avatar" << uuid << LL_ENDL;
- return;
- }
- S32 num_blocks = mesgsys->getNumberOfBlocksFast(_PREHASH_AnimationList);
- S32 num_source_blocks = mesgsys->getNumberOfBlocksFast(_PREHASH_AnimationSourceList);
- avatarp->mSignaledAnimations.clear();
-
- if (avatarp->isSelf())
- {
- LLUUID object_id;
- for( S32 i = 0; i < num_blocks; i++ )
- {
- mesgsys->getUUIDFast(_PREHASH_AnimationList, _PREHASH_AnimID, animation_id, i);
- mesgsys->getS32Fast(_PREHASH_AnimationList, _PREHASH_AnimSequenceID, anim_sequence_id, i);
- LL_DEBUGS("Messaging") << "Anim sequence ID: " << anim_sequence_id << LL_ENDL;
- avatarp->mSignaledAnimations[animation_id] = anim_sequence_id;
- // *HACK: Disabling flying mode if it has been enabled shortly before the agent
- // stand up animation is signaled. In this case we don't get a signal to start
- // flying animation from server, the AGENT_CONTROL_FLY flag remains set but the
- // avatar does not play flying animation, so we switch flying mode off.
- // See LLAgent::setFlying(). This may cause "Stop Flying" button to blink.
- // See EXT-2781.
- if (animation_id == ANIM_AGENT_STANDUP && gAgent.getFlying())
- {
- gAgent.setFlying(FALSE);
- }
- if (i < num_source_blocks)
- {
- mesgsys->getUUIDFast(_PREHASH_AnimationSourceList, _PREHASH_ObjectID, object_id, i);
-
- LLViewerObject* object = gObjectList.findObject(object_id);
- if (object)
- {
- object->mFlags |= FLAGS_ANIM_SOURCE;
- BOOL anim_found = FALSE;
- LLVOAvatar::AnimSourceIterator anim_it = avatarp->mAnimationSources.find(object_id);
- for (;anim_it != avatarp->mAnimationSources.end(); ++anim_it)
- {
- if (anim_it->second == animation_id)
- {
- anim_found = TRUE;
- break;
- }
- }
- if (!anim_found)
- {
- avatarp->mAnimationSources.insert(LLVOAvatar::AnimationSourceMap::value_type(object_id, animation_id));
- }
- }
- }
- }
- }
- else
- {
- for( S32 i = 0; i < num_blocks; i++ )
- {
- mesgsys->getUUIDFast(_PREHASH_AnimationList, _PREHASH_AnimID, animation_id, i);
- mesgsys->getS32Fast(_PREHASH_AnimationList, _PREHASH_AnimSequenceID, anim_sequence_id, i);
- avatarp->mSignaledAnimations[animation_id] = anim_sequence_id;
- }
- }
- if (num_blocks)
- {
- avatarp->processAnimationStateChanges();
- }
- }
- void process_avatar_appearance(LLMessageSystem *mesgsys, void **user_data)
- {
- LLUUID uuid;
- mesgsys->getUUIDFast(_PREHASH_Sender, _PREHASH_ID, uuid);
- LLVOAvatar* avatarp = (LLVOAvatar *)gObjectList.findObject(uuid);
- if( avatarp )
- {
- avatarp->processAvatarAppearance( mesgsys );
- }
- else
- {
- LL_WARNS("Messaging") << "avatar_appearance sent for unknown avatar " << uuid << LL_ENDL;
- }
- }
- void process_camera_constraint(LLMessageSystem *mesgsys, void **user_data)
- {
- LLVector4 cameraCollidePlane;
- mesgsys->getVector4Fast(_PREHASH_CameraCollidePlane, _PREHASH_Plane, cameraCollidePlane);
- gAgent.setCameraCollidePlane(cameraCollidePlane);
- }
- void near_sit_object(BOOL success, void *data)
- {
- if (success)
- {
- // Send message to sit on object
- gMessageSystem->newMessageFast(_PREHASH_AgentSit);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- gAgent.sendReliableMessage();
- }
- }
- void process_avatar_sit_response(LLMessageSystem *mesgsys, void **user_data)
- {
- LLVector3 sitPosition;
- LLQuaternion sitRotation;
- LLUUID sitObjectID;
- BOOL use_autopilot;
- mesgsys->getUUIDFast(_PREHASH_SitObject, _PREHASH_ID, sitObjectID);
- mesgsys->getBOOLFast(_PREHASH_SitTransform, _PREHASH_AutoPilot, use_autopilot);
- mesgsys->getVector3Fast(_PREHASH_SitTransform, _PREHASH_SitPosition, sitPosition);
- mesgsys->getQuatFast(_PREHASH_SitTransform, _PREHASH_SitRotation, sitRotation);
- LLVector3 camera_eye;
- mesgsys->getVector3Fast(_PREHASH_SitTransform, _PREHASH_CameraEyeOffset, camera_eye);
- LLVector3 camera_at;
- mesgsys->getVector3Fast(_PREHASH_SitTransform, _PREHASH_CameraAtOffset, camera_at);
- BOOL force_mouselook;
- mesgsys->getBOOLFast(_PREHASH_SitTransform, _PREHASH_ForceMouselook, force_mouselook);
- LLVOAvatar* avatar = gAgent.getAvatarObject();
- if (avatar && dist_vec_squared(camera_eye, camera_at) > 0.0001f)
- {
- gAgent.setSitCamera(sitObjectID, camera_eye, camera_at);
- }
-
- gAgent.setForceMouselook(force_mouselook);
- LLViewerObject* object = gObjectList.findObject(sitObjectID);
- if (object)
- {
- LLVector3 sit_spot = object->getPositionAgent() + (sitPosition * object->getRotation());
- if (!use_autopilot || (avatar && avatar->isSitting() && avatar->getRoot() == object->getRoot()))
- {
- //we're already sitting on this object, so don't autopilot
- }
- else
- {
- gAgent.startAutoPilotGlobal(gAgent.getPosGlobalFromAgent(sit_spot), "Sit", &sitRotation, near_sit_object, NULL, 0.5f);
- }
- }
- else
- {
- LL_WARNS("Messaging") << "Received sit approval for unknown object " << sitObjectID << LL_ENDL;
- }
- }
- void process_clear_follow_cam_properties(LLMessageSystem *mesgsys, void **user_data)
- {
- LLUUID source_id;
- mesgsys->getUUIDFast(_PREHASH_ObjectData, _PREHASH_ObjectID, source_id);
- LLFollowCamMgr::removeFollowCamParams(source_id);
- }
- void process_set_follow_cam_properties(LLMessageSystem *mesgsys, void **user_data)
- {
- S32 type;
- F32 value;
- bool settingPosition = false;
- bool settingFocus = false;
- bool settingFocusOffset = false;
- LLVector3 position;
- LLVector3 focus;
- LLVector3 focus_offset;
- LLUUID source_id;
- mesgsys->getUUIDFast(_PREHASH_ObjectData, _PREHASH_ObjectID, source_id);
- LLViewerObject* objectp = gObjectList.findObject(source_id);
- if (objectp)
- {
- objectp->mFlags |= FLAGS_CAMERA_SOURCE;
- }
- S32 num_objects = mesgsys->getNumberOfBlocks("CameraProperty");
- for (S32 block_index = 0; block_index < num_objects; block_index++)
- {
- mesgsys->getS32("CameraProperty", "Type", type, block_index);
- mesgsys->getF32("CameraProperty", "Value", value, block_index);
- switch(type)
- {
- case FOLLOWCAM_PITCH:
- LLFollowCamMgr::setPitch(source_id, value);
- break;
- case FOLLOWCAM_FOCUS_OFFSET_X:
- focus_offset.mV[VX] = value;
- settingFocusOffset = true;
- break;
- case FOLLOWCAM_FOCUS_OFFSET_Y:
- focus_offset.mV[VY] = value;
- settingFocusOffset = true;
- break;
- case FOLLOWCAM_FOCUS_OFFSET_Z:
- focus_offset.mV[VZ] = value;
- settingFocusOffset = true;
- break;
- case FOLLOWCAM_POSITION_LAG:
- LLFollowCamMgr::setPositionLag(source_id, value);
- break;
- case FOLLOWCAM_FOCUS_LAG:
- LLFollowCamMgr::setFocusLag(source_id, value);
- break;
- case FOLLOWCAM_DISTANCE:
- LLFollowCamMgr::setDistance(source_id, value);
- break;
- case FOLLOWCAM_BEHINDNESS_ANGLE:
- LLFollowCamMgr::setBehindnessAngle(source_id, value);
- break;
- case FOLLOWCAM_BEHINDNESS_LAG:
- LLFollowCamMgr::setBehindnessLag(source_id, value);
- break;
- case FOLLOWCAM_POSITION_THRESHOLD:
- LLFollowCamMgr::setPositionThreshold(source_id, value);
- break;
- case FOLLOWCAM_FOCUS_THRESHOLD:
- LLFollowCamMgr::setFocusThreshold(source_id, value);
- break;
- case FOLLOWCAM_ACTIVE:
- //if 1, set using followcam,.
- LLFollowCamMgr::setCameraActive(source_id, value != 0.f);
- break;
- case FOLLOWCAM_POSITION_X:
- settingPosition = true;
- position.mV[ 0 ] = value;
- break;
- case FOLLOWCAM_POSITION_Y:
- settingPosition = true;
- position.mV[ 1 ] = value;
- break;
- case FOLLOWCAM_POSITION_Z:
- settingPosition = true;
- position.mV[ 2 ] = value;
- break;
- case FOLLOWCAM_FOCUS_X:
- settingFocus = true;
- focus.mV[ 0 ] = value;
- break;
- case FOLLOWCAM_FOCUS_Y:
- settingFocus = true;
- focus.mV[ 1 ] = value;
- break;
- case FOLLOWCAM_FOCUS_Z:
- settingFocus = true;
- focus.mV[ 2 ] = value;
- break;
- case FOLLOWCAM_POSITION_LOCKED:
- LLFollowCamMgr::setPositionLocked(source_id, value != 0.f);
- break;
- case FOLLOWCAM_FOCUS_LOCKED:
- LLFollowCamMgr::setFocusLocked(source_id, value != 0.f);
- break;
- default:
- break;
- }
- }
- if ( settingPosition )
- {
- LLFollowCamMgr::setPosition(source_id, position);
- }
- if ( settingFocus )
- {
- LLFollowCamMgr::setFocus(source_id, focus);
- }
- if ( settingFocusOffset )
- {
- LLFollowCamMgr::setFocusOffset(source_id, focus_offset);
- }
- }
- //end Ventrella
- // Culled from newsim lltask.cpp
- void process_name_value(LLMessageSystem *mesgsys, void **user_data)
- {
- std::string temp_str;
- LLUUID id;
- S32 i, num_blocks;
- mesgsys->getUUIDFast(_PREHASH_TaskData, _PREHASH_ID, id);
- LLViewerObject* object = gObjectList.findObject(id);
- if (object)
- {
- num_blocks = mesgsys->getNumberOfBlocksFast(_PREHASH_NameValueData);
- for (i = 0; i < num_blocks; i++)
- {
- mesgsys->getStringFast(_PREHASH_NameValueData, _PREHASH_NVPair, temp_str, i);
- LL_INFOS("Messaging") << "Added to object Name Value: " << temp_str << LL_ENDL;
- object->addNVPair(temp_str);
- }
- }
- else
- {
- LL_INFOS("Messaging") << "Can't find object " << id << " to add name value pair" << LL_ENDL;
- }
- }
- void process_remove_name_value(LLMessageSystem *mesgsys, void **user_data)
- {
- std::string temp_str;
- LLUUID id;
- S32 i, num_blocks;
- mesgsys->getUUIDFast(_PREHASH_TaskData, _PREHASH_ID, id);
- LLViewerObject* object = gObjectList.findObject(id);
- if (object)
- {
- num_blocks = mesgsys->getNumberOfBlocksFast(_PREHASH_NameValueData);
- for (i = 0; i < num_blocks; i++)
- {
- mesgsys->getStringFast(_PREHASH_NameValueData, _PREHASH_NVPair, temp_str, i);
- LL_INFOS("Messaging") << "Removed from object Name Value: " << temp_str << LL_ENDL;
- object->removeNVPair(temp_str);
- }
- }
- else
- {
- LL_INFOS("Messaging") << "Can't find object " << id << " to remove name value pair" << LL_ENDL;
- }
- }
- void process_kick_user(LLMessageSystem *msg, void** /*user_data*/)
- {
- std::string message;
- msg->getStringFast(_PREHASH_UserInfo, _PREHASH_Reason, message);
- LLAppViewer::instance()->forceDisconnect(message);
- }
- /*
- void process_user_list_reply(LLMessageSystem *msg, void **user_data)
- {
- LLUserList::processUserListReply(msg, user_data);
- return;
- char firstname[MAX_STRING+1];
- char lastname[MAX_STRING+1];
- U8 status;
- S32 user_count;
- user_count = msg->getNumberOfBlocks("UserBlock");
- for (S32 i = 0; i < user_count; i++)
- {
- msg->getData("UserBlock", i, "FirstName", firstname);
- msg->getData("UserBlock", i, "LastName", lastname);
- msg->getData("UserBlock", i, "Status", &status);
- if (status & 0x01)
- {
- dialog_friends_add_friend(buffer, TRUE);
- }
- else
- {
- dialog_friends_add_friend(buffer, FALSE);
- }
- }
- dialog_friends_done_adding();
- }
- */
- // this is not handled in processUpdateMessage
- /*
- void process_time_dilation(LLMessageSystem *msg, void **user_data)
- {
- // get the time_dilation
- U16 foo;
- msg->getData("TimeDilation", "TimeDilation", &foo);
- F32 time_dilation = ((F32) foo) / 65535.f;
- // get the pointer to the right region
- U32 ip = msg->getSenderIP();
- U32 port = msg->getSenderPort();
- LLViewerRegion *regionp = LLWorld::getInstance()->getRegion(ip, port);
- if (regionp)
- {
- regionp->setTimeDilation(time_dilation);
- }
- }
- */
- void process_money_balance_reply( LLMessageSystem* msg, void** )
- {
- S32 balance = 0;
- S32 credit = 0;
- S32 committed = 0;
- std::string desc;
- msg->getS32("MoneyData", "MoneyBalance", balance);
- msg->getS32("MoneyData", "SquareMetersCredit", credit);
- msg->getS32("MoneyData", "SquareMetersCommitted", committed);
- msg->getStringFast(_PREHASH_MoneyData, _PREHASH_Description, desc);
- LL_INFOS("Messaging") << "L$, credit, committed: " << balance << " " << credit << " "
- << committed << LL_ENDL;
- if (gStatusBar)
- {
- // S32 old_balance = gStatusBar->getBalance();
- // This is an update, not the first transmission of balance
- /* if (old_balance != 0)
- {
- // this is actually an update
- if (balance > old_balance)
- {
- LLFirstUse::useBalanceIncrease(balance - old_balance);
- }
- else if (balance < old_balance)
- {
- LLFirstUse::useBalanceDecrease(balance - old_balance);
- }
- }
- */
- gStatusBar->setBalance(balance);
- gStatusBar->setLandCredit(credit);
- gStatusBar->setLandCommitted(committed);
- }
- LLUUID tid;
- msg->getUUID("MoneyData", "TransactionID", tid);
- static std::deque<LLUUID> recent;
- if(!desc.empty() && gSavedSettings.getBOOL("NotifyMoneyChange")
- && (std::find(recent.rbegin(), recent.rend(), tid) == recent.rend()))
- {
- // Make the user confirm the transaction, since they might
- // have missed something during an event.
- // *TODO: Translate
- LLSD args;
- args["MESSAGE"] = desc;
- // this is a marker to retrieve avatar name from server message:
- // "<avatar name> paid you L$"
- const std::string marker = "paid you L$";
- // extract avatar name from system message
- std::string name = desc.substr(0, desc.find(marker, 0));
- LLStringUtil::trim(name);
- // if name extracted and name cache contains avatar id send loggable notification
- LLUUID from_id;
- if(name.size() > 0 && gCacheName->getUUID(name, from_id))
- {
- args["NAME"] = name;
- LLSD payload;
- payload["from_id"] = from_id;
- LLNotificationsUtil::add("PaymentRecived", args, payload);
- }
- else
- {
- LLNotificationsUtil::add("SystemMessage", args);
- }
- // Once the 'recent' container gets large enough, chop some
- // off the beginning.
- const U32 MAX_LOOKBACK = 30;
- const S32 POP_FRONT_SIZE = 12;
- if(recent.size() > MAX_LOOKBACK)
- {
- LL_DEBUGS("Messaging") << "Removing oldest transaction records" << LL_ENDL;
- recent.erase(recent.begin(), recent.begin() + POP_FRONT_SIZE);
- }
- //LL_DEBUGS("Messaging") << "Pushing back transaction " << tid << LL_ENDL;
- recent.push_back(tid);
- }
- }
- bool handle_special_notification_callback(const LLSD& notification, const LLSD& response)
- {
- S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
-
- if (0 == option)
- {
- // set the preference to the maturity of the region we're calling
- int preferredMaturity = notification["payload"]["_region_access"].asInteger();
- gSavedSettings.setU32("PreferredMaturity", preferredMaturity);
- gAgent.sendMaturityPreferenceToServer(preferredMaturity);
- }
-
- return false;
- }
- // some of the server notifications need special handling. This is where we do that.
- bool handle_special_notification(std::string notificationID, LLSD& llsdBlock)
- {
- int regionAccess = llsdBlock["_region_access"].asInteger();
- llsdBlock["REGIONMATURITY"] = LLViewerRegion::accessToString(regionAccess);
-
- // we're going to throw the LLSD in there in case anyone ever wants to use it
- LLNotificationsUtil::add(notificationID+"_Notify", llsdBlock);
-
- if (regionAccess == SIM_ACCESS_MATURE)
- {
- if (gAgent.isTeen())
- {
- LLNotificationsUtil::add(notificationID+"_KB", llsdBlock);
- return true;
- }
- else if (gAgent.prefersPG())
- {
- LLNotificationsUtil::add(notificationID+"_Change", llsdBlock, llsdBlock, handle_special_notification_callback);
- return true;
- }
- }
- else if (regionAccess == SIM_ACCESS_ADULT)
- {
- if (!gAgent.isAdult())
- {
- LLNotificationsUtil::add(notificationID+"_KB", llsdBlock);
- return true;
- }
- else if (gAgent.prefersPG() || gAgent.prefersMature())
- {
- LLNotificationsUtil::add(notificationID+"_Change", llsdBlock, llsdBlock, handle_special_notification_callback);
- return true;
- }
- }
- return false;
- }
- bool attempt_standard_notification(LLMessageSystem* msgsystem)
- {
- // if we have additional alert data
- if (msgsystem->has(_PREHASH_AlertInfo) && msgsystem->getNumberOfBlocksFast(_PREHASH_AlertInfo) > 0)
- {
- // notification was specified using the new mechanism, so we can just handle it here
- std::string notificationID;
- std::string llsdRaw;
- LLSD llsdBlock;
- msgsystem->getStringFast(_PREHASH_AlertInfo, _PREHASH_Message, notificationID);
- msgsystem->getStringFast(_PREHASH_AlertInfo, _PREHASH_ExtraParams, llsdRaw);
- if (llsdRaw.length())
- {
- std::istringstream llsdData(llsdRaw);
- if (!LLSDSerialize::deserialize(llsdBlock, llsdData, llsdRaw.length()))
- {
- llwarns << "attempt_standard_notification: Attempted to read notification parameter data into LLSD but failed:" << llsdRaw << llendl;
- }
- }
-
- if (
- (notificationID == "RegionEntryAccessBlocked") ||
- (notificationID == "LandClaimAccessBlocked") ||
- (notificationID == "LandBuyAccessBlocked")
- )
- {
- /*---------------------------------------------------------------------
- (Commented so a grep will find the notification strings, since
- we construct them on the fly; if you add additional notifications,
- please update the comment.)
-
- Could throw any of the following notifications:
-
- RegionEntryAccessBlocked
- RegionEntryAccessBlocked_Notify
- RegionEntryAccessBlocked_Change
- RegionEntryAccessBlocked_KB
- LandClaimAccessBlocked
- LandClaimAccessBlocked_Notify
- LandClaimAccessBlocked_Change
- LandClaimAccessBlocked_KB
- LandBuyAccessBlocked
- LandBuyAccessBlocked_Notify
- LandBuyAccessBlocked_Change
- LandBuyAccessBlocked_KB
-
- -----------------------------------------------------------------------*/
- if (handle_special_notification(notificationID, llsdBlock))
- {
- return true;
- }
- }
-
- LLNotificationsUtil::add(notificationID, llsdBlock);
- return true;
- }
- return false;
- }
- void process_agent_alert_message(LLMessageSystem* msgsystem, void** user_data)
- {
- // make sure the cursor is back to the usual default since the
- // alert is probably due to some kind of error.
- gViewerWindow->getWindow()->resetBusyCount();
-
- if (!attempt_standard_notification(msgsystem))
- {
- BOOL modal = FALSE;
- msgsystem->getBOOL("AlertData", "Modal", modal);
- std::string buffer;
- msgsystem->getStringFast(_PREHASH_AlertData, _PREHASH_Message, buffer);
- process_alert_core(buffer, modal);
- }
- }
- // The only difference between this routine and the previous is the fact that
- // for this routine, the modal parameter is always false. Sadly, for the message
- // handled by this routine, there is no "Modal" parameter on the message, and
- // there's no API to tell if a message has the given parameter or not.
- // So we can't handle the messages with the same handler.
- void process_alert_message(LLMessageSystem *msgsystem, void **user_data)
- {
- // make sure the cursor is back to the usual default since the
- // alert is probably due to some kind of error.
- gViewerWindow->getWindow()->resetBusyCount();
-
- if (!attempt_standard_notification(msgsystem))
- {
- BOOL modal = FALSE;
- std::string buffer;
- msgsystem->getStringFast(_PREHASH_AlertData, _PREHASH_Message, buffer);
- process_alert_core(buffer, modal);
- }
- }
- void process_alert_core(const std::string& message, BOOL modal)
- {
- // HACK -- handle callbacks for specific alerts
- if ( message == "You died and have been teleported to your home location")
- {
- LLViewerStats::getInstance()->incStat(LLViewerStats::ST_KILLED_COUNT);
- }
- else if( message == "Home position set." )
- {
- // save the home location image to disk
- std::string snap_filename = gDirUtilp->getLindenUserDir();
- snap_filename += gDirUtilp->getDirDelimiter();
- snap_filename += SCREEN_HOME_FILENAME;
- gViewerWindow->saveSnapshot(snap_filename, gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw(), FALSE, FALSE);
- }
- const std::string ALERT_PREFIX("ALERT: ");
- const std::string NOTIFY_PREFIX("NOTIFY: ");
- if (message.find(ALERT_PREFIX) == 0)
- {
- // Allow the server to spawn a named alert so that server alerts can be
- // translated out of English.
- std::string alert_name(message.substr(ALERT_PREFIX.length()));
- LLNotificationsUtil::add(alert_name);
- }
- else if (message.find(NOTIFY_PREFIX) == 0)
- {
- // Allow the server to spawn a named notification so that server notifications can be
- // translated out of English.
- std::string notify_name(message.substr(NOTIFY_PREFIX.length()));
- LLNotificationsUtil::add(notify_name);
- }
- else if (message[0] == '/')
- {
- // System message is important, show in upper-right box not tip
- std::string text(message.substr(1));
- LLSD args;
- if (text.substr(0,17) == "RESTART_X_MINUTES")
- {
- S32 mins = 0;
- LLStringUtil::convertToS32(text.substr(18), mins);
- args["MINUTES"] = llformat("%d",mins);
- LLNotificationsUtil::add("RegionRestartMinutes", args);
- }
- else if (text.substr(0,17) == "RESTART_X_SECONDS")
- {
- S32 secs = 0;
- LLStringUtil::convertToS32(text.substr(18), secs);
- args["SECONDS"] = llformat("%d",secs);
- LLNotificationsUtil::add("RegionRestartSeconds", args);
- }
- else
- {
- std::string new_msg =LLNotifications::instance().getGlobalString(text);
- args["MESSAGE"] = new_msg;
- LLNotificationsUtil::add("SystemMessage", args);
- }
- }
- else if (modal)
- {
- LLSD args;
- std::string new_msg =LLNotifications::instance().getGlobalString(message);
- args["ERROR_MESSAGE"] = new_msg;
- LLNotificationsUtil::add("ErrorMessage", args);
- }
- else
- {
- LLSD args;
- std::string new_msg =LLNotifications::instance().getGlobalString(message);
- args["MESSAGE"] = new_msg;
- LLNotificationsUtil::add("SystemMessageTip", args);
- }
- }
- mean_collision_list_t gMeanCollisionList;
- time_t gLastDisplayedTime = 0;
- void handle_show_mean_events(void *)
- {
- if (gNoRender)
- {
- return;
- }
- LLFloaterReg::showInstance("bumps");
- //LLFloaterBump::showInstance();
- }
- void mean_name_callback(const LLUUID &id, const std::string& first, const std::string& last, BOOL always_false)
- {
- if (gNoRender)
- {
- return;
- }
- static const U32 max_collision_list_size = 20;
- if (gMeanCollisionList.size() > max_collision_list_size)
- {
- mean_collision_list_t::iterator iter = gMeanCollisionList.begin();
- for (U32 i=0; i<max_collision_list_size; i++) iter++;
- for_each(iter, gMeanCollisionList.end(), DeletePointer());
- gMeanCollisionList.erase(iter, gMeanCollisionList.end());
- }
- for (mean_collision_list_t::iterator iter = gMeanCollisionList.begin();
- iter != gMeanCollisionList.end(); ++iter)
- {
- LLMeanCollisionData *mcd = *iter;
- if (mcd->mPerp == id)
- {
- mcd->mFirstName = first;
- mcd->mLastName = last;
- }
- }
- }
- void process_mean_collision_alert_message(LLMessageSystem *msgsystem, void **user_data)
- {
- if (gAgent.inPrelude())
- {
- // In prelude, bumping is OK. This dialog is rather confusing to
- // newbies, so we don't show it. Drop the packet on the floor.
- return;
- }
- // make sure the cursor is back to the usual default since the
- // alert is probably due to some kind of error.
- gViewerWindow->getWindow()->resetBusyCount();
- LLUUID perp;
- U32 time;
- U8 u8type;
- EMeanCollisionType type;
- F32 mag;
- S32 i, num = msgsystem->getNumberOfBlocks(_PREHASH_MeanCollision);
- for (i = 0; i < num; i++)
- {
- msgsystem->getUUIDFast(_PREHASH_MeanCollision, _PREHASH_Perp, perp);
- msgsystem->getU32Fast(_PREHASH_MeanCollision, _PREHASH_Time, time);
- msgsystem->getF32Fast(_PREHASH_MeanCollision, _PREHASH_Mag, mag);
- msgsystem->getU8Fast(_PREHASH_MeanCollision, _PREHASH_Type, u8type);
- type = (EMeanCollisionType)u8type;
- BOOL b_found = FALSE;
- for (mean_collision_list_t::iterator iter = gMeanCollisionList.begin();
- iter != gMeanCollisionList.end(); ++iter)
- {
- LLMeanCollisionData *mcd = *iter;
- if ((mcd->mPerp == perp) && (mcd->mType == type))
- {
- mcd->mTime = time;
- mcd->mMag = mag;
- b_found = TRUE;
- break;
- }
- }
- if (!b_found)
- {
- LLMeanCollisionData *mcd = new LLMeanCollisionData(gAgentID, perp, time, type, mag);
- gMeanCollisionList.push_front(mcd);
- const BOOL is_group = FALSE;
- gCacheName->get(perp, is_group, &mean_name_callback);
- }
- }
- }
- void process_frozen_message(LLMessageSystem *msgsystem, void **user_data)
- {
- // make sure the cursor is back to the usual default since the
- // alert is probably due to some kind of error.
- gViewerWindow->getWindow()->resetBusyCount();
- BOOL b_frozen;
-
- msgsystem->getBOOL("FrozenData", "Data", b_frozen);
- // TODO: make being frozen change view
- if (b_frozen)
- {
- }
- else
- {
- }
- }
- // do some extra stuff once we get our economy data
- void process_economy_data(LLMessageSystem *msg, void** /*user_data*/)
- {
- LLGlobalEconomy::processEconomyData(msg, LLGlobalEconomy::Singleton::getInstance());
- S32 upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
- LL_INFOS_ONCE("Messaging") << "EconomyData message arrived; upload cost is L$" << upload_cost << LL_ENDL;
- gMenuHolder->childSetLabelArg("Upload Image", "[COST]", llformat("%d", upload_cost));
- gMenuHolder->childSetLabelArg("Upload Sound", "[COST]", llformat("%d", upload_cost));
- gMenuHolder->childSetLabelArg("Upload Animation", "[COST]", llformat("%d", upload_cost));
- gMenuHolder->childSetLabelArg("Bulk Upload", "[COST]", llformat("%d", upload_cost));
- }
- void notify_cautioned_script_question(const LLSD& notification, const LLSD& response, S32 orig_questions, BOOL granted)
- {
- // only continue if at least some permissions were requested
- if (orig_questions)
- {
- // check to see if the person we are asking
- // "'[OBJECTNAME]', an object owned by '[OWNERNAME]',
- // located in [REGIONNAME] at [REGIONPOS],
- // has been <granted|denied> permission to: [PERMISSIONS]."
- LLUIString notice(LLTrans::getString(granted ? "ScriptQuestionCautionChatGranted" : "ScriptQuestionCautionChatDenied"));
- // always include the object name and owner name
- notice.setArg("[OBJECTNAME]", notification["payload"]["object_name"].asString());
- notice.setArg("[OWNERNAME]", notification["payload"]["owner_name"].asString());
- // try to lookup viewerobject that corresponds to the object that
- // requested permissions (here, taskid->requesting object id)
- BOOL foundpos = FALSE;
- LLViewerObject* viewobj = gObjectList.findObject(notification["payload"]["task_id"].asUUID());
- if (viewobj)
- {
- // found the viewerobject, get it's position in its region
- LLVector3 objpos(viewobj->getPosition());
-
- // try to lookup the name of the region the object is in
- LLViewerRegion* viewregion = viewobj->getRegion();
- if (viewregion)
- {
- // got the region, so include the region and 3d coordinates of the object
- notice.setArg("[REGIONNAME]", viewregion->getName());
- std::string formatpos = llformat("%.1f, %.1f,%.1f", objpos[VX], objpos[VY], objpos[VZ]);
- notice.setArg("[REGIONPOS]", formatpos);
- foundpos = TRUE;
- }
- }
- if (!foundpos)
- {
- // unable to determine location of the object
- notice.setArg("[REGIONNAME]", "(unknown region)");
- notice.setArg("[REGIONPOS]", "(unknown position)");
- }
- // check each permission that was requested, and list each
- // permission that has been flagged as a caution permission
- BOOL caution = FALSE;
- S32 count = 0;
- std::string perms;
- for (S32 i = 0; i < SCRIPT_PERMISSION_EOF; i++)
- {
- if ((orig_questions & LSCRIPTRunTimePermissionBits[i]) && SCRIPT_QUESTION_IS_CAUTION[i])
- {
- count++;
- caution = TRUE;
- // add a comma before the permission description if it is not the first permission
- // added to the list or the last permission to check
- if ((count > 1) && (i < SCRIPT_PERMISSION_EOF))
- {
- perms.append(", ");
- }
- perms.append(LLTrans::getString(SCRIPT_QUESTIONS[i]));
- }
- }
- notice.setArg("[PERMISSIONS]", perms);
- // log a chat message as long as at least one requested permission
- // is a caution permission
- if (caution)
- {
- LLChat chat(notice.getString());
- // LLFloaterChat::addChat(chat, FALSE, FALSE);
- }
- }
- }
- bool script_question_cb(const LLSD& notification, const LLSD& response)
- {
- S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
- LLMessageSystem *msg = gMessageSystem;
- S32 orig = notification["payload"]["questions"].asInteger();
- S32 new_questions = orig;
- // check whether permissions were granted or denied
- BOOL allowed = TRUE;
- // the "yes/accept" button is the first button in the template, making it button 0
- // if any other button was clicked, the permissions were denied
- if (option != 0)
- {
- new_questions = 0;
- allowed = FALSE;
- }
- LLUUID task_id = notification["payload"]["task_id"].asUUID();
- LLUUID item_id = notification["payload"]["item_id"].asUUID();
- // reply with the permissions granted or denied
- msg->newMessageFast(_PREHASH_ScriptAnswerYes);
- msg->nextBlockFast(_PREHASH_AgentData);
- msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- msg->nextBlockFast(_PREHASH_Data);
- msg->addUUIDFast(_PREHASH_TaskID, task_id);
- msg->addUUIDFast(_PREHASH_ItemID, item_id);
- msg->addS32Fast(_PREHASH_Questions, new_questions);
- msg->sendReliable(LLHost(notification["payload"]["sender"].asString()));
- // only log a chat message if caution prompts are enabled
- if (gSavedSettings.getBOOL("PermissionsCautionEnabled"))
- {
- // log a chat message, if appropriate
- notify_cautioned_script_question(notification, response, orig, allowed);
- }
- if ( response["Mute"] ) // mute
- {
- LLMuteList::getInstance()->add(LLMute(item_id, notification["payload"]["object_name"].asString(), LLMute::OBJECT));
- // purge the message queue of any previously queued requests from the same source. DEV-4879
- class OfferMatcher : public LLNotificationsUI::LLScreenChannel::Matcher
- {
- public:
- OfferMatcher(const LLUUID& to_block) : blocked_id(to_block) {}
- bool matches(const LLNotificationPtr notification) const
- {
- if (notification->getName() == "ScriptQuestionCaution"
- || notification->getName() == "ScriptQuestion")
- {
- return (notification->getPayload()["item_id"].asUUID() == blocked_id);
- }
- return false;
- }
- private:
- const LLUUID& blocked_id;
- };
- LLNotificationsUI::LLChannelManager::getInstance()->killToastsFromChannel(LLUUID(
- gSavedSettings.getString("NotificationChannelUUID")), OfferMatcher(item_id));
- }
- if (response["Details"])
- {
- // respawn notification...
- LLNotificationsUtil::add(notification["name"], notification["substitutions"], notification["payload"]);
- // ...with description on top
- LLNotificationsUtil::add("DebitPermissionDetails");
- }
- return false;
- }
- static LLNotificationFunctorRegistration script_question_cb_reg_1("ScriptQuestion", script_question_cb);
- static LLNotificationFunctorRegistration script_question_cb_reg_2("ScriptQuestionCaution", script_question_cb);
- void process_script_question(LLMessageSystem *msg, void **user_data)
- {
- // *TODO: Translate owner name -> [FIRST] [LAST]
- LLHost sender = msg->getSender();
- LLUUID taskid;
- LLUUID itemid;
- S32 questions;
- std::string object_name;
- std::string owner_name;
- // taskid -> object key of object requesting permissions
- msg->getUUIDFast(_PREHASH_Data, _PREHASH_TaskID, taskid );
- // itemid -> script asset key of script requesting permissions
- msg->getUUIDFast(_PREHASH_Data, _PREHASH_ItemID, itemid );
- msg->getStringFast(_PREHASH_Data, _PREHASH_ObjectName, object_name);
- msg->getStringFast(_PREHASH_Data, _PREHASH_ObjectOwner, owner_name);
- msg->getS32Fast(_PREHASH_Data, _PREHASH_Questions, questions );
- // Special case. If the objects are owned by this agent, throttle per-object instead
- // of per-owner. It's common for residents to reset a ton of scripts that re-request
- // permissions, as with tier boxes. UUIDs can't be valid agent names and vice-versa,
- // so we'll reuse the same namespace for both throttle types.
- std::string throttle_name = owner_name;
- std::string self_name;
- LLAgentUI::buildName( self_name );
- if( owner_name == self_name )
- {
- throttle_name = taskid.getString();
- }
-
- // don't display permission requests if this object is muted
- if (LLMuteList::getInstance()->isMuted(taskid)) return;
-
- // throttle excessive requests from any specific user's scripts
- typedef LLKeyThrottle<std::string> LLStringThrottle;
- static LLStringThrottle question_throttle( LLREQUEST_PERMISSION_THROTTLE_LIMIT, LLREQUEST_PERMISSION_THROTTLE_INTERVAL );
- switch (question_throttle.noteAction(throttle_name))
- {
- case LLStringThrottle::THROTTLE_NEWLY_BLOCKED:
- LL_INFOS("Messaging") << "process_script_question throttled"
- << " owner_name:" << owner_name
- << LL_ENDL;
- // Fall through
- case LLStringThrottle::THROTTLE_BLOCKED:
- // Escape altogether until we recover
- return;
- case LLStringThrottle::THROTTLE_OK:
- break;
- }
- std::string script_question;
- if (questions)
- {
- BOOL caution = FALSE;
- S32 count = 0;
- LLSD args;
- args["OBJECTNAME"] = object_name;
- args["NAME"] = owner_name;
- // check the received permission flags against each permission
- for (S32 i = 0; i < SCRIPT_PERMISSION_EOF; i++)
- {
- if (questions & LSCRIPTRunTimePermissionBits[i])
- {
- count++;
- script_question += " " + LLTrans::getString(SCRIPT_QUESTIONS[i]) + "n";
- // check whether permission question should cause special caution dialog
- caution |= (SCRIPT_QUESTION_IS_CAUTION[i]);
- }
- }
- args["QUESTIONS"] = script_question;
- LLSD payload;
- payload["task_id"] = taskid;
- payload["item_id"] = itemid;
- payload["sender"] = sender.getIPandPort();
- payload["questions"] = questions;
- payload["object_name"] = object_name;
- payload["owner_name"] = owner_name;
- // check whether cautions are even enabled or not
- if (gSavedSettings.getBOOL("PermissionsCautionEnabled"))
- {
- // display the caution permissions prompt
- LLNotificationsUtil::add(caution ? "ScriptQuestionCaution" : "ScriptQuestion", args, payload);
- }
- else
- {
- // fall back to default behavior if cautions are entirely disabled
- LLNotificationsUtil::add("ScriptQuestion", args, payload);
- }
- }
- }
- void process_derez_container(LLMessageSystem *msg, void**)
- {
- LL_WARNS("Messaging") << "call to deprecated process_derez_container" << LL_ENDL;
- }
- void container_inventory_arrived(LLViewerObject* object,
- InventoryObjectList* inventory,
- S32 serial_num,
- void* data)
- {
- LL_DEBUGS("Messaging") << "container_inventory_arrived()" << LL_ENDL;
- if( gAgent.cameraMouselook() )
- {
- gAgent.changeCameraToDefault();
- }
- LLInventoryPanel *active_panel = LLInventoryPanel::getActiveInventoryPanel();
- if (inventory->size() > 2)
- {
- // create a new inventory category to put this in
- LLUUID cat_id;
- cat_id = gInventory.createNewCategory(gInventory.getRootFolderID(),
- LLFolderType::FT_NONE,
- LLTrans::getString("AcquiredItems"));
- InventoryObjectList::const_iterator it = inventory->begin();
- InventoryObjectList::const_iterator end = inventory->end();
- for ( ; it != end; ++it)
- {
- if ((*it)->getType() != LLAssetType::AT_CATEGORY)
- {
- LLInventoryObject* obj = (LLInventoryObject*)(*it);
- LLInventoryItem* item = (LLInventoryItem*)(obj);
- LLUUID item_id;
- item_id.generate();
- time_t creation_date_utc = time_corrected();
- LLPointer<LLViewerInventoryItem> new_item
- = new LLViewerInventoryItem(item_id,
- cat_id,
- item->getPermissions(),
- item->getAssetUUID(),
- item->getType(),
- item->getInventoryType(),
- item->getName(),
- item->getDescription(),
- LLSaleInfo::DEFAULT,
- item->getFlags(),
- creation_date_utc);
- new_item->updateServer(TRUE);
- gInventory.updateItem(new_item);
- }
- }
- gInventory.notifyObservers();
- if(active_panel)
- {
- active_panel->setSelection(cat_id, TAKE_FOCUS_NO);
- }
- }
- else if (inventory->size() == 2)
- {
- // we're going to get one fake root category as well as the
- // one actual object
- InventoryObjectList::iterator it = inventory->begin();
- if ((*it)->getType() == LLAssetType::AT_CATEGORY)
- {
- ++it;
- }
- LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it));
- const LLUUID category = gInventory.findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(item->getType()));
- LLUUID item_id;
- item_id.generate();
- time_t creation_date_utc = time_corrected();
- LLPointer<LLViewerInventoryItem> new_item
- = new LLViewerInventoryItem(item_id, category,
- item->getPermissions(),
- item->getAssetUUID(),
- item->getType(),
- item->getInventoryType(),
- item->getName(),
- item->getDescription(),
- LLSaleInfo::DEFAULT,
- item->getFlags(),
- creation_date_utc);
- new_item->updateServer(TRUE);
- gInventory.updateItem(new_item);
- gInventory.notifyObservers();
- if(active_panel)
- {
- active_panel->setSelection(item_id, TAKE_FOCUS_NO);
- }
- }
- // we've got the inventory, now delete this object if this was a take
- BOOL delete_object = (BOOL)(intptr_t)data;
- LLViewerRegion *region = gAgent.getRegion();
- if (delete_object && region)
- {
- gMessageSystem->newMessageFast(_PREHASH_ObjectDelete);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- const U8 NO_FORCE = 0;
- gMessageSystem->addU8Fast(_PREHASH_Force, NO_FORCE);
- gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
- gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
- gMessageSystem->sendReliable(region->getHost());
- }
- }
- // method to format the time.
- std::string formatted_time(const time_t& the_time)
- {
- std::string dateStr = "["+LLTrans::getString("LTimeWeek")+"] ["
- +LLTrans::getString("LTimeMonth")+"] ["
- +LLTrans::getString("LTimeDay")+"] ["
- +LLTrans::getString("LTimeHour")+"]:["
- +LLTrans::getString("LTimeMin")+"]:["
- +LLTrans::getString("LTimeSec")+"] ["
- +LLTrans::getString("LTimeYear")+"]";
- LLSD substitution;
- substitution["datetime"] = (S32) the_time;
- LLStringUtil::format (dateStr, substitution);
- return dateStr;
- }
- void process_teleport_failed(LLMessageSystem *msg, void**)
- {
- std::string reason;
- std::string big_reason;
- LLSD args;
- // if we have additional alert data
- if (msg->has(_PREHASH_AlertInfo) && msg->getSizeFast(_PREHASH_AlertInfo, _PREHASH_Message) > 0)
- {
- // Get the message ID
- msg->getStringFast(_PREHASH_AlertInfo, _PREHASH_Message, reason);
- big_reason = LLAgent::sTeleportErrorMessages[reason];
- if ( big_reason.size() > 0 )
- { // Substitute verbose reason from the local map
- args["REASON"] = big_reason;
- }
- else
- { // Nothing found in the map - use what the server returned in the original message block
- msg->getStringFast(_PREHASH_Info, _PREHASH_Reason, reason);
- args["REASON"] = reason;
- }
- LLSD llsd_block;
- std::string llsd_raw;
- msg->getStringFast(_PREHASH_AlertInfo, _PREHASH_ExtraParams, llsd_raw);
- if (llsd_raw.length())
- {
- std::istringstream llsd_data(llsd_raw);
- if (!LLSDSerialize::deserialize(llsd_block, llsd_data, llsd_raw.length()))
- {
- llwarns << "process_teleport_failed: Attempted to read alert parameter data into LLSD but failed:" << llsd_raw << llendl;
- }
- else
- {
- // change notification name in this special case
- if (handle_special_notification("RegionEntryAccessBlocked", llsd_block))
- {
- if( gAgent.getTeleportState() != LLAgent::TELEPORT_NONE )
- {
- gAgent.setTeleportState( LLAgent::TELEPORT_NONE );
- }
- return;
- }
- }
- }
- }
- else
- {
- msg->getStringFast(_PREHASH_Info, _PREHASH_Reason, reason);
- big_reason = LLAgent::sTeleportErrorMessages[reason];
- if ( big_reason.size() > 0 )
- { // Substitute verbose reason from the local map
- args["REASON"] = big_reason;
- }
- else
- { // Nothing found in the map - use what the server returned
- args["REASON"] = reason;
- }
- }
- LLNotificationsUtil::add("CouldNotTeleportReason", args);
- // Let the interested parties know that teleport failed.
- LLViewerParcelMgr::getInstance()->onTeleportFailed();
- if( gAgent.getTeleportState() != LLAgent::TELEPORT_NONE )
- {
- gAgent.setTeleportState( LLAgent::TELEPORT_NONE );
- }
- }
- void process_teleport_local(LLMessageSystem *msg,void**)
- {
- LLUUID agent_id;
- msg->getUUIDFast(_PREHASH_Info, _PREHASH_AgentID, agent_id);
- if (agent_id != gAgent.getID())
- {
- LL_WARNS("Messaging") << "Got teleport notification for wrong agent!" << LL_ENDL;
- return;
- }
- U32 location_id;
- LLVector3 pos, look_at;
- U32 teleport_flags;
- msg->getU32Fast(_PREHASH_Info, _PREHASH_LocationID, location_id);
- msg->getVector3Fast(_PREHASH_Info, _PREHASH_Position, pos);
- msg->getVector3Fast(_PREHASH_Info, _PREHASH_LookAt, look_at);
- msg->getU32Fast(_PREHASH_Info, _PREHASH_TeleportFlags, teleport_flags);
- if( gAgent.getTeleportState() != LLAgent::TELEPORT_NONE )
- {
- gAgent.setTeleportState( LLAgent::TELEPORT_NONE );
- }
- // Sim tells us whether the new position is off the ground
- if (teleport_flags & TELEPORT_FLAGS_IS_FLYING)
- {
- gAgent.setFlying(TRUE);
- }
- else
- {
- gAgent.setFlying(FALSE);
- }
- gAgent.setPositionAgent(pos);
- gAgent.slamLookAt(look_at);
- // likewise make sure the camera is behind the avatar
- gAgent.resetView(TRUE, TRUE);
- // send camera update to new region
- gAgent.updateCamera();
- send_agent_update(TRUE, TRUE);
- // Let the interested parties know we've teleported.
- // Vadim *HACK: Agent position seems to get reset (to render position?)
- // on each frame, so we have to pass the new position manually.
- LLViewerParcelMgr::getInstance()->onTeleportFinished(true, gAgent.getPosGlobalFromAgent(pos));
- }
- void send_simple_im(const LLUUID& to_id,
- const std::string& message,
- EInstantMessage dialog,
- const LLUUID& id)
- {
- std::string my_name;
- LLAgentUI::buildFullname(my_name);
- send_improved_im(to_id,
- my_name,
- message,
- IM_ONLINE,
- dialog,
- id,
- NO_TIMESTAMP,
- (U8*)EMPTY_BINARY_BUCKET,
- EMPTY_BINARY_BUCKET_SIZE);
- }
- void send_group_notice(const LLUUID& group_id,
- const std::string& subject,
- const std::string& message,
- const LLInventoryItem* item)
- {
- // Put this notice into an instant message form.
- // This will mean converting the item to a binary bucket,
- // and the subject/message into a single field.
- std::string my_name;
- LLAgentUI::buildFullname(my_name);
- // Combine subject + message into a single string.
- std::ostringstream subject_and_message;
- // TODO: turn all existing |'s into ||'s in subject and message.
- subject_and_message << subject << "|" << message;
- // Create an empty binary bucket.
- U8 bin_bucket[MAX_INVENTORY_BUFFER_SIZE];
- U8* bucket_to_send = bin_bucket;
- bin_bucket[0] = ' ';
- S32 bin_bucket_size = EMPTY_BINARY_BUCKET_SIZE;
- // If there is an item being sent, pack it into the binary bucket.
- if (item)
- {
- LLSD item_def;
- item_def["item_id"] = item->getUUID();
- item_def["owner_id"] = item->getPermissions().getOwner();
- std::ostringstream ostr;
- LLSDSerialize::serialize(item_def, ostr, LLSDSerialize::LLSD_XML);
- bin_bucket_size = ostr.str().copy(
- (char*)bin_bucket, ostr.str().size());
- bin_bucket[bin_bucket_size] = ' ';
- }
- else
- {
- bucket_to_send = (U8*) EMPTY_BINARY_BUCKET;
- }
-
- send_improved_im(
- group_id,
- my_name,
- subject_and_message.str(),
- IM_ONLINE,
- IM_GROUP_NOTICE,
- LLUUID::null,
- NO_TIMESTAMP,
- bucket_to_send,
- bin_bucket_size);
- }
- bool handle_lure_callback(const LLSD& notification, const LLSD& response)
- {
- std::string text = response["message"].asString();
- text.append("rn").append(LLAgentUI::buildSLURL());
- S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
- if(0 == option)
- {
- LLMessageSystem* msg = gMessageSystem;
- msg->newMessageFast(_PREHASH_StartLure);
- msg->nextBlockFast(_PREHASH_AgentData);
- msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- msg->nextBlockFast(_PREHASH_Info);
- msg->addU8Fast(_PREHASH_LureType, (U8)0); // sim will fill this in.
- msg->addStringFast(_PREHASH_Message, text);
- for(LLSD::array_const_iterator it = notification["payload"]["ids"].beginArray();
- it != notification["payload"]["ids"].endArray();
- ++it)
- {
- LLUUID target_id = it->asUUID();
- msg->nextBlockFast(_PREHASH_TargetData);
- msg->addUUIDFast(_PREHASH_TargetID, target_id);
- // Record the offer.
- {
- std::string target_name;
- gCacheName->getFullName(target_id, target_name);
- LLSD args;
- args["TO_NAME"] = target_name;
-
- LLSD payload;
- payload["from_id"] = target_id;
- payload["SESSION_NAME"] = target_name;
- payload["SUPPRESS_TOAST"] = true;
- LLNotificationsUtil::add("TeleportOfferSent", args, payload);
- }
- }
- gAgent.sendReliableMessage();
- }
- return false;
- }
- void handle_lure(const LLUUID& invitee)
- {
- LLDynamicArray<LLUUID> ids;
- ids.push_back(invitee);
- handle_lure(ids);
- }
- // Prompt for a message to the invited user.
- void handle_lure(const std::vector<LLUUID>& ids)
- {
- LLSD edit_args;
- edit_args["REGION"] = gAgent.getRegion()->getName();
- LLSD payload;
- for (LLDynamicArray<LLUUID>::const_iterator it = ids.begin();
- it != ids.end();
- ++it)
- {
- payload["ids"].append(*it);
- }
- if (gAgent.isGodlike())
- {
- LLNotificationsUtil::add("OfferTeleportFromGod", edit_args, payload, handle_lure_callback);
- }
- else
- {
- LLNotificationsUtil::add("OfferTeleport", edit_args, payload, handle_lure_callback);
- }
- }
- void send_improved_im(const LLUUID& to_id,
- const std::string& name,
- const std::string& message,
- U8 offline,
- EInstantMessage dialog,
- const LLUUID& id,
- U32 timestamp,
- const U8* binary_bucket,
- S32 binary_bucket_size)
- {
- pack_instant_message(
- gMessageSystem,
- gAgent.getID(),
- FALSE,
- gAgent.getSessionID(),
- to_id,
- name,
- message,
- offline,
- dialog,
- id,
- 0,
- LLUUID::null,
- gAgent.getPositionAgent(),
- timestamp,
- binary_bucket,
- binary_bucket_size);
- gAgent.sendReliableMessage();
- }
- void send_places_query(const LLUUID& query_id,
- const LLUUID& trans_id,
- const std::string& query_text,
- U32 query_flags,
- S32 category,
- const std::string& sim_name)
- {
- LLMessageSystem* msg = gMessageSystem;
- msg->newMessage("PlacesQuery");
- msg->nextBlock("AgentData");
- msg->addUUID("AgentID", gAgent.getID());
- msg->addUUID("SessionID", gAgent.getSessionID());
- msg->addUUID("QueryID", query_id);
- msg->nextBlock("TransactionData");
- msg->addUUID("TransactionID", trans_id);
- msg->nextBlock("QueryData");
- msg->addString("QueryText", query_text);
- msg->addU32("QueryFlags", query_flags);
- msg->addS8("Category", (S8)category);
- msg->addString("SimName", sim_name);
- gAgent.sendReliableMessage();
- }
- void process_user_info_reply(LLMessageSystem* msg, void**)
- {
- LLUUID agent_id;
- msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
- if(agent_id != gAgent.getID())
- {
- LL_WARNS("Messaging") << "process_user_info_reply - "
- << "wrong agent id." << LL_ENDL;
- }
-
- BOOL im_via_email;
- msg->getBOOLFast(_PREHASH_UserData, _PREHASH_IMViaEMail, im_via_email);
- std::string email;
- msg->getStringFast(_PREHASH_UserData, _PREHASH_EMail, email);
- std::string dir_visibility;
- msg->getString( "UserData", "DirectoryVisibility", dir_visibility);
- LLFloaterPreference::updateUserInfo(dir_visibility, im_via_email, email);
- LLFloaterPostcard::updateUserInfo(email);
- }
- //---------------------------------------------------------------------------
- // Script Dialog
- //---------------------------------------------------------------------------
- const S32 SCRIPT_DIALOG_MAX_BUTTONS = 12;
- const S32 SCRIPT_DIALOG_BUTTON_STR_SIZE = 24;
- const S32 SCRIPT_DIALOG_MAX_MESSAGE_SIZE = 512;
- const char* SCRIPT_DIALOG_HEADER = "Script Dialog:n";
- bool callback_script_dialog(const LLSD& notification, const LLSD& response)
- {
- LLNotificationForm form(notification["form"]);
- std::string button = LLNotification::getSelectedOptionName(response);
- S32 button_idx = LLNotification::getSelectedOption(notification, response);
- // Didn't click "Ignore"
- if (button_idx != -1)
- {
- LLMessageSystem* msg = gMessageSystem;
- msg->newMessage("ScriptDialogReply");
- msg->nextBlock("AgentData");
- msg->addUUID("AgentID", gAgent.getID());
- msg->addUUID("SessionID", gAgent.getSessionID());
- msg->nextBlock("Data");
- msg->addUUID("ObjectID", notification["payload"]["object_id"].asUUID());
- msg->addS32("ChatChannel", notification["payload"]["chat_channel"].asInteger());
- msg->addS32("ButtonIndex", button_idx);
- msg->addString("ButtonLabel", button);
- msg->sendReliable(LLHost(notification["payload"]["sender"].asString()));
- }
- return false;
- }
- static LLNotificationFunctorRegistration callback_script_dialog_reg_1("ScriptDialog", callback_script_dialog);
- static LLNotificationFunctorRegistration callback_script_dialog_reg_2("ScriptDialogGroup", callback_script_dialog);
- void process_script_dialog(LLMessageSystem* msg, void**)
- {
- S32 i;
- LLSD payload;
- LLUUID object_id;
- msg->getUUID("Data", "ObjectID", object_id);
- if (LLMuteList::getInstance()->isMuted(object_id))
- {
- return;
- }
- std::string message;
- std::string first_name;
- std::string last_name;
- std::string title;
- S32 chat_channel;
- msg->getString("Data", "FirstName", first_name);
- msg->getString("Data", "LastName", last_name);
- msg->getString("Data", "ObjectName", title);
- msg->getString("Data", "Message", message);
- msg->getS32("Data", "ChatChannel", chat_channel);
- // unused for now
- LLUUID image_id;
- msg->getUUID("Data", "ImageID", image_id);
- payload["sender"] = msg->getSender().getIPandPort();
- payload["object_id"] = object_id;
- payload["chat_channel"] = chat_channel;
- // build up custom form
- S32 button_count = msg->getNumberOfBlocks("Buttons");
- if (button_count > SCRIPT_DIALOG_MAX_BUTTONS)
- {
- llwarns << "Too many script dialog buttons - omitting some" << llendl;
- button_count = SCRIPT_DIALOG_MAX_BUTTONS;
- }
- LLNotificationForm form;
- for (i = 0; i < button_count; i++)
- {
- std::string tdesc;
- msg->getString("Buttons", "ButtonLabel", tdesc, i);
- form.addElement("button", std::string(tdesc));
- }
- LLSD args;
- args["TITLE"] = title;
- args["MESSAGE"] = message;
- LLNotificationPtr notification;
- if (!first_name.empty())
- {
- args["FIRST"] = first_name;
- args["LAST"] = last_name;
- notification = LLNotifications::instance().add(
- LLNotification::Params("ScriptDialog").substitutions(args).payload(payload).form_elements(form.asLLSD()));
- }
- else
- {
- args["GROUPNAME"] = last_name;
- notification = LLNotifications::instance().add(
- LLNotification::Params("ScriptDialogGroup").substitutions(args).payload(payload).form_elements(form.asLLSD()));
- }
- }
- //---------------------------------------------------------------------------
- std::vector<LLSD> gLoadUrlList;
- bool callback_load_url(const LLSD& notification, const LLSD& response)
- {
- S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
- if (0 == option)
- {
- LLWeb::loadURL(notification["payload"]["url"].asString());
- }
- return false;
- }
- static LLNotificationFunctorRegistration callback_load_url_reg("LoadWebPage", callback_load_url);
- // We've got the name of the person who owns the object hurling the url.
- // Display confirmation dialog.
- void callback_load_url_name(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group)
- {
- std::vector<LLSD>::iterator it;
- for (it = gLoadUrlList.begin(); it != gLoadUrlList.end(); )
- {
- LLSD load_url_info = *it;
- if (load_url_info["owner_id"].asUUID() == id)
- {
- it = gLoadUrlList.erase(it);
- std::string owner_name;
- if (is_group)
- {
- owner_name = first + LLTrans::getString("Group");
- }
- else
- {
- owner_name = first + " " + last;
- }
- // For legacy name-only mutes.
- if (LLMuteList::getInstance()->isMuted(LLUUID::null, owner_name))
- {
- continue;
- }
- LLSD args;
- args["URL"] = load_url_info["url"].asString();
- args["MESSAGE"] = load_url_info["message"].asString();;
- args["OBJECTNAME"] = load_url_info["object_name"].asString();
- args["NAME"] = owner_name;
- LLNotificationsUtil::add("LoadWebPage", args, load_url_info);
- }
- else
- {
- ++it;
- }
- }
- }
- void process_load_url(LLMessageSystem* msg, void**)
- {
- LLUUID object_id;
- LLUUID owner_id;
- BOOL owner_is_group;
- char object_name[256]; /* Flawfinder: ignore */
- char message[256]; /* Flawfinder: ignore */
- char url[256]; /* Flawfinder: ignore */
- msg->getString("Data", "ObjectName", 256, object_name);
- msg->getUUID( "Data", "ObjectID", object_id);
- msg->getUUID( "Data", "OwnerID", owner_id);
- msg->getBOOL( "Data", "OwnerIsGroup", owner_is_group);
- msg->getString("Data", "Message", 256, message);
- msg->getString("Data", "URL", 256, url);
- LLSD payload;
- payload["object_id"] = object_id;
- payload["owner_id"] = owner_id;
- payload["owner_is_group"] = owner_is_group;
- payload["object_name"] = object_name;
- payload["message"] = message;
- payload["url"] = url;
- // URL is safety checked in load_url above
- // Check if object or owner is muted
- if (LLMuteList::getInstance()->isMuted(object_id, object_name) ||
- LLMuteList::getInstance()->isMuted(owner_id))
- {
- LL_INFOS("Messaging")<<"Ignoring load_url from muted object/owner."<<LL_ENDL;
- return;
- }
- // Add to list of pending name lookups
- gLoadUrlList.push_back(payload);
- gCacheName->get(owner_id, owner_is_group, &callback_load_url_name);
- }
- void callback_download_complete(void** data, S32 result, LLExtStat ext_status)
- {
- std::string* filepath = (std::string*)data;
- LLSD args;
- args["DOWNLOAD_PATH"] = *filepath;
- LLNotificationsUtil::add("FinishedRawDownload", args);
- delete filepath;
- }
- void process_initiate_download(LLMessageSystem* msg, void**)
- {
- LLUUID agent_id;
- msg->getUUID("AgentData", "AgentID", agent_id);
- if (agent_id != gAgent.getID())
- {
- LL_WARNS("Messaging") << "Initiate download for wrong agent" << LL_ENDL;
- return;
- }
- std::string sim_filename;
- std::string viewer_filename;
- msg->getString("FileData", "SimFilename", sim_filename);
- msg->getString("FileData", "ViewerFilename", viewer_filename);
- if (!gXferManager->validateFileForRequest(viewer_filename))
- {
- llwarns << "SECURITY: Unauthorized download to local file " << viewer_filename << llendl;
- return;
- }
- gXferManager->requestFile(viewer_filename,
- sim_filename,
- LL_PATH_NONE,
- msg->getSender(),
- FALSE, // don't delete remote
- callback_download_complete,
- (void**)new std::string(viewer_filename));
- }
- void process_script_teleport_request(LLMessageSystem* msg, void**)
- {
- std::string object_name;
- std::string sim_name;
- LLVector3 pos;
- LLVector3 look_at;
- msg->getString("Data", "ObjectName", object_name);
- msg->getString("Data", "SimName", sim_name);
- msg->getVector3("Data", "SimPosition", pos);
- msg->getVector3("Data", "LookAt", look_at);
- LLFloaterWorldMap* instance = LLFloaterWorldMap::getInstance();
- if(instance)
- {
- instance->trackURL(
- sim_name, (S32)pos.mV[VX], (S32)pos.mV[VY], (S32)pos.mV[VZ]);
- LLFloaterReg::showInstance("world_map", "center");
- }
-
- // remove above two lines and replace with below line
- // to re-enable parcel browser for llMapDestination()
- // LLURLDispatcher::dispatch(LLSLURL::buildSLURL(sim_name, (S32)pos.mV[VX], (S32)pos.mV[VY], (S32)pos.mV[VZ]), FALSE);
-
- }
- void process_covenant_reply(LLMessageSystem* msg, void**)
- {
- LLUUID covenant_id, estate_owner_id;
- std::string estate_name;
- U32 covenant_timestamp;
- msg->getUUID("Data", "CovenantID", covenant_id);
- msg->getU32("Data", "CovenantTimestamp", covenant_timestamp);
- msg->getString("Data", "EstateName", estate_name);
- msg->getUUID("Data", "EstateOwnerID", estate_owner_id);
- LLPanelEstateCovenant::updateEstateName(estate_name);
- LLPanelLandCovenant::updateEstateName(estate_name);
- LLFloaterBuyLand::updateEstateName(estate_name);
- std::string owner_name =
- LLSLURL::buildCommand("agent", estate_owner_id, "inspect");
- LLPanelEstateCovenant::updateEstateOwnerName(owner_name);
- LLPanelLandCovenant::updateEstateOwnerName(owner_name);
- LLFloaterBuyLand::updateEstateOwnerName(owner_name);
- LLPanelPlaceProfile* panel = LLSideTray::getInstance()->findChild<LLPanelPlaceProfile>("panel_place_profile");
- if (panel)
- {
- panel->updateEstateName(estate_name);
- panel->updateEstateOwnerName(owner_name);
- }
- // standard message, not from system
- std::string last_modified;
- if (covenant_timestamp == 0)
- {
- last_modified = LLTrans::getString("covenant_last_modified")+LLTrans::getString("never_text");
- }
- else
- {
- last_modified = LLTrans::getString("covenant_last_modified")+"["
- +LLTrans::getString("LTimeWeek")+"] ["
- +LLTrans::getString("LTimeMonth")+"] ["
- +LLTrans::getString("LTimeDay")+"] ["
- +LLTrans::getString("LTimeHour")+"]:["
- +LLTrans::getString("LTimeMin")+"]:["
- +LLTrans::getString("LTimeSec")+"] ["
- +LLTrans::getString("LTimeYear")+"]";
- LLSD substitution;
- substitution["datetime"] = (S32) covenant_timestamp;
- LLStringUtil::format (last_modified, substitution);
- }
- LLPanelEstateCovenant::updateLastModified(last_modified);
- LLPanelLandCovenant::updateLastModified(last_modified);
- LLFloaterBuyLand::updateLastModified(last_modified);
- // load the actual covenant asset data
- const BOOL high_priority = TRUE;
- if (covenant_id.notNull())
- {
- gAssetStorage->getEstateAsset(gAgent.getRegionHost(),
- gAgent.getID(),
- gAgent.getSessionID(),
- covenant_id,
- LLAssetType::AT_NOTECARD,
- ET_Covenant,
- onCovenantLoadComplete,
- NULL,
- high_priority);
- }
- else
- {
- std::string covenant_text;
- if (estate_owner_id.isNull())
- {
- // mainland
- covenant_text = LLTrans::getString("RegionNoCovenant");
- }
- else
- {
- covenant_text = LLTrans::getString("RegionNoCovenantOtherOwner");
- }
- LLPanelEstateCovenant::updateCovenantText(covenant_text, covenant_id);
- LLPanelLandCovenant::updateCovenantText(covenant_text);
- LLFloaterBuyLand::updateCovenantText(covenant_text, covenant_id);
- if (panel)
- {
- panel->updateCovenantText(covenant_text);
- }
- }
- }
- void onCovenantLoadComplete(LLVFS *vfs,
- const LLUUID& asset_uuid,
- LLAssetType::EType type,
- void* user_data, S32 status, LLExtStat ext_status)
- {
- LL_DEBUGS("Messaging") << "onCovenantLoadComplete()" << LL_ENDL;
- std::string covenant_text;
- if(0 == status)
- {
- LLVFile file(vfs, asset_uuid, type, LLVFile::READ);
-
- S32 file_length = file.getSize();
-
- std::vector<char> buffer(file_length+1);
- file.read((U8*)&buffer[0], file_length);
- // put a EOS at the end
- buffer[file_length] = ' ';
-
- if( (file_length > 19) && !strncmp( &buffer[0], "Linden text version", 19 ) )
- {
- LLViewerTextEditor::Params params;
- params.name("temp");
- params.max_text_length(file_length+1);
- LLViewerTextEditor * editor = LLUICtrlFactory::create<LLViewerTextEditor> (params);
- if( !editor->importBuffer( &buffer[0], file_length+1 ) )
- {
- LL_WARNS("Messaging") << "Problem importing estate covenant." << LL_ENDL;
- covenant_text = "Problem importing estate covenant.";
- }
- else
- {
- // Version 0 (just text, doesn't include version number)
- covenant_text = editor->getText();
- }
- delete editor;
- }
- else
- {
- LL_WARNS("Messaging") << "Problem importing estate covenant: Covenant file format error." << LL_ENDL;
- covenant_text = "Problem importing estate covenant: Covenant file format error.";
- }
- }
- else
- {
- LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
-
- if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ||
- LL_ERR_FILE_EMPTY == status)
- {
- covenant_text = "Estate covenant notecard is missing from database.";
- }
- else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status)
- {
- covenant_text = "Insufficient permissions to view estate covenant.";
- }
- else
- {
- covenant_text = "Unable to load estate covenant at this time.";
- }
-
- LL_WARNS("Messaging") << "Problem loading notecard: " << status << LL_ENDL;
- }
- LLPanelEstateCovenant::updateCovenantText(covenant_text, asset_uuid);
- LLPanelLandCovenant::updateCovenantText(covenant_text);
- LLFloaterBuyLand::updateCovenantText(covenant_text, asset_uuid);
- LLPanelPlaceProfile* panel = LLSideTray::getInstance()->findChild<LLPanelPlaceProfile>("panel_place_profile");
- if (panel)
- {
- panel->updateCovenantText(covenant_text);
- }
- }
- void process_feature_disabled_message(LLMessageSystem* msg, void**)
- {
- // Handle Blacklisted feature simulator response...
- LLUUID agentID;
- LLUUID transactionID;
- std::string messageText;
- msg->getStringFast(_PREHASH_FailureInfo,_PREHASH_ErrorMessage, messageText,0);
- msg->getUUIDFast(_PREHASH_FailureInfo,_PREHASH_AgentID,agentID);
- msg->getUUIDFast(_PREHASH_FailureInfo,_PREHASH_TransactionID,transactionID);
-
- LL_WARNS("Messaging") << "Blacklisted Feature Response:" << messageText << LL_ENDL;
- }
- // ------------------------------------------------------------
- // Message system exception callbacks
- // ------------------------------------------------------------
- void invalid_message_callback(LLMessageSystem* msg,
- void*,
- EMessageException exception)
- {
- LLAppViewer::instance()->badNetworkHandler();
- }
- // Please do not add more message handlers here. This file is huge.
- // Put them in a file related to the functionality you are implementing.
- void LLOfferInfo::forceResponse(InventoryOfferResponse response)
- {
- LLNotification::Params params("UserGiveItem");
- params.functor.function(boost::bind(&LLOfferInfo::inventory_offer_callback, this, _1, _2));
- LLNotifications::instance().forceResponse(params, response);
- }