Hack around with the NPC module to get osNpcCreate() partially working again.
This now creates an avatar but appearance is always cloudy. Move doesn't work. Really, creating an NPC should only involve a ScenePresence rather than doing anything with IClientAPI, since an NPC has no viewer to communicate with!bulletsim
parent
ee92f22f2a
commit
22f25fae38
|
@ -162,12 +162,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||||
// one and we're done otherwise, ask for a rebake
|
// one and we're done otherwise, ask for a rebake
|
||||||
if (checkonly) return false;
|
if (checkonly) return false;
|
||||||
|
|
||||||
m_log.InfoFormat("[AVFACTORY]: missing baked texture {0}, requesting rebake",face.TextureID);
|
m_log.InfoFormat("[AVFACTORY]: missing baked texture {0}, requesting rebake", face.TextureID);
|
||||||
client.SendRebakeAvatarTextures(face.TextureID);
|
client.SendRebakeAvatarTextures(face.TextureID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.DebugFormat("[AVFACTORY]: completed texture check for {0}", client.AgentId);
|
m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0}", client.AgentId);
|
||||||
|
|
||||||
// If we only found default textures, then the appearance is not cached
|
// If we only found default textures, then the appearance is not cached
|
||||||
return (defonly ? false : true);
|
return (defonly ? false : true);
|
||||||
|
|
|
@ -297,9 +297,10 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
||||||
if (m_UserCache.ContainsKey(id))
|
if (m_UserCache.ContainsKey(id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, craetorData {1}", id, creatorData);
|
||||||
|
|
||||||
UserData user = new UserData();
|
UserData user = new UserData();
|
||||||
user.Id = id;
|
user.Id = id;
|
||||||
|
|
||||||
UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id);
|
UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id);
|
||||||
|
|
||||||
if (account != null)
|
if (account != null)
|
||||||
|
|
|
@ -36,4 +36,4 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
void QueueAppearanceSend(UUID agentid);
|
void QueueAppearanceSend(UUID agentid);
|
||||||
void QueueAppearanceSave(UUID agentid);
|
void QueueAppearanceSave(UUID agentid);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2593,8 +2593,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
string homeURL = string.Empty;
|
string homeURL = string.Empty;
|
||||||
string first = aCircuit.firstname, last = aCircuit.lastname;
|
string first = aCircuit.firstname, last = aCircuit.lastname;
|
||||||
|
|
||||||
if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
|
if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
|
||||||
homeURL = aCircuit.ServiceURLs["HomeURI"].ToString();
|
homeURL = aCircuit.ServiceURLs["HomeURI"].ToString();
|
||||||
|
|
||||||
if (aCircuit.lastname.StartsWith("@"))
|
if (aCircuit.lastname.StartsWith("@"))
|
||||||
{
|
{
|
||||||
string[] parts = aCircuit.firstname.Split('.');
|
string[] parts = aCircuit.firstname.Split('.');
|
||||||
|
@ -2604,6 +2606,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
last = parts[1];
|
last = parts[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uMan.AddUser(aCircuit.AgentID, first, last, homeURL);
|
uMan.AddUser(aCircuit.AgentID, first, last, homeURL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3389,7 +3392,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// In all cases, add or update the circuit data with the new agent circuit data and teleport flags
|
// In all cases, add or update the circuit data with the new agent circuit data and teleport flags
|
||||||
agent.teleportFlags = teleportFlags;
|
agent.teleportFlags = teleportFlags;
|
||||||
m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
|
m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
|
||||||
|
|
|
@ -1944,10 +1944,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_log.Warn("Sit requested on unknown object: " + targetID.ToString());
|
m_log.Warn("Sit requested on unknown object: " + targetID.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SendSitResponse(remoteClient, targetID, offset, Quaternion.Identity);
|
SendSitResponse(remoteClient, targetID, offset, Quaternion.Identity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public void SitRayCastAvatarPosition(SceneObjectPart part)
|
public void SitRayCastAvatarPosition(SceneObjectPart part)
|
||||||
{
|
{
|
||||||
|
@ -2380,7 +2379,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// <param name="remoteClient"></param>
|
/// <param name="remoteClient"></param>
|
||||||
public void SendTerseUpdateToClient(IClientAPI remoteClient)
|
public void SendTerseUpdateToClient(IClientAPI remoteClient)
|
||||||
{
|
{
|
||||||
|
|
||||||
// If the client is inactive, it's getting its updates from another
|
// If the client is inactive, it's getting its updates from another
|
||||||
// server.
|
// server.
|
||||||
if (remoteClient.IsActive)
|
if (remoteClient.IsActive)
|
||||||
|
@ -2495,7 +2493,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we aren't using a cached appearance, then clear out the baked textures
|
// If we aren't using a cached appearance, then clear out the baked textures
|
||||||
if (! cachedappearance)
|
if (!cachedappearance)
|
||||||
{
|
{
|
||||||
m_appearance.ResetAppearance();
|
m_appearance.ResetAppearance();
|
||||||
if (m_scene.AvatarFactory != null)
|
if (m_scene.AvatarFactory != null)
|
||||||
|
|
|
@ -113,7 +113,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance
|
||||||
{
|
{
|
||||||
bool bakedTextureValid = scene.AvatarFactory.ValidateBakedTextureCache(client);
|
bool bakedTextureValid = scene.AvatarFactory.ValidateBakedTextureCache(client);
|
||||||
MainConsole.Instance.OutputFormat(
|
MainConsole.Instance.OutputFormat(
|
||||||
"{0} baked apperance texture is {1}", client.Name, bakedTextureValid ? "OK" : "corrupt");
|
"{0} baked appearance texture is {1}", client.Name, bakedTextureValid ? "OK" : "corrupt");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,13 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using OpenMetaverse;
|
using log4net;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
|
using OpenMetaverse;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
using OpenSim.Region.CoreModules.Avatar.NPC;
|
using OpenSim.Region.CoreModules.Avatar.NPC;
|
||||||
|
@ -40,6 +43,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||||
{
|
{
|
||||||
public class NPCModule : IRegionModule, INPCModule
|
public class NPCModule : IRegionModule, INPCModule
|
||||||
{
|
{
|
||||||
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
// private const bool m_enabled = false;
|
// private const bool m_enabled = false;
|
||||||
|
|
||||||
private Mutex m_createMutex;
|
private Mutex m_createMutex;
|
||||||
|
@ -59,6 +64,17 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||||
private UUID p_cloneAppearanceFrom;
|
private UUID p_cloneAppearanceFrom;
|
||||||
private UUID p_returnUuid;
|
private UUID p_returnUuid;
|
||||||
|
|
||||||
|
public void Initialise(Scene scene, IConfigSource source)
|
||||||
|
{
|
||||||
|
m_createMutex = new Mutex(false);
|
||||||
|
|
||||||
|
m_timer = new Timer(500);
|
||||||
|
m_timer.Elapsed += m_timer_Elapsed;
|
||||||
|
m_timer.Start();
|
||||||
|
|
||||||
|
scene.RegisterModuleInterface<INPCModule>(this);
|
||||||
|
}
|
||||||
|
|
||||||
private AvatarAppearance GetAppearance(UUID target, Scene scene)
|
private AvatarAppearance GetAppearance(UUID target, Scene scene)
|
||||||
{
|
{
|
||||||
if (m_appearanceCache.ContainsKey(target))
|
if (m_appearanceCache.ContainsKey(target))
|
||||||
|
@ -76,6 +92,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||||
|
|
||||||
public UUID CreateNPC(string firstname, string lastname,Vector3 position, Scene scene, UUID cloneAppearanceFrom)
|
public UUID CreateNPC(string firstname, string lastname,Vector3 position, Scene scene, UUID cloneAppearanceFrom)
|
||||||
{
|
{
|
||||||
|
m_log.DebugFormat(
|
||||||
|
"[NPC MODULE]: Queueing request to create NPC {0} {1} at {2} in {3} cloning appearance of {4}",
|
||||||
|
firstname, lastname, position, scene.RegionInfo.RegionName, cloneAppearanceFrom);
|
||||||
|
|
||||||
// Block.
|
// Block.
|
||||||
m_createMutex.WaitOne();
|
m_createMutex.WaitOne();
|
||||||
|
|
||||||
|
@ -137,46 +157,67 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Initialise(Scene scene, IConfigSource source)
|
|
||||||
{
|
|
||||||
m_createMutex = new Mutex(false);
|
|
||||||
|
|
||||||
m_timer = new Timer(500);
|
|
||||||
m_timer.Elapsed += m_timer_Elapsed;
|
|
||||||
m_timer.Start();
|
|
||||||
|
|
||||||
scene.RegisterModuleInterface<INPCModule>(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void m_timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
void m_timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
lock (p_lock)
|
try
|
||||||
{
|
{
|
||||||
if (p_inUse)
|
lock (p_lock)
|
||||||
{
|
{
|
||||||
p_inUse = false;
|
if (p_inUse)
|
||||||
|
|
||||||
NPCAvatar npcAvatar = new NPCAvatar(p_firstname, p_lastname, p_position, p_scene);
|
|
||||||
npcAvatar.CircuitCode = (uint) Util.RandomClass.Next(0, int.MaxValue);
|
|
||||||
|
|
||||||
p_scene.AddNewClient(npcAvatar);
|
|
||||||
|
|
||||||
ScenePresence sp;
|
|
||||||
if (p_scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
|
|
||||||
{
|
{
|
||||||
AvatarAppearance x = GetAppearance(p_cloneAppearanceFrom, p_scene);
|
p_inUse = false;
|
||||||
|
|
||||||
|
NPCAvatar npcAvatar = new NPCAvatar(p_firstname, p_lastname, p_position, p_scene);
|
||||||
|
npcAvatar.CircuitCode = (uint) Util.RandomClass.Next(0, int.MaxValue);
|
||||||
|
|
||||||
|
m_log.DebugFormat(
|
||||||
|
"[NPC MODULE]: Creating NPC {0} {1} {2} at {3} in {4}",
|
||||||
|
p_firstname, p_lastname, npcAvatar.AgentId, p_position, p_scene.RegionInfo.RegionName);
|
||||||
|
|
||||||
|
AgentCircuitData acd = new AgentCircuitData();
|
||||||
|
acd.AgentID = npcAvatar.AgentId;
|
||||||
|
acd.firstname = p_firstname;
|
||||||
|
acd.lastname = p_lastname;
|
||||||
|
acd.ServiceURLs = new Dictionary<string, object>();
|
||||||
|
|
||||||
|
AvatarAppearance originalAppearance = GetAppearance(p_cloneAppearanceFrom, p_scene);
|
||||||
|
AvatarAppearance npcAppearance = new AvatarAppearance(originalAppearance, true);
|
||||||
|
acd.Appearance = npcAppearance;
|
||||||
|
|
||||||
|
p_scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
|
||||||
|
p_scene.AddNewClient(npcAvatar);
|
||||||
|
|
||||||
|
ScenePresence sp;
|
||||||
|
if (p_scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
|
||||||
|
{
|
||||||
|
m_log.DebugFormat(
|
||||||
|
"[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);
|
||||||
|
|
||||||
|
// Shouldn't call this - temporary.
|
||||||
|
sp.CompleteMovement(npcAvatar);
|
||||||
|
|
||||||
|
// sp.SendAppearanceToAllOtherAgents();
|
||||||
|
//
|
||||||
|
// // Send animations back to the avatar as well
|
||||||
|
// sp.Animator.SendAnimPack();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_avatars.Add(npcAvatar.AgentId, npcAvatar);
|
||||||
|
|
||||||
|
p_returnUuid = npcAvatar.AgentId;
|
||||||
|
|
||||||
sp.Appearance.SetTextureEntries(x.Texture);
|
m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", p_returnUuid);
|
||||||
sp.Appearance.SetVisualParams((byte[])x.VisualParams.Clone());
|
|
||||||
sp.SendAppearanceToAllOtherAgents();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_avatars.Add(npcAvatar.AgentId, npcAvatar);
|
|
||||||
|
|
||||||
p_returnUuid = npcAvatar.AgentId;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat("[NPC MODULE]: NPC creation failed with exception {0} {1}", ex.Message, ex.StackTrace);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PostInitialise()
|
public void PostInitialise()
|
||||||
|
|
Loading…
Reference in New Issue