diff options
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/AssetCache.cs')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetCache.cs | 69 |
1 files changed, 43 insertions, 26 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 3866e21..c08bef2 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs | |||
@@ -137,6 +137,16 @@ namespace OpenSim.Framework.Communications.Caches | |||
137 | return asset; | 137 | return asset; |
138 | } | 138 | } |
139 | 139 | ||
140 | public AssetBase GetAsset(LLUUID assetID, bool isTexture) | ||
141 | { | ||
142 | AssetBase asset = GetAsset(assetID); | ||
143 | if (asset == null) | ||
144 | { | ||
145 | this._assetServer.RequestAsset(assetID, isTexture); | ||
146 | } | ||
147 | return asset; | ||
148 | } | ||
149 | |||
140 | public void AddAsset(AssetBase asset) | 150 | public void AddAsset(AssetBase asset) |
141 | { | 151 | { |
142 | // Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); | 152 | // Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); |
@@ -241,44 +251,51 @@ namespace OpenSim.Framework.Communications.Caches | |||
241 | if (IsTexture) | 251 | if (IsTexture) |
242 | { | 252 | { |
243 | // Console.WriteLine("asset recieved from asset server"); | 253 | // Console.WriteLine("asset recieved from asset server"); |
254 | |||
244 | TextureImage image = new TextureImage(asset); | 255 | TextureImage image = new TextureImage(asset); |
245 | this.Textures.Add(image.FullID, image); | 256 | if (!this.Textures.ContainsKey(image.FullID)) |
246 | if (this.RequestedTextures.ContainsKey(image.FullID)) | ||
247 | { | 257 | { |
248 | AssetRequest req = this.RequestedTextures[image.FullID]; | 258 | this.Textures.Add(image.FullID, image); |
249 | req.ImageInfo = image; | 259 | if (this.RequestedTextures.ContainsKey(image.FullID)) |
250 | if (image.Data.LongLength > 600) | ||
251 | { | ||
252 | //over 600 bytes so split up file | ||
253 | req.NumPackets = 1 + (int)(image.Data.Length - 600 ) / 1000; | ||
254 | } | ||
255 | else | ||
256 | { | 260 | { |
257 | req.NumPackets = 1; | 261 | AssetRequest req = this.RequestedTextures[image.FullID]; |
262 | req.ImageInfo = image; | ||
263 | if (image.Data.LongLength > 600) | ||
264 | { | ||
265 | //over 600 bytes so split up file | ||
266 | req.NumPackets = 1 + (int)(image.Data.Length - 600) / 1000; | ||
267 | } | ||
268 | else | ||
269 | { | ||
270 | req.NumPackets = 1; | ||
271 | } | ||
272 | this.RequestedTextures.Remove(image.FullID); | ||
273 | this.TextureRequests.Add(req); | ||
258 | } | 274 | } |
259 | this.RequestedTextures.Remove(image.FullID); | ||
260 | this.TextureRequests.Add(req); | ||
261 | } | 275 | } |
262 | } | 276 | } |
263 | else | 277 | else |
264 | { | 278 | { |
265 | AssetInfo assetInf = new AssetInfo(asset); | 279 | AssetInfo assetInf = new AssetInfo(asset); |
266 | this.Assets.Add(assetInf.FullID, assetInf); | 280 | if (!this.Assets.ContainsKey(assetInf.FullID)) |
267 | if (this.RequestedAssets.ContainsKey(assetInf.FullID)) | ||
268 | { | 281 | { |
269 | AssetRequest req = this.RequestedAssets[assetInf.FullID]; | 282 | this.Assets.Add(assetInf.FullID, assetInf); |
270 | req.AssetInf = assetInf; | 283 | if (this.RequestedAssets.ContainsKey(assetInf.FullID)) |
271 | if (assetInf.Data.LongLength > 600) | ||
272 | { | ||
273 | //over 600 bytes so split up file | ||
274 | req.NumPackets = 1 + (int)(assetInf.Data.Length - 600 + 999) / 1000; | ||
275 | } | ||
276 | else | ||
277 | { | 284 | { |
278 | req.NumPackets = 1; | 285 | AssetRequest req = this.RequestedAssets[assetInf.FullID]; |
286 | req.AssetInf = assetInf; | ||
287 | if (assetInf.Data.LongLength > 600) | ||
288 | { | ||
289 | //over 600 bytes so split up file | ||
290 | req.NumPackets = 1 + (int)(assetInf.Data.Length - 600 + 999) / 1000; | ||
291 | } | ||
292 | else | ||
293 | { | ||
294 | req.NumPackets = 1; | ||
295 | } | ||
296 | this.RequestedAssets.Remove(assetInf.FullID); | ||
297 | this.AssetRequests.Add(req); | ||
279 | } | 298 | } |
280 | this.RequestedAssets.Remove(assetInf.FullID); | ||
281 | this.AssetRequests.Add(req); | ||
282 | } | 299 | } |
283 | } | 300 | } |
284 | } | 301 | } |