aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie Thielker2014-08-07 16:55:00 +0200
committerMelanie Thielker2014-08-07 16:55:00 +0200
commita06d66b70b7eb6c76b4dbbf915a1b02ca21db17f (patch)
tree39219012afb0e847debf29fe0c9170b445bc4056 /OpenSim
parentMerge branch 'ubitworkmaster' (diff)
parentminor clean, dont check for cache if we aren't using it.. (diff)
downloadopensim-SC_OLD-a06d66b70b7eb6c76b4dbbf915a1b02ca21db17f.zip
opensim-SC_OLD-a06d66b70b7eb6c76b4dbbf915a1b02ca21db17f.tar.gz
opensim-SC_OLD-a06d66b70b7eb6c76b4dbbf915a1b02ca21db17f.tar.bz2
opensim-SC_OLD-a06d66b70b7eb6c76b4dbbf915a1b02ca21db17f.tar.xz
Merge branch 'ubitworkmaster'
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs2
-rw-r--r--OpenSim/Framework/PermissionsUtil.cs4
-rw-r--r--OpenSim/Framework/WearableCacheItem.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs122
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs153
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs34
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs290
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs1160
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs48
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs9
12 files changed, 951 insertions, 893 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index cf2e037..eb5d784 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -2942,7 +2942,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2942 /// </summary> 2942 /// </summary>
2943 private void ApplyNextOwnerPermissions(InventoryItemBase item) 2943 private void ApplyNextOwnerPermissions(InventoryItemBase item)
2944 { 2944 {
2945 if (item.InvType == (int)InventoryType.Object) 2945 if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
2946 { 2946 {
2947 uint perms = item.CurrentPermissions; 2947 uint perms = item.CurrentPermissions;
2948 PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms); 2948 PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms);
diff --git a/OpenSim/Framework/PermissionsUtil.cs b/OpenSim/Framework/PermissionsUtil.cs
index d785a78..5d3186d 100644
--- a/OpenSim/Framework/PermissionsUtil.cs
+++ b/OpenSim/Framework/PermissionsUtil.cs
@@ -72,8 +72,8 @@ namespace OpenSim.Framework
72 /// <param name="mainPerms">The permissions variable to modify.</param> 72 /// <param name="mainPerms">The permissions variable to modify.</param>
73 public static void ApplyFoldedPermissions(uint foldedPerms, ref uint mainPerms) 73 public static void ApplyFoldedPermissions(uint foldedPerms, ref uint mainPerms)
74 { 74 {
75 if ((foldedPerms & 7) == 0) 75// if ((foldedPerms & 7) == 0)
76 return; // assume that if the folded permissions are 0 then this means that they weren't actually recorded 76// return; // assume that if the folded permissions are 0 then this means that they weren't actually recorded
77 77
78 if ((foldedPerms & ((uint)PermissionMask.Copy >> 13)) == 0) 78 if ((foldedPerms & ((uint)PermissionMask.Copy >> 13)) == 0)
79 mainPerms &= ~(uint)PermissionMask.Copy; 79 mainPerms &= ~(uint)PermissionMask.Copy;
diff --git a/OpenSim/Framework/WearableCacheItem.cs b/OpenSim/Framework/WearableCacheItem.cs
index 1aecf79..cde2862 100644
--- a/OpenSim/Framework/WearableCacheItem.cs
+++ b/OpenSim/Framework/WearableCacheItem.cs
@@ -46,7 +46,7 @@ namespace OpenSim.Framework
46 int itemmax = 21; 46 int itemmax = 21;
47 WearableCacheItem[] retitems = new WearableCacheItem[itemmax]; 47 WearableCacheItem[] retitems = new WearableCacheItem[itemmax];
48 for (uint i=0;i<itemmax;i++) 48 for (uint i=0;i<itemmax;i++)
49 retitems[i] = new WearableCacheItem() {CacheId = UUID.Zero, TextureID = UUID.Zero, TextureIndex = i + 1}; 49 retitems[i] = new WearableCacheItem() {CacheId = UUID.Zero, TextureID = UUID.Zero, TextureIndex = i};
50 return retitems; 50 return retitems;
51 } 51 }
52 public static WearableCacheItem[] FromOSD(OSD pInput, IImprovedAssetCache dataCache) 52 public static WearableCacheItem[] FromOSD(OSD pInput, IImprovedAssetCache dataCache)
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
index 47988dd..50e9275 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
@@ -96,9 +96,7 @@ namespace OpenSim.Region.ClientStack.Linden
96 s.EventManager.OnRemovePresence -= DeRegisterPresence; 96 s.EventManager.OnRemovePresence -= DeRegisterPresence;
97 m_BakedTextureModule = null; 97 m_BakedTextureModule = null;
98 m_scene = null; 98 m_scene = null;
99 } 99 }
100
101
102 100
103 public void RegionLoaded(Scene s) 101 public void RegionLoaded(Scene s)
104 { 102 {
@@ -110,44 +108,58 @@ namespace OpenSim.Region.ClientStack.Linden
110 108
111 private void DeRegisterPresence(UUID agentId) 109 private void DeRegisterPresence(UUID agentId)
112 { 110 {
113 ScenePresence presence = null; 111// ScenePresence presence = null;
114 if (m_scene.TryGetScenePresence(agentId, out presence)) 112// if (m_scene.TryGetScenePresence(agentId, out presence))
115 { 113 {
116 presence.ControllingClient.OnSetAppearance -= CaptureAppearanceSettings; 114// presence.ControllingClient.OnSetAppearance -= CaptureAppearanceSettings;
117 } 115 }
118 116
119 } 117 }
120 118
121 private void RegisterNewPresence(ScenePresence presence) 119 private void RegisterNewPresence(ScenePresence presence)
122 { 120 {
123 presence.ControllingClient.OnSetAppearance += CaptureAppearanceSettings; 121// presence.ControllingClient.OnSetAppearance += CaptureAppearanceSettings;
124
125 } 122 }
126 123
127 private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) 124/* not in use. work done in AvatarFactoryModule ValidateBakedTextureCache() and UpdateBakedTextureCache()
128 { 125 private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems)
129 int maxCacheitemsLoop = cacheItems.Length;
130 if (maxCacheitemsLoop > AvatarWearable.MAX_WEARABLES)
131 {
132 maxCacheitemsLoop = AvatarWearable.MAX_WEARABLES;
133 m_log.WarnFormat("[CACHEDBAKES]: Too Many Cache items Provided {0}, the max is {1}. Truncating!", cacheItems.Length, AvatarWearable.MAX_WEARABLES);
134 }
135
136 m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
137 if (cacheItems.Length > 0)
138 {
139 m_log.Debug("[Cacheitems]: " + cacheItems.Length);
140 for (int iter = 0; iter < maxCacheitemsLoop; iter++)
141 {
142 m_log.Debug("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" +
143 cacheItems[iter].TextureID);
144 }
145
146 ScenePresence p = null;
147 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out p))
148 { 126 {
127 // if cacheItems.Length > 0 viewer is giving us current textures information.
128 // baked ones should had been uploaded and in assets cache as local itens
129
130
131 if (cacheItems.Length == 0)
132 return; // no textures information, nothing to do
133
134 ScenePresence p = null;
135 if (!m_scene.TryGetScenePresence(remoteClient.AgentId, out p))
136 return; // what are we doing if there is no presence to cache for?
137
138 if (p.IsDeleted)
139 return; // does this really work?
140
141 int maxCacheitemsLoop = cacheItems.Length;
142 if (maxCacheitemsLoop > 20)
143 {
144 maxCacheitemsLoop = AvatarWearable.MAX_WEARABLES;
145 m_log.WarnFormat("[CACHEDBAKES]: Too Many Cache items Provided {0}, the max is {1}. Truncating!", cacheItems.Length, AvatarWearable.MAX_WEARABLES);
146 }
147
148 m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
149
150
151 // some nice debug
152 m_log.Debug("[Cacheitems]: " + cacheItems.Length);
153 for (int iter = 0; iter < maxCacheitemsLoop; iter++)
154 {
155 m_log.Debug("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" +
156 cacheItems[iter].TextureID);
157 }
158
159 // p.Appearance.WearableCacheItems is in memory primary cashID to textures mapper
149 160
150 WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems; 161 WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems;
162
151 if (existingitems == null) 163 if (existingitems == null)
152 { 164 {
153 if (m_BakedTextureModule != null) 165 if (m_BakedTextureModule != null)
@@ -161,38 +173,22 @@ namespace OpenSim.Region.ClientStack.Linden
161 p.Appearance.WearableCacheItems = savedcache; 173 p.Appearance.WearableCacheItems = savedcache;
162 p.Appearance.WearableCacheItemsDirty = false; 174 p.Appearance.WearableCacheItemsDirty = false;
163 } 175 }
164
165 } 176 }
166 /* 177
167 * The following Catch types DO NOT WORK with m_BakedTextureModule.Get
168 * it jumps to the General Packet Exception Handler if you don't catch Exception!
169 *
170 catch (System.Net.Sockets.SocketException)
171 {
172 cacheItems = null;
173 }
174 catch (WebException)
175 {
176 cacheItems = null;
177 }
178 catch (InvalidOperationException)
179 {
180 cacheItems = null;
181 } */
182 catch (Exception) 178 catch (Exception)
183 { 179 {
184 // The service logs a sufficient error message. 180 // The service logs a sufficient error message.
185 } 181 }
186 182
187 183
188 if (savedcache != null) 184 if (savedcache != null)
189 existingitems = savedcache; 185 existingitems = savedcache;
190 } 186 }
191 } 187 }
188
192 // Existing items null means it's a fully new appearance 189 // Existing items null means it's a fully new appearance
193 if (existingitems == null) 190 if (existingitems == null)
194 { 191 {
195
196 for (int i = 0; i < maxCacheitemsLoop; i++) 192 for (int i = 0; i < maxCacheitemsLoop; i++)
197 { 193 {
198 if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) 194 if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex)
@@ -205,7 +201,7 @@ namespace OpenSim.Region.ClientStack.Linden
205 AppearanceManager.DEFAULT_AVATAR_TEXTURE; 201 AppearanceManager.DEFAULT_AVATAR_TEXTURE;
206 continue; 202 continue;
207 } 203 }
208 cacheItems[i].TextureID =face.TextureID; 204 cacheItems[i].TextureID = face.TextureID;
209 if (m_scene.AssetService != null) 205 if (m_scene.AssetService != null)
210 cacheItems[i].TextureAsset = 206 cacheItems[i].TextureAsset =
211 m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString()); 207 m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString());
@@ -214,15 +210,10 @@ namespace OpenSim.Region.ClientStack.Linden
214 { 210 {
215 m_log.WarnFormat("[CACHEDBAKES]: Invalid Texture Index Provided, Texture doesn't exist or hasn't been uploaded yet {0}, the max is {1}. Skipping!", cacheItems[i].TextureIndex, textureEntry.FaceTextures.Length); 211 m_log.WarnFormat("[CACHEDBAKES]: Invalid Texture Index Provided, Texture doesn't exist or hasn't been uploaded yet {0}, the max is {1}. Skipping!", cacheItems[i].TextureIndex, textureEntry.FaceTextures.Length);
216 } 212 }
217
218
219 } 213 }
220 } 214 }
221 else 215 else
222 216 {
223
224 {
225 // for each uploaded baked texture
226 for (int i = 0; i < maxCacheitemsLoop; i++) 217 for (int i = 0; i < maxCacheitemsLoop; i++)
227 { 218 {
228 if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) 219 if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex)
@@ -253,23 +244,24 @@ namespace OpenSim.Region.ClientStack.Linden
253 } 244 }
254 } 245 }
255 } 246 }
256
257
258
259 p.Appearance.WearableCacheItems = cacheItems; 247 p.Appearance.WearableCacheItems = cacheItems;
260
261
262 248
263 if (m_BakedTextureModule != null) 249 if (m_BakedTextureModule != null)
264 { 250 {
265 m_BakedTextureModule.Store(remoteClient.AgentId, cacheItems); 251 m_BakedTextureModule.Store(remoteClient.AgentId, cacheItems);
266 p.Appearance.WearableCacheItemsDirty = true; 252 p.Appearance.WearableCacheItemsDirty = true;
267 253
268 } 254 }
269 } 255 else
270 } 256 p.Appearance.WearableCacheItemsDirty = false;
271 }
272 257
258 for (int iter = 0; iter < maxCacheitemsLoop; iter++)
259 {
260 m_log.Debug("[CacheitemsLeaving] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" +
261 cacheItems[iter].TextureID);
262 }
263 }
264 */
273 public void PostInitialise() 265 public void PostInitialise()
274 { 266 {
275 } 267 }
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 34a2797..e9a087b 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -3684,6 +3684,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3684 avp.Sender.IsTrial = false; 3684 avp.Sender.IsTrial = false;
3685 avp.Sender.ID = agentID; 3685 avp.Sender.ID = agentID;
3686 avp.AppearanceData = new AvatarAppearancePacket.AppearanceDataBlock[0]; 3686 avp.AppearanceData = new AvatarAppearancePacket.AppearanceDataBlock[0];
3687
3688 // this need be use in future
3689 // avp.AppearanceData[0].AppearanceVersion = 0;
3690 // avp.AppearanceData[0].CofVersion = 0;
3691
3687 //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString()); 3692 //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString());
3688 OutPacket(avp, ThrottleOutPacketType.Task); 3693 OutPacket(avp, ThrottleOutPacketType.Task);
3689 } 3694 }
@@ -6535,7 +6540,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6535 6540
6536 WearableCacheItem[] cacheitems = new WearableCacheItem[appear.WearableData.Length]; 6541 WearableCacheItem[] cacheitems = new WearableCacheItem[appear.WearableData.Length];
6537 for (int i=0; i<appear.WearableData.Length;i++) 6542 for (int i=0; i<appear.WearableData.Length;i++)
6538 cacheitems[i] = new WearableCacheItem(){CacheId = appear.WearableData[i].CacheID,TextureIndex=Convert.ToUInt32(appear.WearableData[i].TextureIndex)}; 6543 cacheitems[i] = new WearableCacheItem(){
6544 CacheId = appear.WearableData[i].CacheID,
6545 TextureIndex=Convert.ToUInt32(appear.WearableData[i].TextureIndex)
6546 };
6539 6547
6540 6548
6541 6549
@@ -12004,150 +12012,65 @@ namespace OpenSim.Region.ClientStack.LindenUDP
12004 12012
12005 if (cachedtex.AgentData.SessionID != SessionId) 12013 if (cachedtex.AgentData.SessionID != SessionId)
12006 return false; 12014 return false;
12007
12008 12015
12009 // TODO: don't create new blocks if recycling an old packet 12016 // TODO: don't create new blocks if recycling an old packet
12010 cachedresp.AgentData.AgentID = AgentId; 12017 cachedresp.AgentData.AgentID = AgentId;
12011 cachedresp.AgentData.SessionID = m_sessionId; 12018 cachedresp.AgentData.SessionID = m_sessionId;
12012 cachedresp.AgentData.SerialNum = m_cachedTextureSerial; 12019 cachedresp.AgentData.SerialNum = cachedtex.AgentData.SerialNum;
12013 m_cachedTextureSerial++;
12014 cachedresp.WearableData = 12020 cachedresp.WearableData =
12015 new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length]; 12021 new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length];
12016 12022
12017 //IAvatarFactoryModule fac = m_scene.RequestModuleInterface<IAvatarFactoryModule>();
12018 // var item = fac.GetBakedTextureFaces(AgentId);
12019 //WearableCacheItem[] items = fac.GetCachedItems(AgentId);
12020
12021 IAssetService cache = m_scene.AssetService;
12022 IBakedTextureModule bakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
12023 //bakedTextureModule = null;
12024 int maxWearablesLoop = cachedtex.WearableData.Length; 12023 int maxWearablesLoop = cachedtex.WearableData.Length;
12025 if (maxWearablesLoop > AvatarWearable.MAX_WEARABLES) 12024 if (maxWearablesLoop > AvatarWearable.MAX_WEARABLES)
12026 maxWearablesLoop = AvatarWearable.MAX_WEARABLES; 12025 maxWearablesLoop = AvatarWearable.MAX_WEARABLES;
12027 12026
12028 if (bakedTextureModule != null && cache != null) 12027 int cacheHits = 0;
12029 {
12030 // We need to make sure the asset stored in the bake is available on this server also by it's assetid before we map it to a Cacheid
12031 12028
12032 WearableCacheItem[] cacheItems = null; 12029 // We need to make sure the asset stored in the bake is available on this server also by it's assetid before we map it to a Cacheid
12033 ScenePresence p = m_scene.GetScenePresence(AgentId);
12034 if (p.Appearance != null)
12035 if (p.Appearance.WearableCacheItems == null || p.Appearance.WearableCacheItemsDirty)
12036 {
12037 try
12038 {
12039 cacheItems = bakedTextureModule.Get(AgentId);
12040 p.Appearance.WearableCacheItems = cacheItems;
12041 p.Appearance.WearableCacheItemsDirty = false;
12042 }
12043 12030
12044 /* 12031 WearableCacheItem[] cacheItems = null;
12045 * The following Catch types DO NOT WORK, it jumps to the General Packet Exception Handler if you don't catch Exception!
12046 *
12047 catch (System.Net.Sockets.SocketException)
12048 {
12049 cacheItems = null;
12050 }
12051 catch (WebException)
12052 {
12053 cacheItems = null;
12054 }
12055 catch (InvalidOperationException)
12056 {
12057 cacheItems = null;
12058 } */
12059 catch (Exception)
12060 {
12061 cacheItems = null;
12062 }
12063
12064 }
12065 else if (p.Appearance.WearableCacheItems != null)
12066 {
12067 cacheItems = p.Appearance.WearableCacheItems;
12068 }
12069 12032
12070 if (cache != null && cacheItems != null) 12033 ScenePresence p = m_scene.GetScenePresence(AgentId);
12071 {
12072 foreach (WearableCacheItem item in cacheItems)
12073 {
12074
12075 if (cache.GetCached(item.TextureID.ToString()) == null)
12076 {
12077 item.TextureAsset.Temporary = true;
12078 cache.Store(item.TextureAsset);
12079 }
12080 12034
12035 if (p != null && p.Appearance != null)
12036 {
12037 cacheItems = p.Appearance.WearableCacheItems;
12038 }
12081 12039
12082 } 12040 if (cacheItems != null)
12083 } 12041 {
12084 12042 for (int i = 0; i < maxWearablesLoop; i++)
12085 if (cacheItems != null)
12086 { 12043 {
12087 12044 int idx = cachedtex.WearableData[i].TextureIndex;
12088 for (int i = 0; i < maxWearablesLoop; i++)
12089 {
12090 WearableCacheItem item =
12091 WearableCacheItem.SearchTextureIndex(cachedtex.WearableData[i].TextureIndex,cacheItems);
12092 12045
12093 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); 12046 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
12094 cachedresp.WearableData[i].TextureIndex= cachedtex.WearableData[i].TextureIndex; 12047 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
12095 cachedresp.WearableData[i].HostName = new byte[0]; 12048 cachedresp.WearableData[i].HostName = new byte[0];
12096 if (item != null && cachedtex.WearableData[i].ID == item.CacheId) 12049 if (cachedtex.WearableData[i].ID == cacheItems[idx].CacheId)
12097 { 12050 {
12098 12051 cachedresp.WearableData[i].TextureID = cacheItems[idx].TextureID;
12099 cachedresp.WearableData[i].TextureID = item.TextureID; 12052 cacheHits++;
12100 }
12101 else
12102 {
12103 cachedresp.WearableData[i].TextureID = UUID.Zero;
12104 }
12105 } 12053 }
12106 } 12054 else
12107 else
12108 {
12109 for (int i = 0; i < maxWearablesLoop; i++)
12110 { 12055 {
12111 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
12112 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
12113 cachedresp.WearableData[i].TextureID = UUID.Zero; 12056 cachedresp.WearableData[i].TextureID = UUID.Zero;
12114 //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
12115 cachedresp.WearableData[i].HostName = new byte[0];
12116 } 12057 }
12117 } 12058 }
12118 } 12059 }
12119 else 12060 else
12120 { 12061 {
12121 if (cache == null) 12062 for (int i = 0; i < maxWearablesLoop; i++)
12122 { 12063 {
12123 for (int i = 0; i < maxWearablesLoop; i++) 12064 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
12124 { 12065 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
12125 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); 12066 cachedresp.WearableData[i].TextureID = UUID.Zero;
12126 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; 12067 //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
12127 cachedresp.WearableData[i].TextureID = UUID.Zero; 12068 cachedresp.WearableData[i].HostName = new byte[0];
12128 //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
12129 cachedresp.WearableData[i].HostName = new byte[0];
12130 }
12131 } 12069 }
12132 else 12070 }
12133 {
12134 for (int i = 0; i < maxWearablesLoop; i++)
12135 {
12136 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
12137 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
12138
12139 12071
12072 m_log.DebugFormat("texture cached: hits {0}", cacheHits);
12140 12073
12141 if (cache.GetCached(cachedresp.WearableData[i].TextureID.ToString()) == null)
12142 cachedresp.WearableData[i].TextureID = UUID.Zero;
12143 //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
12144 else
12145 cachedresp.WearableData[i].TextureID = UUID.Zero;
12146 // UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
12147 cachedresp.WearableData[i].HostName = new byte[0];
12148 }
12149 }
12150 }
12151 cachedresp.Header.Zerocoded = true; 12074 cachedresp.Header.Zerocoded = true;
12152 OutPacket(cachedresp, ThrottleOutPacketType.Task); 12075 OutPacket(cachedresp, ThrottleOutPacketType.Task);
12153 12076
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index b7c8594..a3fdae1 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -1750,25 +1750,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1750 endPoint, 1750 endPoint,
1751 sessionInfo); 1751 sessionInfo);
1752 1752
1753 // Send ack straight away to let the viewer know that the connection is active.
1754 // The client will be null if it already exists (e.g. if on a region crossing the client sends a use
1755 // circuit code to the existing child agent. This is not particularly obvious.
1756 SendAckImmediate(endPoint, uccp.Header.Sequence);
1757
1758 // We only want to send initial data to new clients, not ones which are being converted from child to root.
1759 if (client != null)
1760 {
1761 AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(uccp.CircuitCode.Code);
1762 bool tp = (aCircuit.teleportFlags > 0);
1763 // Let's delay this for TP agents, otherwise the viewer doesn't know where to get resources from
1764 if (!tp)
1765 client.SceneAgent.SendInitialDataToMe();
1766 }
1767
1768 // Now we know we can handle more data 1753 // Now we know we can handle more data
1769 Thread.Sleep(200); 1754// Thread.Sleep(200);
1770 1755
1771 // Obtain the queue and remove it from the cache 1756 // Obtain the pending queue and remove it from the cache
1772 Queue<UDPPacketBuffer> queue = null; 1757 Queue<UDPPacketBuffer> queue = null;
1773 1758
1774 lock (m_pendingCache) 1759 lock (m_pendingCache)
@@ -1790,6 +1775,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1790 PacketReceived(buf); 1775 PacketReceived(buf);
1791 } 1776 }
1792 queue = null; 1777 queue = null;
1778
1779 // Send ack straight away to let the viewer know that the connection is active.
1780 // The client will be null if it already exists (e.g. if on a region crossing the client sends a use
1781 // circuit code to the existing child agent. This is not particularly obvious.
1782 SendAckImmediate(endPoint, uccp.Header.Sequence);
1783
1784 // We only want to send initial data to new clients, not ones which are being converted from child to root.
1785 if (client != null)
1786 {
1787 AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(uccp.CircuitCode.Code);
1788 bool tp = (aCircuit.teleportFlags > 0);
1789 // Let's delay this for TP agents, otherwise the viewer doesn't know where to get resources from
1790 if (!tp)
1791 client.SceneAgent.SendInitialDataToMe();
1792 }
1793 } 1793 }
1794 else 1794 else
1795 { 1795 {
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 09cc998..2e5c58a 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -188,27 +188,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
188 // Process the visual params, this may change height as well 188 // Process the visual params, this may change height as well
189 if (visualParams != null) 189 if (visualParams != null)
190 { 190 {
191 // string[] visualParamsStrings = new string[visualParams.Length];
192 // for (int i = 0; i < visualParams.Length; i++)
193 // visualParamsStrings[i] = visualParams[i].ToString();
194 // m_log.DebugFormat(
195 // "[AVFACTORY]: Setting visual params for {0} to {1}",
196 // client.Name, string.Join(", ", visualParamsStrings));
197/*
198 float oldHeight = sp.Appearance.AvatarHeight;
199 changed = sp.Appearance.SetVisualParams(visualParams);
200
201 if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0)
202 ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight);
203 */
204// float oldoff = sp.Appearance.AvatarFeetOffset;
205// Vector3 oldbox = sp.Appearance.AvatarBoxSize;
206 changed = sp.Appearance.SetVisualParams(visualParams); 191 changed = sp.Appearance.SetVisualParams(visualParams);
207// float off = sp.Appearance.AvatarFeetOffset;
208// Vector3 box = sp.Appearance.AvatarBoxSize;
209// if(oldoff != off || oldbox != box)
210// ((ScenePresence)sp).SetSize(box,off);
211
212 } 192 }
213 193
214 // Process the baked texture array 194 // Process the baked texture array
@@ -222,9 +202,15 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
222 202
223// WriteBakedTexturesReport(sp, m_log.DebugFormat); 203// WriteBakedTexturesReport(sp, m_log.DebugFormat);
224 204
205
225 // If bake textures are missing and this is not an NPC, request a rebake from client 206 // If bake textures are missing and this is not an NPC, request a rebake from client
226 if (!ValidateBakedTextureCache(sp) && (((ScenePresence)sp).PresenceType != PresenceType.Npc)) 207 // rebake may messup caching, and should not be needed
227 RequestRebake(sp, true); 208
209
210// if (!UpdateBakedTextureCache(sp,cacheItems) && (((ScenePresence)sp).PresenceType != PresenceType.Npc))
211// RequestRebake(sp, true);
212
213 UpdateBakedTextureCache(sp, cacheItems);
228 214
229 // This appears to be set only in the final stage of the appearance 215 // This appears to be set only in the final stage of the appearance
230 // update transaction. In theory, we should be able to do an immediate 216 // update transaction. In theory, we should be able to do an immediate
@@ -377,121 +363,243 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
377 } 363 }
378 } 364 }
379 365
366 // called on textures update
367 public bool UpdateBakedTextureCache(IScenePresence sp, WearableCacheItem[] cacheItems)
368 {
369 bool defonly = true; // are we only using default textures
370
371 // uploaded baked textures will be in assets local cache
372 IAssetService cache = m_scene.AssetService;
373
374 int validDirtyBakes = 0;
375 int hits = 0;
376
377 // our main cacheIDs mapper is p.Appearance.WearableCacheItems
378 WearableCacheItem[] wearableCache = sp.Appearance.WearableCacheItems;
379
380 if (wearableCache == null)
381 {
382 wearableCache = WearableCacheItem.GetDefaultCacheItem();
383 }
384
385 // Process received baked textures
386 for (int i = 0; i < cacheItems.Length; i++)
387 {
388 int idx = (int)cacheItems[i].TextureIndex;
389 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
390
391 // No face
392 if (face == null)
393 {
394 // for some reason viewer is cleaning this
395 sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint) idx);
396 sp.Appearance.Texture.FaceTextures[idx].TextureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE;
397 wearableCache[idx].CacheId = UUID.Zero;
398 wearableCache[idx].TextureID = UUID.Zero;
399 wearableCache[idx].TextureAsset = null;
400 continue;
401 }
402 else
403 {
404 if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
405 {
406 wearableCache[idx].CacheId = UUID.Zero;
407 wearableCache[idx].TextureID = UUID.Zero;
408 wearableCache[idx].TextureAsset = null;
409 continue;
410 }
411
412 defonly = false; // found a non-default texture reference
413
414 if(sp.Appearance.Texture.FaceTextures[idx].TextureID == wearableCache[idx].TextureID)
415 {
416 if(wearableCache[idx].CacheId != cacheItems[i].CacheId)
417 {
418 wearableCache[idx].CacheId = cacheItems[i].CacheId;
419 validDirtyBakes++;
420 hits++;
421 //assuming this can only happen if asset is in cache
422 }
423 continue;
424 }
425
426 wearableCache[idx].TextureAsset = null;
427 if (cache != null)
428 wearableCache[idx].TextureAsset = cache.GetCached(face.TextureID.ToString());
429
430 if (wearableCache[idx].TextureAsset != null)
431 {
432 wearableCache[idx].CacheId = cacheItems[i].CacheId;
433 wearableCache[idx].TextureID = sp.Appearance.Texture.FaceTextures[idx].TextureID;
434 validDirtyBakes++;
435 hits++;
436 }
437 else
438 {
439 wearableCache[idx].CacheId = UUID.Zero;
440 wearableCache[idx].TextureID = UUID.Zero;
441 wearableCache[idx].TextureAsset = null;
442 continue;
443 }
444 }
445 }
446
447 sp.Appearance.WearableCacheItems = wearableCache;
448
449 // if we got a full set of baked textures save all in BakedTextureModule
450
451 if (validDirtyBakes == cacheItems.Length)
452 {
453 IBakedTextureModule m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
454 if (m_BakedTextureModule != null)
455 {
456 m_log.Debug("[UpdateBakedCache] uploading to bakedModule cache");
457
458 WearableCacheItem[] toBakedModule = new WearableCacheItem[AvatarAppearance.BAKE_INDICES.Length];
459
460 for (int i = 0; i < cacheItems.Length; i++)
461 {
462 int idx = (int)cacheItems[i].TextureIndex;
463 cacheItems[i].CacheId = wearableCache[idx].CacheId;
464 cacheItems[i].TextureID = wearableCache[idx].TextureID;
465 cacheItems[i].TextureAsset = wearableCache[idx].TextureAsset;
466 }
467 m_BakedTextureModule.Store(sp.UUID, cacheItems);
468 }
469 }
470
471 // debug
472 for (int iter = 0; iter < AvatarAppearance.BAKE_INDICES.Length; iter++)
473 {
474 int j = AvatarAppearance.BAKE_INDICES[iter];
475 m_log.Debug("[UpdateBCache] {" + iter + "/" +
476 sp.Appearance.WearableCacheItems[j].TextureIndex + "}: c-" +
477 sp.Appearance.WearableCacheItems[j].CacheId + ", t-" +
478 sp.Appearance.WearableCacheItems[j].TextureID);
479 }
480
481 // If we only found default textures, then the appearance is not cached
482 return (defonly ? false : true);
483 }
484
485 // called when we get a new root avatar
380 public bool ValidateBakedTextureCache(IScenePresence sp) 486 public bool ValidateBakedTextureCache(IScenePresence sp)
381 { 487 {
382 bool defonly = true; // are we only using default textures 488 bool defonly = true; // are we only using default textures
383 IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); 489 IAssetService cache = m_scene.AssetService;
384 IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); 490 IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
385 WearableCacheItem[] wearableCache = null; 491 WearableCacheItem[] wearableCache = null;
492 WearableCacheItem[] bakedModuleCache = null;
493
494 wearableCache = WearableCacheItem.GetDefaultCacheItem();
386 495
496 int hits = 0;
387 // Cache wearable data for teleport. 497 // Cache wearable data for teleport.
388 // Only makes sense if there's a bake module and a cache module 498 // Only makes sense if there's a bake module and a cache module
389 if (bakedModule != null && cache != null) 499 if (bakedModule != null && cache != null)
390 { 500 {
501 m_log.Debug("[ValidateBakedCache] calling bakedModule");
391 try 502 try
392 { 503 {
393 wearableCache = bakedModule.Get(sp.UUID); 504 bakedModuleCache = bakedModule.Get(sp.UUID);
394 } 505 }
395 catch (Exception) 506 catch (Exception)
396 { 507 {
397 508 bakedModuleCache = null;
398 }
399 if (wearableCache != null)
400 {
401 for (int i = 0; i < wearableCache.Length; i++)
402 {
403 cache.Cache(wearableCache[i].TextureAsset);
404 }
405 } 509 }
406 } 510
407 /* 511 if (bakedModuleCache != null)
408 IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
409 if (invService.GetRootFolder(userID) != null)
410 {
411 WearableCacheItem[] wearableCache = null;
412 if (bakedModule != null)
413 { 512 {
414 try 513 m_log.Debug("[ValidateBakedCache] got bakedModule cache " + bakedModuleCache.Length);
514
515 for (int i = 0; i < bakedModuleCache.Length; i++)
415 { 516 {
416 wearableCache = bakedModule.Get(userID); 517 int j = (int)bakedModuleCache[i].TextureIndex;
417 appearance.WearableCacheItems = wearableCache; 518
418 appearance.WearableCacheItemsDirty = false; 519 if (bakedModuleCache[i].TextureAsset != null)
419 foreach (WearableCacheItem item in wearableCache)
420 { 520 {
421 appearance.Texture.FaceTextures[item.TextureIndex].TextureID = item.TextureID; 521 wearableCache[j].TextureID = bakedModuleCache[i].TextureID;
522 wearableCache[j].CacheId = bakedModuleCache[i].CacheId;
523 wearableCache[j].TextureAsset = bakedModuleCache[i].TextureAsset;
524 bakedModuleCache[i].TextureAsset.Temporary = true;
525 bakedModuleCache[i].TextureAsset.Local = true;
526 cache.Store(bakedModuleCache[i].TextureAsset);
422 } 527 }
423 } 528 }
424 catch (Exception)
425 {
426
427 }
428 } 529 }
429 */ 530 }
430 531
431 // Process the texture entry 532 // Process the baked textures
432 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) 533 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
433 { 534 {
434 int idx = AvatarAppearance.BAKE_INDICES[i]; 535 int idx = AvatarAppearance.BAKE_INDICES[i];
435 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; 536 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
436 537
437 // No face, so lets check our baked service cache, teleport or login. 538 // No face, so lets check our cache
438 if (face == null) 539 if (face == null || face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
439 { 540 {
440 if (wearableCache != null) 541 sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint)idx);
542 if (wearableCache[idx].TextureID != UUID.Zero)
441 { 543 {
442 // If we find the an appearance item, set it as the textureentry and the face 544 sp.Appearance.Texture.FaceTextures[idx].TextureID = wearableCache[idx].TextureID;
443 WearableCacheItem searchitem = WearableCacheItem.SearchTextureIndex((uint) idx, wearableCache); 545 face = sp.Appearance.Texture.FaceTextures[idx];
444 if (searchitem != null) 546 // let run to end of loop to check cache
445 {
446 sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint) idx);
447 sp.Appearance.Texture.FaceTextures[idx].TextureID = searchitem.TextureID;
448 face = sp.Appearance.Texture.FaceTextures[idx];
449 }
450 else
451 {
452 // if there is no texture entry and no baked cache, skip it
453 continue;
454 }
455 } 547 }
456 else 548 else
457 { 549 {
458 //No texture entry face and no cache. Skip this face. 550 sp.Appearance.Texture.FaceTextures[idx].TextureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE;
551 face = sp.Appearance.Texture.FaceTextures[idx];
552// lets try not invalidating the cache entry
553// wearableCache[idx].CacheId = UUID.Zero;
554// wearableCache[idx].TextureAsset = null;
459 continue; 555 continue;
460 } 556 }
461 } 557 }
462
463
464// m_log.DebugFormat(
465// "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}",
466// face.TextureID, idx, client.Name, client.AgentId);
467 558
468 // if the texture is one of the "defaults" then skip it
469 // this should probably be more intelligent (skirt texture doesnt matter
470 // if the avatar isnt wearing a skirt) but if any of the main baked
471 // textures is default then the rest should be as well
472 if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE) 559 if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
560 {
561 defonly = false; // found a non-default texture reference
473 continue; 562 continue;
474 563 }
475 defonly = false; // found a non-default texture reference
476 564
477 if (cache != null) 565 if(wearableCache[idx].TextureID != face.TextureID)
478 { 566 {
479 if (!cache.Check(face.TextureID.ToString())) 567 wearableCache[idx].CacheId = UUID.Zero;
480 return false; 568 wearableCache[idx].TextureID = UUID.Zero;
569 wearableCache[idx].TextureAsset = null;
570 continue;
481 } 571 }
482 else 572
573 wearableCache[idx].TextureAsset = null;
574 if (cache != null)
483 { 575 {
484 if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) 576 wearableCache[idx].TextureAsset = m_scene.AssetService.Get(face.TextureID.ToString());
485 return false; 577 if (wearableCache[idx].TextureAsset == null)
578 {
579 wearableCache[idx].CacheId = UUID.Zero;
580 wearableCache[idx].TextureID = UUID.Zero;
581 }
582 else
583 hits++;
486 } 584 }
487 } 585 }
488 586
489// m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); 587 sp.Appearance.WearableCacheItems = wearableCache;
588
589 m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1} {2} {3}", sp.Name, sp.UUID, hits, defonly.ToString());
590 // debug
591 for (int iter = 0; iter < AvatarAppearance.BAKE_INDICES.Length; iter++)
592 {
593 int j = AvatarAppearance.BAKE_INDICES[iter];
594 m_log.Debug("[ValidateBakedCache] {" + iter + "/" +
595 sp.Appearance.WearableCacheItems[j].TextureIndex + "}: c-" +
596 sp.Appearance.WearableCacheItems[j].CacheId + ", t-" +
597 sp.Appearance.WearableCacheItems[j].TextureID);
598 }
490 599
491 // If we only found default textures, then the appearance is not cached 600 // If we only found default textures, then the appearance is not cached
492 return (defonly ? false : true); 601 return (defonly ? false : true);
493 } 602 }
494
495 public int RequestRebake(IScenePresence sp, bool missingTexturesOnly) 603 public int RequestRebake(IScenePresence sp, bool missingTexturesOnly)
496 { 604 {
497 int texturesRebaked = 0; 605 int texturesRebaked = 0;
@@ -506,14 +614,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
506 if (face == null) 614 if (face == null)
507 continue; 615 continue;
508 616
509// m_log.DebugFormat(
510// "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}",
511// face.TextureID, idx, client.Name, client.AgentId);
512
513 // if the texture is one of the "defaults" then skip it
514 // this should probably be more intelligent (skirt texture doesnt matter
515 // if the avatar isnt wearing a skirt) but if any of the main baked
516 // textures is default then the rest should be as well
517 if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE) 617 if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
518 continue; 618 continue;
519 619
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index e4f23f9..7b13e0b 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -1032,15 +1032,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1032 // object itself before we rez. 1032 // object itself before we rez.
1033 // 1033 //
1034 // Only do these for the first object if we are rezzing a coalescence. 1034 // Only do these for the first object if we are rezzing a coalescence.
1035 if (i == 0) 1035 // nahh dont mess with coalescence objects,
1036 // the name in inventory can be change for inventory purpuses only
1037 if (objlist.Count == 1)
1036 { 1038 {
1037 rootPart.Name = item.Name; 1039 rootPart.Name = item.Name;
1038 rootPart.Description = item.Description; 1040 rootPart.Description = item.Description;
1039 if ((item.Flags & (uint)InventoryItemFlags.ObjectSlamSale) != 0) 1041 }
1040 { 1042
1041 rootPart.ObjectSaleType = item.SaleType; 1043 if ((item.Flags & (uint)InventoryItemFlags.ObjectSlamSale) != 0)
1042 rootPart.SalePrice = item.SalePrice; 1044 {
1043 } 1045 rootPart.ObjectSaleType = item.SaleType;
1046 rootPart.SalePrice = item.SalePrice;
1044 } 1047 }
1045 1048
1046 so.FromFolderID = item.Folder; 1049 so.FromFolderID = item.Folder;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 746b703..8634a3a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1234,8 +1234,9 @@ namespace OpenSim.Region.Framework.Scenes
1234 { 1234 {
1235 uint perms = taskItem.CurrentPermissions; 1235 uint perms = taskItem.CurrentPermissions;
1236 PermissionsUtil.ApplyFoldedPermissions(taskItem.CurrentPermissions, ref perms); 1236 PermissionsUtil.ApplyFoldedPermissions(taskItem.CurrentPermissions, ref perms);
1237 agentItem.BasePermissions = perms | (uint)PermissionMask.Move; 1237// agentItem.BasePermissions = perms | (uint)PermissionMask.Move;
1238 agentItem.CurrentPermissions = agentItem.BasePermissions; 1238// agentItem.CurrentPermissions = agentItem.BasePermissions;
1239 agentItem.CurrentPermissions = perms | (uint)PermissionMask.Move;
1239 } 1240 }
1240 else 1241 else
1241 { 1242 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 08e26c5..dd0c828 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -1,581 +1,581 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the 12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using System.Threading; 31using System.Threading;
32using OpenMetaverse; 32using OpenMetaverse;
33using log4net; 33using log4net;
34using Nini.Config; 34using Nini.Config;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
37 37
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion; 39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40 40
41namespace OpenSim.Region.Framework.Scenes 41namespace OpenSim.Region.Framework.Scenes
42{ 42{
43 public abstract class SceneBase : IScene 43 public abstract class SceneBase : IScene
44 { 44 {
45 protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 protected static readonly string LogHeader = "[SCENE]"; 46 protected static readonly string LogHeader = "[SCENE]";
47 47
48 #region Events 48 #region Events
49 49
50 public event restart OnRestart; 50 public event restart OnRestart;
51 51
52 #endregion 52 #endregion
53 53
54 #region Fields 54 #region Fields
55 55
56 public string Name { get { return RegionInfo.RegionName; } } 56 public string Name { get { return RegionInfo.RegionName; } }
57 57
58 public IConfigSource Config 58 public IConfigSource Config
59 { 59 {
60 get { return GetConfig(); } 60 get { return GetConfig(); }
61 } 61 }
62 62
63 protected virtual IConfigSource GetConfig() 63 protected virtual IConfigSource GetConfig()
64 { 64 {
65 return null; 65 return null;
66 } 66 }
67 67
68 /// <value> 68 /// <value>
69 /// All the region modules attached to this scene. 69 /// All the region modules attached to this scene.
70 /// </value> 70 /// </value>
71 public Dictionary<string, IRegionModuleBase> RegionModules 71 public Dictionary<string, IRegionModuleBase> RegionModules
72 { 72 {
73 get { return m_regionModules; } 73 get { return m_regionModules; }
74 } 74 }
75 private Dictionary<string, IRegionModuleBase> m_regionModules = new Dictionary<string, IRegionModuleBase>(); 75 private Dictionary<string, IRegionModuleBase> m_regionModules = new Dictionary<string, IRegionModuleBase>();
76 76
77 /// <value> 77 /// <value>
78 /// The module interfaces available from this scene. 78 /// The module interfaces available from this scene.
79 /// </value> 79 /// </value>
80 protected Dictionary<Type, List<object>> ModuleInterfaces = new Dictionary<Type, List<object>>(); 80 protected Dictionary<Type, List<object>> ModuleInterfaces = new Dictionary<Type, List<object>>();
81 81
82 protected Dictionary<string, object> ModuleAPIMethods = new Dictionary<string, object>(); 82 protected Dictionary<string, object> ModuleAPIMethods = new Dictionary<string, object>();
83 83
84 /// <value> 84 /// <value>
85 /// The module commanders available from this scene 85 /// The module commanders available from this scene
86 /// </value> 86 /// </value>
87 protected Dictionary<string, ICommander> m_moduleCommanders = new Dictionary<string, ICommander>(); 87 protected Dictionary<string, ICommander> m_moduleCommanders = new Dictionary<string, ICommander>();
88 88
89 /// <value> 89 /// <value>
90 /// Registered classes that are capable of creating entities. 90 /// Registered classes that are capable of creating entities.
91 /// </value> 91 /// </value>
92 protected Dictionary<PCode, IEntityCreator> m_entityCreators = new Dictionary<PCode, IEntityCreator>(); 92 protected Dictionary<PCode, IEntityCreator> m_entityCreators = new Dictionary<PCode, IEntityCreator>();
93 93
94 /// <summary> 94 /// <summary>
95 /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is 95 /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is
96 /// dispensed. 96 /// dispensed.
97 /// </summary> 97 /// </summary>
98 protected uint m_lastAllocatedLocalId = 720000; 98 protected uint m_lastAllocatedLocalId = 720000;
99 99
100 private readonly Mutex _primAllocateMutex = new Mutex(false); 100 private readonly Mutex _primAllocateMutex = new Mutex(false);
101 101
102 protected readonly ClientManager m_clientManager = new ClientManager(); 102 protected readonly ClientManager m_clientManager = new ClientManager();
103 103
104 public bool LoginsEnabled 104 public bool LoginsEnabled
105 { 105 {
106 get 106 get
107 { 107 {
108 return m_loginsEnabled; 108 return m_loginsEnabled;
109 } 109 }
110 110
111 set 111 set
112 { 112 {
113 if (m_loginsEnabled != value) 113 if (m_loginsEnabled != value)
114 { 114 {
115 m_loginsEnabled = value; 115 m_loginsEnabled = value;
116 EventManager.TriggerRegionLoginsStatusChange(this); 116 EventManager.TriggerRegionLoginsStatusChange(this);
117 } 117 }
118 } 118 }
119 } 119 }
120 private bool m_loginsEnabled; 120 private bool m_loginsEnabled;
121 121
122 public bool Ready 122 public bool Ready
123 { 123 {
124 get 124 get
125 { 125 {
126 return m_ready; 126 return m_ready;
127 } 127 }
128 128
129 set 129 set
130 { 130 {
131 if (m_ready != value) 131 if (m_ready != value)
132 { 132 {
133 m_ready = value; 133 m_ready = value;
134 EventManager.TriggerRegionReadyStatusChange(this); 134 EventManager.TriggerRegionReadyStatusChange(this);
135 } 135 }
136 } 136 }
137 } 137 }
138 private bool m_ready; 138 private bool m_ready;
139 139
140 public float TimeDilation 140 public float TimeDilation
141 { 141 {
142 get { return 1.0f; } 142 get { return 1.0f; }
143 } 143 }
144 144
145 protected ulong m_regionHandle; 145 protected ulong m_regionHandle;
146 protected string m_regionName; 146 protected string m_regionName;
147 147
148 public ITerrainChannel Heightmap; 148 public ITerrainChannel Heightmap;
149 149
150 /// <value> 150 /// <value>
151 /// Allows retrieval of land information for this scene. 151 /// Allows retrieval of land information for this scene.
152 /// </value> 152 /// </value>
153 public ILandChannel LandChannel; 153 public ILandChannel LandChannel;
154 154
155 /// <value> 155 /// <value>
156 /// Manage events that occur in this scene (avatar movement, script rez, etc.). Commonly used by region modules 156 /// Manage events that occur in this scene (avatar movement, script rez, etc.). Commonly used by region modules
157 /// to subscribe to scene events. 157 /// to subscribe to scene events.
158 /// </value> 158 /// </value>
159 public EventManager EventManager 159 public EventManager EventManager
160 { 160 {
161 get { return m_eventManager; } 161 get { return m_eventManager; }
162 } 162 }
163 protected EventManager m_eventManager; 163 protected EventManager m_eventManager;
164 164
165 protected ScenePermissions m_permissions; 165 protected ScenePermissions m_permissions;
166 public ScenePermissions Permissions 166 public ScenePermissions Permissions
167 { 167 {
168 get { return m_permissions; } 168 get { return m_permissions; }
169 } 169 }
170 170
171 protected string m_datastore; 171 protected string m_datastore;
172 172
173 /* Used by the loadbalancer plugin on GForge */ 173 /* Used by the loadbalancer plugin on GForge */
174 protected RegionStatus m_regStatus; 174 protected RegionStatus m_regStatus;
175 public RegionStatus RegionStatus 175 public RegionStatus RegionStatus
176 { 176 {
177 get { return m_regStatus; } 177 get { return m_regStatus; }
178 set { m_regStatus = value; } 178 set { m_regStatus = value; }
179 } 179 }
180 180
181 #endregion 181 #endregion
182 182
183 public SceneBase(RegionInfo regInfo) 183 public SceneBase(RegionInfo regInfo)
184 { 184 {
185 RegionInfo = regInfo; 185 RegionInfo = regInfo;
186 } 186 }
187 187
188 #region Update Methods 188 #region Update Methods
189 189
190 /// <summary> 190 /// <summary>
191 /// Called to update the scene loop by a number of frames and until shutdown. 191 /// Called to update the scene loop by a number of frames and until shutdown.
192 /// </summary> 192 /// </summary>
193 /// <param name="frames"> 193 /// <param name="frames">
194 /// Number of frames to update. Exits on shutdown even if there are frames remaining. 194 /// Number of frames to update. Exits on shutdown even if there are frames remaining.
195 /// If -1 then updates until shutdown. 195 /// If -1 then updates until shutdown.
196 /// </param> 196 /// </param>
197 public abstract void Update(int frames); 197 public abstract void Update(int frames);
198 198
199 #endregion 199 #endregion
200 200
201 #region Terrain Methods 201 #region Terrain Methods
202 202
203 /// <summary> 203 /// <summary>
204 /// Loads the World heightmap 204 /// Loads the World heightmap
205 /// </summary> 205 /// </summary>
206 public abstract void LoadWorldMap(); 206 public abstract void LoadWorldMap();
207 207
208 /// <summary> 208 /// <summary>
209 /// Send the region heightmap to the client 209 /// Send the region heightmap to the client
210 /// </summary> 210 /// </summary>
211 /// <param name="RemoteClient">Client to send to</param> 211 /// <param name="RemoteClient">Client to send to</param>
212 public virtual void SendLayerData(IClientAPI RemoteClient) 212 public virtual void SendLayerData(IClientAPI RemoteClient)
213 { 213 {
214 RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised()); 214 RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised());
215 } 215 }
216 216
217 #endregion 217 #endregion
218 218
219 #region Add/Remove Agent/Avatar 219 #region Add/Remove Agent/Avatar
220 220
221 public abstract ISceneAgent AddNewAgent(IClientAPI client, PresenceType type); 221 public abstract ISceneAgent AddNewAgent(IClientAPI client, PresenceType type);
222 222
223 public abstract bool CloseAgent(UUID agentID, bool force); 223 public abstract bool CloseAgent(UUID agentID, bool force);
224 224
225 public bool TryGetScenePresence(UUID agentID, out object scenePresence) 225 public bool TryGetScenePresence(UUID agentID, out object scenePresence)
226 { 226 {
227 scenePresence = null; 227 scenePresence = null;
228 ScenePresence sp = null; 228 ScenePresence sp = null;
229 if (TryGetScenePresence(agentID, out sp)) 229 if (TryGetScenePresence(agentID, out sp))
230 { 230 {
231 scenePresence = sp; 231 scenePresence = sp;
232 return true; 232 return true;
233 } 233 }
234 234
235 return false; 235 return false;
236 } 236 }
237 237
238 /// <summary> 238 /// <summary>
239 /// Try to get a scene presence from the scene 239 /// Try to get a scene presence from the scene
240 /// </summary> 240 /// </summary>
241 /// <param name="agentID"></param> 241 /// <param name="agentID"></param>
242 /// <param name="scenePresence">null if there is no scene presence with the given agent id</param> 242 /// <param name="scenePresence">null if there is no scene presence with the given agent id</param>
243 /// <returns>true if there was a scene presence with the given id, false otherwise.</returns> 243 /// <returns>true if there was a scene presence with the given id, false otherwise.</returns>
244 public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence); 244 public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence);
245 245
246 #endregion 246 #endregion
247 247
248 /// <summary> 248 /// <summary>
249 /// 249 ///
250 /// </summary> 250 /// </summary>
251 /// <returns></returns> 251 /// <returns></returns>
252 public virtual RegionInfo RegionInfo { get; private set; } 252 public virtual RegionInfo RegionInfo { get; private set; }
253 253
254 #region admin stuff 254 #region admin stuff
255 255
256 public abstract void OtherRegionUp(GridRegion otherRegion); 256 public abstract void OtherRegionUp(GridRegion otherRegion);
257 257
258 public virtual string GetSimulatorVersion() 258 public virtual string GetSimulatorVersion()
259 { 259 {
260 return "OpenSimulator Server"; 260 return "OpenSimulator Server";
261 } 261 }
262 262
263 #endregion 263 #endregion
264 264
265 #region Shutdown 265 #region Shutdown
266 266
267 /// <summary> 267 /// <summary>
268 /// Tidy before shutdown 268 /// Tidy before shutdown
269 /// </summary> 269 /// </summary>
270 public virtual void Close() 270 public virtual void Close()
271 { 271 {
272 try 272 try
273 { 273 {
274 EventManager.TriggerShutdown(); 274 EventManager.TriggerShutdown();
275 } 275 }
276 catch (Exception e) 276 catch (Exception e)
277 { 277 {
278 m_log.Error(string.Format("[SCENE]: SceneBase.cs: Close() - Failed with exception ", e)); 278 m_log.Error(string.Format("[SCENE]: SceneBase.cs: Close() - Failed with exception ", e));
279 } 279 }
280 } 280 }
281 281
282 #endregion 282 #endregion
283 283
284 /// <summary> 284 /// <summary>
285 /// Returns a new unallocated local ID 285 /// Returns a new unallocated local ID
286 /// </summary> 286 /// </summary>
287 /// <returns>A brand new local ID</returns> 287 /// <returns>A brand new local ID</returns>
288 public uint AllocateLocalId() 288 public uint AllocateLocalId()
289 { 289 {
290 uint myID; 290 uint myID;
291 291
292 _primAllocateMutex.WaitOne(); 292 _primAllocateMutex.WaitOne();
293 myID = ++m_lastAllocatedLocalId; 293 myID = ++m_lastAllocatedLocalId;
294 _primAllocateMutex.ReleaseMutex(); 294 _primAllocateMutex.ReleaseMutex();
295 295
296 return myID; 296 return myID;
297 } 297 }
298 298
299 #region Module Methods 299 #region Module Methods
300 300
301 /// <summary> 301 /// <summary>
302 /// Add a region-module to this scene. TODO: This will replace AddModule in the future. 302 /// Add a region-module to this scene. TODO: This will replace AddModule in the future.
303 /// </summary> 303 /// </summary>
304 /// <param name="name"></param> 304 /// <param name="name"></param>
305 /// <param name="module"></param> 305 /// <param name="module"></param>
306 public void AddRegionModule(string name, IRegionModuleBase module) 306 public void AddRegionModule(string name, IRegionModuleBase module)
307 { 307 {
308 if (!RegionModules.ContainsKey(name)) 308 if (!RegionModules.ContainsKey(name))
309 { 309 {
310 RegionModules.Add(name, module); 310 RegionModules.Add(name, module);
311 } 311 }
312 } 312 }
313 313
314 public void RemoveRegionModule(string name) 314 public void RemoveRegionModule(string name)
315 { 315 {
316 RegionModules.Remove(name); 316 RegionModules.Remove(name);
317 } 317 }
318 318
319 /// <summary> 319 /// <summary>
320 /// Register a module commander. 320 /// Register a module commander.
321 /// </summary> 321 /// </summary>
322 /// <param name="commander"></param> 322 /// <param name="commander"></param>
323 public void RegisterModuleCommander(ICommander commander) 323 public void RegisterModuleCommander(ICommander commander)
324 { 324 {
325 lock (m_moduleCommanders) 325 lock (m_moduleCommanders)
326 { 326 {
327 m_moduleCommanders.Add(commander.Name, commander); 327 m_moduleCommanders.Add(commander.Name, commander);
328 } 328 }
329 } 329 }
330 330
331 /// <summary> 331 /// <summary>
332 /// Unregister a module commander and all its commands 332 /// Unregister a module commander and all its commands
333 /// </summary> 333 /// </summary>
334 /// <param name="name"></param> 334 /// <param name="name"></param>
335 public void UnregisterModuleCommander(string name) 335 public void UnregisterModuleCommander(string name)
336 { 336 {
337 lock (m_moduleCommanders) 337 lock (m_moduleCommanders)
338 { 338 {
339 ICommander commander; 339 ICommander commander;
340 if (m_moduleCommanders.TryGetValue(name, out commander)) 340 if (m_moduleCommanders.TryGetValue(name, out commander))
341 m_moduleCommanders.Remove(name); 341 m_moduleCommanders.Remove(name);
342 } 342 }
343 } 343 }
344 344
345 /// <summary> 345 /// <summary>
346 /// Get a module commander 346 /// Get a module commander
347 /// </summary> 347 /// </summary>
348 /// <param name="name"></param> 348 /// <param name="name"></param>
349 /// <returns>The module commander, null if no module commander with that name was found</returns> 349 /// <returns>The module commander, null if no module commander with that name was found</returns>
350 public ICommander GetCommander(string name) 350 public ICommander GetCommander(string name)
351 { 351 {
352 lock (m_moduleCommanders) 352 lock (m_moduleCommanders)
353 { 353 {
354 if (m_moduleCommanders.ContainsKey(name)) 354 if (m_moduleCommanders.ContainsKey(name))
355 return m_moduleCommanders[name]; 355 return m_moduleCommanders[name];
356 } 356 }
357 357
358 return null; 358 return null;
359 } 359 }
360 360
361 public Dictionary<string, ICommander> GetCommanders() 361 public Dictionary<string, ICommander> GetCommanders()
362 { 362 {
363 return m_moduleCommanders; 363 return m_moduleCommanders;
364 } 364 }
365 365
366 /// <summary> 366 /// <summary>
367 /// Register an interface to a region module. This allows module methods to be called directly as 367 /// Register an interface to a region module. This allows module methods to be called directly as
368 /// well as via events. If there is already a module registered for this interface, it is not replaced 368 /// well as via events. If there is already a module registered for this interface, it is not replaced
369 /// (is this the best behaviour?) 369 /// (is this the best behaviour?)
370 /// </summary> 370 /// </summary>
371 /// <param name="mod"></param> 371 /// <param name="mod"></param>
372 public void RegisterModuleInterface<M>(M mod) 372 public void RegisterModuleInterface<M>(M mod)
373 { 373 {
374// m_log.DebugFormat("[SCENE BASE]: Registering interface {0}", typeof(M)); 374// m_log.DebugFormat("[SCENE BASE]: Registering interface {0}", typeof(M));
375 375
376 List<Object> l = null; 376 List<Object> l = null;
377 if (!ModuleInterfaces.TryGetValue(typeof(M), out l)) 377 if (!ModuleInterfaces.TryGetValue(typeof(M), out l))
378 { 378 {
379 l = new List<Object>(); 379 l = new List<Object>();
380 ModuleInterfaces.Add(typeof(M), l); 380 ModuleInterfaces.Add(typeof(M), l);
381 } 381 }
382 382
383 if (l.Count > 0) 383 if (l.Count > 0)
384 return; 384 return;
385 385
386 l.Add(mod); 386 l.Add(mod);
387 387
388 if (mod is IEntityCreator) 388 if (mod is IEntityCreator)
389 { 389 {
390 IEntityCreator entityCreator = (IEntityCreator)mod; 390 IEntityCreator entityCreator = (IEntityCreator)mod;
391 foreach (PCode pcode in entityCreator.CreationCapabilities) 391 foreach (PCode pcode in entityCreator.CreationCapabilities)
392 { 392 {
393 m_entityCreators[pcode] = entityCreator; 393 m_entityCreators[pcode] = entityCreator;
394 } 394 }
395 } 395 }
396 } 396 }
397 397
398 public void UnregisterModuleInterface<M>(M mod) 398 public void UnregisterModuleInterface<M>(M mod)
399 { 399 {
400 List<Object> l; 400 List<Object> l;
401 if (ModuleInterfaces.TryGetValue(typeof(M), out l)) 401 if (ModuleInterfaces.TryGetValue(typeof(M), out l))
402 { 402 {
403 if (l.Remove(mod)) 403 if (l.Remove(mod))
404 { 404 {
405 if (mod is IEntityCreator) 405 if (mod is IEntityCreator)
406 { 406 {
407 IEntityCreator entityCreator = (IEntityCreator)mod; 407 IEntityCreator entityCreator = (IEntityCreator)mod;
408 foreach (PCode pcode in entityCreator.CreationCapabilities) 408 foreach (PCode pcode in entityCreator.CreationCapabilities)
409 { 409 {
410 m_entityCreators[pcode] = null; 410 m_entityCreators[pcode] = null;
411 } 411 }
412 } 412 }
413 } 413 }
414 } 414 }
415 } 415 }
416 416
417 public void StackModuleInterface<M>(M mod) 417 public void StackModuleInterface<M>(M mod)
418 { 418 {
419 List<Object> l; 419 List<Object> l;
420 if (ModuleInterfaces.ContainsKey(typeof(M))) 420 if (ModuleInterfaces.ContainsKey(typeof(M)))
421 l = ModuleInterfaces[typeof(M)]; 421 l = ModuleInterfaces[typeof(M)];
422 else 422 else
423 l = new List<Object>(); 423 l = new List<Object>();
424 424
425 if (l.Contains(mod)) 425 if (l.Contains(mod))
426 return; 426 return;
427 427
428 l.Add(mod); 428 l.Add(mod);
429 429
430 if (mod is IEntityCreator) 430 if (mod is IEntityCreator)
431 { 431 {
432 IEntityCreator entityCreator = (IEntityCreator)mod; 432 IEntityCreator entityCreator = (IEntityCreator)mod;
433 foreach (PCode pcode in entityCreator.CreationCapabilities) 433 foreach (PCode pcode in entityCreator.CreationCapabilities)
434 { 434 {
435 m_entityCreators[pcode] = entityCreator; 435 m_entityCreators[pcode] = entityCreator;
436 } 436 }
437 } 437 }
438 438
439 ModuleInterfaces[typeof(M)] = l; 439 ModuleInterfaces[typeof(M)] = l;
440 } 440 }
441 441
442 /// <summary> 442 /// <summary>
443 /// For the given interface, retrieve the region module which implements it. 443 /// For the given interface, retrieve the region module which implements it.
444 /// </summary> 444 /// </summary>
445 /// <returns>null if there is no registered module implementing that interface</returns> 445 /// <returns>null if there is no registered module implementing that interface</returns>
446 public T RequestModuleInterface<T>() 446 public T RequestModuleInterface<T>()
447 { 447 {
448 if (ModuleInterfaces.ContainsKey(typeof(T)) && 448 if (ModuleInterfaces.ContainsKey(typeof(T)) &&
449 (ModuleInterfaces[typeof(T)].Count > 0)) 449 (ModuleInterfaces[typeof(T)].Count > 0))
450 return (T)ModuleInterfaces[typeof(T)][0]; 450 return (T)ModuleInterfaces[typeof(T)][0];
451 else 451 else
452 return default(T); 452 return default(T);
453 } 453 }
454 454
455 /// <summary> 455 /// <summary>
456 /// For the given interface, retrieve an array of region modules that implement it. 456 /// For the given interface, retrieve an array of region modules that implement it.
457 /// </summary> 457 /// </summary>
458 /// <returns>an empty array if there are no registered modules implementing that interface</returns> 458 /// <returns>an empty array if there are no registered modules implementing that interface</returns>
459 public T[] RequestModuleInterfaces<T>() 459 public T[] RequestModuleInterfaces<T>()
460 { 460 {
461 if (ModuleInterfaces.ContainsKey(typeof(T))) 461 if (ModuleInterfaces.ContainsKey(typeof(T)))
462 { 462 {
463 List<T> ret = new List<T>(); 463 List<T> ret = new List<T>();
464 464
465 foreach (Object o in ModuleInterfaces[typeof(T)]) 465 foreach (Object o in ModuleInterfaces[typeof(T)])
466 ret.Add((T)o); 466 ret.Add((T)o);
467 return ret.ToArray(); 467 return ret.ToArray();
468 } 468 }
469 else 469 else
470 { 470 {
471 return new T[] {}; 471 return new T[] {};
472 } 472 }
473 } 473 }
474 474
475 #endregion 475 #endregion
476 476
477 /// <summary> 477 /// <summary>
478 /// Call this from a region module to add a command to the OpenSim console. 478 /// Call this from a region module to add a command to the OpenSim console.
479 /// </summary> 479 /// </summary>
480 /// <param name="mod"></param> 480 /// <param name="mod"></param>
481 /// <param name="command"></param> 481 /// <param name="command"></param>
482 /// <param name="shorthelp"></param> 482 /// <param name="shorthelp"></param>
483 /// <param name="longhelp"></param> 483 /// <param name="longhelp"></param>
484 /// <param name="callback"></param> 484 /// <param name="callback"></param>
485 public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) 485 public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback)
486 { 486 {
487 AddCommand(module, command, shorthelp, longhelp, string.Empty, callback); 487 AddCommand(module, command, shorthelp, longhelp, string.Empty, callback);
488 } 488 }
489 489
490 /// <summary> 490 /// <summary>
491 /// Call this from a region module to add a command to the OpenSim console. 491 /// Call this from a region module to add a command to the OpenSim console.
492 /// </summary> 492 /// </summary>
493 /// <param name="mod"> 493 /// <param name="mod">
494 /// The use of IRegionModuleBase is a cheap trick to get a different method signature, 494 /// The use of IRegionModuleBase is a cheap trick to get a different method signature,
495 /// though all new modules should be using interfaces descended from IRegionModuleBase anyway. 495 /// though all new modules should be using interfaces descended from IRegionModuleBase anyway.
496 /// </param> 496 /// </param>
497 /// <param name="category"> 497 /// <param name="category">
498 /// Category of the command. This is the section under which it will appear when the user asks for help 498 /// Category of the command. This is the section under which it will appear when the user asks for help
499 /// </param> 499 /// </param>
500 /// <param name="command"></param> 500 /// <param name="command"></param>
501 /// <param name="shorthelp"></param> 501 /// <param name="shorthelp"></param>
502 /// <param name="longhelp"></param> 502 /// <param name="longhelp"></param>
503 /// <param name="callback"></param> 503 /// <param name="callback"></param>
504 public void AddCommand( 504 public void AddCommand(
505 string category, IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) 505 string category, IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback)
506 { 506 {
507 AddCommand(category, module, command, shorthelp, longhelp, string.Empty, callback); 507 AddCommand(category, module, command, shorthelp, longhelp, string.Empty, callback);
508 } 508 }
509 509
510 /// <summary> 510 /// <summary>
511 /// Call this from a region module to add a command to the OpenSim console. 511 /// Call this from a region module to add a command to the OpenSim console.
512 /// </summary> 512 /// </summary>
513 /// <param name="mod"></param> 513 /// <param name="mod"></param>
514 /// <param name="command"></param> 514 /// <param name="command"></param>
515 /// <param name="shorthelp"></param> 515 /// <param name="shorthelp"></param>
516 /// <param name="longhelp"></param> 516 /// <param name="longhelp"></param>
517 /// <param name="descriptivehelp"></param> 517 /// <param name="descriptivehelp"></param>
518 /// <param name="callback"></param> 518 /// <param name="callback"></param>
519 public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) 519 public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback)
520 { 520 {
521 string moduleName = ""; 521 string moduleName = "";
522 522
523 if (module != null) 523 if (module != null)
524 moduleName = module.Name; 524 moduleName = module.Name;
525 525
526 AddCommand(moduleName, module, command, shorthelp, longhelp, descriptivehelp, callback); 526 AddCommand(moduleName, module, command, shorthelp, longhelp, descriptivehelp, callback);
527 } 527 }
528 528
529 /// <summary> 529 /// <summary>
530 /// Call this from a region module to add a command to the OpenSim console. 530 /// Call this from a region module to add a command to the OpenSim console.
531 /// </summary> 531 /// </summary>
532 /// <param name="category"> 532 /// <param name="category">
533 /// Category of the command. This is the section under which it will appear when the user asks for help 533 /// Category of the command. This is the section under which it will appear when the user asks for help
534 /// </param> 534 /// </param>
535 /// <param name="mod"></param> 535 /// <param name="mod"></param>
536 /// <param name="command"></param> 536 /// <param name="command"></param>
537 /// <param name="shorthelp"></param> 537 /// <param name="shorthelp"></param>
538 /// <param name="longhelp"></param> 538 /// <param name="longhelp"></param>
539 /// <param name="descriptivehelp"></param> 539 /// <param name="descriptivehelp"></param>
540 /// <param name="callback"></param> 540 /// <param name="callback"></param>
541 public void AddCommand( 541 public void AddCommand(
542 string category, IRegionModuleBase module, string command, 542 string category, IRegionModuleBase module, string command,
543 string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) 543 string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback)
544 { 544 {
545 if (MainConsole.Instance == null) 545 if (MainConsole.Instance == null)
546 return; 546 return;
547 547
548 bool shared = false; 548 bool shared = false;
549 549
550 if (module != null) 550 if (module != null)
551 shared = module is ISharedRegionModule; 551 shared = module is ISharedRegionModule;
552 552
553 MainConsole.Instance.Commands.AddCommand( 553 MainConsole.Instance.Commands.AddCommand(
554 category, shared, command, shorthelp, longhelp, descriptivehelp, callback); 554 category, shared, command, shorthelp, longhelp, descriptivehelp, callback);
555 } 555 }
556 556
557 public virtual ISceneObject DeserializeObject(string representation) 557 public virtual ISceneObject DeserializeObject(string representation)
558 { 558 {
559 return null; 559 return null;
560 } 560 }
561 561
562 public virtual bool AllowScriptCrossings 562 public virtual bool AllowScriptCrossings
563 { 563 {
564 get { return false; } 564 get { return false; }
565 } 565 }
566 566
567 public virtual void Start() 567 public virtual void Start()
568 { 568 {
569 } 569 }
570 570
571 public void Restart() 571 public void Restart()
572 { 572 {
573 // This has to be here to fire the event 573 // This has to be here to fire the event
574 restart handlerPhysicsCrash = OnRestart; 574 restart handlerPhysicsCrash = OnRestart;
575 if (handlerPhysicsCrash != null) 575 if (handlerPhysicsCrash != null)
576 handlerPhysicsCrash(RegionInfo); 576 handlerPhysicsCrash(RegionInfo);
577 } 577 }
578 578
579 public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); 579 public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep);
580 } 580 }
581} 581}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 257e01e..a6a963b 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -917,12 +917,14 @@ namespace OpenSim.Region.Framework.Scenes
917 // in the serialization, transfer the correct name from the inventory to the 917 // in the serialization, transfer the correct name from the inventory to the
918 // object itself before we rez. 918 // object itself before we rez.
919 // Only do these for the first object if we are rezzing a coalescence. 919 // Only do these for the first object if we are rezzing a coalescence.
920 if (i == 0) 920 // nahh dont mess with coalescence objects,
921 // the name in inventory can be change for inventory purpuses only
922 if (objlist.Count == 1)
921 { 923 {
922 rootPart.Name = item.Name; 924 rootPart.Name = item.Name;
923 rootPart.Description = item.Description; 925 rootPart.Description = item.Description;
924 } 926 }
925 927/* reverted to old code till part.ApplyPermissionsOnRez is better reviewed/fixed
926 group.SetGroup(m_part.GroupID, null); 928 group.SetGroup(m_part.GroupID, null);
927 929
928 foreach (SceneObjectPart part in group.Parts) 930 foreach (SceneObjectPart part in group.Parts)
@@ -938,7 +940,49 @@ namespace OpenSim.Region.Framework.Scenes
938 940
939 part.ApplyPermissionsOnRez(dest, false, m_part.ParentGroup.Scene); 941 part.ApplyPermissionsOnRez(dest, false, m_part.ParentGroup.Scene);
940 } 942 }
943*/
944// old code start
945 SceneObjectPart[] partList = group.Parts;
946
947 group.SetGroup(m_part.GroupID, null);
948
949 // TODO: Remove magic number badness
950 if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number
951 {
952 if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions())
953 {
954 foreach (SceneObjectPart part in partList)
955 {
956 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
957 part.EveryoneMask = item.EveryonePermissions;
958 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
959 part.NextOwnerMask = item.NextPermissions;
960 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
961 part.GroupMask = item.GroupPermissions;
962 }
941 963
964 group.ApplyNextOwnerPermissions();
965 }
966 }
967
968 foreach (SceneObjectPart part in partList)
969 {
970 // TODO: Remove magic number badness
971 if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number
972 {
973 part.LastOwnerID = part.OwnerID;
974 part.OwnerID = item.OwnerID;
975 part.Inventory.ChangeInventoryOwner(item.OwnerID);
976 }
977
978 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
979 part.EveryoneMask = item.EveryonePermissions;
980 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
981 part.NextOwnerMask = item.NextPermissions;
982 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
983 part.GroupMask = item.GroupPermissions;
984 }
985// old code end
942 rootPart.TrimPermissions(); 986 rootPart.TrimPermissions();
943 } 987 }
944 988
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 24a92eb..8fae032 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3369,11 +3369,7 @@ namespace OpenSim.Region.Framework.Scenes
3369 3369
3370 public void SendTerseUpdateToAgentClient(ScenePresence p) 3370 public void SendTerseUpdateToAgentClient(ScenePresence p)
3371 { 3371 {
3372 // messy checks because a client doesn't know what presence it belongs too
3373
3374 IClientAPI remoteClient = p.ControllingClient; 3372 IClientAPI remoteClient = p.ControllingClient;
3375 if (remoteClient == null)
3376 return;
3377 3373
3378 if (!remoteClient.IsActive) 3374 if (!remoteClient.IsActive)
3379 return; 3375 return;
@@ -3381,7 +3377,6 @@ namespace OpenSim.Region.Framework.Scenes
3381 if (ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID && p.GodLevel < 200) 3377 if (ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID && p.GodLevel < 200)
3382 return; 3378 return;
3383 3379
3384
3385 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); 3380 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity);
3386 remoteClient.SendEntityUpdate( 3381 remoteClient.SendEntityUpdate(
3387 this, 3382 this,
@@ -3507,7 +3502,7 @@ namespace OpenSim.Region.Framework.Scenes
3507 // If we aren't using a cached appearance, then clear out the baked textures 3502 // If we aren't using a cached appearance, then clear out the baked textures
3508 if (!cachedappearance) 3503 if (!cachedappearance)
3509 { 3504 {
3510 Appearance.ResetAppearance(); 3505// Appearance.ResetAppearance();
3511// save what ???? 3506// save what ????
3512// maybe needed so the tryretry repair works? 3507// maybe needed so the tryretry repair works?
3513 if (m_scene.AvatarFactory != null) 3508 if (m_scene.AvatarFactory != null)
@@ -3530,7 +3525,7 @@ namespace OpenSim.Region.Framework.Scenes
3530 // send even grays 3525 // send even grays
3531 if (cachedappearance) 3526 if (cachedappearance)
3532 { 3527 {
3533 m_log.DebugFormat("[SCENE PRESENCE]: Baked textures are in the cache for {0} in {1}", Name, m_scene.Name); 3528// m_log.DebugFormat("[SCENE PRESENCE]: Baked textures are in the cache for {0} in {1}", Name, m_scene.Name);
3534 // If the avatars baked textures are all in the cache, then we have a 3529 // If the avatars baked textures are all in the cache, then we have a
3535 // complete appearance... send it out, if not, then we'll send it when 3530 // complete appearance... send it out, if not, then we'll send it when
3536 // the avatar finishes updating its appearance 3531 // the avatar finishes updating its appearance