diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 3685fb92a..b618efa72 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -57,6 +57,7 @@ #include "llnotificationsutil.h" #include "llparcel.h" #include "llrendersphere.h" +#include "llsdmessage.h" #include "llsdutil.h" #include "llsky.h" #include "llsmoothstep.h" @@ -2105,11 +2106,15 @@ LLVector3 ll_vector3_from_sdmap(const LLSD& sd) void LLAgent::setStartPosition( U32 location_id ) { + LLViewerObject *object; + if (gAgentID == LLUUID::null) { return; } - if (gObjectList.findAvatar(gAgentID) == NULL) + // we've got an ID for an agent viewerobject + object = gObjectList.findObject(gAgentID); + if (! object) { llinfos << "setStartPosition - Can't find agent viewerobject id " << gAgentID << llendl; return; @@ -2126,7 +2131,7 @@ void LLAgent::setStartPosition( U32 location_id ) if (isAgentAvatarValid()) { // the z height is at the agent's feet - agent_pos.mV[VZ] -= 0.5f * gAgentAvatarp->mBodySize.mV[VZ]; + agent_pos.mV[VZ] -= 0.5f * gAgentAvatarp->mBodySize.mV[VZ]; } agent_pos.mV[VX] = llclamp( agent_pos.mV[VX], INSET, REGION_WIDTH - INSET ); @@ -2136,46 +2141,44 @@ void LLAgent::setStartPosition( U32 location_id ) agent_pos.mV[VZ] = llclamp( agent_pos.mV[VZ], mRegionp->getLandHeightRegion( agent_pos ), LLWorld::getInstance()->getRegionMaxHeight() ); - std::string url = gAgent.getRegion()->getCapability("HomeLocation"); - if( !url.empty() ) - { - // Send the CapReq - LLSD request; - LLSD body; - LLSD homeLocation; + // Send the CapReq + LLSD request; + LLSD body; + LLSD homeLocation; - homeLocation["LocationId"] = LLSD::Integer(location_id); - homeLocation["LocationPos"] = ll_sdmap_from_vector3(agent_pos); - homeLocation["LocationLookAt"] = ll_sdmap_from_vector3(mFrameAgent.getAtAxis()); + homeLocation["LocationId"] = LLSD::Integer(location_id); + homeLocation["LocationPos"] = ll_sdmap_from_vector3(agent_pos); + homeLocation["LocationLookAt"] = ll_sdmap_from_vector3(mFrameAgent.getAtAxis()); - body["HomeLocation"] = homeLocation; + body["HomeLocation"] = homeLocation; - LLHTTPClient::post( url, body, new LLHomeLocationResponder() ); - } - else - { - LLMessageSystem* msg = gMessageSystem; - msg->newMessageFast(_PREHASH_SetStartLocationRequest); - msg->nextBlockFast( _PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, getID()); - msg->addUUIDFast(_PREHASH_SessionID, getSessionID()); - msg->nextBlockFast( _PREHASH_StartLocationData); - // corrected by sim - msg->addStringFast(_PREHASH_SimName, ""); - msg->addU32Fast(_PREHASH_LocationID, location_id); - msg->addVector3Fast(_PREHASH_LocationPos, agent_pos); - msg->addVector3Fast(_PREHASH_LocationLookAt,mFrameAgent.getAtAxis()); - - // Reliable only helps when setting home location. Last - // location is sent on quit, and we don't have time to ack - // the packets. - msg->sendReliable(mRegionp->getHost()); - } - const U32 HOME_INDEX = 1; - if( HOME_INDEX == location_id ) - { - setHomePosRegion( mRegionp->getHandle(), getPositionAgent() ); - } + // This awkward idiom warrants explanation. + // For starters, LLSDMessage::ResponderAdapter is ONLY for testing the new + // LLSDMessage functionality with a pre-existing LLHTTPClient::Responder. + // In new code, define your reply/error methods on the same class as the + // sending method, bind them to local LLEventPump objects and pass those + // LLEventPump names in the request LLSD object. + // When testing old code, the new LLHomeLocationResponder object + // is referenced by an LLHTTPClient::ResponderPtr, so when the + // ResponderAdapter is deleted, the LLHomeLocationResponder will be too. + // We must trust that the underlying LLHTTPClient code will eventually + // fire either the reply callback or the error callback; either will cause + // the ResponderAdapter to delete itself. + LLSDMessage::ResponderAdapter* + adapter(new LLSDMessage::ResponderAdapter(new LLHomeLocationResponder())); + + request["message"] = "HomeLocation"; + request["payload"] = body; + request["reply"] = adapter->getReplyName(); + request["error"] = adapter->getErrorName(); + + gAgent.getRegion()->getCapAPI().post(request); + + const U32 HOME_INDEX = 1; + if( HOME_INDEX == location_id ) + { + setHomePosRegion( mRegionp->getHandle(), getPositionAgent() ); + } } void LLAgent::requestStopMotion( LLMotion* motion ) diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 60491e952..667b31fad 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -911,7 +911,11 @@ public: } }; -void copy_inventory_from_notecard(const LLUUID& object_id, const LLUUID& notecard_inv_id, const LLInventoryItem *src, U32 callback_id) +void copy_inventory_from_notecard(/* V3: const LLUUID& destination_id, */ + const LLUUID& object_id, + const LLUUID& notecard_inv_id, + const LLInventoryItem *src, + U32 callback_id) { if (NULL == src) { @@ -930,7 +934,7 @@ void copy_inventory_from_notecard(const LLUUID& object_id, const LLUUID& notecar // Fallback to the agents region if for some reason the // object isn't found in the viewer. - if(!viewer_region) + if (! viewer_region) { viewer_region = gAgent.getRegion(); } @@ -958,9 +962,13 @@ void copy_inventory_from_notecard(const LLUUID& object_id, const LLUUID& notecar body["object-id"] = object_id; body["item-id"] = src->getUUID(); body["folder-id"] = gInventory.findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(src->getType())); + // V3: body["folder-id"] = destination_id; body["callback-id"] = (LLSD::Integer)callback_id; - LLHTTPClient::post(url, body, new LLCopyInventoryFromNotecardResponder()); + request["message"] = "CopyInventoryFromNotecard"; + request["payload"] = body; + + viewer_region->getCapAPI().post(request); }