diff options
author | Teravus Ovares | 2008-11-14 14:42:00 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-11-14 14:42:00 +0000 |
commit | 3e4b094921dddfe10f6ee5f73eb1b917381c2c30 (patch) | |
tree | 7cdce613258028725b555e43ad0125081a2fc305 /OpenSim/Region | |
parent | reverting #7295, as it still fails a test case (as pointed out very (diff) | |
download | opensim-SC_OLD-3e4b094921dddfe10f6ee5f73eb1b917381c2c30.zip opensim-SC_OLD-3e4b094921dddfe10f6ee5f73eb1b917381c2c30.tar.gz opensim-SC_OLD-3e4b094921dddfe10f6ee5f73eb1b917381c2c30.tar.bz2 opensim-SC_OLD-3e4b094921dddfe10f6ee5f73eb1b917381c2c30.tar.xz |
* Implements terrain raw upload. You can now upload your .raw terrain files using the Estate Tools.
* Could this be extended in the future to support .oar uploads too? Only time will tell!
Diffstat (limited to 'OpenSim/Region')
7 files changed, 287 insertions, 3 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 09e4160..bb43750 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -172,6 +172,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
172 | private RequestXfer handlerRequestXfer; //OnRequestXfer; | 172 | private RequestXfer handlerRequestXfer; //OnRequestXfer; |
173 | private XferReceive handlerXferReceive; //OnXferReceive; | 173 | private XferReceive handlerXferReceive; //OnXferReceive; |
174 | private ConfirmXfer handlerConfirmXfer; //OnConfirmXfer; | 174 | private ConfirmXfer handlerConfirmXfer; //OnConfirmXfer; |
175 | private AbortXfer handlerAbortXfer; | ||
175 | private CreateInventoryFolder handlerCreateInventoryFolder; //OnCreateNewInventoryFolder; | 176 | private CreateInventoryFolder handlerCreateInventoryFolder; //OnCreateNewInventoryFolder; |
176 | private UpdateInventoryFolder handlerUpdateInventoryFolder; | 177 | private UpdateInventoryFolder handlerUpdateInventoryFolder; |
177 | private MoveInventoryFolder handlerMoveInventoryFolder; | 178 | private MoveInventoryFolder handlerMoveInventoryFolder; |
@@ -206,6 +207,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
206 | private ParcelGodForceOwner handlerParcelGodForceOwner; | 207 | private ParcelGodForceOwner handlerParcelGodForceOwner; |
207 | private ParcelReclaim handlerParcelReclaim; | 208 | private ParcelReclaim handlerParcelReclaim; |
208 | private RequestTerrain handlerRequestTerrain; | 209 | private RequestTerrain handlerRequestTerrain; |
210 | private RequestTerrain handlerUploadTerrain; | ||
209 | private ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest; | 211 | private ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest; |
210 | private RegionInfoRequest handlerRegionInfoRequest; //OnRegionInfoRequest; | 212 | private RegionInfoRequest handlerRegionInfoRequest; //OnRegionInfoRequest; |
211 | private EstateCovenantRequest handlerEstateCovenantRequest; //OnEstateCovenantRequest; | 213 | private EstateCovenantRequest handlerEstateCovenantRequest; //OnEstateCovenantRequest; |
@@ -894,6 +896,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
894 | public event XferReceive OnXferReceive; | 896 | public event XferReceive OnXferReceive; |
895 | public event RequestXfer OnRequestXfer; | 897 | public event RequestXfer OnRequestXfer; |
896 | public event ConfirmXfer OnConfirmXfer; | 898 | public event ConfirmXfer OnConfirmXfer; |
899 | public event AbortXfer OnAbortXfer; | ||
897 | public event RequestTerrain OnRequestTerrain; | 900 | public event RequestTerrain OnRequestTerrain; |
898 | public event RezScript OnRezScript; | 901 | public event RezScript OnRezScript; |
899 | public event UpdateTaskInventory OnUpdateTaskInventory; | 902 | public event UpdateTaskInventory OnUpdateTaskInventory; |
@@ -941,6 +944,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
941 | public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest; | 944 | public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest; |
942 | public event SetRegionTerrainSettings OnSetRegionTerrainSettings; | 945 | public event SetRegionTerrainSettings OnSetRegionTerrainSettings; |
943 | public event BakeTerrain OnBakeTerrain; | 946 | public event BakeTerrain OnBakeTerrain; |
947 | public event RequestTerrain OnUploadTerrain; | ||
944 | public event EstateChangeInfo OnEstateChangeInfo; | 948 | public event EstateChangeInfo OnEstateChangeInfo; |
945 | public event EstateRestartSimRequest OnEstateRestartSimRequest; | 949 | public event EstateRestartSimRequest OnEstateRestartSimRequest; |
946 | public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest; | 950 | public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest; |
@@ -4937,7 +4941,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4937 | break; | 4941 | break; |
4938 | case PacketType.TransferRequest: | 4942 | case PacketType.TransferRequest: |
4939 | //Console.WriteLine("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request"); | 4943 | //Console.WriteLine("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request"); |
4944 | |||
4940 | TransferRequestPacket transfer = (TransferRequestPacket)Pack; | 4945 | TransferRequestPacket transfer = (TransferRequestPacket)Pack; |
4946 | Console.WriteLine("Transfer Request: " + transfer.ToString()); | ||
4941 | // Validate inventory transfers | 4947 | // Validate inventory transfers |
4942 | // Has to be done here, because AssetCache can't do it | 4948 | // Has to be done here, because AssetCache can't do it |
4943 | // | 4949 | // |
@@ -5032,7 +5038,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5032 | break; | 5038 | break; |
5033 | case PacketType.AssetUploadRequest: | 5039 | case PacketType.AssetUploadRequest: |
5034 | AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; | 5040 | AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; |
5035 | // Console.WriteLine("upload request " + Pack.ToString()); | 5041 | // Console.WriteLine("upload request " + request.ToString()); |
5036 | // Console.WriteLine("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString()); | 5042 | // Console.WriteLine("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString()); |
5037 | UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId); | 5043 | UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId); |
5038 | 5044 | ||
@@ -5074,6 +5080,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5074 | handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet); | 5080 | handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet); |
5075 | } | 5081 | } |
5076 | break; | 5082 | break; |
5083 | case PacketType.AbortXfer: | ||
5084 | AbortXferPacket abortXfer = (AbortXferPacket)Pack; | ||
5085 | handlerAbortXfer = OnAbortXfer; | ||
5086 | if (handlerAbortXfer != null) | ||
5087 | { | ||
5088 | handlerAbortXfer(this, abortXfer.XferID.ID); | ||
5089 | } | ||
5090 | |||
5091 | break; | ||
5077 | case PacketType.CreateInventoryFolder: | 5092 | case PacketType.CreateInventoryFolder: |
5078 | CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack; | 5093 | CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack; |
5079 | 5094 | ||
@@ -5738,7 +5753,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5738 | 5753 | ||
5739 | case PacketType.EstateOwnerMessage: | 5754 | case PacketType.EstateOwnerMessage: |
5740 | EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack; | 5755 | EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack; |
5741 | 5756 | //System.Console.WriteLine(messagePacket.ToString()); | |
5742 | switch (Utils.BytesToString(messagePacket.MethodData.Method)) | 5757 | switch (Utils.BytesToString(messagePacket.MethodData.Method)) |
5743 | { | 5758 | { |
5744 | case "getinfo": | 5759 | case "getinfo": |
@@ -5978,6 +5993,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5978 | } | 5993 | } |
5979 | } | 5994 | } |
5980 | } | 5995 | } |
5996 | if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "upload filename") | ||
5997 | { | ||
5998 | if (messagePacket.ParamList.Length > 1) | ||
5999 | { | ||
6000 | handlerUploadTerrain = OnUploadTerrain; | ||
6001 | if (handlerUploadTerrain != null) | ||
6002 | { | ||
6003 | handlerUploadTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter)); | ||
6004 | } | ||
6005 | } | ||
6006 | } | ||
6007 | |||
5981 | } | 6008 | } |
5982 | 6009 | ||
5983 | 6010 | ||
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetTransactionsManager.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetTransactionsManager.cs index be8aeea..010fcf7 100644 --- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetTransactionsManager.cs +++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetTransactionsManager.cs | |||
@@ -180,6 +180,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
180 | public void HandleUDPUploadRequest(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, | 180 | public void HandleUDPUploadRequest(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, |
181 | byte[] data, bool storeLocal, bool tempFile) | 181 | byte[] data, bool storeLocal, bool tempFile) |
182 | { | 182 | { |
183 | //System.Console.WriteLine("HandleUDPUploadRequest - assetID: " + assetID.ToString() + " transaction: " + transaction.ToString() + " type: " + type.ToString() + " storelocal: " + storeLocal + " tempFile: " + tempFile); | ||
183 | if (((AssetType)type == AssetType.Texture || | 184 | if (((AssetType)type == AssetType.Texture || |
184 | (AssetType)type == AssetType.Sound || | 185 | (AssetType)type == AssetType.Sound || |
185 | (AssetType)type == AssetType.TextureTGA || | 186 | (AssetType)type == AssetType.TextureTGA || |
@@ -219,6 +220,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
219 | /// <param name="data"></param> | 220 | /// <param name="data"></param> |
220 | public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) | 221 | public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) |
221 | { | 222 | { |
223 | //System.Console.WriteLine("xferID: " + xferID + " packetID: " + packetID + " data!"); | ||
222 | AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); | 224 | AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); |
223 | 225 | ||
224 | transactions.HandleXfer(xferID, packetID, data); | 226 | transactions.HandleXfer(xferID, packetID, data); |
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs index 09c9aef..19d7066 100644 --- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs +++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs | |||
@@ -43,6 +43,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
43 | private Scene m_scene = null; | 43 | private Scene m_scene = null; |
44 | 44 | ||
45 | private AgentAssetTransactionsManager m_transactionManager; | 45 | private AgentAssetTransactionsManager m_transactionManager; |
46 | |||
46 | 47 | ||
47 | public AssetTransactionModule() | 48 | public AssetTransactionModule() |
48 | { | 49 | { |
@@ -68,7 +69,13 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
68 | IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item) | 69 | IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item) |
69 | { | 70 | { |
70 | m_transactionManager.HandleTaskItemUpdateFromTransaction(remoteClient, part, transactionID, item); | 71 | m_transactionManager.HandleTaskItemUpdateFromTransaction(remoteClient, part, transactionID, item); |
71 | } | 72 | } |
73 | |||
74 | public void RequestXferFromClient(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, | ||
75 | byte[] data, bool storeLocal, bool tempFile) | ||
76 | { | ||
77 | m_transactionManager.HandleUDPUploadRequest(remoteClient, assetID, transaction, type, data, storeLocal, tempFile); | ||
78 | } | ||
72 | 79 | ||
73 | public void RemoveAgentAssetTransactions(UUID userID) | 80 | public void RemoveAgentAssetTransactions(UUID userID) |
74 | { | 81 | { |
diff --git a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs index 52175f4..4aad3b1 100644 --- a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs | |||
@@ -45,6 +45,8 @@ namespace OpenSim.Region.Environment.Modules.World.Estate | |||
45 | 45 | ||
46 | private Scene m_scene; | 46 | private Scene m_scene; |
47 | 47 | ||
48 | private EstateTerrainXferHandler TerrainUploader = null; | ||
49 | |||
48 | #region Packet Data Responders | 50 | #region Packet Data Responders |
49 | 51 | ||
50 | private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice) | 52 | private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice) |
@@ -420,7 +422,119 @@ namespace OpenSim.Region.Environment.Modules.World.Estate | |||
420 | } | 422 | } |
421 | } | 423 | } |
422 | } | 424 | } |
425 | private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID) | ||
426 | { | ||
427 | if (TerrainUploader != null) | ||
428 | { | ||
429 | lock (TerrainUploader) | ||
430 | { | ||
431 | if (XferID == TerrainUploader.XferID) | ||
432 | { | ||
433 | remoteClient.OnXferReceive -= TerrainUploader.XferReceive; | ||
434 | remoteClient.OnAbortXfer -= AbortTerrainXferHandler; | ||
435 | TerrainUploader.TerrainUploadDone -= HandleTerrainApplication; | ||
436 | |||
437 | TerrainUploader = null; | ||
438 | remoteClient.SendAlertMessage("Terrain Upload aborted by the client"); | ||
439 | } | ||
440 | } | ||
441 | } | ||
442 | |||
443 | } | ||
444 | private void HandleTerrainApplication(string filename, byte[] terrainData, IClientAPI remoteClient) | ||
445 | { | ||
446 | lock (TerrainUploader) | ||
447 | { | ||
448 | remoteClient.OnXferReceive -= TerrainUploader.XferReceive; | ||
449 | remoteClient.OnAbortXfer -= AbortTerrainXferHandler; | ||
450 | TerrainUploader.TerrainUploadDone -= HandleTerrainApplication; | ||
451 | |||
452 | TerrainUploader = null; | ||
453 | } | ||
454 | remoteClient.SendAlertMessage("Terrain Upload Complete. Loading...."); | ||
455 | OpenSim.Region.Environment.Modules.World.Terrain.ITerrainModule terr = m_scene.RequestModuleInterface<OpenSim.Region.Environment.Modules.World.Terrain.ITerrainModule>(); | ||
456 | |||
457 | if (terr != null) | ||
458 | { | ||
459 | m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + m_scene.RegionInfo.RegionName); | ||
460 | if (System.IO.File.Exists(Util.dataDir() + "/terrain.raw")) | ||
461 | { | ||
462 | System.IO.File.Delete(Util.dataDir() + "/terrain.raw"); | ||
463 | } | ||
464 | try | ||
465 | { | ||
466 | System.IO.FileStream input = new System.IO.FileStream(Util.dataDir() + "/terrain.raw", System.IO.FileMode.CreateNew); | ||
467 | input.Write(terrainData, 0, terrainData.Length); | ||
468 | input.Close(); | ||
469 | } | ||
470 | catch (System.IO.IOException e) | ||
471 | { | ||
472 | m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString()); | ||
473 | remoteClient.SendAlertMessage("There was an IO Exception loading your terrain. Please check free space"); | ||
474 | |||
475 | return; | ||
476 | } | ||
477 | catch (System.Security.SecurityException e) | ||
478 | { | ||
479 | m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString()); | ||
480 | remoteClient.SendAlertMessage("There was a security Exception loading your terrain. Please check the security on the simulator drive"); | ||
481 | |||
482 | return; | ||
483 | } | ||
484 | catch (System.UnauthorizedAccessException e) | ||
485 | { | ||
486 | m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString()); | ||
487 | remoteClient.SendAlertMessage("There was a security Exception loading your terrain. Please check the security on the simulator drive"); | ||
423 | 488 | ||
489 | return; | ||
490 | } | ||
491 | |||
492 | |||
493 | |||
494 | |||
495 | try | ||
496 | { | ||
497 | terr.LoadFromFile(Util.dataDir() + "/terrain.raw"); | ||
498 | remoteClient.SendAlertMessage("Your terrain was loaded. Give it a minute or two to apply"); | ||
499 | } | ||
500 | catch (Exception e) | ||
501 | { | ||
502 | m_log.ErrorFormat("[TERRAIN]: Error loading a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString()); | ||
503 | remoteClient.SendAlertMessage("There was a general error loading your terrain. Please fix the terrain file and try again"); | ||
504 | } | ||
505 | |||
506 | } | ||
507 | else | ||
508 | { | ||
509 | remoteClient.SendAlertMessage("Unable to apply terrain. Cannot get an instance of the terrain module"); | ||
510 | } | ||
511 | |||
512 | |||
513 | |||
514 | } | ||
515 | |||
516 | private void handleUploadTerrain(IClientAPI remote_client, string clientFileName) | ||
517 | { | ||
518 | |||
519 | if (TerrainUploader == null) | ||
520 | { | ||
521 | |||
522 | TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName); | ||
523 | lock (TerrainUploader) | ||
524 | { | ||
525 | remote_client.OnXferReceive += TerrainUploader.XferReceive; | ||
526 | remote_client.OnAbortXfer += AbortTerrainXferHandler; | ||
527 | TerrainUploader.TerrainUploadDone += HandleTerrainApplication; | ||
528 | } | ||
529 | TerrainUploader.RequestStartXfer(remote_client); | ||
530 | |||
531 | } | ||
532 | else | ||
533 | { | ||
534 | remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!"); | ||
535 | } | ||
536 | |||
537 | } | ||
424 | private void handleTerrainRequest(IClientAPI remote_client, string clientFileName) | 538 | private void handleTerrainRequest(IClientAPI remote_client, string clientFileName) |
425 | { | 539 | { |
426 | // Save terrain here | 540 | // Save terrain here |
@@ -793,6 +907,7 @@ namespace OpenSim.Region.Environment.Modules.World.Estate | |||
793 | client.OnEstateTeleportOneUserHomeRequest += handleEstateTeleportOneUserHomeRequest; | 907 | client.OnEstateTeleportOneUserHomeRequest += handleEstateTeleportOneUserHomeRequest; |
794 | client.OnEstateTeleportAllUsersHomeRequest += handleEstateTeleportAllUsersHomeRequest; | 908 | client.OnEstateTeleportAllUsersHomeRequest += handleEstateTeleportAllUsersHomeRequest; |
795 | client.OnRequestTerrain += handleTerrainRequest; | 909 | client.OnRequestTerrain += handleTerrainRequest; |
910 | client.OnUploadTerrain += handleUploadTerrain; | ||
796 | 911 | ||
797 | client.OnRegionInfoRequest += HandleRegionInfoRequest; | 912 | client.OnRegionInfoRequest += HandleRegionInfoRequest; |
798 | client.OnEstateCovenantRequest += HandleEstateCovenantRequest; | 913 | client.OnEstateCovenantRequest += HandleEstateCovenantRequest; |
diff --git a/OpenSim/Region/Environment/Modules/World/Estate/EstateTerrainXferHandler.cs b/OpenSim/Region/Environment/Modules/World/Estate/EstateTerrainXferHandler.cs new file mode 100644 index 0000000..3ee633e --- /dev/null +++ b/OpenSim/Region/Environment/Modules/World/Estate/EstateTerrainXferHandler.cs | |||
@@ -0,0 +1,129 @@ | |||
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 OpenSim 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 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Communications.Cache; | ||
35 | using OpenSim.Region.Environment.Scenes; | ||
36 | |||
37 | |||
38 | namespace OpenSim.Region.Environment.Modules.World.Estate | ||
39 | { | ||
40 | |||
41 | public class EstateTerrainXferHandler | ||
42 | { | ||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | |||
45 | private AssetBase m_asset; | ||
46 | |||
47 | public delegate void TerrainUploadComplete(string name, byte[] filedata, IClientAPI remoteClient); | ||
48 | |||
49 | public event TerrainUploadComplete TerrainUploadDone; | ||
50 | |||
51 | private string m_description = String.Empty; | ||
52 | private string m_name = String.Empty; | ||
53 | private UUID TransactionID = UUID.Zero; | ||
54 | private sbyte type = 0; | ||
55 | |||
56 | public ulong mXferID; | ||
57 | private TerrainUploadComplete handlerTerrainUploadDone; | ||
58 | |||
59 | |||
60 | |||
61 | public EstateTerrainXferHandler(IClientAPI pRemoteClient, string pClientFilename) | ||
62 | { | ||
63 | |||
64 | m_asset = new AssetBase(); | ||
65 | m_asset.FullID = UUID.Zero; | ||
66 | m_asset.Type = type; | ||
67 | m_asset.Data = new byte[0]; | ||
68 | m_asset.Name = pClientFilename; | ||
69 | m_asset.Description = "empty"; | ||
70 | m_asset.Local = true; | ||
71 | m_asset.Temporary = true; | ||
72 | |||
73 | } | ||
74 | |||
75 | public ulong XferID | ||
76 | { | ||
77 | get { return mXferID; } | ||
78 | } | ||
79 | |||
80 | public void RequestStartXfer(IClientAPI pRemoteClient) | ||
81 | { | ||
82 | mXferID = Util.GetNextXferID(); | ||
83 | pRemoteClient.SendXferRequest(mXferID, m_asset.Type, m_asset.FullID, 0, Utils.StringToBytes(m_asset.Name)); | ||
84 | } | ||
85 | |||
86 | /// <summary> | ||
87 | /// Process transfer data received from the client. | ||
88 | /// </summary> | ||
89 | /// <param name="xferID"></param> | ||
90 | /// <param name="packetID"></param> | ||
91 | /// <param name="data"></param> | ||
92 | public void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) | ||
93 | { | ||
94 | if (mXferID == xferID) | ||
95 | { | ||
96 | if (m_asset.Data.Length > 1) | ||
97 | { | ||
98 | byte[] destinationArray = new byte[m_asset.Data.Length + data.Length]; | ||
99 | Array.Copy(m_asset.Data, 0, destinationArray, 0, m_asset.Data.Length); | ||
100 | Array.Copy(data, 0, destinationArray, m_asset.Data.Length, data.Length); | ||
101 | m_asset.Data = destinationArray; | ||
102 | } | ||
103 | else | ||
104 | { | ||
105 | byte[] buffer2 = new byte[data.Length - 4]; | ||
106 | Array.Copy(data, 4, buffer2, 0, data.Length - 4); | ||
107 | m_asset.Data = buffer2; | ||
108 | } | ||
109 | |||
110 | remoteClient.SendConfirmXfer(xferID, packetID); | ||
111 | |||
112 | if ((packetID & 0x80000000) != 0) | ||
113 | { | ||
114 | SendCompleteMessage(remoteClient); | ||
115 | |||
116 | } | ||
117 | } | ||
118 | } | ||
119 | |||
120 | public void SendCompleteMessage(IClientAPI remoteClient) | ||
121 | { | ||
122 | handlerTerrainUploadDone = TerrainUploadDone; | ||
123 | if (handlerTerrainUploadDone != null) | ||
124 | { | ||
125 | handlerTerrainUploadDone(m_asset.Name,m_asset.Data, remoteClient); | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs index ba73a31..de0a41a 100644 --- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs | |||
@@ -243,6 +243,7 @@ namespace OpenSim.Region.Environment.Modules.World.NPC | |||
243 | public event UDPAssetUploadRequest OnAssetUploadRequest; | 243 | public event UDPAssetUploadRequest OnAssetUploadRequest; |
244 | public event XferReceive OnXferReceive; | 244 | public event XferReceive OnXferReceive; |
245 | public event RequestXfer OnRequestXfer; | 245 | public event RequestXfer OnRequestXfer; |
246 | public event AbortXfer OnAbortXfer; | ||
246 | public event ConfirmXfer OnConfirmXfer; | 247 | public event ConfirmXfer OnConfirmXfer; |
247 | public event RezScript OnRezScript; | 248 | public event RezScript OnRezScript; |
248 | public event UpdateTaskInventory OnUpdateTaskInventory; | 249 | public event UpdateTaskInventory OnUpdateTaskInventory; |
@@ -269,6 +270,7 @@ namespace OpenSim.Region.Environment.Modules.World.NPC | |||
269 | public event RegionInfoRequest OnRegionInfoRequest; | 270 | public event RegionInfoRequest OnRegionInfoRequest; |
270 | public event EstateCovenantRequest OnEstateCovenantRequest; | 271 | public event EstateCovenantRequest OnEstateCovenantRequest; |
271 | public event RequestTerrain OnRequestTerrain; | 272 | public event RequestTerrain OnRequestTerrain; |
273 | public event RequestTerrain OnUploadTerrain; | ||
272 | public event ObjectDuplicateOnRay OnObjectDuplicateOnRay; | 274 | public event ObjectDuplicateOnRay OnObjectDuplicateOnRay; |
273 | 275 | ||
274 | public event FriendActionDelegate OnApproveFriendRequest; | 276 | public event FriendActionDelegate OnApproveFriendRequest; |
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 8317fcc..761d2aa 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs | |||
@@ -137,9 +137,11 @@ namespace OpenSim.Region.Examples.SimpleModule | |||
137 | public event MoveInventoryItem OnMoveInventoryItem; | 137 | public event MoveInventoryItem OnMoveInventoryItem; |
138 | public event UDPAssetUploadRequest OnAssetUploadRequest; | 138 | public event UDPAssetUploadRequest OnAssetUploadRequest; |
139 | public event RequestTerrain OnRequestTerrain; | 139 | public event RequestTerrain OnRequestTerrain; |
140 | public event RequestTerrain OnUploadTerrain; | ||
140 | public event XferReceive OnXferReceive; | 141 | public event XferReceive OnXferReceive; |
141 | public event RequestXfer OnRequestXfer; | 142 | public event RequestXfer OnRequestXfer; |
142 | public event ConfirmXfer OnConfirmXfer; | 143 | public event ConfirmXfer OnConfirmXfer; |
144 | public event AbortXfer OnAbortXfer; | ||
143 | public event RezScript OnRezScript; | 145 | public event RezScript OnRezScript; |
144 | public event UpdateTaskInventory OnUpdateTaskInventory; | 146 | public event UpdateTaskInventory OnUpdateTaskInventory; |
145 | public event MoveTaskInventory OnMoveTaskItem; | 147 | public event MoveTaskInventory OnMoveTaskItem; |