diff options
author | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2010-03-29 10:53:22 -0400 |
---|---|---|
committer | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2010-03-29 10:53:22 -0400 |
commit | 783eb286a67e6f9ace5561073a16c9c1b7f1ade5 (patch) | |
tree | 1b4a6d5a81527202860d3cfc217c30d4e1a67880 /indra/newview/llviewermessage.cpp | |
parent | f428d62c93f2cd2817e055fce7db49410e8324d6 (diff) | |
parent | 61657d2e7904ba7274a0ab5d451669d2ee7bb7cc (diff) |
merge
Diffstat (limited to 'indra/newview/llviewermessage.cpp')
-rw-r--r-- | indra/newview/llviewermessage.cpp | 121 |
1 files changed, 101 insertions, 20 deletions
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 5f7b19a5cb..c2a78f20e1 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -51,6 +51,7 @@ #include "mean_collision_data.h" #include "llagent.h" +#include "llagentcamera.h" #include "llcallingcard.h" //#include "llfirstuse.h" #include "llfloaterbuycurrency.h" @@ -105,6 +106,7 @@ #include "llpanelplaceprofile.h" #include <boost/algorithm/string/split.hpp> // +#include <boost/regex.hpp> #if LL_WINDOWS // For Windows specific error handler #include "llwindebug.h" // For the invalid message handler @@ -272,7 +274,9 @@ void give_money(const LLUUID& uuid, LLViewerRegion* region, S32 amount, BOOL is_ } else { - LLFloaterBuyCurrency::buyCurrency(LLTrans::getString("giving"), amount); + LLStringUtil::format_map_t args; + args["AMOUNT"] = llformat("%d", amount); + LLFloaterBuyCurrency::buyCurrency(LLTrans::getString("giving", args), amount); } } @@ -1081,6 +1085,21 @@ LLOfferInfo::LLOfferInfo(const LLSD& sd) mHost = LLHost(sd["sender"].asString()); } +LLOfferInfo::LLOfferInfo(const LLOfferInfo& info) +{ + mIM = info.mIM; + mFromID = info.mFromID; + mFromGroup = info.mFromGroup; + mFromObject = info.mFromObject; + mTransactionID = info.mTransactionID; + mFolderID = info.mFolderID; + mObjectID = info.mObjectID; + mType = info.mType; + mFromName = info.mFromName; + mDesc = info.mDesc; + mHost = info.mHost; +} + LLSD LLOfferInfo::asLLSD() { LLSD sd; @@ -1572,7 +1591,11 @@ void inventory_offer_handler(LLOfferInfo* info) } else // Agent -> Agent Inventory Offer { + p.responder = info; // Note: sets inventory_offer_callback as the callback + // *TODO fix memory leak + // inventory_offer_callback() is not invoked if user received notification and + // closes viewer(without responding the notification) p.substitutions(args).payload(payload).functor.function(boost::bind(&LLOfferInfo::inventory_offer_callback, info, _1, _2)); p.name = "UserGiveItem"; @@ -2971,10 +2994,10 @@ void process_teleport_finish(LLMessageSystem* msg, void**) /* // send camera update to new region - gAgent.updateCamera(); + gAgentCamera.updateCamera(); // likewise make sure the camera is behind the avatar - gAgent.resetView(TRUE); + gAgentCamera.resetView(TRUE); LLVector3 shift_vector = regionp->getPosRegionFromGlobal(gAgent.getRegion()->getOriginGlobal()); gAgent.setRegion(regionp); gObjectList.shiftObjects(shift_vector); @@ -2982,7 +3005,7 @@ void process_teleport_finish(LLMessageSystem* msg, void**) if (gAgent.getAvatarObject()) { gAgent.getAvatarObject()->clearChatText(); - gAgent.slamLookAt(look_at); + gAgentCamera.slamLookAt(look_at); } gAgent.setPositionAgent(pos); gAssetStorage->setUpstream(sim); @@ -3061,7 +3084,7 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) std::string version_channel; msg->getString("SimData", "ChannelVersion", version_channel); - LLVOAvatar* avatarp = gAgent.getAvatarObject(); + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); if (!avatarp) { // Could happen if you were immediately god-teleported away on login, @@ -3083,7 +3106,7 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) << x << ":" << y << " current pos " << gAgent.getPositionGlobal() << LL_ENDL; - LLAppViewer::instance()->forceDisconnect("You were sent to an invalid region."); + LLAppViewer::instance()->forceDisconnect(LLTrans::getString("SentToInvalidRegion")); return; } @@ -3106,9 +3129,9 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) if( is_teleport ) { // Force the camera back onto the agent, don't animate. - gAgent.setFocusOnAvatar(TRUE, FALSE); - gAgent.slamLookAt(look_at); - gAgent.updateCamera(); + gAgentCamera.setFocusOnAvatar(TRUE, FALSE); + gAgentCamera.slamLookAt(look_at); + gAgentCamera.updateCamera(); gAgent.setTeleportState( LLAgent::TELEPORT_START_ARRIVAL ); @@ -3157,7 +3180,7 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) global_agent_pos[1] += y; look_at = (LLVector3)beacon_pos - global_agent_pos; look_at.normVec(); - gAgent.slamLookAt(look_at); + gAgentCamera.slamLookAt(look_at); } } @@ -3334,7 +3357,7 @@ void send_agent_update(BOOL force_send, BOOL send_reliable) LLQuaternion body_rotation = gAgent.getFrameAgent().getQuaternion(); LLQuaternion head_rotation = gAgent.getHeadRotation(); - camera_pos_agent = gAgent.getCameraPositionAgent(); + camera_pos_agent = gAgentCamera.getCameraPositionAgent(); render_state = gAgent.getRenderState(); @@ -3457,7 +3480,7 @@ void send_agent_update(BOOL force_send, BOOL send_reliable) 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->addF32Fast(_PREHASH_Far, gAgentCamera.mDrawDistance); msg->addU32Fast(_PREHASH_ControlFlags, control_flags); @@ -4109,7 +4132,7 @@ void process_camera_constraint(LLMessageSystem *mesgsys, void **user_data) LLVector4 cameraCollidePlane; mesgsys->getVector4Fast(_PREHASH_CameraCollidePlane, _PREHASH_Plane, cameraCollidePlane); - gAgent.setCameraCollidePlane(cameraCollidePlane); + gAgentCamera.setCameraCollidePlane(cameraCollidePlane); } void near_sit_object(BOOL success, void *data) @@ -4146,10 +4169,10 @@ void process_avatar_sit_response(LLMessageSystem *mesgsys, void **user_data) if (avatar && dist_vec_squared(camera_eye, camera_at) > 0.0001f) { - gAgent.setSitCamera(sitObjectID, camera_eye, camera_at); + gAgentCamera.setSitCamera(sitObjectID, camera_eye, camera_at); } - gAgent.setForceMouselook(force_mouselook); + gAgentCamera.setForceMouselook(force_mouselook); LLViewerObject* object = gObjectList.findObject(sitObjectID); if (object) @@ -4501,8 +4524,64 @@ void process_money_balance_reply( LLMessageSystem* msg, void** ) payload["from_id"] = from_id; LLNotificationsUtil::add("PaymentRecived", args, payload); } + //AD *HACK: Parsing incoming string to localize messages that come from server! EXT-5986 + // It's only a temporarily and ineffective measure. It doesn't affect performance much + // because we get here only for specific type of messages, but anyway it is not right to do it! + // *TODO: Server-side changes should be made and this code removed. else { + if(desc.find("You paid")==0) + { + // Regular expression for message parsing- change it in case of server-side changes. + // Each set of parenthesis will later be used to find arguments of message we generate + // in the end of this if- (.*) gives us name of money receiver, (\\d+)-amount of money we pay + // and ([^$]*)- reason of payment + boost::regex expr("You paid (?:.{0}|(.*) )L\\$(\\d+)\\s?([^$]*)\\."); + boost::match_results <std::string::const_iterator> matches; + if(boost::regex_match(desc, matches, expr)) + { + // Name of full localizable notification string + // there are three types of this string- with name of receiver and reason of payment, + // without name and without reason (but not simultaneously) + // example of string without name - You paid L$100 to create a group. + // example of string without reason - You paid Smdby Linden L$100. + // example of string with reason and name - You paid Smbdy Linden L$100 for a land access pass. + std::string line = "you_paid_ldollars_no_name"; + + // arguments of string which will be in notification + LLStringUtil::format_map_t str_args; + + // extracting amount of money paid (without L$ symbols). It is always present. + str_args["[AMOUNT]"] = std::string(matches[2]); + + // extracting name of person/group you are paying (it may be absent) + std::string name = std::string(matches[1]); + if(!name.empty()) + { + str_args["[NAME]"] = name; + line = "you_paid_ldollars"; + } + + // extracting reason of payment (it may be absent) + std::string reason = std::string(matches[3]); + if (reason.empty()) + { + line = "you_paid_ldollars_no_reason"; + } + else + { + std::string localized_reason; + // if we haven't found localized string for reason of payment leave it as it was + str_args["[REASON]"] = LLTrans::findString(localized_reason, reason) ? localized_reason : reason; + } + + // forming final message string by retrieving localized version from xml + // and applying previously found arguments + line = LLTrans::getString(line, str_args); + args["MESSAGE"] = line; + } + } + LLNotificationsUtil::add("SystemMessage", args); } @@ -5144,9 +5223,9 @@ void container_inventory_arrived(LLViewerObject* object, void* data) { LL_DEBUGS("Messaging") << "container_inventory_arrived()" << LL_ENDL; - if( gAgent.cameraMouselook() ) + if( gAgentCamera.cameraMouselook() ) { - gAgent.changeCameraToDefault(); + gAgentCamera.changeCameraToDefault(); } LLInventoryPanel *active_panel = LLInventoryPanel::getActiveInventoryPanel(); @@ -5371,13 +5450,13 @@ void process_teleport_local(LLMessageSystem *msg,void**) } gAgent.setPositionAgent(pos); - gAgent.slamLookAt(look_at); + gAgentCamera.slamLookAt(look_at); // likewise make sure the camera is behind the avatar - gAgent.resetView(TRUE, TRUE); + gAgentCamera.resetView(TRUE, TRUE); // send camera update to new region - gAgent.updateCamera(); + gAgentCamera.updateCamera(); send_agent_update(TRUE, TRUE); @@ -5489,6 +5568,8 @@ bool handle_lure_callback(const LLSD& notification, const LLSD& response) args["TO_NAME"] = target_name; LLSD payload; + + //*TODO please rewrite all keys to the same case, lower or upper payload["from_id"] = target_id; payload["SESSION_NAME"] = target_name; payload["SUPPRESS_TOAST"] = true; |