From f96083a903024550243ada885c8edccad7e0eed7 Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 21 May 2007 19:12:18 +0000 Subject: More work on adding Events to ClientView (and registering to handle those events in Avatar and World) --- OpenSim.RegionServer/world/Avatar.Update.cs | 44 +++++----- OpenSim.RegionServer/world/Avatar.cs | 15 +++- OpenSim.RegionServer/world/World.PacketHandlers.cs | 98 ++++++++++++++-------- OpenSim.RegionServer/world/World.cs | 5 ++ 4 files changed, 101 insertions(+), 61 deletions(-) (limited to 'OpenSim.RegionServer/world') diff --git a/OpenSim.RegionServer/world/Avatar.Update.cs b/OpenSim.RegionServer/world/Avatar.Update.cs index 75f0bb4..ee72ba3 100644 --- a/OpenSim.RegionServer/world/Avatar.Update.cs +++ b/OpenSim.RegionServer/world/Avatar.Update.cs @@ -148,25 +148,15 @@ namespace OpenSim.world } } - public void SendInitialAppearance() + public void SendOurAppearance() { - AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); - aw.AgentData.AgentID = this.ControllingClient.AgentID; - aw.AgentData.SerialNum = 0; - aw.AgentData.SessionID = ControllingClient.SessionID; - - aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; - AgentWearablesUpdatePacket.WearableDataBlock awb; - for (int i = 0; i < 13; i++) - { - awb = new AgentWearablesUpdatePacket.WearableDataBlock(); - awb.WearableType = (byte)i; - awb.AssetID = this.Wearables[i].AssetID; - awb.ItemID = this.Wearables[i].ItemID; - aw.WearableData[i] = awb; - } + ControllingClient.SendAppearance(this.Wearables); + } - ControllingClient.OutPacket(aw); + public void SendOurAppearance(ClientView OurClient) + { + //event handler for wearables request + this.SendOurAppearance(); } public void SendAppearanceToOtherAgent(Avatar avatarInfo) @@ -188,13 +178,14 @@ namespace OpenSim.world avatarInfo.SendPacketToViewer(avp); } - public void SetAppearance(AgentSetAppearancePacket appear) + public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) { - LLObject.TextureEntry tex = new LLObject.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length); + LLObject.TextureEntry tex = new LLObject.TextureEntry(texture, 0, texture.Length); this.avatarAppearanceTexture = tex; - for (int i = 0; i < appear.VisualParam.Length; i++) + + for (int i = 0; i < visualParam.Length; i++) { - this.visualParams[i] = appear.VisualParam[i].ParamValue; + this.visualParams[i] = visualParam[i].ParamValue; } List avList = this.m_world.RequestAvatarList(); @@ -291,7 +282,7 @@ namespace OpenSim.world } // Sends animation update - public void SendAnimPack() + public void SendAnimPack(LLUUID animID, int seq) { AvatarAnimationPacket ani = new AvatarAnimationPacket(); ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1]; @@ -301,8 +292,8 @@ namespace OpenSim.world ani.Sender.ID = ControllingClient.AgentID; ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1]; ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock(); - ani.AnimationList[0].AnimID = this.current_anim; - ani.AnimationList[0].AnimSequenceID = this.anim_seq; + ani.AnimationList[0].AnimID = this.current_anim = animID; + ani.AnimationList[0].AnimSequenceID = this.anim_seq = seq; List avList = this.m_world.RequestAvatarList(); foreach (Avatar client in avList) @@ -312,5 +303,10 @@ namespace OpenSim.world } + public void SendAnimPack() + { + this.SendAnimPack(this.current_anim, this.anim_seq); + } + } } diff --git a/OpenSim.RegionServer/world/Avatar.cs b/OpenSim.RegionServer/world/Avatar.cs index 55e5ae4..4e90364 100644 --- a/OpenSim.RegionServer/world/Avatar.cs +++ b/OpenSim.RegionServer/world/Avatar.cs @@ -64,6 +64,14 @@ namespace OpenSim.world this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); + //register for events + ControllingClient.OnRequestWearables += new ClientView.GenericCall(this.SendOurAppearance); + ControllingClient.OnSetAppearance += new ClientView.SetAppearance(this.SetAppearance); + ControllingClient.OnCompleteMovementToRegion += new ClientView.GenericCall2(this.CompleteMovement); + ControllingClient.OnCompleteMovementToRegion += new ClientView.GenericCall2(this.SendInitialPosition); + ControllingClient.OnAgentUpdate += new ClientView.GenericCall3(this.HandleAgentUpdate); + ControllingClient.OnStartAnim += new ClientView.StartAnim(this.SendAnimPack); + } public PhysicsActor PhysActor @@ -170,7 +178,7 @@ namespace OpenSim.world } - public void CompleteMovement(World RegionInfo) + public void CompleteMovement() { OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE,"Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet"); AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); @@ -185,6 +193,11 @@ namespace OpenSim.world ControllingClient.OutPacket(mov); } + public void HandleAgentUpdate(Packet pack) + { + this.HandleUpdate((AgentUpdatePacket)pack); + } + public void HandleUpdate(AgentUpdatePacket pack) { if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0) diff --git a/OpenSim.RegionServer/world/World.PacketHandlers.cs b/OpenSim.RegionServer/world/World.PacketHandlers.cs index 27f200f..d12013a 100644 --- a/OpenSim.RegionServer/world/World.PacketHandlers.cs +++ b/OpenSim.RegionServer/world/World.PacketHandlers.cs @@ -15,31 +15,22 @@ namespace OpenSim.world { public partial class World { - - public bool ModifyTerrain(ClientView simClient, Packet packet) + public void ModifyTerrain(byte Action, float North, float West) { - ModifyLandPacket modify = (ModifyLandPacket)packet; - - switch (modify.ModifyBlock.Action) + switch (Action) { case 1: // raise terrain - if (modify.ParcelData.Length > 0) - { - Terrain.raise(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1); - RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West); - } + Terrain.raise(North, West, 10.0, 0.1); + RegenerateTerrain(true, (int)North, (int)West); break; case 2: //lower terrain - if (modify.ParcelData.Length > 0) - { - Terrain.lower(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1); - RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West); - } + Terrain.lower(North, West, 10.0, 0.1); + RegenerateTerrain(true, (int)North, (int)West); break; } - return true; + return; } public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) @@ -79,27 +70,13 @@ namespace OpenSim.world } } - public bool RezObject(ClientView simClient, Packet packet) + public void RezObject(AssetBase primasset, LLVector3 pos) { - RezObjectPacket rezPacket = (RezObjectPacket)packet; - AgentInventory inven = this._inventoryCache.GetAgentsInventory(simClient.AgentID); - if (inven != null) - { - if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID)) - { - AssetBase asset = this._assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID); - if (asset != null) - { - PrimData primd = new PrimData(asset.Data); - Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this); - nPrim.CreateFromStorage(primd, rezPacket.RezData.RayEnd, this._primCount, true); - this.Entities.Add(nPrim.uuid, nPrim); - this._primCount++; - this._inventoryCache.DeleteInventoryItem(simClient, rezPacket.InventoryData.ItemID); - } - } - } - return true; + PrimData primd = new PrimData(primasset.Data); + Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this); + nPrim.CreateFromStorage(primd, pos, this._primCount, true); + this.Entities.Add(nPrim.uuid, nPrim); + this._primCount++; } public bool DeRezObject(ClientView simClient, Packet packet) @@ -191,6 +168,7 @@ namespace OpenSim.world return true; } + /* public void RequestMapBlock(ClientView simClient, int minX, int minY, int maxX, int maxY) { System.Text.Encoding _enc = System.Text.Encoding.ASCII; @@ -212,6 +190,54 @@ namespace OpenSim.world simClient.OutPacket(mapReply); } } + public bool RezObjectHandler(ClientView simClient, Packet packet) + { + RezObjectPacket rezPacket = (RezObjectPacket)packet; + AgentInventory inven = this._inventoryCache.GetAgentsInventory(simClient.AgentID); + if (inven != null) + { + if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID)) + { + AssetBase asset = this._assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID); + if (asset != null) + { + PrimData primd = new PrimData(asset.Data); + Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this); + nPrim.CreateFromStorage(primd, rezPacket.RezData.RayEnd, this._primCount, true); + this.Entities.Add(nPrim.uuid, nPrim); + this._primCount++; + this._inventoryCache.DeleteInventoryItem(simClient, rezPacket.InventoryData.ItemID); + } + } + } + return true; + } + public bool ModifyTerrain(ClientView simClient, Packet packet) + { + ModifyLandPacket modify = (ModifyLandPacket)packet; + + switch (modify.ModifyBlock.Action) + { + case 1: + // raise terrain + if (modify.ParcelData.Length > 0) + { + Terrain.raise(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1); + RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West); + } + break; + case 2: + //lower terrain + if (modify.ParcelData.Length > 0) + { + Terrain.lower(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1); + RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West); + } + break; + } + return true; + } + */ } } diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs index c90e3f6..70ca680 100644 --- a/OpenSim.RegionServer/world/World.cs +++ b/OpenSim.RegionServer/world/World.cs @@ -532,7 +532,12 @@ namespace OpenSim.world public override void AddViewerAgent(ClientView agentClient) { + //register for events agentClient.OnChatFromViewer += new ClientView.ChatFromViewer(this.SimChat); + agentClient.OnRezObject += new ClientView.RezObject(this.RezObject); + agentClient.OnModifyTerrain += new ClientView.ModifyTerrain(this.ModifyTerrain); + agentClient.OnRegionHandShakeReply += new ClientView.GenericCall(this.SendLayerData); + agentClient.OnRequestWearables += new ClientView.GenericCall(this.GetInitialPrims); try { OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); -- cgit v1.1