partially fixing avatar appearance code

0.6.5-rc1
Dr Scofield 2009-05-12 11:51:19 +00:00
parent e08d0a7ba5
commit 13de24f707
1 changed files with 62 additions and 58 deletions

View File

@ -1135,7 +1135,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController
// establish "Default Female". Specifying a specific model can // establish "Default Female". Specifying a specific model can
// establish a specific appearance without regard for gender. // establish a specific appearance without regard for gender.
updateUserAppearance(responseData, requestData, userProfile.ID); // TODO: need to add code to do this only when
// requested
if (requestData.ContainsKey("model"))
updateUserAppearance(responseData, requestData, userProfile.ID);
if (!m_app.CommunicationsManager.UserService.UpdateUserProfile(userProfile)) if (!m_app.CommunicationsManager.UserService.UpdateUserProfile(userProfile))
throw new Exception("did not manage to update user profile"); throw new Exception("did not manage to update user profile");
@ -1177,39 +1180,40 @@ namespace OpenSim.ApplicationPlugins.RemoteController
m_log.DebugFormat("[RADMIN] updateUserAppearance"); m_log.DebugFormat("[RADMIN] updateUserAppearance");
string dmale = m_config.GetString("default_male", "Default Male"); // string dmale = m_config.GetString("default_male", "Default Male");
string dfemale = m_config.GetString("default_female", "Default Female"); // string dfemale = m_config.GetString("default_female", "Default Female");
string dneut = m_config.GetString("default_female", "Default Default"); // string dneut = m_config.GetString("default_female", "Default Default");
string dmodel = dneut; // string dmodel = dneut;
string model = dneut; // string model = dneut;
// string dmodel = String.Empty;
string model = String.Empty;
// Has a gender preference been supplied? // Has a gender preference been supplied?
if (requestData.Contains("gender")) // if (requestData.Contains("gender"))
{ // {
if ((string)requestData["gender"] == "f") // if ((string)requestData["gender"] == "f")
dmodel = dmale; // dmodel = dmale;
else // else
dmodel = dfemale; // dmodel = dfemale;
} // }
else // else
dmodel = dneut; // dmodel = dneut;
// Has an explicit model been specified? // Has an explicit model been specified?
if (requestData.Contains("model")) if (!requestData.Contains("model"))
model = (string)requestData["model"]; return;
else model = (string)requestData["model"];
model = dmodel;
m_log.DebugFormat("[RADMIN] Setting appearance for avatar {0}, using model {1}", userid, model); m_log.DebugFormat("[RADMIN] Setting appearance for avatar {0}, using model {1}", userid, model);
string[] nomens = model.Split(); string[] nomens = model.Split();
if (nomens.Length != 2) if (nomens.Length != 2)
{ {
m_log.WarnFormat("[RADMIN] User appearance not set for {0}. Invalid model name : <{1}>", m_log.WarnFormat("[RADMIN] User appearance not set for {0}. Invalid model name : <{1}>", userid, model);
userid, model); // nomens = dmodel.Split();
nomens = dmodel.Split(); return;
} }
UserProfileData mprof = m_app.CommunicationsManager.UserService.GetUserProfile(nomens[0], nomens[1]); UserProfileData mprof = m_app.CommunicationsManager.UserService.GetUserProfile(nomens[0], nomens[1]);
@ -1217,39 +1221,34 @@ namespace OpenSim.ApplicationPlugins.RemoteController
// Is this the first time one of the default models has been used? Create it if that is the case // Is this the first time one of the default models has been used? Create it if that is the case
// otherwise default to male. // otherwise default to male.
if (mprof == null) // if (mprof == null)
{ // {
if(model != dmale && model != dfemale) // if (model != dmale && model != dfemale)
{ // {
m_log.WarnFormat("[RADMIN] Requested model ({0}) not found. Default appearance assumed", // m_log.WarnFormat("[RADMIN] Requested model ({0}) not found. Default appearance assumed",
model); // model);
nomens = dmodel.Split(); // nomens = dmodel.Split();
} // }
if (createDefaultAvatars()) // if (createDefaultAvatars())
{ // {
mprof = m_app.CommunicationsManager.UserService.GetUserProfile(nomens[0], nomens[1]); // mprof = m_app.CommunicationsManager.UserService.GetUserProfile(nomens[0], nomens[1]);
} // }
} // }
if (mprof == null) if (mprof == null)
{ {
m_log.WarnFormat("[RADMIN] User appearance not set for {0}. Model avatar not found : <{1}>", m_log.WarnFormat("[RADMIN] User appearance not set for {0}. Model avatar not found : <{1}>", userid, model);
userid, model); return;
}
else
{
// Set current user's appearance. This bit is easy. The appearance structure is populated with
// actual asset ids, however to complete the magic we need to populate the inventory with the
// assets in question.
establishAppearance(userid, mprof.ID);
} }
// Set current user's appearance. This bit is easy. The appearance structure is populated with
// actual asset ids, however to complete the magic we need to populate the inventory with the
// assets in question.
establishAppearance(userid, mprof.ID);
m_log.DebugFormat("[RADMIN] Finished setting appearance for avatar {0}, using model {1}", m_log.DebugFormat("[RADMIN] Finished setting appearance for avatar {0}, using model {1}",
userid, model); userid, model);
} }
/// <summary> /// <summary>
@ -1258,7 +1257,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
/// is known to exist, as is the target avatar. /// is known to exist, as is the target avatar.
/// </summary> /// </summary>
private AvatarAppearance establishAppearance(UUID dest, UUID srca) private void establishAppearance(UUID dest, UUID srca)
{ {
m_log.DebugFormat("[RADMIN] Initializing inventory for {0} from {1}", dest, srca); m_log.DebugFormat("[RADMIN] Initializing inventory for {0} from {1}", dest, srca);
@ -1267,10 +1266,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController
// If the model has no associated appearance we're done. // If the model has no associated appearance we're done.
if (ava == null) // if (ava == null)
{ // {
return new AvatarAppearance(); // return new AvatarAppearance();
} // }
if (ava == null)
return;
UICallback sic = new UICallback(); UICallback sic = new UICallback();
UICallback dic = new UICallback(); UICallback dic = new UICallback();
@ -1358,12 +1360,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
catch (Exception e) catch (Exception e)
{ {
m_log.WarnFormat("[RADMIN] Error transferring inventory for {0} : {1}", m_log.WarnFormat("[RADMIN] Error transferring inventory for {0} : {1}",
dest, e.Message); dest, e.Message);
return new AvatarAppearance(); // return new AvatarAppearance();
return;
} }
m_app.CommunicationsManager.AvatarService.UpdateUserAppearance(dest, ava); m_app.CommunicationsManager.AvatarService.UpdateUserAppearance(dest, ava);
return ava; // return ava;
return;
} }