* Converters from new AvatarData to old AvatarAppearance and vice-versa

* Login now retrieves AvatarData from AvatarService and sends it off with the agent data
slimupdates
Diva Canto 2010-01-02 16:26:40 -08:00
parent 28702f585f
commit 6da6b8d9c5
2 changed files with 117 additions and 9 deletions

View File

@ -26,6 +26,7 @@
*/
using System;
using System.Collections;
using System.Collections.Generic;
using OpenSim.Framework;
@ -93,7 +94,16 @@ namespace OpenSim.Services.Interfaces
public AvatarData(Dictionary<string, object> kvp)
{
// TODO
Data = new Dictionary<string, string>();
if (kvp.ContainsKey("AvatarType"))
Int32.TryParse(kvp["AvatarType"].ToString(), out AvatarType);
foreach (KeyValuePair<string, object> _kvp in kvp)
{
if (_kvp.Value != null)
Data[_kvp.Key] = _kvp.Value.ToString();
}
}
/// <summary>
@ -101,7 +111,90 @@ namespace OpenSim.Services.Interfaces
/// <returns></returns>
public Dictionary<string, object> ToKeyValuePairs()
{
Dictionary<string, object> result = new Dictionary<string, object>();
result["AvatarType"] = AvatarType.ToString();
foreach (KeyValuePair<string, string> _kvp in Data)
{
if (_kvp.Value != null)
result[_kvp.Key] = _kvp.Value;
}
return null;
}
public AvatarData(AvatarAppearance appearance)
{
AvatarType = 1; // SL avatars
Data = new Dictionary<string, string>();
// Wearables
Data["AvatarHeight"] = appearance.AvatarHeight.ToString();
Data["BodyItem"] = appearance.BodyItem.ToString();
Data["EyesItem"] = appearance.EyesItem.ToString();
Data["GlovesItem"] = appearance.GlovesItem.ToString();
Data["HairItem"] = appearance.HairItem.ToString();
//Data["HipOffset"] = appearance.HipOffset.ToString();
Data["JacketItem"] = appearance.JacketItem.ToString();
Data["Owner"] = appearance.Owner.ToString();
Data["PantsItem"] = appearance.PantsItem.ToString();
Data["Serial"] = appearance.Serial.ToString();
Data["ShirtItem"] = appearance.ShirtItem.ToString();
Data["ShoesItem"] = appearance.ShoesItem.ToString();
Data["SkinItem"] = appearance.SkinItem.ToString();
Data["SkirtItem"] = appearance.SkirtItem.ToString();
Data["SocksItem"] = appearance.SocksItem.ToString();
Data["UnderPantsItem"] = appearance.UnderPantsItem.ToString();
Data["UnderShirtItem"] = appearance.UnderShirtItem.ToString();
// Attachments
Hashtable attachs = appearance.GetAttachments();
foreach (KeyValuePair<int, Hashtable> kvp in attachs)
{
Data["_ap_" + kvp.Key] = kvp.Value["item"].ToString();
}
}
public AvatarAppearance ToAvatarAppearance()
{
AvatarAppearance appearance = new AvatarAppearance();
// Wearables
appearance.AvatarHeight = float.Parse(Data["AvatarHeight"]);
appearance.BodyItem = UUID.Parse(Data["BodyItem"]);
appearance.EyesItem = UUID.Parse(Data["EyesItem"]);
appearance.GlovesItem = UUID.Parse(Data["GlovesItem"]);
appearance.HairItem = UUID.Parse(Data["HairItem"]);
//appearance.HipOffset = float.Parse(Data["HipOffset"]);
appearance.JacketItem = UUID.Parse(Data["JacketItem"]);
appearance.Owner = UUID.Parse(Data["Owner"]);
appearance.PantsItem = UUID.Parse(Data["PantsItem"]);
appearance.Serial = Int32.Parse(Data["Serial"]);
appearance.ShirtItem = UUID.Parse(Data["ShirtItem"]);
appearance.ShoesItem = UUID.Parse(Data["ShoesItem"]);
appearance.SkinItem = UUID.Parse(Data["SkinItem"]);
appearance.SkirtItem = UUID.Parse(Data["SkirtItem"]);
appearance.SocksItem = UUID.Parse(Data["SocksItem"]);
appearance.UnderPantsItem = UUID.Parse(Data["UnderPantsItem"]);
appearance.UnderShirtItem = UUID.Parse(Data["UnderShirtItem"]);
// Attachments
Dictionary<string, string> attchs = new Dictionary<string, string>();
foreach (KeyValuePair<string, string> _kvp in Data)
if (_kvp.Key.StartsWith("_ap_"))
attchs[_kvp.Key] = _kvp.Value;
Hashtable aaAttachs = new Hashtable();
foreach (KeyValuePair<string, string> _kvp in attchs)
{
string pointStr = _kvp.Key.Substring(4);
int point = 0;
if (!Int32.TryParse(pointStr, out point))
continue;
Hashtable tmp = new Hashtable();
tmp["item"] = _kvp.Value;
tmp["asset"] = UUID.Zero.ToString();
aaAttachs[point] = tmp;
}
return appearance;
}
}
}

View File

@ -27,6 +27,7 @@ namespace OpenSim.Services.LLLoginService
private IPresenceService m_PresenceService;
private ISimulationService m_LocalSimulationService;
private ILibraryService m_LibraryService;
private IAvatarService m_AvatarService;
private string m_DefaultRegionName;
private string m_RemoteSimulationDll;
@ -45,15 +46,15 @@ namespace OpenSim.Services.LLLoginService
string gridService = serverConfig.GetString("GridService", String.Empty);
string presenceService = serverConfig.GetString("PresenceService", String.Empty);
string libService = serverConfig.GetString("LibraryService", String.Empty);
string avatarService = serverConfig.GetString("AvatarService", String.Empty);
m_DefaultRegionName = serverConfig.GetString("DefaultRegion", String.Empty);
m_RemoteSimulationDll = serverConfig.GetString("RemoteSimulationService", String.Empty);
m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!");
m_RequireInventory = serverConfig.GetBoolean("RequireInventory", true);
// These 3 are required; the others aren't
if (accountService == string.Empty || authService == string.Empty ||
invService == string.Empty)
// These are required; the others aren't
if (accountService == string.Empty || authService == string.Empty)
throw new Exception("LoginService is missing service specifications");
Object[] args = new Object[] { config };
@ -64,7 +65,8 @@ namespace OpenSim.Services.LLLoginService
m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
if (presenceService != string.Empty)
m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
if (avatarService != string.Empty)
m_AvatarService = ServerUtils.LoadPlugin<IAvatarService>(avatarService, args);
//
// deal with the services given as argument
//
@ -116,6 +118,11 @@ namespace OpenSim.Services.LLLoginService
}
// Get the user's inventory
if (m_RequireInventory && m_InventoryService == null)
{
m_log.WarnFormat("[LLOGIN SERVICE]: Login failed, reason: inventory service not set up");
return LLFailedLoginResponse.InventoryProblem;
}
List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID);
if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0)))
{
@ -159,6 +166,13 @@ namespace OpenSim.Services.LLLoginService
return LLFailedLoginResponse.GridProblem;
}
// Get the avatar
AvatarData avatar = null;
if (m_AvatarService != null)
{
avatar = m_AvatarService.GetAvatar(account.PrincipalID);
}
// Instantiate/get the simulation interface and launch an agent at the destination
ISimulationService simConnector = null;
string reason = string.Empty;
@ -175,7 +189,7 @@ namespace OpenSim.Services.LLLoginService
if (simConnector != null)
{
circuitCode = (uint)Util.RandomClass.Next(); ;
aCircuit = LaunchAgent(simConnector, destination, account, session, secureSession, circuitCode, position, out reason);
aCircuit = LaunchAgent(simConnector, destination, account, avatar, session, secureSession, circuitCode, position, out reason);
}
if (aCircuit == null)
{
@ -337,16 +351,17 @@ namespace OpenSim.Services.LLLoginService
}
private AgentCircuitData LaunchAgent(ISimulationService simConnector, GridRegion region, UserAccount account,
UUID session, UUID secureSession, uint circuit, Vector3 position, out string reason)
AvatarData avatar, UUID session, UUID secureSession, uint circuit, Vector3 position, out string reason)
{
reason = string.Empty;
AgentCircuitData aCircuit = new AgentCircuitData();
aCircuit.AgentID = account.PrincipalID;
//aCircuit.Appearance = optional
if (avatar != null)
aCircuit.Appearance = avatar.ToAvatarAppearance();
//aCircuit.BaseFolder = irrelevant
aCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
aCircuit.child = false;
aCircuit.child = false; // the first login agent is root
aCircuit.circuitcode = circuit;
aCircuit.firstname = account.FirstName;
//aCircuit.InventoryFolder = irrelevant