From f43e077150d39b454bd66d43a72736a75614a721 Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 1 Apr 2008 13:09:29 +0000 Subject: a few small changes --- .../Environment/Interfaces/IAvatarFactory.cs | 2 +- OpenSim/Region/Environment/Modules/ChatModule.cs | 14 ++-- OpenSim/Region/Environment/Scenes/Scene.cs | 21 +++--- .../Region/Examples/SimpleModule/MyNpcCharacter.cs | 82 ++++++++++++---------- .../Region/Examples/SimpleModule/RegionModule.cs | 2 +- .../Modules/AvatarFactory/AvatarFactoryModule.cs | 4 +- 6 files changed, 67 insertions(+), 58 deletions(-) diff --git a/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs b/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs index a42f1dc..3ebbaab 100644 --- a/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs +++ b/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs @@ -30,7 +30,7 @@ using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.Environment.Interfaces { - public interface IAvatarFactory : IRegionModule + public interface IAvatarFactory { bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance); void UpdateDatabase(LLUUID userID, AvatarAppearance avatAppearance); diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index ab6b791..08c0a11 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs @@ -62,6 +62,13 @@ namespace OpenSim.Region.Environment.Modules { lock (m_syncInit) { + if (!m_scenes.Contains(scene)) + { + m_scenes.Add(scene); + scene.EventManager.OnNewClient += NewClient; + scene.RegisterModuleInterface(this); + } + // wrap this in a try block so that defaults will work if // the config file doesn't specify otherwise. try @@ -82,13 +89,6 @@ namespace OpenSim.Region.Environment.Modules { } - if (!m_scenes.Contains(scene)) - { - m_scenes.Add(scene); - scene.EventManager.OnNewClient += NewClient; - scene.RegisterModuleInterface(this); - } - // setup IRC Relay if (m_irc == null) { m_irc = new IRCChatModule(config); } if (m_irc_connector == null) diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 2fa0459..7ee0478 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -986,15 +986,18 @@ namespace OpenSim.Region.Environment.Scenes if (terrain != null) { byte[] data = terrain.WriteJpegImage("defaultstripe.png"); - m_regInfo.EstateSettings.terrainImageID = LLUUID.Random(); - AssetBase asset = new AssetBase(); - asset.FullID = m_regInfo.EstateSettings.terrainImageID; - asset.Data = data; - asset.Name = "terrainImage"; - asset.Description = RegionInfo.RegionName; - asset.Type = 0; - asset.Temporary = temporary; - AssetCache.AddAsset(asset); + if (data != null) + { + m_regInfo.EstateSettings.terrainImageID = LLUUID.Random(); + AssetBase asset = new AssetBase(); + asset.FullID = m_regInfo.EstateSettings.terrainImageID; + asset.Data = data; + asset.Name = "terrainImage"; + asset.Description = RegionInfo.RegionName; + asset.Type = 0; + asset.Temporary = temporary; + AssetCache.AddAsset(asset); + } } } diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 39d05eb..8fcc3cf 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -41,6 +41,7 @@ namespace OpenSim.Region.Examples.SimpleModule private short flyState = 0; private LLQuaternion bodyDirection = LLQuaternion.Identity; private short count = 0; + private short frame = 0; #pragma warning disable 67 @@ -450,49 +451,54 @@ namespace OpenSim.Region.Examples.SimpleModule private void Update() { - if (OnAgentUpdate != null) + frame++; + if (frame > 20) { - AgentUpdatePacket pack = new AgentUpdatePacket(); - pack.AgentData.ControlFlags = movementFlag; - pack.AgentData.BodyRotation = bodyDirection; - OnAgentUpdate(this, pack); - } - if (flyState == 0) - { - movementFlag = (uint) AgentManager.ControlFlags.AGENT_CONTROL_FLY | - (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG; - flyState = 1; - } - else if (flyState == 1) - { - movementFlag = (uint) AgentManager.ControlFlags.AGENT_CONTROL_FLY | - (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_POS; - flyState = 2; - } - else - { - movementFlag = (uint) AgentManager.ControlFlags.AGENT_CONTROL_FLY; - flyState = 0; - } + frame = 0; + if (OnAgentUpdate != null) + { + AgentUpdatePacket pack = new AgentUpdatePacket(); + pack.AgentData.ControlFlags = movementFlag; + pack.AgentData.BodyRotation = bodyDirection; + OnAgentUpdate(this, pack); + } + if (flyState == 0) + { + movementFlag = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY | + (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG; + flyState = 1; + } + else if (flyState == 1) + { + movementFlag = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY | + (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS; + flyState = 2; + } + else + { + movementFlag = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; + flyState = 0; + } - if (count >= 200) - { - if (OnChatFromViewer != null) + if (count >= 10) { - ChatFromViewerArgs args = new ChatFromViewerArgs(); - args.Message = "Kinda quiet around here, isn't it?"; - args.Channel = 0; - args.From = FirstName + " " + LastName; - args.Position = new LLVector3(128, 128, 26); - args.Sender = this; - args.Type = ChatTypeEnum.Shout; - - OnChatFromViewer(this, args); + if (OnChatFromViewer != null) + { + ChatFromViewerArgs args = new ChatFromViewerArgs(); + args.Message = "Kinda quiet around here, isn't it?"; + args.Channel = 0; + args.From = FirstName + " " + LastName; + args.Position = new LLVector3(128, 128, 26); + args.Sender = this; + args.Type = ChatTypeEnum.Shout; + + OnChatFromViewer(this, args); + } + count = -1; } - count = -1; - } - count++; + count++; + } } public bool AddMoney(int debit) diff --git a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs index 3b21d43..1e043dd 100644 --- a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs +++ b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs @@ -56,7 +56,7 @@ namespace OpenSim.Region.Examples.SimpleModule AddCpuCounter(regionInfo, pos); // AddComplexObjects(regionInfo, pos); - // AddAvatars(); + AddAvatars(); AddFileSystemObjects(); } diff --git a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs index d0ee277..b122753 100644 --- a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs @@ -39,7 +39,7 @@ using OpenSim.Framework.Data.MapperFactory; namespace OpenSim.Region.Modules.AvatarFactory { - public class AvatarFactoryModule : IAvatarFactory + public class AvatarFactoryModule : IAvatarFactory, IRegionModule { private Scene m_scene = null; private readonly Dictionary m_avatarsAppearance = new Dictionary(); @@ -100,7 +100,7 @@ namespace OpenSim.Region.Modules.AvatarFactory } else { - Thread.Sleep(5000); + Thread.Sleep(5000); //why is this here? //this is the first thread to request this appearance //so let it check the db and if not found then create a default appearance -- cgit v1.1