Implement setting home position the way V3 does it, with CAP fallback

This commit is contained in:
Latif Khalifa
2012-08-16 08:00:42 +02:00
parent 95b7842e31
commit 53c7cf116c

View File

@@ -36,6 +36,7 @@
#include "llagentui.h" #include "llagentui.h"
#include "llanimationstates.h" #include "llanimationstates.h"
#include "llcallingcard.h" #include "llcallingcard.h"
#include "llcapabilitylistener.h"
#include "llconsole.h" #include "llconsole.h"
#include "llenvmanager.h" #include "llenvmanager.h"
#include "llfirstuse.h" #include "llfirstuse.h"
@@ -2157,32 +2158,6 @@ void LLAgent::setStartPosition( U32 location_id )
agent_pos.mV[VZ] = llclamp( agent_pos.mV[VZ], agent_pos.mV[VZ] = llclamp( agent_pos.mV[VZ],
mRegionp->getLandHeightRegion( agent_pos ), mRegionp->getLandHeightRegion( agent_pos ),
LLWorld::getInstance()->getRegionMaxHeight() ); LLWorld::getInstance()->getRegionMaxHeight() );
// Do we have HomeLocation capability?
std::string capURL = gAgent.getRegion()->getCapability("HomeLocation");
if ( capURL.empty() )
{
// Send UDP message about the new location
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());
}
else
{
// Send the CapReq // Send the CapReq
LLSD request; LLSD request;
LLSD body; LLSD body;
@@ -2215,7 +2190,6 @@ void LLAgent::setStartPosition( U32 location_id )
request["error"] = adapter->getErrorName(); request["error"] = adapter->getErrorName();
gAgent.getRegion()->getCapAPI().post(request); gAgent.getRegion()->getCapAPI().post(request);
}
const U32 HOME_INDEX = 1; const U32 HOME_INDEX = 1;
if( HOME_INDEX == location_id ) if( HOME_INDEX == location_id )
@@ -2224,6 +2198,33 @@ void LLAgent::setStartPosition( U32 location_id )
} }
} }
struct HomeLocationMapper: public LLCapabilityListener::CapabilityMapper
{
// No reply message expected
HomeLocationMapper(): LLCapabilityListener::CapabilityMapper("HomeLocation") {}
virtual void buildMessage(LLMessageSystem* msg,
const LLUUID& agentID,
const LLUUID& sessionID,
const std::string& capabilityName,
const LLSD& payload) const
{
msg->newMessageFast(_PREHASH_SetStartLocationRequest);
msg->nextBlockFast( _PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, agentID);
msg->addUUIDFast(_PREHASH_SessionID, sessionID);
msg->nextBlockFast( _PREHASH_StartLocationData);
// corrected by sim
msg->addStringFast(_PREHASH_SimName, "");
msg->addU32Fast(_PREHASH_LocationID, payload["HomeLocation"]["LocationId"].asInteger());
msg->addVector3Fast(_PREHASH_LocationPos,
ll_vector3_from_sdmap(payload["HomeLocation"]["LocationPos"]));
msg->addVector3Fast(_PREHASH_LocationLookAt,
ll_vector3_from_sdmap(payload["HomeLocation"]["LocationLookAt"]));
}
};
// Need an instance of this class so it will self-register
static HomeLocationMapper homeLocationMapper;
void LLAgent::requestStopMotion( LLMotion* motion ) void LLAgent::requestStopMotion( LLMotion* motion )
{ {
// Notify all avatars that a motion has stopped. // Notify all avatars that a motion has stopped.