aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorsacha2010-12-04 21:50:48 +0000
committersacha2010-12-04 21:50:48 +0000
commit835103af82eb0b8c0916bbbe3c5a981e92e5a47e (patch)
tree154f02cada4bf550b7278aef31c42f9ba8da3ef5 /OpenSim/Region
parentadd more detail to the log in case of FORM Timeout (diff)
parentAdd some safeguards: DOn't send someone else's HUDs, don't send deleted prims (diff)
downloadopensim-SC_OLD-835103af82eb0b8c0916bbbe3c5a981e92e5a47e.zip
opensim-SC_OLD-835103af82eb0b8c0916bbbe3c5a981e92e5a47e.tar.gz
opensim-SC_OLD-835103af82eb0b8c0916bbbe3c5a981e92e5a47e.tar.bz2
opensim-SC_OLD-835103af82eb0b8c0916bbbe3c5a981e92e5a47e.tar.xz
Merge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/careminster into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs4
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs25
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs136
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs166
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs158
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs28
-rw-r--r--OpenSim/Region/Examples/SimpleModule/RegionModule.cs11
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs6
-rw-r--r--OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs86
-rw-r--r--OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs91
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs17
14 files changed, 517 insertions, 230 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index c5ee385..6a7272d 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -361,13 +361,13 @@ namespace OpenSim
361 m_moduleLoader.InitialiseSharedModules(scene); 361 m_moduleLoader.InitialiseSharedModules(scene);
362 362
363 // Use this in the future, the line above will be deprecated soon 363 // Use this in the future, the line above will be deprecated soon
364 m_log.Info("[MODULES]: Loading Region's modules (new style)"); 364 m_log.Info("[REGIONMODULES]: Loading Region's modules (new style)");
365 IRegionModulesController controller; 365 IRegionModulesController controller;
366 if (ApplicationRegistry.TryGet(out controller)) 366 if (ApplicationRegistry.TryGet(out controller))
367 { 367 {
368 controller.AddRegionToModules(scene); 368 controller.AddRegionToModules(scene);
369 } 369 }
370 else m_log.Error("[MODULES]: The new RegionModulesController is missing..."); 370 else m_log.Error("[REGIONMODULES]: The new RegionModulesController is missing...");
371 371
372 if (m_securePermissionsLoading) 372 if (m_securePermissionsLoading)
373 { 373 {
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 9189260..478cfe6 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -3604,24 +3604,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3604 if (m_killRecord.Contains(part.ParentGroup.RootPart.LocalId)) 3604 if (m_killRecord.Contains(part.ParentGroup.RootPart.LocalId))
3605 continue; 3605 continue;
3606 3606
3607 // Please do not remove this unless you can demonstrate on the OpenSim mailing list that a client
3608 // will never receive an update after a prim kill. Even then, keeping the kill record may be a good
3609 // safety measure.
3610 //
3611 // If a Linden Lab 1.23.5 client (and possibly later and earlier) receives an object update
3612 // after a kill, it will keep displaying the deleted object until relog. OpenSim currently performs
3613 // updates and kills on different threads with different scheduling strategies, hence this protection.
3614 //
3615 // This doesn't appear to apply to child prims - a client will happily ignore these updates
3616 // after the root prim has been deleted.
3617 if (m_killRecord.Contains(part.LocalId)) 3607 if (m_killRecord.Contains(part.LocalId))
3618 {
3619 // m_log.WarnFormat(
3620 // "[CLIENT]: Preventing update for prim with local id {0} after client for user {1} told it was deleted",
3621 // part.LocalId, Name);
3622 continue; 3608 continue;
3623 }
3624 3609
3610 if (part.ParentGroup.IsDeleted)
3611 continue;
3612
3613 if (part.ParentGroup.IsAttachment)
3614 { // Someone else's HUD, why are we getting these?
3615 if (part.ParentGroup.OwnerID != AgentId &&
3616 part.ParentGroup.RootPart.Shape.State >= 30)
3617 continue;
3618 }
3619
3625 if (part.ParentGroup.IsAttachment && m_disableFacelights) 3620 if (part.ParentGroup.IsAttachment && m_disableFacelights)
3626 { 3621 {
3627 if (part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.LeftHand && 3622 if (part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.LeftHand &&
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
index 3d6e7f3..85e1c99 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
@@ -41,19 +41,22 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
41 /// </summary> 41 /// </summary>
42 public class AgentAssetTransactions 42 public class AgentAssetTransactions
43 { 43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(
45 MethodBase.GetCurrentMethod().DeclaringType);
45 46
46 // Fields 47 // Fields
47 private bool m_dumpAssetsToFile; 48 private bool m_dumpAssetsToFile;
48 public AssetTransactionModule Manager; 49 private Scene m_Scene;
49 public UUID UserID; 50 public UUID UserID;
50 public Dictionary<UUID, AssetXferUploader> XferUploaders = new Dictionary<UUID, AssetXferUploader>(); 51 public Dictionary<UUID, AssetXferUploader> XferUploaders =
52 new Dictionary<UUID, AssetXferUploader>();
51 53
52 // Methods 54 // Methods
53 public AgentAssetTransactions(UUID agentID, AssetTransactionModule manager, bool dumpAssetsToFile) 55 public AgentAssetTransactions(UUID agentID, Scene scene,
56 bool dumpAssetsToFile)
54 { 57 {
58 m_Scene = scene;
55 UserID = agentID; 59 UserID = agentID;
56 Manager = manager;
57 m_dumpAssetsToFile = dumpAssetsToFile; 60 m_dumpAssetsToFile = dumpAssetsToFile;
58 } 61 }
59 62
@@ -61,7 +64,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
61 { 64 {
62 if (!XferUploaders.ContainsKey(transactionID)) 65 if (!XferUploaders.ContainsKey(transactionID))
63 { 66 {
64 AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile); 67 AssetXferUploader uploader = new AssetXferUploader(m_Scene,
68 m_dumpAssetsToFile);
65 69
66 lock (XferUploaders) 70 lock (XferUploaders)
67 { 71 {
@@ -88,22 +92,25 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
88 } 92 }
89 } 93 }
90 94
91 public void RequestCreateInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID folderID, 95 public void RequestCreateInventoryItem(IClientAPI remoteClient,
92 uint callbackID, string description, string name, sbyte invType, 96 UUID transactionID, UUID folderID, uint callbackID,
93 sbyte type, byte wearableType, uint nextOwnerMask) 97 string description, string name, sbyte invType,
98 sbyte type, byte wearableType, uint nextOwnerMask)
94 { 99 {
95 if (XferUploaders.ContainsKey(transactionID)) 100 if (XferUploaders.ContainsKey(transactionID))
96 { 101 {
97 XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, 102 XferUploaders[transactionID].RequestCreateInventoryItem(
98 callbackID, description, name, invType, type, 103 remoteClient, transactionID, folderID,
99 wearableType, nextOwnerMask); 104 callbackID, description, name, invType, type,
105 wearableType, nextOwnerMask);
100 } 106 }
101 } 107 }
102 108
103 109
104 110
105 /// <summary> 111 /// <summary>
106 /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed. 112 /// Get an uploaded asset. If the data is successfully retrieved,
113 /// the transaction will be removed.
107 /// </summary> 114 /// </summary>
108 /// <param name="transactionID"></param> 115 /// <param name="transactionID"></param>
109 /// <returns>The asset if the upload has completed, null if it has not.</returns> 116 /// <returns>The asset if the upload has completed, null if it has not.</returns>
@@ -125,105 +132,66 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
125 return null; 132 return null;
126 } 133 }
127 134
128 //private void CreateItemFromUpload(AssetBase asset, IClientAPI ourClient, UUID inventoryFolderID, uint nextPerms, uint wearableType) 135 public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient,
129 //{ 136 SceneObjectPart part, UUID transactionID,
130 // Manager.MyScene.CommsManager.AssetCache.AddAsset(asset); 137 TaskInventoryItem item)
131 // CachedUserInfo userInfo = Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails(
132 // ourClient.AgentId);
133
134 // if (userInfo != null)
135 // {
136 // InventoryItemBase item = new InventoryItemBase();
137 // item.Owner = ourClient.AgentId;
138 // item.Creator = ourClient.AgentId;
139 // item.ID = UUID.Random();
140 // item.AssetID = asset.FullID;
141 // item.Description = asset.Description;
142 // item.Name = asset.Name;
143 // item.AssetType = asset.Type;
144 // item.InvType = asset.Type;
145 // item.Folder = inventoryFolderID;
146 // item.BasePermissions = 0x7fffffff;
147 // item.CurrentPermissions = 0x7fffffff;
148 // item.EveryOnePermissions = 0;
149 // item.NextPermissions = nextPerms;
150 // item.Flags = wearableType;
151 // item.CreationDate = Util.UnixTimeSinceEpoch();
152
153 // userInfo.AddItem(item);
154 // ourClient.SendInventoryItemCreateUpdate(item);
155 // }
156 // else
157 // {
158 // m_log.ErrorFormat(
159 // "[ASSET TRANSACTIONS]: Could not find user {0} for inventory item creation",
160 // ourClient.AgentId);
161 // }
162 //}
163
164 public void RequestUpdateTaskInventoryItem(
165 IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item)
166 { 138 {
167 if (XferUploaders.ContainsKey(transactionID)) 139 if (XferUploaders.ContainsKey(transactionID))
168 { 140 {
169 AssetBase asset = XferUploaders[transactionID].GetAssetData(); 141 AssetBase asset = GetTransactionAsset(transactionID);
142
143 // Only legacy viewers use this, and they prefer CAPS, which
144 // we have, so this really never runs.
145 // Allow it, but only for "safe" types.
146 if ((InventoryType)item.InvType != InventoryType.Notecard &&
147 (InventoryType)item.InvType != InventoryType.LSL)
148 return;
149
170 if (asset != null) 150 if (asset != null)
171 { 151 {
172 m_log.DebugFormat( 152 asset.FullID = UUID.Random();
173 "[ASSET TRANSACTIONS]: Updating task item {0} in {1} with asset in transaction {2}",
174 item.Name, part.Name, transactionID);
175
176 asset.Name = item.Name; 153 asset.Name = item.Name;
177 asset.Description = item.Description; 154 asset.Description = item.Description;
178 asset.Type = (sbyte)item.Type; 155 asset.Type = (sbyte)item.Type;
179 item.AssetID = asset.FullID; 156 item.AssetID = asset.FullID;
180 157
181 Manager.MyScene.AssetService.Store(asset); 158 m_Scene.AssetService.Store(asset);
182 159
183 if (part.Inventory.UpdateInventoryItem(item)) 160 part.Inventory.UpdateInventoryItem(item);
184 {
185 if ((InventoryType)item.InvType == InventoryType.Notecard)
186 remoteClient.SendAgentAlertMessage("Notecard saved", false);
187 else if ((InventoryType)item.InvType == InventoryType.LSL)
188 remoteClient.SendAgentAlertMessage("Script saved", false);
189 else
190 remoteClient.SendAgentAlertMessage("Item saved", false);
191
192 part.GetProperties(remoteClient);
193 }
194 } 161 }
195 } 162 }
196 } 163 }
197 164
198 165 public void RequestUpdateInventoryItem(IClientAPI remoteClient,
199 public void RequestUpdateInventoryItem(IClientAPI remoteClient, UUID transactionID, 166 UUID transactionID, InventoryItemBase item)
200 InventoryItemBase item)
201 { 167 {
202 if (XferUploaders.ContainsKey(transactionID)) 168 if (XferUploaders.ContainsKey(transactionID))
203 { 169 {
204 UUID assetID = UUID.Combine(transactionID, remoteClient.SecureSessionId); 170 // Here we need to get the old asset to extract the
205 171 // texture UUIDs if it's a wearable.
206 AssetBase asset = Manager.MyScene.AssetService.Get(assetID.ToString()); 172 if (item.AssetType == (int)AssetType.Bodypart ||
207 173 item.AssetType == (int)AssetType.Clothing)
208 if (asset == null)
209 { 174 {
210 asset = GetTransactionAsset(transactionID); 175 AssetBase oldAsset = m_Scene.AssetService.Get(item.AssetID.ToString());
176 if (oldAsset != null)
177 XferUploaders[transactionID].SetOldData(oldAsset.Data);
211 } 178 }
212 179
213 if (asset != null && asset.FullID == assetID) 180 AssetBase asset = GetTransactionAsset(transactionID);
181
182 if (asset != null)
214 { 183 {
215 // Assets never get updated, new ones get created
216 asset.FullID = UUID.Random(); 184 asset.FullID = UUID.Random();
217 asset.Name = item.Name; 185 asset.Name = item.Name;
218 asset.Description = item.Description; 186 asset.Description = item.Description;
219 asset.Type = (sbyte)item.AssetType; 187 asset.Type = (sbyte)item.AssetType;
220 item.AssetID = asset.FullID; 188 item.AssetID = asset.FullID;
221 189
222 Manager.MyScene.AssetService.Store(asset); 190 m_Scene.AssetService.Store(asset);
223 }
224 191
225 IInventoryService invService = Manager.MyScene.InventoryService; 192 IInventoryService invService = m_Scene.InventoryService;
226 invService.UpdateItem(item); 193 invService.UpdateItem(item);
194 }
227 } 195 }
228 } 196 }
229 } 197 }
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
index ae31050..82558de 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
@@ -34,22 +34,19 @@ using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
37using Mono.Addins;
37 38
38namespace OpenSim.Region.CoreModules.Agent.AssetTransaction 39namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
39{ 40{
40 public class AssetTransactionModule : IRegionModule, IAgentAssetTransactions 41 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AssetTransactionModule")]
42 public class AssetTransactionModule : INonSharedRegionModule,
43 IAgentAssetTransactions
41 { 44 {
42// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45// private static readonly ILog m_log = LogManager.GetLogger(
46// MethodBase.GetCurrentMethod().DeclaringType);
43 47
44 private readonly Dictionary<UUID, Scene> RegisteredScenes = new Dictionary<UUID, Scene>(); 48 protected Scene m_Scene;
45 private bool m_dumpAssetsToFile = false; 49 private bool m_dumpAssetsToFile = false;
46 private Scene m_scene = null;
47
48 [Obsolete]
49 public Scene MyScene
50 {
51 get{ return m_scene;}
52 }
53 50
54 /// <summary> 51 /// <summary>
55 /// Each agent has its own singleton collection of transactions 52 /// Each agent has its own singleton collection of transactions
@@ -57,33 +54,24 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
57 private Dictionary<UUID, AgentAssetTransactions> AgentTransactions = 54 private Dictionary<UUID, AgentAssetTransactions> AgentTransactions =
58 new Dictionary<UUID, AgentAssetTransactions>(); 55 new Dictionary<UUID, AgentAssetTransactions>();
59 56
57 #region IRegionModule Members
60 58
61 public AssetTransactionModule() 59 public void Initialise(IConfigSource config)
62 { 60 {
63 //m_log.Debug("creating AgentAssetTransactionModule");
64 } 61 }
65 62
66 #region IRegionModule Members 63 public void AddRegion(Scene scene)
67
68 public void Initialise(Scene scene, IConfigSource config)
69 { 64 {
70 if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) 65 m_Scene = scene;
71 { 66 scene.RegisterModuleInterface<IAgentAssetTransactions>(this);
72 // m_log.Debug("initialising AgentAssetTransactionModule"); 67 scene.EventManager.OnNewClient += NewClient;
73 RegisteredScenes.Add(scene.RegionInfo.RegionID, scene); 68 }
74 scene.RegisterModuleInterface<IAgentAssetTransactions>(this);
75
76 scene.EventManager.OnNewClient += NewClient;
77 }
78 69
79 // EVIL HACK! 70 public void RegionLoaded(Scene scene)
80 // This needs killing! 71 {
81 //
82 if (m_scene == null)
83 m_scene = scene;
84 } 72 }
85 73
86 public void PostInitialise() 74 public void RemoveRegion(Scene scene)
87 { 75 {
88 } 76 }
89 77
@@ -96,9 +84,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
96 get { return "AgentTransactionModule"; } 84 get { return "AgentTransactionModule"; }
97 } 85 }
98 86
99 public bool IsSharedModule 87 public Type ReplaceableInterface
100 { 88 {
101 get { return true; } 89 get { return typeof(IAgentAssetTransactions); }
102 } 90 }
103 91
104 #endregion 92 #endregion
@@ -111,8 +99,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
111 99
112 #region AgentAssetTransactions 100 #region AgentAssetTransactions
113 /// <summary> 101 /// <summary>
114 /// Get the collection of asset transactions for the given user. If one does not already exist, it 102 /// Get the collection of asset transactions for the given user.
115 /// is created. 103 /// If one does not already exist, it is created.
116 /// </summary> 104 /// </summary>
117 /// <param name="userID"></param> 105 /// <param name="userID"></param>
118 /// <returns></returns> 106 /// <returns></returns>
@@ -122,7 +110,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
122 { 110 {
123 if (!AgentTransactions.ContainsKey(userID)) 111 if (!AgentTransactions.ContainsKey(userID))
124 { 112 {
125 AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile); 113 AgentAssetTransactions transactions =
114 new AgentAssetTransactions(userID, m_Scene,
115 m_dumpAssetsToFile);
116
126 AgentTransactions.Add(userID, transactions); 117 AgentTransactions.Add(userID, transactions);
127 } 118 }
128 119
@@ -131,8 +122,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
131 } 122 }
132 123
133 /// <summary> 124 /// <summary>
134 /// Remove the given agent asset transactions. This should be called when a client is departing 125 /// Remove the given agent asset transactions. This should be called
135 /// from a scene (and hence won't be making any more transactions here). 126 /// when a client is departing from a scene (and hence won't be making
127 /// any more transactions here).
136 /// </summary> 128 /// </summary>
137 /// <param name="userID"></param> 129 /// <param name="userID"></param>
138 public void RemoveAgentAssetTransactions(UUID userID) 130 public void RemoveAgentAssetTransactions(UUID userID)
@@ -146,10 +138,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
146 } 138 }
147 139
148 /// <summary> 140 /// <summary>
149 /// Create an inventory item from data that has been received through a transaction. 141 /// Create an inventory item from data that has been received through
150 /// 142 /// a transaction.
151 /// This is called when new clothing or body parts are created. It may also be called in other 143 /// This is called when new clothing or body parts are created.
152 /// situations. 144 /// It may also be called in other situations.
153 /// </summary> 145 /// </summary>
154 /// <param name="remoteClient"></param> 146 /// <param name="remoteClient"></param>
155 /// <param name="transactionID"></param> 147 /// <param name="transactionID"></param>
@@ -161,61 +153,72 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
161 /// <param name="type"></param> 153 /// <param name="type"></param>
162 /// <param name="wearableType"></param> 154 /// <param name="wearableType"></param>
163 /// <param name="nextOwnerMask"></param> 155 /// <param name="nextOwnerMask"></param>
164 public void HandleItemCreationFromTransaction(IClientAPI remoteClient, UUID transactionID, UUID folderID, 156 public void HandleItemCreationFromTransaction(IClientAPI remoteClient,
165 uint callbackID, string description, string name, sbyte invType, 157 UUID transactionID, UUID folderID, uint callbackID,
166 sbyte type, byte wearableType, uint nextOwnerMask) 158 string description, string name, sbyte invType,
159 sbyte type, byte wearableType, uint nextOwnerMask)
167 { 160 {
168 // m_log.DebugFormat( 161// m_log.DebugFormat(
169 // "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name); 162// "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name);
170 163
171 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 164 AgentAssetTransactions transactions =
165 GetUserTransactions(remoteClient.AgentId);
172 166
173 transactions.RequestCreateInventoryItem( 167 transactions.RequestCreateInventoryItem(remoteClient, transactionID,
174 remoteClient, transactionID, folderID, callbackID, description, 168 folderID, callbackID, description, name, invType, type,
175 name, invType, type, wearableType, nextOwnerMask); 169 wearableType, nextOwnerMask);
176 } 170 }
177 171
178 /// <summary> 172 /// <summary>
179 /// Update an inventory item with data that has been received through a transaction. 173 /// Update an inventory item with data that has been received through a
174 /// transaction.
180 /// 175 ///
181 /// This is called when clothing or body parts are updated (for instance, with new textures or 176 /// This is called when clothing or body parts are updated (for
182 /// colours). It may also be called in other situations. 177 /// instance, with new textures or colours). It may also be called in
178 /// other situations.
183 /// </summary> 179 /// </summary>
184 /// <param name="remoteClient"></param> 180 /// <param name="remoteClient"></param>
185 /// <param name="transactionID"></param> 181 /// <param name="transactionID"></param>
186 /// <param name="item"></param> 182 /// <param name="item"></param>
187 public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID, 183 public void HandleItemUpdateFromTransaction(IClientAPI remoteClient,
188 InventoryItemBase item) 184 UUID transactionID, InventoryItemBase item)
189 { 185 {
190 // m_log.DebugFormat( 186// m_log.DebugFormat(
191 // "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}", 187// "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}",
192 // item.Name); 188// item.Name);
193 189
194 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 190 AgentAssetTransactions transactions =
191 GetUserTransactions(remoteClient.AgentId);
195 192
196 transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item); 193 transactions.RequestUpdateInventoryItem(remoteClient,
194 transactionID, item);
197 } 195 }
198 196
199 /// <summary> 197 /// <summary>
200 /// Update a task inventory item with data that has been received through a transaction. 198 /// Update a task inventory item with data that has been received
199 /// through a transaction.
201 /// 200 ///
202 /// This is currently called when, for instance, a notecard in a prim is saved. The data is sent 201 /// This is currently called when, for instance, a notecard in a prim
203 /// up through a single AssetUploadRequest. A subsequent UpdateTaskInventory then references the transaction 202 /// is saved. The data is sent up through a single AssetUploadRequest.
203 /// A subsequent UpdateTaskInventory then references the transaction
204 /// and comes through this method. 204 /// and comes through this method.
205 /// </summary> 205 /// </summary>
206 /// <param name="remoteClient"></param> 206 /// <param name="remoteClient"></param>
207 /// <param name="transactionID"></param> 207 /// <param name="transactionID"></param>
208 /// <param name="item"></param> 208 /// <param name="item"></param>
209 public void HandleTaskItemUpdateFromTransaction( 209 public void HandleTaskItemUpdateFromTransaction(IClientAPI remoteClient,
210 IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item) 210 SceneObjectPart part, UUID transactionID,
211 TaskInventoryItem item)
211 { 212 {
212 // m_log.DebugFormat( 213// m_log.DebugFormat(
213 // "[TRANSACTIONS MANAGER] Called HandleTaskItemUpdateFromTransaction with item {0}", 214// "[TRANSACTIONS MANAGER] Called HandleTaskItemUpdateFromTransaction with item {0}",
214 // item.Name); 215// item.Name);
215 216
216 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 217 AgentAssetTransactions transactions =
218 GetUserTransactions(remoteClient.AgentId);
217 219
218 transactions.RequestUpdateTaskInventoryItem(remoteClient, part, transactionID, item); 220 transactions.RequestUpdateTaskInventoryItem(remoteClient, part,
221 transactionID, item);
219 } 222 }
220 223
221 /// <summary> 224 /// <summary>
@@ -227,8 +230,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
227 /// <param name="type"></param> 230 /// <param name="type"></param>
228 /// <param name="data"></param></param> 231 /// <param name="data"></param></param>
229 /// <param name="tempFile"></param> 232 /// <param name="tempFile"></param>
230 public void HandleUDPUploadRequest(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, 233 public void HandleUDPUploadRequest(IClientAPI remoteClient,
231 byte[] data, bool storeLocal, bool tempFile) 234 UUID assetID, UUID transaction, sbyte type, byte[] data,
235 bool storeLocal, bool tempFile)
232 { 236 {
233// m_log.Debug("HandleUDPUploadRequest - assetID: " + assetID.ToString() + " transaction: " + transaction.ToString() + " type: " + type.ToString() + " storelocal: " + storeLocal + " tempFile: " + tempFile); 237// m_log.Debug("HandleUDPUploadRequest - assetID: " + assetID.ToString() + " transaction: " + transaction.ToString() + " type: " + type.ToString() + " storelocal: " + storeLocal + " tempFile: " + tempFile);
234 238
@@ -251,27 +255,33 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
251 } 255 }
252 } 256 }
253 257
254 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 258 AgentAssetTransactions transactions =
259 GetUserTransactions(remoteClient.AgentId);
260
261 AssetXferUploader uploader =
262 transactions.RequestXferUploader(transaction);
255 263
256 AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
257 if (uploader != null) 264 if (uploader != null)
258 { 265 {
259 uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile); 266 uploader.Initialise(remoteClient, assetID, transaction, type,
267 data, storeLocal, tempFile);
260 } 268 }
261 } 269 }
262 270
263 /// <summary> 271 /// <summary>
264 /// Handle asset transfer data packets received in response to the asset upload request in 272 /// Handle asset transfer data packets received in response to the
265 /// HandleUDPUploadRequest() 273 /// asset upload request in HandleUDPUploadRequest()
266 /// </summary> 274 /// </summary>
267 /// <param name="remoteClient"></param> 275 /// <param name="remoteClient"></param>
268 /// <param name="xferID"></param> 276 /// <param name="xferID"></param>
269 /// <param name="packetID"></param> 277 /// <param name="packetID"></param>
270 /// <param name="data"></param> 278 /// <param name="data"></param>
271 public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) 279 public void HandleXfer(IClientAPI remoteClient, ulong xferID,
280 uint packetID, byte[] data)
272 { 281 {
273 //m_log.Debug("xferID: " + xferID + " packetID: " + packetID + " data!"); 282 //m_log.Debug("xferID: " + xferID + " packetID: " + packetID + " data!");
274 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 283 AgentAssetTransactions transactions =
284 GetUserTransactions(remoteClient.AgentId);
275 285
276 transactions.HandleXfer(xferID, packetID, data); 286 transactions.HandleXfer(xferID, packetID, data);
277 } 287 }
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
index 4609738..b8c8c85 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
@@ -28,16 +28,19 @@
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Reflection; 30using System.Reflection;
31using System.Collections.Generic;
31using log4net; 32using log4net;
32using OpenMetaverse; 33using OpenMetaverse;
33using OpenSim.Framework; 34using OpenSim.Framework;
34 35using OpenSim.Region.Framework.Scenes;
35using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
36 37
37namespace OpenSim.Region.CoreModules.Agent.AssetTransaction 38namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
38{ 39{
39 public class AssetXferUploader 40 public class AssetXferUploader
40 { 41 {
42 // Viewer's notion of the default texture
43 private UUID defaultID = new UUID("5748decc-f629-461c-9a36-a35a221fe21f");
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 45
43 private AssetBase m_asset; 46 private AssetBase m_asset;
@@ -50,17 +53,18 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
50 private bool m_finished = false; 53 private bool m_finished = false;
51 private string m_name = String.Empty; 54 private string m_name = String.Empty;
52 private bool m_storeLocal; 55 private bool m_storeLocal;
53 private AgentAssetTransactions m_userTransactions;
54 private uint nextPerm = 0; 56 private uint nextPerm = 0;
55 private IClientAPI ourClient; 57 private IClientAPI ourClient;
56 private UUID TransactionID = UUID.Zero; 58 private UUID TransactionID = UUID.Zero;
57 private sbyte type = 0; 59 private sbyte type = 0;
58 private byte wearableType = 0; 60 private byte wearableType = 0;
61 private byte[] m_oldData = null;
59 public ulong XferID; 62 public ulong XferID;
63 private Scene m_Scene;
60 64
61 public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) 65 public AssetXferUploader(Scene scene, bool dumpAssetToFile)
62 { 66 {
63 m_userTransactions = transactions; 67 m_Scene = scene;
64 m_dumpAssetToFile = dumpAssetToFile; 68 m_dumpAssetToFile = dumpAssetToFile;
65 } 69 }
66 70
@@ -108,11 +112,13 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
108 /// <param name="packetID"></param> 112 /// <param name="packetID"></param>
109 /// <param name="data"></param> 113 /// <param name="data"></param>
110 /// <returns>True if the transfer is complete, false otherwise</returns> 114 /// <returns>True if the transfer is complete, false otherwise</returns>
111 public bool Initialise(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, byte[] data, 115 public bool Initialise(IClientAPI remoteClient, UUID assetID,
112 bool storeLocal, bool tempFile) 116 UUID transaction, sbyte type, byte[] data, bool storeLocal,
117 bool tempFile)
113 { 118 {
114 ourClient = remoteClient; 119 ourClient = remoteClient;
115 m_asset = new AssetBase(assetID, "blank", type, remoteClient.AgentId.ToString()); 120 m_asset = new AssetBase(assetID, "blank", type,
121 remoteClient.AgentId.ToString());
116 m_asset.Data = data; 122 m_asset.Data = data;
117 m_asset.Description = "empty"; 123 m_asset.Description = "empty";
118 m_asset.Local = storeLocal; 124 m_asset.Local = storeLocal;
@@ -137,12 +143,14 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
137 protected void RequestStartXfer() 143 protected void RequestStartXfer()
138 { 144 {
139 XferID = Util.GetNextXferID(); 145 XferID = Util.GetNextXferID();
140 ourClient.SendXferRequest(XferID, m_asset.Type, m_asset.FullID, 0, new byte[0]); 146 ourClient.SendXferRequest(XferID, m_asset.Type, m_asset.FullID,
147 0, new byte[0]);
141 } 148 }
142 149
143 protected void SendCompleteMessage() 150 protected void SendCompleteMessage()
144 { 151 {
145 ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true, m_asset.FullID); 152 ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true,
153 m_asset.FullID);
146 154
147 m_finished = true; 155 m_finished = true;
148 if (m_createItem) 156 if (m_createItem)
@@ -151,18 +159,20 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
151 } 159 }
152 else if (m_storeLocal) 160 else if (m_storeLocal)
153 { 161 {
154 m_userTransactions.Manager.MyScene.AssetService.Store(m_asset); 162 m_Scene.AssetService.Store(m_asset);
155 } 163 }
156 164
157 m_log.DebugFormat( 165 m_log.DebugFormat(
158 "[ASSET TRANSACTIONS]: Uploaded asset {0} for transaction {1}", m_asset.FullID, TransactionID); 166 "[ASSET TRANSACTIONS]: Uploaded asset {0} for transaction {1}",
167 m_asset.FullID, TransactionID);
159 168
160 if (m_dumpAssetToFile) 169 if (m_dumpAssetToFile)
161 { 170 {
162 DateTime now = DateTime.Now; 171 DateTime now = DateTime.Now;
163 string filename = 172 string filename =
164 String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat", now.Year, now.Month, now.Day, 173 String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat",
165 now.Hour, now.Minute, now.Second, m_asset.Name, m_asset.Type); 174 now.Year, now.Month, now.Day, now.Hour, now.Minute,
175 now.Second, m_asset.Name, m_asset.Type);
166 SaveAssetToFile(filename, m_asset.Data); 176 SaveAssetToFile(filename, m_asset.Data);
167 } 177 }
168 } 178 }
@@ -181,9 +191,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
181 fs.Close(); 191 fs.Close();
182 } 192 }
183 193
184 public void RequestCreateInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID folderID, 194 public void RequestCreateInventoryItem(IClientAPI remoteClient,
185 uint callbackID, string description, string name, sbyte invType, 195 UUID transactionID, UUID folderID, uint callbackID,
186 sbyte type, byte wearableType, uint nextOwnerMask) 196 string description, string name, sbyte invType,
197 sbyte type, byte wearableType, uint nextOwnerMask)
187 { 198 {
188 if (TransactionID == transactionID) 199 if (TransactionID == transactionID)
189 { 200 {
@@ -212,7 +223,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
212 223
213 private void DoCreateItem(uint callbackID) 224 private void DoCreateItem(uint callbackID)
214 { 225 {
215 m_userTransactions.Manager.MyScene.AssetService.Store(m_asset); 226 ValidateAssets();
227 m_Scene.AssetService.Store(m_asset);
216 228
217 InventoryItemBase item = new InventoryItemBase(); 229 InventoryItemBase item = new InventoryItemBase();
218 item.Owner = ourClient.AgentId; 230 item.Owner = ourClient.AgentId;
@@ -232,12 +244,77 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
232 item.Flags = (uint) wearableType; 244 item.Flags = (uint) wearableType;
233 item.CreationDate = Util.UnixTimeSinceEpoch(); 245 item.CreationDate = Util.UnixTimeSinceEpoch();
234 246
235 if (m_userTransactions.Manager.MyScene.AddInventoryItem(item)) 247 if (m_Scene.AddInventoryItem(item))
236 ourClient.SendInventoryItemCreateUpdate(item, callbackID); 248 ourClient.SendInventoryItemCreateUpdate(item, callbackID);
237 else 249 else
238 ourClient.SendAlertMessage("Unable to create inventory item"); 250 ourClient.SendAlertMessage("Unable to create inventory item");
239 } 251 }
240 252
253 private void ValidateAssets()
254 {
255 if (m_asset.Type == (sbyte)AssetType.Clothing ||
256 m_asset.Type == (sbyte)AssetType.Bodypart)
257 {
258 string content = System.Text.Encoding.ASCII.GetString(m_asset.Data);
259 string[] lines = content.Split(new char[] {'\n'});
260
261 List<string> validated = new List<string>();
262
263 Dictionary<int, UUID> allowed = ExtractTexturesFromOldData();
264
265 int textures = 0;
266
267 foreach (string line in lines)
268 {
269 try
270 {
271 if (line.StartsWith("textures "))
272 {
273 textures = Convert.ToInt32(line.Substring(9));
274 validated.Add(line);
275 }
276 else if (textures > 0)
277 {
278 string[] parts = line.Split(new char[] {' '});
279
280 UUID tx = new UUID(parts[1]);
281 int id = Convert.ToInt32(parts[0]);
282
283 if (tx == defaultID || tx == UUID.Zero ||
284 (allowed.ContainsKey(id) && allowed[id] == tx))
285 {
286 validated.Add(parts[0] + " " + tx.ToString());
287 }
288 else
289 {
290 int perms = m_Scene.InventoryService.GetAssetPermissions(ourClient.AgentId, tx);
291 int full = (int)(PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Copy);
292
293 if ((perms & full) != full)
294 {
295 m_log.ErrorFormat("[ASSET UPLOADER]: REJECTED update with texture {0} from {1} because they do not own the texture", tx, ourClient.AgentId);
296 validated.Add(parts[0] + " " + defaultID.ToString());
297 }
298 }
299 textures--;
300 }
301 else
302 {
303 validated.Add(line);
304 }
305 }
306 catch
307 {
308 // If it's malformed, skip it
309 }
310 }
311
312 string final = String.Join("\n", validated.ToArray());
313
314 m_asset.Data = System.Text.Encoding.ASCII.GetBytes(final);
315 }
316 }
317
241 /// <summary> 318 /// <summary>
242 /// Get the asset data uploaded in this transfer. 319 /// Get the asset data uploaded in this transfer.
243 /// </summary> 320 /// </summary>
@@ -246,10 +323,55 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
246 { 323 {
247 if (m_finished) 324 if (m_finished)
248 { 325 {
326 ValidateAssets();
249 return m_asset; 327 return m_asset;
250 } 328 }
251 329
252 return null; 330 return null;
253 } 331 }
332
333 public void SetOldData(byte[] d)
334 {
335 m_oldData = d;
336 }
337
338 private Dictionary<int,UUID> ExtractTexturesFromOldData()
339 {
340 Dictionary<int,UUID> result = new Dictionary<int,UUID>();
341 if (m_oldData == null)
342 return result;
343
344 string content = System.Text.Encoding.ASCII.GetString(m_oldData);
345 string[] lines = content.Split(new char[] {'\n'});
346
347 int textures = 0;
348
349 foreach (string line in lines)
350 {
351 try
352 {
353 if (line.StartsWith("textures "))
354 {
355 textures = Convert.ToInt32(line.Substring(9));
356 }
357 else if (textures > 0)
358 {
359 string[] parts = line.Split(new char[] {' '});
360
361 UUID tx = new UUID(parts[1]);
362 int id = Convert.ToInt32(parts[0]);
363 result[id] = tx;
364 textures--;
365 }
366 }
367 catch
368 {
369 // If it's malformed, skip it
370 }
371 }
372
373 return result;
374 }
254 } 375 }
255} 376}
377
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 63e7ddc..7d6d191 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -115,7 +115,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
115 115
116 #endregion 116 #endregion
117 117
118 118 /// <summary>
119 /// Check for the existence of the baked texture assets. Request a rebake
120 /// unless checkonly is true.
121 /// </summary>
122 /// <param name="client"></param>
123 /// <param name="checkonly"></param>
119 public bool ValidateBakedTextureCache(IClientAPI client) 124 public bool ValidateBakedTextureCache(IClientAPI client)
120 { 125 {
121 return ValidateBakedTextureCache(client, true); 126 return ValidateBakedTextureCache(client, true);
@@ -157,12 +162,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
157 // one and we're done otherwise, ask for a rebake 162 // one and we're done otherwise, ask for a rebake
158 if (checkonly) return false; 163 if (checkonly) return false;
159 164
160 m_log.WarnFormat("[AVFACTORY] missing baked texture {0}, request rebake",face.TextureID); 165 m_log.InfoFormat("[AVFACTORY] missing baked texture {0}, request rebake",face.TextureID);
161 client.SendRebakeAvatarTextures(face.TextureID); 166 client.SendRebakeAvatarTextures(face.TextureID);
162 } 167 }
163 } 168 }
164 169
165 m_log.WarnFormat("[AVFACTORY]: complete texture check for {0}",client.AgentId); 170 m_log.InfoFormat("[AVFACTORY]: complete texture check for {0}",client.AgentId);
166 171
167 // If we only found default textures, then the appearance is not cached 172 // If we only found default textures, then the appearance is not cached
168 return (defonly ? false : true); 173 return (defonly ? false : true);
@@ -182,8 +187,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
182 return; 187 return;
183 } 188 }
184 189
185 m_log.WarnFormat("[AVFACTORY]: start SetAppearance for {0}",client.AgentId); 190 m_log.InfoFormat("[AVFACTORY]: start SetAppearance for {0}",client.AgentId);
186 191
192 // TODO: This is probably not necessary any longer, just assume the
193 // textureEntry set implies that the appearance transaction is complete
187 bool changed = false; 194 bool changed = false;
188 195
189 // Process the texture entry transactionally, this doesn't guarantee that Appearance is 196 // Process the texture entry transactionally, this doesn't guarantee that Appearance is
@@ -203,7 +210,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
203 { 210 {
204 changed = sp.Appearance.SetTextureEntries(textureEntry) || changed; 211 changed = sp.Appearance.SetTextureEntries(textureEntry) || changed;
205 212
206 m_log.WarnFormat("[AVFACTORY]: received texture update for {0}",client.AgentId); 213 m_log.InfoFormat("[AVFACTORY]: received texture update for {0}",client.AgentId);
207 Util.FireAndForget(delegate(object o) { ValidateBakedTextureCache(client,false); }); 214 Util.FireAndForget(delegate(object o) { ValidateBakedTextureCache(client,false); });
208 215
209 // This appears to be set only in the final stage of the appearance 216 // This appears to be set only in the final stage of the appearance
@@ -216,13 +223,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
216 223
217 } 224 }
218 225
219// // If something changed in the appearance then queue an appearance save
220// if (changed)
221// QueueAppearanceSave(client.AgentId);
222
223// // And always queue up an appearance update to send out
224// QueueAppearanceSend(client.AgentId);
225
226 // m_log.WarnFormat("[AVFACTORY]: complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString()); 226 // m_log.WarnFormat("[AVFACTORY]: complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString());
227 } 227 }
228 228
@@ -377,9 +377,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
377 377
378 // m_log.WarnFormat("[AVFACTORY]: AvatarIsWearing called for {0}", client.AgentId); 378 // m_log.WarnFormat("[AVFACTORY]: AvatarIsWearing called for {0}", client.AgentId);
379 379
380 // we need to clean out the existing textures
381 sp.Appearance.ResetAppearance();
382
380 // operate on a copy of the appearance so we don't have to lock anything 383 // operate on a copy of the appearance so we don't have to lock anything
381 AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance, false); 384 AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance, false);
382 sp.Appearance.ResetBakedTextures(); // this makes sure we don't reuse old textures if the baking takes time
383 385
384 foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) 386 foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
385 { 387 {
diff --git a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs
index 6da41db..088b818 100644
--- a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs
+++ b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs
@@ -34,6 +34,17 @@ using OpenSim.Region.Framework.Scenes;
34 34
35namespace OpenSim.Region.Examples.SimpleModule 35namespace OpenSim.Region.Examples.SimpleModule
36{ 36{
37 /// <summary>
38 /// Example region module.
39 /// </summary>
40 /// <remarks>
41 /// This is an old and unmaintained region module which uses the old style module interface. It is not loaded into
42 /// OpenSim by default. If you want to try enabling it, look in the bin folder of this project.
43 /// Please see the README.txt in this project on the filesystem for some more information.
44 /// Nonetheless, it may contain some useful example code so has been left here for now.
45 ///
46 /// You can see bare bones examples of the more modern region module system in OpenSim/Region/OptionalModules/Example
47 /// </remarks>
37 public class RegionModule : IRegionModule 48 public class RegionModule : IRegionModule
38 { 49 {
39 #region IRegionModule Members 50 #region IRegionModule Members
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index d17814d..792115a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2391,16 +2391,14 @@ namespace OpenSim.Region.Framework.Scenes
2391 m_log.DebugFormat("[SCENE]: Problem adding scene object {0} in {1} ", sog.UUID, RegionInfo.RegionName); 2391 m_log.DebugFormat("[SCENE]: Problem adding scene object {0} in {1} ", sog.UUID, RegionInfo.RegionName);
2392 return false; 2392 return false;
2393 } 2393 }
2394 2394
2395 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 2); 2395 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject));
2396 2396
2397 newObject.ResumeScripts(); 2397 newObject.ResumeScripts();
2398 2398
2399 // Do this as late as possible so that listeners have full access to the incoming object 2399 // Do this as late as possible so that listeners have full access to the incoming object
2400 EventManager.TriggerOnIncomingSceneObject(newObject); 2400 EventManager.TriggerOnIncomingSceneObject(newObject);
2401 2401
2402 TriggerChangedTeleport(newObject);
2403
2404 return true; 2402 return true;
2405 } 2403 }
2406 2404
@@ -2527,7 +2525,7 @@ namespace OpenSim.Region.Framework.Scenes
2527 return true; 2525 return true;
2528 } 2526 }
2529 2527
2530 private void TriggerChangedTeleport(SceneObjectGroup sog) 2528 private int GetStateSource(SceneObjectGroup sog)
2531 { 2529 {
2532 ScenePresence sp = GetScenePresence(sog.OwnerID); 2530 ScenePresence sp = GetScenePresence(sog.OwnerID);
2533 2531
@@ -2538,13 +2536,12 @@ namespace OpenSim.Region.Framework.Scenes
2538 if (aCircuit != null && (aCircuit.teleportFlags != (uint)TeleportFlags.Default)) 2536 if (aCircuit != null && (aCircuit.teleportFlags != (uint)TeleportFlags.Default))
2539 { 2537 {
2540 // This will get your attention 2538 // This will get your attention
2541 //m_log.Error("[XXX] Triggering "); 2539 //m_log.Error("[XXX] Triggering CHANGED_TELEPORT");
2542 2540
2543 // Trigger CHANGED_TELEPORT 2541 return 5; // StateSource.Teleporting
2544 sp.Scene.EventManager.TriggerOnScriptChangedEvent(sog.LocalId, (uint)Changed.TELEPORT);
2545 } 2542 }
2546
2547 } 2543 }
2544 return 2; // StateSource.PrimCrossing
2548 } 2545 }
2549 2546
2550 #endregion 2547 #endregion
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index b2d9358..ecc7f40 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -1639,6 +1639,7 @@ namespace OpenSim.Region.Framework.Scenes
1639 { 1639 {
1640 parentGroup.areUpdatesSuspended = false; 1640 parentGroup.areUpdatesSuspended = false;
1641 parentGroup.HasGroupChanged = true; 1641 parentGroup.HasGroupChanged = true;
1642 parentGroup.ProcessBackup(m_parentScene.SimulationDataService, true);
1642 parentGroup.ScheduleGroupForFullUpdate(); 1643 parentGroup.ScheduleGroupForFullUpdate();
1643 Monitor.Exit(m_updateLock); 1644 Monitor.Exit(m_updateLock);
1644 } 1645 }
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 5a842d8..7ce94d4 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -2789,7 +2789,7 @@ namespace OpenSim.Region.Framework.Scenes
2789 // If we aren't using a cached appearance, then clear out the baked textures 2789 // If we aren't using a cached appearance, then clear out the baked textures
2790 if (! cachedappearance) 2790 if (! cachedappearance)
2791 { 2791 {
2792 m_appearance.ResetBakedTextures(); 2792 m_appearance.ResetAppearance();
2793 if (m_scene.AvatarFactory != null) 2793 if (m_scene.AvatarFactory != null)
2794 m_scene.AvatarFactory.QueueAppearanceSave(UUID); 2794 m_scene.AvatarFactory.QueueAppearanceSave(UUID);
2795 } 2795 }
@@ -2799,12 +2799,12 @@ namespace OpenSim.Region.Framework.Scenes
2799 // again here... this comes after the cached appearance check because the avatars 2799 // again here... this comes after the cached appearance check because the avatars
2800 // appearance goes into the avatar update packet 2800 // appearance goes into the avatar update packet
2801 SendAvatarDataToAllAgents(); 2801 SendAvatarDataToAllAgents();
2802 SendAppearanceToAgent(this);
2802 2803
2803 // If we are using the the cached appearance then send it out to everyone 2804 // If we are using the the cached appearance then send it out to everyone
2804 if (cachedappearance) 2805 if (cachedappearance)
2805 { 2806 {
2806 m_log.WarnFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); 2807 m_log.InfoFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name);
2807 SendAppearanceToAgent(this);
2808 2808
2809 // If the avatars baked textures are all in the cache, then we have a 2809 // If the avatars baked textures are all in the cache, then we have a
2810 // complete appearance... send it out, if not, then we'll send it when 2810 // complete appearance... send it out, if not, then we'll send it when
diff --git a/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs b/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs
new file mode 100644
index 0000000..7d37135
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs
@@ -0,0 +1,86 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using log4net;
31using Mono.Addins;
32using Nini.Config;
33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes;
35
36namespace OpenSim.Region.OptionalModules.Example.BareBonesNonShared
37{
38 /// <summary>
39 /// Simplest possible example of a non-shared region module.
40 /// </summary>
41 /// <remarks>
42 /// This module is the simplest possible example of a non-shared region module (a module where each scene/region
43 /// in the simulator has its own copy). If anybody wants to create a more complex example in the future then
44 /// please create a separate class.
45 ///
46 /// This module is not active by default. If you want to see it in action,
47 /// then just uncomment the line below starting with [Extension(Path...
48 ///
49 /// When the module is enabled it will print messages when it receives certain events to the screen and the log
50 /// file.
51 /// </remarks>
52 //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BareBonesNonSharedModule")]
53 public class BareBonesNonSharedModule : INonSharedRegionModule
54 {
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56
57 public string Name { get { return "Bare Bones Non Shared Module"; } }
58
59 public Type ReplaceableInterface { get { return null; } }
60
61 public void Initialise(IConfigSource source)
62 {
63 m_log.DebugFormat("[BARE BONES NON SHARED]: INITIALIZED MODULE");
64 }
65
66 public void Close()
67 {
68 m_log.DebugFormat("[BARE BONES NON SHARED]: CLOSED MODULE");
69 }
70
71 public void AddRegion(Scene scene)
72 {
73 m_log.DebugFormat("[BARE BONES NON SHARED]: REGION {0} ADDED", scene.RegionInfo.RegionName);
74 }
75
76 public void RemoveRegion(Scene scene)
77 {
78 m_log.DebugFormat("[BARE BONES NON SHARED]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
79 }
80
81 public void RegionLoaded(Scene scene)
82 {
83 m_log.DebugFormat("[BARE BONES NON SHARED]: REGION {0} LOADED", scene.RegionInfo.RegionName);
84 }
85 }
86} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs
new file mode 100644
index 0000000..781fe95
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs
@@ -0,0 +1,91 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using log4net;
31using Mono.Addins;
32using Nini.Config;
33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes;
35
36namespace OpenSim.Region.OptionalModules.Example.BareBonesShared
37{
38 /// <summary>
39 /// Simplest possible example of a shared region module.
40 /// </summary>
41 /// <remarks>
42 /// This module is the simplest possible example of a shared region module (a module which is shared by every
43 /// scene/region running on the simulator). If anybody wants to create a more complex example in the future then
44 /// please create a separate class.
45 ///
46 /// This module is not active by default. If you want to see it in action,
47 /// then just uncomment the line below starting with [Extension(Path...
48 ///
49 /// When the module is enabled it will print messages when it receives certain events to the screen and the log
50 /// file.
51 /// </remarks>
52 //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BareBonesSharedModule")]
53 public class BareBonesSharedModule : ISharedRegionModule
54 {
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56
57 public string Name { get { return "Bare Bones Shared Module"; } }
58
59 public Type ReplaceableInterface { get { return null; } }
60
61 public void Initialise(IConfigSource source)
62 {
63 m_log.DebugFormat("[BARE BONES SHARED]: INITIALIZED MODULE");
64 }
65
66 public void PostInitialise()
67 {
68 m_log.DebugFormat("[BARE BONES SHARED]: POST INITIALIZED MODULE");
69 }
70
71 public void Close()
72 {
73 m_log.DebugFormat("[BARE BONES SHARED]: CLOSED MODULE");
74 }
75
76 public void AddRegion(Scene scene)
77 {
78 m_log.DebugFormat("[BARE BONES SHARED]: REGION {0} ADDED", scene.RegionInfo.RegionName);
79 }
80
81 public void RemoveRegion(Scene scene)
82 {
83 m_log.DebugFormat("[BARE BONES SHARED]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
84 }
85
86 public void RegionLoaded(Scene scene)
87 {
88 m_log.DebugFormat("[BARE BONES SHARED]: REGION {0} LOADED", scene.RegionInfo.RegionName);
89 }
90 }
91} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
index 0c99d8c..8b7871b 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
@@ -42,7 +42,8 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
42 NewRez = 1, 42 NewRez = 1,
43 PrimCrossing = 2, 43 PrimCrossing = 2,
44 ScriptedRez = 3, 44 ScriptedRez = 3,
45 AttachedRez = 4 45 AttachedRez = 4,
46 Teleporting = 5
46 } 47 }
47 48
48 public interface IScriptWorkItem 49 public interface IScriptWorkItem
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 5288cd3..9548253 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -391,19 +391,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
391 } 391 }
392 else if (m_stateSource == StateSource.RegionStart) 392 else if (m_stateSource == StateSource.RegionStart)
393 { 393 {
394// m_log.Debug("[Script] Posted changed(CHANGED_REGION_RESTART) to script"); 394 //m_log.Debug("[Script] Posted changed(CHANGED_REGION_RESTART) to script");
395 PostEvent(new EventParams("changed", 395 PostEvent(new EventParams("changed",
396 new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION_RESTART) }, 396 new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION_RESTART) }, new DetectParams[0]));
397 new DetectParams[0]));
398 } 397 }
399 else if (m_stateSource == StateSource.PrimCrossing) 398 else if (m_stateSource == StateSource.PrimCrossing || m_stateSource == StateSource.Teleporting)
400 { 399 {
401 // CHANGED_REGION 400 // CHANGED_REGION
402 PostEvent(new EventParams("changed", 401 PostEvent(new EventParams("changed",
403 new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION) }, 402 new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION) }, new DetectParams[0]));
404 new DetectParams[0])); 403
404 // CHANGED_TELEPORT
405 if (m_stateSource == StateSource.Teleporting)
406 PostEvent(new EventParams("changed",
407 new Object[] { new LSL_Types.LSLInteger((int)Changed.TELEPORT) }, new DetectParams[0]));
405 } 408 }
406 } 409 }
407 else 410 else
408 { 411 {
409 Start(); 412 Start();